Sign in Join

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

Mailing lists / lazarus / 2008-10

Carbon: UTF8 and few component showing rect characters

16 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

EarMaster - Bent Olsen

Hi all,

I'm using Lazarus 0.9.27 (rev. 16907), and some of the components (non-native?) is not showing the right characters when you try to display characters like in Japanese, etc., but works for some components (native carbon components, I believe).

The right characters in a text isn't being displayed in like TLabel (you'll get rectangle characters), but the same text is right in a TEdit component.

I understood Lazarus fully supports UTF8, but how do I get the TLabel, TStringGrid, TSpeedButton, etc., to show the right characters? Maybe I missed out a compiler switch or some sort?

Best regards,
Normann

Reply by email

Felipe Monteiro de Carvalho
to EarMaster - Bent Olsen
EarMaster - Bent Olsen wrote
The right characters in a text isn't being displayed in like TLabel (you'll get rectangle characters), but the same text is right in a TEdit component.

Rectagle characters indicates that the font does not support the chracter. Try using another font.

Felipe Monteiro de Carvalho

Reply by email

EarMaster - Bent Olsen
to Felipe Monteiro de Carvalho
Rectagle characters indicates that the font does not support the chracter. Try using another font.

Thanks, and I see, but it's strange thou, because the components was set with the same font at first ("Geneva"), and only TEdit adapted.

I found a font like "STKaiti" which displays a Japanese text just fine in TLabel, but it differs a little bit from the TEdit font - I just noticed that TLabel and TEdit differs in font type, also if you display characters like "1 2 3 4", even if you set these to the same font name and size. I then found out that you can only set font size and style for TEdit, but it completely ignores the font name, which changes just fine for TLabel.

How does TEdit find which font to use, or which font does a component like TEdit use, which then I can apply to a TLabel control?

Thanks again,
Normann

Felipe Monteiro de Carvalho

Reply by email

Felipe Monteiro de Carvalho
to EarMaster - Bent Olsen
EarMaster - Bent Olsen wrote
How does TEdit find which font to use, or which font does a component like TEdit use, which then I can apply to a TLabel control?

TEdit is a native Windows control, and by default Windows will choose the adequate font. The font differs between different Windows versions. The default font under XP is Tahoma, as explained here:

http://wiki.lazarus.freepascal.org/LCL_Unicode_Support#East_Asian_languages_on_Windows

TLabel is not a native control. It is drawn by LCL, so LCL chooses the font by default. I don't know which font LCL uses by default for TLabel.

Felipe Monteiro de Carvalho

Reply by email

mitya boyarintsev
to EarMaster - Bent Olsen: Thanks, and I see, but it's strange thou, because the components was set with the same…
How does TEdit find which font to use, or which font does a component like TEdit use, which then I can apply to a TLabel control?

It's better to refer to Carbon API:
http://developer.apple.com/documentation/Carbon/Conceptual/ATS_Concepts/atsfonts_intro/chapter_1_section_1.html#//apple_ref/doc/uid/TP30000108-DontLinkElementID_15 -------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081013/7b8d870e/attachment.html

Reply by email

EarMaster - Bent Olsen
to Felipe Monteiro de Carvalho: On Mon, Oct 13, 2008 at 10:15 AM, EarMaster - Bent Olsen TEdit is a native Windows…
Show quoted text 6 lines
TEdit is a native Windows control, and by default Windows will choose the adequate font. The font differs between different Windows versions. The default font under XP is Tahoma, as explained here: http://wiki.lazarus.freepascal.org/LCL_Unicode_Support#East_Asian_langu ages_on_Windows

I know, but this does not apply to Carbon on Mac, so I'll try to find a way to obtain the default font name through an API call from a Mac installation, and use this information to apply the same font name to label components.

Thanks,
Normann

TLabel is not a native control. It is drawn by LCL, so LCL chooses the font by default. I don't know which font LCL uses by default for TLabel.

