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

[FEATURE] Nunito Default Font #2471

Merged
merged 8 commits into from
Oct 21, 2024
Merged

[FEATURE] Nunito Default Font #2471

merged 8 commits into from
Oct 21, 2024

Conversation

FaithDaka
Copy link
Collaborator

@FaithDaka FaithDaka commented Oct 14, 2024

PR Checklist

  • PR title descriptive (can be used in release notes)

Description

Refactors the default font from Roboto to Nunito, with the font files added to 'assets/fonts'. Also includes colour changes to the plh_kids_kw theme

Git Issues

Closes #2470

Screenshots/Videos

@FaithDaka FaithDaka added the feature Work on app features/modules label Oct 14, 2024
@FaithDaka FaithDaka added this to the ParentApp Kids KW Dec 2024 milestone Oct 14, 2024
@FaithDaka FaithDaka self-assigned this Oct 14, 2024
Copy link
Collaborator

@jfmcquade jfmcquade left a comment

Choose a reason for hiding this comment

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

See inline comment – I'd like to keep these changes scoped to the plh_kids_kw deployment for now

@@ -3,6 +3,17 @@
--ion-font-family: "Roboto", "Helvetica Neue", sans-serif;
}

// Override roboto font
:root {
--ion-font-family: "Nunito", sans-serif;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit (blocking): It would be good to move this (and the @font-face declaration below) to the plh_kids_kw theme file. Whilst we may well want to incorporate these changes into the default styles, if we keep them scoped to the plh_kids_kw theme for now then we avoid making changes to our existing production apps, and we can decide if/when to roll out the changes independently.

Ideally, it would be good to be able to expose a new variable for $font-name (alongside $color-primary, $color-secondary and $page-background that already exist at the top of the theme files), and infer all the necessary changes from that. However I think that could be tricky as we'd need to account for different font types (we already have .ttf and .woff2 to handle).

So I think for now it might make sense to do the following:

  1. Move the whole @font-face declaration block as it is into the theme file (i.e. under line 10 of src/theme/themes/plh_kids_kw.scss)
  2. Move this variable assignment to the theme file
    • Adding ion-font-family: "Nunito", sans-serif, to the list of $variable-overrides should work I think – the -- gets added automatically

Let me know if that doesn't make sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jfmcquade The scoping of changes does make sense. Given that the font change was required globally, it made sense for me to have that in the variables file but I do understand how that makes deployment somewhat complicated.
I'll work on keeping changes within the theme file.

@chrismclarke
Copy link
Member

Just to quickly add, given all apps run within a (reasonably) modern version of webkit/chrome to run I think we should be able to reliably use woff2 versions of fonts instead of ttf - you'll see that's the format roboto fonts use.

Woff files tend to be a lot smaller (~10x for nunito), so would be good to use so that overall we only add a couple hundred kb to the project instead of the current 2-3MB included in this PR
https://getsnapfont.com/posts/understanding-font-file-formats-ttf-otf-woff-etc

Annoyingly google fonts don't offer woff2 files directly, but you can find most fonts at:
https://gwfh.mranftl.com/fonts/nunito?subsets=latin

Alternatively you can convert using:
https://www.fontsquirrel.com/tools/webfont-generator

I would also recommend matching the current font-weights (400 standard, 700 bold), with italic variant on 400 also. I can't see any other font variants defined in the _typography.scss but possibly @jfmcquade can confirm whether any other variants expected.

@FaithDaka
Copy link
Collaborator Author

@chrismclarke Yeah I did download the Nunito font files from the Google library which was the .tff format. I'll switch to .woff, thanks.
And the weight variants were defined in that Nunito wght tff file so that they get specified using the font-weight CSS attribute but I can define them if that abstracts the font weight.

@FaithDaka
Copy link
Collaborator Author

FaithDaka commented Oct 16, 2024

For review @jfmcquade. Style changes kept to theme file

Default Theme: Roboto Font

Kuwait Theme: Nunito Font

Copy link
Member

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

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

Thanks for making the updates @FaithDaka

Yeah google fonts changed a while back to start using variable fonts, which can give a lot more flexibility to customise fonts, but result in much larger font files. These work well if serving the font from a cdn and only downloading on demand the exact styles needed (and also nice to install on your computer and use locally), but not very well suited for serving offline.

Given that any fonts needed in the app will have to be bundled into the build, using woff2 files just for the specific weights we're likely to need is the best option - I can see each of the ones you included are only around 15kb compared to 160kb for the previous ttfs

Copy link
Collaborator

@jfmcquade jfmcquade left a comment

Choose a reason for hiding this comment

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

Hi, apologies for the delay in reviewing, but this looks good to me, I will approve and merge

@FaithDaka FaithDaka merged commit a3b1e5f into master Oct 21, 2024
6 checks passed
@FaithDaka FaithDaka deleted the style/english-font branch October 21, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Work on app features/modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] New Typeface for English version
3 participants