TPdfMeasureHelper = class helper for TPdf
procedure MeasureText(const Text, Font: WString; FontSize: Single; out Width, Height: Double);
function MeasureTextWidth(const Text, Font: WString; FontSize: Single): Double;
function WrapText(const Text, Font: WString; FontSize: Single; MaxWidth: Double): TArray<WString>;
function WrapText(const Text, Font: WString; FontSize: Single; MaxWidth: Double; BreakLongWords: Boolean): TArray<WString>;
end;
| メンバー | 説明 |
|---|---|
TPdf.MeasureText | 選択されたフォントとサイズについて、PDF ユーザー単位のテキスト幅と高さを返します |
TPdf.MeasureTextWidth | PDF ユーザー単位のテキスト幅だけを返します |
TPdf.WrapText | 明示的な改行を保持し、トークンを MaxWidth に収まるよう折り返し、Unicode スカラー境界で過大なトークンを分割できます |
FPdfMeasure は TPdf へクラスヘルパーを追加し、描画の前に PDF ユーザー単位でテキストを測定できるようにします
レイアウト計算には MeasureText と MeasureTextWidth を、選択した幅に収まる行への分割には WrapText を使用します
元の WrapText オーバーロードは互換性のため過大なトークンをそのまま保持します。UTF-16 サロゲートペアを保持しながら CJK など空白を含まないテキストを分割するには、BreakLongWords=True を渡してください
var
Width, Height: Double;
Lines: TArray<WString>;
begin
Pdf.MeasureText('Invoice total', 'Arial', 12, Width, Height);
Lines := Pdf.WrapText(LongText, 'Arial', 10, 240, True);
end;