[vtk-developers] UTF8 text rendering

Sean McBride sean at rogue-research.com
Thu Sep 9 10:04:47 EDT 2010


On Wed, 30 Jun 2010 16:31:22 +0200, Marco Nolden said:

>I wrote a little fix to enable the rendering of utf8 characters. I think 
>the restriction to ascii actually was a bug caused by the incorrect 
>conversion of signed and unsigned values which did not work for 
>character codes >127:
>
>http://github.com/nolden/VTK/commit/9ba958806256e38ae4ae4fc424c37f8a7eea2ae9
>
>See also:
>http://www.vtk.org/Bug/view.php?id=4501
>
>Maybe you could include that till the unicode support is fully implemented.

Marco, Marcus,

I've updated to git head to try this and it does not work for me. 

After a quick look at the code in vtkFreeTypeUtilities.cxx, I'm not
surprised UTF8 does not work.  The code does things like:

for (; *str; str++)

which presupposes that each character is one byte, which is not the case
with UTF8.  The patch did nothing to correct this.  Indeed, if I use
UTF8 characters that are represented as 2 bytes, they are rendered as
two characters.

So the first question is: which character encoding does
vtkTextActor::SetInput() expect?  The documentation was regressed in
this regard:
<http://vtk.org/gitweb?p=VTK.git;a=blobdiff;f=Rendering/
vtkTextActor.h;h=8e1363d66962f15f5ec3
4dc8cb21308730043e83;hp=5ed913a900677
2d074cf3f642acb698be3d5b1ce;hb=331a44
656276882766248c1f8e338434b40226ef;hp
b=b5510d3eb9aff91706820b59516f741698dfa9f7>

Through experimentation, I believe the answer is: ISO-8859-1.  Though
I'm not sure if that depends on the platform or the font, or anything
else.  Anyone know?

Marco, might you have misused the term 'UTF8' to mean 'better than
ASCII'?  Character encodings are a complicated thing, I've always found
this a good article if you want to learn more:
<http://www.joelonsoftware.com/articles/Unicode.html>

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada





More information about the vtk-developers mailing list