microsoft / cascadia-code

This is a fun, new monospaced font that includes programming ligatures and is designed to enhance the modern look and feel of the Windows Terminal.
Other
25.1k stars 793 forks source link

Problem adding GDI+DWrite glyphs pair for contribution (help needed) #704

Closed PhMajerus closed 5 months ago

PhMajerus commented 5 months ago

I'm trying to add some missing symbols to Cascadia to be able to submit my contribution as a pull request. I've forked the project and managed to build it and add new characters to it just fine.

I have two main categories of symbols: Some are based on the dimensions of characters, while others are designed to fill their cell (like the U+2588 full block character). For the ones based on characters dimensions, I looked at existing uppercase letters and found out that they should fit in the bounding rectangle 0,1420 to 1060,0. For the ones based on a full cell, my understanding is I have to provide a GDI-based version that fits the rectangle 0,2226 to 1200,-480, as well as a DirectWrite-based version that fits the rectangle 0,1900 to 1200,-480. The GDI one is considered the base one and should include the unicode hex value, while the DirectWrite one should have a .stypo suffix to its name and filename, and not include any unicode hex value.

I looked at the files referencing existing block characters in the project and believe I found all the places where I should add references to mine, including the rclt substututions to make it use the DirectWrite glyphs instead of the GDI ones.

Unfortunately, it appears the font I build always uses the GDI glyphs, making them the wrong height in Windows Terminal.

I would really appreciate some guidance to get this to work so I can add many symbols I have been working on.


I tried a simple modification to add 3 characters, U+2427, U+2428, and U+2429.

Here is how I proceeded so far: (These changes can also be seen on my repository https://github.com/PhMajerus/cascadia-code)

Glyph files

Added glyph files to the glyphs subfolder of each font (CascadiaCode-Bold.ufo, CascadiaCode-BoldItalic.ufo, CascadiaCode-ExtraLight.ufo, CascadiaCode-ExtraLightItalic.ufo, CascadiaCode-Italic.ufo, and CascadiaCode-Regular.ufo)

The Apple2 and Trs80 symbols dimensions are relative to characters, while the AmstradCpc symbol dimensions are relative to a full block. Therefore, two versions are provided to support GDI and DirectWrite-based renderers.

Contents files

Added the glyphs name and filename tuples to each contents.plist file within the glyphs subfolder of each font.

Features files

In the features.fea file of each non-italic font (CascadiaCode-Bold.ufo, CascadiaCode-ExtraLight.ufo, and CascadiaCode-Regular.ufo)… Added the glyphs names to the @NotSpace list. Added GDI to DirectWrite substitution to feature rclt for the AmstradCpc character, using the following line: sub checkerBoardDeleteAmstradCpc by checkerBoardDeleteAmstradCpc.stypo;

Lib files

In the lib.plist file of each font… Added the glyphs names to the public.glyphOrder list. Added the glyphs name and uniXXXX codepoint name tuples to the public.postscriptNames list.

Building the font

Building the font using python3 build.py works without any error, and opening it in VTT shows the added glyphs, including both GDI and DirectWrite variants of the AmstradCpc one.

image image

In VTT, compiling everything for all glyphs succeeds on first try, and ship font generates a smaller .ttf file.

Problem

Installing the font and using it in Windows Terminal works, but the U+2429 character apparently uses the GDI checkerBoardDeleteAmstradCpc.glif instead of the DirectWrite checkerBoardDeleteAmstradCpc.stypo.glif version. I was under the impression that the feature rclt substitution would make the .stypo version be used instead of the base one. Unfortunately, that doesn’t seem to be the case.

image See the U+2429 checkerboard character, it is extending above the cell, but it should fit the same bounding box as the U+2588 full block character.


I have 800 glif files ready to add to Cascadia, including the ones requested in https://github.com/microsoft/cascadia-code/issues/647, https://github.com/microsoft/cascadia-code/issues/607, and fixes for https://github.com/microsoft/cascadia-code/issues/644, but almost all of them are block mosaics that need to fill a full block cell properly, so I need to be able to fix this basic update before adding the others.

image

Can you help me find out what I missed?

Thanks,

aaronbell commented 5 months ago

Awesome! So the thing that is probably catching you up is that the final font feature code is actually not stored in the UFOs but in the sources/feature foldeer, divided up by feature name. So for rclt features, you should put them in here. I think that should be enough to get what you want working. Do note that this will be applied both to the Roman and Italic variants.

The other thing I wanted to say, though, is that I'm working on an overhaul of the font, which will include changing the vertical metrics. This whole DWrite vs GDI difference is the cause of too many bugs, so I'm thinking to align them (like the coding fonts of old), which will make the need for two versions unnecessary. Unfortunately, I haven't had a chance to think through what that final height will be as of yet, but I wanted to mention :).

PhMajerus commented 5 months ago

Thank you so much @aaronbell, it works now!

image

So now I can start methodically adding all my other glyphs to all those script files.

Do you prefer several small pull requests or a large one with all the characters? They're basically all sextants, octants, separated quadrants, separated sextants, and a few extra Symbols for Legacy Computing stuff.

Don't feel too bad about the overhaul and changing all the metrics I have to use for my 800 glyphs. For the larger sets I basically wrote scripts to generate them from coordinates tables, so I should be able to build new ones for whichever dimensions you decide.

aaronbell commented 5 months ago

Glad to be of help! I'd say it would probably be easiest to review them in individual sets. Maybe individual bug groups?

PhMajerus commented 5 months ago

Ok, I'll try the following:

  1. • New Control Pictures (these 4 seen above). • Replacing old quadrants: 10×2 files with long upper/lower Left/Right and* names replaced by new blockQuadrants-[pseudopixels indexes], 7×2 of the old files have wrong middle y coordinates, and the new naming will make sense once you see the next mosaics that share some characters with quadrants. • More checkerboards, 2×4 glyphs. That would be 4+20+12 glyphs, and fixing 2 existing glyphs (upperHalfBlock that also has wrong middle y coordinates).

  2. Block Sextants, that's the set of 2×3 pseudopixels mosaics, 2×60 glyphs.

  3. Triangular Quadrants, 2×10 glyphs.

  4. Digits in 7-segments style, 10 glyphs.

  5. Block Octants, that's the set of 2×4 pseudopixels mosaics, 2×238 glyphs. It's a lot at once, but its a single group.

  6. Separated Quadrants, 2×15 glyphs.

  7. Separated Sextants, 2×63 glyphs.

Does that seem ok for you?