PDFium Delphi Component Docs

FPdfTextShaping unit

Unit: FPdfTextShaping
Shapes bidirectional Unicode text into visual glyph runs for TPdf.AddShapedText, with bounded input and output sizes and an extensible shaper base class

Workflow

APIPurpose
ShapePdfText(Text, FontName, FontSize, Direction, out Shaped)Shapes text with the built-in Windows Uniscribe implementation and default resource limits
TPdfTextShaper.ShapeAbstract shaping contract for custom engines that return glyph identifiers, clusters, visual runs, advances, and selected font data
TPdfUniscribeTextShaper.ShapeUses usp10.dll to itemise, shape, place, and visually reorder text runs
TPdfTextShapingOptions.DefaultReturns automatic direction with limits of 1,000,000 characters, 2,000,000 glyphs, and 100,000 runs
ConfigureTextShaper(Shaper)Installs the shaping backend the unit uses, replacing the built-in one for the rest of the process; the unit takes ownership of the instance
ClearTextShaperRemoves an installed backend and returns to the platform default
ActiveTextShaperThe backend currently in use, or nil when no shaper is available on this platform
ActiveTextShaperNameName the active backend reports, for logging and for telling one deployment from another

Public types

TypeDescription
EPdfTextShapingErrorException raised for invalid inputs, resource-limit violations, font-data failures, or shaping-engine errors
TPdfTextDirectionptdAuto, ptdLeftToRight, or ptdRightToLeft
TPdfShapedGlyphOne glyph with GlyphID, Advance, OffsetX, OffsetY, ClusterStart, and ClusterLength
TPdfShapedGlyphsDynamic array of TPdfShapedGlyph records
TPdfShapedRunOne visual run with TextStart, TextLength, VisualX, Width, BidiLevel, IsRightToLeft, and Glyphs
TPdfShapedRunsDynamic array of TPdfShapedRun records in visual order
TPdfShapedTextSource Text, selected FontName, FontSize, embedded FontData, shaped Runs, total Width, GlyphCount, and LogicalCharacterCount
TPdfTextShapingOptionsDirection, MaxCharacters, MaxGlyphs, and MaxRuns resource limits
TPdfTextShaperAbstract base class for a caller-provided shaping implementation
TPdfUniscribeTextShaperBuilt-in Windows implementation of TPdfTextShaper

Remarks

Example

var
  Shaped: TPdfShapedText;
  MeasuredWidth: Single;
begin
  if ShapePdfText(Text, 'Segoe UI', 12, ptdAuto, Shaped) then
    MeasuredWidth := Shaped.Width;
end;

See Also

TPdf.AddShapedText