font

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 0 Imported by: 0

README

tinywasm/font

Typeface identity shared by web and PDF: WASM-safe names, no embedded bytes.

A product declares its typeface once; every medium derives the face names from that single origin.

// config/fonts.go — no build tag: identity crosses to WASM
func Fonts() font.Declaration {
    return font.Declare("Roboto", "fonts/")
}

Ready-to-use faces live in faces/ — Roboto and Inter, subsetted to Latin with , four real faces each. Copy the ones you want into your project's config/fonts/. They are files, not code: no .go here embeds them, so they never enter a binary.

Documentation

Documentation

Overview

Package font names the typeface of a product and derives the names of its faces. It carries no bytes, no paths and no medium knowledge: web and PDF derive their font names from this single origin.

It travels inside the WASM binary, so it never reads a file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Declaration added in v0.0.2

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

Declaration is what a project declares in its font.go: the family and the subfolder where its faces live. It is built only with Declare, so a partial declaration cannot exist.

func Declare added in v0.0.2

func Declare(family Family, dir string) Declaration

Declare fixes the family and the subfolder where its faces live.

func (Declaration) Dir added in v0.0.2

func (d Declaration) Dir() string

Dir returns the declared subfolder, exactly as given.

func (Declaration) Family added in v0.0.2

func (d Declaration) Family() Family

Family returns the declared typeface name.

type Family added in v0.0.2

type Family string

Family is the name of the product's typeface. It is the only thing of this package that crosses to WASM.

func (Family) Face added in v0.0.2

func (f Family) Face(s Style) string

Face is a face's file name, derived — never written by hand. Without extension: each medium adds its own (.ttf for PDF, .woff2 for web).

type Style added in v0.0.2

type Style uint8

Style names a face. The set is closed: these four, and exactly the four tinywasm/pdf registers.

const (
	Regular Style = iota
	Bold
	Italic
	BoldItalic
)

Jump to

Keyboard shortcuts

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