Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatize casks update on releases #1008

Merged
merged 20 commits into from
Dec 14, 2022
Merged

Automatize casks update on releases #1008

merged 20 commits into from
Dec 14, 2022

Conversation

Finii
Copy link
Collaborator

@Finii Finii commented Nov 27, 2022

Description

Automatize homebrew cask updates in releases.

Requirements / Checklist

What does this Pull Request (PR) do?

  • Update the generate-casks.sh script to produce modern updates of the existing casks
    • Without changing the (sometimes strange) cask name
    • With sorted font clauses to make autogenerated update diffs be small
  • Hook that into the CI workflows
    • We need a homebrew fork in the organization
    • Push changed files to our fork
    • Autocreate PR at homebrew

How should this be manually tested?

I guess we will have a manual trigger too, but testing is of course hard(er) because we do not want to generate rouge PRs in some other project 馃槵

Any background context you can provide?

What are the relevant tickets (if any)?

#1003
Homebrew/homebrew-cask-fonts#6649

Screenshots (if appropriate or helpful)

@Finii
Copy link
Collaborator Author

Finii commented Nov 28, 2022

Fix some rare bug and remove leftover debug output; force push

@Finii
Copy link
Collaborator Author

Finii commented Nov 28, 2022

Still these unexpected (i.e. wrong) changes:

-  name "3270 Nerd Font (3270)"
+  name "3270Medium Nerd Font (3270)"

-  name "BigBlue_Terminal Nerd Font families (BigBlue Terminal)"
+  name "BigBlue_TerminalPlus Nerd Font (BigBlue Terminal)"

-  name "GoMono Nerd Font (Go)"
+  name "GoMono Nerd Font (Go Mono)"

-  name "iMWriting Nerd Font families (iA Writer)"
+  name "iMWritingDuoS Nerd Font (iA Writer)"

-  name "Literation Nerd Font families (Liberation)"
+  name "LiterationMono Nerd Font (Liberation)"

-  name "MesloLG Nerd Font families (Meslo LG)"
+  name "MesloLGL Nerd Font (Meslo)"

-  name "Mononoki Nerd Font (Mononoki)"
+  name "mononoki Nerd Font (Mononoki)"

-  name "Noto Nerd Font families (Noto)"
+  name "NotoMono Nerd Font (Noto)"

-  name "OpenDyslexic Nerd Font families (OpenDyslexic)"
+  name "OpenDyslexic Nerd Font (OpenDyslexic)"

-  name "ProFont Nerd Font families (ProFont)"
+  name "ProFontIIx Nerd Font (ProFont)"

-  name "ProggyCleanTT Nerd Font families (ProggyCleanTT)"
+  name "ProggyCleanTT Nerd Font (ProggyCleanTT)"

-  name "RobotoMono Nerd Font (RobotoMono)"
+  name "RobotoMono Nerd Font (Roboto Mono)"

+  name "Symbols Nerd Font (Symbols Only
+Symbols Only)"

I guess this is a fix:

-  font "Gohu/11/complete/GohuFont Nerd Font Complete.ttf"
-  font "Gohu/11/complete/GohuFont Nerd Font Complete Mono.ttf"
+  font "GohuFont Nerd Font Complete Mono.ttf"
+  font "GohuFont Nerd Font Complete.ttf"
+  font "GohuFont Nerd Font Complete Mono.ttf"
+  font "GohuFont Nerd Font Complete.ttf"
+  font "GohuFont Nerd Font Complete Mono.ttf"
+  font "GohuFont Nerd Font Complete.ttf"
+  font "GohuFont Nerd Font Complete Mono.ttf"
+  font "GohuFont Nerd Font Complete.ttf"

-  name "InconsolataGo Nerd Font (Inconsolata Go)"
+  name "InconsolataGo Nerd Font (InconsolataGo)"


What exactly is the livecheck doing?

   name "JetBrainsMono Nerd Font (JetBrains Mono)"
   desc "Developer targeted fonts with a high number of glyphs"
   homepage "https://github.com/ryanoasis/nerd-fonts"

   livecheck do
-    url :stable
-    regex(/^v?(\d+(?:\.\d+)+)$/i)
+    url :url
+    strategy :github_latest
   end

@Finii
Copy link
Collaborator Author

Finii commented Nov 29, 2022

https://docs.brew.sh/Brew-Livecheck

and

% brew livecheck --debug font-3270-nerd-font.rb
[...]

Cask:             font-3270-nerd-font
Livecheckable?:   Yes

URL (url):        https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/3270.zip
Strategy:         GithubLatest
URL (strategy):   https://github.com/ryanoasis/nerd-fonts/releases/latest
URL (final):      https://github.com/ryanoasis/nerd-fonts/releases/tag/v2.2.2
Regex (strategy): /href=.*?\/tag\/v?(\d+(?:\.\d+)+)["' >]/i

Matched Versions:
2.2.2

font-3270-nerd-font: 2.2.2 ==> 2.2.2

@Finii
Copy link
Collaborator Author

Finii commented Nov 29, 2022

-  name "3270 Nerd Font (3270)"
+  name "3270 Nerd Font families (3270)"

-  name "CaskaydiaCove Nerd Font (Caskaydia code)"
+  name "CaskaydiaCove Nerd Font (Cascadia Code)"

-  name "GoMono Nerd Font (Go)"
+  name "GoMono Nerd Font (Go Mono)"

-  name "iMWriting Nerd Font families (iA Writer)"
+  name "IMWriting Nerd Font families (iA Writer)"

-  name "InconsolataGo Nerd Font (Inconsolata Go)"
+  name "InconsolataGo Nerd Font (InconsolataGo)"

-  name "JetBrainsMono Nerd Font (JetBrains Mono)"
+  name "JetBrainsMono Nerd Font families (JetBrains Mono)"

-  name "MesloLG Nerd Font families (Meslo LG)"
+  name "MesloLG Nerd Font families (Meslo)"

-  name "Monofur Nerd Font (Monofur)"
+  name "Monofur Nerd Font families (Monofur)"

-  name "mplus Nerd Font (M+)"
+  name "Mplus Nerd Font (M+)"

-  name "Overpass Nerd Font (Overpass)"
+  name "Overpass Nerd Font families (Overpass)"

-  name "ProFont Nerd Font families (ProFont)"
+  name "ProFontIIx Nerd Font (ProFont)"

-  name "RobotoMono Nerd Font (RobotoMono)"
+  name "RobotoMono Nerd Font (Roboto Mono)"

-  name "Nerd Font Symbols Template (Symbols Only)"
+  name "Symbols Nerd Font (Symbols Only)"

-  name "Ubuntu Nerd Font (Ubuntu)"
+  name "Ubuntu Nerd Font families (Ubuntu)"

Looks ok except ProFont

@Finii
Copy link
Collaborator Author

Finii commented Nov 29, 2022

Nice, and it autodetects that we have now multiple families and not just one:

diff --git a/casks/font-profont-nerd-font.rb b/casks/font-profont-nerd-font.rb
index dcb6a36ad..83adcfc53 100644
--- a/casks/font-profont-nerd-font.rb
+++ b/casks/font-profont-nerd-font.rb
@@ -3,7 +3,7 @@ cask "font-profont-nerd-font" do
   sha256 "6ca55a1620f7eab6cea96f2dc83b8fb59bc900f4d72ce4bd508411f86c1ebe11"
 
   url "https://github.com/ryanoasis/nerd-fonts/releases/download/v#{version}/ProFont.zip"
-  name "ProFontIIx Nerd Font (ProFont)"
+  name "ProFont Nerd Font families (ProFont)"
   desc "Developer targeted fonts with a high number of glyphs"
   homepage "https://github.com/ryanoasis/nerd-fonts"
 
@@ -14,4 +14,6 @@ cask "font-profont-nerd-font" do
 
   font "ProFont IIx Nerd Font Complete Mono.ttf"
   font "ProFont IIx Nerd Font Complete.ttf"
+  font "ProFontWindows Nerd Font Complete Mono.ttf"
+  font "ProFontWindows Nerd Font Complete.ttf"
 end

@Finii Finii mentioned this pull request Dec 1, 2022
3 tasks
Finii added a commit that referenced this pull request Dec 14, 2022
Now we can create the casks of some specific release ('latest' in this
case) at will, based purely on the artifact files and on nothing in the
repo. We do not even need to fetch the repo.

This is still some kind of WIP, because we do not have the secrets and
not even a proper homebrew fork in our organization.

THIS WILL NOT WORK out of the box. Refer to PR #1008 to get instruction
on additional steps needed to make this run.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Finii added a commit that referenced this pull request Dec 14, 2022
Now we can create the casks of some specific release ('latest' in this
case) at will, based purely on the artifact files and on nothing in the
repo. We do not even need to fetch the repo.

This is still some kind of WIP, because we do not have the secrets and
not even a proper homebrew fork in our organization.

THIS WILL NOT WORK out of the box. Refer to PR #1008 to get instruction
on additional steps needed to make this run.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator Author

Finii commented Dec 14, 2022

At the moment this uses my Homebrew fork to prepare the PR with new casks.

This repo (Nerd Fonts) needs to have some access to it, to be able to create anything there.
For this I set up a fine grained access token like so:

image

Because I can not store secrets in this repo (Nerd Fonts), it is stored *cough cough* ...

The token will expire soon and afterwards this will not work anymore. This needs to be fixed for good, but that can only be done by Ryan.

[why]
Several different indentations methods used here. That confuses me and I
want to edit this file.

[how]
Unify to '4 blanks' as used in other (recently edited) files.
Unify if-then and while-do syntax.

Also replace single quotes with double quite in the cask file.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
* Remove appcast
* Process fonts in alphabetical order
* Skip fonts where no checksum can be determined
* Add livecheck
* Add description
* Fail generation on any error in the script

[notes]
* The code to work without checksum (:no_check) did not work anyhow

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
People might want to know how the original/unpatched font really is
called. This is done for most current casks.

[how]
Utilize jq and the fonts.json database to retrieve the name (which is
stored nowhere else). Put it in the parens in the name field.

Update some `unpatchedName`s.

[note]
Examples from current casks:

homebrew-cask-fonts/Casks$ find . -name '*nerd-font*' -exec grep " name" {} \; | sort
  name "3270 Nerd Font (3270)"
  name "Agave Nerd Font (Agave)"
  name "Anonymice Nerd Font (Anonymous Pro)"
  name "Arimo Nerd Font (Arimo)"
  name "AurulentSansMono Nerd Font (Aurulent Sans Mono)"
  name "BigBlue_Terminal Nerd Font families (BigBlue Terminal)"
  name "BitstreamVeraSansMono Nerd Font (Bitstream Vera Sans Mono)"
  name "BlexMono Nerd Font (IBM Plex Mono)"
  name "CaskaydiaCove Nerd Font (Caskaydia code)"
  name "CodeNewRoman Nerd Font (Code New Roman)"
  name "Cousine Nerd Font (Cousine)"
  name "DaddyTimeMono Nerd Font (DaddyTimeMono)"
  name "DejaVuSansMono Nerd Font (DejaVu Sans Mono)"
  name "DroidSansMono Nerd Font (Droid Sans Mono)"
  name "FantasqueSansMono Nerd Font (Fantasque Sans Mono)"
  name "FiraCode Nerd Font (Fira Code)"
  name "FiraMono Nerd Font (Fira)"
  name "GohuFont Nerd Font (Gohu)"
  name "GoMono Nerd Font (Go)"
  name "Hack Nerd Font (Hack)"
  name "Hasklug Nerd Font (Hasklig)"
  name "HeavyData Nerd Font (Heavy Data)"
  name "Hurmit Nerd Font (Hermit)"
  name "iMWriting Nerd Font families (iA Writer)"
  name "InconsolataGo Nerd Font (Inconsolata Go)"
  name "InconsolataLGC Nerd Font (Inconsolata LGC)"
  name "Inconsolata Nerd Font (Inconsolata)"
  name "Iosevka Nerd Font (Iosevka)"
  name "JetBrainsMono Nerd Font (JetBrains Mono)"
  name "Lekton Nerd Font (Lekton)"
  name "Literation Nerd Font families (Liberation)"
  name "MesloLG Nerd Font families (Meslo LG)"
  name "Monofur Nerd Font (Monofur)"
  name "Monoid Nerd Font (Monoid)"
  name "Mononoki Nerd Font (Mononoki)"
  name "mplus Nerd Font (M+)"
  name "Nerd Font Symbols Template (Symbols Only)"
  name "Noto Nerd Font families (Noto)"
  name "OpenDyslexic Nerd Font families (OpenDyslexic)"
  name "Overpass Nerd Font (Overpass)"
  name "ProFont Nerd Font families (ProFont)"
  name "ProggyCleanTT Nerd Font families (ProggyCleanTT)"
  name "RobotoMono Nerd Font (RobotoMono)"
  name "SauceCodePro Nerd Font (Source Code Pro)"
  name "ShureTechMono Nerd Font (Share Tech Mono)"
  name "SpaceMono Nerd Font (Space Mono)"
  name "TerminessTTF Nerd Font (Terminus)"
  name "Tinos Nerd Font (Tinos)"
  name "UbuntuMono Nerd Font (Ubuntu Mono)"
  name "Ubuntu Nerd Font (Ubuntu)"
  name "VictorMono Nerd Font (Victor Mono)"

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The existing Casks _all_ contain both the Mono and non-Mono variants.

I believe splitting would be a good idea, but that would break existing
uses.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
We want to replace the existing casks. But they do not have a consistent
way to name the casks. Sometimes blanks are preserved (as dashes):

      "unpatchedName": "DejaVu Sans Mono",
      "patchedName": "DejaVuSansMono",
      "caskName": "dejavu-sans-mono",

The above looks like cask-name == unpatched-name.

Here they introduce blanks out of thin air (the original name does not
have blanks):

      "unpatchedName": "DaddyTimeMono",
      "patchedName": "DaddyTimeMono",
      "caskName": "daddy-time-mono",

Here they add something to the name??!:

      "unpatchedName": "Gohu",
      "patchedName": "Gohu",
      "caskName": "gohufont",

Here the cask-name follows the RFN renaming:

      "unpatchedName": "Hasklig",
      "patchedName": "Hasklug",
      "caskName": "hasklug",

Here they do not follow the RFN renaming:

      "unpatchedName": "Liberation",
      "patchedName": "LiterationMono",
      "caskName": "liberation",

And there are a lot more ... strangenesses.
I guess the casks have been created by different people following
different ideas.

[how]
All these inconsistencies makes setting up rules how to determine the
cask name from the other names very complicated and brittle.

If we want to preserve the existing cask names the simplest and most
stable approach is to explicitely specify them in the fonts.json
database:
Introduce a new data field "caskName", like shown above.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The code takes the FamilyName out of the first patched font file and
puts that into the cask name field.

This has two problems:

After we joined Mono and non-Mono fonts into one cask the first font
might be a "Nerd Font Complete Mono" and we certainly do not want that
FamilyName in a cask that also contains the non-Mono variants.

We have some fonts with more than one Family, for example
  CaskaydiaCove Nerd Font SemiLight
  CaskaydiaCove Nerd Font Light
  CaskaydiaCove Nerd Font
  CaskaydiaCove Nerd Font ExtraLight

Taking the first encountered Family name is most certainly not want we
want.

[how]
Examine all patched fonts and collect their FamilyName and use the
shortest of them, as that usually is the base stem.

This still fails for somem fonts, like Hasklug
  Hasklig Black
  Hasklig ExtraLight
  Hasklig Light
  Hasklig Medium
  Hasklig Semibold
  Hasklug Nerd Font

But that font's FamilyName is broken anyhow, note that the RFN renaming
does not really work consistently. It would be fixed by using
`font-patcher` with option `--makegroups`, which should become the
default soon.
This will be tackled by the next commit.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Some fonts have different and not consistent Family names set,
especially (only) if the `--makegroups` option has not been used for
patching.

Example:
$ fc-query --format='%{family}\n' patched-fonts/Hasklig/Black/complete/Hasklug\ Black\ Nerd\ Font\ Complete.otf
Hasklug Nerd Font,Hasklig Black

See also previous commit's message, bottom.

[how]
We want to use only one of the Family names (fc-query reports all as
csv, unless we specify an index), so query one by one.
Check that it is 'our' name (that contains "Nerd") and not a leftover
from uncomplete patching.

[note]
Also whitespace change: One tab to spaces.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Add some more documentation / comments.
Increase version number.

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>
[why]
Sometimes the shortest Family is not a meaningful name, for example

  iMWritingDuo
  iMWritingDuospace
  iMWritingMono
  iMWritingQuattro

Obviously the shortest name is not adequate.

[how]
Instead we find the shortest word stem of the name. The common beginning
of all names. In the example above that is `iMWriting`.

If we have such a case we show in the name that there are multiple
families in the cask, by adding "families" to the name.

[note]
Also always capitalize the font name. Some fonts have a
all-small-letters name, but that seems a bit out of place and has been
changed with the manual naming (previously) already to Capitalized Name.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The symbols only font has two entries in the fonts.json and that breaks
generation of the cask.

[how]
Do the queries on a 'first wins' strategy; ignore further entries in the
fonts.json.

[note]
I guess we should remove one of the two instances of Symbols Only from
the database; I have still not figured out why there are two distinct
entries.
And why there are two fonts at all 馃槵

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It is in fact Meslo LG that we consume and produce.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
ProFontWindows is missing from the cask, just ProFontIIx is included.

According to their documentation ProFontWindows has been created
specifically for MS Windows, but it can also be useful on Linux or
MacOS. [1]

[how]
Make the filter more strict, so that we only filter out our own Windows
versions and not all fonts that contain "Windows" in the name.

[note]
I'm not sure this ProFontWindows font is useful at all ;-}

[1] https://tobiasjung.name/profont/ paragraph "ProFont for Windows"

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It fetches the release we did last, which can be a release candidate.
But we want the latest release, or some other specified one.

[how]
Add parameter for the version tag.

[note]
Also correct some docs.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It does not really make sense to couple the names of the download files
to some currently existing directories in the repo. They could be
different, especially if current version and requested version differ.

[how]
Complete rewrite. Fetch the release data from Github and examine the
release database.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
The json file is transported to jq via pipe AND as file.
That is not needed of course.

[how]
Just use the filename.

[note]
Also some whitespace changes.
Also remove debug output.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It does not really make sense to couple the casks, which checksums are
based on the zip files in the archive directory to files currently
existing in the repo. They could be different from the archived ones.

[how]
Use solely the archives. For this they must be unpacked temporarely so
that the fonts can be examined for family names.
We do not try to automatically determine the release tag of the archive
files. They could in principle we different for each. Instead it usually
has to be specified on the command line.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Finii added a commit that referenced this pull request Dec 14, 2022
Now we can create the casks of some specific release ('latest' in this
case) at will, based purely on the artifact files and on nothing in the
repo. We do not even need to fetch the repo.

This is still some kind of WIP, because we do not have the secrets and
not even a proper homebrew fork in our organization.

THIS WILL NOT WORK out of the box. Refer to PR #1008 to get instruction
on additional steps needed to make this run.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator Author

Finii commented Dec 14, 2022

Rebase on master, force push

@Finii Finii marked this pull request as ready for review December 14, 2022 08:37
Now we can create the casks of some specific release ('latest' in this
case) at will, based purely on the artifact files and on nothing in the
repo. We do not even need to fetch the repo.

This is still some kind of WIP, because we do not have the secrets and
not even a proper homebrew fork in our organization.

THIS WILL NOT WORK out of the box. Refer to PR #1008 to get instruction
on additional steps needed to make this run.

[note]
Remove cask generation from normal release workflow.
Later on the release workflow has to trigger the cask workflow.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii Finii merged commit 762be5b into master Dec 14, 2022
@Finii Finii deleted the feature/Casks-generation branch December 14, 2022 08:46
@Finii
Copy link
Collaborator Author

Finii commented Dec 14, 2022

This is in fact a bug and not a fix:

image

Finii added a commit that referenced this pull request Dec 14, 2022
[why]
Normally the release zip files have a flat directory structure, i.e. all
files are in the base directory and there are no subdirs. The existing
subdirectory structure is removed on zip creation via `archive-fonts.sh`.

If the patch results have two fonts with identical name these flat
archives can not be generated. The `archive-fonts.sh` reports:

    Could not create archive with the path junked (-j option) - likely
    same font names for different paths, zip status: $zipStatus
    Retrying with full path

But now the problem is only delayed. When the font file has the name
name the Family and SubFamily are most likely also the same for both
font files. If we install both the user (and the system) can not really
distinguish the font files anymore.

This turned up with [1] when doing a `brew style *nerd-font*` that
complains in fact about duplicate fonts to install. At that point we had
the additional problem that the subdir-path had been missing in the cask
files. So I'm not sure if it would work from a Cask standpoint (i.e.
font files are installed in subdirs).

