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

Update font tooling to support semi-bold font weight #11976

Conversation

rtibbles
Copy link
Member

@rtibbles rtibbles commented Mar 9, 2024

Summary

  • Updates fontTools library to the latest version, and enforce Python version at a module level in the Python aspects of the i18n module
  • Updates our font tooling to use the new repository https://github.com/notofonts/notofonts.github.io as the old one has been archived
  • Updates our font tooling to either download SemiBold weights, or in the case where they are unavailable, use variable versions to generate the missing font weight (or weights).
  • Note that this means that some of our fonts will be unhinted, whereas until now all our fonts are hinted.
  • Preference is given to downloading the slimline version of the variable fonts (as we do not need variation in font width) but it falls back to the full variable font if not available.
  • Adds the ability to exclude specific typefaces that would otherwise be bundled based on our 'weights are available' criteria - does so with the NotoSansTest font which is not needed and is only for testing.
  • Excludes fonts that are only used for ancient texts, or have incredibly limited usage.
  • Adds some specific exclusions for fonts used during font subsetting - these fonts seemed to cause errors during font subsetting that I could not resolve, and as they are not used in UI text, it seemed simplest to exclude them from the subsetting code.

Reviewer guidance

In the future we may want to be explicit about which typefaces we want to include in the font subsetting code - although, with the dropping of IE11 support in the future, it's possible we can stop doing the subsetting altogether.

Opening this as a draft for now, to make sure that everything builds, check the size of the built WHL file, and also open it up for QA testing to make sure fonts are still behaving as expected.


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

rtibbles added 3 commits March 9, 2024 15:08
Enforce Python 3.8 for font tooling.
Add flexibility to use variable fonts to fill in missing font weights.
@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... DEV: tools Internal tooling for development SIZE: very large labels Mar 9, 2024
@rtibbles rtibbles force-pushed the to_semi_boldly_go_where_no_one_has_semi_gone_before branch from 2c2cdf8 to ae19b87 Compare March 10, 2024 05:55
@rtibbles rtibbles marked this pull request as ready for review March 10, 2024 23:02
@radinamatic
Copy link
Member

Tested the DEB asset in Firefox and Chrome on Ubuntu 20.04, and checked the loading of all 32 locales in Kolibri. No issues noticed neither in the UI font display, nor in the network tab and console regarding the subsets loading.

This newest DEB is 81.7 MB compared to 75.3 MB of 0.16.0 release.

2024-03-11_10-08-42

@pcenov can you please test the EXE and DMG assets? Thank you!

@pcenov
Copy link
Member

pcenov commented Mar 11, 2024

Hi @radinamatic no fonts related issues observed while testing with the .deb and .exe builds as well.

Copy link
Member

@radinamatic radinamatic left a comment

Choose a reason for hiding this comment

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

Manual QA passes, should be good to go after the code review! 🙂

Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

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

I think I got a good grasp of what was going on in the code and the changes made sense and made for a clean grokkable read.

Just left a non-blocking question

Comment on lines 33 to 40
except ImportError:
utils.install_requirement(f"fonttools=={font_tools_version}")
except AssertionError:
utils.install_requirement(f"fonttools=={font_tools_version}")
logging.error(
"Wrong fontTools version was installed. This has been updated. Please re-run the command."
)
sys.exit(1)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we notify that we've updated fontTools on one type of error but not the other?

Copy link
Member Author

Choose a reason for hiding this comment

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

The assertion error only happens in the case that fontTools was already installed. Unfortunately, because we already imported it, we have to exit Python before we can import the updated version (although, now I think about it, it might be possible to clear the module cache - but generally safer to quit). When the import didn't even succeed, we can reimport again.

@marcellamaki marcellamaki self-requested a review March 12, 2024 21:54
Copy link
Member

@marcellamaki marcellamaki left a comment

Choose a reason for hiding this comment

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

Blocking merge into 0.16.x until we are ready for all branding to be merged

@marcellamaki marcellamaki dismissed their stale review April 25, 2024 14:55

Ready to merge!

@marcellamaki marcellamaki merged commit e7edd02 into learningequality:release-v0.16.x Apr 25, 2024
34 checks passed
@rtibbles rtibbles deleted the to_semi_boldly_go_where_no_one_has_semi_gone_before branch August 9, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... DEV: tools Internal tooling for development SIZE: very large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants