Browse Source

Merge commit '93362e2' into axis-reg-pull-v0410

Viviana Monsalve 8 months ago
parent
commit
7070b69111

+ 35 - 10
axisregistry/.github/workflows/publish-release.yml

@@ -7,9 +7,8 @@ name: Create and Publish Release
 
 jobs:
   build:
-    name: Create and Publish Release
+    name: Build distribution
     runs-on: ubuntu-latest
-
     steps:
       - uses: actions/checkout@v2
         with:
@@ -23,7 +22,8 @@ jobs:
       - name: Install release dependencies
         run: |
           python -m pip install --upgrade pip
-          pip install --upgrade setuptools wheel twine
+          pip install --upgrade setuptools wheel build
+
       - name: Get release notes
         id: release_notes
         run: |
@@ -34,6 +34,7 @@ jobs:
           git fetch --tags --force
           TAG_NAME=${GITHUB_REF/refs\/tags\//}
           echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md"
+
       - name: Create GitHub release
         id: create_release
         uses: actions/create-release@v1
@@ -46,10 +47,34 @@ jobs:
           draft: false
           prerelease: false
 
-      - name: Build and publish to PyPI
-        env:
-          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
-          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
-        run: |
-          python setup.py sdist bdist_wheel
-          twine upload dist/axisregistry*
+      - name: Build a binary wheel and a source tarball
+        run: python3 -m build
+      - name: Store the distribution packages
+        uses: actions/upload-artifact@v3
+        with:
+          name: python-package-distributions
+          path: dist/
+
+  publish-to-pypi:
+    name: >-
+      Publish Python 🐍 distribution 📦 to PyPI
+    if: startsWith(github.ref, 'refs/tags/')  # only publish to PyPI on tag pushes
+    needs:
+      - build
+    runs-on: ubuntu-latest
+    environment:
+      name: pypi
+      url: https://pypi.org/p/axisregistry
+    permissions:
+      id-token: write  # IMPORTANT: mandatory for trusted publishing
+    steps:
+      - name: Download all the dists
+        uses: actions/download-artifact@v3
+        with:
+          name: python-package-distributions
+          path: dist/
+      - name: Publish distribution 📦 to PyPI
+        uses: pypa/gh-action-pypi-publish@v1.8.11
+        with:
+          # repository-url: https://test.pypi.org/legacy/ # for testing purposes
+          verify-metadata: false # twine previously didn't verify metadata when uploading

+ 92 - 24
axisregistry/CHANGELOG.md

@@ -1,58 +1,126 @@
 Below are the most important changes from each release.
 
-## Upcoming release: 0.3.11 (2022-Dic-??)
-  - ...
+### 0.4.10 (2024-Jul-03)
 
+- Add Element Expansion [ELXP] axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/166
+- Add Size of Paint 1 [SZP1] axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/167
+- Add Size of Paint 2 [SZP2] axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/168
+- Add Horizontal Element Alignment [XELA] axis by @simoncozens in https://github.com/googlefonts/axisregistry/pull/158
+- Add Horizontal Position Paint 1 [XPN1] axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/169
+- Add Horizontal Position Paint 2 [XPN2] axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/170
+- Add Vertical Position of Paint 1 [YPN1] axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/171
+- Add Vertical Position of Paint 2 [YPN2] axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/172
+- YELA desc updated to match reviewed XELA by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/174
 
-## 0.3.10 (2022-Nov-24)
+
+### 0.4.9 (2024-Feb-26)
+
+- Allow less aggressive renames [#165](https://github.com/googlefonts/axisregistry/pull/165)
+
+### 0.4.8 (2024-Feb-05)
+
+- repull and push
+
+### 0.4.7 (2024-Feb-05)
+
+- publish-release: update to trusted publishers workflow [#164](https://github.com/googlefonts/axisregistry/pull/164)
+
+### 0.4.6 (2024-Feb-05)
+
+- _fvar_dflts: move priority of opsz axis [#162](https://github.com/googlefonts/axisregistry/pull/162)
+
+### 0.4.5 (2023-Nov-17)
+
+- Create shadow.textproto by @yanone in https://github.com/googlefonts/axisregistry/pull/150
+- Adding [SCAN] Scanlines custom Axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/145
+- Adding [BLED] Bleed custom Axis by @vv-monsalve in https://github.com/googlefonts/axisregistry/pull/144
+- Don't fail if there are no axis values by @simoncozens in https://github.com/googlefonts/axisregistry/pull/155
+- @yanone made their first contribution in https://github.com/googlefonts/axisregistry/pull/150
+
+### 0.4.4 (2023-Oct-25)
+
+- Adding [ZROT] Rotation in Z custom axis by @vv-monsalve in #137
+- Update z_rotation.textproto with fallback_only field by @chrissimpkins in #140
+- Add test for proto wellformedness (no missing required fields) by @simoncozens in #143
+- Update requirements.txt by @felipesanches in #146
+- Adding [ARRR] AR Retinal Resolution custom Axis by @vv-monsalve in #141
+- If we delete a name STAT was using, put it back by @simoncozens in #154
+
+### 0.4.3 (2023-Jun-22)
+  - Adding [SHRP] Sharpness custom Axis by @vv-monsalve in #121
+  - Delete MUTA axis by @vv-monsalve in #124
+  - Adding [YALN] Y Alignment custom Axis by @vv-monsalve in #125
+
+### 0.4.2 (2023-Apr-14)
+  - update name builders #133
+
+### 0.4.1 (2023-Apr-13)
+  - build_name_table: set bits as well #131
+
+### 0.4.0 (2023-Mar-24)
+  - #120 MORPH axis added
+  - #119 VOLM axis updated
+  - #118 XROT YROT updated
+  - #115 FLAR axis updated
+  - #97 OPSZ range increase
+
+### 0.3.11 (2023-Jan-11)
+  - Update x_rotation.textproto 05a0728
+  - Update y_rotation.textproto 944a3e7
+  - Add Spacing [SPAC] axis #62
+  - Add Informality [INFM] axis #90
+  - Add Bounce [BNCE] axis #63
+  - tests/data/RobotoFlex-ttf Correct Optical Size title case 2d86d4c
+  - Add Mutation [MUTA] axis #100
+  - Update width.textproto #105
+  - Update wonky.textproto #107
+  - Also protect STAT table name IDs from the axis list #108
+  - Fix ci #110
+
+### 0.3.10 (2022-Nov-24)
   - Better issue templates (PR #94)
   - build_stat: improve elided axisvalues (PR #95)
 
-## 0.3.9 (2022-Oct-27)
+### 0.3.9 (2022-Oct-27)
   - loosen protobuf dependency on setup.py so that it is easier to install axisregistry as a dependency of other projects (such as fontbakery) (https://github.com/googlefonts/axisregistry/commit/bb213824f9b8a6215b9b78c28f59773e0bd93515)
   - #91 Added ROND axis
   - #55 Added YROT axis
   - #55 Added XROT axis
 
-
-## 0.3.8 (2022-Oct-10)
+### 0.3.8 (2022-Oct-10)
   - fix_stat do not drop nameids <= 25 (PR #88)
 
-
-## 0.3.7 (2022-Oct-10)
+### 0.3.7 (2022-Oct-10)
   - build_stat: do not rm fvar axis name records (PR #87)
 
-
-## 0.3.6 (2022-Oct-07)
+### 0.3.6 (2022-Oct-07)
   - Added YEAR axis (PR #53)
   - Added ELSH axis (PR #56)
   - Changed EGRD to ELGR (PR #57)
   - Added EHLT and EDPT (PR #61)
   - Added HEXP axis (PR #79)
 
-
-## 0.3.5 (2022-Jul-01)
+### 0.3.5 (2022-Jul-01)
   - Move nameid25 to its own func (PR #52)
 
-
-## 0.3.4 (2022-Jul-01)
+### 0.3.4 (2022-Jul-01)
   - Fix typo and ensure tox runs tests correctly (PR #50)
 
 
-## 0.3.3 (2022-Jul-01)
+### 0.3.3 (2022-Jul-01)
   - Don't delete name IDs which are shared with the STAT table (PR #49)
 
 
-## 0.3.2 (2022-Jun-27)
+### 0.3.2 (2022-Jun-27)
   - added _fvar_instance_collision function, which determines whether a family of fonts will have fvar instances which collide.	
   - build_vf_name_table: only use v1 name tables if fvar instances match (PR #48)
 
 
-## 0.3.1 (2022-Jun-24)
+### 0.3.1 (2022-Jun-24)
   - AxisRegistry: add items method. Fixed googlefonts/gftools#576 (PR #47)
 
 
-## 0.3.0 (2022-Jun-23)
+### 0.3.0 (2022-Jun-23)
   - Add name builder (PR #31)
   - Add illustrations (PRs #29, #30, #32 and #35)
   - Reduce length of parametric axis descriptions (PR #34)
@@ -60,19 +128,19 @@ Below are the most important changes from each release.
   - tox: use black (PR #39)
 
 
-## 0.2.0 (2022-Mar-14)
+### 0.2.0 (2022-Mar-14)
   - Remove pre-processing of fallback names and simplify API
 
 
-## 0.1.1 (2022-Mar-14)
+### 0.1.1 (2022-Mar-14)
   - Fix typos on cursive and monospace axes descriptions.
   - Remove space characteres from fallback name entries of all axes. (issue #7)
-  - Update `min_value` and `default_value` on **y_transparent_uppercase**.
+  - Update `min_value` and `default_value` on --y_transparent_uppercase--.
 
 
-## 0.1.0 (2022-Mar-04)
-### Release notes
+### 0.1.0 (2022-Mar-04)
+#### Release notes
   - Initial release of the `axisregistry` python module.
   - Most of the code & data was migrated from the [`fontbakery`](https://github.com/googlefonts/fontbakery/) and [`google/fonts`](https://github.com/google/fonts/) git repositories so that the GF Axis Registry data can be easily available to all our tools. The most immediate user of this module is `Font Bakery` itself, as well as `GFTools`.
-  - Axis Registry definitions are still being gradualy updated on the `google/fonts` repo, on its **axisregistry/** directory (https://github.com/google/fonts/tree/main/axisregistry) and this `axisregistry` python module will try to be kept in sync.
+  - Axis Registry definitions are still being gradualy updated on the `google/fonts` repo, on its --axisregistry/-- directory (https://github.com/google/fonts/tree/main/axisregistry) and this `axisregistry` python module will try to be kept in sync.
   - There's an ongoing plan to make this module the main place to update these definitions, avoiding data duplication and guaranteeing uniformity across tools.

+ 43 - 30
axisregistry/Lib/axisregistry/__init__.py

@@ -150,14 +150,14 @@ def _fvar_dflts(ttFont):
     res = OrderedDict()
     for a in ttFont["fvar"].axes:
         fallback = axis_registry.fallback_for_value(a.axisTag, a.defaultValue)
-        if fallback:
+        if a.axisTag == "opsz":
+            name = f"{int(a.defaultValue)}pt"
+            elided = True
+        elif fallback:
             name = fallback.name
             elided = fallback.value == axis_registry[
                 a.axisTag
             ].default_value and name not in ["Regular", "Italic", "14pt"]
-        elif a.axisTag == "opsz":
-            name = f"{int(a.defaultValue)}pt"
-            elided = False
         else:
             name = None
             elided = True  # since we can't find a name for it, keep it elided
@@ -213,9 +213,11 @@ def build_stat(ttFont, sibling_ttFonts=[]):
                     "name": fallback.name,
                     "value": fallback.value,
                     # include flags and linked values
-                    "flags": 0x2
-                    if fallback.value == axis_registry[axis].default_value
-                    else 0x0,
+                    "flags": (
+                        0x2
+                        if fallback.value == axis_registry[axis].default_value
+                        else 0x0
+                    ),
                 }
             )
             if axis in LINKED_VALUES and fallback.value in LINKED_VALUES[axis]:
@@ -255,7 +257,9 @@ def build_stat(ttFont, sibling_ttFonts=[]):
     buildStatTable(ttFont, res, macNames=False)
 
 
-def build_name_table(ttFont, family_name=None, style_name=None, siblings=[]):
+def build_name_table(
+    ttFont, family_name=None, style_name=None, siblings=[], aggressive=True
+):
     from fontTools.varLib.instancer import setRibbiBits
 
     log.info("Building name table")
@@ -263,9 +267,13 @@ def build_name_table(ttFont, family_name=None, style_name=None, siblings=[]):
     family_name = family_name if family_name else name_table.getBestFamilyName()
     style_name = style_name if style_name else name_table.getBestSubFamilyName()
     if is_variable(ttFont):
-        build_vf_name_table(ttFont, family_name, siblings=siblings)
+        build_vf_name_table(
+            ttFont, family_name, siblings=siblings, aggressive=aggressive
+        )
     else:
-        build_static_name_table_v1(ttFont, family_name, style_name)
+        build_static_name_table_v1(
+            ttFont, family_name, style_name, aggressive=aggressive
+        )
 
     # Set bits
     style_name = name_table.getBestSubFamilyName()
@@ -297,14 +305,16 @@ def _fvar_instance_collisions(ttFont, siblings=[]):
     return len(family_styles) != len(set(family_styles))
 
 
-def build_vf_name_table(ttFont, family_name, siblings=[]):
+def build_vf_name_table(ttFont, family_name, siblings=[], aggressive=True):
     # VF name table should reflect the 0 origin of the font!
     assert is_variable(ttFont), "Not a VF!"
     style_name = _vf_style_name(ttFont, family_name)
     if _fvar_instance_collisions(ttFont, siblings):
-        build_static_name_table_v1(ttFont, family_name, style_name)
+        build_static_name_table_v1(
+            ttFont, family_name, style_name, aggressive=aggressive
+        )
     else:
-        build_static_name_table(ttFont, family_name, style_name)
+        build_static_name_table(ttFont, family_name, style_name, aggressive=aggressive)
     build_variations_ps_name(ttFont, family_name)
 
 
@@ -432,7 +442,7 @@ def build_fvar_instances(ttFont, axis_dflts={}):
     fvar.instances = instances
 
 
-def build_static_name_table(ttFont, family_name, style_name):
+def build_static_name_table(ttFont, family_name, style_name, aggressive=True):
     # stip mac names
     name_table = ttFont["name"]
     name_table.removeNames(platformID=1)
@@ -504,23 +514,26 @@ def build_static_name_table(ttFont, family_name, style_name):
         name_table.setName(v, *k)
 
     # Replace occurences of old family name in untouched records
-    skip_ids = [i.numerator for i in NameID]
-    for r in ttFont["name"].names:
-        if r.nameID in skip_ids:
-            continue
-        current = r.toUnicode()
-        if existing_name not in current:
-            continue
-        if " " not in current:
-            replacement = current.replace(existing_name, family_name).replace(" ", "")
-        else:
-            replacement = current.replace(existing_name, family_name)
-        ttFont["name"].setName(
-            replacement, r.nameID, r.platformID, r.platEncID, r.langID
-        )
+    if aggressive:
+        skip_ids = [i.numerator for i in NameID]
+        for r in ttFont["name"].names:
+            if r.nameID in skip_ids:
+                continue
+            current = r.toUnicode()
+            if existing_name not in current:
+                continue
+            if " " not in current:
+                replacement = current.replace(existing_name, family_name).replace(
+                    " ", ""
+                )
+            else:
+                replacement = current.replace(existing_name, family_name)
+            ttFont["name"].setName(
+                replacement, r.nameID, r.platformID, r.platEncID, r.langID
+            )
 
 
-def build_static_name_table_v1(ttFont, family_name, style_name):
+def build_static_name_table_v1(ttFont, family_name, style_name, aggressive=True):
     """Pre VF name tables, this version can only accept wght + ital"""
     non_weight_tokens = []
     v1_tokens = []
@@ -545,7 +558,7 @@ def build_static_name_table_v1(ttFont, family_name, style_name):
     style_name = style_name or "Regular"
     log.debug(f"New family name: {family_name}")
     log.debug(f"New style name: {style_name}")
-    build_static_name_table(ttFont, family_name, style_name)
+    build_static_name_table(ttFont, family_name, style_name, aggressive)
 
 
 def build_filename(ttFont):

+ 14 - 0
axisregistry/Lib/axisregistry/data/element_expansion.textproto

@@ -0,0 +1,14 @@
+#Element Expansion, based on https://github.com/petrvanblokland/TYPETR-Bitcount
+tag: "ELXP"
+display_name: "Element Expansion"
+min_value: 0
+default_value: 0
+max_value: 100
+precision: 0
+fallback {
+  name: "Default"
+  value: 0
+}
+fallback_only: false
+description: 
+  "As the Element Expansion axis progresses, the elements move apart."

+ 17 - 0
axisregistry/Lib/axisregistry/data/size_paint_1.textproto

@@ -0,0 +1,17 @@
+#Size of Paint 1, based on https://github.com/petrvanblokland/TYPETR-Bitcount
+tag: "SZP1"
+display_name: "Size of Paint 1"
+min_value: -100
+default_value: 0
+max_value: 100
+precision: 0
+fallback {
+  name: "Default"
+  value: 0
+}
+fallback_only: false
+description: 
+  "Modifies the size of a paint element going from an initial size (0)"
+  " to positive values that increase the size (100%)"
+  " or negative values that shrink it down (-100%)."
+  " Reducing the size can create transparency."

+ 18 - 0
axisregistry/Lib/axisregistry/data/size_paint_2.textproto

@@ -0,0 +1,18 @@
+#Size of Paint 2, based on https://github.com/petrvanblokland/TYPETR-Bitcount
+tag: "SZP2"
+display_name: "Size of Paint 2"
+min_value: -100
+default_value: 0
+max_value: 100
+precision: 0
+fallback {
+  name: "Default"
+  value: 0
+}
+fallback_only: false
+description: 
+  "Modifies the size of a paint element going from an initial size (0)"
+  " to positive values that increase the size (100%)"
+  " or negative values that shrink it down (-100%)."
+  " Reducing the size can create transparency."
+  " Paint 2 is in front of Paint 1."

+ 16 - 0
axisregistry/Lib/axisregistry/data/x_element_alignment.textproto

@@ -0,0 +1,16 @@
+#XELA based on [SixtyFour](https://github.com/jenskutilek/homecomputer-fonts/Sixtyfour)
+tag: "XELA"
+display_name: "Horizontal Element Alignment"
+min_value: -100.0
+default_value: -1
+max_value: 100.0
+precision: 0
+fallback {
+  name: "Default"
+  value: 0
+}
+fallback_only: false
+description:
+  "Align glyph elements from their default position (0%),"
+  " usually the baseline, to a rightmost (100%)"
+  " or leftmost (-100%) position."

+ 16 - 0
axisregistry/Lib/axisregistry/data/x_position_paint_1.textproto

@@ -0,0 +1,16 @@
+#Horizontal Position of Paint 1, based on https://github.com/petrvanblokland/TYPETR-Bitcount
+tag: "XPN1"
+display_name: "Horizontal Position of Paint 1"
+min_value: -100
+default_value: 0
+max_value: 100
+precision: 0
+fallback {
+  name: "Default"
+  value: 0.0
+}
+fallback_only: false
+description: 
+  "The position of the paint moves left and right. Negative values"
+  " move to the left and positive values move to the right, in the X dimension."
+  " Paint 1 is behind Paint 2."

+ 16 - 0
axisregistry/Lib/axisregistry/data/x_position_paint_2.textproto

@@ -0,0 +1,16 @@
+#Horizontal Position of Paint 2, based on https://github.com/petrvanblokland/TYPETR-Bitcount
+tag: "XPN2"
+display_name: "Horizontal Position of Paint 2"
+min_value: -100
+default_value: 0
+max_value: 100
+precision: 0
+fallback {
+  name: "Default"
+  value: 0.0
+}
+fallback_only: false
+description: 
+  "The position of the paint moves left and right. Negative values"
+  " move to the left and positive values move to the right, in the X dimension."
+  " Paint 2 is in front of Paint 1."

+ 1 - 1
axisregistry/Lib/axisregistry/data/y_element_alignment.textproto

@@ -11,6 +11,6 @@ fallback {
 }
 fallback_only: false
 description:
-  "Align glyphs from their default position (0%),"
+  "Align glyphs elements from their default position (0%),"
   " usually the baseline, to an upper (100%)"
   " or lower (-100%) position."

Some files were not shown because too many files changed in this diff