Anyhow, this will fail when the user wants to select the font files,
because normally this is done on a Family-name basis. And identical file
name usually means identical Family-SubFamily.

Note that this ONLY happens with GohuFont, which has these subdirs:

    11/complete
    14/complete
    uni-11/complete
    uni-14/complete

The font has embedded bitmaps, but only one size. The "11" ones have
11px bitmap fonts and the "14" ones 14px bitmaps.
The "uni-" variant has much more glyphs.
Otherwise the differences are slim. From the font creation date the
"uni-" ones are newer.

[how]
Each font filename added to a cask is memorized. When the next fontfile
is to be added to the cask it is checked if we already have that
filename installed. Duplicates are then skipped.

If we have a deep archive, the fonts are added to the cask with full
relative path.

In case of Gohu that means the 11/complete variant is added (because all
files are alphabetically sorted before adding). By chance this is the
same variant that has historically been in the Cask, so no change here.

Fixes:

#1008 (comment)
Homebrew/homebrew-cask-fonts#6758 (comment)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
LNKLEO pushed a commit to LNKLEO/Nerd that referenced this pull request Nov 24, 2023
Now we can create the casks of some specific release ('latest' in this
case) at will, based purely on the artifact files and on nothing in the
repo. We do not even need to fetch the repo.

This is still some kind of WIP, because we do not have the secrets and
not even a proper homebrew fork in our organization.

