PDFium Component Docs

FontSize プロパティ

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
コンポーネント: TPdf  ·  ユニット: PDFium
現在 page の個々の character の rendered font size を PDF point で返します。FontSize は backward compatibility のために残された CharacterFontSize の alias です

構文

property FontSize[Index: Integer]: Double; // read only

説明

FontSize reports the effective glyph height that PDFium computed for the character at the given index, expressed in PDF user-space points (1 pt = 1/72 inch). The value already incorporates the font's selected size and the current text-state scaling, so it is the size the character would render at if the page were printed at its natural scale.

index は、現在 page の text page における character の 0-based position で、Character が返す順序、Text が生成する順序と同じです。有効範囲は 0 から CharacterCount - 1 までです。property を読む前に page (PageNumber) を load する必要があります。text page は最初のアクセス時に自動生成されます

同じ page の text でも run ごとに size が違うことがあり、1 行の中でも変わることがあるので、size は page 単位ではなく character ごとに問い合わせる必要があります。この size は font 自体を表す FontAscent / FontDescent の metric とは無関係で、FontSize は個々の glyph instance がどの大きさで描かれているかを表します

パラメータ

Index現在 page の 0-based character index で、範囲は 0..CharacterCount - 1 です

備考

var
  I: Integer;
  Total, Avg: Double;
begin
  Pdf1.PageNumber := 1;
  Total := 0;
  for I := 0 to Pdf1.CharacterCount - 1 do
    Total := Total + Pdf1.FontSize[I];
  if Pdf1.CharacterCount > 0 then
  begin
    Avg := Total / Pdf1.CharacterCount;
    ShowMessage('Average size on page 1: ' + FormatFloat('0.00', Avg) + ' pt');
  end;
end;

関連項目

CharacterFontSize, FontWeight, FontFamilyName, CharacterCount, Character