[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Font.CharSet for Farsi

Posted on 2005-04-06
12
Medium Priority
?
2,953 Views
Last Modified: 2012-05-05
I'm looking for a value for Font.Charset that fits for the Farsi (Persian) language.

I know that ARABIC_CHARSET is 178, but according to a translator who's working on Farsi, Farsi has 4 additional letters which distinguishes it from Arabic. And my apps (Delphi 7) using TMemo and TEdit controls set to Font.Charset=178 won't allow to enter those four special characters.

Does anyone have experience with Farsi & Delphi, and could tell me which charset to use? Or if 178 is the correct one, what trick to use to allow Delphi to let those letters entered?

Thank you!
0
Comment
Question by:ccrdude
  • 5
  • 4
  • 3
12 Comments
 
LVL 27

Expert Comment

by:BigRat
ID: 13715326
0
 
LVL 2

Author Comment

by:ccrdude
ID: 13715660
Your first link doesn't mention the license the font comes under, your second link does even explicitely forbid to distribute the font (and is even labeled *web* font - probably not usable for smaller font sizes as common in applications). So what use would they be?

And sorry, I'm not speaking about the font (which doesn't pose any problems), I'm speaking about the CHARSET. Which I would need with any font, even those two.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 13718414
>>And sorry...

You don't have to be sorry, I thought I didn't understand the question because my googling turned up lots of entries, and I wasn't sure why you rejected them and asked here.

According to MSDN there isn't one for Farsi, I suspect you'll just have to set ARABIC_CHARSET. Obviously setting the face name will force the font chooser to choose that particular font.

TMemo and TEdit are just wrappers for the corresponding Windows controls and are rendered by the API ExTextOut using (effectively) the TFont object. The TFont object when rendered selects or makes a font internally in Windows (LOGFONT).

Now in both controls are 8-bit byte controls so the text rendering is different on different platforms. On Win95 and derivatives the value of the 8-bit character indexes a 256 entry glyph table in the True Type Font. On WinNT and derivatives the 8-bit characters are converted to Unicode using the system locale and the Unicode value is used to find the glyph in the font. This conversion is done my MultiCharToWideChar and the four additional characters might not be mapped to their Unicode equivalents. (Question: do these characters have unicode values?)

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:ccrdude
ID: 13725006
Yes, those additional characters have Unicode equivalents: Peh, Tcheh, Jeh, Gaf.
See http://encyclopedia.laborlawtalk.com/Persian_language

I'm not sure if you ever have used a foreign system, or just installed support for a foreign system. If you did, you would have seen that Microsoft hsa the defaults fonts available in all localizations. Just by installing Arabic support, I can see Arabic letters in Arial, so I don't see the need to install yet another font that supports Arabic. I guess we can try to play around with the default fonts (Arial, MS Sans Serif, etc.)...

Arabic being an example, since Arabic has a separate language code (ar) from Farsi (fa, fa_IR).

I know that MSDN does not list it - of course I searched MSDN before this, I also looked through the SDK file WinGDI.h, where known charsets are defined (because you can't always depend on Borland having translated everything), and I searches koders.com for possibly separate definitions. If this would've been a simple 5-minute-Google question, I surely wouldn't have asked here ;)
0
 
LVL 27

Expert Comment

by:BigRat
ID: 13725343
>>If this would've been a simple 5-minute-Google question, I surely wouldn't have asked here ;)

You wouldn't believe the sort of questions that get asked here!

>>I'm not sure if you ever have used a foreign system, or just installed support for a foreign system.

I'm located in Germany. Our software is Unicode compliant and I have on my English laptop German, Russian and Hebrew installed.

>>those additional characters have Unicode equivalents:

They're in Unicode standard 2.0 even!

Peh 067E
Tcheh 0686
Jeh 0698
Gaf  06AF

Like I said the problem is the conversion from the 8-bit character set (is your locale set to Arabic?) and Unicode. For this the MultiByteToWideChar API function uses the tables installed by MS corresponding to the local (on WinNT derived systems). The Arabic Charset property implies code page 1256. This code page has the letters at :-

81 = U+067E : ARABIC LETTER PEH
8D = U+0686 : ARABIC LETTER TCHEH
8E = U+0698 : ARABIC LETTER JEH
90 = U+06AF : ARABIC LETTER GAF

Now once again I see that I have not understood the question :-

>>won't allow to enter those four special characters

has not nothing to do with fonts.

Question: How are you trying to enter those characters?

Suggestion: Try using the ALT key method. Hold ALT down and type in the numeric decimal value of the key (HEX 81 = 129) then release ALT.




0
 
LVL 2

Author Comment

by:ccrdude
ID: 13725794
Well, it's still set to ARABIC_CHARSET, I've installed Farsi keyboard support on my XP, and entered my application.

Using Alt+ your hex code (0x81 = 129, 0x8D = 141, 0x8E = 142, 0x90 = 133) I get the umlaut ü, two question marks, and an a with accent. Using any other letters a-z gets me Farsi/Arabian characters, so I know keyboard layout and TMemo character setting are working correctly together.

Copying the character from the Screen keyboard (Zeichentabelle in german) and pasting it into the Delphi TMemo works btw. I guess I have to check with the translator how exactly he tries to add them.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 13728700
>>Copying the character from the Screen keyboard (Zeichentabelle in german) and pasting it into the Delphi TMemo works.

