//獲取字體信息
var
fontFamily: TGPFontFamily;
font: TGPFont;
begin
fontFamily := TGPFontFamily.Create('宋體');
font := TGPFont.Create(fontFamily, 9, FontStyleRegular, UnitPixel);
ShowMessage(FloatToStr(font.GetSize)); {字號大小}
ShowMessage(IntToStr(fontFamily.GetEmHeight(FontStyleRegular))); {字體高度, 采用設計時單位}
ShowMessage(IntToStr(fontFamily.GetLineSpacing(FontStyleRegular)));{行間距, 采用設計時單位}
ShowMessage(IntToStr(fontFamily.GetCellAscent(FontStyleRegular))); {上升距, 采用設計時單位}
ShowMessage(IntToStr(fontFamily.GetCellDescent(FontStyleRegular)));{下降距, 采用設計時單位}
font.Free;
fontFamily.Free;
end;
//獲取已安裝字體的列表
var
fonts: TGPFontCollection;
fArr: array of TGPFontFamily;
count,ti: Integer;
s: string;
i: Integer;
begin
fonts := TGPInstalledFontCollection.Create;
count := fonts.GetFamilyCount;
SetLength(fArr, count);
for i := 0 to count - 1 do
begin
fArr[i] := TGPFontFamily.Create;
end;
fonts.GetFamilies(count, fArr, ti);
Memo1.Clear;
for i := 0 to count - 1 do
begin
fArr[i].GetFamilyName(s);
Memo1.Lines.Add(s);
fArr[i].Free;
end;
fonts.Free;
end;