swcarpentry / DEPRECATED-bc

DEPRECATED: This repository is now frozen - please see individual lesson repositories.
Other
299 stars 383 forks source link

Use local fonts for slides #571

Closed gvwilson closed 9 years ago

gvwilson commented 10 years ago

Our slides currently load fonts over the web. According to @alexperala, we should be able to load locally instead (so that things will run on a laptop that isn't on the web, which is useful in a lot of circumstances). His comment is below; it would be useful if someone could explore this and see (a) if we can do it, and (b) how much it would add to the repo.

Our slides are loading the fonts from Google Fonts, but it looks like there is a way to use them locally. I checked out the first one, 'Lato', and when I clicked the download button I got this message:

image

It looks like SkyFonts will allow you to download the fonts to your device, and I imagine the Google Code Project gives you all Google Fonts. In any case I believe each font will be saved as a .woff file, which you can then link to by replacing those @import lines with what you get when you click those links - the code from the Google Fonts API. So for example, you would replace this:

@import url(
https://fonts.googleapis.com/css?family=3DLato:400,700,400italic,700italic);

with this:

@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  src: local('Lato Regular'), local('Lato-Regular'), url(http://localfolder/lato.woff) format('woff');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  src: local('Lato Bold'), local('Lato-Bold'), url(http://localfolder/lato.woff) format('woff');
}
@font-face {
  font-family: 'Lato';
  font-style: italic;
  font-weight: 400;
  src: local('Lato Italic'), local('Lato-Italic'), url(http://localfolder/lato.woff) format('woff');
}
@font-face {
  font-family: 'Lato';
  font-style: italic;
  font-weight: 700;
  src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url(http://localfolder/lato.woff) format('woff');
}
twitwi commented 10 years ago

I've been doing the same (downloading web fonts) for my presentations so I can confirm it works. I have a script for that but we just need to do it once, so a manual approach would be ok. https://github.com/twitwi/deck.js-theme-builder/blob/master/tools/get-and-use-local-fonts.py

The .woff I use are around 30kB so it shouldn't be a big problem to put them in the repo. https://github.com/twitwi/deck.js-theme-builder/tree/master/local-fonts

(I just saw this issue randomly, not sure I'll work on it)

wking commented 10 years ago

Can we download Google's font and store it in the repository? I'm not sure what the license is, but then you'd get the fonts along with the slides. If Google won't let you store them in a repository, I'd just pick a font that does allow that.

twitwi commented 10 years ago

I think I checked the licence prior to doing it but I'm not 100% sure. I'll check later.

twitwi commented 10 years ago

It seems to be ok, it's said to be "open source" and "you can use them in every way you want, privately or commercially — in print, on your computer, or in your websites". http://www.google.com/fonts/#AboutPlace:about

wking commented 10 years ago

On Tue, Aug 19, 2014 at 01:23:22PM -0700, Rémi Emonet wrote:

"you can use them in every way you want, …"

Lovely. Thanks for checking :).

twitwi commented 10 years ago

Here: https://github.com/swcarpentry/bc/pull/673

twitwi commented 9 years ago

The patch has been merged by @r-gaia-cs cheers