PDFium Component Docs

FontSize property

Component: TPdf  ·  Unit: PDFium
Trả về cỡ phông đã render, tính bằng point PDF, của một ký tự riêng lẻ trên trang hiện tại FontSize là bí danh của CharacterFontSize được giữ lại để tương thích ngược

Syntax

property FontSize[Index: Integer]: Double; // read only

Description

FontSize reports the effective glyph height that PDFium computed for the character at the given index, expressed in PDF user-space points (1 pt = 1/72 inch). The value already incorporates the font's selected size and the current text-state scaling, so it is the size the character would render at if the page were printed at its natural scale.

The index is the 0-based position of the character in the current page's text page, in the same order returned by Character and produced by Text. Valid values run from 0 to CharacterCount - 1. Before reading the property you must load a page (PageNumber); the text page is created automatically on first access.

Different runs of text on the same page can have different sizes, even within a single line, so the size must be queried per character rather than per page. Note that this size is unrelated to the metrics returned by FontAscent / FontDescent, which describe the font itself; FontSize describes how a specific glyph instance is sized.

Parameters

Index0-based character index in the current page, in the range 0..CharacterCount - 1.

Remarks

Example

var
  I: Integer;
  Total, Avg: Double;
begin
  Pdf1.PageNumber := 1;
  Total := 0;
  for I := 0 to Pdf1.CharacterCount - 1 do
    Total := Total + Pdf1.FontSize[I];
  if Pdf1.CharacterCount > 0 then
  begin
    Avg := Total / Pdf1.CharacterCount;
    ShowMessage('Average size on page 1: ' + FormatFloat('0.00', Avg) + ' pt');
  end;
end;

See Also

CharacterFontSize, FontWeight, FontFamilyName, CharacterCount, Character