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

Could "code ligatures" be split into a different unicode-range, for font-serving CSS? #2103

Closed
thundernixon opened this issue Aug 5, 2019 · 4 comments

Comments

@thundernixon
Copy link
Collaborator

thundernixon commented Aug 5, 2019

In Fira Code's font-face CSS from Google Fonts, unicode ranges are split to allow progressive downloads of basic Latin, then Extended Latin, then Greek, and so on.

Fira Code font-face CSS from Google Fonts (Click to expand)
/* cyrillic-ext */
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/firacode/v3/uU9eCBsR6Z2vfE9aq3bL0fxyUs4tcw4W_D1sJV37MOzlojwUKaJO.woff) format('woff');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/firacode/v3/uU9eCBsR6Z2vfE9aq3bL0fxyUs4tcw4W_D1sJVT7MOzlojwUKaJO.woff) format('woff');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/firacode/v3/uU9eCBsR6Z2vfE9aq3bL0fxyUs4tcw4W_D1sJVz7MOzlojwUKaJO.woff) format('woff');
  unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/firacode/v3/uU9eCBsR6Z2vfE9aq3bL0fxyUs4tcw4W_D1sJVP7MOzlojwUKaJO.woff) format('woff');
  unicode-range: U+0370-03FF;
}
/* latin-ext */
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/firacode/v3/uU9eCBsR6Z2vfE9aq3bL0fxyUs4tcw4W_D1sJV77MOzlojwUKaJO.woff) format('woff');
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/firacode/v3/uU9eCBsR6Z2vfE9aq3bL0fxyUs4tcw4W_D1sJVD7MOzlojwUKQ.woff) format('woff');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

Based on opening a download of the basic latin font in GlyphsApp, it appears that code ligatures are included in the basic latin range. This doesn't seem ideal for the fastest possible downloads – particularly if code ligatures were to be included in a more complex variable font (which is something I am working towards currently).

What might be an appropriate way to subset/split out these ligatures from the first load to improve overall download speed?

image

(That image may make it look like the code ligatures don't have the correct spacing, but based on a CodePen test, they seem to be working as expected.)

https://codepen.io/thundernixon/pen/OKzVvd

@khaledhosny
Copy link
Contributor

CSS unicode-range is for characters, these are glyphs.

@thundernixon
Copy link
Collaborator Author

thundernixon commented Aug 9, 2019

Hmm, shoot. So, is the currently no way to progressively load non-unicode characters glyphs such as ligatures?

@khaledhosny
Copy link
Contributor

No, not currently.

@rsheeter
Copy link
Collaborator

rsheeter commented Oct 2, 2019

IIUC this is working as intended. Glyphs that are reachable using the characters in the subset, including by ligature, should be retained.

@rsheeter rsheeter closed this as completed Oct 2, 2019
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

3 participants