2

I need to find what Unicode characters are supported by a font. There is a WinAPI function GetFontUnicodeRanges, but they work only for BMP (Basic Multilingual Plane). Is there any function or source code example that work also for SMP (Supplementary Multilingual Plane). I know that DirectWrite have such function but I do not use DirectX/DirectWrite in my application.

Olivier
  • 13,283
  • 1
  • 8
  • 24
Denis Sletkov
  • 221
  • 1
  • 4
  • You'll need to clarify what "*supported by font*" means here. There is a difference between what the font itself supports, and what Windows will display when using that font through fallback and linking, see [how does windows deal with drawing chars not in the current font](https://stackoverflow.com/questions/64473346/how-does-windows-deal-with-drawing-chars-not-in-the-current-font/) for example. – dxiv Apr 12 '21 at 07:40
  • Only Unicode symbols that have glyph in this font. I know that information available in font cmap table but i try to find a easy solution. – Denis Sletkov Apr 12 '21 at 09:30
  • I don't know of any API for the SMPs, but the free utility BabelMap will tell you what Windows fonts are available for any given combination of Unicode characters (which can even come from different Unicode blocks in any planes). So if you do find a way to do this programmatically, BabelMap might be a useful way of verifying that your code is good. See [this answer to _How can I know which programs and fonts will support certain unicode characters / glyphs that I want to use?_](https://stackoverflow.com/a/48517325/2985643) for more information on BabelMap. – skomisa Apr 13 '21 at 02:02

1 Answers1

1

There is no reason why not to use DWrite in your app for this purpose. As you pointed out, GetFontUnicodeRanges supports only BMP, so if you want SMP or other characters you need to use something else, so why not use DWrite. You can use the IDWriteFont1::GetUnicodeRanges method to get the info you want.

Peter Constable
  • 2,707
  • 10
  • 23
  • I solve this problem parse cmap font table. The SMP characters can be encoding only in subtable format 8, 10, 12, and 13. The format 8 and 10 is not widely used, so parse format 12 and 13 is enough for my task. – Denis Sletkov Apr 14 '21 at 00:00
  • Writing your own parser is better than using DWrite?! OK. But you can probably ignore format 13 as it's not likely useful for your purposes: format 13 is efficient only for mapping many characters to the same glyph -- i.e., it's only really useful for an ultimate fallback font in which entire blocks or planes of Unicode characters are shown with the same glyph. – Peter Constable Apr 14 '21 at 02:12
  • Not better :) , but i do not any reason to add DWrite to application for one feature only. Anyway i already have a big portion of code that parse a font file. – Denis Sletkov Apr 15 '21 at 14:52