[Lazarus] Reading a file that contains UTF-8 text

Graeme Geldenhuys graemeg at opensoft.homeip.net
Thu Jul 9 13:07:01 CEST 2009


I was thinking more about a solution to this problem.

What if we move away from the point sizes and rather give it a name 
like: ExtraLarge, Large, Normal, Small, Tiny etc... Then each platform 
implements the size name to what they consider the valid point size 
(taking into account dpi settings).

eg: Based on a 96dpi on Linux and Windows and 75 dpi on Mac

    Font Size         Linux      Windows      Mac
   =================================================
    Large              12pt       10pt         15pt
    Normal             10pt        8pt         13pt
    Small               8pt        7pt         11pt
    ...

So when you specify Font-Size = Normal, it looks the same sime (or very 
close) to what you intended, no matter the platform.

fpGUI Toolkit already uses what is called a Font Alias (or Font 
Description) when specifying fonts in components. Obviously the 
developer could specify fonts in the normal fashion as well (real font 
name, size, attribute).

Examples of Font Aliases as used in fpGUI Toolkit:
(font aliases are denoted by a # prefix)

   '#label1'     =  Arial-10:antialias=true
   '#label2'     =  Arial-10:antialias=true:bold
   '#edit1'      =  Arial-10:antialias=true
   '#edit2'      =  Courier New-10:antialias=true
   '#grid'       =  Arial-9
   ...

So I could probably define new font alias called #Large, #Normal, 
#Small, or modify the existing aliases. Then under each platform 
(platform specify backend units) specify the preferred point size for 
each of those. That way my applications can still continue using the 
Font Alias as normal when specifying a font. Ummm... that could work.

Here is an example of setting a font for a component using Font Aliases 
- as used in fpGUI Toolkit:

   Label1 := TfpgLabel.Create(self);
   with Label1 do
   begin
     Name := 'Label1';
     SetPosition(8, 16, 104, 30);
     FontDesc := '#Label2';          // font defined here
     Hint := '';
     Text := 'Some Caption';
   end;

   Edit1 := TfpgEdit.Create(self);
   with Edit1 do
   begin
     Name := 'Edit1';
     SetPosition(116, 16, 160, 34);
     TabOrder := 1;
     FontDesc := '#Edit1';          // font defined here
     Text := '';
   end;




Regards,
   - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/





More information about the Lazarus mailing list