Skip to content

Add font size customization options - #661

Closed
douglasduarte wants to merge 1 commit into
nfephp-org:masterfrom
douglasduarte:codex/font-size-customization
Closed

Add font size customization options#661
douglasduarte wants to merge 1 commit into
nfephp-org:masterfrom
douglasduarte:codex/font-size-customization

Conversation

@douglasduarte

@douglasduarte douglasduarte commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add global font size scaling support to the shared PDF renderer.
  • Add exact font size replacements through a font size map.
  • Expose the configuration through DaCommon and apply it when auxiliary documents create their internal PDF instances.
  • Document DANFE usage and add tests for PDF font sizing and DANFE rendering with customized font sizes.

Usage

$danfe = new Danfe($xml);
$danfe->setFontSizeScale(0.9, 4);
$danfe->setFontSizeMap([
    10 => 9,
    8 => 7,
    '5.7' => 5,
]);
$pdf = $danfe->render();

Tests

  • vendor/bin/phpunit --filter 'PdfFontSizeTest|DanfeTest'
  • php -l src/Common/DaCommon.php && php -l src/Legacy/Pdf.php && php -l src/NFe/Danfe.php && php -l src/NFe/Traits/TraitBlocoIX.php

Note: running composer test locally with PHP 8.4 currently fails in NFePHP\DA\Tests\NFSe\DanfseTest::testUsaIbscbsConsolidadoDaInfNfseQuandoInformado because the generated text contains Base de Cálculo Após Exclusões e Reduções R$ 985,00 while the test expects R$ 777,77. This failure is outside the font customization changes.

@douglasduarte

Copy link
Copy Markdown
Contributor Author

Closing this proposal to redesign the API with explicit per-DANFE-element font settings.

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