How To: Draw HTML Formatted Text lazarus / 39-Graphics ---------------------------------------------------------------------- Marion · 2012-08-17 17:28 I have to write a control (TLabel) that will accepted simple HTML tags and render the rich text on the control canvas. I am wondering if anyone has found a tutorial on the best practices for this. Some of the questions I have are: How do you anticipate word breaks? How do you calculate the total RECT since some of the lines may be different heights? How do I keep track of where I am as I render the text on the Canvas? Any hints on how to do this will be appreciated. ---------------------------------------------------------------------- Phil · 2012-08-17 17:33 Quote from: Marion on August 17, 2012, 07:28:53 pmI have to write a control (TLabel) that will accepted simple HTML tags and render the rich text on the control canvas. I am wondering if anyone has found a tutorial on the best practices for this. Some of the questions I have are: How do you anticipate word breaks? How do you calculate the total RECT since some of the lines may be different heights? How do I keep track of where I am as I render the text on the Canvas? Any hints on how to do this will be appreciated. This might be more than you need: http://wiki.lazarus.freepascal.org/THtmlPort You might be able to use a narrow THtmlViewer as a label. In any case, you can see how it renders HTML. Thanks. -Phil ---------------------------------------------------------------------- Leledumbo · 2012-08-17 21:43 QuoteHow do you anticipate word breaks? How do you calculate the total RECT since some of the lines may be different heights?By making a good use of TextExtent QuoteHow do I keep track of where I am as I render the text on the Canvas?Use additional variables. Update as you draw.