Skip to content

Fix font loading normalization and improve font screen UX - #26

Closed
relativemodder wants to merge 5 commits into
teidesu:mainfrom
relativemodder:fix/fonts
Closed

Fix font loading normalization and improve font screen UX#26
relativemodder wants to merge 5 commits into
teidesu:mainfrom
relativemodder:fix/fonts

Conversation

@relativemodder

@relativemodder relativemodder commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added “Proxy Settings” to the navigation drawer, including a toggle and quick access to proxy configuration.
    • Added an import-progress UI for font imports with animated placeholder rows and localized “Importing font…” messages.
  • Bug Fixes

    • Fixed imported fonts with inflated vertical metrics that could add incorrect top/bottom padding.
    • Improved proxy settings appearance in MD3 layouts by preventing hardcoded cell background overrides.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27ecd8ca-abcd-40d1-9c12-58fb3a02a5de

📥 Commits

Reviewing files that changed from the base of the PR and between 58693ee and 79f4fe5.

📒 Files selected for processing (4)
  • FEATURES.md
  • src/kotlin/helpers/font/FontLibrary.kt
  • src/kotlin/ui/drawer/DrawerProxyCell.kt
  • src/kotlin/ui/settings/fonts/FontsSettingsActivity.kt
🚧 Files skipped from review as they are similar to previous changes (4)
  • FEATURES.md
  • src/kotlin/ui/drawer/DrawerProxyCell.kt
  • src/kotlin/ui/settings/fonts/FontsSettingsActivity.kt
  • src/kotlin/helpers/font/FontLibrary.kt

📝 Walkthrough

Walkthrough

Imported fonts now normalize inflated vertical metrics and show progress placeholders during import. The navigation drawer gains proxy controls with state synchronization, and proxy list cells no longer override MD3 section backgrounds.

Changes

Font import pipeline

Layer / File(s) Summary
Font metric normalization
src/kotlin/helpers/font/FontLibrary.kt, FEATURES.md
Staged fonts are normalized before system loadability checks, with table checksums updated after metric changes.
Font import progress UI
src/kotlin/ui/settings/fonts/FontsSettingsActivity.kt, src/res/values*/strings_inu.xml
Font imports display localized progress text and shimmer placeholders, block overlapping additions, and refresh the roster after completion.

Proxy drawer integration

Layer / File(s) Summary
Proxy drawer row and switch
src/kotlin/ui/drawer/DrawerProxyCell.kt, src/kotlin/ui/drawer/DrawerLayoutAdapter.kt
Adds a proxy row with themed rendering, RTL-aware switch hit testing, visibility handling, and enabled-state binding.
Proxy state and navigation wiring
src/kotlin/helpers/dialogs/DrawerHelper.kt
Routes the drawer row to ProxyListActivity, applies proxy settings through ConnectionsManager, and refreshes state through notifications.
Proxy list MD3 backgrounds
patches/bugfix/proxy-list-md3-sections.patch, series
Removes forced white backgrounds from proxy list cells and registers the patch in the series.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FontsSettingsActivity
  participant FontLibrary
  participant FontImportSkeletonRow
  User->>FontsSettingsActivity: pick font URIs
  FontsSettingsActivity->>FontImportSkeletonRow: show import placeholders
  FontsSettingsActivity->>FontLibrary: import fonts in background
  FontLibrary-->>FontsSettingsActivity: return imported faces
  FontsSettingsActivity->>FontsSettingsActivity: refresh font roster
Loading
sequenceDiagram
  participant User
  participant DrawerProxyCell
  participant DrawerHelper
  participant ConnectionsManager
  participant NotificationCenter
  User->>DrawerProxyCell: toggle proxy switch
  DrawerProxyCell->>DrawerHelper: report enabled state
  DrawerHelper->>ConnectionsManager: apply proxy configuration
  DrawerHelper->>NotificationCenter: post proxySettingsChanged
  NotificationCenter-->>DrawerHelper: refresh drawer state
Loading

Possibly related PRs

  • teidesu/inugram#19: Earlier font-management work extended here with import placeholders and font metric normalization.
  • teidesu/inugram#24: Related proxy drawer integration and MD3 proxy-list background changes.
  • teidesu/inugram#5: Related Russian localization resource changes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main font-loading normalization fix and the related font-screen UX improvements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/kotlin/ui/settings/fonts/FontsSettingsActivity.kt (1)

280-305: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Always clear import progress when background processing fails.

If FontLibrary.importFromUris throws, the UI callback never runs; importPlaceholderCount remains nonzero and Add stays disabled for the process lifetime. Wrap the import in try/finally or return a failure result, then clear placeholders and show the failure bulletin on the UI thread.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/kotlin/ui/settings/fonts/FontsSettingsActivity.kt` around lines 280 -
305, Ensure the import flow around FontLibrary.importFromUris always clears
import progress when background processing throws. Catch failures or use
finally, then dispatch setImportPlaceholderCount(0, notifyOthers = true) and the
existing InuFontImportFailed bulletin on the UI thread, while preserving the
current success and rejection handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@FEATURES.md`:
- Line 221: Update the FEATURES.md claim to refer specifically to standalone
TTF/OTF fonts rather than imported fonts generally. Keep the statement focused
on inflated vertical metrics not adding bogus top/bottom padding, and do not
imply TTC collection support.

In `@src/kotlin/helpers/font/FontLibrary.kt`:
- Around line 371-380: Replace the two debug logging calls in
normalizeVerticalMetrics with android.util.Log.d, including the normalized and
unknown-magic messages. Leave the existing FileLog.e error logging unchanged.
- Around line 428-448: The normalization logic around shouldNormalizeHeadBox and
shouldNormalizeWinBox must account for actual glyph extents before reducing font
bounds. Calculate or preserve the font’s contour extrema, clamp targetAsc and
targetDesc so the head table contains every glyph, and ensure
usWinAscent/usWinDescent remain large enough to avoid clipping before writing
the fields.
- Around line 367-369: TTC containers are currently skipped by the font
normalization logic in FontLibrary.kt around the readInt magic check; either
implement traversal of each TTC face so affected table checksums are updated, or
explicitly exclude/reject TTC files. If TTC support is not added, update
FEATURES.md at line 221 to claim normalization only for standalone TTF/OTF
files; both listed sites require corresponding changes.
- Around line 477-495: Update tableChecksum to seek to offset once, then process
the padded table data through a reusable buffered byte array with sequential
reads instead of seeking for each four-byte word. Preserve the existing
big-endian checksum calculation, zero-padding of the final partial word, and
32-bit masking behavior.

In `@src/kotlin/ui/drawer/DrawerProxyCell.kt`:
- Around line 46-48: Update the child layout parameters in DrawerProxyCell to
respect the existing isRTL flag: swap LEFT/RIGHT gravities and exchange
corresponding left/right margins for imageView, textView, and checkBox. Preserve
the current dimensions, vertical positioning, and spacing in LTR while ensuring
mirrored placement and non-overlapping views in RTL.

---

Outside diff comments:
In `@src/kotlin/ui/settings/fonts/FontsSettingsActivity.kt`:
- Around line 280-305: Ensure the import flow around FontLibrary.importFromUris
always clears import progress when background processing throws. Catch failures
or use finally, then dispatch setImportPlaceholderCount(0, notifyOthers = true)
and the existing InuFontImportFailed bulletin on the UI thread, while preserving
the current success and rejection handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dca46331-96a7-4d63-96be-d25b7879dcb9

📥 Commits

Reviewing files that changed from the base of the PR and between 55495fe and 58693ee.

📒 Files selected for processing (12)
  • FEATURES.md
  • patches/bugfix/proxy-list-md3-sections.patch
  • series
  • src/kotlin/helpers/dialogs/DrawerHelper.kt
  • src/kotlin/helpers/font/FontLibrary.kt
  • src/kotlin/ui/drawer/DrawerLayoutAdapter.kt
  • src/kotlin/ui/drawer/DrawerProxyCell.kt
  • src/kotlin/ui/settings/fonts/FontsSettingsActivity.kt
  • src/res/values-ja/strings_inu.xml
  • src/res/values-ru/strings_inu.xml
  • src/res/values-zh-rCN/strings_inu.xml
  • src/res/values/strings_inu.xml

Comment thread FEATURES.md Outdated
Comment on lines +367 to +369
when (val magic = raf.readInt()) {
0x74746366 -> Unit // TTC checkSumAdjustment is per-face; skip rather than risk corrupting it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Either normalize TTC faces or narrow the feature scope.

The implementation explicitly skips TTC containers while the feature documentation covers imported fonts generally.

  • src/kotlin/helpers/font/FontLibrary.kt#L367-L369: traverse each TTC font directory and update affected table checksums, or explicitly reject/exclude TTC normalization.
  • FEATURES.md#L221-L221: limit the claim to standalone TTF/OTF files until TTC support exists.
📍 Affects 2 files
  • src/kotlin/helpers/font/FontLibrary.kt#L367-L369 (this comment)
  • FEATURES.md#L221-L221
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/kotlin/helpers/font/FontLibrary.kt` around lines 367 - 369, TTC
containers are currently skipped by the font normalization logic in
FontLibrary.kt around the readInt magic check; either implement traversal of
each TTC face so affected table checksums are updated, or explicitly
exclude/reject TTC files. If TTC support is not added, update FEATURES.md at
line 221 to claim normalization only for standalone TTF/OTF files; both listed
sites require corresponding changes.

Source: Coding guidelines

Comment thread src/kotlin/helpers/font/FontLibrary.kt
Comment thread src/kotlin/helpers/font/FontLibrary.kt Outdated
Comment thread src/kotlin/helpers/font/FontLibrary.kt Outdated
Comment thread src/kotlin/ui/drawer/DrawerProxyCell.kt Outdated
@teidesu

teidesu commented Jul 17, 2026

Copy link
Copy Markdown
Owner

merged in 39ef155, thanks!

@teidesu teidesu closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants