Skip to content

Use font in resources for exporting qrs#1046

Merged
SzBeni2003 merged 2 commits into
stagingfrom
fix/qr-export-font-missing
Jul 2, 2026
Merged

Use font in resources for exporting qrs#1046
SzBeni2003 merged 2 commits into
stagingfrom
fix/qr-export-font-missing

Conversation

@SzBeni2003

@SzBeni2003 SzBeni2003 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved QR export image text rendering by using a custom TrueType font when available.
    • Added a safe fallback to the default system font if the custom font can’t be loaded.
    • Font-loading problems are now logged to help diagnose rendering issues.

@coderabbitai

coderabbitai Bot commented Jun 30, 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: 0a878c0e-d404-49ae-967d-0a6812e9d4fb

📥 Commits

Reviewing files that changed from the base of the PR and between a8c777e and fdf49da.

📒 Files selected for processing (1)
  • backend/src/main/kotlin/hu/bme/sch/cmsch/component/token/QrExporterDashboard.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/src/main/kotlin/hu/bme/sch/cmsch/component/token/QrExporterDashboard.kt

📝 Walkthrough

Walkthrough

QrExporterDashboard now logs font-loading failures, attempts to load a custom OpenSans TrueType font, and falls back to a default sans-serif font when the resource is unavailable or cannot be loaded.

Changes

QR Export Font Handling

Layer / File(s) Summary
Font loading and rendering integration
backend/src/main/kotlin/hu/bme/sch/cmsch/component/token/QrExporterDashboard.kt
Adds SLF4J logging, loads /OpenSans-Regular.ttf in a companion object with warning-on-failure fallback to null, and uses the loaded font for QR export text when available, otherwise falling back to sans-serif.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly matches the main change: loading and using a resource font when exporting QR images.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/qr-export-font-missing

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.

@SzBeni2003 SzBeni2003 changed the title Import font to use for exporting qrs Use font in resources for exporting qrs Jun 30, 2026
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmsch-cst Ready Ready Preview, Comment Jul 2, 2026 10:40am
cmsch-felezobal Ready Ready Preview, Comment Jul 2, 2026 10:40am
cmsch-golyakorte Ready Ready Preview, Comment Jul 2, 2026 10:40am
cmsch-seniortabor Ready Ready Preview, Comment Jul 2, 2026 10:40am
cmsch-skktv Ready Ready Preview, Comment Jul 2, 2026 10:40am
cmsch-snyt Ready Ready Preview, Comment Jul 2, 2026 10:40am
cmsch-vitorlaskupa Ready Ready Preview, Comment Jul 2, 2026 10:40am

Request Review

@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: 1

🤖 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
`@backend/src/main/kotlin/hu/bme/sch/cmsch/component/token/QrExporterDashboard.kt`:
- Around line 74-85: The `renderFont` initialization in `QrExporterDashboard`
leaks the `fontStream` resource because `getResourceAsStream` is never closed.
Update the `try` block to wrap the stream in a scoped close pattern such as `use
{}` around the `Font.createFont` call, and keep the existing `logger.warn` paths
for missing or failing font loads; ensure the stream is always closed regardless
of success or exception.
🪄 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: 6291f5dd-82a8-46c4-8d71-596f63a191d4

📥 Commits

Reviewing files that changed from the base of the PR and between f4b0b49 and a8c777e.

📒 Files selected for processing (1)
  • backend/src/main/kotlin/hu/bme/sch/cmsch/component/token/QrExporterDashboard.kt

@SzBeni2003 SzBeni2003 deleted the fix/qr-export-font-missing branch July 2, 2026 10:42
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.

1 participant