Sophie

Sophie

distrib > Mageia > 8 > armv7hl > by-pkgid > 8ec28b8601f37b473a91f52684a28eba > files > 5

cascadia-code-fonts-2009.22-1.mga8.src.rpm

From ad49ee68744dd19af8a8ac7dbfa50ea1ada9f99b Mon Sep 17 00:00:00 2001
From: Aaron <aaronbell@users.noreply.github.com>
Date: Thu, 8 Oct 2020 11:05:10 -0700
Subject: [PATCH] Set the names of the static instances properly (#370)

As far as I can tell, what essentially happened here is that _instances_
in the designspace were not being renamed, even though the sources were
being renamed. As a result, the variable fonts would build correctly,
but the static instances were not. The font naming approach has now been
changed and is producing reliable results.

What's particularly vexing is that for the life of me I can't figure out
how the code actually worked before, because as far as I can tell, we've
_never_ modified the instance code before.

Fixes #369.

Co-authored-by: Aaron Bell <aaron@sajatypeworks.com>
---
 build.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/build.py b/build.py
index e437d2f0..b26ecb0f 100644
--- a/build.py
+++ b/build.py
@@ -38,11 +38,11 @@
 # ****************************************************************
 
 
-def step_set_font_name(name: str, instance: ufoLib2.Font) -> None:
-    instance.info.familyName = name
+def step_set_font_name(name: str, source: ufoLib2.Font) -> None:
+    source.info.familyName = source.info.familyName.replace("Cascadia Code", name)
     # We have to change the style map family name because that's what
     # Windows uses to map Bold/Regular/Medium/etc. fonts
-    instance.info.styleMapFamilyName = name
+    source.info.styleMapFamilyName = source.info.styleMapFamilyName.replace("Cascadia Code", name)
 
 
 def step_merge_glyphs_from_ufo(path: Path, instance: ufoLib2.Font) -> None:
@@ -121,6 +121,10 @@ def prepare_fonts(
         else:
             print("Variant name not identified. Please check.")
         set_font_metaData(source.font)
+    for instance in designspace.instances:
+        instance.name = instance.name.replace("Cascadia Code", name)
+        instance.familyName = instance.familyName.replace("Cascadia Code", name)
+        instance.styleMapFamilyName = instance.styleMapFamilyName.replace("Cascadia Code", name)
 
 
 def to_woff2(source_path: Path, target_path: Path) -> None:
@@ -152,8 +156,7 @@ def build_font_static(
     prepare_fonts(designspace, name)
     generator = fontmake.instantiator.Instantiator.from_designspace(designspace)
     instance = generator.generate_instance(instance_descriptor)
-    step_set_font_name(name, instance)
-    compile_static_and_save(instance)
+    compile_static_and_save(instance, name)
 
 
 # Export fonts
@@ -194,8 +197,8 @@ def compile_variable_and_save(
     print(f"[{familyName}] Done: {file_path}")
 
 
-def compile_static_and_save(instance: ufoLib2.Font) -> None:
-    family_name = instance.info.familyName
+def compile_static_and_save(instance: ufoLib2.Font, name:str) -> None:
+    family_name = name
     style_name = instance.info.styleName
     print(f"[{family_name}] Building static instance: {style_name}")