diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index b958354..57f3811 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1292,7 +1292,7 @@ void SvgBuilder::_flushText() { // Append the character to the text buffer if (0 != glyph.code[0]) { - text_buffer.append((char *)&glyph.code, 1); + text_buffer.append(glyph.code, 1); } glyphs_in_a_row++; @@ -1350,18 +1350,21 @@ void SvgBuilder::addChar(GfxState *state, double x, double y, _text_position += delta; // Convert the character to UTF-8 since that's our SVG document's encoding - static UnicodeMap *u_map = NULL; - if ( u_map == NULL ) { - GooString *enc = new GooString("UTF-8"); - u_map = globalParams->getUnicodeMap(enc); - u_map->incRefCnt(); - delete enc; - } - int code_size = 0; - for ( int i = 0 ; i < uLen ; i++ ) { - code_size += u_map->mapUnicode(u[i], (char *)&new_glyph.code[code_size], sizeof(new_glyph.code) - code_size); - } - new_glyph.code_size = code_size; + gunichar2 uu[8]; + glong written; + + for (int i = 0 ; i < uLen ; i++) { + uu[i] = u[i]; + } + + new_glyph.code = g_utf16_to_utf8(uu, uLen, NULL, &written, NULL); + + if (written != NULL) { + new_glyph.code_size = (int) written; + } else { + new_glyph.code[0] = 0; + new_glyph.code_size = 0; + } // Copy current style if it has changed since the previous glyph if (_invalidated_style || _glyphs.size() == 0 ) { diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 3b9192d..952a190 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -77,7 +77,7 @@ struct SvgGlyph { Geom::Point text_position; // Absolute glyph coords in text space double dx, dy; // Advance values double rise; // Text rise parameter - char code[8]; // UTF-8 coded character + char* code; // UTF-8 coded character int code_size; bool is_space;