textrun

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package textrun holds what the renderers of BDF text share: how a string of a FILL_TEXT is put in visual order, where its baseline lies, which families a font reference names, and the bold and italic that are synthesized for a face that has none. The renderers (raster/imagebdf, vector/pdfbdf) draw text the same way with it.

Index

Constants

View Source
const FakeItalicSkew = 0.25

FakeItalicSkew is the slant of synthesized italic (x per unit of height).

Variables

View Source
var GenericFamilies = map[string]string{
	"sans-serif": fontdb.Sans, "serif": fontdb.Serif, "monospace": fontdb.Mono,
	"cursive": fontdb.Sans, "fantasy": fontdb.Sans, "system-ui": fontdb.Sans, "math": fontdb.Serif,
	"ui-sans-serif": fontdb.Sans, "ui-serif": fontdb.Serif, "ui-monospace": fontdb.Mono, "ui-rounded": fontdb.Sans,
}

GenericFamilies maps CSS generic family keywords to the generic families of fontdb.

Functions

func BaselineShift

func BaselineShift(baseline byte, size, asc, dsc float64) float64

BaselineShift is how far below the anchor the alphabetic baseline lies for a textBaseline, from the em box of a face with the ascent asc and the descent dsc in em, both positive (as Blink does).

func FakeBoldWidth

func FakeBoldWidth(size float64) float64

FakeBoldWidth is the outline growth of synthesized bold for a size in device pixels (Skia's interpolation between 1/24 at 9 px and 1/32 at 36 px).

func HasRTL

func HasRTL(s string) bool

HasRTL reports whether a string has right-to-left characters.

func SplitFamilies

func SplitFamilies(list string) []string

SplitFamilies splits a CSS font-family list into names without quotes.

func VisualOrder

func VisualOrder(s string, rtlBase bool) []rune

VisualOrder reorders a string for display: runs of right-to-left characters are reversed, and so is the order of the runs in a right-to-left paragraph. It covers what previews need, not the whole Unicode bidirectional algorithm (no mirroring, no Arabic shaping).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL