TImage and Input Locale


I use Canvas on a TImage for writing Russian text on it. It looks OK while the default system locale on my computer is set to Russian. When I switch it to something different, all the cyrillic letters turn into "??????". Assigning Canvas.Font.Charset:='RUSSIAN CHARSET' doesn't help. Is there any method to make my text look cyrillic under ANY system settings?

I want to emphasize, just in case, that it's not the problem of "localization". I don't care about menus and buttons. I only care about the text written on TImage.

Vadim Smolensky,
Saint-Petersburg, Russia
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pierre CorneliusCommented:
Have you set the font's character set?

Try this:
procedure TForm1.Button1Click(Sender: TObject);
  canvas.Font.Charset:= RUSSIAN_CHARSET;
  canvas.TextOut(20,20, 'Hello world! '#$9C#$9D#$9E#$9F);
VSmolenskyAuthor Commented:
> Have you set the font's character set?

If you'd read my question carefully, you wouldn't have asked me this.
Pierre CorneliusCommented:
sorry, It's a bit late over here... Obviously need some rest
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Pierre CorneliusCommented:
I've tested on my machine. By setting the canvas.font.charset to RUSSIAN_CHARSET on my machine it works.
Are you sure you've set the charset of the correct canvas?

Maybe You should also set font name to such which have russian_charset.
VSmolenskyAuthor Commented:
To mokule: the font name is OK, otherwise it wouldn't work under Russian locale either, but it does.

To PierreC: did you test it under XP? I have 2000. When I tried it under XP, the results were really strange: it was OK either with Russian default locale and no additional operators or with English default locale and assigning Canvas.Font.Charset:='russian_charset'. BUT: when it had Russian default locale and assigning russian_charset, it didn't work again! A paradox, isn't it?

I think I know how to deal with it, I just have to determine the default locale in the runtime and assign or not assign the charset depending on it. How to do this?

And yet, I think that You are giving such font parameters that don't exist in a system and Windows selects the nearest font. Who knows what will be chosen?
VSmolenskyAuthor Commented:
To mokule: please, believe me, it's not a problem of particular fonts. It's a problem of system settings. It goes the same with any possible font.
Pierre CorneliusCommented:
>>>To PierreC: did you test it under XP? I have 2000.

Yes, I tested under Win XP.

>>>... I just have to determine the default locale in the runtime and assign or not assign the charset depending on it. How to >>>do this?

You can get the default user or system locale by using one the following 2 windows API functions:


uses Windows;
procedure TForm1.FormCreate(Sender: TObject);
  ShowMessage('Default system locale: '
              'Default user locale: '
VSmolenskyAuthor Commented:
Thank you. It gave me Russian for System Default and English (UK) for User Default. Could you please explain the difference between the two (system default and user default)?

And one more thing: the compiler gave me a warning: "Symbol 'NameFromLocaleID' is specific to a platform". Does this mean that under a certain version of Windows this operator can provoke an exception? If yes, how can I avoid it?
Pierre CorneliusCommented:
System vs. user locale

Windows' regional settings facilitate and control the formats of your date, time currency etc. (but I'm sure you know that). Quite simply the system locale is the default used by the system, so unless a user has set his/her own personalised settings, the system locale is used. E.g. if you set your currency symbol to "$" then all new users created will have that as their currency symbol. That is until such time as they decide to change their user locale settings to make "ZAR" their currency symbol.

Platform specific
It is specific to the windows platform (as opposed to Linux). It should work on all windows platforms (Win95, Win32s, WinNT).


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.