PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Determining unsopported characters in a font

 
 
Jeff Johnson
Guest
Posts: n/a
 
      27th Jul 2009
I wrote a little utility which views how code pages map characters to their
Unicode code points, and in the process of viewing non-Latin character sets
I see that several fonts do not support scripts like Cyrillic, for example.
However, Windows (or .NET, or something) substitutes a font which does
support those characters (Arial, it looks like), so I always see 256
characters on-screen*. This has me wondering: is there any way to determine
if a font provides a given Unicode character (i.e., code point)?


*In other words, with code page 1251 (Cyrillic) active, I see 0 - 127 in
Curlz MT, for example, but characters 128 - 255, which for the most part
differ from what most people would call "high-ASCII," appear in Arial,
because Curlz MT doesn't have glyphs for U+0400 - U+04FF.

The code for drawing these glyphs doesn't change; I simply iterate over the
256 characters in my string and print the current one using a font set up
earlier:

g.DrawString(current.ToString(), displayFont,
characterBrush,
new PointF((float)x * 32 + 24, (float)y * 36 + 52));


 
Reply With Quote
 
 
 
 
Mihai N.
Guest
Posts: n/a
 
      28th Jul 2009
> This has me wondering: is there any way to determine
> if a font provides a given Unicode character (i.e., code point)?


Several ways:
1. Parse the cmap OpenType table
http://www.microsoft.com/typography/otspec/cmap.htm
You can read it from the .otf file or retrieve it with GetFontData
2. GetGlyphIndices (but it does not handle Unicode characters above FFFF)
http://msdn.microsoft.com/en-us/library/dd144890(VS.85).aspx
3. ScriptGetCMap (Uniscribe)
http://msdn.microsoft.com/en-us/library/dd319122(VS.85).aspx

Nothing pure .NET (except maybe the cmap parsing)

--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      30th Jul 2009
"Mihai N." <(E-Mail Removed)> wrote in message
news:Xns9C55D6835B2BAMihaiN@207.46.248.16...

>> This has me wondering: is there any way to determine
>> if a font provides a given Unicode character (i.e., code point)?

>
> Several ways:
> 1. Parse the cmap OpenType table
> http://www.microsoft.com/typography/otspec/cmap.htm
> You can read it from the .otf file or retrieve it with GetFontData
> 2. GetGlyphIndices (but it does not handle Unicode characters above FFFF)
> http://msdn.microsoft.com/en-us/library/dd144890(VS.85).aspx
> 3. ScriptGetCMap (Uniscribe)
> http://msdn.microsoft.com/en-us/library/dd319122(VS.85).aspx
>
> Nothing pure .NET (except maybe the cmap parsing)


Thanks for these links. This stuff is complicated! In some sample source I
saw something I'd never seen in my (admittedly limited) C[++] experience: a
pointer to an array of pointers, declared like this:

SOME_STRUCT*** blah;

THREE asterisks!! Holy crap! That's some indirection and a half right there!


 
Reply With Quote
 
Mihai N.
Guest
Posts: n/a
 
      31st Jul 2009
> This stuff is complicated!
Amen to that :-D



--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining unsopported characters in a font Jeff Johnson Microsoft C# .NET 3 31st Jul 2009 08:37 AM
Determining Target font colour kirkm Microsoft Excel Programming 4 3rd Sep 2008 04:21 AM
Determining max number of characters in a TextBox =?Utf-8?B?VXNtYWFr?= Microsoft VB .NET 4 7th Sep 2006 05:21 AM
HOW? Determining font metrics MessageBox will use Lee Gillie Microsoft Dot NET Framework Forms 0 6th Dec 2004 05:51 PM
Determining which font is embedded in my PPT Charlie Brown Microsoft Powerpoint 1 15th Sep 2004 03:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:00 AM.