Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical anchor on font symbols to the bounds #60080

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

signedav
Copy link
Contributor

@signedav signedav commented Jan 8, 2025

Requires (branch of) #60044

And concerns bounds part from here #59732

Anchor can be set according to the bounds and not the line top and bottom.

image

The "old" anchors persists but are marked in the GUI (only in the GUI) as legacy.

Technical details

To evaluate the character offset we get the font metric bounds bottom and add the half of the bounds's height.

IMG_20250108_102708_1

To evaluate the top and bottom anchor then we don't concern the whole size but only the font metric bounds's height (there we need to "unscale" it first, to be able to use the standard markerOffset function).

Problems

@github-actions github-actions bot added this to the 3.42.0 milestone Jan 8, 2025
if ( mVerticalAnchorMode == VerticalAnchorMode::Bounds )
{
// when we use the bounds, the font metrics used are already scaled. To be able to deal with this, they should not be scaled, so we scale them back beforehand.
sizeToCalculateOffsets = context.renderContext().convertFromPainterUnits( mFontMetrics->boundingRect( mString.at( 0 ) ).height(), mSizeUnit );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This don't work with "Meter at Scale". It would work with converting, converting back and converting again. Don't know yet why...

    sizeToCalculateOffsets = context.renderContext().convertFromPainterUnits( mFontMetrics->boundingRect( mString.at( 0 ) ).height(), mSizeUnit );
    double newheight = context.renderContext().convertToPainterUnits(  sizeToCalculateOffsets, mSizeUnit);
    sizeToCalculateOffsets = context.renderContext().convertFromPainterUnits( newheight, mSizeUnit );

Copy link

github-actions bot commented Jan 8, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 9506122)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 9506122)

Copy link

github-actions bot commented Jan 8, 2025

Tests failed for Qt 6

One or more tests failed using the build from commit 9506122

fontmarker (fontMarkerSymbol)

fontmarker

Test failed at fontMarkerSymbol at tests/src/core/testqgsfontmarker.cpp:124

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker/expected_fontmarker.png (found 2288 pixels different)

fontmarker_style (fontMarkerSymbolStyle)

fontmarker_style

Test failed at fontMarkerSymbolStyle at tests/src/core/testqgsfontmarker.cpp:137

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_style/expected_fontmarker_style.png (found 2744 pixels different)

fontmarker_outline (fontMarkerSymbolStroke)

fontmarker_outline

Test failed at fontMarkerSymbolStroke at tests/src/core/testqgsfontmarker.cpp:169

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_outline/expected_fontmarker_outline.png (found 29738 pixels different)

fontmarker_bounds (bounds)

fontmarker_bounds

Test failed at bounds at tests/src/core/testqgsfontmarker.cpp:186

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_bounds/expected_fontmarker_bounds.png (found 179 pixels different)

fontmarker_datadefinedproperties (fontMarkerSymbolDataDefinedProperties)

fontmarker_datadefinedproperties

Test failed at fontMarkerSymbolDataDefinedProperties at tests/src/core/testqgsfontmarker.cpp:153

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_datadefinedproperties/expected_fontmarker_datadefinedproperties.png (found 2744 pixels different)

fontmarker_opacityddcolor (opacityWithDataDefinedColor)

fontmarker_opacityddcolor

Test failed at opacityWithDataDefinedColor at tests/src/core/testqgsfontmarker.cpp:207

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_opacityddcolor/expected_fontmarker_opacityddcolor.png (found 14243 pixels different)

fontmarker_ddopacity (dataDefinedOpacity)

fontmarker_ddopacity

Test failed at dataDefinedOpacity at tests/src/core/testqgsfontmarker.cpp:230

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_ddopacity/expected_fontmarker_ddopacity.png (found 14145 pixels different)

fontmarker_largesize (massiveFont)

fontmarker_largesize

Test failed at massiveFont at tests/src/core/testqgsfontmarker.cpp:253

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_largesize/expected_fontmarker_largesize.png (found 57541 pixels different)

geometrygenerator_feature_geometry

geometrygenerator_feature_geometry

Test failed at test_feature_geometry at tests/src/python/test_qgsgeometrygeneratorsymbollayer.py:610

Rendered image did not match tests/testdata/control_images/expected_geometrygenerator_feature_geometry/expected_geometrygenerator_feature_geometry.png (found 7194 pixels different)

geometrygenerator_function_geometry

geometrygenerator_function_geometry

Test failed at test_geometry_function at tests/src/python/test_qgsgeometrygeneratorsymbollayer.py:527

