fontforge

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 7 Imported by: 0

README

Go bindings for the Python fontforge module

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

[!IMPORTANT] Currently supports python-3.11 only.

Prerequisites

  • Go >= 1.22

Install

go get go.nhat.io/fontforge

Usage

TBD

Examples

TBA

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Paypal donation

paypal

       or scan this

Documentation

Overview

Package fontforge provides go bindings for Python fontforge module.

Index

Constants

View Source
const (
	LookupTypeGSubSingle       = LookupType("gsub_single")
	LookupTypeGSubContextChain = LookupType("gsub_contextchain")
)

Lookup types.

View Source
const (
	LookupFlagRightToLeft     = LookupFlag("right_to_left")
	LookupFlagIgnoreBases     = LookupFlag("ignore_bases")
	LookupFlagIgnoreLigatures = LookupFlag("ignore_ligatures")
	LookupFlagIgnoreMarks     = LookupFlag("ignore_marks")
)

Lookup flags.

Variables

View Source
var ErrFileNotFound = os.ErrNotExist

ErrFileNotFound indicates that a file was not found.

Functions

func AddContextualLookupSubtable

func AddContextualLookupSubtable(font *Font, lookupName string, lookupSubtableName string, lookupType, lookupRule string)

AddContextualLookupSubtable creates a new subtable within the specified contextual lookup (contextual, contextual chaining, or reverse contextual chaining). The lookup name should be a string specifying an existing lookup. The subtable name should also be a string and should not match any currently existing subtable in the lookup.

func AddLookup

func AddLookup(font *Font, lookupName string, lookupType LookupType, lookupFlags LookupFlags, lookupFeatures LookupFeatures)

AddLookup creates a new lookup with the given name, type and flags. It will tag it with any indicated features.

func AddLookupSubtable

func AddLookupSubtable(font *Font, lookupName string, lookupSubtableName string)

AddLookupSubtable creates a new subtable within the specified lookup. The lookup name should be a string specifying an existing lookup. The subtable name should also be a string and should not match any currently existing subtable in the lookup.

func AddPositionSubstitutionVariant

func AddPositionSubstitutionVariant(glyph *Glyph, subtableName string, variant string)

AddPositionSubstitutionVariant adds position/substitution data to the glyph. The number and type of the arguments vary according to the type of the lookup containing the subtable.

func CopyGlyph

func CopyGlyph(font *Font, glyph string) error

