---
title: "onepdf/fonts"
url: https://recursiveai.org/onepdf/go/docs/fonts/
description: "The recursiveai.org/go/onepdf/fonts module: Liberation and Noto faces for fonts a PDF does not embed, and how to install it."
version: "1.0.1"
source: https://github.com/recursive-ai-oss/onepdf-go/blob/3d3418a2841e1b3884bba991436fb426c24a560e/fonts/README.md
---

# onepdf/fonts

Substitute fonts for [onepdf](https://github.com/recursive-ai-oss/onepdf-go/tree/3d3418a2841e1b3884bba991436fb426c24a560e/): Liberation Sans, Serif and Mono (the metric-compatible faces for Helvetica/Arial,
Times and Courier), and Noto Sans Math, Noto Sans Symbols and Noto Sans Symbols 2 for Symbol and ZapfDingbats. They are
the upstream releases, byte for byte, under the SIL Open Font License 1.1 (`licenses/`, `SOURCE.md`). The root module
is `MIT OR Apache-2.0` and does not include them, so a program that never imports this module carries none of them.

```go
import "recursiveai.org/go/onepdf/fonts"

fonts.Register() // once, at startup: documents without an embedded font now draw with these faces

doc, _ := onepdf.OpenFile("in.pdf", onepdf.WithEditing())
rep, _ := doc.EmbedSubstituteFonts() // subset the faces into the document, keeping its widths
```

`fonts.Provider()` is the provider itself, for one document (`doc.SetFontProvider`) or one call. An unknown font name is
drawn with the face its descriptor flags ask for (serif, fixed pitch, else sans serif); a symbolic font or a CJK
collection gets none. `EmbedSubstituteFonts` embeds only fonts the package has a metric-compatible face for.

The module has its own `go.mod` and is versioned separately from the root module (tags `fonts/vX.Y.Z`):
`go get recursiveai.org/go/onepdf/fonts` adds it, together with the onepdf version it requires.

Installed system fonts are a separate, opt-in source (`onepdf.WithSystemFonts()`); registering this package does not turn them on.
