fontconfig

package
v1.16.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Open(ctx context.Context) (*Config, error)

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

func (c *Config) Aliases(ctx context.Context, family string) ([]string, error)

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) Covers

func (c *Config) Covers(path string, index int, r rune) (has, known bool)

Covers says whether the font that an earlier Match listed (the file and the face in it) has a glyph for r, from the character set that fontconfig keeps for it: no font file is opened. known is false for a font that no Match listed, and after Close.

Flutter: no counterpart

func (*Config) Families

func (c *Config) Families(ctx context.Context) ([]string, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL