Main Content

Configure PDF Fonts

PDF Font Support for Languages

For PDF output, MATLAB® Report Generator™ comes configured with default fonts: a serif, a sans serif, and dingbats. It also comes configured to use the font for your language, based on your locale. You can map to a different font for your locale.

When generating PDF reports, the MATLAB Report Generator uses a font capable of rendering text in these languages:

  • English

  • Japanese

  • Korean

  • Russian (Cyrillic)

The Report Generator uses a font map to determine the font appropriate for a particular locale. The font map specifies a default set of fonts. You can modify the map to:

  • Change the fonts used for a particular locale

  • Add support for locales other than the default locales

The language font map specifies the font to use on a specific platform (for example, Windows®) and locale for basic report elements such as body text.

Identifying When to Specify a Font

If a required non-English font is missing for a report, the generated text includes pound sign characters (#). For example:

Generated text displaying as a string of pound signs

Style Sheets Override PDF Font Mapping

PDF style sheets for the MATLAB Report Generator specify fonts for body text, copyright, quotes, symbols, dingbats, monospace, sans serif, and titles.

The PDF style sheet settings override the PDF font mapping entries.

If you do not specify a PDF style sheet, then you can use PDF language font mapping entries to change the default fonts for English reports.

Non-English PDF Font Mapping Tasks

To add or modify non-English PDF font mapping specifications:

lang_font_map.xml File

Use an XML editor with the lang_font_map.xml file to enter all the PDF font mappings for your reports.

Installing the MATLAB Report Generator software loads the lang_font_map.xml file in the following location:

<matlabroot>/toolbox/shared/rptgen/resources/fontmap

The lang_font_map.xml file includes two sections:

  • name_map — Contains name_mapping elements that specify the name of the font, the language, and the font usage in the report (for example, body text).

  • file_map— Contains entries for the location of the font files for the fonts specified in the name_map.

Diagram showing that lang_font_map contains two sections, name_map and file-map

For example, the following lang_font_map.xml file includes name_map and file_map entries that provide basic PDF font support for Japanese (ja), Korean (ko), and Russian (ru).

 lang_font_map.xml example

Locate Non-English Fonts

The system from which you generate a report using the language font map must have access to the appropriate non-English fonts.

Use one of these font formats for non-English font support:

  • Type 1 (PostScript®)

  • TrueType

  • OpenType®

Fonts in other formats, such as bitmap fonts for the X Window System (X11), produce poor MATLAB Report Generator report output.

Some TrueType fonts are grouped into packages called TrueType Collections. To specify a collection in the language font map file, specify the individual font within the TrueType Collection.

In addition to the font name, the weight (e.g., bold) and slant (e.g., italic, oblique) may distinguish one font from another in the same family.

The approach you use to identify font names depends on your computer platform.

 Font names on Windows

 Font names on Mac OS X

 Font names on Linux

Add or Modify Language Font Mappings

In the name_map section of the lang_font_map.xml file, add a separate name_mapping entry for each combination of language, font, and usage that you want in PDF reports.

Each name_mapping element has three attributes:

  • lang specifies the two letter ISO 639-1 code corresponding to the language of the report.

  • platform specifies the operating system platform:

    • win — Windows

    • macMac OS X

    • glnx— Linux

  • usage specifies the kind of report element or font:

    • body

    • title

    • monospaced

    • sans (sanserif)

The text of the name_mapping element is a font name, as specified in an XSL-FO style sheet.

Here is an example name_mapping entry:

<name_mapping_lang="ja" platform="win" usage="body">MS Gothic</name_mapping>

Specify the Location of Font Files

In the file_map section, add a file_mapping entry that identifies the location of the font file for each font that you include in the name_map section.

Each of the platforms (Windows, Mac, and Linux) has a different default search path for fonts. If the lang_font_map.xml file does not contain a full file path for a font, the MATLAB Report Generator uses a platform-specific approach to search for the font.

 Windows Font File Locations

 Mac Font File Locations

 Linux Font File Locations