Migrate to woff2 fonts with woff2ttf decoder#908
Conversation
WalkthroughThis pull request switches icon font sources to WOFF2 and decodes them to TTF when downloaded. MaterialFontRepository now decodes downloaded WOFF2 bytes; three MaterialIconFontFamily CDN URLs were changed from .ttf to .woff2 (Outlined, Rounded, Sharp); LucideRepository now fetches lucide.woff2 and decodes it to TTF. Public classes and method signatures remain unchanged. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fd2b19d to
15af299
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tools/idea-plugin/CHANGELOG.md`:
- Line 17: Fix the typo in the changelog entry string "- [Web Import] Forse
`Material Symbols` and `Lucide` icons providers to use woff2 font" by changing
"Forse" to "Force" and update "icons providers" to "icon providers" so the line
reads "- [Web Import] Force `Material Symbols` and `Lucide` icon providers to
use woff2 font"; edit the CHANGELOG.md entry containing that exact text.
In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/standard/lucide/data/LucideRepository.kt`:
- Around line 48-53: The cached fontBytesCache is being returned by reference
(from the block that fetches via
httpClient.get(FONT_URL).bodyAsChannel().toByteArray() and decodes with
Woff2Decoder.decodeBytes), which allows callers to mutate the shared ByteArray;
fix by storing a defensive copy into fontBytesCache and always returning a copy
to callers (i.e., after decoding ttfBytes make fontBytesCache =
ttfBytes.copyOf() and return fontBytesCache.copyOf()), so neither the stored
cache nor subsequent callers can be mutated externally.
ℹ️ Review info
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
tools/idea-plugin/CHANGELOG.mdtools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/data/font/MaterialFontRepository.kttools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/domain/model/font/MaterialIconFontFamily.kttools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/standard/lucide/data/LucideRepository.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/domain/model/font/MaterialIconFontFamily.kt
15af299 to
18d5117
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/data/font/MaterialFontRepository.kt (1)
17-20: Split network I/O and decode CPU work across dispatchers.
downloadFontcurrently performs both fetch and decode onDispatchers.IO. Consider decoding onDispatchers.Defaultto avoid saturating I/O threads during bulk imports.Proposed refactor
suspend fun downloadFont(url: String): ByteArray = withContext(Dispatchers.IO) { - val woff2Bytes = httpClient.get(url).bodyAsChannel().toByteArray() - - Woff2Decoder.decodeBytes(woff2Bytes) ?: error("Failed to decode WOFF2 font") + val woff2Bytes = httpClient.get(url).bodyAsChannel().toByteArray() + withContext(Dispatchers.Default) { + Woff2Decoder.decodeBytes(woff2Bytes) ?: error("Failed to decode WOFF2 font") + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/data/font/MaterialFontRepository.kt` around lines 17 - 20, downloadFont currently performs both network I/O and CPU-heavy WOFF2 decoding on Dispatchers.IO; change it to fetch the bytes on Dispatchers.IO (keep the httpClient.get(...).bodyAsChannel().toByteArray() call there) then switch to Dispatchers.Default for the Woff2Decoder.decodeBytes(woff2Bytes) call and any subsequent processing, returning the decoded ByteArray or throwing the same error on failure. Ensure you use withContext(Dispatchers.Default) around the decode step so only the I/O portion runs on IO threads and the decode runs on Default.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/data/font/MaterialFontRepository.kt`:
- Around line 17-20: downloadFont currently performs both network I/O and
CPU-heavy WOFF2 decoding on Dispatchers.IO; change it to fetch the bytes on
Dispatchers.IO (keep the httpClient.get(...).bodyAsChannel().toByteArray() call
there) then switch to Dispatchers.Default for the
Woff2Decoder.decodeBytes(woff2Bytes) call and any subsequent processing,
returning the decoded ByteArray or throwing the same error on failure. Ensure
you use withContext(Dispatchers.Default) around the decode step so only the I/O
portion runs on IO threads and the decode runs on Default.
ℹ️ Review info
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
tools/idea-plugin/CHANGELOG.mdtools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/data/font/MaterialFontRepository.kttools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/domain/model/font/MaterialIconFontFamily.kttools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/standard/lucide/data/LucideRepository.kt
🚧 Files skipped from review as they are similar to previous changes (2)
- tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/material/domain/model/font/MaterialIconFontFamily.kt
- tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/standard/lucide/data/LucideRepository.kt
📝 Changelog
If this PR introduces user-facing changes, please update the relevant Unreleased section in changelogs: