TChart.Title not rendering correct when using HTML

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Whookie
Newbie
Newbie
Posts: 5
Joined: Thu Mar 03, 2016 12:00 am

TChart.Title not rendering correct when using HTML

Post by Whookie » Wed Apr 27, 2016 9:13 am

There seem to be some problems with TChart - Title when using HTML as text format:

I used "<b>Header</b><small>(Details)</small>Test" (without the quotes) and a font size of 13 to get
s1.PNG
s1.PNG (7.51 KiB) Viewed 7218 times
1. The Header isn't centered in a correct way (centering seems to be based on the plain html-string)
2. The closing </small> - Tag is not recogniced
3. "Test" (and "</small>") is placed with a wrong baseline

By experimenting I found, that removing the "/" from the closing </small> tag has another effect:
s2.PNG
s2.PNG (5.98 KiB) Viewed 7220 times
It seems, as the </small> - tag is ignored the next string is drawn even smaller BUT also the baseline moves down (as if <sub></sub> where used).

Note: I do only need the first 2 parts "<b>Header</b><small>(Details)</small>", the "Test" string was just added when experimenting with the HTML expression.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart.Title not rendering correct when using HTML

Post by Yeray » Thu Apr 28, 2016 11:58 am

Hello,

I could reproduce the problem so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1528

I could also fix it. However, I'm afraid it couldn't be included in the maintenance release we've just published.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart.Title not rendering correct when using HTML

Post by Yeray » Thu Apr 28, 2016 12:11 pm

However, as you own the source code, you can apply the fix to your sources and recompile the packages with TeeRecompile.
Here the git patch from the commit, affecting only TeeHtml.pas (in your "Sources" folder):

Code: Select all

---
 TeeHtml.pas | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/TeeHtml.pas b/TeeHtml.pas
index 407ecd4..a08c363 100644
--- a/TeeHtml.pas
+++ b/TeeHtml.pas
@@ -672,10 +672,28 @@ var
     end
     else
     if tmpU='<BIG>' then
-       NewSize(ACanvas.Font.Size+2)
+    begin
+      NewSize(ACanvas.Font.Size+2);
+      y:=y-4;
+    end
     else
     if tmpU='<SMALL>' then
-       NewSize(ACanvas.Font.Size-2)
+    begin
+      NewSize(ACanvas.Font.Size-2);
+      y:=y-1;
+    end
+    else
+    if tmpU='</BIG>' then
+    begin
+      SetBackFont;
+      y:=y+2;
+    end
+    else
+    if tmpU='</SMALL>' then
+    begin
+      SetBackFont;
+      y:=y-2;
+    end
     else
     if tmpU='</SUB>' then
     begin
@@ -689,13 +707,13 @@ var
       y:=y+ACanvas.FontHeight;
     end
     else
-    if tmpU='</SUPER>' then
+    if (tmpU='</SUPER>') or (tmpU='</SUP>') then
     begin
       SetBackFont;
       y:=y+(ACanvas.FontHeight div 2);
     end
     else
-    if tmpU='<SUPER>' then
+    if (tmpU='<SUPER>') or (tmpU='<SUP>') then
     begin
       NewSize(ACanvas.Font.Size {$IFDEF FMX}*0.5{$ELSE}div 2{$ENDIF});
       y:=y-(ACanvas.FontHeight div 2);
-- 
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Whookie
Newbie
Newbie
Posts: 5
Joined: Thu Mar 03, 2016 12:00 am

Re: TChart.Title not rendering correct when using HTML

Post by Whookie » Thu Apr 28, 2016 3:37 pm

Very nice!! :D

Thanx!

Post Reply