adam7 / delugia-code

Can we add Nerd Fonts to Cascadia Code Font using a GitHub Action
MIT License
567 stars 34 forks source link

Default character height is greater than Cascadia Code #78

Closed rashil2000 closed 1 year ago

rashil2000 commented 1 year ago

See the gif below, when I change the font to Delugia, the characters seem to become longer. It's not really a big deal, but it was noticeable to me at font size 11. (The gif has font size set to 32, to make the difference easily visible).

cursor2

Finii commented 1 year ago

Thanks for reporting. Sorry to hear you have an issue.

I assume you use the Cascadia Code VF, which is hard-bundled with Windows Terminal? There are slight differences between the VF and the static versions, even the unpatched fonts.

Or do you have the static Cascadia Code version(s) installed? Then I would have a look.

Explanation: We use the static Cascadia Code font files as source because fontforge has problems with modern VF.

Edit: Add explanation

rashil2000 commented 1 year ago

Yes, I'm using the Cascadia Code that is bundled with Windows Terminal (Preview).

Finii commented 1 year ago

Ok, I tried to normal (non preview) version, and it uses the ttf-VF:

image

Lets see if we can see differences.

Download release from MS, compare ttf versions of static and VF:

image

The glyph is drawn a light bit differently, but the top-point on the exact same position: 604/1080.

Delugia is the same:

image

Vertical metrics are also the same (except WIN values which should not be used because use-typo-metrics bit is set:

image

Testing CascadiaCodeVL vs Delugia at 42pt at 400% magnification:

Peek 2023-01-31 13-42

The difference is less than 1 pixel. Even with still bigger fonts, the difference is always < 1 px. I believe this is a rendering issue.

I also noticed that Caskaydia Cove (the 'original' Nerd Fonts version of Cascadia Code has even more rendering problems, the antialiasing seems to be broken there? Ah, now that I write that, NF uses the otf versions. Hmm. There is devinitively somthing strange about how Windows Terminal handles Cascadia Code in the antialias, it looks far far smoother than all other fonts.

Finii commented 1 year ago

Unfortunately I have forgotten almost all Windows related things. Would be worth to try disabling ClearType (I believe it was called something like that) and or other font rendering settings. But were are they ;-D

Finii commented 1 year ago

The rendering flags are different :-o

image

image

Is the code not working :-o

image

Edit: I have only the lowestppem change in the font-patcher test suite, not the ppem to int :angry:

Finii commented 1 year ago

WAT

image

Ah, now I know. Delugia pushes the patched font one time more through fontforge to change the names, and fontforge does not even see neither the flags nor the lowestPPEM, so they get destroyed afterwards :-(

Will fix that, thanks for reporting!

Finii commented 1 year ago
#!/usr/bin/env sh
#
# Create and rename one font style according to the specs
#
# Example invocation:
#   do_generate 01 --powerline --mono CascadiaCodePL-Regular.ttf DelugiaPowerline.ttf Delugia Regular
#
# No parameters are checked, but they are:
# 1: Number of logfile
# 2: Conversion spec #1
# 3: Conversion spec #2
# 4: Input font file name
# 5: Output font file name
# 6: Font family name

set -e

if [ "$#" -ne 6 ]; then
    exit 1
fi

PWD=$( pwd )

rm -f C*.ttf
fontforge -script "${PWD}/font-patcher" --careful "${3}" --custom SomeExtraSymbols.sfd --no-progressbars "${PWD}/ttf/static/${4}" "${2}" --outputdir "${PWD}" | tee "process${1}.log"

if [ -z "${OURVERSION}" ]; then
    # Github CI sets this variable, but this can be useful for manual calls:
    OURVERSION=`git describe --always --tags`
fi
fontforge -script "${PWD}/rename-font" --orig "${PWD}/ttf/static/${4}" --input ${PWD}/C*.ttf --output "${PWD}/${5}" --version "${OURVERSION}" --name "${6}"

First patching, the patching fixes the flags and lowest-ppm AFTER fontforge did its thing. And then again fontforge to change the names, but fontforge always writes dump default values in both fields :-(

Finii commented 1 year ago

Peek 2023-01-31 16-28

Still some difference, but less visibly so

Finii commented 1 year ago

@rashil2000

Maybe you can check the fonts generated with the fix (scroll down): https://github.com/adam7/delugia-code/actions/runs/4062092045

If they are fine we can pull and re-release.

rashil2000 commented 1 year ago

There is devinitively somthing strange about how Windows Terminal handles Cascadia Code in the antialias, it looks far far smoother than all other fonts.

Yes damn you're right, I remember suddenly spotting this difference when I upgraded my Terminal version some months ago. I felt something changed with how the Terminal handles fonts, and waited for the next release.

Maybe you can check the fonts generated with the fix (scroll down):

I downloaded the artifact from the action.

Here's Cascadia: image

Here's Delugia: image

The font size is 11, unfortunately I still see the original difference.

Finii commented 1 year ago

So. Finally to be able to really test this, I removed the Cascadia Cove that are part of the Windows Terminal app.

Which is kind of hard

grafik

No Cascadia Code to be seen in neither Terminal nor Fonts

Finii commented 1 year ago

Install only static fonts, the two we want to check:

grafik

Still different

grafik

grafik

Peek 2023-02-03 12-59

Finii commented 1 year ago

No wait, I compare the ttf with the otf

grafik

grafik

Finii commented 1 year ago

Ah, now they look the same...

grafik

Right side: see the Cascadia Code otf is installed

grafik

grafik

Finii commented 1 year ago

The otf version has no autohint run, at least not in the version number.

Edit: Which should not have anything to do anything with glyph height

Finii commented 1 year ago

Peek 2023-02-03 13-28

So the issue you have is a difference between Cascadia Code otf and ttf

I guess ;-)

AHH, but then you talk about Delugia which is a patched version of the ttf Cascadia Code one.

I do not know what they have in Cascadia Code TTF that is missing in Cascadia Code OTF and all patched versions.

Finii commented 1 year ago

Differently encoded in tables

image

Finii commented 1 year ago

Ah, so if I create a Delugia with the current HEAD font-patcher (HEAD of nerd-fonts) from the static/ttf, it will look different, but look the same as Cascadia Code static/ttf.

So there are differences in Cascadia Code depending on static/variable and ttf/otf, but we can do nothing about these. The patched fonts (Delugia and also vanilla Caskaydia) look the same as the original MS font that has been taken as source.

grafik


I would close this now. (?)

This (Delugia) should be more like the "normal / autoinstalled" Cascadia Code, because Windows Terminal installs the variable-ttf version. Delugia is based on the static-ttf version. CaskaydiaCove is based on static-otf which looks even more different.

rashil2000 commented 1 year ago

Okay, thanks for the detailed investigation!