nerd-fonts icon indicating copy to clipboard operation
nerd-fonts copied to clipboard

Update Cascadia to 2111.01

Open Finii opened this issue 4 years ago • 15 comments

Description

Update Cascadia to 2111.01

Also including the italic variants.

We do not use the PL versions but patch in the PL glyphs ourselves. If this is smart can be discussed (I believe: no).

This does not add 'Cascadia Mono'.

[how]

$ ./standardize-and-complete-readmes.sh ../../src/unpatched-fonts/CascadiaCode
$ ./gotta-patch-em-all-font-patcher\!.sh Cascadia

[note] Also fix font name typo ('Cascdia') in info files.

[note] Because of the font family naming problem the font-patcher has been patched. See comments.

Requirements / Checklist

  • [x] Read the Contributing Guidelines
  • [x] Read or at least glanced at the FAQ
  • [x] Read or at least glanced at the Wiki
  • [x] Scripts execute without error (if necessary):
    • If any of the scripts were modified they have been tested and execute without error, e.g.:
      • ./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
      • ./gotta-patch-em-all-font-patcher\!.sh Hermit
  • [x] Extended the README and documentation if necessary, e.g. You added a new font please update the table

What does this Pull Request (PR) do?

  • Update Cascadia Files in src/unpatched-fonts/CascadiaCode/ to latest release files.
  • Include italics
  • Use standard mechanism to create patched fonts
  • Patched fonts included in PR.

How should this be manually tested?

Use a font or two.

Any background context you can provide?

https://github.com/microsoft/cascadia-code/releases/tag/v2111.01

What are the relevant tickets (if any)?

Stalled #601

Screenshots (if appropriate or helpful)

Finii avatar Dec 16 '21 17:12 Finii

The standard font naming of font-patcher is not very nice for fonts with multiple weights (which Cascadia has).

See https://github.com/ryanoasis/nerd-fonts/pull/717#issuecomment-995879333

This PR uses a slightly modified font-patcher to get a more reasonable font grouping. We use Really set Family to what we want (mentioned in comment linked above).

This has been done by modifying font-patcher:

--- a/font-patcher
+++ b/font-patcher
@@ -224,6 +224,17 @@ class font_patcher:
         #     self.args.weather is True
         # ])
 
+    def insert_sfnt(self, key, value):
+        found = False
+        table = list(self.sourceFont.sfnt_names)
+        for i, e in enumerate(table):
+            if e[1] != key:
+                continue
+            table[i] = ( e[0], key, value )
+            found = True
+        if not found:
+            table += [ ( "English (US)", key, value ) ]
+        self.sourceFont.sfnt_names = tuple(table)
 
     def setup_font_names(self):
         verboseAdditionalFontNameSuffix = " " + projectNameSingular
@@ -399,7 +410,7 @@ class font_patcher:
         self.sourceFont.fontname   = " ".join(fontname.split())
 
         self.sourceFont.appendSFNTName(str('English (US)'), str('Preferred Family'), self.sourceFont.familyname)
-        self.sourceFont.appendSFNTName(str('English (US)'), str('Family'), self.sourceFont.familyname)
+        self.insert_sfnt(str('Family'), self.sourceFont.familyname)
         self.sourceFont.appendSFNTName(str('English (US)'), str('Compatible Full'), self.sourceFont.fullname)
         self.sourceFont.appendSFNTName(str('English (US)'), str('SubFamily'), subFamily)
         self.sourceFont.comment = projectInfo
-- 
2.32.0

Finii avatar Dec 16 '21 17:12 Finii

Font naming details:

