Help us shape the future of Go! Take the 2026 Go Developer Survey

imagefontmac

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package imagefontmac connects inline images to macOS's font APIs. Font registration does not control Terminal. Separate operations update the caller's exact tab while preserving its selected profile and size.

Index

Constants

This section is empty.

Variables

View Source
var ErrLegacyFont = errors.New("this older image font cannot identify your original font; select your original font and size in Terminal, then retry the command")

ErrLegacyFont identifies an older gallery whose original text face was not recorded. Callers can retain that gallery's existing rendering behavior.

View Source
var ErrOtherProfile = errors.New("sharp image settings are not enabled in this tab")

ErrOtherProfile means this tab needs the image font enabled. Its Inspector profile name is not significant once the owned font is selected.

View Source
var ErrUnsupported = errors.New("Apple Terminal image fonts require local macOS with /usr/bin/osascript")

Functions

func Preserve

func Preserve(ctx context.Context, profileName, tty, fontName string, expected ProfileStatus) error

Preserve activates an image-capable copy only if the font and size still match the captured settings. It never writes a point size or selects a profile.

func Register

func Register(ctx context.Context, path string) error

Register makes a generated font available for this macOS login session. The caller must retain the file at the same path until it is unregistered.

func Restore

func Restore(ctx context.Context, profileName, tty, fontName string, original ProfileStatus) error

Restore undoes activation only while this tab still has the generated font and captured settings. Concurrent changes belong to the user and are left alone.

func Supported

func Supported() bool

func Unregister

func Unregister(ctx context.Context, path string) error

Unregister removes a session registration. A font that is already absent is treated as successfully removed. This does not delete the caller's font file.

Types

type NativeError

type NativeError struct {
	Operation string
	Code      int
}

NativeError reports a CoreText error without exposing native diagnostics, which can contain unescaped filenames or other private image metadata.

func (*NativeError) Error

func (e *NativeError) Error() string

type ProfileStatus

type ProfileStatus struct {
	FontName    string  `json:"fontName"`
	FontSize    float64 `json:"fontSize"`
	ProfileID   int     `json:"profileID"`
	ProfileName string  `json:"profileName"`
}

ProfileStatus describes the settings that Terminal exposes for the exact local tab. It does not certify line spacing, which Terminal's scripting API does not expose, or the window width, which callers must check separately.

func InspectProfile

func InspectProfile(ctx context.Context, profileName, tty string) (ProfileStatus, error)

InspectProfile reads this tab's image font and size without changing it. An unsupported font size returns the checked status together with an error. This may request macOS Automation permission when the user runs the command; it never selects a tab or changes a default.

func Snapshot

func Snapshot(ctx context.Context, profileName, tty string) (ProfileStatus, error)

Snapshot reads the exact caller's font before preparing an image-capable copy. Unlike InspectProfile, the font need not belong to this gallery.

type SourceFont

type SourceFont struct {
	PostScript string `json:"postscript"`
	// LookupName disambiguates bundled faces whose PostScript name is shared
	// across different font files. It is their exact native full face name.
	LookupName string `json:"lookup_name,omitempty"`
	// Variations captures the selected face's user-space axis coordinates.
	// Keys are decimal OpenType axis tags returned by CoreText.
	Variations  map[string]float64 `json:"variations,omitempty"`
	FamilyClass uint8              `json:"family_class,omitempty"`
	Style       string             `json:"style"`
	Tables      map[string][]byte  `json:"tables"`
	Ascent      float64            `json:"ascent"`
	Descent     float64            `json:"descent"`
	Leading     float64            `json:"leading"`
	Advance     float64            `json:"advance"`
	LineHeight  float64            `json:"line_height"`
	Companions  []SourceFont       `json:"companions,omitempty"`
}

SourceFont is an exact installed face's unmodified sfnt tables plus its native metrics at the requested point size. Tables can include the optional OAIp lineage table when the source is one of our generated image fonts.

func Source

func Source(ctx context.Context, postScript string, size int) (SourceFont, error)

Source reads an exact installed face by PostScript or native display name without registering fonts, accessing application preferences, or controlling Terminal. Missing names fail rather than returning CoreText's automatic fallback font. For a generated image font, its OAIp lineage identifies the original installed face instead. Companions includes available real bold/italic faces from the same family.

type TerminalTab

type TerminalTab struct {
	TTY      string `json:"tty"`
	FontName string `json:"fontName"`
}

TerminalTab identifies a live tab and its selected font for cache cleanup.

func TerminalTabs

func TerminalTabs(ctx context.Context) ([]TerminalTab, error)

TerminalTabs reads every tab without selecting or changing any of them. Any partial or invalid inventory is an error, never evidence of closed tabs.

Jump to

Keyboard shortcuts

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