File tree Expand file tree Collapse file tree
src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414- [ Gutter] Add support for multiple icons in kt file
1515- [ Web Import] Add ` Remix ` icons provider
1616- [ Web Import] Add ` Box ` icons provider
17+ - [ Web Import] Force ` Material Symbols ` and ` Lucide ` icon providers to use woff2 font
1718
1819### Fixed
1920
Original file line number Diff line number Diff line change 11package io.github.composegears.valkyrie.ui.screen.webimport.material.data.font
22
33import io.github.composegears.valkyrie.ui.screen.webimport.material.domain.model.font.MaterialFontSettings
4+ import io.github.composegears.valkyrie.util.font.Woff2Decoder
45import io.ktor.client.HttpClient
56import io.ktor.client.request.get
67import io.ktor.client.statement.bodyAsChannel
@@ -14,7 +15,9 @@ class MaterialFontRepository(
1415 private val httpClient : HttpClient ,
1516) {
1617 suspend fun downloadFont (url : String ): ByteArray = withContext(Dispatchers .IO ) {
17- httpClient.get(url).bodyAsChannel().toByteArray()
18+ val woff2Bytes = httpClient.get(url).bodyAsChannel().toByteArray()
19+
20+ Woff2Decoder .decodeBytes(woff2Bytes) ? : error(" Failed to decode WOFF2 font" )
1821 }
1922
2023 suspend fun downloadSvg (
Original file line number Diff line number Diff line change @@ -6,17 +6,17 @@ enum class MaterialIconFontFamily(
66 val fontFamily : String ,
77) {
88 Outlined (
9- cdnUrl = " https://cdn.jsdelivr.net/gh/google/material-design-icons@master/variablefont/MaterialSymbolsOutlined%5BFILL%2CGRAD%2Copsz%2Cwght%5D.ttf " ,
9+ cdnUrl = " https://cdn.jsdelivr.net/gh/google/material-design-icons@master/variablefont/MaterialSymbolsOutlined%5BFILL%2CGRAD%2Copsz%2Cwght%5D.woff2 " ,
1010 displayName = " Outlined" ,
1111 fontFamily = " materialsymbolsoutlined" ,
1212 ),
1313 Rounded (
14- cdnUrl = " https://cdn.jsdelivr.net/gh/google/material-design-icons@master/variablefont/MaterialSymbolsRounded%5BFILL%2CGRAD%2Copsz%2Cwght%5D.ttf " ,
14+ cdnUrl = " https://cdn.jsdelivr.net/gh/google/material-design-icons@master/variablefont/MaterialSymbolsRounded%5BFILL%2CGRAD%2Copsz%2Cwght%5D.woff2 " ,
1515 displayName = " Rounded" ,
1616 fontFamily = " materialsymbolsrounded" ,
1717 ),
1818 Sharp (
19- cdnUrl = " https://cdn.jsdelivr.net/gh/google/material-design-icons@master/variablefont/MaterialSymbolsSharp%5BFILL%2CGRAD%2Copsz%2Cwght%5D.ttf " ,
19+ cdnUrl = " https://cdn.jsdelivr.net/gh/google/material-design-icons@master/variablefont/MaterialSymbolsSharp%5BFILL%2CGRAD%2Copsz%2Cwght%5D.woff2 " ,
2020 displayName = " Sharp" ,
2121 fontFamily = " materialsymbolssharp" ,
2222 ),
Original file line number Diff line number Diff line change 11package io.github.composegears.valkyrie.ui.screen.webimport.standard.lucide.data
22
3+ import io.github.composegears.valkyrie.util.font.Woff2Decoder
34import io.ktor.client.HttpClient
45import io.ktor.client.request.get
56import io.ktor.client.statement.bodyAsChannel
@@ -20,7 +21,7 @@ class LucideRepository(
2021) {
2122 companion object {
2223 private const val UNPKG_BASE = " https://unpkg.com/lucide-static@latest"
23- private const val FONT_URL = " $UNPKG_BASE /font/lucide.ttf "
24+ private const val FONT_URL = " $UNPKG_BASE /font/lucide.woff2 "
2425 private const val CSS_URL = " https://cdn.jsdelivr.net/npm/lucide-static@latest/font/lucide.css"
2526 }
2627
@@ -45,9 +46,10 @@ class LucideRepository(
4546 suspend fun loadFontBytes (): ByteArray = withContext(Dispatchers .IO ) {
4647 fontMutex.withLock {
4748 fontBytesCache ? : run {
48- val bytes = httpClient.get(FONT_URL ).bodyAsChannel().toByteArray()
49- fontBytesCache = bytes
50- bytes
49+ val woff2Bytes = httpClient.get(FONT_URL ).bodyAsChannel().toByteArray()
50+ val ttfBytes = Woff2Decoder .decodeBytes(woff2Bytes) ? : error(" Failed to decode WOFF2 font" )
51+ fontBytesCache = ttfBytes
52+ ttfBytes
5153 }
5254 }
5355 }
You can’t perform that action at this time.
0 commit comments