+// Do not use this pointer directly, it's only used by
+// GetDrawTextStringFormat() and the cleanup code in wxGDIPlusRendererModule.
+StringFormat* gs_drawTextStringFormat = NULL;
+
+// Get the string format used for the text drawing and measuring functions:
+// notice that it must be the same one for all of them, otherwise the drawn
+// text might be of different size than what measuring it returned.
+inline StringFormat* GetDrawTextStringFormat()
+{
+ if ( !gs_drawTextStringFormat )
+ {
+ // We create this string format with exactly the same flags as
+ // StringFormat::GenericTypographic() is documented to use in MSDN
+ // except for the last one which doesn't make any difference for
+ // DrawText() but that we do want to use when measuring text.
+ //
+ // The reason for not just using GenericTypographic itself is that it
+ // does something else (what exactly is unfortunately not documented),
+ // which results in string being displayed quite differently from the
+ // default rendering, see #14537.
+ gs_drawTextStringFormat
+ = new StringFormat
+ (
+ StringFormatFlagsLineLimit |
+ StringFormatFlagsNoClip |
+ StringFormatFlagsNoFitBlackBox |
+ StringFormatFlagsMeasureTrailingSpaces
+ );
+ }
+
+ return gs_drawTextStringFormat;
+}
+