Documentation ¶
Index ¶
- Constants
- Variables
- func EmbeddingLevels(str []rune) []int
- func IsNewline(r rune) bool
- func IsParagraphSeparator(r rune) bool
- func IsSpace(r rune) bool
- func IsSpacelessScript(script Script) bool
- func IsVerticalScript(script Script) bool
- func LinebreakGlyphs(sfnt *font.SFNT, size float64, glyphs []Glyph, indent, width float64, ...) [][]Glyph
- type Align
- type Breakpoint
- type Breakpoints
- type Direction
- type Glyph
- type Item
- type Rotation
- type Script
- type ScriptItem
- type Shaper
- type Type
Constants ¶
const ( DirectionInvalid Direction = 0 LeftToRight = Direction(harfbuzz.LeftToRight) RightToLeft = Direction(harfbuzz.RightToLeft) TopToBottom = Direction(harfbuzz.TopToBottom) BottomToTop = Direction(harfbuzz.BottomToTop) )
see Direction
const ( ScriptInvalid Script = 0 ScriptCommon = Script(language.Common) ScriptInherited = Script(language.Inherited) ScriptUnknown = Script(language.Unknown) Arabic = Script(language.Arabic) Armenian = Script(language.Armenian) Bengali = Script(language.Bengali) Cyrillic = Script(language.Cyrillic) Devanagari = Script(language.Devanagari) Georgian = Script(language.Georgian) Greek = Script(language.Greek) Gujarati = Script(language.Gujarati) Gurmukhi = Script(language.Gurmukhi) Hangul = Script(language.Hangul) Han = Script(language.Han) Hebrew = Script(language.Hebrew) Hiragana = Script(language.Hiragana) Kannada = Script(language.Kannada) Katakana = Script(language.Katakana) Lao = Script(language.Lao) Latin = Script(language.Latin) Malayalam = Script(language.Malayalam) Oriya = Script(language.Oriya) Tamil = Script(language.Tamil) Telugu = Script(language.Telugu) Thai = Script(language.Thai) Tibetan = Script(language.Tibetan) Bopomofo = Script(language.Bopomofo) Braille = Script(language.Braille) CanadianSyllabics = Script(language.Canadian_Aboriginal) Cherokee = Script(language.Cherokee) Ethiopic = Script(language.Ethiopic) Khmer = Script(language.Khmer) Mongolian = Script(language.Mongolian) Myanmar = Script(language.Myanmar) Ogham = Script(language.Ogham) Runic = Script(language.Runic) Sinhala = Script(language.Sinhala) Syriac = Script(language.Syriac) Thaana = Script(language.Thaana) Yi = Script(language.Yi) Deseret = Script(language.Deseret) Gothic = Script(language.Gothic) OldItalic = Script(language.Old_Italic) Buhid = Script(language.Buhid) Hanunoo = Script(language.Hanunoo) Tagalog = Script(language.Tagalog) Tagbanwa = Script(language.Tagbanwa) Cypriot = Script(language.Cypriot) Limbu = Script(language.Limbu) LinearB = Script(language.Linear_B) Osmanya = Script(language.Osmanya) Shavian = Script(language.Shavian) TaiLe = Script(language.Tai_Le) Ugaritic = Script(language.Ugaritic) Buginese = Script(language.Buginese) Coptic = Script(language.Coptic) Glagolitic = Script(language.Glagolitic) Kharoshthi = Script(language.Kharoshthi) NewTaiLue = Script(language.New_Tai_Lue) OldPersian = Script(language.Old_Persian) SylotiNagri = Script(language.Syloti_Nagri) Tifinagh = Script(language.Tifinagh) Balinese = Script(language.Balinese) Cuneiform = Script(language.Cuneiform) Nko = Script(language.Nko) PhagsPa = Script(language.Phags_Pa) Phoenician = Script(language.Phoenician) Carian = Script(language.Carian) Cham = Script(language.Cham) KayahLi = Script(language.Kayah_Li) Lepcha = Script(language.Lepcha) Lycian = Script(language.Lycian) Lydian = Script(language.Lydian) OlChiki = Script(language.Ol_Chiki) Rejang = Script(language.Rejang) Saurashtra = Script(language.Saurashtra) Sundanese = Script(language.Sundanese) Vai = Script(language.Vai) Avestan = Script(language.Avestan) Bamum = Script(language.Bamum) EgyptianHieroglyphs = Script(language.Egyptian_Hieroglyphs) ImperialAramaic = Script(language.Imperial_Aramaic) InscriptionalPahlavi = Script(language.Inscriptional_Pahlavi) InscriptionalParthian = Script(language.Inscriptional_Parthian) Javanese = Script(language.Javanese) Kaithi = Script(language.Kaithi) Lisu = Script(language.Lisu) MeeteiMayek = Script(language.Meetei_Mayek) OldSouthArabian = Script(language.Old_South_Arabian) OldTurkic = Script(language.Old_Turkic) Samaritan = Script(language.Samaritan) TaiTham = Script(language.Tai_Tham) TaiViet = Script(language.Tai_Viet) Batak = Script(language.Batak) Brahmi = Script(language.Brahmi) Mandaic = Script(language.Mandaic) Chakma = Script(language.Chakma) MeroiticCursive = Script(language.Meroitic_Cursive) MeroiticHieroglyphs = Script(language.Meroitic_Hieroglyphs) Miao = Script(language.Miao) Sharada = Script(language.Sharada) SoraSompeng = Script(language.Sora_Sompeng) Takri = Script(language.Takri) BassaVah = Script(language.Bassa_Vah) CaucasianAlbanian = Script(language.Caucasian_Albanian) Duployan = Script(language.Duployan) Elbasan = Script(language.Elbasan) Grantha = Script(language.Grantha) Khojki = Script(language.Khojki) Khudawadi = Script(language.Khudawadi) LinearA = Script(language.Linear_A) Mahajani = Script(language.Mahajani) Manichaean = Script(language.Manichaean) MendeKikakui = Script(language.Mende_Kikakui) Modi = Script(language.Modi) Mro = Script(language.Mro) Nabataean = Script(language.Nabataean) OldNorthArabian = Script(language.Old_North_Arabian) OldPermic = Script(language.Old_Permic) PahawhHmong = Script(language.Pahawh_Hmong) Palmyrene = Script(language.Palmyrene) PauCinHau = Script(language.Pau_Cin_Hau) PsalterPahlavi = Script(language.Psalter_Pahlavi) Siddham = Script(language.Siddham) Tirhuta = Script(language.Tirhuta) WarangCiti = Script(language.Warang_Citi) Adlam = Script(language.Adlam) Bhaiksuki = Script(language.Bhaiksuki) Marchen = Script(language.Marchen) Osage = Script(language.Osage) Tangut = Script(language.Tangut) Newa = Script(language.Newa) MasaramGondi = Script(language.Masaram_Gondi) Nushu = Script(language.Nushu) Soyombo = Script(language.Soyombo) ZanabazarSquare = Script(language.Zanabazar_Square) Dogra = Script(language.Dogra) GunjalaGondi = Script(language.Gunjala_Gondi) HanifiRohingya = Script(language.Hanifi_Rohingya) Makasar = Script(language.Makasar) Medefaidrin = Script(language.Medefaidrin) OldSogdian = Script(language.Old_Sogdian) Sogdian = Script(language.Sogdian) Elymaic = Script(language.Elymaic) Nandinagari = Script(language.Nandinagari) NyiakengPuachueHmong = Script(language.Nyiakeng_Puachue_Hmong) Wancho = Script(language.Wancho) Chorasmian = Script(language.Chorasmian) DivesAkuru = Script(language.Dives_Akuru) KhitanSmallScript = Script(language.Khitan_Small_Script) Yezidi = Script(language.Yezidi) )
see Script
const FairyTales = "" /* 678-byte string literal not displayed */
FairyTales is an example text.
Variables ¶
var ( SentenceFactor = 3.0 ColonFactor = 2.0 SemicolonFactor = 1.5 CommaFactor = 1.25 )
Stretchability and shrinkability factors for inter-sentence and other types of spaces, not used if FrenchSpacing is set.
var DemeritsFitness = 100.0
DemeritsFitness is the badness rating for very different fitness ratings for consecutive lines. Fitness is a categorization of four types for ratio ranges.
var DemeritsFlagged = 100.0
DemeritsFlagged is the badness rating for two consecutive lines ending in hyphens.
var DemeritsLine = 10.0
DemeritsLine is the badness rating for an extra line.
var FrenchSpacing = false
FrenchSpacing enforces equal widths for inter-word and inter-sentence spaces.
var HyphenPenalty = 50.0
HyphenPenalty is the aesthetic cost of ending a line in a hyphen.
var Infinity = 1000.0 // in case of ratio, demerits become about 1e22
Infinity specifies infinity as something finite to prevent numerical errors.
var SpaceShrink = 1.0 / 3.0
SpaceShrink is the shrinkability of spaces.
var SpaceStretch = 1.0 / 2.0
SpaceStretch is the stretchability of spaces.
var Tolerance = 2.0
Tolerance is the maximum stretchability of the spaces of a line.
Functions ¶
func EmbeddingLevels ¶
EmbeddingLevels returns the embedding levels for each rune of a mixed LTR/RTL string. A change in level means a change in direction.
func IsParagraphSeparator ¶
IsParagraphSeparator returns true for paragraph separator runes.
func IsSpacelessScript ¶
func IsVerticalScript ¶
func LinebreakGlyphs ¶
func LinebreakGlyphs(sfnt *font.SFNT, size float64, glyphs []Glyph, indent, width float64, align Align, looseness int) [][]Glyph
LinebreakGlyphs breaks a slice of glyphs uing the given SFNT font and font size. The indent and width specify the first line's indentation and the maximum line's width respectively. Align sets the horizontal alignment of the text. The looseness specifies whether it is desirable to have less or more lines than optimal.
Types ¶
type Breakpoint ¶
type Breakpoint struct { Position int Line int Fitness int Width float64 W, Y, Z float64 Ratio float64 Demerits float64 // contains filtered or unexported fields }
Breakpoint is a (possible) break point in the string.
func Linebreak ¶
func Linebreak(items []Item, width float64, looseness int) ([]*Breakpoint, bool)
Linebreak breaks a list of items using Donald Knuth's line breaking algorithm. See Donald E. Knuth and Michael F. Plass, "Breaking Paragraphs into Lines", 1981
func (*Breakpoint) String ¶
func (br *Breakpoint) String() string
type Breakpoints ¶
type Breakpoints struct {
// contains filtered or unexported fields
}
Breakpoints is a list of break points.
func (*Breakpoints) Has ¶
func (list *Breakpoints) Has(b *Breakpoint) bool
Has return true if it contains break point b.
func (*Breakpoints) InsertBefore ¶
func (list *Breakpoints) InsertBefore(b *Breakpoint, at *Breakpoint)
InsertBefore inserts break point b before at.
func (*Breakpoints) Push ¶
func (list *Breakpoints) Push(b *Breakpoint)
Push adds break point b to the end of the list.
func (*Breakpoints) Remove ¶
func (list *Breakpoints) Remove(b *Breakpoint)
Remove removes break point b.
func (*Breakpoints) String ¶
func (list *Breakpoints) String() string
type Glyph ¶
type Glyph struct { SFNT *font.SFNT Size float64 Script Vertical bool // is false for Latin/Mongolian/etc in a vertical layout ID uint16 Cluster uint32 XAdvance int32 YAdvance int32 XOffset int32 YOffset int32 Text rune }
Glyph is a shaped glyph for the given font and font size. It specified the glyph ID, the cluster ID, its X and Y advance and offset in font units, and its representation as text.
type Item ¶
type Item struct { Type Width, Stretch, Shrink float64 Penalty float64 Flagged bool Size int // number of boxes (glyphs) compressed into one }
Item is a box, glue or penalty item.
func Glue ¶
Glue returns a glue item where width is the default width, stretch*Tolerance the maximum width, and shrink*Tolerance the minimum width.
func GlyphsToItems ¶
GlyphsToItems converts a slice of glyphs into the box/glue/penalty items model as used by Knuth's line breaking algorithm. The SFNT and Size of each glyph must be set. Indent and align specify the indentation width of the first line and the alignment (left, right, centered, justified) of the lines respectively.
type ScriptItem ¶
func ScriptItemizer ¶
func ScriptItemizer(runes []rune, embeddingLevels []int) []ScriptItem
ScriptItemizer divides the string in parts for each different script. Also separates on different embedding levels and runs of U+FFFC (object replacement characters)