# Windows rendering issues

**URL:** https://discourse.vtk.org/t/windows-rendering-issues/2542
**Category:** Development
**Created:** [February 4, 2020, 5:38pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542 "2020-02-04T17:38:42Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [February 4, 2020, 5:38pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/1 "2020-02-04T17:38:42Z")

</div>

OK, seeing some odd behaviors on Window using Java/VTK 6.3 (but also with 8.1.2 as well).

1. In a vtkCaptionActor2D caption, the degree symbol (0x00B0) does NOT render, and it actually will cause the ENTIRE caption text to not render. This does not happen on the Mac or Linux.
2. vtkPNGWriter flips the data along the x axis of the image (so top is bottom, vice versa). This also does not happen on Macs.

Any thoughts on what is going on here?

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 5, 2020, 2:04am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/2 "2020-02-05T02:04:56Z")

</div>

VTK 8.1.2 doesn’t support unicode, so extended characters depend on your locale CODE\_PAGE setting.

Have you tried the latest build of VTK from master? It uses utf-8 strings. Displaying text/labels has not been addressed yet; however, since it appears to be working on Mac/Linux, the changes might resolve your issue.

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [February 6, 2020, 9:38pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/3 "2020-02-06T21:38:07Z")

</div>

Sadly, we can’t run with the master because VTK (or should I say the JOGL library, I think) is horribly broken on Mac for the OpenGL2 pipeline code (at least with how we use it in our code), so we haven’t been able to test with anything beyond VTK 8.1.2.

I’m not sure what CODE\_PAGE is - is that a build switch when compiling VTK? What are the possibilities?

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 6, 2020, 10:43pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/4 "2020-02-06T22:43:05Z")

</div>

Here’s some information on setting the code page on Windows. [https://docs.microsoft.com/en-us/cpp/c-runtime-library/code-pages?view=vs-2019](https://docs.microsoft.com/en-us/cpp/c-runtime-library/code-pages?view=vs-2019)  
You could try altering your code page to see whether it affects the output. Even if that works, this approach is flawed since it breaks on any machine with a different code page setting.

Another option is to build VTK with Freetype. I haven’t had success with this either due to problems with the search paths in CMake on Windows, but I understand there is a superbuild for Paraview which compiles properly. My preliminary investigations _suggest_ that Freetype will render the correct characters provided the correct font file is provided.

Please detail the steps to reproduce this issue. It would make a good test case for the UTF-8 support in VTK 8.2+ Perhaps the fix can be back-ported later.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 11, 2020, 2:00am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/5 "2020-02-11T02:00:27Z")

</div>

You could also try setting the ActiveCodePage property in the manifest file for VTK 8.1.2, if you’re using Windows 10 (1903)

See some recent discussion here [What is state of the art: Unicode file names on Windows](https://discourse.vtk.org/t/what-is-state-of-the-art-unicode-file-names-on-windows/1821/47)

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 18, 2020, 12:56am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/6 "2020-02-18T00:56:46Z")

</div>

@Gilthalas I’m going to ask again. Please outline the steps to recreate this bug. Otherwise it won’t get fixed.

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [February 18, 2020, 1:24am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/7 "2020-02-18T01:24:47Z")

</div>

I’ve been hard at work getting the build for vtk8.2 to work, which I am glad to say I have been successful at.

I am glad to report that it seems like the vtkPNGWriter flip problem has gone away, so that’s good!

The degree symbol still doesn’t render correctly in vtk 8.2. Are the utf-8 features only in the master branch? We still have some issues getting that to build, but now knowing what I do on how to build 8.2, I may be able to get master to compile.

My other concern was that the degree symbol may be deeper than vtk - it can clearly handle it on the Mac and on Linux, so I’m wondering what makes the Windows build not able to handle it.

More information as a I get it on using the master branch.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 18, 2020, 1:37am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/8 "2020-02-18T01:37:23Z")

</div>

The utf-8 changes are only in the master branch but they affect file and path names, so that probably won’t help you. Are you using Windows 10? Did you try setting the code page to UTF-8 in the application manifest?

