summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2010-10-03 08:54:33 +0000
committerJon A. Cruz <jon@joncruz.org>2010-10-03 08:54:33 +0000
commitc673771aa41b30f73a9a65364049c3ea05dd4a47 (patch)
tree8dd1ef10010c5a4478d60f37faa72a512fc8f6d2 /src
parentWarning cleanup. (diff)
downloadinkscape-c673771aa41b30f73a9a65364049c3ea05dd4a47.tar.gz
inkscape-c673771aa41b30f73a9a65364049c3ea05dd4a47.zip
Applied patch and updated to address non-BMP Unicode charcters. Fixes bug #369861.
Fixed bugs: - https://launchpad.net/bugs/369861 (bzr r9812)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp35
-rw-r--r--src/extension/internal/pdfinput/svg-builder.h7
2 files changed, 23 insertions, 19 deletions
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index b9583545f..e343dbf33 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -1291,8 +1291,8 @@ void SvgBuilder::_flushText() {
last_delta_pos = delta_pos;
// Append the character to the text buffer
- if (0 != glyph.code[0]) {
- text_buffer.append((char *)&glyph.code, 1);
+ if ( !glyph.code.empty() ) {
+ text_buffer.append(1, glyph.code[0]);
}
glyphs_in_a_row++;
@@ -1333,8 +1333,8 @@ void SvgBuilder::addChar(GfxState *state, double x, double y,
return;
}
// Allow only one space in a row
- if ( is_space && _glyphs[_glyphs.size() - 1].code_size == 1 &&
- _glyphs[_glyphs.size() - 1].code[0] == 32 ) {
+ if ( is_space && (_glyphs[_glyphs.size() - 1].code.size() == 1) &&
+ (_glyphs[_glyphs.size() - 1].code[0] == 32) ) {
Geom::Point delta(dx, dy);
_text_position += delta;
return;
@@ -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] = {0};
+
+ for (int i = 0; i < uLen; i++) {
+ uu[i] = u[i];
+ }
+
+ gchar *tmp = g_utf16_to_utf8(uu, uLen, NULL, NULL, NULL);
+ if ( tmp && *tmp ) {
+ new_glyph.code = tmp;
+ } else {
+ new_glyph.code.clear();
+ }
+ g_free(tmp);
+ }
// 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 3b9192d31..f0062bbe6 100644
--- a/src/extension/internal/pdfinput/svg-builder.h
+++ b/src/extension/internal/pdfinput/svg-builder.h
@@ -28,6 +28,7 @@ namespace Inkscape {
#include <2geom/point.h>
#include <2geom/matrix.h>
+#include <glibmm/ustring.h>
#include "CharTypes.h"
class GooString;
@@ -75,10 +76,10 @@ struct SvgGraphicsState {
struct SvgGlyph {
Geom::Point position; // Absolute glyph coords
Geom::Point text_position; // Absolute glyph coords in text space
- double dx, dy; // Advance values
+ double dx; // X advance value
+ double dy; // Y advance value
double rise; // Text rise parameter
- char code[8]; // UTF-8 coded character
- int code_size;
+ Glib::ustring code; // UTF-8 coded character
bool is_space;
bool style_changed; // Set to true if style has to be reset