From bbf35166115ecf66edf863dde92a02be85bd2cc9 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 20 Sep 2025 13:27:16 -0700 Subject: [PATCH] Fix QA ToStdString does not work in C locale --- common/plotters/PDF_plotter.cpp | 7 ++++++- common/plotters/pdf_outline_font.cpp | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 3ed60bbff0..48bee8e654 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -1965,7 +1966,11 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos, bool textMirrored = aSize.x < 0; // Parse the text for markup - MARKUP::MARKUP_PARSER markupParser( text.ToStdString() ); + // IMPORTANT: Use explicit UTF-8 encoding. wxString::ToStdString() is locale-dependent + // and under C/POSIX locale can drop or mangle non-ASCII, leading to missing CMaps. + // The markup parser expects UTF-8 bytes. + UTF8 utf8Text( text ); + MARKUP::MARKUP_PARSER markupParser( utf8Text.substr() ); std::unique_ptr markupTree( markupParser.Parse() ); if( !markupTree ) diff --git a/common/plotters/pdf_outline_font.cpp b/common/plotters/pdf_outline_font.cpp index 58048ccb2f..e99c6b0d51 100644 --- a/common/plotters/pdf_outline_font.cpp +++ b/common/plotters/pdf_outline_font.cpp @@ -386,8 +386,6 @@ std::string PDF_OUTLINE_FONT_SUBSET::sanitizeFontName( const wxString& aName ) { if( std::isalnum( ch ) ) sanitized.push_back( static_cast( ch ) ); - else if( ch == '-' ) - sanitized.push_back( '-' ); else sanitized.push_back( '-' ); }