Rendered image did not match tests/testdata/control_images/expected_geometrygenerator_function_geometry/expected_geometrygenerator_function_geometry.png (found 7430 pixels different)

part_num_variable

part_num_variable

Test failed at testPartNum at tests/src/python/test_qgsmarkerlinesymbollayer.py:532

Rendered image did not match tests/testdata/control_images/symbol_markerline/expected_part_num_variable/expected_part_num_variable.png (found 6648 pixels different)

poly_part_num_variable

poly_part_num_variable

Test failed at testPartNumPolygon at tests/src/python/test_qgsmarkerlinesymbollayer.py:583

Rendered image did not match tests/testdata/control_images/symbol_markerline/expected_poly_part_num_variable/expected_poly_part_num_variable.png (found 4204 pixels different)

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

Copy link

github-actions bot commented Jan 8, 2025

Tests failed for Qt 5

One or more tests failed using the build from commit 9506122

fontmarker (fontMarkerSymbol)

fontmarker

Test failed at fontMarkerSymbol at tests/src/core/testqgsfontmarker.cpp:124

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker/expected_fontmarker.png (found 2288 pixels different)

fontmarker_style (fontMarkerSymbolStyle)

fontmarker_style

Test failed at fontMarkerSymbolStyle at tests/src/core/testqgsfontmarker.cpp:137

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_style/expected_fontmarker_style.png (found 2744 pixels different)

fontmarker_outline (fontMarkerSymbolStroke)

fontmarker_outline

Test failed at fontMarkerSymbolStroke at tests/src/core/testqgsfontmarker.cpp:169

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_outline/expected_fontmarker_outline.png (found 29738 pixels different)

fontmarker_bounds (bounds)

fontmarker_bounds

Test failed at bounds at tests/src/core/testqgsfontmarker.cpp:186

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_bounds/expected_fontmarker_bounds.png (found 179 pixels different)

fontmarker_datadefinedproperties (fontMarkerSymbolDataDefinedProperties)

fontmarker_datadefinedproperties

Test failed at fontMarkerSymbolDataDefinedProperties at tests/src/core/testqgsfontmarker.cpp:153

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_datadefinedproperties/expected_fontmarker_datadefinedproperties.png (found 2744 pixels different)

fontmarker_opacityddcolor (opacityWithDataDefinedColor)

fontmarker_opacityddcolor

Test failed at opacityWithDataDefinedColor at tests/src/core/testqgsfontmarker.cpp:207

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_opacityddcolor/expected_fontmarker_opacityddcolor.png (found 14243 pixels different)

fontmarker_ddopacity (dataDefinedOpacity)

fontmarker_ddopacity

Test failed at dataDefinedOpacity at tests/src/core/testqgsfontmarker.cpp:230

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_ddopacity/expected_fontmarker_ddopacity.png (found 14145 pixels different)

fontmarker_largesize (massiveFont)

fontmarker_largesize

Test failed at massiveFont at tests/src/core/testqgsfontmarker.cpp:253

Rendered image did not match tests/testdata/control_images/symbol_fontmarker/expected_fontmarker_largesize/expected_fontmarker_largesize.png (found 57543 pixels different)

geometrygenerator_feature_geometry

geometrygenerator_feature_geometry

Test failed at test_feature_geometry at tests/src/python/test_qgsgeometrygeneratorsymbollayer.py:610

Rendered image did not match tests/testdata/control_images/expected_geometrygenerator_feature_geometry/expected_geometrygenerator_feature_geometry.png (found 7194 pixels different)

geometrygenerator_function_geometry

geometrygenerator_function_geometry

Test failed at test_geometry_function at tests/src/python/test_qgsgeometrygeneratorsymbollayer.py:527

Rendered image did not match tests/testdata/control_images/expected_geometrygenerator_function_geometry/expected_geometrygenerator_function_geometry.png (found 7430 pixels different)

part_num_variable

part_num_variable

Test failed at testPartNum at tests/src/python/test_qgsmarkerlinesymbollayer.py:532

Rendered image did not match tests/testdata/control_images/symbol_markerline/expected_part_num_variable/expected_part_num_variable.png (found 6648 pixels different)

poly_part_num_variable

poly_part_num_variable

Test failed at testPartNumPolygon at tests/src/python/test_qgsmarkerlinesymbollayer.py:583

Rendered image did not match tests/testdata/control_images/symbol_markerline/expected_poly_part_num_variable/expected_poly_part_num_variable.png (found 4204 pixels different)

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

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