Skip to main content
GameDev.net gamedev.net
🔒 Locked

OTF charsets issue

Started by BlackJoker Apr 23, 2020 at 11:04 AM 17 replies 19.2k views
Original Post
BlackJoker
BlackJoker

Hello everyone.

I am working on my own OTF parser on C# and I am currently stuck on charsets.

I successfully parsed the list of charsets and found out that it contains several formats, which is not described in Adobe CFF documentation.

It contains Unicode, AFII, human readable characters and some feature sets.

And now I am stuck with it, because I dont know how to cast all this to Unicode.

OK, actually the most questions I have to the AFII part, because it contains code for Cyrillic and Asian characters, which contains quite a lot of Unicode list of characters (a few thousands) and I cannot find info how to convert AFII codes to Unicode in automatic way. I found some matching tables, but I think that entering manually ~10 000 characters is not a good practice.

I want to cast all entries inside charset list to Unicode to simplify user input as far as all entered characters anyway will belong to Unicode.

So, my question is: If anyone present here know anything about this issue, please, help me to solve it. I would appreciate any help.

Shaarigan
Shaarigan

I found a paper from Adobe that describes the difference between Unicode (as character encoding) and AFII (as glyph registry) so maybe you can find your answers here

https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5013.Cyrillic_Font_Spec.pdf

BlackJoker
BlackJoker

Unfortunately this Adobe paper does not answer how to convert AFII to Unicode in automatic way

Shaarigan
Shaarigan

TL;DR from what I read in the paper, you can't because AFII is “not an encoding but a glyph registry mapping glyph names", so you have to download and convert the registry from what I understand so far

BlackJoker
BlackJoker

I would appreciate if you tell me where exactly I can find that registry to download it and convert to Unicode, because I didnt find any links or other resources in the internet regarding AFII…

I mean resources that contains all the glyphs available in AFII

BlackJoker
BlackJoker

Partially… I am not sure that ~4K entries can cover Cyrillic, Chinese, Japanese, Korean and other languages.

Correct me if I am wrong, but this list seems not to be full or I am missing something?

Elzianor
Elzianor

I'm also interested in this topic. And for me it's not seems right to just hardcode thousands of mapping values even if there will be the full list of them. Maybe in OTF / CFF there is some table to map user input to glyphs? Something like ‘cmap’ table in TTF?

a light breeze
a light breeze

Have you looked at (the source code of) Freetype? It supports OpenType fonts and is under a liberal license, so you can probably just copy their solution.

LorenzoGatti
LorenzoGatti

BlackJoker said:

Partially… I am not sure that ~4K entries can cover Cyrillic, Chinese, Japanese, Korean and other languages.

Correct me if I am wrong, but this list seems not to be full or I am missing something?

Yes, you are missing that this list is by no means complete and authoritative.

This list comprises the set of glyph names from the AGLv2,0 which map

# to via the AGL rules to the semanticly correct Unicode value.

This means that if you use these glyph names, and you do not have to, AGL rules will use them for suitable Unicode characters, which as you already noticed don't range very far from Latin-1.

Omae Wa Mou Shindeiru
BlackJoker
BlackJoker

@lorenzogatti

Can you please clarify a little what is AGL and what rules it uses to find suitable Unicode characters?

BlackJoker
BlackJoker

I would appreciate anyone for detailed explanation of this AGL rules. What is it, how it works, etc.

Does anyone has knowledge about that?

wintertime
wintertime

Noone says you need to hard code a table. You could load it as a data file and then use it from your code.

BlackJoker
BlackJoker

@wintertime

Yeah, its not the big deal how to create this data.

I am worried about what to do, if I cannot find some symbols from user input inside this table because there will be no corresponding mapping between Unicode and AFII for example.

Thats the case, which I want understand how to handle correctly.

wintertime
wintertime

You could try to fall back to other fonts and if those also do not have the character you display the missing-character-square (and if you want display the hex code inside that, like browsers do).

BlackJoker
BlackJoker

@wintertime

You didn't answer my question.

My question was: How to match user input from keyboard (which will be definitely in Unicode) to the character inside font in case when some characters could be defined in AFII (not in Unicode).

For example, user press “A” button and I want to find this character in the font. This char definitely present there, but in AFII, which does not match to Unicode.

So, how to find this char in the font if it will be missing in the hardcoded data dictionary, but present in the font itself?

wintertime
wintertime

For that, you probably have to read the documentation for that table and/or file format yourself. I doubt anyone here would know that without doing the same.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.