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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NinjaBuilder doesn't create instance TTFs, only makes (unwanted) instance UFOs #849

Open
RickyDaMa opened this issue Mar 12, 2024 · 7 comments

Comments

@RickyDaMa
Copy link
Contributor

Example config:

buildOTF: false
buildStatic: true
buildWebfont: false
familyName: Comic Sans
instances:
  Comic Sans[GRAD,ROND,opsz,slnt,wdth,wght].ttf:
  - coordinates:
      ROND: 0
      opsz: 144
      wdth: 100
      wght: 100.0
    familyName: Comic Sans
    styleName: Thin
removeOutlineOverlaps: false
reverseOutlineDirection: false
sources:
  - Comic Sans.designspace
stat:
  # -- snip --

With GFBuilder, this works as I expect:

  1. The VF is compiled
  2. The static instances defined in the designspace and in the config.yaml are built

With the NinjaBuilder, the following happens:

  1. The VF is compiled
  2. Instance UFOs are generated and put into the sources/instance_ufos directory (unwanted)

No errors in either case, but very different behaviour


I had a look why the NinjaBuilder wasn't producing static TTFs in the debugger and think I found why:

def build_static(self):
# Let's make our interpolated UFOs.
self.w.newline()
self.w.comment("STATIC FONTS")
self.w.newline()
for (path, designspace) in self.designspaces:
self.w.comment(f" Interpolate UFOs for {os.path.basename(path)}")
instances = self._instance_ufo_filenames(path, designspace)
if not instances:
continue
self.w.build(
[str(i) for i in instances],
"instanceufo",
path,
)
self.w.newline()
return GFBuilder.build_static(self)

Here we can see that NinjaBuilder.build_static unconditionally generates instance UFOs, and then delegates to GFBuilder.build_static, but overriding self as the NinjaBuilder

def build_static(self):
if self.config["buildOTF"]:
self.build_a_static_format("otf", self.config["otDir"], self.post_process_static_otf)
if self.config["buildTTF"]:
if "instances" in self.config:
self.instantiate_static_fonts(
self.config["ttDir"], self.post_process_static_ttf
)

GFBuilder then delegates to self.instantiate_static_fonts, but self in this context is NinjaBuilder, which...

def instantiate_static_fonts(self, directory, postprocessor):
pass

Ah. Perhaps this was intended to be GFBuilder.instantiate_static_fonts, instead of NinjaBuilder's stub?

This would be easy to workaround if there was a way to manually override the builder being used, but as far as I know there isn't, meaning I either have to change operating system or the source code to avoid the NinjaBuilder for now

@m4rc1e
Copy link
Collaborator

m4rc1e commented Mar 12, 2024

@RickyDaMa Could you try out #726 please? we're hoping to merge it this week.

@RickyDaMa
Copy link
Contributor Author

Okay, looking at the builder2 branch:

'instances' no longer supported; generate a config with --generate and select the instances you want

So now I can't specify my own instances?

The workflow of creating a config, then doing gftools builder --generate sources/myconfig.yaml > sources/myconfig2.yaml is a bit weird. I'm guessing this has given me the designspace instances, which unfortunately as #850 alludes to, I don't want, and nor do I see a way to specify custom instances if I want to

Is there still a way with builder 2 to specify custom instances?

@m4rc1e
Copy link
Collaborator

m4rc1e commented Mar 12, 2024

Actually good point. Imo we should support all the features we had in the original builder.

@simoncozens
Copy link
Contributor

We should support the options from the original builder but I'm unconvinced about the use case of declaring certain instances in the font sources and asking the builder to generate completely different ones. Why is this a good idea?

@Hoolean
Copy link
Contributor

Hoolean commented Mar 12, 2024

In this case, we have a wide designspace for which we want to build more static instances than we have named instances for in the variable font.

(in particular, we are happy to have a less crowded set of instances in the variable font as the user can reach other areas with sliders manually, but for the statics this is not an option, and so we need to build more for a wider reach)

As instances are shared for VFs and statics in a designspace, we can only store one set in a single source. There are workarounds we could deploy here (e.g. dynamically generating a second designspace) but we were interested to see if we could do it with only the gftools builder first :)

@simoncozens
Copy link
Contributor

OK, I'm on it...

@RickyDaMa
Copy link
Contributor Author

Thanks Simon, sorry for the hassle! There's no urgency here as we're going to re-use a handrolled approach we know works while we wait for builder2 to stabilise (before hopefully migrating to it)

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

No branches or pull requests

4 participants