获得TrueType字体轮廓数据的问题(10分)

  • 主题发起人 主题发起人 小小荷叶
  • 开始时间 开始时间

小小荷叶

Unregistered / Unconfirmed
GUEST, unregistred user!
在win98下delphi5.0中
procedure TForm1.Button1Click(Sender: TObject);
var dc:HDC;
m_pPoint:array of Tpoint;
Bezier:array[0..3] of Tpoint;
m_pFlag:array of integer;
m_nCount,i,xp,yp:integer;
begin
form1.Canvas.pen.Style:=pssolid;
form1.Canvas.pen.Width:=3;
form1.Canvas.pen.Color:=rgb(255,0,0);
form1.Canvas.Brush.Color:=rgb(0,255,0);
form1.Canvas.Font.Name:='隶书';
form1.Canvas.Font.Size:=80;
Bezier[0]:=point(100,100);
Bezier[1]:=point(200,100);
Bezier[2]:=point(400,400);
Bezier[3]:=point(100,100);
dc:=form1.Canvas.Handle;
SetBkMode(dc, TRANSPARENT);

beginpath(dc);
Polygon(dc,Bezier,4);
form1.canvas.textout(100,100,'hello');
endpath(dc);


SetLength(m_pPoint,0);
SetLength(m_pFlag,0);
m_nCount:=GetPath(dc, m_pPoint, m_pFlag, 0);

self.Caption:=inttostr(m_nCount);
if ( m_nCount>0 ) then
begin
SetLength(m_pPoint,m_nCount);
SetLength(m_pFlag,m_nCount);
if ( (m_pPoint<>Nil) and (m_pFlag<>Nil) ) then
m_nCount:=GetPath(dc, m_pPoint, m_pFlag, m_nCount);
end;
self.Caption:=self.Caption+','+inttostr(m_nCount);

for i:=0 to m_nCount do
begin
xp:=m_pPoint.x;
yp:=m_pPoint.y;
form1.Canvas.Rectangle(rect(xp,yp,xp+2,yp+2));

end;

end;
欲获得TrueType字体轮廓数据的问题,试了又试,不得其解,改用在C++buider5.0中,
单击按钮三次才得到字体轮廓数据.C++buider5.0中程序如下
void __fastcall TForm1::Button1Click(TObject *Sender)
{
POINT * m_pPoint;
BYTE * m_pFlag;
int m_nCount;

m_pPoint = NULL;
m_pFlag = NULL;
m_nCount = 0;

HDC hDC;
hDC=Form1->Canvas->Handle;
SetBkMode(hDC, TRANSPARENT);
Form1->Canvas->Font->Name="Arial";
Form1->Canvas->Font->Size=50;
BeginPath(hDC);
TextOut(hDC, 100, 100, "hello", 5);
EndPath(hDC);

// KPathData pd;

// pd.GetPathData(hDC);

if ( m_pPoint ) delete m_pPoint;
if ( m_pFlag ) delete m_pFlag;

m_nCount = GetPath(hDC, NULL, NULL, 0);
Form1->Edit1->Text=m_nCount;
if ( m_nCount>0 )
{
m_pPoint = new POINT[m_nCount];
m_pFlag = new BYTE[m_nCount];

if ( m_pPoint!=NULL &amp;&amp; m_pFlag!=NULL )
m_nCount = GetPath(hDC, m_pPoint, m_pFlag, m_nCount);
}

Form1->Edit2->Text=m_nCount;
int i,xp,yp;
for (i=0;i< m_nCount;i++)
{
xp=m_pPoint.x;
yp=m_pPoint.y;
Form1->Canvas->Rectangle(xp,yp,xp+2,yp+2);
}
}

大虾们,请帮帮忙,多谢[:)][:)]
 
后退
顶部