diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-11 14:45:24 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-11 14:45:24 +0000 |
commit | 74bfea219da3b719ae61b445fc04c40948e2bca4 (patch) | |
tree | bfe016fa5a84e63b1214a3506d99df47f9d43692 /src | |
parent | ebafc605dc3551b20ec7a8fd6f1d8f068222c86a (diff) | |
download | fpGUI-74bfea219da3b719ae61b445fc04c40948e2bca4.tar.xz |
* Implemented fpgApplicatio.GetFontfaceList (GDI untested)
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 26 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 9 | ||||
-rw-r--r-- | src/corelib/x11/gfx_x11.pas | 34 |
3 files changed, 69 insertions, 0 deletions
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index ee92b156..44923000 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -168,6 +168,7 @@ type FFocusedWindow: THANDLE; LastClickWindow: TfpgWinHandle; // double click generation LastWinClickTime: longword; + function DoGetFontFaceList: TStringList; override; public constructor Create(const aparams: string); override; function DoMessagesPending: boolean; @@ -713,6 +714,31 @@ end; { TfpgApplicationImpl } +function TfpgApplicationImpl.DoGetFontFaceList: TStringList; + //------ + function MyFontEnumerator(var LogFont: ENUMLOGFONTEX; var TextMetric: NEWTEXTMETRICEX; + FontType: Integer; data: LPARAM): Integer; stdcall; + var + sl: TStringList; + s: string; + begin + sl := TStringList(data); + s := LogFont.elfLogFont.lfFaceName; + if ((sl.Count = 0) or (sl.Strings[sl.Count-1] <> s)) then + sl.Add(s); + Result := 1; + end; + +var + LFont: TLogFont; +begin + Result := TStringList.Create; + FillChar(LFont, sizeof(LFont), 0); + LFont.lfCharset := DEFAULT_CHARSET; + EnumFontFamiliesEx(Display, @LFont, @MyFontEnumerator, LongInt(result), 0); + Result.Sort; +end; + constructor TfpgApplicationImpl.Create(const aparams: string); begin FIsInitialized := False; diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 4a43fb49..78ef4b66 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -368,8 +368,10 @@ type FTopModalForm: TfpgWindowBase; protected FIsInitialized: Boolean; + function DoGetFontFaceList: TStringList; virtual; abstract; public constructor Create(const AParams: string); virtual; abstract; + function GetFontFaceList: TStringList; property IsInitialized: boolean read FIsInitialized; property TopModalForm: TfpgWindowBase read FTopModalForm write FTopModalForm; property MainForm: TfpgWindowBase read FMainForm write FMainForm; @@ -1474,5 +1476,12 @@ begin result := 2.0; end; +{ TfpgApplicationBase } + +function TfpgApplicationBase.GetFontFaceList: TStringList; +begin + Result := DoGetFontFaceList; +end; + end. diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index 03f3c945..f11bfd38 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -181,6 +181,7 @@ type InputContext: PXIC; LastClickWindow: TfpgWinHandle; // double click generation LastWinClickTime: longword; + function DoGetFontFaceList: TStringList; override; public constructor Create(const aparams: string); override; destructor Destroy; override; @@ -480,6 +481,39 @@ begin SizeOf(FComposeBuffer) - 1, @Result, @FComposeStatus)); end; +function TfpgApplicationImpl.DoGetFontFaceList: TStringList; +var + pfs: PFcFontSet; + ppat: PPFcPattern; + n: integer; + s: string; + pc: PChar; + fl: TStringList; +begin + pfs := XftListFonts(Display, DefaultScreen, [FC_SCALABLE, FcTypeBool, 1, 0, FC_FAMILY, 0]); + + if pfs = nil then + Exit; //==> + + Result := TStringList.Create; + + GetMem(pc, 128); + n := 0; + ppat := pfs^.fonts; + while n < pfs^.nfont do + begin + XftNameUnparse(ppat^, pc, 127); //XftNameUnparse does not free the name string! + s := pc; + Result.Add(s); + inc(PChar(ppat), sizeof(pointer)); + inc(n); + end; + FreeMem(pc); + FcFontSetDestroy(pfs); + + Result.Sort; +end; + constructor TfpgApplicationImpl.Create(const aparams: string); var wa: TXWindowAttributes; |