@ Override public Font getFont ( AttributeSet attr ) { boolean bUnderline = StyleConstants . isUnderline ( attr ) ; boolean bStrikethrough = StyleConstants . isStrikeThrough ( attr ) ; if ( ! bUnderline && ! bStrikethrough ) { // StyleContext ignores the Underline and Strikethrough attribute return getFont ( attr , getFontFamily ( attr ) ) ; } // Must build the font via TextAttribute map to support Underlined and Strikethrough text Map < TextAttribute , Object > map = new HashMap < TextAttribute , Object > ( ) ; map . put ( TextAttribute . FAMILY , getFontFamily ( attr ) ) ; map . put ( TextAttribute . SIZE , ( float ) getFontSize ( ) ) ; map . put ( TextAttribute . WEIGHT , StyleConstants . isBold ( attr ) ? TextAttribute . WEIGHT_BOLD : TextAttribute . WEIGHT_REGULAR ) ; map . put ( TextAttribute . POSTURE , StyleConstants . isItalic ( attr ) ? TextAttribute . POSTURE_OBLIQUE : TextAttribute . POSTURE_REGULAR ) ; if ( bUnderline ) { map . put ( TextAttribute . UNDERLINE , TextAttribute . UNDERLINE_ON ) ; if ( attr . getAttribute ( DASHED ) != null ) { map . put ( TextAttribute . UNDERLINE , TextAttribute . UNDERLINE_LOW_GRAY ) ; } } if ( bStrikethrough ) { map . put ( TextAttribute . STRIKETHROUGH , TextAttribute . STRIKETHROUGH_ON ) ; } Font font = _fontCache . get ( attr ) ; if ( font == null ) { font = new Font ( map ) ; _fontCache . put ( attr , font ) ; } return font ; }
Fetch the font to use for a given attribute set .