PDFiumVCL 文件

FontAscent property

此 API 條目保留識別符號、簽名、程式碼塊和 PDF 術語的原始形式。
Component: TPdf  ·  Unit: PDFium
Returns the font's ascent (distance from the baseline to the highest ascender) of a page object's font, expressed in PDF points and scaled to a caller-supplied font size.

Syntax

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

Description

FontAscent reports the ascent metric of the font referenced by the page object at the given index. Ascent is the vertical distance from the baseline up to the highest extent reached by the font's tallest characters (capitals, accents, ascenders such as 'l', 'h', or 'k'). The result is expressed in PDF user-space points, already scaled to the FontSize you pass in.

The Index indexer is the 0-based page-object index (0..ObjectCount - 1). The second indexer, FontSize, is the size in PDF points at which the metric should be computed. Pass the size you intend to render at, or use CharacterFontSize[n] to mirror the size of an existing text run. A page must be active when reading the property.

Together with FontDescent this gives the total line height of the font: LineHeight := FontAscent - FontDescent (descent is typically negative). PDFium returns 0 when the font lacks the metric or when the indexed 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. Typically the size at which the font will be rendered (e.g. 10.0, 12.0).

Remarks

Example

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

See Also

FontDescent, FontSize, FontHandle, FontFamilyName