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

Multiple fonts support #58

Merged
merged 11 commits into from
Sep 11, 2020
Merged

Multiple fonts support #58

merged 11 commits into from
Sep 11, 2020

Conversation

RoelN
Copy link
Collaborator

@RoelN RoelN commented Sep 9, 2020

@RoelN RoelN requested a review from pascalw September 9, 2020 11:49
@RoelN RoelN added the WIP Work in progress label Sep 9, 2020
@RoelN RoelN mentioned this pull request Sep 9, 2020
4 tasks
So 11ty can work with 'em!
TODO:
- Apply proper class so the correct font is used
- Loop over the other specimen components (grid
  and interactive controls)
_tools/generateFontData.js Show resolved Hide resolved
const fontFiles = process.argv[2] || (await findFontFile(fontsDirectory));

// Initialise files
writeFile(
Copy link
Contributor

Choose a reason for hiding this comment

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

These writeFile calls are not awaited now. I think the writes should be awaited, to prevent race conditions with other writes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call, will do.


const assert = (condition, message) => {
if (!condition) {
throw new Error(message);
}
};

const _appendFile = util.promisify(fs.appendFile);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of mutating things. I'd rather build up the whole result and write it at once, instead of appending things. Many things can go wrong with appending, you need to handle order etc. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm. I'll see if I can refactor this.

@@ -14,7 +14,7 @@ <h2>Axes & Instances</h2>
class="interactive-controls-slider"
/>
</li>
{% for axis in axes %}
{% for axis in font[1].axes %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this loop over all fonts? And why [1] and not [0]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the way 11ty returns data in _data: [0] contains the directory name, and [1] contains the actual data for each file. (In this case, axes.json). The looping happens here (prettier smashes this into one line, not happy about that, but hopefully you can parse it ;-))

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah clear!

The directory names for the generated data in ./_data is based
on the classname. This in turn is based on a "slugified" name of
the font.

Maybe upon generating new _data, we should empty the dir? I got
confused a couple of times by old font _data files lingering.
Grids are generated for all fonts, sliders only for variable
fonts.
@RoelN RoelN mentioned this pull request Sep 11, 2020
@RoelN
Copy link
Collaborator Author

RoelN commented Sep 11, 2020

Decided to keep the refactoring for a later time, so we can move ahead now. Issue here: #59

@RoelN
Copy link
Collaborator Author

RoelN commented Sep 11, 2020

@pascalw Thanks for the review & suggestions!

@RoelN RoelN merged commit cea98fc into master Sep 11, 2020
@RoelN RoelN deleted the multiple-fonts branch September 11, 2020 09:00
@RoelN RoelN restored the multiple-fonts branch September 11, 2020 09:00
@RoelN RoelN deleted the multiple-fonts branch September 11, 2020 09:00
@RoelN RoelN removed the WIP Work in progress label Sep 11, 2020
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.

2 participants