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 も同じです
| Index | 0-based page-object index, in the range 0..ObjectCount - 1. Only text objects produce a non-zero weight. |
0 を返します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;