[fpc-pascal] fcl-pdf custom font from memstream
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Nov 2 16:42:48 CET 2023
On 02.11.23 14:00, Michael Van Canneyt via fpc-pascal wrote:
>
>
> On Thu, 2 Nov 2023, Alexey Torgashin via fpc-pascal wrote:
>
>>
>>>> How to load a custom font from a stream instead of from a file?
>>>
>>> Currently no way to my knowledge,
>>
>> But fpparsettf.pp has this:
>>
>> TTFFileInfo = class(TObject)
>> ...
>> public
>> // Load a TTF file from file or stream.
>> Procedure LoadFromFile(const AFileName : String);
>> Procedure LoadFromStream(AStream: TStream); virtual;
>
> Yes, but the font cache/manager in fpttf does not support this, and all
> font access happens
> through the font cache. (at least that is how I understood Mattias'
> request)
Yes. I added two functions and extended the example.
To my surprise it turns out that a ttf file is loaded up to 3 times:
Once for AddFont, once for gTTFontCache and once in SaveDocument.
SaveDocument now uses the TPDFFont stream if available, so only 2 times.
Wouldn't it be better if TPDFDocument.Fonts and gTTFontCache share the
stream?
Mattias
More information about the fpc-pascal
mailing list