Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-04

fpTTF: TFPFontCacheItem properties aren't loaded from font

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

TFPFontCacheItem properties (FamilyName, IsBold, IsItalic, ...) aren't loaded from the font file. I have to assign them explicitely. Is it really wanted? Can a TTF file embed font with various styles?

E.g. I have to do now:

   TPrintFontCacheList = class(TFPFontCacheList)
   public
     function Add(const AObject: TFPFontCacheItem): Integer;
   end;
function TPrintFontCacheList.Add(const AObject: TFPFontCacheItem): Integer;
begin
   Result := inherited Add(AObject);
   AObject.FamilyName := AObject.GetFontData.FamilyName;
   AObject.IsBold := AObject.GetFontData.Bold;
   AObject.IsItalic := AObject.GetFontData.ItalicAngle  0;
end;

in order the used font is correctly found.

IMO the file should be read in TFPFontCacheItem.Create and the properties should be set accordingly. Furthermore the properties should be read-only as well.

Ondrej

Reply by email

Graeme Geldenhuys
to Ondrej Pokorny
Ondrej Pokorny wrote
Can a TTF file embed font with various styles?

No, not that I'm aware of. Each style is a different TTF file.

IMO the file should be read in TFPFontCacheItem.Create and the properties should be set accordingly. Furthermore the properties should be read-only as well.

You are correct on both counts. You are welcome to make that change.

On a side note:
My initial thinking was that the TFPContCacheItem could manage multiple TTF files of the same FamilyName. eg: Ubuntu-Regular.ttf, Ubuntu-Bold.ttf, Ubuntu-Italic.ttf etc. The FamilyName would be "Ubuntu". This thinking came from how fpGUI manages fonts. eg: Label1.FontDesc = 'Ubuntu-13:bold,italic'; My thinking was that fpReport could use similar. Internally the fontcache would know exactly which TTF file to use. I found some problem with that idea (unfortunately I can't remember what that was), and stopped work in that direction - until a later date.

But you are welcome to make the changes you suggested above. I will take up my research on fontcache mods some time in the future. I don't have time at the moment.

Regards,
??Graeme??

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email