0

I am trying to use a purchased font in a Hugo Academic website, built with the hugodown R package, but it's only partially working. The font shows up fine in the Preview on RStudio, and on Chrome on my laptop (both on localhost and when deployed to netlify). However, it reverts to the fallback font on Safari on my laptop and on both Safari and Chrome on a different laptop (those are the only two browsers I’ve tested it with).

The purchased font is LEMONMILKPro (though I have the same trouble with all the fonts that I’ve tried to declare through @font-face, rather than using Google Fonts). The fallback font is Raleway.

Here's the set-up:

  • font files (.woff, .woff2) saved in static/fonts
  • @font-face declarations in assets/css/custom.css (and repeated for good measure in assests/scss/custom.scss):
@import url("//hello.myfonts.net/count/3c07c5");

@font-face {
  font-family: 'LEMONMILKPro-Medium';
  src: local('LEMONMILKPro-Medium'), url('fonts/LEMONMILKPro-Medium.woff2') format('woff2'), url('fonts/LEMONMILKPro-Medium.woff') format('woff');
}
@font-face {
  font-family: 'LEMONMILKPro-Regular';
  src: local('LEMONMILKPro-Regular'), url('fonts/LEMONMILKPro-Regular.woff2') format('woff2'), url('fonts/LEMONMILKPro-Regular.woff') format('woff');
}
@font-face {
  font-family: 'LEMONMILKPro-Light';
  src: local('LEMONMILKPro-Light'), url('fonts/LEMONMILKPro-Light.woff2') format('woff2'), url('fonts/LEMONMILKPro-Light.woff') format('woff');
}
@font-face {
  font-family: 'LEMONMILKPro-UltraLight';
  src: local('LEMONMILKPro-UltraLight'), url('fonts/LEMONMILKPro-UltraLight.woff2') format('woff2'), url('fonts/LEMONMILKPro-UltraLight.woff') format('woff');
}
  • font theme (emk_font_set), saved in data/fonts and linked to in config/_default/params.toml, includes:
# Font families
heading_font = "LEMONMILKPro-Regular"
body_font = "LEMONMILKPro-UltraLight"
nav_font = "LEMONMILKPro-UltraLight"
  • So that I can use Raleway as a back-up font when LEMONMILKPro, isn’t working, custom.css and custom.scss also contains
html {
  font-family: "LEMONMILKPro-UltraLight", "Raleway", sans-serif;
}

h1, h2, h3 {
  font-family: "LEMONMILK-Regular", "Raleway", sans-serif;
  text-transform: uppercase;
}

The whole set-up is at https://github.com/EllaKaye/hugodown-website.

The website itself is (temporarily) at https://gallant-shaw-c70134.netlify.app/.

I've pieced together what I've done so far from https://github.com/gcushen/hugo-academic/issues/1061 (though updated slightly for Hugo Academic v4.8) and https://css-tricks.com/snippets/css/using-font-face/. I've read at least a dozen posts/forum queries around this topic and haven't been able to resolve this issue.

I bought LEMONMILKPro and the appropriate licenses on myfonts.com which provided a webkit, including a css stylesheet (and the @import line above), but in order to (attempt to) get that working with Hugo, I’ve copied the contents of that into custom.scss and custom.css, and tweaked the @font-face declarations and the font file names and locations to match the above local fonts GitHub issue.

Any idea how to get my purchased working on all (modern) browsers on all computers? Thank you!

EllaK
  • 209
  • 2
  • 9
  • I have a feeling it's the paths you're using for the fonts: `fonts/LEMONMILKPro-Medium.woff2` - if this is being set in a css file in `assets/css/` that relative path will not point to `/static/fonts`, you'll need to back up a couple of directories: `../../static/fonts/LEMONMILKPro-Medium.woff2` (or thereabouts) – OK sure Aug 11 '20 at 11:54
  • Thanks for your speedy reply and suggestion @OKsure. Could well be something to do with paths (Hugo Academic is tricky like that!) but I've tried your change and it doesn't make a difference. – EllaK Aug 11 '20 at 11:59
  • If you check your site and open the developer tools and check the network tab you'll see all the 404s for the font files - the browser is trying to access them at this path `https://gallant-shaw-c70134.netlify.app/css/fonts/LEMONMILKPro-UltraLight.woff2`. You could try an absolute path in that css so for example: `/static/fonts/LEMONMILKPro-Medium.woff2` - I am fairly confident that the issue is in this area. – OK sure Aug 11 '20 at 13:35
  • Also, just another note - are you sure they're uploaded? https://gallant-shaw-c70134.netlify.app/static/fonts/LEMONMILKPro-Medium.woff2 is erroring – OK sure Aug 11 '20 at 13:41
  • @OKSure, you were right, it was a path issue. Setting url('../fonts/LEMONMILKPro-Medium.woff2') etc did the trick. Thank you for your help. – EllaK Aug 11 '20 at 21:03
  • Excellent! Glad that got you going in the right direction. – OK sure Aug 12 '20 at 09:48

0 Answers0