@@ -15,7 +15,7 @@ const float globalMinScale = 0.5f; // underscale by 1 zoom level
15
15
16
16
SymbolQuads getIconQuads (Anchor& anchor, const PositionedIcon& shapedIcon,
17
17
const GeometryCoordinates& line, const SymbolLayoutProperties& layout,
18
- const bool alongLine) {
18
+ const bool alongLine, const Shaping& shapedText ) {
19
19
20
20
auto image = *(shapedIcon.image );
21
21
@@ -24,11 +24,43 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon,
24
24
auto right = left + image.pos .w / image.relativePixelRatio ;
25
25
auto top = shapedIcon.top - border;
26
26
auto bottom = top + image.pos .h / image.relativePixelRatio ;
27
- Point <float > tl{left, top};
28
- Point <float > tr{right, top};
29
- Point <float > br{right, bottom};
30
- Point <float > bl{left, bottom};
31
-
27
+ Point <float > tl;
28
+ Point <float > tr;
29
+ Point <float > br;
30
+ Point <float > bl;
31
+
32
+ if (layout.iconTextFit != IconTextFitType::None && shapedText) {
33
+ auto iconWidth = right - left;
34
+ auto iconHeight = bottom - top;
35
+ auto size = layout.textSize / 24 .0f ;
36
+ auto textLeft = shapedText.left * size;
37
+ auto textRight = shapedText.right * size;
38
+ auto textTop = shapedText.top * size;
39
+ auto textBottom = shapedText.bottom * size;
40
+ auto textWidth = textRight - textLeft;
41
+ auto textHeight = textBottom - textTop;;
42
+ auto padT = layout.iconTextFitPadding .value [0 ];
43
+ auto padR = layout.iconTextFitPadding .value [1 ];
44
+ auto padB = layout.iconTextFitPadding .value [2 ];
45
+ auto padL = layout.iconTextFitPadding .value [3 ];
46
+ auto offsetY = layout.iconTextFit == IconTextFitType::Width ? (textHeight - iconHeight) * 0.5 : 0 ;
47
+ auto offsetX = layout.iconTextFit == IconTextFitType::Height ? (textWidth - iconWidth) * 0.5 : 0 ;
48
+ auto width = layout.iconTextFit == IconTextFitType::Width || layout.iconTextFit == IconTextFitType::Both ? textWidth : iconWidth;
49
+ auto height = layout.iconTextFit == IconTextFitType::Height || layout.iconTextFit == IconTextFitType::Both ? textHeight : iconHeight;
50
+ left = textLeft + offsetX - padL;
51
+ top = textTop + offsetY - padT;
52
+ right = textLeft + offsetX + padR + width;
53
+ bottom = textTop + offsetY + padB + height;
54
+ tl = {left, top};
55
+ tr = {right, top};
56
+ br = {right, bottom};
57
+ bl = {left, bottom};
58
+ } else {
59
+ tl = {left, top};
60
+ tr = {right, top};
61
+ br = {right, bottom};
62
+ bl = {left, bottom};
63
+ }
32
64
33
65
float angle = layout.iconRotate * util::DEG2RAD;
34
66
if (alongLine) {
0 commit comments