core

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ERROR_INCORRECT_MAGIC_NUMBER = errors.New("Incorrect magic number")
View Source
var ERROR_NO_GET_WRONG_TYPE = errors.New("get wrong type")
View Source
var ERROR_NO_KEY_FOUND = errors.New("no key found")
View Source
var ERROR_NO_UNICODE_ENCODING_FOUND = errors.New("No Unicode encoding found")
View Source
var ERROR_POSTSCRIPT_NAME_NOT_FOUND = errors.New("PostScript name not found")
View Source
var ERROR_UNEXPECTED_SUBTABLE_FORMAT = errors.New("Unexpected subtable format")
View Source
var ErrFontLicenseDoesNotAllowEmbedding = errors.New("Font license does not allow embedding")

ErrFontLicenseDoesNotAllowEmbedding Font license does not allow embedding

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

ErrTableNotFound error table not found

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

Functions

func Round

func Round(value float64) int

Types

type CmapFormat12GroupingTable

type CmapFormat12GroupingTable struct {
	StartCharCode, EndCharCode, GlyphID uint
}

type FontMaker

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

FontMaker font maker

func NewFontMaker

func NewFontMaker() *FontMaker

NewFontMaker new FontMaker

func (*FontMaker) FileSize

func (f *FontMaker) FileSize(path string) (int64, error)

func (*FontMaker) GetInfoFromTrueType

func (f *FontMaker) GetInfoFromTrueType(fontpath string, fontmaps []FontMap) (TtfInfo, error)

func (*FontMaker) GetResults

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

GetResults get result

func (*FontMaker) GoStructName

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

func (*FontMaker) LoadMap

func (f *FontMaker) LoadMap(encodingpath string) ([]FontMap, error)

func (*FontMaker) MakeDefinitionFile

func (f *FontMaker) MakeDefinitionFile(gofontname string, mappath string, exportfile string, encode string, fontmaps []FontMap, info TtfInfo) (string, error)

func (*FontMaker) MakeFont

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

func (*FontMaker) MakeFontDescriptor

func (f *FontMaker) MakeFontDescriptor(info TtfInfo) (string, error)

func (*FontMaker) MakeFontEncoding

func (f *FontMaker) MakeFontEncoding(mappath string, fontmaps []FontMap) (string, error)

func (*FontMaker) MakeWidthArray

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

func (*FontMaker) MultiplyAndRound

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

func (*FontMaker) MultiplyAndRoundWithUInt64

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

func (*FontMaker) Round

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

type FontMap

type FontMap struct {
	Uv   int
	Name string
}

type KernMap

type KernMap map[uint]KernValue

KernMap kerning map map[left]KernValue

type KernTable

type KernTable struct {
	Version uint //for debug
	NTables uint //for debug
	Kerning KernMap
}

KernTable https://www.microsoft.com/typography/otspec/kern.htm

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 added in v0.18.1

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 postion 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

type TableDirectoryEntry struct {
	CheckSum uint
	Offset   uint
	Length   uint
}

func (TableDirectoryEntry) PaddedLength

func (t TableDirectoryEntry) PaddedLength() int

type TtfInfo

type TtfInfo map[string]interface{}

func NewTtfInfo

func NewTtfInfo() TtfInfo

func (TtfInfo) GetBool

func (t TtfInfo) GetBool(key string) (bool, error)

func (TtfInfo) GetInt64

func (t TtfInfo) GetInt64(key string) (int, error)

func (TtfInfo) GetInt64s

func (t TtfInfo) GetInt64s(key string) ([]int, error)

func (TtfInfo) GetMapIntInt64

func (t TtfInfo) GetMapIntInt64(key string) (map[int]int, error)

func (TtfInfo) GetString

func (t TtfInfo) GetString(key string) (string, error)

func (TtfInfo) PushBool

func (t TtfInfo) PushBool(key string, val bool)

func (TtfInfo) PushBytes

func (t TtfInfo) PushBytes(key string, val []byte)

func (TtfInfo) PushInt

func (t TtfInfo) PushInt(key string, val int)

func (TtfInfo) PushInt64

func (t TtfInfo) PushInt64(key string, val int64)

func (TtfInfo) PushInt64s

func (t TtfInfo) PushInt64s(key string, val []int)

func (TtfInfo) PushMapIntInt64

func (t TtfInfo) PushMapIntInt64(key string, val map[int]int)

func (TtfInfo) PushString

func (t TtfInfo) PushString(key string, val string)

func (TtfInfo) PushUInt64

func (t TtfInfo) PushUInt64(key string, val uint)

Jump to

Keyboard shortcuts

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