RadPdfProcessing uses fonts represented by FontBase objects to specify the look of the text that is exported to PDF. Currently, it supports two font types: Standard and Embedded.
There are 14 standard fonts that are not embedded in the document when you use them. These fonts can be accessed through the FontsRepository class and are listed below.
- Helvetica Bold
- Helvetica Oblique
- Helvetica BoldOblique
- Courier Bold
- Courier Oblique
- Courier BoldOblique
- Times Roman
- Times Bold
- Times Italic
- Times BoldItalic
All fonts, which are not included in the 14 standard ones should be embedded in the PDF document. Otherwise, the result when the document is rendered is unpredictable. In RadPdfProcessing you have the ability to embed fonts following the approaches described below.
If you want to use a font, which is not part of the standard ones, you can register it using the RegisterFont() method of the FontRepository static class. The method requires four parameters - FontFamily, FontStyle and FontWeight objects describing the font and a byte array containing the raw font data.
Example 1 demonstrates how you can use the RegisterFont() method.
Example 1: Register font
FontsRepository.RegisterFont(fontFamily, fontStyle, fontWeight, data);
Each registered font can be obtained from the font repository as FontBase object and applied to a TextFragment.
Example 2 shows how to create a font using the FontsRepository.
Example 2: Create FontBase
FontBase font; bool success = FontsRepository.TryCreateFont(fontFamily, fontStyle, fontWeight, out font);
You can create fonts that are not explicitly registered. Creating a font that is not registered in the repository with the code from Example 2 tries to find the font from the ones installed on the machine.
Note that due to security limitations in Silverlight, creating a font that is not present in the repository with the code from Example 2 is going to fail - the application doesn't have the permissions to get the font from the file system.