feat: default non-monospace UI font to Roboto (Noto Sans fallback) while keeping Fira Code monospace

This commit is contained in:
Luxferre committed 2026-11-26 17:01:37 +02:00
1 parent c4bee91e6b
commit 9a5615af4b
32 files changed
+352 -38

No files matched your search

+37 -5
View File
@@ -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]
+30 -1
View File
@@ -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")"
+84 -4
View File
@@ -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/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g')"
XML_MONO_FONT="$(printf '%s' "$MONO_FONT" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/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 }
' )"