org.apache.poi.hssf.usermodel.HSSFFont.getFontName()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.apache.poi.hssf.usermodel.HSSFFont.getFontName()方法的一些代码示例,展示了HSSFFont.getFontName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFFont.getFontName()方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFFont
类名称:HSSFFont
方法名:getFontName

HSSFFont.getFontName介绍

[英]get the name for the font (i.e. Arial)
[中]获取字体的名称(即Arial)

代码示例

代码示例来源:origin: org.apache.poi/poi

/**
 * Finds a font that matches the one with the supplied attributes
 */
@Override
public HSSFFont findFont(boolean bold, short color, short fontHeight,
             String name, boolean italic, boolean strikeout,
             short typeOffset, byte underline)
{
  int numberOfFonts = getNumberOfFontsAsInt();
  for (int i = 0; i <= numberOfFonts; i++) {
    // Remember - there is no 4!
    if(i == 4) {
      continue;
    }
    HSSFFont hssfFont = getFontAt(i);
    if (hssfFont.getBold() == bold
        && hssfFont.getColor() == color
        && hssfFont.getFontHeight() == fontHeight
        && hssfFont.getFontName().equals(name)
        && hssfFont.getItalic() == italic
        && hssfFont.getStrikeout() == strikeout
        && hssfFont.getTypeOffset() == typeOffset
        && hssfFont.getUnderline() == underline)
    {
      return hssfFont;
    }
  }
  return null;
}

代码示例来源:origin: caryyu/excel2pdf

/**
   * 將 POI Font 轉換到 iText Font
   * @param font
   * @return
   */
  public static com.itextpdf.text.Font getFont(HSSFFont font) {
    try {
      com.itextpdf.text.Font iTextFont =FontFactory.getFont(font.getFontName(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED,font.getFontHeightInPoints());
      return iTextFont;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
}

代码示例来源:origin: org.apache.poi/poi-contrib

/**
 *  Creates a new font for a specific cell style
 */
public static Font makeFont(HSSFFont font) {
 boolean isbold = font.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL;
 boolean isitalics = font.getItalic();
 int fontstyle = Font.PLAIN;
 if (isbold) {
  fontstyle = Font.BOLD;
 }
 if (isitalics) {
  fontstyle = fontstyle | Font.ITALIC;
 }
 int fontheight = font.getFontHeightInPoints();
 if (fontheight == 9) {
  //fix for stupid ol Windows
  fontheight = 10;
 }
 return new Font(font.getFontName(), fontstyle, fontheight);
}

代码示例来源:origin: org.apache.poi/poi-examples

/**
 *  Creates a new font for a specific cell style
 */
public static Font makeFont(HSSFFont font) {
 boolean isbold = font.getBold();
 boolean isitalics = font.getItalic();
 int fontstyle = Font.PLAIN;
 if (isbold) {
  fontstyle = Font.BOLD;
 }
 if (isitalics) {
  fontstyle = fontstyle | Font.ITALIC;
 }
 int fontheight = font.getFontHeightInPoints();
 if (fontheight == 9) {
  //fix for stupid ol Windows
  fontheight = 10;
 }
 return new Font(font.getFontName(), fontstyle, fontheight);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 *  Creates a new font for a specific cell style
 */
public static Font makeFont(HSSFFont font) {
 boolean isbold = font.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL;
 boolean isitalics = font.getItalic();
 int fontstyle = Font.PLAIN;
 if (isbold) {
  fontstyle = Font.BOLD;
 }
 if (isitalics) {
  fontstyle = fontstyle | Font.ITALIC;
 }
 int fontheight = font.getFontHeightInPoints();
 if (fontheight == 9) {
  //fix for stupid ol Windows
  fontheight = 10;
 }
 return new Font(font.getFontName(), fontstyle, fontheight);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

private FontMetrics getFontMetrics(HSSFFont hf){
  FontMetrics fm;
  Short pFont = hf.getIndex();
  fm = fontMetrics.get(pFont);
  if (fm == null) {
    int style;
    if (hf.getBold() || hf.getItalic()) {
      style = 0;
      if (hf.getBold()) style ^= Font.BOLD;
      if (hf.getItalic()) style ^= Font.ITALIC;
    } else {
      style = Font.PLAIN;
    }
    Font f = new java.awt.Font(hf.getFontName(), style, hf.getFontHeightInPoints());
    if (graphics == null) {
      BufferedImage i = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
      graphics = i.createGraphics();
    }
    fm = graphics.getFontMetrics(f);
    fontMetrics.put(pFont, fm);
  }
  return fm;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

protected void processCellStyleFont( HSSFWorkbook workbook,
    Element blockTarget, HSSFFont font )
{
  Triplet triplet = new Triplet();
  triplet.fontName = font.getFontName();
  triplet.bold = font.getBold();
  triplet.italic = font.getItalic();
  getFontReplacer().update( triplet );
  setBlockProperties( blockTarget, triplet );
  final HSSFColor fontColor = workbook.getCustomPalette().getColor(
      font.getColor() );
  if ( fontColor != null )
    blockTarget.setAttribute( "color",
        ExcelToHtmlUtils.getColor( fontColor ) );
  if ( font.getFontHeightInPoints() != 0 )
    blockTarget.setAttribute( "font-size", font.getFontHeightInPoints()
        + "pt" );
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * Finds a font that matches the one with the supplied attributes
 */
public HSSFFont findFont(short boldWeight, short color, short fontHeight,
             String name, boolean italic, boolean strikeout,
             short typeOffset, byte underline)
{
  for (short i=0; i<=getNumberOfFonts(); i++) {
    // Remember - there is no 4!
    if(i == 4) continue;
    HSSFFont hssfFont = getFontAt(i);
    if (hssfFont.getBoldweight() == boldWeight
        && hssfFont.getColor() == color
        && hssfFont.getFontHeight() == fontHeight
        && hssfFont.getFontName().equals(name)
        && hssfFont.getItalic() == italic
        && hssfFont.getStrikeout() == strikeout
        && hssfFont.getTypeOffset() == typeOffset
        && hssfFont.getUnderline() == underline)
    {
      return hssfFont;
    }
  }
  return null;
}

代码示例来源:origin: com.haulmont.thirdparty/poi

/**
 * Finds a font that matches the one with the supplied attributes
 */
public HSSFFont findFont(short boldWeight, short color, short fontHeight,
             String name, boolean italic, boolean strikeout,
             short typeOffset, byte underline)
{
  for (short i=0; i<=getNumberOfFonts(); i++) {
    // Remember - there is no 4!
    if(i == 4) continue;
    HSSFFont hssfFont = getFontAt(i);
    if (hssfFont.getBoldweight() == boldWeight
        && hssfFont.getColor() == color
        && hssfFont.getFontHeight() == fontHeight
        && hssfFont.getFontName().equals(name)
        && hssfFont.getItalic() == italic
        && hssfFont.getStrikeout() == strikeout
        && hssfFont.getTypeOffset() == typeOffset
        && hssfFont.getUnderline() == underline)
    {
      return hssfFont;
    }
  }
  return null;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

protected void processCellStyleFont( HSSFWorkbook workbook,
    Element blockTarget, HSSFFont font )
{
  Triplet triplet = new Triplet();
  triplet.fontName = font.getFontName();
  switch ( font.getBoldweight() )
  {
  case HSSFFont.BOLDWEIGHT_BOLD:
    triplet.bold = true;
    break;
  case HSSFFont.BOLDWEIGHT_NORMAL:
    triplet.bold = false;
    break;
  }
  if ( font.getItalic() )
  {
    triplet.italic = true;
  }
  getFontReplacer().update( triplet );
  setBlockProperties( blockTarget, triplet );
  final HSSFColor fontColor = workbook.getCustomPalette().getColor(
      font.getColor() );
  if ( fontColor != null )
    blockTarget.setAttribute( "color",
        ExcelToHtmlUtils.getColor( fontColor ) );
  if ( font.getFontHeightInPoints() != 0 )
    blockTarget.setAttribute( "font-size", font.getFontHeightInPoints()
        + "pt" );
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Finds a font that matches the one with the supplied attributes
 */
@Override
public HSSFFont findFont(boolean bold, short color, short fontHeight,
             String name, boolean italic, boolean strikeout,
             short typeOffset, byte underline)
{
  int numberOfFonts = getNumberOfFontsAsInt();
  for (int i = 0; i <= numberOfFonts; i++) {
    // Remember - there is no 4!
    if(i == 4) {
      continue;
    }
    HSSFFont hssfFont = getFontAt(i);
    if (hssfFont.getBold() == bold
        && hssfFont.getColor() == color
        && hssfFont.getFontHeight() == fontHeight
        && hssfFont.getFontName().equals(name)
        && hssfFont.getItalic() == italic
        && hssfFont.getStrikeout() == strikeout
        && hssfFont.getTypeOffset() == typeOffset
        && hssfFont.getUnderline() == underline)
    {
      return hssfFont;
    }
  }
  return null;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

if (fontheight == 9) fontheight = 10; //fix for stupid ol Windows
Font font = new Font(f.getFontName(),fontstyle,fontheight);
editor.setFont(font);

代码示例来源:origin: org.apache.poi/poi-contrib

if (fontheight == 9) fontheight = 10; //fix for stupid ol Windows
Font font = new Font(f.getFontName(),fontstyle,fontheight);
editor.setFont(font);

代码示例来源:origin: stackoverflow.com

fontNew.setCharSet(fontOld.getCharSet());
fontNew.setColor(fontOld.getColor());
fontNew.setFontName(fontOld.getFontName());
fontNew.setFontHeight(fontOld.getFontHeight());
fontNew.setItalic(fontOld.getItalic());

代码示例来源:origin: jasperreports/jasperreports

cf.getFontName().equals(fontName) &&
(cf.getColor() == forecolor) &&
(cf.getFontHeightInPoints() == fontSize) &&

代码示例来源:origin: org.apache.poi/poi-examples

Font font = new Font(f.getFontName(), fontstyle, fontheight);
editor.setFont(font);

代码示例来源:origin: cuba-platform/yarg

newFont = resultWorkbook.createFont();
newFont.setFontName(cellFont.getFontName());
newFont.setItalic(cellFont.getItalic());
newFont.setStrikeout(cellFont.getStrikeout());

代码示例来源:origin: com.haulmont.yarg/yarg

newFont = resultWorkbook.createFont();
newFont.setFontName(cellFont.getFontName());
newFont.setItalic(cellFont.getItalic());
newFont.setStrikeout(cellFont.getStrikeout());

相关文章