|
预测 Unicode 文本在给定框宽内需要占用的行数(v2.216.0)
Delphi 语法:
function GetWideTextRowCount ( BoxWidth: Integer; Text: WideString ): Integer;
说明
GetWideTextRowCount 是 GetTextRowCount(AnsiString 版)的 Unicode 对应方法,返回以当前字体将 Text 填入 BoxWidth 宽度的框时所需的行数。内部使用 GetWideTextWidth 测量宽度,因此 CJK / 代理对 / 多字节文本可以正确换行计算。此方法通常在调用 WideTextOutBox 之前使用,以确定所需的框高
参数
| Name | 说明 |
BoxWidth | 文本框宽度(用户空间单位) |
Text | 要计算行数的 Unicode 文本 |
返回值
在 BoxWidth 宽度内、当前字体下该文本占用的行数
代码示例
// 先预测行数,再以行高计算框高,然后输出
var
Rows: Integer;
BoxHeight: Integer;
Text: WideString;
begin
Text := '日本語のテキスト。折り返しのテストを行います。';
Rows := HPDF.CurrentPage.GetWideTextRowCount(200, Text);
BoxHeight := Rows * 20 + 10; // 每行 20pt,加 10pt 余量
HPDF.CurrentPage.WideTextOutBox(30, 700, 20, 200, BoxHeight, Text, jtLeft);
end;
另请参阅: GetWideTextWidth WideTextOutBox GetWideCharAdvances
|