package metadata

import "github.com/go-text/typesetting/opentype/api/metadata"

Index

Functions

func NormalizeFamily

func NormalizeFamily(family string) string

NormalizeFamily removes spaces and lower the given string.

Types

type Aspect

type Aspect struct {
	Style   Style
	Weight  Weight
	Stretch Stretch
}

Aspect stores the properties that specify which font in a family to use: style, weight, and stretchiness.

func Describe

func Describe(ld *loader.Loader, buffer []byte) (family string, aspect Aspect, _ []byte)

Describe provides access to family and aspect. 'buffer' may be provided to reduce allocations.

func (*Aspect) SetDefaults

func (as *Aspect) SetDefaults()

SetDefaults replace unspecified values by the default values: StyleNormal, WeightNormal, StretchNormal

type Description

type Description struct {
	Family      string
	Aspect      Aspect
	IsMonospace bool
}

Description provides font metadata.

func Metadata

func Metadata(font *loader.Loader) Description

Metadata queries the family and the aspect properties of the font loaded under font

type Stretch

type Stretch float32

Stretch is the width of a font as an approximate fraction of the normal width. Widths range from 0.5 to 2.0 inclusive, with 1.0 as the normal width.

const (
	// Ultra-condensed width (50%), the narrowest possible.
	StretchUltraCondensed Stretch = 0.5
	// Extra-condensed width (62.5%).
	StretchExtraCondensed Stretch = 0.625
	// Condensed width (75%).
	StretchCondensed Stretch = 0.75
	// Semi-condensed width (87.5%).
	StretchSemiCondensed Stretch = 0.875
	// Normal width (100%).
	StretchNormal Stretch = 1.0
	// Semi-expanded width (112.5%).
	StretchSemiExpanded Stretch = 1.125
	// Expanded width (125%).
	StretchExpanded Stretch = 1.25
	// Extra-expanded width (150%).
	StretchExtraExpanded Stretch = 1.5
	// Ultra-expanded width (200%), the widest possible.
	StretchUltraExpanded Stretch = 2.0
)

type Style

type Style uint8

Style (also called slant) allows italic or oblique faces to be selected.

const (
	// A face that is neither italic not obliqued.
	StyleNormal Style = iota + 1
	// A form that is generally cursive in nature or slanted.
	// This groups what is usually called Italic or Oblique.
	StyleItalic
)

note that we use the 0 value to indicate no style has been found yet

type Weight

type Weight float32

Weight is the degree of blackness or stroke thickness of a font. This value ranges from 100.0 to 900.0, with 400.0 as normal.

const (
	// Thin weight (100), the thinnest value.
	WeightThin Weight = 100
	// Extra light weight (200).
	WeightExtraLight Weight = 200
	// Light weight (300).
	WeightLight Weight = 300
	// Normal (400).
	WeightNormal Weight = 400
	// Medium weight (500, higher than normal).
	WeightMedium Weight = 500
	// Semibold weight (600).
	WeightSemibold Weight = 600
	// Bold weight (700).
	WeightBold Weight = 700
	// Extra-bold weight (800).
	WeightExtraBold Weight = 800
	// Black weight (900), the thickest value.
	WeightBlack Weight = 900
)

Source Files

aspect.go descriptor.go

Version
v0.1.1
Published
Mar 29, 2024
Platform
linux/amd64
Imports
4 packages
Last checked
1 hour ago

Tools for package owners.