Recursive AI

onepdf/fonts

All onepdf Go docs

Substitute fonts for onepdf: 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.