获得字体列表
<p>最简单的办法是 做一个动态库,下面给出delphi的实现</p><p>pb调用只需声明<font color="#113dee">function string getfontfaces() library "pbgdiex.dll"</font></p><p>结果以tab分割,每项前面用T,R,D分别指明为实型字体,光栅字体,设备字体等</p><p><font color="#5ea26b">library pbgdiex;</font></p><p><font color="#5ea26b">uses<br/> windows;</font></p><p><font color="#5ea26b">{$R *.res}<br/>var<br/> gfuntmpstr:string;<br/>function EnumFontFamiliesCallBack(lpelf:pENUMLOGFONT; next:pNEWTEXTMETRIC; FontType:integer; lParam:LPARAM):integer;stdcall;<br/>var pstr:pchar;<br/> l:integer;<br/> typestr:string;<br/>begin<br/> if pos(lpelf.elfFullName,gfuntmpstr)>1 then exit;<br/> if fonttype=TRUETYPE_FONTTYPE then typestr:='T '<br/> else if fonttype=RASTER_FONTTYPE then typestr:='R '<br/> else if fonttype=DEVICE_FONTTYPE then typestr:='D '<br/> else typestr:='';<br/> gfuntmpstr:=gfuntmpstr+typestr+lpelf.elfFullName+#$9;<br/>end;<br/>function getfontfaces():LPCTSTR;stdcall;<br/>var pfss:pchar;<br/>begin<br/> gfuntmpstr:='';<br/> windows.EnumFontFamilies(GetDC(0),nil,@EnumFontFamiliesCallBack,0);<br/> result:=pchar(gfuntmpstr);<br/>end;<br/>exports getfontfaces;<br/>begin</font></p><p><font color="#5ea26b">end.<br/></font> </p> 顶
页:
[1]