利用可能な Font 名を取得する (Windows / OS X)

(現在の所) FireMonkey には利用可能なフォントを取得する機能はありません。Windows なら Windows API を使ってフォント一覧を得ればいいのですが、OS X では別のコーディングをしなくてはなりません…面倒ですね。

Delphi Science の Google Code から以下の 3 つのファイルを DL しましょう。

コンボボックスにフォント一覧を格納するサンプルは以下のようになります。Windows でも OS X でも同じ書き方です。

uses
  ..., FMX.PlatformExtensions;

var
  FontList: TstringList;
  Dmy: String;
begin
  FontList := TStringList.Create;
  try
    PlatformExtensions.GetSystemFonts(FontList);
    FontList.Sort;
    ComboBox1.Clear;
    for Dmy in FontList do
      ComboBox1.Items.Add(Dmy);
  finally
    FontList.DisposeOf;
  end;
end;


See Also:


 BACK