📄 getkerningpairsu.pas
字号:
unit GetKerningPairsU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
Label3: TLabel;
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{Whoops! Delphi incorrectly imports this function, so we must reimport it
manually to obtain the full functionality of this function}
function GetKerningPairs(DC: HDC; Count: DWORD;
KerningPairs: Pointer): DWORD; stdcall;
var
Form1: TForm1;
implementation
{$R *.DFM}
{reimport the function}
function GetKerningPairs; external gdi32 name 'GetKerningPairs';
procedure TForm1.FormActivate(Sender: TObject);
type
TKerningPairs = array[0..0] of TKerningPair; // holds the kerning pairs
var
FaceName: array[0..255] of char; // holds the selected font typeface name
KerningPairs: ^TKerningPairs; // a pointer to the kerning pair array
NumPairs: DWORD; // holds the number of pairs
Count: Integer; // general loop control variable
begin
{retrieve the name of the currently selected font and display it}
GetTextFace(Form1.Canvas.Handle, 255, @FaceName[0]);
Label2.Caption := FaceName;
{retrieve the total number of kerning pairs in the selected font}
NumPairs := GetKerningPairs(Form1.Canvas.Handle, 0, nil);
{allocate enough memory to hold all of the kerning pairs}
GetMem(KerningPairs, SizeOf(TKerningPair)*NumPairs);
{retrieve the kerning pairs for the font}
GetKerningPairs(Form1.Canvas.Handle, NumPairs, KerningPairs);
{display every kerning pair and its kerning amount}
Memo1.Lines.Clear;
Memo1.Lines.Add('Pair'+#9+'Kern Amount');
for Count := 0 to NumPairs-1 do
Memo1.Lines.Add(Char(KerningPairs^[Count].wFirst)+
Char(KerningPairs^[Count].wSecond)+#9+
IntToStr(KerningPairs^[Count].iKernAmount));
{free the kerning pairs array memory}
FreeMem(KerningPairs,SizeOf(TKerningPair)*NumPairs);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -