layout

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: BSD-3-Clause Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package layout lays out paragraphs: it turns the styled text of a ui.ParagraphBuilder into lines of shaped glyphs with go-text. The steps are those of SPEC §10:

  1. the text is split into runs by bidi level, script, style and font (with fallback through text.Collection);
  2. the runs are shaped with HarfBuzz;
  3. the lines are broken (UAX #14) honoring the width, the maximum number of lines and the ellipsis;
  4. each line is reordered for bidi;
  5. the text is aligned and justified, and the lines take their height from the fonts, the style heights and the strut;
  6. the metrics (baselines, line metrics, intrinsic widths) are computed.

Offsets into the text are UTF-8 byte offsets (SPEC §12.10).

Flutter: engine/src/flutter/third_party/txt (libtxt) and Skia's skparagraph module

Index

Constants

View Source
const DoubleDecorationSpacing = 3.0

DoubleDecorationSpacing is the distance between the two lines of a double decoration.

Flutter: engine/src/flutter/third_party/skia/modules/skparagraph/src/Decorations.cpp kDoubleDecorationSpacing

Variables

This section is empty.

Functions

This section is empty.

Types

type DecorationSegment

type DecorationSegment struct {
	// Line is the line the segment is on.
	Line int
	// Kind is one of TextDecorationUnderline, TextDecorationOverline and TextDecorationLineThrough.
	Kind ui.TextDecoration
	// Style is how the line is drawn: solid, double, dotted, dashed or wavy.
	Style ui.TextDecorationStyle
	// Color is the color of the line.
	Color ui.Color
	// X0 and X1 are the horizontal extent of the line.
	X0, X1 float64
	// Y is the vertical center of the line (of the first line, for a double decoration).
	Y float64
	// Thickness is the thickness of the line.
	Thickness float64
	// FontSize is the size of the font of the text, for the shape of dotted, dashed and wavy lines.
	FontSize float64
}

DecorationSegment is one line of a text decoration: an underline, an overline or a line through a stretch of text of one style on one line, ready to draw. The positions are in paragraph coordinates.

Flutter: engine/src/flutter/third_party/skia/modules/skparagraph/src/Decorations.cpp Decorations

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the text engine: it makes paragraphs from the fonts of a text.Collection. It implements ui.ParagraphFactory. An Engine and its paragraphs are for the UI thread only (SPEC §13).

Flutter: engine/src/flutter/lib/ui/text/paragraph_builder.cc ParagraphBuilder

func NewEngine

func NewEngine(ctx context.Context, fonts *text.Collection, opts ...EngineOpts) *Engine

NewEngine makes a text engine over a font collection. ctx bounds the loading of font files, which happens while a paragraph is built. More than one options value panics with MultipleOptions.

Flutter: no counterpart

func (*Engine) BuildParagraph

func (e *Engine) BuildParagraph(c *ui.ParagraphContent) ui.ParagraphLayout

BuildParagraph shapes the content (ui.ParagraphFactory). The result is laid out at once with an infinite width, so that the intrinsic widths are known; Layout lays it out for a width.

type EngineOpts

type EngineOpts struct {
	// OnFontError, when not nil, receives the problems with finding or loading a
	// font; the layout goes on with the next font.
	OnFontError func(error)
}

EngineOpts are the optional parameters of NewEngine.

Flutter: no counterpart

Jump to

Keyboard shortcuts

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