Welcome

首页 / 软件开发 / Delphi / Delphi GDI+ 学习记录(24): 输出文本<3>

Delphi GDI+ 学习记录(24): 输出文本<3>2012-03-26 cnblogs 万一//获取字体信息

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;