Documentation
¶
Overview ¶
Package font supplies font face wrappers for monospaced fonts, for use with github.com/ezrec/ebiten_tcell.
Index ¶
- Constants
- Variables
- type CacheFont
- func (mf *CacheFont) Empty() *ebiten.Image
- func (mf *CacheFont) Glyph(character rune, style FontStyle) (glyph *ebiten.Image, is_empty bool)
- func (mf *CacheFont) HasGlyph(character rune, style FontStyle) (has bool)
- func (mf *CacheFont) Metrics() ebiten_text.Metrics
- func (mf *CacheFont) SetGlyph(character rune, glyph *ebiten.Image)
- func (mf *CacheFont) Size() (width, height int)
- type Face
- type FaceWithBackup
- type FaceWithOnlyRunes
- type FaceWithRuneMapping
- type FaceWithStyle
- type FontStyle
- type MonoFont
Constants ¶
const ( FontStyleNormal = FontStyle(iota) // Normal font style. FontStyleBold // Bold font style. FontStyleItalic // Italic font style. FontStyleBoldItalic // Bold & Italic font style. )
Variables ¶
var ErrFontType = errors.New("unknown font source type")
Functions ¶
This section is empty.
Types ¶
type CacheFont ¶
type CacheFont struct { FontMetrics ebiten_text.Metrics Cache map[rune](*ebiten.Image) Width int // Nominal cell width. Height int // Nominal cell height. // contains filtered or unexported fields }
Implements Face
func (*CacheFont) Empty ¶
func (mf *CacheFont) Empty() *ebiten.Image
Empty() returns the empty image.
func (*CacheFont) Glyph ¶
Glyph returns a glyph for a rune. Rune glyphs are cached on their first access.
func (*CacheFont) HasGlyph ¶
HasGlyph returns true if a rune is in the font, in the specified style.
func (*CacheFont) Metrics ¶
func (mf *CacheFont) Metrics() ebiten_text.Metrics
Metrics returns the font metrics.
type Face ¶
type Face interface { Metrics() (metrics ebiten_text.Metrics) Size() (width, height int) // Character cell size, in pixels. Glyph(character rune, style FontStyle) (glyph *ebiten.Image, is_empty bool) Empty() (empty_glyph *ebiten.Image) }
Face provides an interace to the font properties.
type FaceWithBackup ¶
FaceWithBackup allows a font be the 'backup' for another font, if the primary font doesn't have the right runes. Implements Face
type FaceWithOnlyRunes ¶
FaceWithOnlyRunes limits the font to only the specified runes.
type FaceWithRuneMapping ¶
FaceWithRuneMapping applies a rune mapping to a font. Implements Face
type FaceWithStyle ¶
FaceWithStyle has alternate fonts for bold or italic styles.
FontStyleNormal must be mapped to a valid face. Implements Face
func (*FaceWithStyle) Empty ¶
func (fm *FaceWithStyle) Empty() (glyph *ebiten.Image)
Empty returns the empty glyph
func (*FaceWithStyle) Glyph ¶
func (fm *FaceWithStyle) Glyph(character rune, style FontStyle) (glyph *ebiten.Image, is_empty bool)
Glyph returns the image for the rune, using the appropriate style font. FontStyleBoldItalic falls back to FontStyleBold FontStyleItalic falls back to FontStyleNormal FontStyleBold falls back to FontStyleNormal
FontStyleNormal must be mapped.
Style hints are passed unchanged to the underlying font.
func (*FaceWithStyle) Metrics ¶
func (fm *FaceWithStyle) Metrics() ebiten_text.Metrics
Metrics returns the font metrics.
func (*FaceWithStyle) Size ¶
func (fm *FaceWithStyle) Size() (width, height int)
Size returns the font size.
type MonoFont ¶
type MonoFont struct { CacheFont Face ebiten_text.Face // contains filtered or unexported fields }
Implements Face
func NewMonoFont ¶
NewMonoFont() creates a new monospaced font face. Takes any of the following types:
- image_font.Face
- ebiten_text.Face
- nil (assumes GoMono TTF, size 11)
func NewMonoFontFromTTF ¶
NewMonoFontFromTTF creates a new monospaced font face from a TTF font. Takes any of the following types: - io.Reader (to a TTF source) - []byte (of a TTF blob) - nil (assumes GoMono TTF)