auto cover style: use sextants when fontconfig has a font with the glyphs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 23:08:52 +02:00
co-authored by Claude Sonnet 5.5
parent 108541af91
commit b3275f6a81
7 changed files with 62 additions and 5 deletions
+32
View File
@@ -223,7 +223,39 @@ func TestSextantCell(t *testing.T) {
}
}
func TestCoverStyleForFontCheck(t *testing.T) {
defer func(old func() bool) { sextantFontAvailable = old }(sextantFontAvailable)
env := func(m map[string]string) func(string) string { return func(k string) string { return m[k] } }
sextantFontAvailable = func() bool { return true }
for _, tc := range []struct {
name string
env map[string]string
want string
}{
{"unknown terminal with a suitable font", map[string]string{"TERM": "xterm-256color"}, "sextant"},
{"over ssh the local fonts are unknown", map[string]string{"TERM": "xterm-256color", "SSH_CONNECTION": "1 2 3 4"}, "quadrant"},
{"over ssh with a tty", map[string]string{"SSH_TTY": "/dev/pts/1"}, "quadrant"},
} {
if got := coverStyleFor("auto", env(tc.env)).name; got != tc.want {
t.Errorf("%s: %s, want %s", tc.name, got, tc.want)
}
}
// An explicit setting never asks fontconfig.
sextantFontAvailable = func() bool { t.Error("fontconfig consulted for an explicit style"); return true }
if coverStyleFor("quadrant", env(nil)).name != "quadrant" || coverStyleFor("sextant", env(nil)).name != "sextant" {
t.Error("explicit styles must win")
}
// No suitable font: quadrants.
sextantFontAvailable = func() bool { return false }
if got := coverStyleFor("auto", env(map[string]string{"TERM": "xterm-256color"})).name; got != "quadrant" {
t.Errorf("no font: %s", got)
}
}
func TestCoverStyleFor(t *testing.T) {
defer func(old func() bool) { sextantFontAvailable = old }(sextantFontAvailable)
sextantFontAvailable = func() bool { return false } // the table below is about the terminal checks
env := func(m map[string]string) func(string) string { return func(k string) string { return m[k] } }
for _, tc := range []struct {
setting string