Generate decrypt strings for unknown CG fonts#22
Conversation
|
@elewing interesting. Did you have a look here #21? (I added in the PR wawoff2_decompress_binding.js so we don't need to load it from the internet) (Ithink there are issues with scripts from the Internet if you just open the HTML as a file in the browser but i am not sure.) Can you elxplain what glyphToCharMapping does? where did you get the keys from? |
|
Oh, I must have missed that part of the method when I was looking earlier! I did some testing using the local HTML file and didn't see issues, but happy to update to add the scripts locally in the same way if that's best practice. Apologies if I'm explaining things you already know, but for context, the way the fonts are set up, each glyph is mapped to the "scrambled" unicode character rather than its actual displayed character. In order to decrypt it, we have been defining a "decrypt string" which maps the appearance of each glyph (e.g. the actual displayed character), which is defined by its path, to its unicode value/the character it says it is. So, in order to automate that decryption process, all that is necessary is to have some way to identify what the glyph actually is rather than the unicode character it is declaring it is, then map it to our expected format for calling I got those glyph paths by opening a sample font from a CG epub and logging the path of each glyph in the console, then mapping them to their actual displayed character the same way we have been doing to manually create these decryption strings. This should work for any font as long as it uses the same base glyphs, though I'd expect it to break if CG changed their underlying font style (though that doesn't seem to have happened thus far). |
|
@elewing thanks for the explanation. I understood it like this: Normally it works like this. (The values aren't real)
You now extracted the Binary representation from "Display svg for font character" and can now make a reverse lookup. Binary representation of the svg font -> what real world char is that? -> override original Binary (text) Very elegant. Is better than my solution witch maps the custom fonts. Your solution works for tts/ search etc. I would keep my solution as https://requiemtls.com/ also uses custom fonts. (And in case they set one pixel in the future different for each font my solution would still work as a backup.) |
dteviot/WebToEpub#2173 (comment)