Reply by email

EarMaster - Bent Olsen
to mitya boyarintsev: It's better to refer to Carbon API: http://developer.apple.com/documentation/Carbon/Concep…
> How does TEdit find which font to use, or which font does a component

like

> TEdit use, which then I can apply to a TLabel control? It's better to refer to Carbon API:

http://developer.apple.com/documentation/Carbon/Conceptual/ATS_Concepts/atsf onts_intro/chapter_1_section_1.html#//apple_ref/doc/uid/TP30000108-DontLinkE lementID_15

Thanks, I'll try and narrow this to an API call and get a name for the default font name used in a Mac installation.

Best regards,
Normann

Reply by email

mitya boyarintsev
to EarMaster - Bent Olsen: I know, but this does not apply to Carbon on Mac, so I'll try to find a way to obtain the…

Apple developers mailing lists (lists.apple.com) are also rich in discussion of such problems. It's good practise to search aboutr carbon problems there:

i.e.: this thread, is cocoa based application, but still might be useful: http://lists.apple.com/archives/java-dev/2002/Nov/msg00072.html I'm pretty sure, that there're some discussions about carbon too.

may be you can check if font supports some unicode features: http://developer.apple.com/documentation/Carbon/Conceptual/ATSUI_Concepts/atsui_app_features/chapter_9_section_1.html -------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081013/3bd2e0b9/attachment.html

Reply by email

EarMaster - Bent Olsen
to mitya boyarintsev

Thanks, I found GetThemeFont from the unit Appearance, which returns the system font (in this case 'Lucida Grande'), but changing TLabel to this font didn't had the expected effect.

I'm more convinced now that Lazarus, at least for Carbon, doesn't fully support UTF8. If you take a TLabel and set its caption to

??

which means Print (I hope this looks right in this mail), and as long as you have the focus at its caption in Lazarus Object Inspector the text displays right (the InEdit or alike supports this), but as soon as you remove the focus away from the property, the text displays in rectangles in the Inspector grid.

I presume the native controls like TEdit in Carbon uses the system font, but how come there's this difference when using the same font name? Does the native controls automatically switch to Japanese fonts like "Hiragino" when they encounter Japanese characters?

This is a major setback, because this goes for all drawings of texts on canvases as well.

I'm using Lazarus v0.9.27, FPC 2.2.2, rev 16907, on i386-darwin-carbon, but do I need to rebuild Lazarus with some option to support UTF8. I read Lazarus supports UTF8, so this looks more of a font issue, and a way of dealing with characters, which is not supported for a current font.

Thanks again,
Normann

Apple developers mailing lists (lists.apple.com) are also rich in

discussion of such problems.

Show quoted text 9 lines
It's good practise to search aboutr carbon problems there: i.e.: this thread, is cocoa based application, but still might be useful: http://lists.apple.com/archives/java-dev/2002/Nov/msg00072.html I'm pretty sure, that there're some discussions about carbon too. may be you can check if font supports some Unicode features:http://developer.apple.com/documentation/Carbon/ Conceptual/ATSUI_Concepts/atsui_app_features/chapter_9_section_1.html

Reply by email

Felipe Monteiro de Carvalho
to EarMaster - Bent Olsen
I'm more convinced now that Lazarus, at least for Carbon, doesn't fully support UTF8. If you take a TLabel and set its caption to ??