I’m also interested in rendering labels/text with extended characters which is the next step in the Unicode compliance fixes. I suspect the Linux/Mac builds are using a system API for the rendering which handles utf-8 text, whereas Windows does not so it requires explicit handling in VTK.

What I’m asking for is some simple steps to reproduce this problem; a few lines of code. I still have no clue what classes/methods you’re using.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 18, 2020, 7:02am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/9 "2020-02-18T07:02:29Z")

</div>

Where is the caption text coming from? Is it a string literal in your code? Is it being typed into a dialog? Is it being read from a file?

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [February 18, 2020, 2:28pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/10 "2020-02-18T14:28:14Z")

</div>

It looks something like this:

```
String deg = String.valueOf(Character.toChars(0x00B0));
String captionLabel = String.format(fmt, lon / Math.PI * 180) + deg;

vtkCaptionActor2D caption = new OccludingCaptionActor(intersectPoint, null , smallBodyModel);
caption.SetCaption(captionLabel);
caption.BorderOff();
caption.SetAttachmentPoint(intersectPoint);
captionActors.add(caption);

```

Where the “deg” string contains the unicode for the degrees symbol. The text just doesn’t render at all (the degree symbol and the surrounding text) on Windows The line connecting the caption to the attachment point does render, however.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 18, 2020, 9:10pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/11 "2020-02-18T21:10:20Z")

</div>

In Java a string takes a UTF-16 representation. Unfortunately that is most likely a little-endian, LE, form on Windows and a big-endian, BE, form on Linux/Mac; or vice versa. So the byte order is swapped.

The simple solution is to only pass UTF-8 bytes to VTK char\* parameters. Try this  
`caption.SetCaption(captionLabel.getBytes(StandardCharsets.UTF_8));`

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [February 18, 2020, 9:19pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/12 "2020-02-18T21:19:03Z")

</div>

Thanks! I will try that out when I get a chance - may not be for a few days though. Will let you know.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 19, 2020, 12:19am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/13 "2020-02-19T00:19:35Z")

</div>

Actually you can’t pass a byte array to the `SetCaption()` method, so that won’t work either.

I’ve looked at the java wrapper code now and there is a bug converting a java String to C++ char\* due to the JVM `Charset.defaultCharset()` setting. On Mac/Linux it defaults to UTF-8, whereas on Windows it depends on the locale. That is the reason you’re seeing correct rendering on Mac/Linux.

The conversion to UTF-8 needs to be handled explicity in VTK. I will push a MR for the fix to the master branch shortly.

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [February 19, 2020, 12:41am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/14 "2020-02-19T00:41:59Z")

</div>

Thanks! Looking forward to the merge request. Send a link to the MR when you have it - I may bring it into my forked version of 8.2 I have with some other changes.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [February 19, 2020, 1:44am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/15 "2020-02-19T01:44:44Z")

</div>

Here it is. [https://gitlab.kitware.com/vtk/vtk/merge\_requests/6487](https://gitlab.kitware.com/vtk/vtk/merge_requests/6487)

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [May 9, 2020, 5:48am UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/16 "2020-05-09T05:48:53Z")

</div>

@Gilthalas Did you ever patch these changes into your forked VTK 8.2 repository?

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [May 12, 2020, 12:59pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/17 "2020-05-12T12:59:15Z")

</div>

No I never did - life got in the way of me working on this, and then before I knew it 9.0 was out the door - is the change in there as well?

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [May 12, 2020, 1:14pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/18 "2020-05-12T13:14:37Z")

</div>

I know the feeling. We live in a time of great upheaval. I believe the changes made it into VTK 9 @ben.boeckel?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 12, 2020, 3:28pm UTC](https://discourse.vtk.org/t/windows-rendering-issues/2542/19 "2020-05-12T15:28:54Z")

</div>

It has the 9.0 tag, so it made it (I removed the milestone from MRs that didn’t make it a while ago because they kept showing up in my “find 9.0 MRs that aren’t actually there” script; most of those have links to the MR where they did land in 9.0).
