font

package module
v0.0.4 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/")
}

Bring your own faces. Download them, buy them, or reuse ones you already have — this module says nothing about where they come from. It requires exactly two things:

  • the four files live in the folder you pass to Declare(...) — you choose it, and Dir() is relative to the project root;
  • each is named what Face(Style) returns, plus .ttfRoboto-Regular.ttf, Roboto-Bold.ttf, Roboto-Italic.ttf, Roboto-BoldItalic.ttf.

If you have no family chosen yet, faces/ offers two verified ones — Roboto and Inter, subsetted to Latin with , four real faces each. They are files, not code: no .go here embeds them, so they never enter a binary.

Importing this root is free and safe from any medium; importing a font subpackage is a backend decision — the file that does it carries //go:build !wasm.

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). All four styles carry a "-Style" suffix, Regular included.

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