PDFium Component Docs

FontAscent プロパティ

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
コンポーネント: TPdf  ·  ユニット: PDFium
page object の font の ascent (baseline から最も高い ascender までの距離) を返します。値は PDF point で表され、caller が渡した font size に合わせて scale されます

構文

property FontAscent[Index: Integer; FontSize: Single]: Single; // read only

説明

FontAscent は、指定 index の page object が参照する font の ascent metric を返します。ascent は baseline から font の最も高い文字 (大文字、accent、'l', 'h', 'k' のような ascender) の先端までの垂直距離です。結果は PDF user-space point で返され、FontSize に合わせてすでに scale されています

Index indexer は 0 基準の page-object index です (ObjectCount - 1 まで)。2 つ目の indexer である FontSize は、metric を計算する PDF point の size です。実際に render したい size を渡すか、CharacterFontSize[n] を使って既存の text run に合わせてください。property を読むときは page が active である必要があります

FontDescent と合わせると font の総 line height が分かります。LineHeight := FontAscent - FontDescent です (descent は通常 negative です)。font に metric がないか、index した object が text でないとき、PDFium は 0 を返します

パラメータ

Index0 基準の page-object index です。範囲は 0..ObjectCount - 1 です
FontSizemetric を scale するための PDF point の font size です。通常は実際に render する size です (たとえば 10.0, 12.0)

備考

var
  I: Integer;
  Asc: Single;
begin
  Pdf1.PageNumber := 1;
  for I := 0 to Pdf1.ObjectCount - 1 do
  begin
    Asc := Pdf1.FontAscent[I, 12.0];
    if Asc > 0 then
      Memo1.Lines.Add(Format('Object %d: ascent = %.2f pt', [I, Asc]));
  end;
end;

関連項目

FontDescent, FontSize, FontHandle, FontFamilyName