I'm trying to create a image that has text in is (using datatype text-data-yx). The trouble is in some cases there are special characters in it like é or à etc and they don't get displayed correctly (the input in html so they are encoded like à etc). When I put the html with encoded (&...; stuff) in the SetTitle it all goes well and the correct character is shown. However if I put them in SetDataValues, the text gets displayed as the & sequence (eg à). So pulling through html_entities_decode fixes this for some characters (like é) but others (è) get malformed (eg egrave becomes a c with a reverse ^. I tried various options for html_entity_decode. And if I just plain var_dump the output of the data it shows the correct characters. Any ideas on how to fix this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If it is working in titles, but not in data labels from your data array, then my first suspect is fonts. Are you using TrueType fonts for the data labels too? Special characters only work with TrueType font text.
(P.s. I'm not sure what Sourceforge / markdown did to your message, but it some of it doesn't make sense, for example: "the text gets displayed as the & sequence (e.g. ...)" where ... is an accented a. If the problem turns out to not be just a font issue, could you post a reply with more specific examples and check (with Preview) to make sure it comes through OK?)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To clarify for anyone else: Named character entities like à do not work anywhere. Numeric character entities like à and UTF-8 sequences work only with TrueType fonts. Using characters above ASCII 126 works with both TrueType and GD built-in fonts, but the GD built-in fonts are encoded for ISO8859-2 not the usual ISO8859-1 (Latin1) so you probably won't get the characters you expect. More info can be found here
This is how GD processes strings - PHPlot doesn't do anything to them.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to create a image that has text in is (using datatype text-data-yx). The trouble is in some cases there are special characters in it like é or à etc and they don't get displayed correctly (the input in html so they are encoded like à etc). When I put the html with encoded (&...; stuff) in the SetTitle it all goes well and the correct character is shown. However if I put them in SetDataValues, the text gets displayed as the & sequence (eg à). So pulling through html_entities_decode fixes this for some characters (like é) but others (è) get malformed (eg egrave becomes a c with a reverse ^. I tried various options for html_entity_decode. And if I just plain var_dump the output of the data it shows the correct characters. Any ideas on how to fix this?
If it is working in titles, but not in data labels from your data array, then my first suspect is fonts. Are you using TrueType fonts for the data labels too? Special characters only work with TrueType font text.
(P.s. I'm not sure what Sourceforge / markdown did to your message, but it some of it doesn't make sense, for example: "the text gets displayed as the & sequence (e.g. ...)" where ... is an accented a. If the problem turns out to not be just a font issue, could you post a reply with more specific examples and check (with Preview) to make sure it comes through OK?)
Cool, thanx! Adding
$plot->SetFontTTF('y_label'...
seems to fix it.
(I sorta expected SF to catch those & sequeces :/)
Glad it works.
To clarify for anyone else: Named character entities like à do not work anywhere. Numeric character entities like à and UTF-8 sequences work only with TrueType fonts. Using characters above ASCII 126 works with both TrueType and GD built-in fonts, but the GD built-in fonts are encoded for ISO8859-2 not the usual ISO8859-1 (Latin1) so you probably won't get the characters you expect. More info can be found here
This is how GD processes strings - PHPlot doesn't do anything to them.