PDFiumVCL Docs

FontWeight property

Ten wpis API zachowuje identyfikatory, sygnatury, bloki kodu i terminy PDF w oryginalnej postaci.
Component: TPdf  ·  Unit: PDFium
Returns the CSS-style weight (boldness) of the font used by a page object on the current page. Typical values are 400 for regular and 700 for bold.

Syntax

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

Description

FontWeight reports the weight class of the font referenced by the page object at the given index, mirroring the CSS / OpenType convention: 100 (Thin) up to 900 (Black), with 400 = Regular and 700 = Bold. It is derived from the embedded font descriptor or, for non-embedded fonts, from PDFium's substitution table.

The index is the 0-based page object index, valid from 0 to ObjectCount - 1. Only text objects carry a meaningful weight; querying a non-text object returns 0. For weights tied to individual extracted characters (rather than to a page object's font dictionary) use CharacterFontWeight.

A page must be active (PageNumber already set). The weight is decoded from the font handle obtained via FontHandle; if the font itself does not declare a weight, PDFium returns 0 and the property does likewise.

Parameters

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

Remarks

Example

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;

See Also

CharacterFontWeight, FontFamilyName, FontItalicAngle, FontHandle, ObjectCount