Fonts

Information about how to use fonts (including web fonts) to style documents.

Supported Fonts

Oxygen PDF Chemistry supports TTF fonts, either as local files or as web fonts, with the following limitations:
  • Some fonts may use features that are unsupported, such as the MarkGlyphSet in the GDEF table.
  • The advanced features of OTF are not supported, but the Compact Font Format (CFF) extracted from the OTF is embedded as a Type1C font.

Basic Fonts

By default, a PDF document should embed all the fonts except for a few that are considered to be available in all the PDF rendering applications, called basic fonts:

  • Times (v3) (in regular, italic, bold, and bold italic)
  • Courier (in regular, oblique, bold and bold oblique)
  • Helvetica (v3) (in regular, oblique, bold and bold oblique)
  • Symbol.
  • Zapf Dingbats.

Using Web Fonts

If the font is available from a website (such as https://fonts.google.com/), all you need to do is to select the font, along with its font weights and insert the generated @import declaration in your CSS:
@import url('https://fonts.googleapis.com/css?family=Montserrat:300,300i,400,500,700i');

section h2 {
    font-family: Montserrat, Serif;
    font-weight:500;
}
Note: You might consider adding a fallback to the remote font (Serif in the above example).

Using Installed Fonts

Suppose you want to style some elements using a font that is available on your system. On Windows, it means it was installed in the Windows/Fonts directory. In this case, you can reference it directly:
section h2 {
    font-family: Calibri;
}

Using Local Font Files

Font Files from a Directory

If you have your font files located in a directory, you can instruct Oxygen PDF Chemistry to load them. Use the -fonts-dir command line argument. In this case, just specify the name of the font directly in the font-family property, as you would for the built-in fonts. There is no need to define a @font-face in the CSS.

Font Files Next to the CSS

If the font file is not installed in the system, you can place it next to your CSS file. You will have to declare one or more @font-face structures, with the same font-family, but with possible different font-weight and font-style, as in the example below, where the TitilliumWeb font is a bundle of multiple TTF files, each one for a specific font-weight and style. The TTF files were placed in a folder next to the CSS, named fonts/titillium. In simpler cases, you might create a single @font-face structure.

@font-face {
  font-family: titillium;
  font-style: normal;
  font-weight: 400;
  src: url(fonts/titillium/TitilliumWeb-Regular.ttf) ;
}
@font-face {
  font-family: titillium;
  font-style: normal;
  font-weight: 300;
  src: url(fonts/titillium/TitilliumWeb-Light.ttf) ;
}
@font-face {
  font-family: titillium;
  font-style: normal;
  font-weight: 200;
  src: url(fonts/titillium/TitilliumWeb-ExtraLight.ttf) ;
}
@font-face {
  font-family: titillium;
  font-style: normal;
  font-weight: 600;
  src: url(fonts/titillium/TitilliumWeb-SemiBold.ttf) ;
}

section h2 {
    font-family: titillium, Serif;
}

Font Embedding

CSS Font Embedding

All the font families that are referenced from the CSS are embedded automatically in the PDF by Oxygen PDF Chemistry.

Basic Fonts Embedding

Although the basic fonts are guaranteed to be available in all PDF readers, there are some situations where you will have to embed them explicitly when using PDF/Universal Accessibility or Archiving. Because there are some copyright restrictions on these fonts, Oxygen PDF Chemistry cannot redistribute them. You will have to locate the files on your system and declare a set of font faces with the same name as the default ones, as in the following example.

Note: The following stylesheet assumes the fonts are placed in a fonts directory next to the stylesheet. The names of the fonts may differ on your platform.
@font-face{
	font-family:Times;
	font-style: normal;
	font-weight:400;
	src: url("fonts/TIMES.TTF");	
}
@font-face{
	font-family:Times;
	font-style: italic;
	font-weight:400;
	src: url("fonts/TIMESI.TTF");	
}
@font-face{
	font-family:Times;
	font-style: italic;
	font-weight:700;
	src: url("fonts/TIMESBI.TTF");
}
@font-face{
	font-family:Times;
	font-style: normal;
	font-weight:700;
	src: url("fonts/TIMESBD.TTF");	
}

/* –––––––––––––––––––––––- */

@font-face{
	font-family:Helvetica;
	font-style: normal;
	font-weight:400;
	src: url("fonts/ARIAL.TTF");
}
@font-face{
	font-family:Helvetica;
	font-style: italic;
	font-weight:400;
	src: url("fonts/ARIALI.TTF");	
}
@font-face{
	font-family:Helvetica;
	font-style: italic;
	font-weight:700;
	src: url("fonts/ARIALBI.TTF");
}
@font-face{
	font-family:Helvetica;
	font-style: normal;
	font-weight:700;
	src: url("fonts/ARIALBD.TTF");	
}

/* –––––––––––––––––––––––- */

@font-face{
	font-family:Courier;
	font-style: normal;
	font-weight:400;
	src: url("fonts/COUR.TTF");	
}
@font-face{
	font-family:Courier;
	font-style: italic;
	font-weight:400;
	src: url("fonts/COURI.TTF");
}
@font-face{
	font-family:Courier;
	font-style: italic;
	font-weight:700;
	src: url("fonts/COURBI.TTF");
}
@font-face{
	font-family:Courier;
	font-style: normal;
	font-weight:700;
	src: url("fonts/COURBD.TTF");	
}

/* –––––––––––––––––––––––- */

@font-face{
	font-family:Symbol;
	font-style: normal;
	font-weight:400;
	src: url("fonts/SYMBOL.TTF");	
}

/* –––––––––––––––––––––––- */

@font-face{
	font-family:"Zapf Dingbats";
	font-style: normal;
	font-weight:400;
	src: url("fonts/WINGDING.TTF");	
}

/* –––––––––––––––––––––––- */
@font-face{
	font-family:Any;
	font-style: normal;
	font-weight:400;
	src: url("fonts/TIMES.TTF");	
}
@font-face{
	font-family:Any;
	font-style: italic;
	font-weight:400;
	src: url("fonts/TIMESI.TTF");	
}
@font-face{
	font-family:Any;
	font-style: italic;
	font-weight:700;
	src: url("fonts/TIMESBI.TTF");
}
@font-face{
	font-family:Any;
	font-style: normal;
	font-weight:700;
	src: url("fonts/TIMESBD.TTF");	
}