-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load custom fonts for different browsers on Android 15+ #1
Comments
Possibly related function calls: |
I have used the following CSS rule for testing: Lines 9 to 33 in c021e90
and all mentioned fonts in the code are installed into system using MagiskFonts. Here are the results
Note that when |
The above test was misleading, because the font |
It turns out that // ==UserScript==
// @name Font Loader
// @namespace JingMatrix
// @match https://jingmatrix.github.io/zh/blog/*
// @run-at document-idle
// @grant GM_addStyle
// @description Fix the problem of custom font loading in browsers on Android 15+
// ==/UserScript==
const font_lists = ["STKaiti", "STFangsong", "STXingkai", "STXihei", "STLiti"];
function GM_addStyle(doc, css) {
if (doc == null) {
console.error("Unable to add style for null document");
return;
}
const style = doc.createElement("style");
style.setAttribute("type", "text/css");
style.textContent = css;
try {
(doc.head || doc.documentElement).appendChild(style);
} catch {
setTimeout(() => {
doc.head.appendChild(style);
});
}
return style;
}
const style = font_lists
.map((font) => `@font-face { font-family: ${font}; src: local(${font}); }`)
.join("\n");
GM_addStyle(document, style); The above script can be loaded by ChromeXt. |
After reinstalling Chrome, now Chrome behaves the same way as other Chromium browsers. Hence, this should really be a bug of how system fonts are matching on Android 15+. |
See JingMatrix/ChromeXt#136 (comment) for a wrokaround of |
Currently, custom fonts added by MagiskFonts are not rendered correctly in WebView/Chromium based browsers.
This Zygisk module aims to solve this problem.
Here are relevant docs:
The text was updated successfully, but these errors were encountered: