Documentation ¶
Index ¶
Constants ¶
const EmbeddedFontsDir = "fonts"
EmbeddedFontsDir is the directory in the embedded file system holding the embedded fonts.
Variables ¶
var ( // FaceDflt is the font face of a zero giorune.Font and is set in // giorune.init. FaceDflt *font.Face // SizeDflt is a zero giorune.Font's size. SizeDflt = 14 )
var ( Black = color.NRGBA{A: 255} Red = color.NRGBA{R: 255, A: 255} Green = color.NRGBA{G: 255, A: 255} Blue = color.NRGBA{B: 255, A: 255} Yellow = color.NRGBA{R: 255, G: 255, A: 255} Magenta = color.NRGBA{R: 255, B: 255, A: 255} Cyan = color.NRGBA{G: 255, B: 255, A: 255} White = color.NRGBA{R: 255, G: 255, B: 255, A: 255} )
var ErrFaceNotFound = errors.New("view: select face: not found")
ErrFaceNotFound is returned by Faces.SelectFace if no font with given arguments can be found.
var FontsFS embed.FS
Functions ¶
func NewFontLibForEmbedded ¶
NewFontLibForEmbedded returns an implementation of [view.FontLib] with an adapted [FontLib.ReadDir] method which operates on embedded [view.FontsFS] which has always slashes as directory separator no matter which os.
Types ¶
type Faces ¶
type Faces map[*font.Face]metadata.Description
A Faces instance holds open-type font-faces and their description.
var Embedded Faces
Embedded are the font-faces along with their descriptions which are embedded with this package. The Embedded font-faces are set by this package's init function.
func ReadFontsDir ¶
ReadFontsDir utilizes given font-lib lib to read from given directory d all *.ttf files and parses them into returned faces. Note to read fonts of embedded file system provide giorune.NewFontLibForEmbedded otherwise lib may be nil because its default-implementation will do.
func (Faces) SelectFace ¶
func (ff Faces) SelectFace( family string, weight metadata.Weight, style metadata.Style, ) (*font.Face, error)
SelectFace returns the first face which matches all three of the given font family its given weight and style. If no font with given Arguments is found an ErrFaceNotFound-error is returned.
type Font ¶
type Font struct { Lib FontLib // Face wrapping the actual font and is used to shape the runes. // Face defaults to FaceDflt. A change in face clears the font's // caches. Face *font.Face // Size of the font. Size defaults to SizeDflt. A change in size // clears the font's caches. Size int // Metric provides the device dependent density-independent and // scale-independent pixels per dp/sp; These values default to 1 and // are typically set from a gio FrameEvent. An change in metric // clears the font's caches. Metric unit.Metric // contains filtered or unexported fields }
A Font is the starting point to layout or paint a given rune respectively its glyph in set font face. A zero Font is ready to use. A once used font-instance may not be copied. A font's metric you typically set from a [app.FrameEvent]. Note a Font caches layout and painting of a rune respectively its graphical representation as a glyph. This cache is cleared when ever Font.Face, Font.Size or Font.Metric changes.
func Fitting ¶ added in v0.3.0
Fitting returns given Font fnt in the size that given lines ll fit into given dimension dim or the size is 1. Fitting returns nil if one of the given arguments is zero (or less).
func HorizontallyFitting ¶ added in v0.3.0
HorizontallyFitting returns given Font fnt in the size that given strings ss fit into given width or the size is 1. HorizontallyFitting returns nil if one of the given arguments is zero (or less).
func VerticallyFitting ¶ added in v0.3.0
VerticallyFitting returns given Font fnt in the size that given lines ll fit into given height or the size is 1. VerticallyFitting returns nil if one of given arguments is zero (or less).
func (*Font) Center ¶
Center given rune r's dimensions horizontally and vertically within given viewport.
func (*Font) Paint ¶
Paint given rune to given operations stack *to* at given point *at* which is the upper left corner of the runes bounding box. I.e. the point 0/0 would paint given rune on "the beginning" at the "first line".
type FontLib ¶
type FontLib interface { // ReadDir must provide the directory entries of a given directory. ReadDir(string) ([]fs.DirEntry, error) // ReadFile must provide the content of given file. ReadFile(string) ([]byte, error) // NewFont is expected to parse from a given bytes sequence a font // and its meta data. NewFont([]byte) (*font.Font, metadata.Description, error) // Join connects given elements to a returned path. Join(...string) string // Shape maps runes to glyphs. Shape(shaping.Input) shaping.Output }
FontLib provides stdlib/third party lib functionality which may fail or is interesting to adapt/mock for other reasons. Note where ever giorune wants an implementation of FontLib it is optional and defaults to an internal default implementation. Is there a specific implementation needed for a specific use-case there is typically a constructor for that purpose around like giorune.NewFontLibForEmbedded.
type Option ¶
Option is typically a painting option adding what is other places called "material" to a painting operation.
type R ¶
type R struct { HasGlyphs bool Ascent fixed.Int26_6 Descent fixed.Int26_6 shaping.Glyph // contains filtered or unexported fields }
A R-instance holds layout and painting information of a rune's graphical representation relative to a given giorune.Font.
type Sequence ¶
type Sequence struct { // Font used to calculate dimensions of rune sequences and paint // them. Font *Font // contains filtered or unexported fields }
Sequence may be used for layout calculations and paintings of rune sequences. Note as of now only vertical sequence from left to right is supported without ligatures.
func (*Sequence) Center ¶
Center given string dimensions horizontally and vertically within given viewport.
func (*Sequence) Clone ¶ added in v0.2.0
Clone given Sequence s, i.e. returned sequence will have a different harfbuzz shaper instance which might be necessary since it is not concurrency save.
func (*Sequence) Dim ¶
Dim returns the width and height of given rune sequence rr and the biggest ascent. Note if a sequence contains runes with varying baselines the painting of that sequence will probably not turn out as desired.
func (*Sequence) Paint ¶
Paint given rune-sequence rr to given operations list starting at at.X and at.Y+asc whereas the asc the biggest ascent in rr is; i.e. at.Y+asc is interpreted as baseline. I.e. having scriptures with different baselines in rr will most likely not yield the desired result. Given options oo are evaluated before rr is painted.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
giorune/view
Package view provides an api to build a simple graphical user interface through the GUI type, e.g.
|
Package view provides an api to build a simple graphical user interface through the GUI type, e.g. |
giorune/view/internal
Package internal provides functions/types that should be accessible for the testing backend and for the view but not for any one else.
|
Package internal provides functions/types that should be accessible for the testing backend and for the view but not for any one else. |