-
Notifications
You must be signed in to change notification settings - Fork 0
Fonts
This page contains all the relevant information about fonts in the GoGi framework.
The primary way to specify a font is via the FontStyle
which is found in the overall Style
struct (see Style). It has fields for all the different supported font parameters, including Stretch, Weight, Style, Decoration, etc.
The standard CSS font styling terms are supported, as described in these links:
- https://www.w3schools.com/css/css_font.asp
- https://developer.mozilla.org/en-US/docs/Web/CSS/font
- https://www.w3.org/Style/Examples/007/fonts.en.html
-
Google Noto ("No Tofu") fonts, provide good international support: https://www.google.com/get/noto/
-
Standard Microsoft TrueType fonts for linux: https://askubuntu.com/questions/651441/how-to-install-arial-font-in-ubuntu -- these fonts are available by default on Windows and Mac platforms, and are very familiar to most users -- recommend downloading / including those in an app to provide a minimal standard set of fonts available across all platforms.
-
Monospaced fonts that are good for coding: https://ss64.com/fonts.html
The Ubuntu distribution of linux includes Liberation
fonts (https://en.wikipedia.org/wiki/Liberation_fonts) (which are the basis for the Noto fonts) -- these are specified as a platform-specific default font for linux, instead of Arial
which is the default on Windows and Mac.
Currently, only TrueType fonts are supported, with a .ttf
extension.
Some TTF fonts come in a "Collection" format (.ttc
extension) -- these should be unpacked into separate .ttf files to enable the system to actually use the different variants within the collection -- use e.g., https://onlinefontconverter.com/ or similar utilties to extract ttf from ttc files.
The standardized / regularized name of a font is the base FamilyName
(e.g., Arial
) followed by the following modifiers, in that order, space separated:
- Stretch: Normal (omitted from name), Condensed, Expanded, etc (not as commonly used)
- Weight: Regular (omitted from name), Thin, Bold, etc
- Style: Normal (omitted from name), Italic, Oblique
It is ideal if the font file names follow this convention, but the FontLib
code in GoGi attempts to regularize as best it can. This FontLib system does its best to try to map a font specification given by FontStyle
into an actual available font file found on the system -- usually you don't need to worry about it but see gi/font.go
for all the gory details if something is not working right.
The special Go font: https://blog.golang.org/go-fonts is compiled in and always available on all platforms, in all variants. Specify Go
or GoMono
as the Family
name.
On Windows and Linux, Unicode support for things like the keyboard symbols (shift, etc) is not great. Mac has it in one arial unicode font that we specifically use for symbol characters. Here's some notes on this issue:
- https://unix.stackexchange.com/questions/14027/what-fonts-are-good-for-unicode-glyphs
- windows: arialuni.ttf https://docs.microsoft.com/en-us/typography/font-list/arial-unicode-ms -- this does not appear to be installed by default, so extra step to get it installed..