PrintDocument for WinForms
埋め込みフォント
PrintDocument ライブラリ > 埋め込みフォント

When a C1PrintDocument is saved as a C1DX or C1D file, fonts used in the document may be embedded in that file. In that case, when that document is loaded from the file on a different system, text drawn with fonts that have been embedded is guaranteed to render correctly even if the current system does not have all the original fonts installed. Font embedding may be particularly useful when rare or specialized fonts are used (such as, a font drawing barcodes). Note that when a font is embedded in a C1PrintDocument that does not mean that all glyphs from that font are embedded. Instead, just the glyphs actually used in the font are embedded.

The following C1PrintDocument properties are related to font embedding:

Font Substitution

When a text is rendered using a font, and a glyph appears in the text that is not present in the specified font, a substitute font may be selected to render that glyph. For instance, if the Arial font is used to render Japanese hieroglyphs, Arial Unicode MS font may be used to actually render the text. C1PrintDocument can analyze this and add the actual fonts used (rather than those specified) to the DocumentFonts and/or EmbeddedFonts collections. To do that, the FontHandling must be set to FontHandling.BuildActualDocumentFonts or FontHandling.EmbedActualFonts. The downside to those settings is that it takes time, making the document generate slower. Hence it may be recommended that those settings are used only if the document contains characters that may be missing from the fonts that are specified (for example, text in Far Eastern languages using common Latin fonts).

When font substitution is analyzed, the following predefined set of fonts is searched for the best matching font containing the missing glyphs:

Selective Font Embedding

If your document uses a specialized font along with the commonly available fonts such as Arial, you may want to embed just that specialized font (or several fonts) without embedding all fonts used in the document. To do that, follow these steps:

  1. Set FontHandling to a value other than FontHandling.EmbedFonts or FontHandling.EmbedActualFonts. This will leave the EmbeddedFonts collection empty when the document generates;
  2. Add the specialized fonts (they must be installed on the current system) to the document's EmbeddedFonts collection manually in code. To create an EmbeddedFont, pass the.NET Font object corresponding to your custom font to the EmbeddedFont's constructor. Add the required glyphs to the font using the EmbeddedFont.AddGlyphs method (several overloads are provided).

When a C1PrintDocument with the EmbeddedFonts collection created in this way is saved (as C1DX or C1D file), just the fonts specified in that collection are embedded in the document.