Class RunFontSelector

java.lang.Object
org.docx4j.fonts.RunFontSelector

public class RunFontSelector
extends java.lang.Object
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.
Author:
jharrop
  • Field Details

    • log

      protected static org.slf4j.Logger log
    • CSS_NAME

      public static final java.lang.String CSS_NAME
      See Also:
      Constant Field Values
    • FO_NAME

      public static final java.lang.String FO_NAME
      See Also:
      Constant Field Values
  • Constructor Details

  • Method Details

    • getCssName

      public java.lang.String getCssName()
    • getDefaultFont

      public java.lang.String getDefaultFont()
    • createElement

      public org.w3c.dom.Element createElement​(org.w3c.dom.Document document)
    • setAttribute

      public void setAttribute​(org.w3c.dom.Element el, java.lang.String fontName)
    • fontSelector

      public java.lang.Object fontSelector​(PPr pPr, RPr rPr, Text wmlText)
      Apply font selection algorithm to this Text, based on supplied PPr, RPr (and docDefaults, Theme part etc).
      Parameters:
      pPr -
      rPr -
      wmlText -
      Returns:
    • fontSelector

      public java.lang.Object fontSelector​(PPr pPr, RPr rPr, java.lang.String text)
      Apply font selection algorithm to this Text, based on supplied PPr, RPr (and docDefaults, Theme part etc).
      Parameters:
      pPr -
      rPr -
      wmlText -
      Returns: