[Lazarus] fpTTF: TFPFontCacheItem properties aren't loaded from font

Ondrej Pokorny lazarus at kluug.net
Wed Apr 13 18:02:43 CEST 2016


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




More information about the Lazarus mailing list