Help us shape the future of Go! Take the 2026 Go Developer Survey

theme

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package theme is the look lfm gives every editable file of a product: the faces, colors and typesetting a concept's Look decides, on a quiet base for what it leaves open, the color math its checks need, and the DrawingML theme part Word and PowerPoint read, so a set's documents and decks match.

Index

Constants

This section is empty.

Variables

View Source
var Base = Theme{Base: 10.5, Leading: 1.42, Ratio: 1.25, HeadingBold: true, Table: "booktabs", Ornament: "·",
	Ink: "#1E1F22", Muted: "#5B5F66", Accent: "#1E1F22", Tint: Tint("#1E1F22", 0.92), Stroke: "#C9CCD1"}

Base is the typesetting a Look starts from. It holds no faces and no accent of its own: a concept names its families, and a set without an accent stays in its ink.

View Source
var Variants = map[string]string{
	"base":            "Text font: Lora",
	"indented":        "Text font: Lora\nParagraphs: indented\nHeadings: regular\nText size: 11.5\nLine height: 1.35\nOrnament: ❧\nAccent: #7A2E2E",
	"hairline":        "Text font: Lora\nTables: hairline\nText size: 10\nLine height: 1.45\nHeading scale: 1.2\nAccent: #1F4FD1",
	"monochrome":      "Text font: Lora\nTables: hairline\nText size: 10\nLine height: 1.5\nHeading scale: 1.125",
	"accent-headings": "Text font: Lora\nHeadings: regular\nHeading color: accent\nText size: 11\nLine height: 1.45\nOrnament: ❦\nAccent: #9C4A2C",
	"grid":            "Text font: Lora\nTables: grid\nText size: 10\nLine height: 1.4\nHeading scale: 1.2\nOrnament: ■\nAccent: #2F4A6D",
}

Variants are Looks that between them use every typesetting mechanism a concept decides: lfm's tests build every file format in each. The faces are the test fixtures' own; a product names its families.

Functions

func Contrast

func Contrast(a, b string) float64

Contrast is the WCAG 2.1 contrast ratio of two #rrggbb colors.

func Families added in v0.1.6

func Families(t Theme) []string

Families are the font families a theme sets, each once, text first.

func Half

func Half(pt float64) float64

Half rounds a size to half points, as Word and PowerPoint store sizes.

func Hex

func Hex(c string) string

Hex is a #rrggbb color as OOXML writes it: RRGGBB.

func Shade added in v0.1.6

func Shade(hex string, share float64) string

Shade mixes a color with black: share 0 is the color, 1 black.

func Tint

func Tint(hex string, share float64) string

Tint mixes a color with white: share 0 is the color, 1 white.

Types

type Look

type Look struct {
	TextFont, HeadFont, Accent          string
	Paragraphs, Tables, Headings, Color string // spaced|indented, booktabs|hairline|grid, bold|regular, ink|accent
	TextSize, LineHeight, HeadingScale  float64
	Ornament                            string
}

Look is a concept's Look section: the faces, the accent and whatever typesetting the concept decides; what it leaves out comes from Base.

func ParseLook

func ParseLook(s *concept.Section, add func(line int, message, hint string)) Look

ParseLook reads a concept's Look section; what is wrong goes to add.

func (Look) Resolve

func (l Look) Resolve() Theme

Resolve is the Look on the base: the concept's faces and accent, and its typesetting where it decides any.

type Theme

type Theme struct {
	Text, Heading string  // font families the concept names
	Base          float64 // body size in pt
	Leading       float64 // body line height as a multiple of the size
	Ratio         float64 // heading scale
	Indent        bool    // paragraphs separate by a first-line indent instead of space
	HeadingBold   bool
	HeadingAccent bool   // headings take the accent; otherwise the ink
	Table         string // booktabs, hairline or grid
	Ornament      string // the section break glyph
	Ink, Muted    string
	Accent, Tint  string
	Stroke        string // hairlines and table rules
}

Theme is the look of every editable file of a product: the tokens a concept's Look decides and the compiler turns into Word and PowerPoint styles, so the documents of a set match and nothing is formatted by hand.

func (Theme) ColorProblems

func (m Theme) ColorProblems() []string

ColorProblems are the colors of a theme that do not read on white or on its tint.

func (Theme) DrawingML

func (m Theme) DrawingML() string

DrawingML is the theme part of a .docx or .pptx: the palette and the two font families, so Word's Design tab or PowerPoint's Variants recolor or refont the whole file at once. Apps without themes read the explicit values every style keeps.

Jump to

Keyboard shortcuts

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