Package org.docx4j.fonts
Class RunFontSelector
java.lang.Object
org.docx4j.fonts.RunFontSelector
Apply the appropriate font to the characters in the run,
following the rules specified in
http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/rFonts.html
and http://msdn.microsoft.com/en-us/library/ff533743.aspx
([MS-OI29500] 2.1.87)
See also http://blogs.msdn.com/b/officeinteroperability/archive/2013/04/22/office-open-xml-themes-schemes-and-fonts.aspx
The ASCII font formats all characters in the ASCII range (character values 0–127).
This font is specified using the ascii attribute on the rFonts element.
The East Asian font formats all characters that belong to Unicode sub ranges for East Asian languages.
This font is specified using the eastAsia attribute on the rFonts element.
The complex script font formats all characters that belong to Unicode sub ranges for complex script languages.
This font is specified using the cs attribute on the rFonts element.
The high ANSI font formats all characters that belong to Unicode sub ranges other than those explicitly included
by one of the groups above. This font is specified using the hAnsi attribute on the rFonts element.
Per Tristan Davis
http://openxmldeveloper.org/discussions/formats/f/13/t/150.aspx
First, the characters are classified into the high ansi / east asian / complex script buckets [per above]
Next, we grab *one* theme font from the theme for each bucket - in the settings part, there's an element called themeFontLang
The three attributes on that specify the language to use for the characters in each bucket
Then you take the language specified for each attribute and look out for the right language in the theme - and you use that font
See also http://blogs.msdn.com/b/officeinteroperability/archive/2013/04/22/office-open-xml-themes-schemes-and-fonts.aspx
regarding what to do if the font is not available on the computer.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum(package private) static enumstatic enumstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprivate Stringprivate Styleprivate static String(package private) Stringstatic final Stringprotected static org.slf4j.Loggerprivate static RunFontSelector.MicrosoftWordNumeralOptionprivate static RunFontSelector.NativeDigitsSettingprivate static NumericShaperprivate boolean(package private) CTLanguageprivate WordprocessingMLPackage -
Constructor Summary
ConstructorsConstructorDescriptionRunFontSelector(WordprocessingMLPackage wordMLPackage, RunFontSelector.RunFontCharacterVisitor visitor, RunFontSelector.RunFontActionType outputType) -
Method Summary
Modifier and TypeMethodDescriptionprivate StringarabicNumbering(String text, BooleanDefaultTrue rtl, BooleanDefaultTrue cs, CTLanguage themeFontLang) private booleancreateElement(Document document) private voiddebugCheckGlyph(String fontName, char c) fontSelector(PPr pPr, RPr rPr, String text) Apply font selection algorithm to this Text, based on supplied PPr, RPr (and docDefaults, Theme part etc).fontSelector(PPr pPr, RPr rPr, Text wmlText) Apply font selection algorithm to this Text, based on supplied PPr, RPr (and docDefaults, Theme part etc).private StringgetCssProperty(String fontName) private Styleprivate static Stringprivate static RunFontSelector.MicrosoftWordNumeralOptionprivate static RunFontSelector.NativeDigitsSettingprivate static NumericShaperprivate StringgetPhysicalFont(String fontName) private ThemePartprivate DocumentFragmentprivate DocumentFragmentvoidsetAttribute(Element el, String fontName) private StringshapeAsArabicIndic(String text) voidprivate inttranslateUnicode2SingleByte(int cp) private ObjectunicodeRangeToFont(String text, STHint hint, String langEastAsia, String eastAsia, String ascii, String hAnsi)
-
Field Details
-
log
protected static org.slf4j.Logger log -
wordMLPackage
-
vis
-
outputType
-
fallbackFont
String fallbackFont -
themeFontLang
CTLanguage themeFontLang -
CSS_NAME
- See Also:
-
FO_NAME
- See Also:
-
defaultParagraphStyle
-
defaultFont
-
spacePreserve
private boolean spacePreserve -
EMOJI_FONT
-
numericShaperArabicIndic
-
nativeDigitsSetting
-
microsoftWordNumeralOption
-
-
Constructor Details
-
RunFontSelector
public RunFontSelector(WordprocessingMLPackage wordMLPackage, RunFontSelector.RunFontCharacterVisitor visitor, RunFontSelector.RunFontActionType outputType)
-
-
Method Details
-
getCssName
-
getThemePart
-
getDefaultPStyle
-
getDefaultFont
-
nullRPr
-
result
-
createElement
-
setAttribute
-
symbolSetAttribute
-
fontSelector
Apply font selection algorithm to this Text, based on supplied PPr, RPr (and docDefaults, Theme part etc).- Parameters:
pPr-rPr-wmlText-- Returns:
-
fontSelector
Apply font selection algorithm to this Text, based on supplied PPr, RPr (and docDefaults, Theme part etc).- Parameters:
pPr-rPr-wmlText-- Returns:
-
translateUnicode2SingleByte
private int translateUnicode2SingleByte(int cp) -
contains
-
getEmojiFont
-
unicodeRangeToFont
-
debugCheckGlyph
-
getCssProperty
-
getPhysicalFont
-
getNumericShaperArabicIndic
-
getNativeDigitsSetting
-
getMicrosoftWordNumeralOption
-
shapeAsArabicIndic
-
arabicNumbering
private String arabicNumbering(String text, BooleanDefaultTrue rtl, BooleanDefaultTrue cs, CTLanguage themeFontLang)
-