HTML Processing
HSmart_DrawText
Draws text on a canvas with horizontal and vertical alignment control.Returns the size of the rendered text area.
Function HSmart_DrawText(CONST Canvas: TCanvas; CONST Text: String; CONST Rect: TRect; CONST HAlign, VAlign: Byte): TSize;
Parameters
- Canvas: TCanvas; the canvas on which to draw the text.
- Text: String; the text to render.
- Rect: TRect; the bounding rectangle for the text.
- HAlign: Byte; horizontal alignment (e.g. left, center, right).
- VAlign: Byte; vertical alignment (e.g. top, middle, bottom).
Return Value
Returns the size of the area occupied by the drawn text.HSmart_Text_Dimensions
Calculates the size of a multiline text block based on a fixed width.Useful for layout planning before rendering text on canvas.
Function HSmart_Text_Dimensions(CONST Canvas: TCanvas; CONST Text: String; CONST FixedWidth: Integer): TSize;
Parameters
- Canvas: TCanvas; the canvas used for measuring text.
- Text: String; the text content to measure.
- FixedWidth: Integer; maximum width for wrapping text.
Return Value
Returns the dimensions required to render the wrapped text block.HDrawText
Draws text directly on a canvas using standard Windows API flags.Provides low-level rendering control via bitwise style flags.
Procedure HDrawText(CONST Canvas: TCanvas; CONST Text: String; Rect: TRect; CONST Flags: Cardinal);
Parameters
- Canvas: TCanvas; the drawing surface.
- Text: String; the text to render.
- Rect: TRect; the area to render within.
- Flags: Cardinal; text rendering flags (e.g. DT_CENTER, DT_VCENTER, etc).
HDrawText_SL
Draws text on a canvas using simplified alignment flags.Automatically maps horizontal and vertical alignment into proper text flags.
Procedure HDrawText_SL(CONST Canvas: TCanvas; CONST Text: String; Rect: TRect; CONST Halign, Valign: Byte);
Parameters
- Canvas: TCanvas; the canvas on which to draw.
- Text: String; the text to be displayed.
- Rect: TRect; the text's drawing area.
- Halign: Byte; horizontal alignment value.
- Valign: Byte; vertical alignment value.
HTextDimensions
Calculates the pixel size required to render a string with the current canvas font.Optionally includes inter-character spacing for alignment purposes.
Function HTextDimensions(CONST Canvas: TCanvas; CONST Text: String; Inc_Pixel: Boolean = True): TSize;
Parameters
- Canvas: TCanvas; the canvas used for measurement.
- Text: String; the string to measure.
- Inc_Pixel: Boolean; if True, includes an extra pixel to align rendering properly.
Return Value
Returns the width and height required to draw the string.Convert_Html_Body_To_Hapi_Tagged_Text
Converts an HTML-formatted string into simplified HAPI tagged text.Strips unsupported HTML tags and replaces known elements with internal tag syntax.
Function Convert_Html_Body_To_Hapi_Tagged_Text(Html: String): String;
Parameters
- Html: String; the HTML content to convert.
Return Value
Returns a string with HAPI-style markup replacing the original HTML formatting.Convert_Hapi_Tagged_Text_To_Html
Converts a HAPI-tagged text string into standard HTML format.Replaces internal markup symbols with corresponding HTML elements.
Function Convert_Hapi_Tagged_Text_To_Html(Text: String): String;
Parameters
- Text: String; the HAPI-tagged string to convert to HTML.
Return Value
Returns a string with standard HTML markup derived from the HAPI tags.Convert_Chars_From_Unicode_To_Html
Encodes a Unicode string into HTML-safe format with optional line break handling.Replaces special characters with HTML entities and optionally converts CR to <br>.
Function Convert_Chars_From_Unicode_To_Html(Original_Unicode16: String; Convert_CR_To_BR: Boolean = True): String;
Parameters
- Original_Unicode16: String; the Unicode string to encode.
- Convert_CR_To_BR: Boolean; if True, line breaks are converted to <br> tags.
Return Value
Returns the encoded HTML-safe string.Does_Html_Need_To_Be_RtL
Analyzes a string to determine if it should be rendered as right-to-left HTML.Detection is based on the presence of RTL characters such as Hebrew or Arabic.
Function Does_Html_Need_To_Be_RtL(Text: String): Boolean;
Parameters
- Text: String; the input string to analyze.
Return Value
Returns True if the text includes RTL characters.Returns False otherwise.