Documentation ¶
Index ¶
- Variables
- func CanBreakText(t []rune) pr.MaybeBool
- func ChWidth(style pr.StyleAccessor, fontSize pr.Float, context TextLayoutContext, ...) pr.Float
- func ExRatio(style pr.ElementStyle, context TextLayoutContext) pr.Float
- func GetLastWordEnd(t []rune) int
- func PangoUnitsFromFloat(v pr.Fl) int32
- func PangoUnitsToFloat(v pango.Unit) pr.Fl
- func StrutLayout(style pr.StyleAccessor, context TextLayoutContext) [2]pr.Float
- type FontConfiguration
- type HyphenDictKey
- type Splitted
- type StrutLayoutKey
- type TextLayout
- type TextLayoutContext
Constants ¶
This section is empty.
Variables ¶
var ( FONTCONFIG_WEIGHT = map[pr.IntString]string{ {String: "normal"}: "regular", {String: "bold"}: "bold", {Int: 100}: "thin", {Int: 200}: "extralight", {Int: 300}: "light", {Int: 400}: "regular", {Int: 500}: "medium", {Int: 600}: "demibold", {Int: 700}: "bold", {Int: 800}: "extrabold", {Int: 900}: "black", } FONTCONFIG_STYLE = map[pr.String]string{ "normal": "roman", "italic": "italic", "oblique": "oblique", } FONTCONFIG_STRETCH = map[pr.String]string{ "normal": "normal", "ultra-condensed": "ultracondensed", "extra-condensed": "extracondensed", "condensed": "condensed", "semi-condensed": "semicondensed", "semi-expanded": "semiexpanded", "expanded": "expanded", "extra-expanded": "extraexpanded", "ultra-expanded": "ultraexpanded", } )
Fontconfig features
Functions ¶
func CanBreakText ¶
func ChWidth ¶
func ChWidth(style pr.StyleAccessor, fontSize pr.Float, context TextLayoutContext, letterSpacing pr.Value) pr.Float
ChWidth returns the logical width of the "0" text, without querying WordSpacing or LetterSpacing from the style, so that is may be used to compute these style properties.
func ExRatio ¶
func ExRatio(style pr.ElementStyle, context TextLayoutContext) pr.Float
ExRatio returns the ratio 1ex/font_size, according to given style. It should be used with a valid text context to get accurate result. Otherwise, if context is `nil`, it returns 1 as a default value. It does not query WordSpacing or LetterSpacing from the style.
func GetLastWordEnd ¶
GetLastWordEnd returns the index in `t` if the last word, or -1
func PangoUnitsFromFloat ¶
func StrutLayout ¶
func StrutLayout(style pr.StyleAccessor, context TextLayoutContext) [2]pr.Float
StrutLayout returns a tuple of the used value of `line-height` and the baseline. The baseline is given from the top edge of line height. `context` is mandatory for the text layout.
Types ¶
type FontConfiguration ¶
type FontConfiguration struct { Fontmap *fcfonts.FontMap // contains filtered or unexported fields }
FontConfiguration holds information about the available fonts on the system. It is used for text layout at various steps of the process.
func NewFontConfiguration ¶
func NewFontConfiguration(fontmap *fcfonts.FontMap) *FontConfiguration
NewFontConfiguration uses a fontconfig database to create a new font configuration
func (*FontConfiguration) AddFontFace ¶
func (f *FontConfiguration) AddFontFace(ruleDescriptors validation.FontFaceDescriptors, urlFetcher utils.UrlFetcher) string
func (*FontConfiguration) FontContent ¶
func (f *FontConfiguration) FontContent(faceID fonts.FaceID) []byte
FontContent returns the content of the given face, which may be needed in the final output.
func (*FontConfiguration) LoadFace ¶
func (f *FontConfiguration) LoadFace(key fonts.FaceID, format fc.FontFormat) (fonts.Face, error)
type HyphenDictKey ¶
type HyphenDictKey struct {
// contains filtered or unexported fields
}
type Splitted ¶
type Splitted struct { // pango Layout with the first line Layout *TextLayout // length in runes of the first line Length int // the number of runes to skip for the next line. // May be -1 if the whole text fits in one line. // This may be greater than `Length` in case of preserved // newline characters. ResumeAt int // width in pixels of the first line Width pr.Float // height in pixels of the first line Height pr.Float // baseline in pixels of the first line Baseline pr.Float }
Splitted exposes the result of laying out one line of text
func SplitFirstLine ¶
func SplitFirstLine(text_ string, style pr.StyleAccessor, context TextLayoutContext, maxWidth pr.MaybeFloat, justificationSpacing pr.Float, minimum, isLineStart bool) Splitted
Fit as much as possible in the available width for one line of text. minimum=False
type StrutLayoutKey ¶
type StrutLayoutKey struct {
// contains filtered or unexported fields
}
type TextLayout ¶
type TextLayout struct { Style pr.StyleAccessor Metrics *pango.FontMetrics // optional MaxWidth pr.MaybeFloat Context TextLayoutContext // will be a *LayoutContext; to avoid circular dependency Layout pango.Layout JustificationSpacing pr.Fl FirstLineDirection pango.Direction }
TextLayout wraps a pango.Layout object
func CreateLayout ¶
func CreateLayout(text string, style pr.StyleAccessor, context TextLayoutContext, maxWidth pr.MaybeFloat, justificationSpacing pr.Float) *TextLayout
CreateLayout returns a pango.Layout with default Pango line-breaks. `style` is a style dict of computed values. `maxWidth` is the maximum available width in the same unit as style.GetFontSize(), or `nil` for unlimited width.
func NewTextLayout ¶
func NewTextLayout(context TextLayoutContext, fontSize pr.Fl, style pr.StyleAccessor, justificationSpacing pr.Fl, maxWidth pr.MaybeFloat) *TextLayout
func (*TextLayout) ApplyJustification ¶
func (p *TextLayout) ApplyJustification()
ApplyJustification re-layout the text, applying justification.
func (*TextLayout) GetFirstLine ¶
func (p *TextLayout) GetFirstLine() (*pango.LayoutLine, int)
GetFirstLine returns the first line and the index of the second line, or -1.
func (*TextLayout) SetText ¶
func (p *TextLayout) SetText(text string)
type TextLayoutContext ¶
type TextLayoutContext interface { Fonts() *FontConfiguration HyphenCache() map[HyphenDictKey]hyphen.Hyphener StrutLayoutsCache() map[StrutLayoutKey][2]pr.Float }
Directories ¶
Path | Synopsis |
---|---|
Package draw use a backend and a layout object to draw glyphs on the ouput.
|
Package draw use a backend and a layout object to draw glyphs on the ouput. |
Package hyphen hyphenates text using existing Hunspell hyphenation dictionaries.
|
Package hyphen hyphenates text using existing Hunspell hyphenation dictionaries. |