-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Cascadia to 2111.01 #723
Conversation
The standard font naming of See #717 (comment) This PR uses a slightly modified This has been done by modifying --- 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 |
Font naming details:
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) |
Open questions
|
We could also pull #717 (which does not change anything if users do not use Generate Caskaydia Cove with |
That's actually not a bad idea. I was thinking #717 would go with the next major release (
I'd say no, not for now, but I don't have a strong opinion on that.
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. |
I would like to merge this soon.
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 |
I did the patching again, but this time with all the bells and whistles ;-) i.e.
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. |
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 |
a9d6a37
to
85d4783
Compare
Hope this is what you intended. The release action seems to use 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
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
Edit: typo |
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: Also, it generated file with names such as |
ce7ff4d
to
5de5359
Compare
Force push: Removed patched fonts from all the commits (as per #775 (comment)). Needed the rebase for this: |
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())
Interestingly it works OK under Python 2, if the Edit: It is just the |
Regressions 🙄 Reason known the fix will be easy *cough* ;) |
[why] The symbol only fonts Symbols-1000-em Nerd Font Complete.ttf and 2048-em in `NerdFontsSymbolsOnly/` are gerenated from some 'almost' empty source fonts, that are assumably in turn generated from the sfd font descriptions in `src/glyphs/`? The process is not documented and we have issues in the generated font (for example the glyph for capital `E` is defined (and empty) #581 #765). [how] Use the existing font definitions from `src/glyphs/*.sfd` directly as source font. That needs a change in font-patcher because the empty fonts have no glyphs that can be used to orient the scaling upon. In that case scale on the source font definitions EM. Then we need patch-em-all to also patch *.sfd fonts. And finally we need patch-em-all to take a font specific command line switch for font-patcher (compare 9e2bc9a of #723) to instruct it to create a ttf rather than a sfd front file. In the sfd file we additionally set the Panose type. And the UnderlinePosition is adjusted to match the current patched font. [note] Also fix wrong glob pattern in patch-em-all `*.[o,t]tf`. The comma is for sure some leftover from a '{}' shell pattern, that is not used anymore. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] The symbol only fonts Symbols-1000-em Nerd Font Complete.ttf and 2048-em in `NerdFontsSymbolsOnly/` are generated from some 'almost' empty source fonts, that are assumable in turn generated from the sfd font descriptions in `src/glyphs/`? The process is not documented and we have issues in the generated font (for example the glyph for capital `E` is defined (and empty) #581 #765). [how] Use the existing font definitions from `src/glyphs/*.sfd` directly as source font. That needs a change in font-patcher because the empty fonts have no glyphs that can be used to orient the scaling upon. In that case scale on the source font definitions EM. Then we need patch-em-all to also patch *.sfd fonts. And finally we need patch-em-all to take a font specific command line switch for font-patcher (compare 9e2bc9a of #723) to instruct it to create a ttf rather than a sfd font file. In the sfd file we additionally set the Panose type. And the UnderlinePosition is adjusted to match the current patched font. [note] Also fix wrong glob pattern in patch-em-all `*.[o,t]tf`. The comma is for sure some leftover from a '{}' shell pattern, that is not used anymore. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Use all stuff from PR ryanoasis#723 to allow correct font names. Use fontforge HEAD to have no 16 bit field errors. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Thanks, tested the font and it is working. |
[why] Some CJK fonts seem to have no Fullname. [how] But they have a Postscript name. Use that for parsing the names. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] Under certain circumstances the WWS names (Family and Subfamily) are used to identify a font. We do not touch these SFNT table entries, so when the font is renamed these are wrong (have the original name). Font-grouping will go wrong then. [how] The typographic ('Preferred') Family and Styles are set correctly already and they follow the WWS pattern, so the WWS fields can be (and should) be empty. They exist to allow font grouping in the case where the typographic names do not follow that pattern. Remove preexisting WWS entries (because they are not needed anymore, otherwise we would need to write the corrected new names there). We already set the WWS bit in fsSelection that is needed: def fs_selection(self, fs): """Modify a given fsSelection value for current name, bits 0, 5, 6, 8, 9 touched""" [...] b |= WWS # We assert this by our naming process return b Unfortunately we have no way (jet) to set fsSelection. This is only the case for Iosevka for all fonts in src/unpatched-fonts. Reported-by: Rui Ming (Max) Xiong <xsrvmy> Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
fontforge has an undocumented call to set the fsSelection bits. Never rely on documentation :-( Found this here: fontforge/fontforge#3174 And the readback values are actually not read from the source font, so we do not use them. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] A lot people expect the font-patcher to be a stand alone script. They even think that the source glyphs (symbols) to be added to be somehow magically there and one PR makes sure that they are fetched if missing. The same problem arises when we have a script distributed over multiple files. For maintenance reasons and code quality this is what one wants. But that might hinder easy use of the font-patcher. [how] Put all the code in the main script. That has an additional drawback: For the nameparser_test* scripts to work we need stand alone files for that classes. Now the code is duplicated and will get out of sync. I have no solution for that, and it all boils down what Nerd Font wants to do. One solution would be to have font-patcher properly set up / divided in many .py files, and to create one monolithic font-patcher from all the sources on demand (via github actions or manually when someone pushes changes to any of the constituends). That approach is taken by a lot of C++ 'header only libraries' that originally consist of a lot files but create one big 'all in one' file automatically from all the small files. For now I guess we can live with the duplication, but we need to think about a solution, as this will bite us sooner or later. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
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'. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] We want to patch Cascadia with `--parser` while all other fonts shall be patched as before. [how] Use the config.cfg file that each source font can have to specify one arbitrary option to the font-patcher calls. This is just set in Cascadia's config.cfg, but can be extended to other fonts gradually. In this way the stand alone `font-patcher` works as before, unless someone adds the `--parser` option. Which probably will become the recommended way to use it over time. The patch-em-all script on the other hand can be instructed to use or not to use --parser on a font by font basis via their cfg file. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] The fontname for Windows can be quite unusable, for example `CaskaydiaCoveNerdFontCompleteM-` for several different fonts, as this is the maximum allowed length of 31 characters that is enforced. The style/weight is completely lost. [how] Split the name into base and style (at a dash `-`) and just shrink the base name. Result for example: `CaskaydiaCoveN-ExtraLightItalic` Use equal approach for the PostScriptName (although it is less likely that length limit is ever met). Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This reverts commit df42c91. [why] Having all the code in one big file is probably a maintenance nightmare. We should develop other solutions to make the usage for end-users easy. Future commits might do that.
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] The option `--parser` instructs `font-patcher` to come up with the font naming by utilizing the FontnameParser object. This sounds logical from a programmers perspective, but the option name is not descriptive for end users of `font-patcher` [how] As usual naming is hard. A short but maybe more descriptive name for the option can be `--makegroups`; as it describes what the option means for the end user: functioning font grouping. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] Sometimes scripts can not be run. [how] Depending on installed python versions and 'alternatives' setup the script's shebang needs to point to python3 of course. Also the files need the executable bit set. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] People might want to use the font-patcher with just the one script file. The error message does not help them to understand the problem. [how] Require the modules only if the user wants to use it (i.e. --makegroups). Give the expected path in the error message. We could also download the missing files instead, similar to #741 But that PR did not get any feedback yet, so I do not know if this is something we want. Anyhow, the fetching of missing parts should then be unified for both usecases (i.e. Fontname* and src/glyphs). And then, there is font-patcher.zip (which needs to be adapted), maybe that is the way to go. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] The naming has bizarre blanks strewn in sometimes, or is all caps. For example `C a s k a y d i a C o v e` or `CASKAYDIACOVE-Regular` [how] When run under Python2 all strings are unicode strings because `unicode_literals` is imported by `font-patcher`. Unfortunately the code checks for type str; but that will all become type unicode with the import. One check is suboptimal anyhow and can be dropped, while the other is turned around. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
195c5d1
to
45ce832
Compare
Rebase on master (because manual merge conflict solving), force push |
Need to check:
Edit: It is in the zip and it should be in the docker. The later can only be checked after pulling this. |
Do the name_parser tests...
Reasons:
Reasons:
Hmm, what is it about FuraMono / Fira Mono? We already list both as 'no RFN': Related:
This still needs cleanup (and probably a source update?) |
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This is ready to be merged now.
|
[why] We want to patch some fonts with different font-patcher options. [how] Use the config.cfg file that each source font can have to specify one arbitrary option to the font-patcher calls. [note] This is partially commit 9e2bc9a from ryanoasis#723. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why] The symbol only fonts Symbols-1000-em Nerd Font Complete.ttf and 2048-em in `NerdFontsSymbolsOnly/` are generated from some 'almost' empty source fonts, that are assumable in turn generated from the sfd font descriptions in `src/glyphs/`? The process is not documented and we have issues in the generated font (for example the glyph for capital `E` is defined (and empty) ryanoasis#581 ryanoasis#765). [how] Use the existing font definitions from `src/glyphs/*.sfd` directly as source font. That needs a change in font-patcher because the empty fonts have no glyphs that can be used to orient the scaling upon. In that case scale on the source font definitions EM. Then we need patch-em-all to also patch *.sfd fonts. And finally we need patch-em-all to take a font specific command line switch for font-patcher (compare 9e2bc9a of ryanoasis#723) to instruct it to create a ttf rather than a sfd font file. In the sfd file we additionally set the Panose type. And the UnderlinePosition is adjusted to match the current patched font. [note] Also fix wrong glob pattern in patch-em-all `*.[o,t]tf`. The comma is for sure some leftover from a '{}' shell pattern, that is not used anymore. (This comment is probably outdated, due to rebasing.) Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
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]
[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
./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
./gotta-patch-em-all-font-patcher\!.sh Hermit
What does this Pull Request (PR) do?
src/unpatched-fonts/CascadiaCode/
to latest release files.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)