This means that the code page of the systems 8-bit data and the font are correct.

>>Using Alt+ your hex code (0x81 = 129, 0x8D = 141, 0x8E = 142, 0x90 = 133) I get the umlaut ü, two question marks, and an a with accent.

Which means that this feature is not available.

>>Zeichentabelle in german

Character Map in English. BTW I'm not German.
0
 
LVL 14

Assisted Solution

by:huji
huji earned 500 total points
ID: 15380029
Hi

Hope I'm not too late, or offtopic.
If I've understood the question correctly, you re looking for the charecter set for Farsi. Regarding my information (which is mainly related to web dev area, but I guess is the same as app dev area) there is no charset for Farsi. You have to use Unicode character set (utf-8) for example.
Regarding the List of Locale ID (LCID) Values as Assigned by Microsoft which is available from http://www.microsoft.com/globaldev/reference/lcid-all.mspx the LCID value for Farsi is 1065, which I'm not sure may help you or not.
My little experience of Farsi app programming have shown me the use of unicode enabled components to be the easiest way.

Hope it helps
Huji
0
 
LVL 2

Author Comment

by:ccrdude
ID: 15380381
I'm afraid your easiest way is the most complicated for me, since it would mean redesigning a huge application and probably re-doing translations into 40 languages :-/
Unicode is planed for the future, but it's still a major release away ;)

Regarding the LCID list - I've created a table showing for each language microsoft locale, linux locale, ISO-639-1 und -2, SIL, Dos/Win/Mac Codepages, Web ISO and other standards, and Delphi charset.
IBM (IBM-864) & Windows (Windows-1256) Codepage, ISO-8859 standard (ISO-8859-6) are the same for Farsi and Arabic, just the Mac uses a different codepage (MacFarsi instead of MacArabic)...

Imho the translator has avoided the problem by choosing a font that would display those characters, but I'll have to ask him again...
0
 
LVL 14

Accepted Solution

by:
huji earned 500 total points
ID: 15381752
Hi again,

Well, I have developed a few (very basic) programs in Farsi using BCB. I'm sure that working with unicode in Borland products is almost a pain. I'm not that expert in the field, but I've had the experience to tell you my own opinion.
Borland's Delphi and C++Builder are the best developing environments I've ever seen, for sure. But the other side of the story is, they are the best untill you never need a character out of the ANSI set. When it comes to right-to-left language, Windows itself is not so talented! Worse is the situation with Borland's no-unicode systems.
There are some tricks to enable Farsi (say unicode) in your applications, thought they are limitted to NT versions of Windows (including XP.) The fact is, pre-NT versions (or better to say pre-unicode-enabled versions) do not support the same functionality, so if you hand code your program (like a C# Programmer) you have to hand code some forms/dialogs/etc for pre-NT machines, or you have to tell the end user that the software is limitted to Win 2000 and XP machines.
When it comes to Borland, I know one direct way to show uniocde text in Edits and other controls, and that's to use a third party component named TNTware. Search the net for TNTware and you'll find. Look at my Question History and Comment History and find those parts in BCB and C++ Programming topic areas, and you'll also find some related questions (you may search EE for Huji and TNT as well.) TNT offers a new set of components, which covers almost all of the standard, commonly used visual/nonvisual components. It has its own Edit, its own Label, etc.
The benefit of this new set of components is they can accept unicode values. However, if you ask me, they are not the 100% solution of the problem. I tried to have both Farsi and English characters in a string and I failed in some cases.
Afterall, Borland MUST develop its next generation of BCB and Delphi as unicode-supporting RADs. By the time, the best solution for you is to shift to microsoft developing environments. As a Delphi programmer, you may find Delphi.net easy to learn and use.

Wish I can help
Huji

PS: About Farsi in pre-NT machines: Programs showing Farsi in Windows98 used a simple trick usually: The font trick. They installed a special font uppon installation. The English characters were replaced by Farsi ones in this font, so when you pressed the D button, the computer understood that as D, but the font showed that as Yeh. The fonts were wise enough to support different shapes of the same letter, and special characters such as non-joining break in some cases.This trick had its own inevitable intolerable disadvantages.
0
 
LVL 2

Author Comment

by:ccrdude
ID: 15395764
I already use one component from the TNT set :)

My problem with exchanging the components is the translation package. Since I don't like the Borland one, which creates files of half a Megabyte per translation and difficulties for the translators, I've written my own, which simple goes through all components and writes/reads them to a file. Would have to make that compatible to the TNT tools. But I couldn't replace everything (got two other special components I can't simply replace, and then there are forms and some other things as well...).

Delphi 2005 can already understand UTF8 source files, but imho not the VCL. And I doubt 2006 (which I already have preordered) will be able to.

But I surely won't switch to .Net. I like backward compatibility to 95, and I would never ask of any user of my software to download a huge .Net framework for a small application. And sorry - I can work in Visual C as well, and I have enough Microsoft stuff on my machine to know that it's sometimes even worse than Delphi (and that means a lot :D ).

In fact, I've nearly switched to FreePascal+Lazarus by now, but: same problems there ;)

I guess I'll simple split the points between you two to close the question, as I guess there won't come any better answer ;)
0
 
LVL 14

Expert Comment

by:huji
ID: 15396644
Well, I just wanted to help. I reached this question by ocasion, and I'm no expert in Delphi programming.
Huji
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question