Interface FixedTextMeasurer
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
FixedMeasurer
以與 FixedPdfRenderer 相同的字型登錄、fallback 鏈與字距規則量測單行文字,
供應用在建立 FixedDocument 前自行計算座標(例如逐字定位、置中或拉伸標籤)。
同一份 ReportFonts 下,量得的寬度等於 renderer 對齊與超框檢查使用的寬度。
寬度=各字字寬總和+相鄰 code point 間字距(行尾不加);不做 kerning、不換行。
未知家族、缺少粗體字面或任何字型都不含的字元,與 renderer 一樣以 pdf.fixed.font 拒絕。
實例持有已解析字型,非 thread-safe;同一次產生的多次量測應重用同一實例,用畢 close。
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic final record -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()釋放已解析的字型;之後的量測丟出 IllegalStateException。static FixedTextMeasurercreate(ReportFonts fonts) default FixedTextMeasurer.Measurement字距為 0 的量測。Tab 展開成四個空格,與FixedDocument.Text一致;換行與其他控制字元拒絕。
-
Method Details
-
create
-
measure
FixedTextMeasurer.Measurement measure(String text, String family, double sizePt, boolean bold, double letterSpacingPt) Tab 展開成四個空格,與FixedDocument.Text一致;換行與其他控制字元拒絕。- Parameters:
text- 單行文字family- 邏輯字型家族sizePt- 字級(pt)bold- 是否使用粗體字面letterSpacingPt- 相鄰字元間的額外距離(pt,非負)- Returns:
- 量測結果
-
measure
default FixedTextMeasurer.Measurement measure(String text, String family, double sizePt, boolean bold) 字距為 0 的量測。 -
close
-