<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Sean,<br>
<br>
Thanks for the tips on encoding. I knew that I probably wasn't using
the right terminology and I'll read up on those soon.<br>
<br>
In the meantime, I'm no closer to being able to display "J (A/m2)"
as the title of a vtkScalarBarActor.<br>
<br>
I tried using these APIs on the TitleTextProperty of the
vtkScalarBarActor<br>
<pre> m_VTKScalarBarActor->GetTitleTextProperty()->SetFontFamily(VTK_FONT_FILE);
m_VTKScalarBarActor->GetTitleTextProperty()->SetFontFile("C:\\Windows\\winsxs\\amd64_microsoft-windows-font-truetype-arial_31bf3856ad364e35_6.1.7601.18528_none_d0a29012c3ff391b\\arial.ttf");
</pre>
and then encoding the string to be a sequence of hex escape
sequences like the example here:<br>
<pre> <a class="moz-txt-link-freetext" href="http://marc.info/?l=vtkusers&m=138868987612759&w=2">http://marc.info/?l=vtkusers&m=138868987612759&w=2</a>)</pre>
and it just spits out the string as-is, that is something like
"\x4A\x20\x28\x41\x2F\x6D\xC2\xB2\x29".<br>
<br>
Is there a tutorial or a wiki that shows how to use Unicode strings
in VTK? Ideally with the system fonts? What's the magic formula? ;-)<br>
<br>
Thanks.<br>
<br>
<div class="moz-cite-prefix">On 1/20/2015 11:05 AM, Sean McBride
wrote:<br>
</div>
<blockquote
cite="mid:20150120160547.2004569427@mail.rogue-research.com"
type="cite">
<pre wrap="">On Tue, 20 Jan 2015 10:18:44 -0500, Serge Lalonde said:
</pre>
<blockquote type="cite">
<pre wrap="">I'm upgrading from VTK 5.10.1 to VTK 6.1. All went smoothly until I ran
into an error rendering a vtkScalarBarActor whose title was set to "J (A/m2)".
This worked fine in 5.10.1, but in 6.1, the vtkutf8::is_valid() method
called from vtkUnicodeString::from_utf8() returns false because the
value of "2" is 0xB2 (in the extended ASCII range) but the vtkutf8 code
internally stops at 0x80 (sequence_length() in core.h returns 0). That
in turn causes a debug message "vtkUnicodeString::from_utf8(): not a
valid UTF-8 string." to appear and then other problems with vtkTextActor
not being able to calculate its bounds and so on.
</pre>
</blockquote>
<pre wrap="">
I think you are a bit confused about character encodings (it's a confusing thing!).
First, there are no ASCII characters above 127. ASCII is a 7 bit code. What you mean to refer to is ISO-8859-1 aka Latin1. In that encoding, the 'square' character does indeed seem to be 0xB2:
<a class="moz-txt-link-rfc2396E" href="https://en.wikipedia.org/wiki/ISO/IEC_8859-1"><https://en.wikipedia.org/wiki/ISO/IEC_8859-1></a>
8859 is not part of Unicode at all and is not the same as UTF-8.
There are many online Unicode tools, ex:
<a class="moz-txt-link-rfc2396E" href="http://utf8-chartable.de"><http://utf8-chartable.de></a>
Where you can see the Unicode code point for 'superscript two' is U+00B2, which encoded as UTF-8 is 'c2 b2' in hex.
You might want to read this, which is a helpful classic:
<a class="moz-txt-link-rfc2396E" href="http://www.joelonsoftware.com/articles/Unicode.html"><http://www.joelonsoftware.com/articles/Unicode.html></a>
Cheers,
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<title>Signature</title>
<a href="http:://www.infolytica.com">www.infolytica.com </a><br>
300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3<br>
(514) 849-8752 x236, Fax: (514) 849-4239
</div>
</body>
</html>