Commit 66d05776 authored by Patrick Storz's avatar Patrick Storz 🦄

Modified fix for compatibility with poppler 0.64

This is slightly uglier than f0697de0
but avoids duplicating strings (which is unnecessary and leaked memory).

It's also closer to what upstream intended with the changes in 0.64.

(cherry picked from commit 722e1213)
parent ba833b0c
Pipeline #29413860 failed with stage
...@@ -36,6 +36,7 @@ extern "C" { ...@@ -36,6 +36,7 @@ extern "C" {
#include "pdf-parser.h" #include "pdf-parser.h"
#include "util/units.h" #include "util/units.h"
#include "glib/poppler-features.h"
#include "goo/gmem.h" #include "goo/gmem.h"
#include "goo/GooString.h" #include "goo/GooString.h"
#include "GlobalParams.h" #include "GlobalParams.h"
...@@ -2581,7 +2582,11 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/) ...@@ -2581,7 +2582,11 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
} }
} }
#if POPPLER_CHECK_VERSION(0,64,0)
void PdfParser::doShowText(const GooString *s) { void PdfParser::doShowText(const GooString *s) {
#else
void PdfParser::doShowText(GooString *s) {
#endif
GfxFont *font; GfxFont *font;
int wMode; int wMode;
double riseX, riseY; double riseX, riseY;
...@@ -2594,7 +2599,11 @@ void PdfParser::doShowText(const GooString *s) { ...@@ -2594,7 +2599,11 @@ void PdfParser::doShowText(const GooString *s) {
Object charProc; Object charProc;
Dict *resDict; Dict *resDict;
Parser *oldParser; Parser *oldParser;
#if POPPLER_CHECK_VERSION(0,64,0)
const char *p;
#else
char *p; char *p;
#endif
int len, n, uLen; int len, n, uLen;
font = state->getFont(); font = state->getFont();
...@@ -2630,7 +2639,7 @@ void PdfParser::doShowText(const GooString *s) { ...@@ -2630,7 +2639,7 @@ void PdfParser::doShowText(const GooString *s) {
double lineX = state->getLineX(); double lineX = state->getLineX();
double lineY = state->getLineY(); double lineY = state->getLineY();
oldParser = parser; oldParser = parser;
p = g_strdup(s->getCString()); p = s->getCString();
len = s->getLength(); len = s->getLength();
while (len > 0) { while (len > 0) {
n = font->getNextChar(p, len, &code, n = font->getNextChar(p, len, &code,
...@@ -2685,7 +2694,7 @@ void PdfParser::doShowText(const GooString *s) { ...@@ -2685,7 +2694,7 @@ void PdfParser::doShowText(const GooString *s) {
} else { } else {
state->textTransformDelta(0, state->getRise(), &riseX, &riseY); state->textTransformDelta(0, state->getRise(), &riseX, &riseY);
p = g_strdup(s->getCString()); p = s->getCString();
len = s->getLength(); len = s->getLength();
while (len > 0) { while (len > 0) {
n = font->getNextChar(p, len, &code, n = font->getNextChar(p, len, &code,
...@@ -2731,7 +2740,11 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/) ...@@ -2731,7 +2740,11 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
{ {
Object obj1, obj2, obj3, refObj; Object obj1, obj2, obj3, refObj;
char *name = g_strdup(args[0].getName()); #if POPPLER_CHECK_VERSION(0,64,0)
const char *name = args[0].getName();
#else
char *name = args[0].getName();
#endif
#if defined(POPPLER_NEW_OBJECT_API) #if defined(POPPLER_NEW_OBJECT_API)
if ((obj1 = res->lookupXObject(name)).isNull()) { if ((obj1 = res->lookupXObject(name)).isNull()) {
#else #else
......
...@@ -25,6 +25,7 @@ namespace Inkscape { ...@@ -25,6 +25,7 @@ namespace Inkscape {
// TODO clean up and remove using: // TODO clean up and remove using:
using Inkscape::Extension::Internal::SvgBuilder; using Inkscape::Extension::Internal::SvgBuilder;
#include "glib/poppler-features.h"
#include "goo/gtypes.h" #include "goo/gtypes.h"
#include "Object.h" #include "Object.h"
...@@ -287,7 +288,12 @@ private: ...@@ -287,7 +288,12 @@ private:
void opMoveShowText(Object args[], int numArgs); void opMoveShowText(Object args[], int numArgs);
void opMoveSetShowText(Object args[], int numArgs); void opMoveSetShowText(Object args[], int numArgs);
void opShowSpaceText(Object args[], int numArgs); void opShowSpaceText(Object args[], int numArgs);
#if POPPLER_CHECK_VERSION(0,64,0)
void doShowText(const GooString *s); void doShowText(const GooString *s);
#else
void doShowText(GooString *s);
#endif
// XObject operators // XObject operators
void opXObject(Object args[], int numArgs); void opXObject(Object args[], int numArgs);
......
...@@ -1020,9 +1020,9 @@ void SvgBuilder::updateFont(GfxState *state) { ...@@ -1020,9 +1020,9 @@ void SvgBuilder::updateFont(GfxState *state) {
GfxFont *font = state->getFont(); GfxFont *font = state->getFont();
// Store original name // Store original name
if (font->getName()) { if (font->getName()) {
_font_specification = g_strdup(font->getName()->getCString()); _font_specification = font->getName()->getCString();
} else { } else {
_font_specification = (char*) "Arial"; _font_specification = "Arial";
} }
// Prune the font name to get the correct font family name // Prune the font name to get the correct font family name
...@@ -1030,7 +1030,7 @@ void SvgBuilder::updateFont(GfxState *state) { ...@@ -1030,7 +1030,7 @@ void SvgBuilder::updateFont(GfxState *state) {
char *font_family = NULL; char *font_family = NULL;
char *font_style = NULL; char *font_style = NULL;
char *font_style_lowercase = NULL; char *font_style_lowercase = NULL;
char *plus_sign = strstr(_font_specification, "+"); const char *plus_sign = strstr(_font_specification, "+");
if (plus_sign) { if (plus_sign) {
font_family = g_strdup(plus_sign + 1); font_family = g_strdup(plus_sign + 1);
_font_specification = plus_sign + 1; _font_specification = plus_sign + 1;
......
...@@ -80,7 +80,7 @@ struct SvgGlyph { ...@@ -80,7 +80,7 @@ struct SvgGlyph {
bool style_changed; // Set to true if style has to be reset bool style_changed; // Set to true if style has to be reset
SPCSSAttr *style; SPCSSAttr *style;
int render_mode; // Text render mode int render_mode; // Text render mode
char *font_specification; // Pointer to current font specification const char *font_specification; // Pointer to current font specification
}; };
/** /**
...@@ -202,7 +202,7 @@ private: ...@@ -202,7 +202,7 @@ private:
SPCSSAttr *_font_style; // Current font style SPCSSAttr *_font_style; // Current font style
GfxFont *_current_font; GfxFont *_current_font;
char *_font_specification; const char *_font_specification;
double _font_scaling; double _font_scaling;
bool _need_font_update; bool _need_font_update;
Geom::Affine _text_matrix; Geom::Affine _text_matrix;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment