예제 #1
0
 /** Copy text attributes from the supplied Font to Java2D AttributedString */
 private static void copyAttributes(Font font, AttributedString str, int startIdx, int endIdx) {
   str.addAttribute(TextAttribute.FAMILY, font.getFontName(), startIdx, endIdx);
   str.addAttribute(TextAttribute.SIZE, (float) font.getFontHeightInPoints());
   if (font.getBoldweight() == Font.BOLDWEIGHT_BOLD)
     str.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, startIdx, endIdx);
   if (font.getItalic())
     str.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, startIdx, endIdx);
   if (font.getUnderline() == Font.U_SINGLE)
     str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, startIdx, endIdx);
 }
  protected SFont createZssFont(Font poiFont) {
    SFont font = book.createFont(true);
    // font
    font.setName(poiFont.getFontName());
    font.setBoldweight(PoiEnumConversion.toBoldweight(poiFont.getBoldweight()));
    font.setItalic(poiFont.getItalic());
    font.setStrikeout(poiFont.getStrikeout());
    font.setUnderline(PoiEnumConversion.toUnderline(poiFont.getUnderline()));

    font.setHeightPoints(poiFont.getFontHeightInPoints());
    font.setTypeOffset(PoiEnumConversion.toTypeOffset(poiFont.getTypeOffset()));
    font.setColor(book.createColor(BookHelper.getFontHTMLColor(workbook, poiFont)));

    return font;
  }
예제 #3
0
 /** 單元格的字体 workbook excel font --字体模型 */
 public static XSSFFont getXSSFFont(XSSFWorkbook workbook, Font f) {
   XSSFFont font = workbook.createFont();
   // 字体名称
   font.setFontName(f.getFontNm());
   // 字号
   font.setFontHeightInPoints(f.getFontSize());
   // 字体颜色
   font.setColor(f.getFontColor());
   // 下划线
   font.setUnderline(f.getUnderline());
   // 上标下标
   font.setTypeOffset(f.getOffset());
   // 删除线
   font.setStrikeout(f.getDelLine());
   // 加粗
   font.setBoldweight(f.getBold());
   // 斜线
   font.setItalic(f.getItalic());
   // 字体高度
   // font.setFontHeight(arg0);
   return font;
 }