Repository navigation
PERF: Measure the pole figure label width on a 1x1 canvas - #71
Closed
imikejackson wants to merge 1 commit into
Closed
imikejackson wants to merge 1 commit into
imikejackson wants to merge 1 commit into
Conversation
PoleFigureCompositor::computeLayoutMetrics measured the letter X on a canvas as large as one pole figure. At imageDim 8000 this canvas used about 1 GB for each composite. The measured width depends only on the font and the font size, so the function now uses a 1x1 canvas. The layout metrics do not change. Add a test that checks the layout metrics at imageDim 128 against the X advance width read from the Lato Bold font tables. Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
This was referenced Nov 12, 2026
Collaborator
Author
|
Closed in favor of #86, which merges this branch (with its history) together with the other open EbsdLib fixes for the next release, so simplnx can build against one EbsdLib branch. The branch is kept. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PoleFigureCompositor::computeLayoutMetricsmeasures the width of the letter X to calculate the composite layout. It measured the letter on a canvas as large as one pole figure (imageDimximageDim). A canvas allocates 16 bytes for each pixel, so atimageDim8000 this temporary canvas used about 1 GB for each composite. The measured width depends only on the font and the font size, so the function now uses a 1x1 canvas. The layout metrics do not change.DiscretePoleFigureCompositoruses the same function and gets the same change. 2 files changed, +20 / −2 lines.1. Text measurement
Source/EbsdLib/Utilities/PoleFigureCompositor.cpp— 1x1 measurement canvas.canvas_ity::canvas::measure_textadds the advance widths of the glyphs and multiplies the sum by the font scale.set_fontsets that scale to the font size divided by the units per em of the font. Neither function reads the canvas size. All othercanvas_ity::canvasobjects inSource/are drawn on, so they keep their sizes.2. Test
Source/Test/PoleFigureCompositorTest.cpp—LayoutMetrics_FontAdvanceOracle.The test checks
subCanvasWidth(145.432),pageWidth(580) andpageHeight(176) atimageDim128 with the Horizontal layout. The expected values come from the embedded Lato Bold font tables: the X advance is 1358 and the units per em is 2000, so the X width at font size 8 is 5.432. The test fails when the measured width changes. It cannot detect the size of the measurement canvas, because the result is the same for every canvas size.Companion pull request: BlueQuartzSoftware/simplnx#1965 makes the same change in the Write Pole Figure preflight. The two pull requests do not depend on each other.
Test plan
LayoutMetrics_FontAdvanceOraclepasses, and fails when 1 px is added to the measured width.Related Issue