PDFium Component Docs

FontDescent property

Component: TPdf  ·  Unit: PDFium
Trả về descent của phông chữ (khoảng cách từ đường cơ sở xuống điểm thấp nhất của nét vươn xuống) của phông chữ thuộc object trang, được biểu diễn bằng point PDF và đã scale theo cỡ chữ do bên gọi cung cấp

Syntax

property FontDescent[Index: Integer; FontSize: Single]: Single; // read only

Description

FontDescent reports the descent metric of the font referenced by the page object at the given index. Descent is the vertical distance (typically negative in PDF metrics) from the baseline to the lowest point reached by descenders such as the tails of 'g', 'p', or 'y'. The value PDFium returns is already scaled to the FontSize argument, in PDF user-space points.

The Index indexer is the 0-based page-object index (0..ObjectCount - 1). FontSize is the size at which you want the metric computed; pass either the size you intend to render at or, when reproducing existing text, the value returned by CharacterFontSize. A page must be active before the property is read.

Combined with FontAscent the descent gives the total line height of a font at a chosen size: LineHeight := FontAscent - FontDescent. PDFium returns 0 when the underlying font does not expose the metric (for example, certain Type3 fonts) or when the page object is not text.

Parameters

Index0-based page-object index in the range 0..ObjectCount - 1.
FontSizeFont size in PDF points used to scale the metric (e.g. 12.0). Match it to the actual rendering size for a realistic descender value.

Remarks

Example

var
  I: Integer;
  Asc, Dsc, LineHeight: Single;
begin
  Pdf1.PageNumber := 1;
  for I := 0 to Pdf1.ObjectCount - 1 do
  begin
    Asc := Pdf1.FontAscent[I, 12.0];
    Dsc := Pdf1.FontDescent[I, 12.0];
    LineHeight := Asc - Dsc;
    if LineHeight > 0 then
      Memo1.Lines.Add(Format('Object %d: line height = %.2f pt', [I, LineHeight]));
  end;
end;

See Also

FontAscent, FontSize, FontHandle, FontFamilyName