Search in sources :

Example 1 with DrawFontManager

use of org.apache.poi.sl.draw.DrawFontManager in project poi by apache.

the class HwmfGraphics method addAttributes.

private void addAttributes(AttributedString as, HwmfFont font) {
    DrawFontManager fontHandler = (DrawFontManager) graphicsCtx.getRenderingHint(Drawable.FONT_HANDLER);
    String fontFamily = null;
    @SuppressWarnings("unchecked") Map<String, String> fontMap = (Map<String, String>) graphicsCtx.getRenderingHint(Drawable.FONT_MAP);
    if (fontMap != null && fontMap.containsKey(font.getFacename())) {
        fontFamily = fontMap.get(font.getFacename());
    }
    if (fontHandler != null) {
        fontFamily = fontHandler.getRendererableFont(font.getFacename(), font.getPitchAndFamily());
    }
    if (fontFamily == null) {
        fontFamily = font.getFacename();
    }
    as.addAttribute(TextAttribute.FAMILY, fontFamily);
    as.addAttribute(TextAttribute.SIZE, getFontHeight(font));
    as.addAttribute(TextAttribute.STRIKETHROUGH, font.isStrikeOut());
    if (font.isUnderline()) {
        as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    }
    if (font.isItalic()) {
        as.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
    }
    as.addAttribute(TextAttribute.WEIGHT, font.getWeight());
}
Also used : AttributedString(java.text.AttributedString) DrawFontManager(org.apache.poi.sl.draw.DrawFontManager) Map(java.util.Map)

Aggregations

AttributedString (java.text.AttributedString)1 Map (java.util.Map)1 DrawFontManager (org.apache.poi.sl.draw.DrawFontManager)1