Skip to content

Add support for embedded fonts and multi-column sections - #16

Merged
sahebansari merged 2 commits into
masterfrom
chore/repo-readiness
Aug 29, 2026
Merged

sahebansari merged 2 commits into
masterfrom
chore/repo-readiness

Conversation

@sahebansari

Copy link
Copy Markdown
Owner
  • Introduced EmbeddedFont class to allow embedding fonts directly into HTML reports, ensuring self-contained documents without external font dependencies.
  • Added RowStyle class for row-specific styling options in reports.
  • Implemented MultiColumnSection class to facilitate multi-column layouts in reports, including functionality for measuring and rendering content across multiple columns.
  • Created unit tests for EmbeddedFont, ApproximateTextMeasurer, and MultiColumnSection to ensure correct behavior and edge case handling.
  • Added smoke tests for PlaywrightTextMeasurer to validate text measurement functionality.

Summary

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (existing API or generated output changes)
  • Documentation / samples only
  • Build, CI, or tooling

Checklist

  • dotnet build -c Release succeeds with no new warnings
  • dotnet test -c Release passes
  • Added or updated tests covering this change
  • Updated CHANGELOG.md under [Unreleased]
  • Updated the relevant docs under docs/
  • Public API additions have XML doc comments
  • No new runtime package dependencies added to the library project

Output Impact

Notes for Reviewers

- Introduced `EmbeddedFont` class to allow embedding fonts directly into HTML reports, ensuring self-contained documents without external font dependencies.
- Added `RowStyle` class for row-specific styling options in reports.
- Implemented `MultiColumnSection` class to facilitate multi-column layouts in reports, including functionality for measuring and rendering content across multiple columns.
- Created unit tests for `EmbeddedFont`, `ApproximateTextMeasurer`, and `MultiColumnSection` to ensure correct behavior and edge case handling.
- Added smoke tests for `PlaywrightTextMeasurer` to validate text measurement functionality.
Comment thread src/TerraFluent.Html.Reporting/Model/Elements/QrCodeImage.cs Fixed
})
.Build();

var outputPath = Path.Combine(AppContext.BaseDirectory, "playwright-measured-report.html");
}
}

var path = Path.Combine(Path.GetTempPath(), $"terrafluent-preview-{Guid.NewGuid():N}.html");
Comment on lines +41 to +44
catch (Exception ex)
{
Console.WriteLine($"Could not open a browser automatically ({ex.Message}) - open the file above manually.");
}
/// <summary>Resolves paths to the font files shipped in the fonts/ folder next to the built sample.</summary>
internal static class SampleFonts
{
public static string Resolve(string fileName) => Path.Combine(AppContext.BaseDirectory, "fonts", fileName);
Comment thread src/TerraFluent.Html.Reporting/Model/Elements/QrCodeImage.cs Fixed
Comment thread src/TerraFluent.Html.Reporting/Model/Elements/QrCodeImage.cs Fixed
Comment thread src/TerraFluent.Html.Reporting/Model/Elements/QrCodeImage.cs Fixed
Comment thread src/TerraFluent.Html.Reporting/Model/Elements/QrCodeImage.cs Fixed
Comment thread src/TerraFluent.Html.Reporting/Model/Elements/QrCodeImage.cs Fixed
- QrCodeImage: cast size to double before multiplying in LostPointLevel4
  to avoid a possible int-multiplication-then-cast precision loss
  (CodeQL error; not exploitable given size <= 177, but worth being
  precise about).
- QrCodeImage: extract IsFinderPatternDark/HasFinderLikeRatio helpers to
  de-duplicate and de-complexify the finder-pattern and masking-penalty
  conditions; use .Where(...) instead of foreach+if in two loops.
- MultiColumnSection: use Any(...) instead of foreach+if for the
  nested-section validation check.

All are behavior-preserving refactors - re-verified the QR encoder
end-to-end against an independent decoder (pyzbar) across 7 values
spanning versions 1-10 plus UTF-8 content; byte-for-byte identical PNG
output to before the change. Full unit (162) and browser (7) test
suites pass.
Comment on lines +418 to +420
(r >= 0 && r <= 6 && (c == 0 || c == 6))
|| (c >= 0 && c <= 6 && (r == 0 || r == 6))
|| (r >= 2 && r <= 4 && c >= 2 && c <= 4);
Comment on lines +730 to +732
!at(1) && at(4) && !at(5) && at(6) && !at(9)
&& ((at(0) && at(2) && at(3) && !at(7) && !at(8) && !at(10))
|| (!at(0) && !at(2) && !at(3) && at(7) && at(8) && at(10)));
@sahebansari

Copy link
Copy Markdown
Owner Author

merge

@sahebansari
sahebansari merged commit c9f787c into master Aug 29, 2026
4 checks passed
@sahebansari
sahebansari deleted the chore/repo-readiness branch August 29, 2026 20:08
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