feat: default non-monospace UI font to Roboto (Noto Sans fallback) while keeping Fira Code monospace
This commit is contained in:
1 parent
c4bee91e6b
commit
9a5615af4b
32 files changed
+352
-38
No files matched your search
@@ -2,6 +2,7 @@
|
||||
theme.name: AnodeDefault
|
||||
theme.isDark: 1
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
theme.gtkTheme: Anode-AnodeDefault
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: CatppuccinLatte
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: CatppuccinMocha
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: Cyberpunk
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: Default
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: Dracula
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: EverforestDark
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
! ANODE Unified Theme: ANODEHelio
|
||||
theme.name: GeminuxHelio
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: GitHubDark
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: GruvboxDark
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: GruvboxLight
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: Kanagawa
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: LinuxConsole
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: LynxLair
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: MatrixGreen
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: MonokaiPro
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: NordFrost
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: OneDark
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: RosePine
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: SolarizedDark
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: SolarizedLight
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
theme.name: TokyoNight
|
||||
theme.fontFace: Fira Code
|
||||
theme.uiFontFace: Roboto
|
||||
theme.iconFontFace: DejaVuSansM Nerd Font
|
||||
theme.baseFontSize: 15
|
||||
|
||||
|
||||
@@ -65,10 +65,41 @@ fi
|
||||
: "${SCALE:=1.00}"
|
||||
: "${TOUCH:=0}"
|
||||
|
||||
resolve_ui_font() {
|
||||
_req="$1"
|
||||
[ -n "$_req" ] || _req="Roboto"
|
||||
if [ "$_req" = "Roboto" ] && command -v fc-list >/dev/null 2>&1; then
|
||||
_resolved="$(fc-list : family 2>/dev/null | awk '
|
||||
{
|
||||
n = split($0, a, ",")
|
||||
for (i = 1; i <= n; i++) {
|
||||
s = a[i]
|
||||
gsub(/^[ \t\r\n]+|[ \t\r\n]+$/, "", s)
|
||||
ls = tolower(s)
|
||||
if (ls == "roboto") has_rob = 1
|
||||
else if (ls == "noto sans") has_noto = 1
|
||||
}
|
||||
}
|
||||
END {
|
||||
if (has_rob) print "Roboto"
|
||||
else if (has_noto) print "Noto Sans"
|
||||
else print "Roboto"
|
||||
}
|
||||
' || true)"
|
||||
if [ -n "$_resolved" ]; then
|
||||
printf '%s\n' "$_resolved"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
printf '%s\n' "$_req"
|
||||
}
|
||||
|
||||
THEME_NAME="$(awk -F: '/^theme\.name[[:space:]]*:/ { sub(/^[[:space:]]+/, "", $2); print $2; exit }' "$XTH_FILE" || true)"
|
||||
if [ -z "$THEME_NAME" ]; then
|
||||
THEME_NAME="$(basename "$XTH_FILE" .xth)"
|
||||
fi
|
||||
RAW_UI_FONT="$(awk -F: '/^theme\.uiFontFace[[:space:]]*:/ { sub(/^[[:space:]]+/, "", $2); sub(/[ \t\r\n]+$/, "", $2); print $2; exit }' "$XTH_FILE" || true)"
|
||||
UI_FONT="$(resolve_ui_font "${RAW_UI_FONT:-Roboto}")"
|
||||
|
||||
mkdir -p "$CONF_DIR"
|
||||
LOCAL_XRES="$CONF_DIR/Xresources.local"
|
||||
@@ -121,7 +152,7 @@ fi
|
||||
|
||||
TMP_XRES="$HOME/.Xresources.tmp.$$"
|
||||
|
||||
awk -v scale_str="$SCALE" -v touch_str="$TOUCH" -v tname="$THEME_NAME" '
|
||||
awk -v scale_str="$SCALE" -v touch_str="$TOUCH" -v tname="$THEME_NAME" -v ui_font="$UI_FONT" '
|
||||
function trim(s) {
|
||||
gsub(/^[ \t\r\n]+|[ \t\r\n]+$/, "", s)
|
||||
return s
|
||||
@@ -189,6 +220,7 @@ END {
|
||||
|
||||
over["theme.name"] = tname
|
||||
over["theme.fontFace"] = font_face
|
||||
over["theme.uiFontFace"] = ui_font
|
||||
over["theme.iconFontFace"] = icon_face
|
||||
over["theme.baseFontSize"] = sprintf("%d", scaled_font_px)
|
||||
over["theme.scale"] = sprintf("%.2f", s)
|
||||
@@ -226,10 +258,10 @@ END {
|
||||
}
|
||||
order[1] = "theme.scale"; order[2] = "theme.touchMode"; order[3] = "theme.gtkTheme"
|
||||
order[4] = "*TkTheme"; order[5] = "Xft.dpi"; order[6] = "Xcursor.size"
|
||||
order[7] = "theme.fontFace"; order[8] = "theme.iconFontFace"; order[9] = "theme.baseFontSize"
|
||||
order[10] = "dwm.borderpx"; order[11] = "dwm.font"; order[12] = "dmenu.font"
|
||||
order[13] = "dmenu.lineheight"; order[14] = "st.font"
|
||||
for (j = 1; j <= 14; j++) {
|
||||
order[7] = "theme.fontFace"; order[8] = "theme.uiFontFace"; order[9] = "theme.iconFontFace"
|
||||
order[10] = "theme.baseFontSize"; order[11] = "dwm.borderpx"; order[12] = "dwm.font"
|
||||
order[13] = "dmenu.font"; order[14] = "dmenu.lineheight"; order[15] = "st.font"
|
||||
for (j = 1; j <= 15; j++) {
|
||||
ok = order[j]
|
||||
if (!(ok in emitted)) {
|
||||
printf "%s: %s\n", ok, over[ok]
|
||||
|
||||
@@ -39,7 +39,36 @@ if [ ! -r "$XRES" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
FONT_FACE="$(xres_get theme.fontFace "Fira Code")"
|
||||
resolve_ui_font() {
|
||||
_req="$1"
|
||||
[ -n "$_req" ] || _req="Roboto"
|
||||
if [ "$_req" = "Roboto" ] && command -v fc-list >/dev/null 2>&1; then
|
||||
_resolved="$(fc-list : family 2>/dev/null | awk '
|
||||
{
|
||||
n = split($0, a, ",")
|
||||
for (i = 1; i <= n; i++) {
|
||||
s = a[i]
|
||||
gsub(/^[ \t\r\n]+|[ \t\r\n]+$/, "", s)
|
||||
ls = tolower(s)
|
||||
if (ls == "roboto") has_rob = 1
|
||||
else if (ls == "noto sans") has_noto = 1
|
||||
}
|
||||
}
|
||||
END {
|
||||
if (has_rob) print "Roboto"
|
||||
else if (has_noto) print "Noto Sans"
|
||||
else print "Roboto"
|
||||
}
|
||||
' || true)"
|
||||
if [ -n "$_resolved" ]; then
|
||||
printf '%s\n' "$_resolved"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
printf '%s\n' "$_req"
|
||||
}
|
||||
|
||||
FONT_FACE="$(resolve_ui_font "$(xres_get theme.uiFontFace "Roboto")")"
|
||||
SCALE="$(xres_get theme.scale "1.00")"
|
||||
BASE_SZ="$(xres_get theme.baseFontSize "15")"
|
||||
|
||||
|
||||
@@ -39,9 +39,40 @@ xres_get() {
|
||||
fi
|
||||
}
|
||||
|
||||
resolve_ui_font() {
|
||||
_req="$1"
|
||||
[ -n "$_req" ] || _req="Roboto"
|
||||
if [ "$_req" = "Roboto" ] && command -v fc-list >/dev/null 2>&1; then
|
||||
_resolved="$(fc-list : family 2>/dev/null | awk '
|
||||
{
|
||||
n = split($0, a, ",")
|
||||
for (i = 1; i <= n; i++) {
|
||||
s = a[i]
|
||||
gsub(/^[ \t\r\n]+|[ \t\r\n]+$/, "", s)
|
||||
ls = tolower(s)
|
||||
if (ls == "roboto") has_rob = 1
|
||||
else if (ls == "noto sans") has_noto = 1
|
||||
}
|
||||
}
|
||||
END {
|
||||
if (has_rob) print "Roboto"
|
||||
else if (has_noto) print "Noto Sans"
|
||||
else print "Roboto"
|
||||
}
|
||||
' || true)"
|
||||
if [ -n "$_resolved" ]; then
|
||||
printf '%s\n' "$_resolved"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
printf '%s\n' "$_req"
|
||||
}
|
||||
|
||||
TNAME="$(xres_get theme.name "AnodeDefault")"
|
||||
DARK="$(xres_get theme.isDark "")"
|
||||
FONT_FACE="$(xres_get theme.fontFace "Fira Code")"
|
||||
MONO_FONT="$FONT_FACE"
|
||||
UI_FONT="$(resolve_ui_font "$(xres_get theme.uiFontFace "Roboto")")"
|
||||
BASE_SZ="$(xres_get theme.baseFontSize "15")"
|
||||
SCALE="$(xres_get theme.scale "1.00")"
|
||||
CUR_SZ="$(xres_get Xcursor.size "24")"
|
||||
@@ -126,7 +157,7 @@ SB_W="$7"
|
||||
IS_DARK="$8"
|
||||
GTK_CUR_SZ="$9"
|
||||
|
||||
GTK_FONT="$FONT_FACE $GTK_PT"
|
||||
GTK_FONT="$UI_FONT $GTK_PT"
|
||||
|
||||
# 1. GTK-2 theme, metadata, XDG theme symlink & ~/.gtkrc-2.0
|
||||
THEME_ROOT="$HOME/.themes/$THEME_ID"
|
||||
@@ -467,8 +498,8 @@ standard_dialogs=gtk3
|
||||
style=$_qt_style
|
||||
|
||||
[Fonts]
|
||||
fixed="$FONT_FACE,$GTK_PT,-1,5,50,0,0,0,0,0"
|
||||
general="$FONT_FACE,$GTK_PT,-1,5,50,0,0,0,0,0"
|
||||
fixed="$MONO_FONT,$GTK_PT,-1,5,50,0,0,0,0,0"
|
||||
general="$UI_FONT,$GTK_PT,-1,5,50,0,0,0,0,0"
|
||||
EOF
|
||||
mv -f "${_qconf}.tmp.$$" "$_qconf"
|
||||
}
|
||||
@@ -476,7 +507,44 @@ EOF
|
||||
write_qt_conf 5
|
||||
write_qt_conf 6
|
||||
|
||||
# 5. Kvantum theme
|
||||
# 5. Fontconfig user generic aliases (sans-serif -> UI font, monospace -> Fira Code)
|
||||
FC_CONF_DIR="$XDG_CONFIG_HOME/fontconfig/conf.d"
|
||||
mkdir -p "$FC_CONF_DIR"
|
||||
XML_UI_FONT="$(printf '%s' "$UI_FONT" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')"
|
||||
XML_MONO_FONT="$(printf '%s' "$MONO_FONT" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')"
|
||||
FC_FILE="$FC_CONF_DIR/60-anode-fonts.conf"
|
||||
cat > "${FC_FILE}.tmp.$$" <<EOF
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
|
||||
<!-- Managed by anode-sync-gtk-theme -->
|
||||
<fontconfig>
|
||||
<alias>
|
||||
<family>sans-serif</family>
|
||||
<prefer>
|
||||
<family>$XML_UI_FONT</family>
|
||||
EOF
|
||||
if [ "$UI_FONT" != "Noto Sans" ]; then
|
||||
printf ' <family>Noto Sans</family>\n' >> "${FC_FILE}.tmp.$$"
|
||||
fi
|
||||
cat >> "${FC_FILE}.tmp.$$" <<EOF
|
||||
</prefer>
|
||||
</alias>
|
||||
<alias>
|
||||
<family>monospace</family>
|
||||
<prefer>
|
||||
<family>$XML_MONO_FONT</family>
|
||||
EOF
|
||||
if [ "$MONO_FONT" != "Fira Code" ]; then
|
||||
printf ' <family>Fira Code</family>\n' >> "${FC_FILE}.tmp.$$"
|
||||
fi
|
||||
cat >> "${FC_FILE}.tmp.$$" <<EOF
|
||||
</prefer>
|
||||
</alias>
|
||||
</fontconfig>
|
||||
EOF
|
||||
mv -f "${FC_FILE}.tmp.$$" "$FC_FILE"
|
||||
|
||||
# 6. Kvantum theme
|
||||
KV_DIR="$XDG_CONFIG_HOME/Kvantum"
|
||||
KV_TDIR="$KV_DIR/$THEME_ID"
|
||||
mkdir -p "$KV_TDIR"
|
||||
@@ -518,6 +586,18 @@ EOF
|
||||
mv -f "$KV_TDIR/$THEME_ID.kvconfig.tmp.$$" "$KV_TDIR/$THEME_ID.kvconfig"
|
||||
|
||||
if [ -n "${DISPLAY:-}" ] && [ "${ANODE_NO_SIGNAL:-0}" != "1" ]; then
|
||||
if [ "${ANODE_NO_DBUS:-0}" != "1" ] && command -v gsettings >/dev/null 2>&1; then
|
||||
_cscheme="default"
|
||||
if [ "$IS_DARK" = "1" ]; then
|
||||
_cscheme="prefer-dark"
|
||||
fi
|
||||
gsettings set org.gnome.desktop.interface font-name "$GTK_FONT" >/dev/null 2>&1 || true
|
||||
gsettings set org.gnome.desktop.interface document-font-name "$GTK_FONT" >/dev/null 2>&1 || true
|
||||
gsettings set org.gnome.desktop.interface monospace-font-name "$MONO_FONT $GTK_PT" >/dev/null 2>&1 || true
|
||||
gsettings set org.gnome.desktop.interface gtk-theme "$THEME_ID" >/dev/null 2>&1 || true
|
||||
gsettings set org.gnome.desktop.interface icon-theme "$ICON_THEME" >/dev/null 2>&1 || true
|
||||
gsettings set org.gnome.desktop.interface color-scheme "$_cscheme" >/dev/null 2>&1 || true
|
||||
fi
|
||||
_xpids="$( (ps -eo pid=,comm= 2>/dev/null || ps -ax -o pid=,comm= 2>/dev/null || true) | awk '
|
||||
{ cmd=$2; sub(/^.*\//, "", cmd); if (cmd == "xsettingsd") print $1 }
|
||||
' )"
|
||||
|
||||
@@ -172,8 +172,8 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
st->themes[st->sel].name, 1, true, GEMUI_ALIGN_LEFT, p->fg_bright);
|
||||
iy += line_h + pad;
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){prev_r.x + pad, iy, prev_r.w - pad * 2, line_h},
|
||||
"Fira Code Ligatures: -> => != === <= >= ::", -1, false, GEMUI_ALIGN_LEFT, p->fg_main);
|
||||
gemui_draw_mono_text(cr, t, (gemui_rect_t){prev_r.x + pad, iy, prev_r.w - pad * 2, line_h},
|
||||
"Fira Code Ligatures: -> => != === <= >= ::", -1, false, GEMUI_ALIGN_LEFT, p->fg_main);
|
||||
iy += line_h + pad / 2;
|
||||
|
||||
const gemui_color_t sw_cols[6] = {
|
||||
|
||||
@@ -233,6 +233,9 @@ static void load_theme_and_geom(vkbd_t *v) {
|
||||
if (XrmGetResource(db, "theme.fontFace", "*", &type, &val) && val.addr) {
|
||||
snprintf(v->theme.font_face, sizeof(v->theme.font_face), "%s", val.addr);
|
||||
}
|
||||
if (XrmGetResource(db, "theme.uiFontFace", "*", &type, &val) && val.addr) {
|
||||
snprintf(v->theme.ui_font_face, sizeof(v->theme.ui_font_face), "%s", val.addr);
|
||||
}
|
||||
XrmDestroyDatabase(db);
|
||||
}
|
||||
v->scale = sc;
|
||||
|
||||
@@ -769,6 +769,33 @@ namespace eval ttk::theme::gtkTtk {
|
||||
return [expr {$v < 1 ? 1 : $v}]
|
||||
};# spx
|
||||
|
||||
proc getXresFontFaces {} {
|
||||
set home [expr {[info exists ::env(HOME)] ? $::env(HOME) : [file normalize ~]}]
|
||||
set xres [file join $home .Xresources]
|
||||
if {![file readable $xres] && [file readable /etc/skel/.Xresources]} {
|
||||
set xres /etc/skel/.Xresources
|
||||
}
|
||||
set mono "Fira Code"
|
||||
set ui "Roboto"
|
||||
if {[file readable $xres]} {
|
||||
set fd [open $xres r]
|
||||
set data [read $fd]
|
||||
close $fd
|
||||
foreach line [split $data "\n"] {
|
||||
set line [string trim $line]
|
||||
if {$line eq "" || [string match "!*" $line] || [string match "#*" $line]} {
|
||||
continue
|
||||
}
|
||||
if {[regexp {^theme\.fontFace\s*:\s*(.+)$} $line -> v]} {
|
||||
set mono [string trim $v]
|
||||
} elseif {[regexp {^theme\.uiFontFace\s*:\s*(.+)$} $line -> v]} {
|
||||
set ui [string trim $v]
|
||||
}
|
||||
}
|
||||
}
|
||||
return [list $mono $ui]
|
||||
};# getXresFontFaces
|
||||
|
||||
proc syncTkClassicPaletteAndFonts {} {
|
||||
variable prevClassicPalette
|
||||
variable prevClassicGeom
|
||||
@@ -960,21 +987,28 @@ namespace eval ttk::theme::gtkTtk {
|
||||
catch {option add $pat $val widgetDefault}
|
||||
}
|
||||
|
||||
set fam "Fira Code"
|
||||
catch {
|
||||
set cur_fam [font configure TkDefaultFont -family]
|
||||
if {$cur_fam ne ""} { set fam $cur_fam }
|
||||
}
|
||||
lassign [getXresFontFaces] xres_mono xres_ui
|
||||
set ui_fam $xres_ui
|
||||
set rc_pt 10
|
||||
if {![catch {set font_spec [settingsProperty gtk-font-name string]}] && $font_spec ne ""} {
|
||||
set parts [split [string trim $font_spec]]
|
||||
if {[llength $parts] >= 2 && [string is double -strict [lindex $parts end]]} {
|
||||
set rc_pt [lindex $parts end]
|
||||
set fam [join [lrange $parts 0 end-1] " "]
|
||||
set ui_fam [join [lrange $parts 0 end-1] " "]
|
||||
} elseif {[llength $parts] >= 1} {
|
||||
set fam [join $parts " "]
|
||||
set ui_fam [join $parts " "]
|
||||
}
|
||||
}
|
||||
if {$ui_fam eq "Roboto"} {
|
||||
set avail_fams {}
|
||||
catch {set avail_fams [font families]}
|
||||
if {[llength $avail_fams] > 0 && [lsearch -nocase -exact $avail_fams "Roboto"] < 0} {
|
||||
if {[lsearch -nocase -exact $avail_fams "Noto Sans"] >= 0} {
|
||||
set ui_fam "Noto Sans"
|
||||
}
|
||||
}
|
||||
}
|
||||
set mono_fam $xres_mono
|
||||
if {[string is integer -strict $base_sz] && $base_sz >= 8} {
|
||||
set px_main [expr {int($base_sz)}]
|
||||
} elseif {[string is double -strict $rc_pt] && $rc_pt > 0} {
|
||||
@@ -987,14 +1021,15 @@ namespace eval ttk::theme::gtkTtk {
|
||||
set px_small [expr {int(round($px_main * 0.85))}]
|
||||
if {$px_small < 8} { set px_small 8 }
|
||||
|
||||
foreach tkfont {TkDefaultFont TkTextFont TkFixedFont TkMenuFont TkIconFont} {
|
||||
catch {font configure $tkfont -family $fam -size [expr {-$px_main}]}
|
||||
foreach tkfont {TkDefaultFont TkTextFont TkMenuFont TkIconFont} {
|
||||
catch {font configure $tkfont -family $ui_fam -size [expr {-$px_main}]}
|
||||
}
|
||||
catch {font configure TkFixedFont -family $mono_fam -size [expr {-$px_main}]}
|
||||
foreach tkfont {TkHeadingFont TkCaptionFont} {
|
||||
catch {font configure $tkfont -family $fam -size [expr {-$px_head}] -weight bold}
|
||||
catch {font configure $tkfont -family $ui_fam -size [expr {-$px_head}] -weight bold}
|
||||
}
|
||||
foreach tkfont {TkSmallCaptionFont TkTooltipFont} {
|
||||
catch {font configure $tkfont -family $fam -size [expr {-$px_small}]}
|
||||
catch {font configure $tkfont -family $ui_fam -size [expr {-$px_small}]}
|
||||
}
|
||||
|
||||
scaleExistingAppFonts
|
||||
|
||||
+29
-6
@@ -159,6 +159,7 @@ void gemui_theme_defaults(gemui_theme_t *t) {
|
||||
memset(t, 0, sizeof(*t));
|
||||
snprintf(t->name, sizeof(t->name), "AnodeDefault");
|
||||
snprintf(t->font_face, sizeof(t->font_face), "Fira Code");
|
||||
snprintf(t->ui_font_face, sizeof(t->ui_font_face), "Roboto");
|
||||
snprintf(t->icon_font_face, sizeof(t->icon_font_face), "DejaVuSansM Nerd Font");
|
||||
t->base_font_size = 15;
|
||||
t->dpi = 96;
|
||||
@@ -246,6 +247,9 @@ static void gemui_apply_xrm_db(XrmDatabase db, gemui_theme_t *t) {
|
||||
if (XrmGetResource(db, "theme.fontFace", "Theme.FontFace", &type, &val) && val.addr) {
|
||||
snprintf(t->font_face, sizeof(t->font_face), "%s", val.addr);
|
||||
}
|
||||
if (XrmGetResource(db, "theme.uiFontFace", "Theme.UiFontFace", &type, &val) && val.addr) {
|
||||
snprintf(t->ui_font_face, sizeof(t->ui_font_face), "%s", val.addr);
|
||||
}
|
||||
if (XrmGetResource(db, "theme.iconFontFace", "Theme.IconFontFace", &type, &val) && val.addr) {
|
||||
snprintf(t->icon_font_face, sizeof(t->icon_font_face), "%s", val.addr);
|
||||
}
|
||||
@@ -1085,9 +1089,9 @@ static int gemui_draw_pango(cairo_t *cr, const char *face, int px_size,
|
||||
int align, gemui_color_t c) {
|
||||
if (!text || !text[0] || r.w <= 4 || r.h <= 4) return 0;
|
||||
PangoLayout *layout = g_active_layout ? g_active_layout : pango_cairo_create_layout(cr);
|
||||
char desc_str[160];
|
||||
char desc_str[288];
|
||||
snprintf(desc_str, sizeof(desc_str), "%s%s %dpx",
|
||||
face && face[0] ? face : "Fira Code",
|
||||
face && face[0] ? face : "Roboto, Noto Sans",
|
||||
bold ? " Bold" : "",
|
||||
px_size > 8 ? px_size : 14);
|
||||
PangoFontDescription *desc = pango_font_description_from_string(desc_str);
|
||||
@@ -1117,20 +1121,39 @@ static int gemui_draw_pango(cairo_t *cr, const char *face, int px_size,
|
||||
return tw;
|
||||
}
|
||||
|
||||
int gemui_draw_text(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *text, int pt_delta, bool bold, int align, gemui_color_t c) {
|
||||
static int gemui_draw_text_with_face(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *face, const char *text, int pt_delta,
|
||||
bool bold, int align, gemui_color_t c) {
|
||||
double sc = (t && t->scale > 0.0) ? t->scale : 1.0;
|
||||
int base_px = (t && t->base_font_size > 0) ? t->base_font_size : anode_scale_px(15, sc);
|
||||
int delta_px = (int)llround((double)pt_delta * sc);
|
||||
int px = base_px + delta_px;
|
||||
if (px < 8) px = 8;
|
||||
char fam[200];
|
||||
char fam[256];
|
||||
snprintf(fam, sizeof(fam), "%s, %s",
|
||||
(t && t->font_face[0]) ? t->font_face : "Fira Code",
|
||||
(face && face[0]) ? face : "Roboto, Noto Sans",
|
||||
(t && t->icon_font_face[0]) ? t->icon_font_face : "DejaVuSansM Nerd Font");
|
||||
return gemui_draw_pango(cr, fam, px, r, text, bold, align, c);
|
||||
}
|
||||
|
||||
int gemui_draw_text(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *text, int pt_delta, bool bold, int align, gemui_color_t c) {
|
||||
const char *uface = (t && t->ui_font_face[0]) ? t->ui_font_face : "Roboto";
|
||||
char ui_with_fallback[128];
|
||||
if (strcmp(uface, "Noto Sans") == 0) {
|
||||
snprintf(ui_with_fallback, sizeof(ui_with_fallback), "Noto Sans");
|
||||
} else {
|
||||
snprintf(ui_with_fallback, sizeof(ui_with_fallback), "%s, Noto Sans", uface);
|
||||
}
|
||||
return gemui_draw_text_with_face(cr, t, r, ui_with_fallback, text, pt_delta, bold, align, c);
|
||||
}
|
||||
|
||||
int gemui_draw_mono_text(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *text, int pt_delta, bool bold, int align, gemui_color_t c) {
|
||||
const char *mface = (t && t->font_face[0]) ? t->font_face : "Fira Code";
|
||||
return gemui_draw_text_with_face(cr, t, r, mface, text, pt_delta, bold, align, c);
|
||||
}
|
||||
|
||||
int gemui_draw_icon(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *icon_utf8, int pt_delta, int align, gemui_color_t c) {
|
||||
double sc = (t && t->scale > 0.0) ? t->scale : 1.0;
|
||||
|
||||
@@ -53,6 +53,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
char name[64];
|
||||
char font_face[96];
|
||||
char ui_font_face[96];
|
||||
char icon_font_face[96];
|
||||
int base_font_size;
|
||||
int dpi;
|
||||
@@ -144,6 +145,8 @@ void gemui_fill_round(cairo_t *cr, gemui_rect_t r, double radius, gemui_color_t
|
||||
void gemui_stroke_round(cairo_t *cr, gemui_rect_t r, double radius, double lw, gemui_color_t c);
|
||||
int gemui_draw_text(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *text, int pt_delta, bool bold, int align, gemui_color_t c);
|
||||
int gemui_draw_mono_text(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *text, int pt_delta, bool bold, int align, gemui_color_t c);
|
||||
int gemui_draw_icon(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
const char *icon_utf8, int pt_delta, int align, gemui_color_t c);
|
||||
void gemui_draw_header(gemui_app_t *app, cairo_t *cr, const char *icon,
|
||||
|
||||
@@ -32,7 +32,28 @@ def parse_xres(path):
|
||||
return out
|
||||
|
||||
|
||||
def detect_expected_ui_font():
|
||||
if os.environ.get("ANODE_TEST_UI_FONT"):
|
||||
return os.environ["ANODE_TEST_UI_FONT"]
|
||||
try:
|
||||
out = subprocess.check_output(["fc-list", ":", "family"], text=True)
|
||||
except Exception:
|
||||
return "Roboto"
|
||||
fams = set()
|
||||
for line in out.splitlines():
|
||||
for part in line.split(","):
|
||||
p = part.strip().lower()
|
||||
if p:
|
||||
fams.add(p)
|
||||
if "roboto" in fams:
|
||||
return "Roboto"
|
||||
if "noto sans" in fams:
|
||||
return "Noto Sans"
|
||||
return "Roboto"
|
||||
|
||||
|
||||
def test_fractional_scales():
|
||||
exp_ui = detect_expected_ui_font()
|
||||
scales = [
|
||||
("0.75", 72, "1", "1.0", 11, 16, 16),
|
||||
("1.00", 96, "1", "1.0", 15, 24, 24),
|
||||
@@ -75,8 +96,10 @@ def test_fractional_scales():
|
||||
assert int(xres["theme.baseFontSize"]) == exp_px, f"scale={s_str} base={xres['theme.baseFontSize']}"
|
||||
assert int(xres["Xcursor.size"]) == exp_cur, f"scale={s_str} cur={xres['Xcursor.size']}"
|
||||
assert xres["theme.fontFace"] == "Fira Code"
|
||||
assert xres["theme.uiFontFace"] == exp_ui
|
||||
assert "Fira Code" in xres["st.font"] and "size=13" in xres["st.font"]
|
||||
assert "Fira Code" in xres["dwm.font"] and f"{exp_px}px" in xres["dwm.font"]
|
||||
assert "Fira Code" in xres["dmenu.font"] and f"{exp_px}px" in xres["dmenu.font"]
|
||||
assert xres["*TkTheme"] == "gtkTtk"
|
||||
assert xres["theme.touchMode"] == "1"
|
||||
|
||||
@@ -86,12 +109,12 @@ def test_fractional_scales():
|
||||
xs = f.read()
|
||||
assert "Xft/DPI" not in xs, f"Xft/DPI must not exist in xsettingsd.conf:\n{xs}"
|
||||
assert f"Gdk/WindowScalingFactor {exp_gdk}" in xs, xs
|
||||
assert 'Gtk/FontName "Fira Code 10"' in xs, xs
|
||||
assert f'Gtk/FontName "{exp_ui} 10"' in xs, xs
|
||||
assert f"Gtk/CursorThemeSize {exp_gtk_cur}" in xs, xs
|
||||
|
||||
with open(os.path.join(tmp, ".gtkrc-2.0"), "r", encoding="utf-8") as f:
|
||||
gtk2 = f.read()
|
||||
assert 'gtk-font-name="Fira Code 10"' in gtk2, gtk2
|
||||
assert f'gtk-font-name="{exp_ui} 10"' in gtk2, gtk2
|
||||
assert f"gtk-cursor-theme-size={exp_cur}" in gtk2, gtk2
|
||||
|
||||
assert os.path.isfile(os.path.join(tmp, ".themes", "ANODE-AnodeDefault", "index.theme"))
|
||||
@@ -105,7 +128,7 @@ def test_fractional_scales():
|
||||
for gver in ("gtk-3.0", "gtk-4.0"):
|
||||
with open(os.path.join(tmp, ".config", gver, "settings.ini"), "r", encoding="utf-8") as f:
|
||||
gini = f.read()
|
||||
assert "gtk-font-name=Fira Code 10" in gini, gini
|
||||
assert f"gtk-font-name={exp_ui} 10" in gini, gini
|
||||
assert f"gtk-cursor-theme-size={exp_gtk_cur}" in gini, gini
|
||||
with open(os.path.join(tmp, ".config", gver, "gtk.css"), "r", encoding="utf-8") as f:
|
||||
gcss = f.read()
|
||||
@@ -128,17 +151,28 @@ def test_fractional_scales():
|
||||
for qver in ("qt5ct", "qt6ct"):
|
||||
with open(os.path.join(tmp, ".config", qver, f"{qver}.conf"), "r", encoding="utf-8") as f:
|
||||
qconf = f.read()
|
||||
assert 'general="Fira Code,10,' in qconf, qconf
|
||||
assert f'general="{exp_ui},10,' in qconf, qconf
|
||||
assert 'fixed="Fira Code,10,' in qconf, qconf
|
||||
|
||||
fc_p = os.path.join(tmp, ".config", "fontconfig", "conf.d", "60-anode-fonts.conf")
|
||||
import xml.etree.ElementTree as ET
|
||||
fc_root = ET.parse(fc_p).getroot()
|
||||
aliases = {
|
||||
al.findtext("family"): [el.text for el in al.findall("./prefer/family")]
|
||||
for al in fc_root.findall("./alias")
|
||||
}
|
||||
assert aliases.get("sans-serif", [None])[0] == exp_ui, aliases
|
||||
assert aliases.get("monospace", [None])[0] == "Fira Code", aliases
|
||||
|
||||
with open(os.path.join(tmp, ".config", "dunst", "dunstrc"), "r", encoding="utf-8") as f:
|
||||
drc = f.read()
|
||||
assert "scale = 1" in drc, drc
|
||||
assert f"font = Fira Code {exp_px}px" in drc, drc
|
||||
assert f"font = {exp_ui} {exp_px}px" in drc, drc
|
||||
|
||||
# Verify Qt5 + Qt6 + Kvantum + Dunst + GTK2/3/4 files
|
||||
# Verify Fontconfig + Qt5 + Qt6 + Kvantum + Dunst + GTK2/3/4 files
|
||||
for p in [
|
||||
".gtkrc-2.0",
|
||||
".config/fontconfig/conf.d/60-anode-fonts.conf",
|
||||
".config/gtk-3.0/gtk.css",
|
||||
".config/gtk-3.0/settings.ini",
|
||||
".config/gtk-4.0/gtk.css",
|
||||
@@ -299,8 +333,9 @@ def test_stale_env_does_not_override_scale_conf():
|
||||
assert xres["Xft.dpi"] == "120", xres["Xft.dpi"]
|
||||
assert xres["theme.touchMode"] == "0", xres["theme.touchMode"]
|
||||
|
||||
exp_ui = detect_expected_ui_font()
|
||||
with open(os.path.join(tmp, ".config", "dunst", "dunstrc"), "r", encoding="utf-8") as f:
|
||||
assert "font = Fira Code 19px" in f.read()
|
||||
assert f"font = {exp_ui} 19px" in f.read()
|
||||
with open(os.path.join(tmp, ".config", "gtk-3.0", "settings.ini"), "r", encoding="utf-8") as f:
|
||||
assert "gtk-cursor-theme-size=24" in f.read()
|
||||
|
||||
@@ -383,6 +418,57 @@ def test_gtk_theme_light_dark_detection_and_css_parse():
|
||||
)
|
||||
|
||||
|
||||
def test_ui_font_fallback_roboto_to_noto_sans():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
fbin = os.path.join(tmp, "bin")
|
||||
os.makedirs(fbin)
|
||||
fc_list_p = os.path.join(fbin, "fc-list")
|
||||
with open(fc_list_p, "w", encoding="utf-8") as f:
|
||||
f.write("#!/bin/sh\nprintf 'Noto Sans\\nFira Code\\n'\n")
|
||||
os.chmod(fc_list_p, 0o755)
|
||||
|
||||
env = dict(os.environ)
|
||||
env.pop("DISPLAY", None)
|
||||
env["HOME"] = tmp
|
||||
env["XDG_CONFIG_HOME"] = os.path.join(tmp, ".config")
|
||||
env["XDG_DATA_HOME"] = os.path.join(tmp, ".local", "share")
|
||||
env["ANODE_PREFIX"] = ROOT
|
||||
env["ANODE_NO_SIGNAL"] = "1"
|
||||
env["ANODE_NO_DBUS"] = "1"
|
||||
env["PATH"] = fbin + ":" + env.get("PATH", "")
|
||||
|
||||
run_env(env, [APPLY_SCALE, "1.25", "--touch=0"])
|
||||
|
||||
xres = parse_xres(os.path.join(tmp, ".Xresources"))
|
||||
assert xres["theme.uiFontFace"] == "Noto Sans", xres
|
||||
assert xres["theme.fontFace"] == "Fira Code", xres
|
||||
assert "Fira Code" in xres["dwm.font"] and "Fira Code" in xres["dmenu.font"] and "Fira Code" in xres["st.font"]
|
||||
|
||||
with open(os.path.join(tmp, ".config", "xsettingsd", "xsettingsd.conf"), "r", encoding="utf-8") as f:
|
||||
assert 'Gtk/FontName "Noto Sans 10"' in f.read()
|
||||
with open(os.path.join(tmp, ".gtkrc-2.0"), "r", encoding="utf-8") as f:
|
||||
assert 'gtk-font-name="Noto Sans 10"' in f.read()
|
||||
for gver in ("gtk-3.0", "gtk-4.0"):
|
||||
with open(os.path.join(tmp, ".config", gver, "settings.ini"), "r", encoding="utf-8") as f:
|
||||
assert "gtk-font-name=Noto Sans 10" in f.read()
|
||||
for qver in ("qt5ct", "qt6ct"):
|
||||
with open(os.path.join(tmp, ".config", qver, f"{qver}.conf"), "r", encoding="utf-8") as f:
|
||||
qc = f.read()
|
||||
assert 'general="Noto Sans,10,' in qc, qc
|
||||
assert 'fixed="Fira Code,10,' in qc, qc
|
||||
with open(os.path.join(tmp, ".config", "dunst", "dunstrc"), "r", encoding="utf-8") as f:
|
||||
assert "font = Noto Sans 19px" in f.read()
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
fc_root = ET.parse(os.path.join(tmp, ".config", "fontconfig", "conf.d", "60-anode-fonts.conf")).getroot()
|
||||
aliases = {
|
||||
al.findtext("family"): [el.text for el in al.findall("./prefer/family")]
|
||||
for al in fc_root.findall("./alias")
|
||||
}
|
||||
assert aliases.get("sans-serif") == ["Noto Sans"], aliases
|
||||
assert aliases.get("monospace") == ["Fira Code"], aliases
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open(os.path.join(ROOT, "data", "env.sh"), "r", encoding="utf-8") as f:
|
||||
env_sh = f.read()
|
||||
@@ -393,4 +479,5 @@ if __name__ == "__main__":
|
||||
test_auto_scale_honors_explicit_server_dpi()
|
||||
test_stale_env_does_not_override_scale_conf()
|
||||
test_gtk_theme_light_dark_detection_and_css_parse()
|
||||
print("test_theme_scale: ALL PASSED (7 fractional scales, 22 themes, legacy 192-DPI import, St overrides, auto DPI, scale.conf precedence, GTK light/dark)")
|
||||
test_ui_font_fallback_roboto_to_noto_sans()
|
||||
print("test_theme_scale: ALL PASSED (7 fractional scales, 22 themes, legacy 192-DPI import, St overrides, auto DPI, scale.conf precedence, GTK light/dark, Roboto->Noto Sans fallback)")
|
||||
@@ -495,7 +495,7 @@ def test_st_font_override_and_dunst():
|
||||
dout, derr = dp.communicate(timeout=3)
|
||||
combined = dout + "\n" + derr
|
||||
assert "Trying to set scale to 1" in combined, combined
|
||||
assert "Fira Code 23px" in combined, combined
|
||||
assert ("Roboto 23px" in combined or "Noto Sans 23px" in combined), combined
|
||||
finally:
|
||||
for p in reversed(procs):
|
||||
terminate(p)
|
||||
|
||||
Reference in new issue
Block a user