I added this to my form OnCreate (I don't know how to type it):

  Label1.Caption :=  '??';

With the Osaka font and it displays correctly. With the Lucida Grande font it indeed does not display correctly so I can only assume that this font does not support those characters.

I presume the native controls like TEdit in Carbon uses the system font, but how come there's this difference when using the same font name? Does the native controls automatically switch to Japanese fonts like "Hiragino" when they encounter Japanese characters?

Maybe. I do not know how Mac OS X handles this internally. Lazarus controls like TLabel do not do this. If you set it to use a font they will always use it.

I'm using Lazarus v0.9.27, FPC 2.2.2, rev 16907, on i386-darwin-carbon, but do I need to rebuild Lazarus with some option to support UTF8.

No, only UTF8 is supported in Mac OS X.

I read Lazarus supports UTF8, so this looks more of a font issue, and a way of dealing with characters, which is not supported for a current font.

Yes, it's a font issue.

Felipe Monteiro de Carvalho

Reply by email

EarMaster - Bent Olsen
to Felipe Monteiro de Carvalho
Show quoted text 7 lines
I added this to my form OnCreate (I don't know how to type it): Label1.Caption := '??'; With the Osaka font and it displays correctly. With the Lucida Grande font it indeed does not display correctly so I can only assume that this font does not support those characters.

Yes, Osaka displays nicely.

If only I could get the Appearance Manager, or some area of the OS X system, to tell me which font to use, it would be more right - with different languages in mind, of course.

I can use GetThemeFont, which tells me to use 'Lucida Grande', but it does that too, even if I set the hole Mac installation to run with Japanese language - or any other language I choose.

Maybe. I do not know how Mac OS X handles this internally. Lazarus controls like TLabel do not do this. If you set it to use a font they will always use it.

So, I will need to find out why GetThemeFont keeps telling me to use 'Lucida Grande' for a language setup, in which characters are not supported. Maybe I just need a different API call for that.

Any ideas?

Thanks, and best regards,
Normann

Reply by email

mitya boyarintsev
to EarMaster - Bent Olsen

I'm not sure, but Appearance Manager is a bit out of date, though still used. May be you should use gestalt or HITheme API (hitheme is not documented properly, at least i have not found).

AFAIK, MacOS should do font substitution in case selected font cannot render Unicode characters.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081014/dda73be3/attachment-0001.html

Reply by email

EarMaster - Bent Olsen
to mitya boyarintsev
I'm not sure, but Appearance Manager is a bit out of date, though still

used.

May be you should use gestalt or HITheme API (hitheme is not documented

properly,

at least i have not found).

Oh, I thought Appearance Manager and HITheme is part of the same HIToolbox framework - at least it says in Appearance.h and HITheme.h.

But you're right, most of the function in Appearance Manager are deprecated in Mac OS X v10.5.

AFAIK, MacOS should do font substitution in case selected font cannot

render

Unicode characters.

Yes, it should.

Reply by email

Tom Gregorovic
to EarMaster - Bent Olsen: used. Oh, I thought Appearance Manager and HITheme is part of the same HIToolbox…
EarMaster - Bent Olsen wrote 18 lines
> I'm not sure, but Appearance Manager is a bit out of date, though still used. > May be you should use gestalt or HITheme API (hitheme is not documented properly, > at least i have not found). Oh, I thought Appearance Manager and HITheme is part of the same HIToolbox framework - at least it says in Appearance.h and HITheme.h. But you're right, most of the function in Appearance Manager are deprecated in Mac OS X v10.5. > AFAIK, MacOS should do font substitution in case selected font cannot render > Unicode characters. Yes, it should.

I have changed in latest Lazarus SVN to allow font substitution under Carbon (via ATSUSetTransientFontMatching) by default. Now it should draw exotic glyphs correctly, whatever font is used.

Tom Gregorovic

Reply by email

EarMaster - Bent Olsen
to Tom Gregorovic
Show quoted text 5 lines
I have changed in latest Lazarus SVN to allow font substitution under Carbon (via ATSUSetTransientFontMatching) by default. Now it should draw exotic glyphs correctly, whatever font is used. Tom Gregorovic

Thanks Tom! I updated to the latest Lazarus SVN this morning, and it does draw characters correctly - though I can't read Japanese, or any other exotic language, but I can see they look right ;-)

And the characters show up right on the Lazarus IDE also.

Thanks again, and best regards,
Normann

Reply by email