From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Picture Box With Unicode

Solved!
Go to solution

Hello all,

 

I'm afraid the answer to this question is probably going to be "you just can't do that," but I'm posting just in case there is some genius out there that has an idea to make it work.

 

I want to draw text on a .NET picture box. I have the "UseUnicode=true" ini flag and I am able to type unicode into string controls and display it properly. However when I wire that string control into the "DrawString" .NET node, it treats it as though it was a regular ascii string that's twice as long (I guess) and doesn't draw it properly. 

 

UnicodePictureBox.PNG

 

Does anyone know a way to draw unicode text into a .NET picture box?

 

(attached is a VI with my attempt)

0 Kudos
Message 1 of 7
(2,662 Views)

Oops sorry, realized I had a missing VI. See attached VI instead.

0 Kudos
Message 2 of 7
(2,643 Views)

Try changing the font family to Symbol.  This doesn't have all Greek letters but it has a lot of them, especially ones associated with math.  You can find a character map online to know what HEX values to use.  Change the text box to display HEX values and type in the values you need. I understand that Arial Unicode MS font supports all of the Greek characters but I do not see it as an option on computers without Office installed.  Ideally, you find a font that is installed by default with Windows, otherwise you would need to buy a font or locate a free one online.  Lucida Sans Unicode may work for you. 

 

There is a VI called "Color to RGB".  It will convert LabVIEW color to RGB values (minus the Alpha channel).  Press Control+Spacebar and search for RGB. 

 

I wouldn't put this code in the Timeout case.  Create a value change event for the string control, change the string control to "Update Value While Typing" and put the drawing code there.  That way, the code isn't making unnecessary .NET calls when the value hasn't changed. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 7
(2,574 Views)

Thanks for your suggestion! I just tried it, but sadly it still isn't working for me. I have the Lucida Sans Unicode font installed, but when I put that in instead of Arial, I get the same result (except the nonsense characters that show up are styled slightly differently).

 

I think the problem is that the DrawString function is interpreting the string like strictly each character is 1 byte, that's why its displaying six characters when I only have 3, but I need it to interpret the string like it's UTF-8. I guess there's no way to do this? Or maybe there is some other .net function that does it?

0 Kudos
Message 4 of 7
(2,557 Views)

See attached.  It works for me.  Start typing in the text box and the picture will update.  

2019-04-05_12-10-19.png

Edit: Virus scan failed on the VI.  Not sure why so i'm zipping it.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 5 of 7
(2,554 Views)

Oh, I see, you mean to not use unicode at all and just use a font that maps to greek symbols. Hmm, yes this might work, but I'm worried then we would need to find a special font for each language we support and work out the mapping for all the characters, and I'm afraid that could be brittle and not very scaleable.

 

Our goal is that once the program is built into an executable, it can support any new language just by being provided a new translation file, without re-building the executable.

0 Kudos
Message 6 of 7
(2,546 Views)
Solution
Accepted by topic author prettypwnie

Ok I think I've figured it out! You got me on the right track, realizing that using unicode just isn't going to work for this. But there is a way to make it work using the windows settings.

 

In case anyone else has this problem later, what I did was change the language for non-unicode programs:

system local settings.PNG

 

Once you change this it will work to display text in that language without using unicode - I don't know how exactly it does work, but somehow it does (?). It's not as flexible as I would prefer, because you can only use one language at a time, but it does work and this way I don't have to play around with finding the mapping to a special font that may or may not contain all the characters for whatever language I'm using.

0 Kudos
Message 7 of 7
(2,538 Views)