pango

package
v0.0.0-...-1143ee3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pango provides a type-safe way to construct pango markup. Using nested Span and Text nodes, pango formatted output can be easily constructed with compile-time validation of nesting and automatic escaping.

For example, to construct pango markup for:

<span color="#ff0000">Red <span weight="bold">Bold Text</span></span>

the go code would be:

pango.Span(
  colors.Hex("#ff0000"),
  "Red ",
  pango.Span(
    pango.Weight("bold"),
    "Bold Text",
  ),
)

Index

Constants

This section is empty.

Variables

View Source
var (
	XXSmall Attribute = size("xx-small")
	XSmall            = size("x-small")
	Small             = size("small")
	Medium            = size("medium")
	Large             = size("large")
	XLarge            = size("x-large")
	XXLarge           = size("xx-large")

	Smaller = size("smaller")
	Larger  = size("larger")
)

Keyword sizes supported in Pango.

View Source
var (
	StyleNormal Attribute = style("normal")
	Oblique               = style("oblique")
	Italic                = style("italic")
)

Font styles supported in Pango.

View Source
var (
	Ultralight   Attribute = weight("ultralight")
	Light                  = weight("light")
	WeightNormal           = weight("normal")
	Bold                   = weight("bold")
	UltraBold              = weight("ultrabold")
	Heavy                  = weight("heavy")
)

Keyword weights supported in Pango.

View Source
var (
	StretchNormal  Attribute = stretch("normal")
	UltraCondensed           = stretch("ultracondensed")
	ExtraCondensed           = stretch("extracondensed")
	Condensed                = stretch("condensed")
	SemiCondensed            = stretch("semicondensed")
	SemiExpanded             = stretch("semiexpanded")
	Expanded                 = stretch("expanded")
	ExtraExpanded            = stretch("extraexpanded")
	UltraExpanded            = stretch("ultraexpanded")
)

Pango font stretch keywords.

View Source
var (
	UnderlineNone   Attribute = underline("none")
	UnderlineSingle           = underline("single")
	UnderlineDouble           = underline("double")
	UnderlineLow              = underline("low")
	UnderlineError            = underline("error")
)

Pango underline keywords.

Functions

This section is empty.

Types

type Alpha

type Alpha float64

Alpha sets the foreground opacity on a scale of 0 to 1.

func (Alpha) AttrName

func (a Alpha) AttrName() string

AttrName returns the name of the pango 'alpha' attribute.

func (Alpha) AttrValue

func (a Alpha) AttrValue() string

AttrValue returns the fg alpha as a pango 'alpha' value.

type Attribute

type Attribute interface {
	AttrName() string
	AttrValue() string
}

Attribute represents a pango attribute name and value.

var (
	VariantNormal Attribute = variant("normal")
	SmallCaps               = variant("smallcaps")
)

Pango font variants.

var (
	Strikethrough   Attribute = strikethrough(true)
	NoStrikethrough           = strikethrough(false)
)

Whether to strike through the text.

type Background

type Background bar.Color

Background wraps a bar color but applies it as a background instead of the foreground.

func (Background) AttrName

func (b Background) AttrName() string

AttrName returns the name of the pango 'background' attribute.

func (Background) AttrValue

func (b Background) AttrValue() string

AttrValue delegates to bar.Color to return the pango color value.

type BgAlpha

type BgAlpha float64

BgAlpha sets the background opacity on a scale of 0 to 1.

func (BgAlpha) AttrName

func (b BgAlpha) AttrName() string

AttrName returns the name of the pango 'background_alpha' attribute.

func (BgAlpha) AttrValue

func (b BgAlpha) AttrValue() string

AttrValue returns the bg alpha as a pango 'background_alpha' value.

type Font

type Font string

Font sets the font face.

func (Font) AttrName

func (f Font) AttrName() string

AttrName returns the name of the pango 'face' attribute.

func (Font) AttrValue

func (f Font) AttrValue() string

AttrValue returns the font as a pango 'face' value.

type LetterSpacing

type LetterSpacing float64

LetterSpacing sets the letter spacing, in points.

func (LetterSpacing) AttrName

func (l LetterSpacing) AttrName() string

AttrName returns the name of the pango 'letter_spacing' attribute.

func (LetterSpacing) AttrValue

func (l LetterSpacing) AttrValue() string

AttrValue returns the letter spacing as a pango 'letter_spacing' value.

type Node

type Node interface {
	// Pango returns a pango-formatted version of the element.
	Pango() string
}

Node represents nodes in a pango "document".

func Span

func Span(things ...interface{}) Node

Span constructs a new span with the given attributes and segments.

func Tag

func Tag(tagName string, things ...interface{}) Node

Tag constructs a pango element with the given name, with any children and/or attributes. The interface varargs are used as below:

  • A pango.Attribute is added to the tag directly
  • A pango.Element is added as a child node
  • Any other object is added as a text node using the %v format.

func Textf

func Textf(format string, args ...interface{}) Node

Textf constructs a text node by interpolating arguments. Note that it will escape both the format string and arguments, so you should use pango constructs to add formatting. i.e.,

Textf("<span color='%s'>%s</span>", "red", "text")

won't give you red text.

type Rise

type Rise int

Rise sets the font "rise" in pango units. Negative for subscript, positive for superscript.

func (Rise) AttrName

func (r Rise) AttrName() string

AttrName returns the name of the pango 'rise' attribute.

func (Rise) AttrValue

func (r Rise) AttrValue() string

AttrValue returns the rise as a pango 'rise' value.

type Size

type Size float64

Size sets the font size, in points.

func (Size) AttrName

func (s Size) AttrName() string

AttrName returns the name of the pango 'size' attribute.

func (Size) AttrValue

func (s Size) AttrValue() string

AttrValue returns the font size as a pango 'size' value.

type StrikethroughColor

type StrikethroughColor bar.Color

StrikethroughColor wraps a bar color but applies it as the strikethrough color instead of the foreground.

func (StrikethroughColor) AttrName

func (s StrikethroughColor) AttrName() string

AttrName returns the name of the pango 'strikethrough_color' attribute.

func (StrikethroughColor) AttrValue

func (s StrikethroughColor) AttrValue() string

AttrValue delegates to bar.Color to return the pango color value.

type Text

type Text string

Text represents a plaintext section of text.

func (Text) Pango

func (t Text) Pango() string

Pango returns html-escaped text.

type UnderlineColor

type UnderlineColor bar.Color

UnderlineColor wraps a bar color but applies it as the underline color instead of the foreground.

func (UnderlineColor) AttrName

func (u UnderlineColor) AttrName() string

AttrName returns the name of the pango 'underline_color' attribute.

func (UnderlineColor) AttrValue

func (u UnderlineColor) AttrValue() string

AttrValue delegates to bar.Color to return the pango color value.

type Weight

type Weight int

Weight sets the font weight in numeric form.

func (Weight) AttrName

func (w Weight) AttrName() string

AttrName returns the name of the pango 'weight' attribute.

func (Weight) AttrValue

func (w Weight) AttrValue() string

AttrValue returns the weight as a pango 'weight' value.

Directories

Path Synopsis
Package icons provides an interface for using icon fonts in a bar.
Package icons provides an interface for using icon fonts in a bar.
fontawesome
Package fontawesome provides support for FontAwesome Icons from https://github.com/FortAwesome/Font-Awesome
Package fontawesome provides support for FontAwesome Icons from https://github.com/FortAwesome/Font-Awesome
ionicons
Package ionicons provides support for Ionicicons from https://github.com/driftyco/ionicons
Package ionicons provides support for Ionicicons from https://github.com/driftyco/ionicons
material
Package material provides support for Google's Material Design Icons from https://github.com/google/material-design-icons
Package material provides support for Google's Material Design Icons from https://github.com/google/material-design-icons
material_community
Package materialCommunity provides support for the community fork "Material Design Icons" from https://materialdesignicons.com/
Package materialCommunity provides support for the community fork "Material Design Icons" from https://materialdesignicons.com/
typicons
Package typicons provides support for Typicons from https://github.com/stephenhutchings/typicons.font
Package typicons provides support for Typicons from https://github.com/stephenhutchings/typicons.font

Jump to

Keyboard shortcuts

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