khaledhosny / ots

Sanitizer for OpenType
BSD 3-Clause "New" or "Revised" License
260 stars 62 forks source link

Support bitmap fonts (EBDT, EBLC) #200

Open o5k opened 4 years ago

o5k commented 4 years ago

In deciding to not support bitmap fonts at all, OTS completely ignores many cultures and the ability to write crisp small print: Japanese print in Bitmap and vector Furthermore, it may be needed for designers to use crisp rendering for stylish purposes as well. As a major part of our web experience, OTS should look to support all languages and styles evenly!

khaledhosny commented 4 years ago

I won’t have time to work on this, but patches are welcome. Browsers can also ask OTS tp pass-though these tables and this wouldn’t need any changes to OTS, but someone will have to ask browsers to do it.

mmulet commented 3 years ago

I can patch this in, if it still needs doing.

khaledhosny commented 3 years ago

Contributions are always welcome.

mmulet commented 3 years ago

I made a Code Relay task for this https://github.com/code-relay-io/ots/blob/main/README.md . It will get done.

ra-om commented 3 years ago

In on this. Don't want to be stuck to Firefox forever.

mmulet commented 3 years ago

@ra-om We're on the ebdt branch right now. https://github.com/code-relay-io/ots/tree/ebdt You can jump right in.

flarn2006 commented 3 years ago

@mmulet I was wondering whether you found this issue the same way I found it. Then I looked back at where I found it and saw you created it. :P

Pomax commented 1 year ago

@mmulet how's the work going? It would be great if OTS finally supported this =)

mmulet commented 1 year ago

Code Relay has been on pause for a year and half (although we've been been attempting to restart it since January). Agreed that this one should really get done, so I think I will have to do it myself. I looked at the problem a few years ago and I believe that with copilot/gpt-4 these days, it shouldn't take too long. Depending on how much free time I have, I think finishing during this summer would be realistic. (Side note: Are you the pomax of the bezier primer? If so, I just want to say that the primer is a goldmine of information and you have my heartfelt thanks for making it.)

Pomax commented 1 year ago

I am, always good to know it's been useful.

mmulet commented 10 months ago

Here is an update because it's been about 6 months and past my summer estimate.

This issue has been on my todo list, but life and work keep on getting in the way. This issue keeps on getting pushed back further and further on my list. At this rate, I estimate I will be finished by the end of January.

Sorry for the delay!

mmulet commented 7 months ago

I have the first draft of the EBDT, EBLC, and EBSC validators implemented.

If anyone has any fonts that use these tables, please share them here or send me an email. I'm looking for some real fonts that use these tables, so I can test the validators against them. So far, I've found that font forge will output ebdt/etc tables, and of course I can hand create some fonts or convert from bdf, but I would prefer to test against fonts in real use. It's been a little hard to find ebdt fonts because there is a lot of overlap with bdf/etc fonts when I search for "bitmap fonts".

kenmcd commented 7 months ago

The Windows Korean Supplemental fonts have some EBDT fonts. batang.ttc and gulim.ttc both have TTFs inside with EBDT. So if you extract the TTC files, you will have eight TTF files with EBDT.

Some of the other CJK TTC files may also TTFs with EBDT, but you will have to check.

mmulet commented 7 months ago

Edit: Actually, this was a bug. The fact that Microsoft has a workaround for this font seems to be a strange coincidence.

On my validator, batang.ttc fails to validate because it uses variable metrics image formats in the EBDT while using constant metric index formats in the EBLC table Looking at the spec, it's unclear if this is allowed or disallowed.

I tried looking at other validators to see what they do, I found that Microsoft's font validator specifically ignores this issue just for batang.ttc

microsfot/Font-Validator/OTFFontFile/Table_EBDT.cs#L235:

// These images all have the same metrics as described in the indexSubTable so should have the proper image format
// Debug.Assert( nIndexFormat != 2 && nIndexFormat != 5 );
// commented out the above assert because batang.ttc violates this too much

So, if there are no objections here, I'm okay with allowing this (metrics in both EBLC and EBDT) in the validator.

kenmcd commented 7 months ago

MS Mincho (msmincho.ttc) also has EBDT in the two TTF fonts. In the Windows Japanese Supplemental Fonts Pack.

Did not find any others with EBDT in the other CJK fonts.

mmulet commented 7 months ago

MS Mincho (msmincho.ttc) also has EBDT in the two TTF fonts. In the Windows Japanese Supplemental Fonts Pack.

Did not find any others with EBDT in the other CJK fonts.

mcmincho.ttc, uses a different bitmap format and a different embedded bitmap location format. So, that is a really good find.

I've created a list of all tested fonts and formats in the pull request: #273

kenmcd commented 7 months ago

Found a few more with EBDT

Windows 11 standard fonts

Windows 95 standard font - MSSONG.TTF Thought this may now be in one of the newer TTC files, but did not find it.

stgiga commented 2 months ago

I've made UnifontEX builds with bitmap tables but don't distribute them precisely because of OTS. I provide the FontForge SFD to allow turning it on, but I had used CacheTT afterwards to add a VDMX table so you'll need to repeat that. OTS handles all of UnifontEX's rare tables fine when no bitmaps are present.

NightFurySL2001 commented 1 month ago

The following CJK fonts in Windows uses EBDT/EBLC. All of these are legacy CJK font files (Windows 9x) that persist until today due to widespread usage; some of the Windows interface will still use the bitmaps from EBDT table. Filenames are font name listed using lowercase without space, ending in .ttc except SimSun-ExtB.