1.一般用点阵字库都是取现成的字库文件,按照格式读出来,非要自己生成点阵的话用手描不是个好办法,下面的代码段可以试试.
const
PointSize = 24;
type
TPointFont = array [1..PointSize, 1..PointSize] of Boolean;
function GetPointFont(const s: string): TPointFont;
const
DestRect: TRect = (Left: 1; Top: 1; Right: PointSize; Bottom: PointSize);
var
c1, c2: TCanvas;
h: HWnd;
SourRect: TRect;
i, j: Integer;
begin
c1:=TCanvas.Create;
try
c1.Handle:=Form1.GetDeviceContext(h);
c1.TextOut(1, 1, s);
SourRect.Left:=1;
SourRect.Top:=1;
SourRect.Right:=c1.TextWidth(s);
SourRect.Bottom:=c1.TextHeight(s);
c2:=TCanvas.Create;
try
c2.Handle:=Form1.GetDeviceContext(h);
c2.CopyRect(DestRect, c1, SourRect);
FillChar(Result, SizeOf(Result), 0);
for i:=1 to PointSize do
for j:=1 to PointSize do
Result[i, j]:=c2.Pixels[i, j]=c2.Font.Color
finally
c2.Free
end
finally
c1.Free
end
end;
至于点阵格式不一定非要用Boolean数组,也可以用一个字节的8位来分别表示,这么写完全是为了阅读方便.