Use Inter custom font in ItemWebView

This commit is contained in:
Shinokuni 2024-04-13 15:58:16 +02:00
parent 7b644cbc97
commit d486bd92f9
6 changed files with 16 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,6 @@ package com.readrops.app.compose.item.view
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.util.Base64
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.compose.ui.graphics.Color
@ -50,8 +49,13 @@ class ItemWebView(
formatText(itemWithFeed)
)
val data = Base64.encodeToString(string.encodeToByteArray(), Base64.NO_PADDING)
loadData(data, "text/html; charset=utf-8", "base64")
loadDataWithBaseURL(
"file:///android_asset/",
string,
"text/html; charset=utf-8",
"UTF-8",
null
)
}
private fun formatText(itemWithFeed: ItemWithFeed): String {

View File

@ -15,6 +15,14 @@
%3$s: background color
*/
@font-face {
font-family: Inter;
font-style: normal;
font-weight: normal;
font-display: swap;
src: url("fonts/Inter-Regular.woff2") format("woff2");
}
a:link, a:active, a:hover { color: %1$s }
* {
@ -31,6 +39,7 @@
margin-right: 3%%;
color: %2$s;
background-color: %3$s;
font-family: Inter !important;
}
figure, img, iframe, video {