THIS WILL NOT WORK out of the box. Refer to PR ryanoasis#1008 to get instruction
on additional steps needed to make this run.

[note]
Remove cask generation from normal release workflow.
Later on the release workflow has to trigger the cask workflow.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
LNKLEO pushed a commit to LNKLEO/Nerd that referenced this pull request Nov 24, 2023
[why]
Normally the release zip files have a flat directory structure, i.e. all
files are in the base directory and there are no subdirs. The existing
subdirectory structure is removed on zip creation via `archive-fonts.sh`.

If the patch results have two fonts with identical name these flat
archives can not be generated. The `archive-fonts.sh` reports:

    Could not create archive with the path junked (-j option) - likely
    same font names for different paths, zip status: $zipStatus
    Retrying with full path

But now the problem is only delayed. When the font file has the name
name the Family and SubFamily are most likely also the same for both
font files. If we install both the user (and the system) can not really
distinguish the font files anymore.

This turned up with [1] when doing a `brew style *nerd-font*` that
complains in fact about duplicate fonts to install. At that point we had
the additional problem that the subdir-path had been missing in the cask
files. So I'm not sure if it would work from a Cask standpoint (i.e.
font files are installed in subdirs).

Anyhow, this will fail when the user wants to select the font files,
because normally this is done on a Family-name basis. And identical file
name usually means identical Family-SubFamily.

Note that this ONLY happens with GohuFont, which has these subdirs:

    11/complete
    14/complete
    uni-11/complete
    uni-14/complete

The font has embedded bitmaps, but only one size. The "11" ones have
11px bitmap fonts and the "14" ones 14px bitmaps.
The "uni-" variant has much more glyphs.
Otherwise the differences are slim. From the font creation date the
"uni-" ones are newer.

[how]
Each font filename added to a cask is memorized. When the next fontfile
is to be added to the cask it is checked if we already have that
filename installed. Duplicates are then skipped.

If we have a deep archive, the fonts are added to the cask with full
relative path.

In case of Gohu that means the 11/complete variant is added (because all
files are alphabetically sorted before adding). By chance this is the
same variant that has historically been in the Cask, so no change here.

Fixes:

ryanoasis#1008 (comment)
Homebrew/homebrew-cask-fonts#6758 (comment)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant