oddbird / accoutrement-type

Font helpers
MIT License
2 stars 1 forks source link

Support for unicode-range #7

Closed mabar closed 6 years ago

mabar commented 6 years ago

Fonts are often distributed in multiple files. eg. character š is on Google Fonts in separated file. unicode-range allows download font files only if contained characters are used in page.

https://fonts.googleapis.com/css?family=Barlow+Condensed:400,700

mirisuzanne commented 6 years ago

Great! What would that look like? How is it used, and what would we have to do in order to support it? Thanks!

mabar commented 6 years ago

Only change in that library should be addition of unicode-range to output and allow multiple fonts with same name. It's still the same font, just divided into multiple files.

$fonts: (
  'Barlow Condensed - Latin Extended': (
    'name': 'Barlow Condensed',
    'normal': 'barlow-condensed/normal-latin-extended',
    'unicode-range': U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF
  ),
  'Barlow Condensed - Latin': (
    'name': 'Barlow Condensed',
    'normal': 'barlow-condensed/normal-latin',
    'unicode-range': U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215
  ),
);
mirisuzanne commented 6 years ago

Oh, this is great. I wasn't aware of the feature. Here's more detail for reference:

https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range

Happy to accept a pull request, or I'll add it when I have time.

mabar commented 6 years ago

I would like to send PR but my attempts for more complex programming in sass are always catastrophical, I am sorry. Thank you