Android: editor font-size setting now applies - disable WebView text-autosizing (layoutAlgorithm NORMAL) + respect the font-size var (#100)

This commit is contained in:
Yuri Karamian
2026-06-12 10:24:14 +02:00
parent 4df96362f4
commit 35894cdfd1
2 changed files with 122 additions and 0 deletions
@@ -26,6 +26,13 @@ class MainActivity : TauriActivity() {
super.onWebViewCreate(webView) super.onWebViewCreate(webView)
this.webView = webView this.webView = webView
webView.addJavascriptInterface(StorageBridge(this), "Android") webView.addJavascriptInterface(StorageBridge(this), "Android")
// Render text at the size CSS specifies, ignoring the device's system font-size
// accessibility setting (textZoom is otherwise tied to the system font scale). (#100)
webView.settings.textZoom = 100
// The actual fix: disable WebView "text autosizing" / font-boosting, which recomputes
// paragraph font-size and line-height from viewport heuristics and ignores our CSS (only
// size + line-height were affected; font-family was fine). NORMAL turns it off. (#100)
webView.settings.layoutAlgorithm = android.webkit.WebSettings.LayoutAlgorithm.NORMAL
} }
override fun onResume() { override fun onResume() {
+115
View File
@@ -36,6 +36,121 @@
src: url("/fonts/jetbrains-mono/JetBrainsMono-BoldItalic.woff2") format("woff2"); src: url("/fonts/jetbrains-mono/JetBrainsMono-BoldItalic.woff2") format("woff2");
} }
/* Reading fonts - self-hosted (static/fonts/<name>/, OFL-1.1). Offered in the font picker;
bundled so they render the same on every platform instead of falling back to a system serif. */
@font-face {
font-family: "Lora";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("/fonts/lora/Lora-Regular.woff2") format("woff2");
}
@font-face {
font-family: "Lora";
font-style: normal;
font-weight: 700;
font-display: swap;
src: url("/fonts/lora/Lora-Bold.woff2") format("woff2");
}
@font-face {
font-family: "Lora";
font-style: italic;
font-weight: 400;
font-display: swap;
src: url("/fonts/lora/Lora-Italic.woff2") format("woff2");
}
@font-face {
font-family: "Lora";
font-style: italic;
font-weight: 700;
font-display: swap;
src: url("/fonts/lora/Lora-BoldItalic.woff2") format("woff2");
}
@font-face {
font-family: "Merriweather";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("/fonts/merriweather/Merriweather-Regular.woff2") format("woff2");
}
@font-face {
font-family: "Merriweather";
font-style: normal;
font-weight: 700;
font-display: swap;
src: url("/fonts/merriweather/Merriweather-Bold.woff2") format("woff2");
}
@font-face {
font-family: "Merriweather";
font-style: italic;
font-weight: 400;
font-display: swap;
src: url("/fonts/merriweather/Merriweather-Italic.woff2") format("woff2");
}
@font-face {
font-family: "Merriweather";
font-style: italic;
font-weight: 700;
font-display: swap;
src: url("/fonts/merriweather/Merriweather-BoldItalic.woff2") format("woff2");
}
@font-face {
font-family: "Literata";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("/fonts/literata/Literata-Regular.woff2") format("woff2");
}
@font-face {
font-family: "Literata";
font-style: normal;
font-weight: 700;
font-display: swap;
src: url("/fonts/literata/Literata-Bold.woff2") format("woff2");
}
@font-face {
font-family: "Literata";
font-style: italic;
font-weight: 400;
font-display: swap;
src: url("/fonts/literata/Literata-Italic.woff2") format("woff2");
}
@font-face {
font-family: "Literata";
font-style: italic;
font-weight: 700;
font-display: swap;
src: url("/fonts/literata/Literata-BoldItalic.woff2") format("woff2");
}
@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("/fonts/open-sans/OpenSans-Regular.woff2") format("woff2");
}
@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 700;
font-display: swap;
src: url("/fonts/open-sans/OpenSans-Bold.woff2") format("woff2");
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 400;
font-display: swap;
src: url("/fonts/open-sans/OpenSans-Italic.woff2") format("woff2");
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 700;
font-display: swap;
src: url("/fonts/open-sans/OpenSans-BoldItalic.woff2") format("woff2");
}
:root { :root {
/* Light theme */ /* Light theme */
--bg-primary: #ffffff; --bg-primary: #ffffff;