I am able to sucessfully create PDF files using PDFsharp and MigraDoc. Two private fonts (OTF format) are used for the creation of a single page PDF. The created PDF contains both fonts fully embedded. Unfortunatly each font contains Chinese letters too and therefor measures about 4 MB in size each, resulting in a PDF file size about 9 MB (containing one page with a bit of text only!). :shock:
Is it possible to use a subset of those fonts to save valuable space. The thing is I need to create a few thousand PDF files and therefor file size is crucial.
Is there a special setting i can use? Can anyone point me into the right direction?
Update: I used fontforge to extract the embedded font subgroub and found out that the fonts derived from the pdf match the full font files exactly. So no font subsetting is indeed used at all. :(
Taking a look into the PDFsharp sources I found the function
public OpenTypeFontface CreateFontSubSet(Dictionary<int, object> glyphs, bool cidFont)
which is commented as follows: Creates a new font image that is a subset of this font image containing only the specified glyphs. Which is exactly what I want to be used here.
The thing I do not understand here is why this function seems not to get used when creating my PDF. What criteria needs to be met in order to make it work?
Some fonts have a "loca table", some do not. The loca table stores the offsets to the locations of the glyphs in the font.
CreateFontSubSet
is and can only be called for fonts with a loca table that provides the information needed to create subsets.