-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
base: master
Are you sure you want to change the base?
Conversation
…lculated with the same offset like the offset of the font. this differed before what leaded to issues. still the old way is available as legacy
… setting for this mode making a differene between legacy and baseline (and future bounds) on the positioning of the characters
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 ); |
There was a problem hiding this comment.
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 );
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
Tests failed for Qt 6One or more tests failed using the build from commit 9506122 fontmarker (fontMarkerSymbol)fontmarkerTest 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_styleTest 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_outlineTest 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_boundsTest 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_datadefinedpropertiesTest 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_opacityddcolorTest 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_ddopacityTest 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_largesizeTest 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_geometrygeometrygenerator_feature_geometryTest 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_geometrygeometrygenerator_function_geometryTest 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_variablepart_num_variableTest 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_variablepoly_part_num_variableTest 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. |
Tests failed for Qt 5One or more tests failed using the build from commit 9506122 fontmarker (fontMarkerSymbol)fontmarkerTest 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_styleTest 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_outlineTest 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_boundsTest 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_datadefinedpropertiesTest 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_opacityddcolorTest 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_ddopacityTest 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_largesizeTest 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_geometrygeometrygenerator_feature_geometryTest 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_geometrygeometrygenerator_function_geometryTest 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_variablepart_num_variableTest 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_variablepoly_part_num_variableTest 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. |
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.
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.
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
Only works when the if the maximum font size is not exceeded:
Screencast from 08.01.2025 10:21:22.webm
Could be fixed by raising this https://github.com/qgis/QGIS/blob/master/src/core/symbology/qgsmarkersymbollayer.cpp#L44 but I don't know the effects.
Not working on "Meters at Scale". Don't know the exact reason. Would work with this "hack" https://github.com/qgis/QGIS/pull/60080/files#r1906881851