Documentation
¶
Index ¶
- Variables
- func ClearLoadedFonts()
- func Fonts() ([]string, error)
- func LoadedFonts() []string
- func PreloadFonts(names []FontName) error
- func Text(text string, opts ...*FigletOptions) (string, error)
- type BreakWordResult
- type FigCharWithOverlap
- type FigCharsWithOverlap
- type FigletDefaults
- type FigletFont
- type FigletOptions
- type FittingProperties
- type FittingRules
- type FontMetadata
- type FontName
- type InternalOptions
- type KerningMethods
- type PrintDirection
Constants ¶
This section is empty.
Variables ¶
var FontFS embed.FS
FontFS is the embedded filesystem containing all bundled .flf font files.
Functions ¶
func LoadedFonts ¶
func LoadedFonts() []string
LoadedFonts returns the names of all currently cached fonts.
func PreloadFonts ¶
PreloadFonts loads multiple fonts into the cache.
Types ¶
type BreakWordResult ¶
type BreakWordResult struct {
// contains filtered or unexported fields
}
type FigCharWithOverlap ¶
type FigCharWithOverlap struct {
// contains filtered or unexported fields
}
type FigCharsWithOverlap ¶
type FigCharsWithOverlap struct {
// contains filtered or unexported fields
}
type FigletDefaults ¶
FigletDefaults holds the package-level defaults used when no FigletOptions are provided to Text. Modify via Defaults().
func Defaults ¶
func Defaults(opts *FigletDefaults) FigletDefaults
Defaults gets or sets the default options. Pass nil to read without modifying.
type FigletFont ¶
type FigletFont struct {
// contains filtered or unexported fields
}
FigletFont is the internal representation of a parsed .flf font file.
func NewFigletFont ¶
func NewFigletFont() *FigletFont
NewFigletFont returns an empty FigletFont ready to be populated by ParseFont.
type FigletOptions ¶
type FigletOptions struct {
Font FontName
HorizontalLayout KerningMethods
VerticalLayout KerningMethods
Width int
WhitespaceBreak bool
PrintDirection PrintDirection
ShowHardBlanks bool
}
FigletOptions controls how a piece of text is rendered by Text. All fields are optional; zero values fall back to font/package defaults.
type FittingProperties ¶
type FittingProperties string
FontName is a string alias for a FIGlet font name. KerningMethods is a string alias for a horizontal kerning/smushing mode. FittingProperties is a string alias for a field name within FittingRules.
const ( FitHLayout FittingProperties = "hLayout" FitHRule1 FittingProperties = "hRule1" FitHRule2 FittingProperties = "hRule2" FitHRule3 FittingProperties = "hRule3" FitHRule4 FittingProperties = "hRule4" FitHRule5 FittingProperties = "hRule5" FitHRule6 FittingProperties = "hRule6" FitVLayout FittingProperties = "vLayout" FitVRule1 FittingProperties = "vRule1" FitVRule2 FittingProperties = "vRule2" FitVRule3 FittingProperties = "vRule3" FitVRule4 FittingProperties = "vRule4" FitVRule5 FittingProperties = "vRule5" )
FittingProperties constants name the individual fields of FittingRules.
type FittingRules ¶
type FittingRules struct {
HLayout int
HRule1 bool
HRule2 bool
HRule3 bool
HRule4 bool
HRule5 bool
HRule6 bool
VLayout int
VRule1 bool
VRule2 bool
VRule3 bool
VRule4 bool
VRule5 bool
}
FittingRules holds the horizontal and vertical layout mode and the individual smushing rule flags decoded from a font's header.
type FontMetadata ¶
type FontMetadata struct {
Baseline int
CodeTagCount *int
FittingRules FittingRules
FullLayout *int
HardBlank string
Height int
MaxLength int
NumCommentLines int
OldLayout int
PrintDirection PrintDirection
}
FontMetadata contains the parsed header fields of a FIGlet font file (.flf).
func LoadFont ¶
func LoadFont(name string) (*FontMetadata, error)
LoadFont loads a font by name. It first resolves any known aliases via getFontName, then checks the in-memory cache, then tries the embedded FontFS, and finally falls back to the filesystem at figDefaults.FontPath.
type FontName ¶
type FontName string
FontName is a string alias for a FIGlet font name. KerningMethods is a string alias for a horizontal kerning/smushing mode. FittingProperties is a string alias for a field name within FittingRules.
type InternalOptions ¶
type InternalOptions struct {
FontMetadata
Width int
WhitespaceBreak bool
ShowHardBlanks bool
}
type KerningMethods ¶
type KerningMethods string
FontName is a string alias for a FIGlet font name. KerningMethods is a string alias for a horizontal kerning/smushing mode. FittingProperties is a string alias for a field name within FittingRules.
const ( KerningDefault KerningMethods = "default" KerningFull KerningMethods = "full" KerningFitted KerningMethods = "fitted" KerningControlledSmushing KerningMethods = "controlled smushing" KerningUniversalSmushing KerningMethods = "universal smushing" )
KerningMethods constants define the supported horizontal kerning/smushing modes.
type PrintDirection ¶
type PrintDirection int
PrintDirection controls the direction in which FIGlet characters are rendered.
const ( DefaultDirection PrintDirection = iota - 1 // -1: use font header's value LeftToRight // 0: left to right (FIGlet default) RightToLeft // 1: right to left )