CopyGlyph copies a glyph into (FontForge's internal) clipboard.

func Generate

func Generate(font *Font, path string) error

Generate generates a font file.

func PasteGlyph

func PasteGlyph(font *Font, glyph string) error

PasteGlyph pastes the contents of (FontForge's internal) clipboard into the selected glyphs – and removes what was there before.

Types

type Font

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

Font is a wrapper around a Python object.

func Open

func Open(path string) (*Font, error)

Open opens a font file.

func (*Font) AsObject

func (f *Font) AsObject() *python3.Object

AsObject returns the underlying Object.

func (*Font) Close

func (f *Font) Close() error

Close closes the font.

func (*Font) Copyright

func (f *Font) Copyright() string

Copyright returns the copyright.

func (*Font) CreateGlyph

func (f *Font) CreateGlyph(glyph string) error

CreateGlyph creates a new glyph.

func (*Font) DecRef

func (f *Font) DecRef()

DecRef decreases the reference count of the object.

func (*Font) Em

func (f *Font) Em() int

Em returns the em size of the font.

func (*Font) FamilyName

func (f *Font) FamilyName() string

FamilyName returns the family name of the font.

func (*Font) FontName

func (f *Font) FontName() string

FontName returns the font name of the font.

func (*Font) FullName

func (f *Font) FullName() string

FullName returns the full name of the font.

func (*Font) Glyph

func (f *Font) Glyph(glyph any) *Glyph

Glyph returns the glyph of the font.

func (*Font) HasGlyph

func (f *Font) HasGlyph(glyph any) bool

HasGlyph returns true if the font has the glyph.

func (*Font) Path

func (f *Font) Path() string

Path returns the path of the font.

func (*Font) SFNTNames

func (f *Font) SFNTNames() SFNTNames

SFNTNames returns the SFNT names.

func (*Font) SetCopyright

func (f *Font) SetCopyright(copyright string)

SetCopyright sets the copyright.

func (*Font) SetEm

func (f *Font) SetEm(em int)

SetEm sets the em size of the font.

func (*Font) SetFamilyName

func (f *Font) SetFamilyName(name string)

SetFamilyName sets the family name of the font.

func (*Font) SetFontName

func (f *Font) SetFontName(name string)

SetFontName sets the font name of the font.

func (*Font) SetFullName

func (f *Font) SetFullName(name string)

SetFullName sets the full name of the font.

func (*Font) SetSFNTNames

func (f *Font) SetSFNTNames(keyAndValues ...string)

SetSFNTNames sets the SFNT names.

func (*Font) SetUnderlinePosition

func (f *Font) SetUnderlinePosition(pos float64)

SetUnderlinePosition sets the underline position of the font.

func (*Font) SetUnderlineWith

func (f *Font) SetUnderlineWith(with float64)

SetUnderlineWith sets the underline with of the font.

func (*Font) SetVersion

func (f *Font) SetVersion(version semver.Version)

SetVersion sets the version of the font.

func (*Font) UnderlinePosition

func (f *Font) UnderlinePosition() float64

UnderlinePosition returns the underline position of the font.

func (*Font) UnderlineWith

func (f *Font) UnderlineWith() float64

UnderlineWith returns the underline with of the font.

func (*Font) Version

func (f *Font) Version() *semver.Version

Version returns the version of the font.

type Glyph

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

Glyph is a font glyph.

func (*Glyph) AsObject

func (g *Glyph) AsObject() *python3.Object

AsObject returns the underlying Object.

func (*Glyph) Close

func (g *Glyph) Close() error

Close closes the glyph.

func (*Glyph) DecRef

func (g *Glyph) DecRef()

DecRef decreases the reference count of the object.

func (*Glyph) GlyphName

func (g *Glyph) GlyphName() string

GlyphName returns the name of the glyph.

func (*Glyph) LeftSideBearing

func (g *Glyph) LeftSideBearing() float64

LeftSideBearing returns the left side bearing of the glyph.

func (*Glyph) RightSideBearing

func (g *Glyph) RightSideBearing() float64

RightSideBearing returns the right side bearing of the glyph.

func (*Glyph) SetGlyphName

func (g *Glyph) SetGlyphName(name string)

SetGlyphName sets the name of the glyph.

func (*Glyph) SetLeftSideBearing

func (g *Glyph) SetLeftSideBearing(bearing float64)

SetLeftSideBearing sets the left side bearing of the glyph.

func (*Glyph) SetRightSideBearing

func (g *Glyph) SetRightSideBearing(bearing float64)

SetRightSideBearing sets the right side bearing of the glyph.

func (*Glyph) SetWidth

func (g *Glyph) SetWidth(width int)

SetWidth sets the width of the glyph.

func (*Glyph) Transform

func (g *Glyph) Transform(matrix []float64)

Transform applies a transformation matrix to the glyph.

func (*Glyph) Width

func (g *Glyph) Width() int

Width returns the width of the glyph.

type LookupFeature

type LookupFeature struct {
	TagName LookupFeatureTag
	Scripts []LookupFeatureScript
}

LookupFeature is a font lookup feature.

func NewLookupFeature

func NewLookupFeature(tag string) LookupFeature

NewLookupFeature creates a new lookup feature.

func (LookupFeature) MarshalPyObject

func (f LookupFeature) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

func (LookupFeature) WithScript

func (f LookupFeature) WithScript(scriptTag LookupFeatureScriptTag, scriptLanguages ...LookupFeatureScriptLanguage) LookupFeature

WithScript adds a script to the lookup feature.

type LookupFeatureScript

type LookupFeatureScript struct {
	Tag       LookupFeatureScriptTag
	Languages []LookupFeatureScriptLanguage
}

LookupFeatureScript is a font lookup feature script.

func (LookupFeatureScript) MarshalPyObject

func (s LookupFeatureScript) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

type LookupFeatureScriptLanguage

type LookupFeatureScriptLanguage string

LookupFeatureScriptLanguage is a font lookup feature script language.

func (LookupFeatureScriptLanguage) MarshalPyObject

func (l LookupFeatureScriptLanguage) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

type LookupFeatureScriptTag

type LookupFeatureScriptTag string

LookupFeatureScriptTag is a font lookup feature script tag.

func (LookupFeatureScriptTag) MarshalPyObject

func (t LookupFeatureScriptTag) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

type LookupFeatureTag

type LookupFeatureTag string

LookupFeatureTag is a font lookup feature tag.

func (LookupFeatureTag) MarshalPyObject

func (t LookupFeatureTag) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

type LookupFeatures

type LookupFeatures []LookupFeature

LookupFeatures are font lookup features.

func (LookupFeatures) MarshalPyObject

func (s LookupFeatures) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

type LookupFlag

type LookupFlag string

LookupFlag is a font lookup flag.

func (LookupFlag) MarshalPyObject

func (f LookupFlag) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

type LookupFlags

type LookupFlags []LookupFlag

LookupFlags are font lookup flags.

func (LookupFlags) MarshalPyObject

func (f LookupFlags) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying Object.

type LookupType

type LookupType string

LookupType is a font lookup type.

func (LookupType) MarshalPyObject

func (t LookupType) MarshalPyObject() *python3.Object

MarshalPyObject returns the underlying PyObject.

type SFNTName

type SFNTName struct {
	Locale string
	Key    string
	Value  string
}

SFNTName is a SFNT name.

func (SFNTName) MarshalPyObject

func (n SFNTName) MarshalPyObject() *python3.Object

MarshalPyObject marshals a SFNTName to a python3.Object.

func (*SFNTName) UnmarshalPyObject

func (n *SFNTName) UnmarshalPyObject(o *python3.Object) error

UnmarshalPyObject unmarshals a python3.Object to a SFNTName.

type SFNTNames

type SFNTNames []SFNTName

SFNTNames is a list of SFNTName.

func (SFNTNames) Find

func (n SFNTNames) Find(key string) string

Find finds a SFNTName by key.

func (SFNTNames) MarshalPyObject

func (n SFNTNames) MarshalPyObject() *python3.Object

MarshalPyObject marshals a SFNTName to a python3.Object.

Jump to

Keyboard shortcuts

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