$ fontforge --script ~/git/nerd-fonts/bin/scripts/name_parser/query_relevant_names patched-fonts/CascadiaCode/**/*Complete.otf 2>/dev/null

 |PSname                                             | | Fullname                                           | | Family                         | | Subfamily                      | | Typogr. Family                 | | Typogr. Subfamily
 |-------------------------------------------------- |-| -------------------------------------------------- |-| ------------------------------ |-| ------------------------------ |-| ------------------------------ |-| ------------------------------
 |CaskaydiaCoveNerdFontComplete-BoldItalic           | | Caskaydia Cove Bold Italic Nerd Font Complete      | | CaskaydiaCove Nerd Font        | | Bold Italic                    | | CaskaydiaCove Nerd Font        | |
 |CaskaydiaCoveNerdFontComplete-Bold                 | | Caskaydia Cove Bold Nerd Font Complete             | | CaskaydiaCove Nerd Font        | | Bold                           | | CaskaydiaCove Nerd Font        | |
 |CaskaydiaCoveNerdFontComplete-ExtraLightItalic     | | Caskaydia Cove ExtraLight Italic Nerd Font Complet | | CaskaydiaCove Nerd Font        | | Italic                         | | CaskaydiaCove Nerd Font        | | ExtraLight Italic
 |CaskaydiaCoveNerdFontComplete-ExtraLight           | | Caskaydia Cove ExtraLight Nerd Font Complete       | | CaskaydiaCove Nerd Font        | | Regular                        | | CaskaydiaCove Nerd Font        | | ExtraLight
 |CaskaydiaCoveNerdFontComplete-LightItalic          | | Caskaydia Cove Light Italic Nerd Font Complete     | | CaskaydiaCove Nerd Font        | | Italic                         | | CaskaydiaCove Nerd Font        | | Light Italic
 |CaskaydiaCoveNerdFontComplete-Light                | | Caskaydia Cove Light Nerd Font Complete            | | CaskaydiaCove Nerd Font        | | Regular                        | | CaskaydiaCove Nerd Font        | | Light
 |CaskaydiaCoveNerdFontComplete-Italic               | | Caskaydia Cove Italic Nerd Font Complete           | | CaskaydiaCove Nerd Font        | | Italic                         | | CaskaydiaCove Nerd Font        | |
 |CaskaydiaCoveNerdFontComplete-Regular              | | Caskaydia Cove Regular Nerd Font Complete          | | CaskaydiaCove Nerd Font        | | Regular                        | | CaskaydiaCove Nerd Font        | |
 |CaskaydiaCoveNerdFontComplete-SemiBoldItalic       | | Caskaydia Cove SemiBold Italic Nerd Font Complete  | | CaskaydiaCove Nerd Font        | | Italic                         | | CaskaydiaCove Nerd Font        | | SemiBold Italic
 |CaskaydiaCoveNerdFontComplete-SemiBold             | | Caskaydia Cove SemiBold Nerd Font Complete         | | CaskaydiaCove Nerd Font        | | Regular                        | | CaskaydiaCove Nerd Font        | | SemiBold
 |CaskaydiaCoveNerdFontComplete-SemiLightItalic      | | Caskaydia Cove SemiLight Italic Nerd Font Complete | | CaskaydiaCove Nerd Font        | | Italic                         | | CaskaydiaCove Nerd Font        | | SemiLight Italic
 |CaskaydiaCoveNerdFontComplete-SemiLight            | | Caskaydia Cove SemiLight Nerd Font Complete        | | CaskaydiaCove Nerd Font        | | Regular                        | | CaskaydiaCove Nerd Font        | | SemiLight

with this helper script:

#!/usr/bin/env python
# coding=utf8

import fontforge
import sys

def get_sfnt_dict(font):
    """Extract SFNT table as nice dict"""
    return { k: v for l, k, v in font.sfnt_names }

def format_names(header, *stuff):
    """Unify outputs (with header)"""
    f = '{:1.1}|{:50.50} |{:1.1}| {:50.50} |{:1.1}| {:30.30} |{:1.1}| {:30.30} |{:1.1}| {:30.30} |{:1.1}| {:.30}'
    if header:
        d = '------------------------------------------------------------'
        return f.format(*stuff) + '\n' + f.format('', d, d, d, d, d, d, d, d, d, d, d)
    return f.format(*stuff).rstrip()

