Page 1 of 1

TChart.Title not rendering correct when using HTML

Posted: Wed Apr 27, 2016 9:13 am
by 16577799
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 7222 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 7224 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.

Re: TChart.Title not rendering correct when using HTML

Posted: Thu Apr 28, 2016 11:58 am
by yeray
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.

Re: TChart.Title not rendering correct when using HTML

Posted: Thu Apr 28, 2016 12:11 pm
by yeray
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);
-- 

Re: TChart.Title not rendering correct when using HTML

Posted: Thu Apr 28, 2016 3:37 pm
by 16577799
Very nice!! :D

Thanx!