@@ -780,15 +780,13 @@ void PPGeMeasureText(float *w, float *h, std::string_view text, float scale, int
780
780
std::string s = PPGeSanitizeText (text);
781
781
782
782
if (HasTextDrawer ()) {
783
- std::string s2 = ReplaceAll (s, " &" , " &&" );
784
-
785
783
float mw, mh;
786
784
textDrawer->SetFontScale (scale, scale);
787
785
int dtalign = (WrapType & PPGE_LINE_WRAP_WORD) ? FLAG_WRAP_TEXT : 0 ;
788
786
if (WrapType & PPGE_LINE_USE_ELLIPSIS)
789
787
dtalign |= FLAG_ELLIPSIZE_TEXT;
790
788
Bounds b (0 , 0 , wrapWidth <= 0 ? 480 .0f : wrapWidth, 272 .0f );
791
- textDrawer->MeasureStringRect (s2 , b, &mw, &mh, dtalign);
789
+ textDrawer->MeasureStringRect (s , b, &mw, &mh, dtalign);
792
790
793
791
if (w)
794
792
*w = mw;
@@ -898,14 +896,14 @@ inline int GetPow2(int x) {
898
896
return ret;
899
897
}
900
898
901
- static PPGeTextDrawerImage PPGeGetTextImage (const char * text, const PPGeStyle &style, float maxWidth, bool wrap) {
899
+ static PPGeTextDrawerImage PPGeGetTextImage (std::string_view text, const PPGeStyle &style, float maxWidth, bool wrap) {
902
900
int tdalign = 0 ;
903
901
tdalign |= FLAG_ELLIPSIZE_TEXT;
904
902
if (wrap) {
905
903
tdalign |= FLAG_WRAP_TEXT;
906
904
}
907
905
908
- PPGeTextDrawerCacheKey key{ text, tdalign, maxWidth / style.scale };
906
+ PPGeTextDrawerCacheKey key{ std::string ( text) , tdalign, maxWidth / style.scale };
909
907
PPGeTextDrawerImage im{};
910
908
911
909
auto cacheItem = textDrawerImages.find (key);
@@ -1065,7 +1063,7 @@ void PPGeDrawText(std::string_view text, float x, float y, const PPGeStyle &styl
1065
1063
}
1066
1064
1067
1065
if (HasTextDrawer ()) {
1068
- PPGeTextDrawerImage im = PPGeGetTextImage (ReplaceAll ( str, " & " , " && " ). c_str () , style, 480 .0f - x, false );
1066
+ PPGeTextDrawerImage im = PPGeGetTextImage (str, style, 480 .0f - x, false );
1069
1067
if (im.ptr ) {
1070
1068
PPGeDrawTextImage (im, x, y, style);
1071
1069
return ;
@@ -1116,13 +1114,11 @@ void PPGeDrawTextWrapped(std::string_view text, float x, float y, float wrapWidt
1116
1114
float maxScaleDown = zoom == 1 ? 1 .3f : 2 .0f ;
1117
1115
1118
1116
if (HasTextDrawer ()) {
1119
- std::string s2 = ReplaceAll (s, " &" , " &&" );
1120
-
1121
1117
float actualWidth, actualHeight;
1122
1118
Bounds b (0 , 0 , wrapWidth <= 0 ? 480 .0f - x : wrapWidth, wrapHeight);
1123
1119
int tdalign = 0 ;
1124
1120
textDrawer->SetFontScale (style.scale , style.scale );
1125
- textDrawer->MeasureStringRect (s2 , b, &actualWidth, &actualHeight, tdalign | FLAG_WRAP_TEXT);
1121
+ textDrawer->MeasureStringRect (s , b, &actualWidth, &actualHeight, tdalign | FLAG_WRAP_TEXT);
1126
1122
1127
1123
// Check if we need to scale the text down to fit better.
1128
1124
PPGeStyle adjustedStyle = style;
@@ -1138,14 +1134,14 @@ void PPGeDrawTextWrapped(std::string_view text, float x, float y, float wrapWidt
1138
1134
actualHeight = (maxLines + 1 ) * lineHeight;
1139
1135
// Add an ellipsis if it's just too long to be readable.
1140
1136
// On a PSP, it does this without scaling it down.
1141
- s2 = StripTrailingWhite (CropLinesToCount (s2 , (int )maxLines));
1142
- s2 .append (" \n ..." );
1137
+ s = StripTrailingWhite (CropLinesToCount (s , (int )maxLines));
1138
+ s .append (" \n ..." );
1143
1139
}
1144
1140
1145
1141
adjustedStyle.scale *= wrapHeight / actualHeight;
1146
1142
}
1147
1143
1148
- PPGeTextDrawerImage im = PPGeGetTextImage (s2. c_str () , adjustedStyle, wrapWidth <= 0 ? 480 .0f - x : wrapWidth, true );
1144
+ PPGeTextDrawerImage im = PPGeGetTextImage (s , adjustedStyle, wrapWidth <= 0 ? 480 .0f - x : wrapWidth, true );
1149
1145
if (im.ptr ) {
1150
1146
PPGeDrawTextImage (im, x, y, adjustedStyle);
1151
1147
return ;
0 commit comments