###### Let's go!

if len(sys.argv) < 2:
    print('Usage: {} font_name [font_name ...]\n'.format(sys.argv[0]))
    sys.exit(1)

print(format_names(True, '', 'PSname', '', 'Fullname', '', 'Family', '', 'Subfamily', '', 'Typogr. Family', '', 'Typogr. Subfamily'))

for filename in sys.argv[1:]:

    font = fontforge.open(filename)
    sfnt = get_sfnt_dict(font)
    fullname = font.fullname
    fontname = font.fontname
    font.close()

    sfnt_psname =  sfnt['PostScriptName']
    sfnt_full =    sfnt['Fullname']
    sfnt_fam =     sfnt['Family']
    sfnt_subfam =  sfnt['SubFamily']
    sfnt_pfam =    sfnt['Preferred Family'] if 'Preferred Family' in sfnt else ''
    sfnt_psubfam = sfnt['Preferred Styles'] if 'Preferred Styles' in sfnt else ''

    if fontname != sfnt_psname or fullname != sfnt_full:
        o1 = format_names(False, '!', fontname, '', fullname, '', '', '', '', '', '', '', '')
        o1 += '\n'
    else:
        o1 = ''
    o2 = format_names(False, '', sfnt_psname, '', sfnt_full, '', sfnt_fam, '', sfnt_subfam, '', sfnt_pfam, '', sfnt_psubfam)

    print(o1 + o2)

Finii avatar Dec 16 '21 17:12 Finii

