PDFium Component Docs

FontWeight プロパティ

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
コンポーネント: TPdf  ·  ユニット: PDFium
現在 page の page object で使われている font の CSS-style weight (boldness) を返します。典型値は regular が 400、bold が 700 です

構文

property FontWeight[Index: Integer]: Integer; // read only

説明

FontWeight は、指定した index の page object が参照する font の weight class を返します。CSS / OpenType の convention に合わせて、100 (Thin) から 900 (Black) までを扱い、400 は Regular、700 は Bold です。値は embedded font descriptor から、non-embedded font では PDFium の substitution table から導かれます

index は 0-based の page object index で、範囲は 0 から ObjectCount - 1 です。意味のある weight を持つのは text object だけで、non-text object を問い合わせると 0 を返します。page object の font dictionary ではなく抽出した個々の character に結びつく weight が必要な場合は CharacterFontWeight を使ってください

page は active (PageNumber が設定済み) でなければなりません。weight は FontHandle で得た font handle から decode され、font 自体が weight を宣言していない場合は PDFium も 0 を返し、この property も同じです

パラメータ

Index0-based page-object index, in the range 0..ObjectCount - 1. Only text objects produce a non-zero weight.

備考

var
  I, BoldCount: Integer;
begin
  Pdf1.PageNumber := 1;
  BoldCount := 0;
  for I := 0 to Pdf1.ObjectCount - 1 do
    if Pdf1.FontWeight[I] >= 600 then
      Inc(BoldCount);
  ShowMessage(IntToStr(BoldCount) + ' bold text objects on page 1');
end;

関連項目

CharacterFontWeight, FontFamilyName, FontItalicAngle, FontHandle, ObjectCount