Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-10

How do I use Unicode characters on MacOS / Carbon?

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Brad Campbell

G'day all.

On Linux/gtk2 I simply do this

Edit1.Text := WideChar($F080);

I don't even need to specify the font name as it's the only one with that character and it just gets pulled up.

On Carbon all I get is '?' in the non ASCII char ranges.

I've tried specifying the font by name ..

Edit1.Font.Name := 'Parallax';

..and the ASCII chars use that font, but still nothing outside the $20 - $7E range.

I'm trying to use these unicode chars in a Synedit and directly on a canvas with

Canvas.TextOut(aRect.Left + 2, aRect.Top + 2, WideChar(B));

Linux, no problem.. works perfectly.

Am I doing something obviously silly?

Regards,
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Tom Gregorovic
to Brad Campbell
Brad Campbell wrote 25 lines
G'day all. On Linux/gtk2 I simply do this Edit1.Text := WideChar($F080); I don't even need to specify the font name as it's the only one with that character and it just gets pulled up. On Carbon all I get is '?' in the non ASCII char ranges. I've tried specifying the font by name .. Edit1.Font.Name := 'Parallax'; ..and the ASCII chars use that font, but still nothing outside the $20 - $7E range. I'm trying to use these unicode chars in a Synedit and directly on a canvas with Canvas.TextOut(aRect.Left + 2, aRect.Top + 2, WideChar(B)); Linux, no problem.. works perfectly. Am I doing something obviously silly?

You have to pass strings to the LCL in UTF-8 encoding on all platforms. You can use UTF16ToUTF8 conversion routine from LCLProc unit.

Tom Gregorovic

Reply by email

Mattias Gaertner
to Brad Campbell: G'day all. On Linux/gtk2 I simply do this Edit1.Text := WideChar($F080); I don't even…
Show quoted text 8 lines
G'day all. On Linux/gtk2 I simply do this Edit1.Text := WideChar($F080); I don't even need to specify the font name as it's the only one with that character and it just gets pulled up.

It does not show here (gtk2/ubuntu). It shows the usual box with the hex code.

On Carbon all I get is '?' in the non ASCII char ranges.

Non ascii characters like 8364 (euro) works here (utf8/carbon).

Show quoted text 6 lines
I've tried specifying the font by name .. Edit1.Font.Name := 'Parallax'; ..and the ASCII chars use that font, but still nothing outside the $20 - $7E range.

Why do you think, that your font supports that character?

Show quoted text 8 lines
I'm trying to use these unicode chars in a Synedit and directly on a canvas with Canvas.TextOut(aRect.Left + 2, aRect.Top + 2, WideChar(B)); Linux, no problem.. works perfectly. Am I doing something obviously silly?

Mattias

Reply by email

Brad Campbell
to Tom Gregorovic: You have to pass strings to the LCL in UTF-8 encoding on all platforms. You can use…
Tom Gregorovic wrote
You have to pass strings to the LCL in UTF-8 encoding on all platforms. You can use UTF16ToUTF8 conversion routine from LCLProc unit.

I see. I just got lucky then that LCL/Gtk2 accepts UTF-16 directly with WideStrings :)

Thanks for the advice :)
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Brad Campbell
to Mattias Gaertner: On Sun, 05 Oct 2008 11:03:08 +0400 It does not show here (gtk2/ubuntu). It shows the…
Mattias Gaertner wrote 14 lines
On Sun, 05 Oct 2008 11:03:08 +0400 Brad Campbell wrote: > G'day all. > > On Linux/gtk2 I simply do this > > Edit1.Text := WideChar($F080); > > I don't even need to specify the font name as it's the only one with > that character and it just gets pulled up. It does not show here (gtk2/ubuntu). It shows the usual box with the hex code.

That would probably be because you don't have this particular font. It uses a Unicode range for "Manufacturer Specific" stuff..

> On Carbon all I get is '?' in the non ASCII char ranges. Non ascii characters like 8364 (euro) works here (utf8/carbon).

Ok, I tried converting $F080 to UTF-8 and inserting it that way, but I got an odd symbol that was not what I was expecting. I'll play with it some more.

For testing can I just manually convert to 3 byte UTF-8 and insert it like
Edit1.Text := Char($EF) + Char($82) + Char($80);
Show quoted text 9 lines
> I've tried specifying the font by name .. > > Edit1.Font.Name := 'Parallax'; > > ..and the ASCII chars use that font, but still nothing outside the > $20 - $7E range. Why do you think, that your font supports that character?

Because :

A) on Linux/gtk2 it displays the correct glyph when I use WideChar($F080)

B) I went through the font in FontForge and checked that the glyphs are assigned in the correct places.

I have this working flawlessly on Linux / GTK2, I just can't get it to work on Mac/Carbon.

I'll have a play with using UTF-8 instead of WideChar again. I did try it, and I got a glyph, just not one that exists in this Font set.

Cheers for the advice guys :)
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Brad Campbell
to Brad Campbell

Brad Campbell wrote:

Just a follow up and big thankyou to Mattias and Tom.

A) on Linux/gtk2 it displays the correct glyph when I use WideChar($F080)

It appears this works, however it's obviously not usable cross-platform.

B) I went through the font in FontForge and checked that the glyphs are assigned in the correct places. I have this working flawlessly on Linux / GTK2, I just can't get it to work on Mac/Carbon.

Having converted all my code to use the UTF conversion routines in LCLproc, I now get flawless Unicode on Linux and MacOS.. Whoo! On to Win32 now :)

Again, a big thanks guys, that was a headache.

Regards,
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Doug Chamberlin
to Brad Campbell
Brad Campbell wrote
Having converted all my code to use the UTF conversion routines in LCLproc, I now get flawless Unicode on Linux and MacOS.. Whoo! On to Win32 now :) Again, a big thanks guys, that was a headache.

Would you consider writing up short summary of what is needed to accomplish this when you finish with Win32 fixes?

I, for one, have yet to start tackling character conversions and I'm looking for a succinct guide. Real life experience is worth a bunch!

Reply by email

Brad Campbell
to Doug Chamberlin
Doug Chamberlin wrote 11 lines
Brad Campbell wrote: > Having converted all my code to use the UTF conversion routines in LCLproc, I now get flawless > Unicode on Linux and MacOS.. Whoo! On to Win32 now :) > > Again, a big thanks guys, that was a headache. Would you consider writing up short summary of what is needed to accomplish this when you finish with Win32 fixes? I, for one, have yet to start tackling character conversions and I'm looking for a succinct guide. Real life experience is worth a bunch!

Sure.. I've also got some oddities with regards to cross compiling for Darwin Intel/PPC and Win32 from Linux i386 that I'd like to add to the Wiki at some point.

It'll be a couple of weeks before I'm into the Win32 port for real. I have some Mac ugliness to clean up first. (Ugliness as in a Gtk app ported to Mac behaves like a Unix app and not a Mac App. Does not worry me, but Mac users are sticklers for human interface guidelines! ;) )

I still can't get lazbuild to build carbon binaries from linux/x86, but with a bit of a verbose makefile and calling fpc directly I can now compile my project for Linux/x86, MacOS ppc/intel and Win32 in one stroke.

Have to say I'm pretty happy about the way fpc and lazarus cope with cross compilation. It's a real testament to the developers!

Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email