I suppose you could have something like this.... TNamedFontItem = class private .... public constructor Create(AFontID, AFontDesc : string); property FontID : string .... property FontDesc : string .... end;
The above class is used for the mappings. You need to store a list of mappings somewhere. In fpGUI I could to this in the Style class. In Lazarus this would maybe live in TApplication or TScreen. For example: FNamedFonts : TList; You would also need some methods to work with the mappings... and return a TFont. function GetNamedFontDesc(AFontID : string) : string; function CreateNamedFont(AFontID : string) : TFont; procedure SetNamedFont(AFontID, AFontDesc : string); You can then register whatever font mappings (Named Fonts) you need. eg: SetNamedFont('Label1', 'Arial-10'); SetNamedFont('Label2', 'Arial-10:bold'); SetNamedFont('Edit1', 'Arial-10'); SetNamedFont('Edit2', 'Courier New-10'); SetNamedFont('List', 'Arial-10'); SetNamedFont('Grid', 'Arial-9'); SetNamedFont('GridHeader', 'Arial-9:bold'); SetNamedFont('Menu', 'Arial-10'); Then in the application do this... AControl.Font.Assign(gGetFont('#Label1')); The '#' indicates the Named Font. Without a '#' would indicate the exact font name and no lookup would be needed (tip thanks to LPTK project). I guess you could remove the '#' bit as well, but I think it is a good idea, so you can differentiate between named fonts and actual font names - and use a consistent method (gGetFont) throughout your application for assigning fonts. Regards, - Graeme - On 12/14/06, Micha Nelissen <[EMAIL PROTECTED]> wrote:
Mattias Gaertner wrote: > About 'header': Most often the font name will be the same, but the size > or the style will be different. > Maybe better: > AControl.Font.Assign(GetDefaultHeaderFont) Yes, ok, but my point was that the user could make up his own needs for his/her application and use those. 'header' was just an example, and defining a function like this seems like a hardcoded way. Maybe GetDefaultFont(dfHeader), with additionally RegisterFont(....) which returns an integer to you can pass to GetDefaultFont. Not sure where this 'mapping' could be stored, maybe in the project (unit) resources ? Micha _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
-- Graeme Geldenhuys There's no place like S34° 03.168' E018° 49.342' _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives