fontengine

package
v0.0.80 Latest Latest
Warning

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

Go to latest
Published: May 10, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTableNotFound = errs.New("table not found")

ErrTableNotFound error table not found

View Source
var Nonsymbolic = (1 << 5)
View Source
var Symbolic = 1 << 2

Functions

func NewTtfInfo

func NewTtfInfo() ttfInfo

Types

type FontEngine

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

FontEngine font maker

func NewFontEngine

func NewFontEngine(w env.FileWriter) *FontEngine

NewFontEngine new FontEngine

func (*FontEngine) GetInfoFromTrueType

func (f *FontEngine) GetInfoFromTrueType(fontpath string, fontmaps []fontMap) (ttfInfo, error)

func (*FontEngine) GetResults

func (f *FontEngine) GetResults() []string

GetResults get result

func (*FontEngine) GoStructName

func (f *FontEngine) GoStructName(name string) string

func (*FontEngine) LoadMap

func (f *FontEngine) LoadMap(encodingpath string) ([]fontMap, error)

func (*FontEngine) MakeDefinitionFile

func (f *FontEngine) MakeDefinitionFile(gofontname string, mappath string, exportfile string, encode string, fontmaps []fontMap, info ttfInfo) (string, error)

func (*FontEngine) MakeFont

func (f *FontEngine) MakeFont(fontpath string, mappath string, encode string, outfolderpath string) error

func (*FontEngine) MakeFontDescriptor

func (f *FontEngine) MakeFontDescriptor(info ttfInfo) (string, error)

func (*FontEngine) MakeFontEncoding

func (f *FontEngine) MakeFontEncoding(mappath string, fontmaps []fontMap) (string, error)

func (*FontEngine) MakeWidthArray

func (f *FontEngine) MakeWidthArray(widths map[int]int) (string, error)

func (*FontEngine) MultiplyAndRound

func (f *FontEngine) MultiplyAndRound(k float64, v int) int

func (*FontEngine) MultiplyAndRoundWithUInt64

func (f *FontEngine) MultiplyAndRoundWithUInt64(k float64, v uint) int

func (*FontEngine) Round

func (f *FontEngine) Round(value float64) int

type FontProvider added in v0.0.72

type FontProvider interface {
	// Identificación de la fuente
	Name() string   // Nombre de la fuente
	Family() string // Familia de la fuente

	// Propiedades de estilo
	Weight() string // Peso: regular, bold, etc.
	Style() string  // Estilo: normal, italic, etc.

	// Propiedades para renderizado SVG
	SVGFontID() string // ID para referenciar en SVG

	// Opcionalmente, para sistemas que necesiten la ruta al archivo
	Path() string // Ruta al archivo de la fuente
}

FontProvider es una interfaz que abstrae las propiedades necesarias de una fuente para que el renderizador pueda trabajar con ella independientemente de su implementación

type KernValue

type KernValue map[uint]int16

KernValue kerning values map[right]value

func (KernValue) ValueByRight

func (k KernValue) ValueByRight(right uint) (bool, int16)

ValueByRight get value by right

type TTFParser

type TTFParser struct {
	Embeddable bool
	Bold       bool

	//cmap
	IsShortIndex  bool
	LocaTable     []uint
	SegCount      uint
	StartCount    []uint
	EndCount      []uint
	IdRangeOffset []uint
	IdDelta       []uint
	GlyphIdArray  []uint
	// contains filtered or unexported fields
}

TTFParser true type font parser

func (*TTFParser) ArrayPadUint

func (t *TTFParser) ArrayPadUint(arr []uint, size uint, val uint) ([]uint, error)

func (*TTFParser) Ascender

func (t *TTFParser) Ascender() int

func (*TTFParser) BytesToString

func (t *TTFParser) BytesToString(b []byte) string

BytesToString convert bytes to string

func (*TTFParser) CapHeight

func (t *TTFParser) CapHeight() int

CapHeight https://en.wikipedia.org/wiki/Cap_height

func (*TTFParser) Chars

func (t *TTFParser) Chars() map[int]uint

func (*TTFParser) Descender

func (t *TTFParser) Descender() int

func (*TTFParser) FTell

func (t *TTFParser) FTell(fd *bytes.Reader) (uint, error)

func (*TTFParser) Flag

func (t *TTFParser) Flag() int

func (*TTFParser) FontData

func (t *TTFParser) FontData() []byte

func (*TTFParser) GetTables

func (t *TTFParser) GetTables() map[string]TableDirectoryEntry

func (*TTFParser) GroupingTables

func (t *TTFParser) GroupingTables() []cmapFormat12GroupingTable

GroupingTables get cmap format12 grouping table

func (*TTFParser) ItalicAngle

func (t *TTFParser) ItalicAngle() int

func (*TTFParser) Kern

func (t *TTFParser) Kern() *kernTable

Kern get kernTable

func (*TTFParser) NumGlyphs

func (t *TTFParser) NumGlyphs() uint

NumGlyphs number of glyph

func (*TTFParser) NumberOfHMetrics

func (t *TTFParser) NumberOfHMetrics() uint

func (*TTFParser) Parse

func (t *TTFParser) Parse(filepath string) error

Parse parse

func (*TTFParser) ParseByReader

func (t *TTFParser) ParseByReader(rd io.Reader) error

ParseByReader parse by io.reader

func (*TTFParser) ParseCmap

func (t *TTFParser) ParseCmap(fd *bytes.Reader) error

ParseCmap parse cmap table format 4 https://www.microsoft.com/typography/otspec/cmap.htm

func (*TTFParser) ParseCmapFormat12

func (t *TTFParser) ParseCmapFormat12(fd *bytes.Reader) (bool, error)

ParseCmapFormat12 parse cmap table format 12 https://www.microsoft.com/typography/otspec/cmap.htm

func (*TTFParser) ParseFontData

func (t *TTFParser) ParseFontData(fontData []byte) error

ParseFontData parses font data.

func (*TTFParser) ParseHead

func (t *TTFParser) ParseHead(fd *bytes.Reader) error

ParseHead parse head table https://www.microsoft.com/typography/otspec/Head.htm

func (*TTFParser) ParseHhea

func (t *TTFParser) ParseHhea(fd *bytes.Reader) error

ParseHhea parse hhea table https://www.microsoft.com/typography/otspec/hhea.htm

func (*TTFParser) ParseHmtx

func (t *TTFParser) ParseHmtx(fd *bytes.Reader) error

ParseHmtx parse hmtx table https://www.microsoft.com/typography/otspec/hmtx.htm

func (*TTFParser) ParseLoca

func (t *TTFParser) ParseLoca(fd *bytes.Reader) error

ParseLoca parse loca table https://www.microsoft.com/typography/otspec/loca.htm

func (*TTFParser) ParseMaxp

func (t *TTFParser) ParseMaxp(fd *bytes.Reader) error

ParseMaxp parse maxp table https://www.microsoft.com/typography/otspec/Maxp.htm

func (*TTFParser) ParseName

func (t *TTFParser) ParseName(fd *bytes.Reader) error

ParseName parse name table https://www.microsoft.com/typography/otspec/name.htm

func (*TTFParser) ParseOS2

func (t *TTFParser) ParseOS2(fd *bytes.Reader) error

ParseOS2 parse OS2 table https://www.microsoft.com/typography/otspec/OS2.htm

func (*TTFParser) ParsePost

func (t *TTFParser) ParsePost(fd *bytes.Reader) error

ParsePost parse post table https://www.microsoft.com/typography/otspec/post.htm

func (*TTFParser) Parsekern

func (t *TTFParser) Parsekern(fd *bytes.Reader) error

Parsekern parse kerning table https://www.microsoft.com/typography/otspec/kern.htm

func (*TTFParser) PregReplace

func (t *TTFParser) PregReplace(pattern string, replacement string, subject string) (string, error)

func (*TTFParser) Read

func (t *TTFParser) Read(fd *bytes.Reader, length int) ([]byte, error)

Read read

func (*TTFParser) ReadShort

func (t *TTFParser) ReadShort(fd *bytes.Reader) (int, error)

ReadShort read short

func (*TTFParser) ReadShortInt16

func (t *TTFParser) ReadShortInt16(fd *bytes.Reader) (int16, error)

ReadShortInt16 read short return int16

func (*TTFParser) ReadULong

func (t *TTFParser) ReadULong(fd *bytes.Reader) (uint, error)

ReadULong read ulong

func (*TTFParser) ReadUShort

func (t *TTFParser) ReadUShort(fd *bytes.Reader) (uint, error)

ReadUShort read ushort

func (*TTFParser) Seek

func (t *TTFParser) Seek(fd *bytes.Reader, tag string) error

Seek seek by tag

func (*TTFParser) SetUseKerning

func (t *TTFParser) SetUseKerning(use bool)

SetUseKerning set useKerning must set before Parse

func (*TTFParser) Skip

func (t *TTFParser) Skip(fd *bytes.Reader, length int) error

Skip skip

func (*TTFParser) TypoAscender

func (t *TTFParser) TypoAscender() int

func (*TTFParser) TypoDescender

func (t *TTFParser) TypoDescender() int

func (*TTFParser) UnderlinePosition

func (t *TTFParser) UnderlinePosition() int

UnderlinePosition config.Alignment of underline

func (*TTFParser) UnderlineThickness

func (t *TTFParser) UnderlineThickness() int

UnderlineThickness thickness of underline

func (*TTFParser) UnitsPerEm

func (t *TTFParser) UnitsPerEm() uint

func (*TTFParser) Widths

func (t *TTFParser) Widths() []uint

func (*TTFParser) XHeight

func (t *TTFParser) XHeight() int

func (*TTFParser) XMax

func (t *TTFParser) XMax() int

func (*TTFParser) XMin

func (t *TTFParser) XMin() int

func (*TTFParser) YMax

func (t *TTFParser) YMax() int

func (*TTFParser) YMin

func (t *TTFParser) YMin() int

type TableDirectoryEntry added in v0.0.68

type TableDirectoryEntry struct {
	CheckSum uint
	Offset   uint
	Length   uint
}

func (TableDirectoryEntry) PaddedLength added in v0.0.68

func (t TableDirectoryEntry) PaddedLength() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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