|
Possible Bug with CDML advanceTo |
Posted by Medic89 on Jan-27-2023 21:13 |
|
Hi Peter,
ich make a PDF-Output of my chart and on this PDF page I create a textbox with Text that contains the CDML advanteTo statement. I used to set the size of the Textbox with the two separate functions setWidth() and setHeight(). However, when I replace those two functions with the setSize() function, the advanceTo statements don't work anymore. |
Re: Possible Bug with CDML advanceTo |
Posted by Peter Kwan on Jan-30-2023 21:55 |
|
Hi Medic89,
I have just tried myself but I cannot reproduce the problem. In my case everything looks normal.
My code is as follows. It simply adds a line of CDML text with "advanceTo" to the chart, and use setSize to set the size. I added some lines and background colors to help me see the boundary of the chart and text box. Both the screen image and PDF looks normal to me.
PieChart* c = new PieChart(401, 401, 0xaaccee, Chart::Transparent);
// Add some lines to help me see the distance
for (int i = 0; i <= 400; i += 100)
c->addLine(i, 0, i, 400, 0x555555);
// The text box with CDML advanceTo and setSize
TextBox*t = c->addText(50, 100, "ABCD<*advanceTo=200*>DEFG", "Arial", 10);
t->setBackground(0xffcc99);
t->setSize(300, 150);
c->makeChart("advanceToTest.pdf");
c->makeChart("advanceToTest.png");
Is it possible to provide a simple example (such as to modify the CDML in my test code) to help me reproduce the problem?
Best Regards
Peter Kwan
|
Re: Possible Bug with CDML advanceTo |
Posted by Medic89 on Jan-31-2023 00:36 |
|
This is my Textbox, which I add to a piechart:
TextBox* TextBoxEZ1 = nextPage->addText(962, 159, TCHARtoUTF8(L"<*font=Arial Bold,size=20,color=000000*>Titlen<*font=Arial,size=18,color=000000*>nText1<*advanceTo=74*>Text2<*advanceTo=258*>more text"), "Arial", 18);
TextBoxEZ1->setBackground(Chart::Transparent, RGB(0, 0, 0), 0);
TextBoxEZ1->setMargin(5, 0, 2, 2);
TextBoxEZ1->setWidth(563);
TextBoxEZ1->setHeight(231);
when I replace the last two functions with setSize(), the advanceTo statement doesn't work anymore. |
Re: Possible Bug with CDML advanceTo |
Posted by Peter Kwan on Jan-31-2023 01:49 |
|
Hi Medic89,
Unluckily, I am unable to reproduce the problem.
I have just tried your code by creating two text boxes in the same chart, one using setWidth/setHeight, and the order using setSize. In my case, they look identical. I also use Photoshop to measure examine the text pixel by pixel, and I found that all the text are at their expected position.
The exact code I use is:
PieChart* c = new PieChart(801, 601, 0xaaccee, Chart::Transparent);
TextBox* t1 = c->addText(100, 50, TCHARtoUTF8(L"<*font=Arial Bold,size=20,color=000000*>Titlen<*font=Arial,size=18,color=000000*>nText1<*advanceTo=74*>Text2<*advanceTo=258*>more text"), "Arial", 18);
t1->setBackground(Chart::Transparent, RGB(0, 0, 0), 0);
t1->setMargin(5, 0, 2, 2);
t1->setWidth(563);
t1->setHeight(231);
TextBox* t2 = c->addText(100, 300, TCHARtoUTF8(L"<*font=Arial Bold,size=20,color=000000*>Titlen<*font=Arial,size=18,color=000000*>nText1<*advanceTo=74*>Text2<*advanceTo=258*>more text"), "Arial", 18);
t2->setBackground(Chart::Transparent, RGB(0, 0, 0), 0);
t2->setMargin(5, 0, 2, 2);
t2->setSize(563, 231);
c->makeChart("c:\\temp\\advanceToTest.pdf");
c->makeChart("c:\\temp\\advanceToTest.png");
Best Regards
Peter Kwan
|
Re: Possible Bug with CDML advanceTo |
Posted by Medic89 on Jan-31-2023 02:22 |
|
I realised, my text contains "n" instead of "n":
TextBox* TextBoxEZ1 = nextPage->addText(962, 159, TCHARtoUTF8(L"<*font=Arial Bold,size=20,color=000000*>Titlen<*font=Arial,size=18,color=000000*>nText1<*advanceTo=74*>Text2<*advanceTo=258*>more text"), "Arial", 18);
TextBoxEZ1->setBackground(Chart::Transparent, RGB(0, 0, 0), 0);
TextBoxEZ1->setMargin(5, 0, 2, 2);
TextBoxEZ1->setWidth(563);
TextBoxEZ1->setHeight(231); |
Re: Possible Bug with CDML advanceTo |
Posted by Peter Kwan on Jan-31-2023 14:35 |
|
Hi Medic89,
I see. I understand your text now. The "n" is caused by the forum software, as it treats the "\\" as an escape character. (You can see the "\\" I typed here because I type it as double backslash "\\\\".) I just found the code in my previous message has the same problem. Instead of:
c->makeChart("c:\\temp\\advanceToTest.png");
it should be:
c->makeChart("c:\\\\temp\\\\advanceToTest.png");
I will test your code and update you later.
Best Regards
Peter Kwan |
Re: Possible Bug with CDML advanceTo |
Posted by Peter Kwan on Feb-01-2023 01:39 |
|
Hi Medic89,
Thank you very much for reporting this problem to us and take the time to help us reproduce this problem. I confirm it is in fact a bug in ChartDirector. It is triggered when the following conditions are met:
(a) Box.setSize is used, and TextBox.setWidth is not used.
(b) There is a new line character ("\\n" in C++) in the CDML text.
(c) There is an <*advanceTo=xxx*> after the new line character.
In this case, the "advanceTo" will not move the text to the correct position.
For the moment, to work around, if the code needs to specify the height, please use TextBox.setWidth and TextBox.setHeight to set the width and height instead of Box.setSize.
We will fix this bug in the next version of ChartDirector.
Best Regards
Peter Kwan |
|