Open questions

  • Add Cascadia Mono?
  • Use Cascadia * PL together with a partial --careful?
  • Font Family and SubFamily naming :-(

Finii avatar Dec 16 '21 17:12 Finii

We could also pull #717 (which does not change anything if users do not use --parser).

Generate Caskaydia Cove with --parser for this PR (secretly, without telling anyone). :grinning:

Finii avatar Dec 16 '21 17:12 Finii

We could also pull #717 (which does not change anything if users do not use --parser).

That's actually not a bad idea. I was thinking #717 would go with the next major release (3.0) but might be a good idea to incorporate it in a limited fashion and prove/test it out with some limited fonts (Cascadia)

Add Cascadia Mono?

I'd say no, not for now, but I don't have a strong opinion on that.

Font Family and SubFamily naming :-(

I think it's best to take the approach of incremental steps. There are a lot of issues and requests and it's all too tempting to try to tackle it all at once (or at least I can get lost in that way). At least here we get the font updated, names as it seems is going to take some time and trial and error to get better.

ryanoasis avatar Dec 20 '21 02:12 ryanoasis

I would like to merge this soon.

Generate Caskaydia Cove with --parser for this PR (secretly, without telling anyone).

I think maybe that is the most reasonable way forward and changes to patcher etc are going to now repatch the fonts upon changes to the font-patcher

ryanoasis avatar Dec 24 '21 20:12 ryanoasis

I did the patching again, but this time with all the bells and whistles ;-)

i.e.

  • MASTER
  • #732 applied
  • #717 applied
  • Use --parser in gonna-patch-em-all https://github.com/Finii/nerd-fonts/commit/d1ecbab9896be338484f9d1dd9df67824c8e3e43

Not sure if you want the result here, therefore it is in the fork: https://github.com/Finii/nerd-fonts/tree/feature/cascadia-2111.01

Related #731 bottom.

Finii avatar Dec 28 '21 16:12 Finii

Could you implement your flag idea (i.e. do some special logic with Cascadia only) so this will work okay with the release action? 🙇🏻

now that the fonts are rebuilding in CI there is going to continuously be conflicts and if I merge with --theirs that'll be fine but during a release they will get overwritten 😢

ryanoasis avatar Jan 09 '22 19:01 ryanoasis

Hope this is what you intended. The release action seems to use gotta-*.sh.

Hard reset to current master and cherry pick #732 and #717:

git reset --hard origin/master
git cherry-pick cfcd15aa25afa6450da6287864720ec4a2a3bbf2
git cherry-pick e5768e925cd023c31bdea80adc7c7d2157360488
git cherry-pick d8579b1b11e8154fcf958293cf5444accade5bcc
git cherry-pick d887391ca0ba7bb0d4930a3fb14246f37340708f
git cherry-pick e805b87997bf7dbe3d99fc3582e246d8c9cb4dda
git cherry-pick 2016539a9188c435256a63733b8b2216817dac54
git cherry-pick ae0f6bf3b7169f6e21db4c42049c7232a51b72ee
git cherry-pick 53f759a774e424f049d4f8f240c1ff0726a1c18b
git cherry-pick 89620ade6d78b21191d7e9194af8ebc141ab9680
git cherry-pick 778763b49f7a4cbd034432988b54c1b34a8dcf11
git cherry-pick af1eab2458474c8c524611ac341fd5920a0d70e0

cd src/unpatched-fonts/CascadiaCode
cp ~/Downloads/CascadiaCode-2111.01/otf/static/CascadiaCode-Bold* Bold      
cp ~/Downloads/CascadiaCode-2111.01/otf/static/CascadiaCode-ExtraLight* ExtraLight
cp ~/Downloads/CascadiaCode-2111.01/otf/static/CascadiaCode-Light* Light
cp ~/Downloads/CascadiaCode-2111.01/otf/static/CascadiaCode-Regular.otf Regular
cp ~/Downloads/CascadiaCode-2111.01/otf/static/CascadiaCode-Italic.otf Regular 
cp ~/Downloads/CascadiaCode-2111.01/otf/static/CascadiaCode-SemiBold* SemiBold
cp ~/Downloads/CascadiaCode-2111.01/otf/static/CascadiaCode-SemiLight* SemiLight

The result is 2b29a96

Then added a way to specify --parser in the config.cfg of individual source fonts. I was a bit hesitant to add a specific font name into the code; and in this way source fonts can be switched over one by one conveniently.

  • patch-em-all: Allow to specify font specific options 109d2aa
  • name-parser: Create more usable short (Windows) names 69fa09c
  • Update patched Cascadia (Caskaydia) 85d4783

I will push both changing commits (patch-em-all: options & name-parser: short names) also to #717, where it belongs.

Note: CodeClimate probably fails here, because one can not commit changes to the CodeClimate settings and have them into effect in one PR, I would have needed to push them one by one... (or there is a real issue)

So in summary: Merging this will implicitely pull

  • #717 (will silently sit there unless a user specifies --parse
  • #732 (looked for me you wanted to test that also)

Edit: typo

Finii avatar Jan 10 '22 13:01 Finii

I forgot to mention, and I'm not sure if it was because of a change I made to get it to run but.. there was strange script output for Cascadia: Generated: CaskaydiaCoveNERDFONTCOMPLETE-Regular

Also, it generated file with names such as C a s k a y d i a C o v e N e r d F o n t C o m p l e t e Regular.otf or Caskaydia Cove N e r d F o n t C o m p l e t e Regular.otf

ryanoasis avatar Feb 06 '22 00:02 ryanoasis

Force push: Removed patched fonts from all the commits (as per https://github.com/ryanoasis/nerd-fonts/pull/775#issuecomment-1030713133). This improves future rebase actions (if needed).

Needed the rebase for this: Add change to font-patcher.zip to include the now needed Module files.

Finii avatar Feb 06 '22 15:02 Finii

I forgot to mention, and I'm not sure if it was because of a change I made to get it to run but.. there was strange script output for Cascadia: Generated: CaskaydiaCoveNERDFONTCOMPLETE-Regular

Can reproduce...

Given this small 2-line-script:

#!/usr/bin/env python

from __future__ import absolute_import, print_function, unicode_literals

import sys
import os

sys.path.insert(0, os.path.abspath(os.path.dirname(sys.argv[0])) + '/bin/scripts/name_parser/')
from FontnameParser import FontnameParser
from FontnameTools import FontnameTools

parser_name = 'Cascadia Code Regular'
print(FontnameParser(parser_name).ps_fontname())
fini@Ryzen:~/git/nerd-fonts$ python3 aa.py
CaskaydiaCove-Regular
fini@Ryzen:~/git/nerd-fonts$ python2 aa.py
CASKAYDIACOVE-Regular

Interestingly it works OK under Python 2, if the from __future__ is dropped?!!

Edit: It is just the unicode_literals!

Finii avatar Feb 06 '22 16:02 Finii

Source

Drawbacks of unicode-literals

Adding unicode_literals to a module amounts to a “global flag day” for that module, changing the data types of all strings in the module at once. Cautious developers may prefer an incremental approach. (See here for an excellent article describing the superiority of an incremental patch-set in the the case of the Linux kernel.)

Changing to unicode_literals will likely introduce regressions on Python 2 that require an initial investment of time to find and fix. The APIs may be changed in subtle ways that are not immediately obvious.

Regressions :roll_eyes:

Reason known the fix will be easy *cough* ;)

Finii avatar Feb 06 '22 16:02 Finii

Thanks, tested the font and it is working. I am using latest Windows Terminal.

RomelSan avatar Apr 18 '22 00:04 RomelSan

Rebase on master, force push (to keep this easily mergeable).

Finii avatar May 13 '22 06:05 Finii

Rebase on master (because manual merge conflict solving), force push

Finii avatar Aug 20 '22 17:08 Finii

Need to check:

  • docker
  • font-patcher.zip

Edit: It is in the zip and it should be in the docker. The later can only be checked after pulling this. Edit: docker checked

Finii avatar Aug 20 '22 17:08 Finii

Do the name_parser tests... See this for an explanation: https://github.com/ryanoasis/nerd-fonts/blob/feature/cascadia-2111.01/bin/scripts/name_parser/README.md

$ fontforge name_parser_test1 ../../../src/unpatched-fonts/**/*.[ot]tf 2>/dev/null
[...]
Fonts with different name rendering: 69/601 (69/69 are in known_issues)
There are 3 lines not needed in known_issues, appending commented out in new known_issues

Reasons:

  • Lilex VF has been removed
$ fontforge name_parser_test2 ../../../src/unpatched-fonts/**/*.[ot]tf 2>/dev/null
Fonts with different name rendering: 437/598 (430/437 are in known_issues)
There are 552 lines not needed in known_issues, appending commented out in new known_issues

Reasons:

  • 67 Noto Serif Display fonts have been removed

  • 68 Noto Sans Display fonts have been removed

  • Noto Emoji has been removed

  • 2 Fura Mono Powerline have been changed

  • 67+68+1+2 = 138 --> four lines each = 552 lines

  • Added Cascadia Code Italic for ExtraLight, Light, SemiBold, SemiLight

  • Added Fira Mono Bold

Hmm, what is it about FuraMono / Fira Mono? In older times Fira Mono was a RFN, so we called it FuraMono. But the RFN has been removed at least in 2018 and 2019 for Mono.

We already list both as 'no RFN': image

Related:

  • https://github.com/ryanoasis/nerd-fonts/issues/136
  • https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraMono

This still needs cleanup (and probably a source update?)

Finii avatar Aug 21 '22 18:08 Finii

This is ready to be merged now.

  • It is added as experimental feature that people need to actively select with --makegroups
  • It is used by the CI only on Cascadia Code, later more fonts might follow (like in 3.0.0)

Finii avatar Aug 22 '22 08:08 Finii