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

Compile simple VFs w/gvar that works in a browser #236

Merged
merged 6 commits into from
Apr 11, 2023
Merged

Compile simple VFs w/gvar that works in a browser #236

merged 6 commits into from
Apr 11, 2023

Conversation

rsheeter
Copy link
Contributor

@rsheeter rsheeter commented Apr 4, 2023

Builds on #230, #239. Fixes #207. Fixes #95.

Update fontations to pickup gvar fixes and thereby fixes #245.

cargo run -p fontc -- --source resources/testdata/mov_xy.designspace now produces a VF that works in a browser.

I have punted some feedback to issues as I believe just compiling any vf that works is worth capturing, specifically:

  1. Better phantom points for gvar #240
  2. Make sure our inputs are healthy before computing deltas #241

Sufficient to compile an at least somewhat functional Oswald:

$ git clone https://github.com/googlefonts/OswaldFont
$ cd fontmake-rs
$ cargo run -p fontc -- --source ../OswaldFont/sources/Oswald.glyphs

In browser:

image

@rsheeter rsheeter force-pushed the gvar2 branch 3 times, most recently from 5c15f95 to 335c8be Compare April 4, 2023 05:33
Base automatically changed from gvar1 to main April 4, 2023 20:10
@rsheeter rsheeter mentioned this pull request Apr 4, 2023
fontc/src/lib.rs Show resolved Hide resolved
fontbe/src/glyphs.rs Outdated Show resolved Hide resolved
fontbe/src/glyphs.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
fontbe/src/glyphs.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
Base automatically changed from glyph-path-builder-close-path to main April 6, 2023 15:34
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
@rsheeter
Copy link
Contributor Author

rsheeter commented Apr 7, 2023

cargo run -p fontc -- --source resources/testdata/mov_xy.designspace produces a VF the browser renders.

@rsheeter rsheeter changed the title [WIP] Compute deltas and feed to gvar gvar step 1: compute deltas and produce a gvar table Apr 7, 2023
@rsheeter rsheeter marked this pull request as ready for review April 7, 2023 22:33
@rsheeter rsheeter force-pushed the gvar2 branch 2 times, most recently from 22a3c9e to 76547d8 Compare April 7, 2023 22:43
@rsheeter rsheeter changed the base branch from main to movxy April 7, 2023 22:44
@rsheeter rsheeter changed the title gvar step 1: compute deltas and produce a gvar table Compile a simple VF w/gvar that works in a browser Apr 8, 2023
@rsheeter rsheeter changed the title Compile a simple VF w/gvar that works in a browser Compile simple VFs w/gvar that works in a browser Apr 8, 2023
@rsheeter rsheeter changed the base branch from movxy to main April 10, 2023 15:58
Somewhat dodgy, but still a significant step forward.
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick run-through for me, but overall seems sane? Some notes inline, I imagine its worth getting cosimo's input here as well.

fontbe/src/glyphs.rs Show resolved Hide resolved
fontbe/src/glyphs.rs Outdated Show resolved Hide resolved
fontbe/src/gvar.rs Outdated Show resolved Hide resolved
@@ -17,6 +17,8 @@ pub enum Access<I> {
All,
/// Access to one specific resource is permitted
One(I),
/// Access to two specific resource is permitted
Two(I, I),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see where this is going

fontir/src/variations.rs Show resolved Hide resolved
fontir/src/variations.rs Outdated Show resolved Hide resolved
fontir/src/variations.rs Outdated Show resolved Hide resolved
@rsheeter
Copy link
Contributor Author

I imagine its worth getting cosimo's input here as well.

Cosimo is OOO so I will merge + send him an email to please review when back.

@@ -248,6 +252,10 @@ impl<T: Copy> Location<T> {
self
}

pub fn rm_pos(&mut self, axis: &str) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this rm_pos being used? Also, the name is a bit cryptic

@@ -41,32 +41,40 @@ pub struct StaticMetadata {
/// See <https://learn.microsoft.com/en-us/typography/opentype/spec/name>.
pub names: HashMap<NameKey, String>,

/// Every axis used by the font being compiled
/// Every axis used by the font being compiled, including point axes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using "discrete axes" as that's the name used in DesignSpace format

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, maybe is this about something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"an axis of variation defined only at a single point"... It's not immediately clear to me why we need to special case these

Copy link
Member

@anthrotype anthrotype Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you want to exclude these so-called "point axes" when constructing the VariationModel. In reality, these kind of setups (a variaiton axis where min=default=max) do not actually occur in real world font sources because they do not make sense to have, they would be no op. They may occur in your made-up test data (e.g. static.designspace) but I don't think it is worth having two different Vec<Axis> in the static metadata, one for axes in general and one for actually variable ones (which is 100% of them in an actually variable font project). You can filter on demand when needed, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW fontmake does not treat these point-axes specially; e.g. if you feed your static.designspace to fontmake-py and ask it to make a "variable" font, fontmake resources/testdata/static.designspace -o variable, it will make one with fvar containing that point axis, and all the other variation tables basically empty.
If you ask it to create static ttfs from the same designspace (-o ttf), it will make one for each of the masters (or one for each of the instances with additional -i option), and would be equivalent to running fontmake directly on the master UFO as input. I'm not saying we should replicate this UX in fontmake-rs, I think the latter should be designed to build variable fonts only.
Just saying that a font like our test static.designspace does not normally occur in the wild; if one wants to build a static font, one builds that one, doesn't create a dummy designspace to wrap it.

Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's nice to finally see variable glyphs render in browser, great work reaching this milestone.
A belated LGTM!

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.

Build a valid gvar for Texturina Emit gvar Implement BE work for a simple variable glyph
3 participants