fcfonts

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: LGPL-2.1, LGPL-2.1 Imports: 9 Imported by: 2

Documentation

Overview

Package fcfonts is an implementation of the font tooling required by Pango, using textlayout/fontconfig and textlayout/fonts.

The entry point of the package is the `NewFontMap` constructor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLoadFace

func DefaultLoadFace(key fonts.FaceID, format fc.FontFormat) (fonts.Face, error)

DefaultLoadFace interprets the key as a file name and load from disk.

Types

type FaceLoader

type FaceLoader interface {
	// LoadFace opens and parses the given face. See `DefaultLoadFace` for a fallback.
	LoadFace(key fonts.FaceID, format fc.FontFormat) (fonts.Face, error)
}

FaceLoader is implemented by client application to extend loading capabilities. By default, fonts are loaded from disk, but FaceLoader may for instance load from memory.

type Font

type Font struct {
	Pattern fc.Pattern // fully resolved pattern
	// contains filtered or unexported fields
}

Font implements the pango.Font interface, using fontconfig.

func (*Font) Describe

func (font *Font) Describe(absolute bool) pango.FontDescription

func (*Font) FaceID

func (font *Font) FaceID() fonts.FaceID

func (*Font) GetCoverage

func (font *Font) GetCoverage(_ pango.Language) pango.Coverage

func (*Font) GetFeatures

func (font *Font) GetFeatures() []harfbuzz.Feature

func (*Font) GetFontMap

func (font *Font) GetFontMap() pango.FontMap

func (*Font) GetHarfbuzzFont

func (font *Font) GetHarfbuzzFont() *harfbuzz.Font

func (*Font) GetMetrics

func (font *Font) GetMetrics(lang pango.Language) pango.FontMetrics

func (*Font) GlyphExtents

func (font *Font) GlyphExtents(glyph pango.Glyph, inkRect, logicalRect *pango.Rectangle)

type FontMap

type FontMap struct {

	// Config is the fontconfig configuration used to
	// transform patterns when querying the database.
	// This is a readonly property, see SetConfig.
	Config *fc.Config

	// Database stores all the potential fonts, coming from
	// a fontconfig scan (or a cache).
	// This value is initialised at the start and should not be mutated,
	// to avoid caching misuse.
	// This is a readonly property, see SetConfig.
	Database fc.Fontset
	// contains filtered or unexported fields
}

FontMap implements pango.FontMap using 'fontconfig' and 'fonts'.

func NewFontMap

func NewFontMap(config *fc.Config, database fc.Fontset) *FontMap

NewFontMap creates a new font map, used to cache information about available fonts, and holds certain global parameters such as the resolution and the default substitute function. The `config` object will be used to query information from the `database`.

func (*FontMap) GetSerial

func (fontmap *FontMap) GetSerial() uint

func (*FontMap) LoadFontset

func (fontmap *FontMap) LoadFontset(context *pango.Context, desc *pango.FontDescription, language pango.Language) pango.Fontset

func (*FontMap) SetConfig

func (fontmap *FontMap) SetConfig(config *fc.Config, database fc.Fontset)

SetConfig updates the config and database, and clears the internal cache.

func (*FontMap) SetFaceLoader

func (fontmap *FontMap) SetFaceLoader(loader FaceLoader)

SetFaceLoader uses a custom mechanism to load fonts. Pass `nil` to restore the default, that is loading from disk.

type Fontset

type Fontset struct {
	// contains filtered or unexported fields
}

Fontset implements the pango.Fontset interface.

func (*Fontset) Foreach

func (fs *Fontset) Foreach(fn pango.FontsetForeachFunc)

func (*Fontset) GetLanguage

func (fs *Fontset) GetLanguage() pango.Language

Jump to

Keyboard shortcuts

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