Printing Unicode text...

BlitzMax Forums/BlitzMax Programming/Printing Unicode text...

neilo(Posted 2006) [#1]
Hi,

I'm just starting a multimedia presentation program that is right up Blitz's alley. I'm taking 3D content from Autodesk Inventor (ultra-high end parametric modelling software) and converting the models into something Blitz can use (It's a c# project, makes a OLE link to Inventor and reads out the vertex information). The multimedia stuff is for interactive manuals of our equipment.

The manuals must be translated into all sorts of languages (an occupational hazard being a global company), so Unicode is a must.

I was heading down the Dark Basic path, but stopped dead with Unicode. Blitz 3D doesn't seem to do the double-byte thing, either (willing to be proved wrong on that, though). BlitzMax does do the unicode shuffle, much to my surprise.

I've written a little test program, to print some Arabic:

Graphics 640,480

Local font:TImageFont=LoadImageFont("c:\windows\fonts\cour.ttf",24)
SetImageFont font

text$=""

Local unicode:Short[8]


Local nextChar:Short

For i=6 To 0 Step -1
ReadData nextChar
unicode[i]=nextChar
Next

text$=string.FromShorts(unicode,7)

While Not KeyHit(KEY_ESCAPE)
Cls
DrawText text$,100,100
Flip
Wend

' A line of Arabic text
DefData $0625,$0646,$0643,$0644,$064a,$0632,$064a

(sorry if the formatting is smashed; first time poster to the forums)

Arabic is indeed being printed - but all the characters are in the final form!

So... has anyone succesfully printed a fancy double-byte character to the screen before, using BlitzMax? Or, am I doing something spectacularly stupid here? I followed the DrawText command right down; it processes text one character at a time, instead of handing off to the OS for printing. So I'm guessing there might be another form of DrawText which will process a string in it's entirety.

Can anyone give me a pointer or two as to what I'm doing wrong - or, if soemone from BRL is reading, can I keep developing my application, with a proper Unicode update just 'round the corner?

Kind regards,

Neil


Regular K(Posted 2006) [#2]
In the most extreme case, you will have to write your own module to draw unicode.

Although, I don't see anything wrong with that code up there. I guess I just don't know enough about arabic?
but all the characters are in the final form!



WendellM(Posted 2006) [#3]
has anyone succesfully printed a fancy double-byte character to the screen before, using BlitzMax?

I'm not too familiar with Arabic, but using a slightly modified version of your code (using msgothic.ttf rather than cour.ttf and looping "0 to 2" to go left-to-right rather than right-to-left with "6 to 0 step -1") I was able to print "DefData $30e4, $30de, $30c8" correctly as "Yamato" in katakana:



So, your approach works just fine with double-byte unicode Japanese. And thanks for posting it, since this is the first that I've seen that works in BlitzMax.


Arabic is indeed being printed - but all the characters are in the final form!

Looking at Charmap, it seems that the initial and medial forms are also available (just with higher unicode values than in your test above):




(sorry if the formatting is smashed; first time poster to the forums)

Welcome aboard, Neil! You can use (code)(/code) or (codebox)(/codebox) around your code to preserve it (replacing the "()" with "[]"). More formatting goodness is at: What are the forum codes?

Wendell


neilo(Posted 2006) [#4]
Hi,

Thanks to both of you for the replies.

Wendell, thanks for you additional help / pointers.

Looks like I've got some work ahead of me :)

Neil


Jay Kyburz(Posted 2006) [#5]
Neilo, I would really appreciate if you could get back to use with anything you discover. I have been hoping to support Unicode languages in my game but have been having trouble because i don't know enough about unicode.

Your test code it a great head start for me. Anything else would be great!