di

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause, Unlicense Imports: 1 Imported by: 17

README

di

di is a library that converts bi-directional text into uni-directional text

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis bool

Axis indicates the axis of layout for a piece of text.

const (
	Horizontal Axis = false
	Vertical   Axis = true
)

type Direction

type Direction uint8

Direction indicates the layout direction of a piece of text.

const (
	// DirectionLTR is for Left-to-Right text.
	DirectionLTR Direction = iota
	// DirectionRTL is for Right-to-Left text.
	DirectionRTL
	// DirectionTTB is for Top-to-Bottom text.
	DirectionTTB
	// DirectionBTT is for Bottom-to-Top text.
	DirectionBTT
)

func (Direction) Axis

func (d Direction) Axis() Axis

Axis returns the layout axis for d.

func (Direction) Harfbuzz

func (d Direction) Harfbuzz() harfbuzz.Direction

Harfbuzz returns the equivalent direction used by harfbuzz.

func (Direction) HasVerticalOrientation

func (d Direction) HasVerticalOrientation() bool

HasVerticalOrientation returns true if the direction has set up an orientation for vertical text (typically using [SetSideways] or [SetUpright])

func (Direction) IsSideways

func (d Direction) IsSideways() bool

IsSideways returns true if the direction is vertical with a 'sideways' orientation.

When shaping vertical text, 'sideways' means that the glyphs are rotated by 90°, clock-wise. This flag should be used by renderers to properly rotate the glyphs when drawing.

func (Direction) IsVertical

func (d Direction) IsVertical() bool

IsVertical returns whether d is laid out on a vertical axis. If the return value is false, d is on the horizontal axis.

func (Direction) Progression

func (d Direction) Progression() Progression

Progression returns the text layout progression for d.

func (*Direction) SetProgression

func (d *Direction) SetProgression(p Progression)

SetProgression sets the progression, preserving the others bits.

func (*Direction) SetSideways

func (d *Direction) SetSideways(sideways bool)

SetSideways makes d vertical with 'sideways' or 'upright' orientation, preserving only the progression.

func (Direction) SwitchAxis

func (d Direction) SwitchAxis() Direction

SwitchAxis switches from horizontal to vertical (and vice versa), preserving the progression.

type Progression

type Progression bool

Progression indicates how text is read within its Axis relative to the top left corner.

const (
	// FromTopLeft indicates text in which a reader starts reading
	// at the top left corner of the text and moves away from it.
	// DirectionLTR and DirectionTTB are examples of FromTopLeft
	// Progression.
	FromTopLeft Progression = false
	// TowardTopLeft indicates text in which a reader starts reading
	// at the opposite end of the text's Axis from the top left corner
	// and moves towards it. DirectionRTL and DirectionBTT are examples
	// of TowardTopLeft progression.
	TowardTopLeft Progression = true
)

Jump to

Keyboard shortcuts

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