liberation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package liberation supplies substitute font programs for documents that embed none.

What is here and why these faces

Eight faces of Liberation 2.1.5 — Sans and Serif, each in regular, bold, italic and bold italic — which stand in for 8 of the standard 14 fonts and for any non-embedded Arial or Times. Liberation is *metric-compatible* with Arial, Times New Roman and Courier New by construction, which is the property that matters most here and is worth more than the glyph shapes: a standard-14 font may omit /Widths entirely, and where it does the advances come from the program, so a stand-in with different metrics would reflow the line. Where /Widths is present §9.2.4 makes it authoritative and the substitute's metrics are irrelevant.

Monospaced is deliberately absent. Courier is requested on 0 of the corpus's 1,251 pages, and the three Mono faces cost 686 KB gzipped; a page asking for one is refused with a reason naming the missing family, which is honest and one line from being fixed when a document needs it. Symbol and ZapfDingbats are not here and will not be: no text face can stand in for a font whose codes are not characters, and font.FamilySymbol exists so that such a request is declined rather than answered with Latin letters.

Why gzipped, and why not subsetted

The faces carry full Unicode coverage — Cyrillic, Greek, Hebrew, extended Latin — and weigh 3.17 MB raw against 1.69 MB gzipped, so they are stored compressed and inflated on first use. Subsetting them to Latin would be smaller still and is not done, because the OFL reserves the name: a modified Liberation may not be called Liberation, so subsetting would mean renaming the faces and shipping something no longer traceable to its upstream. Compression leaves the bytes identical.

Licensing

SIL Open Font License 1.1, reproduced verbatim in faces/LICENSE along with faces/AUTHORS. The OFL is a redistribution licence and imposes nothing on this repository's own MIT terms; what it does require is that the licence travel with the fonts and that the Reserved Font Name not be applied to a modified version, both of which hold here.

Why internal

So that no external importer pays for these bytes. render/native takes a FaceSource interface and refuses without one, because which face substitutes for Helvetica is policy rather than parsing; this package is the policy cmd/pdfspec chooses, and an internal package cannot become part of the module's surface by accident.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Notice

func Notice() string

Notice is the SIL Open Font License and the AUTHORS file, verbatim.

Embedded and exported rather than only committed beside the fonts, because the OFL requires the licence to accompany the Font Software wherever it is redistributed — and a single static binary with the faces compiled in *is* a redistribution. A licence file sitting in the source tree satisfies that for a clone and not for the binary someone downloads, so `pdfspec version` prints this. It is the one piece of compliance that cannot be met by a file in the repository.

Types

type Source

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

Source resolves a font.Style to one of the embedded faces.

Safe for concurrent use, and it has to be: render.Rasterizer implementations are not, so a caller rendering pages in parallel holds one rasterizer per worker — and they would all share one of these.

func New

func New() *Source

New returns a Source. Nothing is read or parsed until a page asks for a face.

func (*Source) Face

func (s *Source) Face(req font.FaceRequest) (*font.TrueType, bool)

Face returns the embedded program for the requested style.

The style decides, not the name: a request for "ArialMT" and one for "Helvetica" both resolve to Liberation Sans, because that is what metric compatibility means and the name adds nothing this Source can act on. A caller holding the genuine Arial would write its own FaceSource and use the name — which is why FaceRequest carries it.

Jump to

Keyboard shortcuts

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