RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
DelphiRAD Studio

Learn To Add Custom Text Rendering And Formatting Capabilities To Your Delphi FMX Controls Quickly

Most applications demand high-quality text rendering, resolution-independent outline fonts, and full Unicode text and layout support. Looking for a device-independent text layout system that improves text readability in documents and in UI for Your Delphi/C++ applications? How to build such Text Rendering Capabilities to your FireMonkey controls? This post will guide you. (e.g) Let’s see how to enhance the TLabel control with Rendering and formatting capabilities for the Text in HTML Tags.

How to create:
1. Create a descendant of TLabel that supports a limited selection of HTML tags. Parse the label for HTML tags every time the text changes.
2. Override its Dochanged method to parse the text for HTML tags
3. Use Firemonkey’s TTextLayout class to apply formatting attributes to parts of the text.
Note: No need to use HTML for formatting instead we can use TTextlayout.

  • TTextLayout is an abstract class that provides mechanisms to render text quickly. Such rendering systems are supported by DirectWrite API (Windows) and Core Text framework (OS X). Also used to calculate glyph positions, measure text, draw text, and covert to curves for path effects and 3D extrusion.
  • To create this class, use TTextLayoutManager – In charge of choosing the appropriate layout class type for the current running platform.
  • Use AddAttribute to assign text block properties like TTextRange (starting position and length) and TTextAttribute (font and color).
  • When changing several properties of the layout, you should use the BeginUpdate and EndUpdate procedures.
  • Use RenderLayout to render the text on a canvas.
  • The PositionAtPoint method returns the position in the text by the position’s coordinates.
  • The RegionForRange method returns the array of the rectangles surrounding the range of the text specified in ARange.
  • Another feature is the ability to convert text to a TPathData object by calling the ConvertToPath procedure.

Check out the full Video of creating a Simple FMX HTML control below.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Deep Dive Webinar: Boost C++Builder Compile Speed with TwineCompile
Related posts
CodeDelphi

Quickly Build Enterprise-Grade Multi-Tier Solutions Using DataSnap In Delphi And C++

C++CodeDelphi

Easily Create A Python Container Type In Delphi And Execute It In This Windows Sample App

C++DelphiRAD Studio

Manual uninstall of RAD Studio/Delphi/C++Builder 10.4 Sydney

CodeDelphiRAD Studio

Learn How To Send Arrays To A PostgreSQL Database Server Using FireDAC In Delphi On Windows

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES