Skip to content

feat(pdf): print badge labels in the document's font - #396

Open
gcutrini wants to merge 1 commit into
feature/pdf-toolkit-loaders-v4from
feature/pdf-badge-font-v4
Open

gcutrini wants to merge 1 commit into
feature/pdf-toolkit-loaders-v4from
feature/pdf-badge-font-v4

Conversation

@gcutrini

Copy link
Copy Markdown
Contributor

ref: https://app.clickup.com/t/86bbf0d90

Builds on #393, so it shows only its own change. Please merge #393 first.

  • badge(text, { font, fontMetrics }) prints the label in the template's font. With fontMetrics, the badge is as wide as the label measures and its capital letters are centered. Without them, the badge is drawn as before.
  • A template passes both from its context: badge(text, { font: ctx.font, fontMetrics: ctx.fontMetrics }).
  • fontMetrics[style].textWidth(text) gives a text's width per em, read from the font file loadFont already downloads. The Helvetica fallback uses the widths of pdfmake's Helvetica.
  • The badge() doc comment sits on badge() again.

Same change as #395 for the 4.x line.

badge() takes the template's font and fontMetrics. The label prints in
that font, the badge is as wide as the label measures, and its capital
letters are centered. Without them, the badge is drawn as before: in
Helvetica, with a width estimated from the number of letters.

loadFont gives each style a textWidth, read from the font file, and
Helvetica's widths for the fallback.
@gcutrini gcutrini self-assigned this Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0cca3376-c354-4e24-8acc-b49543ce82fb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@santipalenque santipalenque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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