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
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user