List of usage examples for java.awt.font TextAttribute FAMILY
TextAttribute FAMILY
To view the source code for java.awt.font TextAttribute FAMILY.
Click Source Link
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java
private PdfTextSpec computeFont(final RichTextSpec.StyledChunk c) { final StyleSheet layoutContext = c.getStyleSheet(); final PdfGraphics2D g2 = (PdfGraphics2D) getGraphics(); final PdfContentByte cb = g2.getRawContentByte(); final TypedMapWrapper<Attribute, Object> attributes = new TypedMapWrapper<Attribute, Object>( c.getAttributes());/*from w w w.j av a 2 s . c o m*/ final String fontName = attributes.get(TextAttribute.FAMILY, String.class); final Number fontSize = attributes.get(TextAttribute.SIZE, 10f, Number.class); final String encoding = (String) layoutContext.getStyleProperty(TextStyleKeys.FONTENCODING); final boolean embed = globalEmbed || layoutContext.getBooleanStyleProperty(TextStyleKeys.EMBEDDED_FONT); final Float weightRaw = attributes.get(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR, Float.class); final Float italicsRaw = attributes.get(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, Float.class); final BaseFontFontMetrics fontMetrics = getMetaData().getBaseFontFontMetrics(fontName, fontSize.doubleValue(), weightRaw >= TextAttribute.WEIGHT_DEMIBOLD, italicsRaw >= TextAttribute.POSTURE_OBLIQUE, encoding, embed, false); return new PdfTextSpec(layoutContext, getMetaData(), g2, fontMetrics, cb); }
From source file:org.zkoss.poi.ss.util.SheetUtil.java
/** * Copy text attributes from the supplied Font to Java2D AttributedString *///w ww . ja v a 2 s.c o m 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); }