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 ¶
- Variables
- func Preserve(ctx context.Context, profileName, tty, fontName string, expected ProfileStatus) error
- func Register(ctx context.Context, path string) error
- func Restore(ctx context.Context, profileName, tty, fontName string, original ProfileStatus) error
- func Supported() bool
- func Unregister(ctx context.Context, path string) error
- type NativeError
- type ProfileStatus
- type SourceFont
- type TerminalTab
Constants ¶
This section is empty.
Variables ¶
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.
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.
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 ¶
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.
Types ¶
type NativeError ¶
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.
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 ¶
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 ¶
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.