PDFium Delphi Component Docs

FontAscent プロパティ

コンポーネント: 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 メトリックを報告します。ascent とは baseline から、フォントの最も高い文字(大文字、アクセント付き文字、'l'・'h'・'k' といった ascender)が届く上端までの垂直距離です。結果は PDF user-space の point で、渡した FontSize に合わせてすでに scale 済みです

1 つ目の Index は 0 基準の page-object インデックス(0..ObjectCount - 1)です。2 つ目の FontSize は、メトリックを計算する PDF point のサイズです。実際に描画するサイズを渡すか、既存のテキスト run のサイズに合わせるなら CharacterFontSize[n] を使います。読み取りにはページがアクティブである必要があります

FontDescent と組み合わせればフォントの行の全高が得られます: LineHeight := FontAscent - FontDescent(descent は通常負の値)。フォントにメトリックがない場合や、index されたオブジェクトがテキストでない場合、PDFium は 0 を返します

パラメーター

Index0..ObjectCount - 1 の範囲の 0 基準 page-object インデックス
FontSizeメトリックを scale する PDF point のフォントサイズ。通常は実際に描画するサイズ(例: 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