0

It is a long journey to switch and change fonts in Emacs: download a package of fonts, unpack it, install those fonts in my computer, use commands to find the names of the fonts, and then write functions to switch my Emacs to one of them.

I wonder if there is a way to use a font in googleapi to automatic show fonts in Emacs when I specify the name and/or some options.

If there may be a way to do this, would you mind give me some suggestions about how to do this?

  • Do you mean the fonts that Google offers for "free" use on websites? In which case, I suspect the answer is "no". Those are webfonts, emacs is a desktop application and uses the fonts offered by the desktop (Windows or whatever). They're not the same kind of fonts at all. If you want to make testing out fonts in emacs easier, try looking in the menu commands (e.g. "Options > Choose Default Font"). It will save you having to look up the name at least – Reign of Error Aug 9 '17 at 22:35
  • So it is not possible to use a webfont in Emacs. I am sorry, but why not? – cmal Aug 10 '17 at 0:58
2

In short: I think the answer here is "no", you can't use the web fonts from Google as display fonts in Emacs.

The feature "download and use arbitrary fonts over the network" is deemed useful enough to implement for apps whose purpose is "download and display arbitrary text and multimedia content over the network", notably browsers, but not for almost all other applications, including Emacs, which rely on locally installed fonts.

In more detail: Google (among others) offers access to fonts free of charge which are intended for use on websites. Google encourages users to make use of these fonts by including a snippet of Javascript in their webpages. Underlying this are a set of files, hosted by Google but also downloadable. These web font files come in various competing formats, including W3C's woff and woff2 and Microsoft's eot.

These file formats are compressed representations of fonts, so that they can be sent with web pages that use them. The font files are interpreted within the web browser and used primarily to display letters in a page on a screen.

Emacs runs in either a desktop (like Windows, Gnome OS X) or as a terminal application. The fonts it can use are those that are provided by that desktop or terminal. These are the ones that are installed locally in whatever way that system provides. In modern desktops, otf or ttf are the commonest file formats.

Basically, Emacs is here the same as any other desktop (or terminal) application in using the fonts offered by that environment. It's browsers that are "special" in knowing how to use web fonts.

Many fonts that are offered "free" as web fonts are also available for download and installation as ttf or otf. Using Emacs's menus (e.g. "Options > Choose Default Font") may make testing out different display fonts easier.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.