Einhugur PDF Plugin Font Question

I’m a bit hazy on teh whole font file thing to begin with so I need some clarifications.

No issue with the 14 PDF fonts… that is straight forward…

By things get murky for me when taking about TrueType and Type1 fonts… so her are some questions
the docs say:

[quote]PDFDocument.LoadTrueTypeFont( f as FolderItem) as Font
Parameters f: Path to the Font file.
Returns : Font -The font or nil if there was error.

This must be TrueType font with the extension .tt (and renaming the extension of different types will not work). And this must be unicode capable TrueType font.[/quote]

But looking at the Libharu docs (http://libharu.sourceforge.net/fonts.html) there are two methods to load TrueType Fonts…

[quote]The first format whose extension is “.ttf” includes only one font-data in the file. The function HPDF_LoadTTFontFromFile() is available to load this type of font.
The second format whose extension is “.ttc” includes multiple font-data in the file. The function HPDF_LoadTTFontFromFile2() is available to load this type of font. HPDF_LoadTTFontFromFile2() has a parameter which is used to specify the index of the font to load.
[/quote]

Did the Einhugur mean to say the file type should be .tt* meaning that both types of files are loaded? But the function only returns a single font, not an array… so I guess the docs mean .ttf only! Is the a way to load only or all the fonts from a .ttc file?

The libHaru docs go on to say:

[quote]If the parameter “embedding” is set to HPDF_TRUE when invoking HPDF_LoadTTFontFromFile() or HPDF_LoadTTFontFromFile2(), the subset of a font is embeded into a PDF file. If not, only the matrix data is stored into a PDF file. In this case a viewer application may use an alternative font if it cannot find font.
[/quote]

But the Einhugur functions do not seem to have an embed parameter… Are all loaded fonts (besides the standard PDF ones) embedded if the font allows it or does it need to reside on the reader system? Should there be an embed parameter?

Thanks,
-karen

There is example project with the plugin on how to embed TrueType fonts and also example fonts to embed are included. The fonts embed as far as I understand it. (At least the give you the path Unicode which clearly hints that their actually embedded)

There are two types of TrueType font files. Those with a .ttf extension which contains a single font and those with a .ttc extension (where c = collection) that usually contains a font family (all the styles).

LibHaru loads .ttf font files using the method HPDF_LoadTTFontFromFile() and I am guessing that is what your method PDFDocument.LoadTrueTypeFont uses on the hood.

But LibHaru has a second method to load fonts from a .ttc file:

HPDF_LoadTTFontFromFile2

Is there any way to do that in your plugin?

In LibHaru both Truetype font loading methods have a parameter called embedding that is documented as:

[quote]embedding - If this parameter is set to HPDF_TRUE, the glyph data of the font is embedded, otherwise only the matrix data is included in PDF file.
[/quote]

For your .ttf loader method I assume you always default to true?

While I would never have thought of this on my own, as discussed elsewhere in teh forum, there are times when one might want to use a font BUT NOT want to embed it.

Apparently if only the matrix is embedded a PDF reader will see if that font is installed on the host computer. If it is it will use it, otherwise it will substitute. That advantage of that is an organization may ensure all it machines have a specific font set and that will enable all their PDFs to be smaller in size for storage purposes…

Also licensing issues may play into if you want to embed a font you ar using or just rely on it being already installed on computer where the PDF is being read

That is why I was asking about control of embedding.

-Karen