Documentation
¶
Overview ¶
Package fontconfig binds libfontconfig (through purego, SPEC §8.1) to match a font family, weight, slant and language to the font files of the system, in the fallback order the user's fontconfig settings give. The Linux engine of Flutter asks fontconfig the same way.
Flutter: no counterpart (engine/src/flutter/third_party/txt uses Skia's SkFontMgr_fontconfig)
Index ¶
Constants ¶
const LibraryEnv = "GLUTTER_FONTCONFIG_LIBRARY"
LibraryEnv names the environment variable that overrides the path of libfontconfig, for setups such as NixOS (SPEC §8.1).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a loaded fontconfig configuration with the system fonts. It is safe for concurrent use.
Flutter: no counterpart
func Open ¶
Open loads libfontconfig and the user's fontconfig configuration, which reads the configuration files and scans the font directories. It fails with FontconfigLoadFailed when the library is not there, with FontconfigInitFailed when it cannot load a configuration, and with FontconfigCanceled when ctx is done. Close the Config when done.
Flutter: no counterpart
func (*Config) Aliases ¶
Aliases returns the other family names that the user's configuration says the family stands for, in order: after FcConfigSubstitute the pattern lists the family and then, for Arial, Liberation Sans and its metric-compatible names, or for a family with a rule of the user, the names the rules add. The names that the configuration adds to every family (the default sans-serif and the fonts it stands for) are left out, so a family that nothing mentions has none. It fails like Match.
Flutter: no counterpart (SkFontMgr_fontconfig::onMatchFamilyStyle accepts the strongly bound families)
func (*Config) Close ¶
func (c *Config) Close()
Close releases the configuration. The Config must not be used after.
Flutter: no counterpart
func (*Config) Families ¶
Families lists the family names of the installed fonts, sorted without regard to case and without duplicates (FcFontList with the family as the only object). It fails with FontconfigListFailed when fontconfig cannot list the fonts, with FontconfigPatternFailed when it cannot build the query, with FontconfigClosed after Close, and with FontconfigCanceled when ctx is done.
Flutter: no counterpart
func (*Config) Match ¶
func (c *Config) Match(ctx context.Context, family string, weight int, italic bool, lang string) ([]File, error)
Match returns the font files for the family in the order of fontconfig's fallback: the best match first, then the fonts the family and language substitution rules and the user's preferences put next. family may be a generic name such as "sans-serif" or "emoji"; weight is an OpenType weight (400 regular, 700 bold); lang is a BCP 47 tag such as "ja" or "" for the default. It fails with FontconfigMatchFailed when fontconfig cannot sort the fonts, with FontconfigPatternFailed when it cannot build the query, with FontconfigClosed after Close, and with FontconfigCanceled when ctx is done.
Flutter: no counterpart (SkFontMgr_fontconfig::onMatchFamilyStyle)
type File ¶
type File struct {
// Path is the font file.
Path string
// Index is fontconfig's FC_INDEX: the face in a collection in the low 16 bits,
// and for a variable font, 1 + the named instance in the high 16 bits (0 means
// the default instance).
Index int
// Family is the first family name of the font, or "".
Family string
}
File is one font that fontconfig matched.
Flutter: no counterpart