mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
updated to poppler-0.62.0 on Ubuntu 18.04
This commit is contained in:
parent
665ddaaa27
commit
21115c3adf
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,3 +18,6 @@ src/pdf2htmlEX-config.h
|
|||||||
src/util/css_const.h
|
src/util/css_const.h
|
||||||
test export-ignore
|
test export-ignore
|
||||||
Testing/*
|
Testing/*
|
||||||
|
DartConfiguration.tcl
|
||||||
|
test/test.py
|
||||||
|
|
||||||
|
70
3rdparty/poppler/git/CairoFontEngine.cc
vendored
70
3rdparty/poppler/git/CairoFontEngine.cc
vendored
@ -34,6 +34,16 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
|
||||||
|
// Copied on 2019/March/26
|
||||||
|
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
|
||||||
|
// Corrected <config.h> includes to <poppler-config.h>
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
|
||||||
#include <poppler-config.h>
|
#include <poppler-config.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -180,7 +190,7 @@ _ft_new_face_uncached (FT_Library lib,
|
|||||||
FT_Face face;
|
FT_Face face;
|
||||||
cairo_font_face_t *font_face;
|
cairo_font_face_t *font_face;
|
||||||
|
|
||||||
if (font_data == nullptr) {
|
if (font_data == NULL) {
|
||||||
if (FT_New_Face (lib, filename, 0, &face))
|
if (FT_New_Face (lib, filename, 0, &face))
|
||||||
return gFalse;
|
return gFalse;
|
||||||
} else {
|
} else {
|
||||||
@ -286,7 +296,7 @@ _ft_new_face (FT_Library lib,
|
|||||||
|
|
||||||
tmpl.fd = -1;
|
tmpl.fd = -1;
|
||||||
|
|
||||||
if (font_data == nullptr) {
|
if (font_data == NULL) {
|
||||||
/* if we fail to mmap the file, just pass it to FreeType instead */
|
/* if we fail to mmap the file, just pass it to FreeType instead */
|
||||||
tmpl.fd = open (filename, O_RDONLY);
|
tmpl.fd = open (filename, O_RDONLY);
|
||||||
if (tmpl.fd == -1)
|
if (tmpl.fd == -1)
|
||||||
@ -297,7 +307,7 @@ _ft_new_face (FT_Library lib,
|
|||||||
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
|
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl.bytes = (unsigned char *) mmap (nullptr, st.st_size,
|
tmpl.bytes = (unsigned char *) mmap (NULL, st.st_size,
|
||||||
PROT_READ, MAP_PRIVATE,
|
PROT_READ, MAP_PRIVATE,
|
||||||
tmpl.fd, 0);
|
tmpl.fd, 0);
|
||||||
if (tmpl.bytes == MAP_FAILED) {
|
if (tmpl.bytes == MAP_FAILED) {
|
||||||
@ -351,7 +361,7 @@ _ft_new_face (FT_Library lib,
|
|||||||
|
|
||||||
l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data));
|
l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data));
|
||||||
*l = tmpl;
|
*l = tmpl;
|
||||||
l->prev = nullptr;
|
l->prev = NULL;
|
||||||
l->next = _ft_open_faces;
|
l->next = _ft_open_faces;
|
||||||
if (_ft_open_faces)
|
if (_ft_open_faces)
|
||||||
_ft_open_faces->prev = l;
|
_ft_open_faces->prev = l;
|
||||||
@ -411,20 +421,20 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
|
|
||||||
int *codeToGID;
|
int *codeToGID;
|
||||||
Guint codeToGIDLen;
|
Guint codeToGIDLen;
|
||||||
|
|
||||||
codeToGID = nullptr;
|
codeToGID = NULL;
|
||||||
codeToGIDLen = 0;
|
codeToGIDLen = 0;
|
||||||
font_data = nullptr;
|
font_data = NULL;
|
||||||
font_data_len = 0;
|
font_data_len = 0;
|
||||||
fileName = nullptr;
|
fileName = NULL;
|
||||||
fileNameC = nullptr;
|
fileNameC = NULL;
|
||||||
|
|
||||||
GBool substitute = gFalse;
|
GBool substitute = gFalse;
|
||||||
|
|
||||||
ref = *gfxFont->getID();
|
ref = *gfxFont->getID();
|
||||||
fontType = gfxFont->getType();
|
fontType = gfxFont->getType();
|
||||||
|
|
||||||
if (!(fontLoc = gfxFont->locateFont(xref, nullptr))) {
|
if (!(fontLoc = gfxFont->locateFont(xref, NULL))) {
|
||||||
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
|
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
|
||||||
gfxFont->getName() ? gfxFont->getName()->getCString()
|
gfxFont->getName() ? gfxFont->getName()->getCString()
|
||||||
: "(unnamed)");
|
: "(unnamed)");
|
||||||
@ -434,7 +444,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
// embedded font
|
// embedded font
|
||||||
if (fontLoc->locType == gfxFontLocEmbedded) {
|
if (fontLoc->locType == gfxFontLocEmbedded) {
|
||||||
font_data = gfxFont->readEmbFontFile(xref, &font_data_len);
|
font_data = gfxFont->readEmbFontFile(xref, &font_data_len);
|
||||||
if (nullptr == font_data)
|
if (NULL == font_data)
|
||||||
goto err2;
|
goto err2;
|
||||||
|
|
||||||
// external font
|
// external font
|
||||||
@ -444,7 +454,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
substitute = gTrue;
|
substitute = gTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName != nullptr) {
|
if (fileName != NULL) {
|
||||||
fileNameC = fileName->getCString();
|
fileNameC = fileName->getCString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,9 +466,9 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
error(errSyntaxError, -1, "could not create type1 face");
|
error(errSyntaxError, -1, "could not create type1 face");
|
||||||
goto err2;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
enc = ((Gfx8BitFont *)gfxFont)->getEncoding();
|
enc = ((Gfx8BitFont *)gfxFont)->getEncoding();
|
||||||
|
|
||||||
codeToGID = (int *)gmallocn(256, sizeof(int));
|
codeToGID = (int *)gmallocn(256, sizeof(int));
|
||||||
codeToGIDLen = 256;
|
codeToGIDLen = 256;
|
||||||
for (i = 0; i < 256; ++i) {
|
for (i = 0; i < 256; ++i) {
|
||||||
@ -481,7 +491,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
break;
|
break;
|
||||||
case fontCIDType2:
|
case fontCIDType2:
|
||||||
case fontCIDType2OT:
|
case fontCIDType2OT:
|
||||||
codeToGID = nullptr;
|
codeToGID = NULL;
|
||||||
n = 0;
|
n = 0;
|
||||||
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
|
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
|
||||||
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
|
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
|
||||||
@ -491,7 +501,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
n * sizeof(int));
|
n * sizeof(int));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (font_data != nullptr) {
|
if (font_data != NULL) {
|
||||||
ff = FoFiTrueType::make(font_data, font_data_len);
|
ff = FoFiTrueType::make(font_data, font_data_len);
|
||||||
} else {
|
} else {
|
||||||
ff = FoFiTrueType::load(fileNameC);
|
ff = FoFiTrueType::load(fileNameC);
|
||||||
@ -505,7 +515,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
/* Fall through */
|
/* Fall through */
|
||||||
case fontTrueType:
|
case fontTrueType:
|
||||||
case fontTrueTypeOT:
|
case fontTrueTypeOT:
|
||||||
if (font_data != nullptr) {
|
if (font_data != NULL) {
|
||||||
ff = FoFiTrueType::make(font_data, font_data_len);
|
ff = FoFiTrueType::make(font_data, font_data_len);
|
||||||
} else {
|
} else {
|
||||||
ff = FoFiTrueType::load(fileNameC);
|
ff = FoFiTrueType::load(fileNameC);
|
||||||
@ -525,16 +535,16 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
goto err2;
|
goto err2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fontCIDType0:
|
case fontCIDType0:
|
||||||
case fontCIDType0C:
|
case fontCIDType0C:
|
||||||
|
|
||||||
codeToGID = nullptr;
|
codeToGID = NULL;
|
||||||
codeToGIDLen = 0;
|
codeToGIDLen = 0;
|
||||||
|
|
||||||
if (!useCIDs)
|
if (!useCIDs)
|
||||||
{
|
{
|
||||||
if (font_data != nullptr) {
|
if (font_data != NULL) {
|
||||||
ff1c = FoFiType1C::make(font_data, font_data_len);
|
ff1c = FoFiType1C::make(font_data, font_data_len);
|
||||||
} else {
|
} else {
|
||||||
ff1c = FoFiType1C::load(fileNameC);
|
ff1c = FoFiType1C::load(fileNameC);
|
||||||
@ -552,7 +562,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case fontCIDType0COT:
|
case fontCIDType0COT:
|
||||||
codeToGID = nullptr;
|
codeToGID = NULL;
|
||||||
n = 0;
|
n = 0;
|
||||||
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
|
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
|
||||||
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
|
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
|
||||||
@ -566,7 +576,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
|
|
||||||
if (!codeToGID) {
|
if (!codeToGID) {
|
||||||
if (!useCIDs) {
|
if (!useCIDs) {
|
||||||
if (font_data != nullptr) {
|
if (font_data != NULL) {
|
||||||
ff = FoFiTrueType::make(font_data, font_data_len);
|
ff = FoFiTrueType::make(font_data, font_data_len);
|
||||||
} else {
|
} else {
|
||||||
ff = FoFiTrueType::load(fileNameC);
|
ff = FoFiTrueType::load(fileNameC);
|
||||||
@ -603,7 +613,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
|
|||||||
gfree (codeToGID);
|
gfree (codeToGID);
|
||||||
gfree (font_data);
|
gfree (font_data);
|
||||||
fprintf (stderr, "some font thing failed\n");
|
fprintf (stderr, "some font thing failed\n");
|
||||||
return nullptr;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -703,7 +713,7 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
|
|||||||
box.y1 = mat[1];
|
box.y1 = mat[1];
|
||||||
box.x2 = mat[2];
|
box.x2 = mat[2];
|
||||||
box.y2 = mat[3];
|
box.y2 = mat[3];
|
||||||
gfx = new Gfx(info->doc, output_dev, resDict, &box, nullptr);
|
gfx = new Gfx(info->doc, output_dev, resDict, &box, NULL);
|
||||||
output_dev->startDoc(info->doc, info->fontEngine);
|
output_dev->startDoc(info->doc, info->fontEngine);
|
||||||
output_dev->startPage (1, gfx->getState(), gfx->getXRef());
|
output_dev->startPage (1, gfx->getState(), gfx->getXRef());
|
||||||
output_dev->setInType3Char(gTrue);
|
output_dev->setInType3Char(gTrue);
|
||||||
@ -808,9 +818,9 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) {
|
|||||||
|
|
||||||
lib = libA;
|
lib = libA;
|
||||||
for (i = 0; i < cairoFontCacheSize; ++i) {
|
for (i = 0; i < cairoFontCacheSize; ++i) {
|
||||||
fontCache[i] = nullptr;
|
fontCache[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Int major, minor, patch;
|
FT_Int major, minor, patch;
|
||||||
// as of FT 2.1.8, CID fonts are indexed by CID instead of GID
|
// as of FT 2.1.8, CID fonts are indexed by CID instead of GID
|
||||||
FT_Library_Version(lib, &major, &minor, &patch);
|
FT_Library_Version(lib, &major, &minor, &patch);
|
||||||
@ -823,7 +833,7 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) {
|
|||||||
|
|
||||||
CairoFontEngine::~CairoFontEngine() {
|
CairoFontEngine::~CairoFontEngine() {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < cairoFontCacheSize; ++i) {
|
for (i = 0; i < cairoFontCacheSize; ++i) {
|
||||||
if (fontCache[i])
|
if (fontCache[i])
|
||||||
delete fontCache[i];
|
delete fontCache[i];
|
||||||
@ -839,7 +849,7 @@ CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xr
|
|||||||
Ref ref;
|
Ref ref;
|
||||||
CairoFont *font;
|
CairoFont *font;
|
||||||
GfxFontType fontType;
|
GfxFontType fontType;
|
||||||
|
|
||||||
fontEngineLocker();
|
fontEngineLocker();
|
||||||
ref = *gfxFont->getID();
|
ref = *gfxFont->getID();
|
||||||
|
|
||||||
@ -853,7 +863,7 @@ CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xr
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fontType = gfxFont->getType();
|
fontType = gfxFont->getType();
|
||||||
if (fontType == fontType3)
|
if (fontType == fontType3)
|
||||||
font = CairoType3Font::create (gfxFont, doc, this, printing, xref);
|
font = CairoType3Font::create (gfxFont, doc, this, printing, xref);
|
||||||
|
15
3rdparty/poppler/git/CairoFontEngine.h
vendored
15
3rdparty/poppler/git/CairoFontEngine.h
vendored
@ -15,7 +15,7 @@
|
|||||||
// under GPL version 2 or later
|
// under GPL version 2 or later
|
||||||
//
|
//
|
||||||
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
|
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
|
||||||
// Copyright (C) 2005, 2018 Albert Astals Cid <aacid@kde.org>
|
// Copyright (C) 2005 Albert Astals Cid <aacid@kde.org>
|
||||||
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
|
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
|
||||||
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
|
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
|
||||||
// Copyright (C) 2008, 2017 Adrian Johnson <ajohnson@redneon.com>
|
// Copyright (C) 2008, 2017 Adrian Johnson <ajohnson@redneon.com>
|
||||||
@ -26,6 +26,15 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
|
||||||
|
// Copied on 2019/March/26
|
||||||
|
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
|
||||||
|
// Corrected <config.h> includes to <poppler-config.h>
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#ifndef CAIROFONTENGINE_H
|
#ifndef CAIROFONTENGINE_H
|
||||||
#define CAIROFONTENGINE_H
|
#define CAIROFONTENGINE_H
|
||||||
|
|
||||||
@ -51,8 +60,6 @@ public:
|
|||||||
GBool substitute,
|
GBool substitute,
|
||||||
GBool printing);
|
GBool printing);
|
||||||
virtual ~CairoFont();
|
virtual ~CairoFont();
|
||||||
CairoFont(const CairoFont &) = delete;
|
|
||||||
CairoFont& operator=(const CairoFont &other) = delete;
|
|
||||||
|
|
||||||
virtual GBool matches(Ref &other, GBool printing);
|
virtual GBool matches(Ref &other, GBool printing);
|
||||||
cairo_font_face_t *getFontFace(void);
|
cairo_font_face_t *getFontFace(void);
|
||||||
@ -116,8 +123,6 @@ public:
|
|||||||
// Create a font engine.
|
// Create a font engine.
|
||||||
CairoFontEngine(FT_Library libA);
|
CairoFontEngine(FT_Library libA);
|
||||||
~CairoFontEngine();
|
~CairoFontEngine();
|
||||||
CairoFontEngine(const CairoFontEngine &) = delete;
|
|
||||||
CairoFontEngine& operator=(const CairoFontEngine &other) = delete;
|
|
||||||
|
|
||||||
CairoFont *getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref);
|
CairoFont *getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref);
|
||||||
|
|
||||||
|
240
3rdparty/poppler/git/CairoOutputDev.cc
vendored
240
3rdparty/poppler/git/CairoOutputDev.cc
vendored
@ -35,6 +35,15 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
|
||||||
|
// Copied on 2019/March/26
|
||||||
|
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
|
||||||
|
// Corrected <config.h> includes to <poppler-config.h>
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include <poppler-config.h>
|
#include <poppler-config.h>
|
||||||
|
|
||||||
#ifdef USE_GCC_PRAGMAS
|
#ifdef USE_GCC_PRAGMAS
|
||||||
@ -69,11 +78,6 @@
|
|||||||
|
|
||||||
// #define LOG_CAIRO
|
// #define LOG_CAIRO
|
||||||
|
|
||||||
// To limit memory usage and improve performance when printing, limit
|
|
||||||
// cairo images to this size. 8192 is sufficient for an A2 sized
|
|
||||||
// 300ppi image.
|
|
||||||
#define MAX_PRINT_IMAGE_SIZE 8192
|
|
||||||
|
|
||||||
#ifdef LOG_CAIRO
|
#ifdef LOG_CAIRO
|
||||||
#define LOG(x) (x)
|
#define LOG(x) (x)
|
||||||
#else
|
#else
|
||||||
@ -96,7 +100,7 @@ static inline void printMatrix(cairo_matrix_t *matrix){
|
|||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
CairoImage::CairoImage (double x1, double y1, double x2, double y2) {
|
CairoImage::CairoImage (double x1, double y1, double x2, double y2) {
|
||||||
this->image = nullptr;
|
this->image = NULL;
|
||||||
this->x1 = x1;
|
this->x1 = x1;
|
||||||
this->y1 = y1;
|
this->y1 = y1;
|
||||||
this->x2 = x2;
|
this->x2 = x2;
|
||||||
@ -128,26 +132,26 @@ FT_Library CairoOutputDev::ft_lib;
|
|||||||
GBool CairoOutputDev::ft_lib_initialized = gFalse;
|
GBool CairoOutputDev::ft_lib_initialized = gFalse;
|
||||||
|
|
||||||
CairoOutputDev::CairoOutputDev() {
|
CairoOutputDev::CairoOutputDev() {
|
||||||
doc = nullptr;
|
doc = NULL;
|
||||||
|
|
||||||
if (!ft_lib_initialized) {
|
if (!ft_lib_initialized) {
|
||||||
FT_Init_FreeType(&ft_lib);
|
FT_Init_FreeType(&ft_lib);
|
||||||
ft_lib_initialized = gTrue;
|
ft_lib_initialized = gTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fontEngine = nullptr;
|
fontEngine = NULL;
|
||||||
fontEngine_owner = gFalse;
|
fontEngine_owner = gFalse;
|
||||||
glyphs = nullptr;
|
glyphs = NULL;
|
||||||
fill_pattern = nullptr;
|
fill_pattern = NULL;
|
||||||
fill_color.r = fill_color.g = fill_color.b = 0;
|
fill_color.r = fill_color.g = fill_color.b = 0;
|
||||||
stroke_pattern = nullptr;
|
stroke_pattern = NULL;
|
||||||
stroke_color.r = stroke_color.g = stroke_color.b = 0;
|
stroke_color.r = stroke_color.g = stroke_color.b = 0;
|
||||||
stroke_opacity = 1.0;
|
stroke_opacity = 1.0;
|
||||||
fill_opacity = 1.0;
|
fill_opacity = 1.0;
|
||||||
textClipPath = nullptr;
|
textClipPath = NULL;
|
||||||
strokePathClip = nullptr;
|
strokePathClip = NULL;
|
||||||
cairo = nullptr;
|
cairo = NULL;
|
||||||
currentFont = nullptr;
|
currentFont = NULL;
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
||||||
prescaleImages = gFalse;
|
prescaleImages = gFalse;
|
||||||
#else
|
#else
|
||||||
@ -161,23 +165,23 @@ CairoOutputDev::CairoOutputDev() {
|
|||||||
text_matrix_valid = gTrue;
|
text_matrix_valid = gTrue;
|
||||||
antialias = CAIRO_ANTIALIAS_DEFAULT;
|
antialias = CAIRO_ANTIALIAS_DEFAULT;
|
||||||
|
|
||||||
groupColorSpaceStack = nullptr;
|
groupColorSpaceStack = NULL;
|
||||||
maskStack = nullptr;
|
maskStack = NULL;
|
||||||
group = nullptr;
|
group = NULL;
|
||||||
mask = nullptr;
|
mask = NULL;
|
||||||
shape = nullptr;
|
shape = NULL;
|
||||||
cairo_shape = nullptr;
|
cairo_shape = NULL;
|
||||||
knockoutCount = 0;
|
knockoutCount = 0;
|
||||||
|
|
||||||
text = nullptr;
|
text = NULL;
|
||||||
actualText = nullptr;
|
actualText = NULL;
|
||||||
|
|
||||||
// the SA parameter supposedly defaults to false, but Acrobat
|
// the SA parameter supposedly defaults to false, but Acrobat
|
||||||
// apparently hardwires it to true
|
// apparently hardwires it to true
|
||||||
stroke_adjust = gTrue;
|
stroke_adjust = gTrue;
|
||||||
align_stroke_coords = gFalse;
|
align_stroke_coords = gFalse;
|
||||||
adjusted_stroke_width = gFalse;
|
adjusted_stroke_width = gFalse;
|
||||||
xref = nullptr;
|
xref = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CairoOutputDev::~CairoOutputDev() {
|
CairoOutputDev::~CairoOutputDev() {
|
||||||
@ -195,15 +199,15 @@ CairoOutputDev::~CairoOutputDev() {
|
|||||||
cairo_pattern_destroy (mask);
|
cairo_pattern_destroy (mask);
|
||||||
if (shape)
|
if (shape)
|
||||||
cairo_pattern_destroy (shape);
|
cairo_pattern_destroy (shape);
|
||||||
if (text)
|
if (text)
|
||||||
text->decRefCnt();
|
text->decRefCnt();
|
||||||
if (actualText)
|
if (actualText)
|
||||||
delete actualText;
|
delete actualText;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setCairo(cairo_t *cairo)
|
void CairoOutputDev::setCairo(cairo_t *cairo)
|
||||||
{
|
{
|
||||||
if (this->cairo != nullptr) {
|
if (this->cairo != NULL) {
|
||||||
cairo_status_t status = cairo_status (this->cairo);
|
cairo_status_t status = cairo_status (this->cairo);
|
||||||
if (status) {
|
if (status) {
|
||||||
error(errInternal, -1, "cairo context error: {0:s}\n", cairo_status_to_string(status));
|
error(errInternal, -1, "cairo context error: {0:s}\n", cairo_status_to_string(status));
|
||||||
@ -211,21 +215,21 @@ void CairoOutputDev::setCairo(cairo_t *cairo)
|
|||||||
cairo_destroy (this->cairo);
|
cairo_destroy (this->cairo);
|
||||||
assert(!cairo_shape);
|
assert(!cairo_shape);
|
||||||
}
|
}
|
||||||
if (cairo != nullptr) {
|
if (cairo != NULL) {
|
||||||
this->cairo = cairo_reference (cairo);
|
this->cairo = cairo_reference (cairo);
|
||||||
/* save the initial matrix so that we can use it for type3 fonts. */
|
/* save the initial matrix so that we can use it for type3 fonts. */
|
||||||
//XXX: is this sufficient? could we miss changes to the matrix somehow?
|
//XXX: is this sufficient? could we miss changes to the matrix somehow?
|
||||||
cairo_get_matrix(cairo, &orig_matrix);
|
cairo_get_matrix(cairo, &orig_matrix);
|
||||||
setContextAntialias(cairo, antialias);
|
setContextAntialias(cairo, antialias);
|
||||||
} else {
|
} else {
|
||||||
this->cairo = nullptr;
|
this->cairo = NULL;
|
||||||
this->cairo_shape = nullptr;
|
this->cairo_shape = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setTextPage(TextPage *text)
|
void CairoOutputDev::setTextPage(TextPage *text)
|
||||||
{
|
{
|
||||||
if (this->text)
|
if (this->text)
|
||||||
this->text->decRefCnt();
|
this->text->decRefCnt();
|
||||||
if (actualText)
|
if (actualText)
|
||||||
delete actualText;
|
delete actualText;
|
||||||
@ -234,8 +238,8 @@ void CairoOutputDev::setTextPage(TextPage *text)
|
|||||||
this->text->incRefCnt();
|
this->text->incRefCnt();
|
||||||
actualText = new ActualText(text);
|
actualText = new ActualText(text);
|
||||||
} else {
|
} else {
|
||||||
this->text = nullptr;
|
this->text = NULL;
|
||||||
actualText = nullptr;
|
actualText = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +290,7 @@ void CairoOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
|
|||||||
|
|
||||||
if (text)
|
if (text)
|
||||||
text->startPage(state);
|
text->startPage(state);
|
||||||
if (xrefA != nullptr) {
|
if (xrefA != NULL) {
|
||||||
xref = xrefA;
|
xref = xrefA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,7 +349,7 @@ void CairoOutputDev::restoreState(GfxState *state) {
|
|||||||
if (strokePathClip->dashes)
|
if (strokePathClip->dashes)
|
||||||
gfree (strokePathClip->dashes);
|
gfree (strokePathClip->dashes);
|
||||||
gfree (strokePathClip);
|
gfree (strokePathClip);
|
||||||
strokePathClip = nullptr;
|
strokePathClip = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,7 +673,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
|
|||||||
//FIXME: use cairo font engine?
|
//FIXME: use cairo font engine?
|
||||||
if (text)
|
if (text)
|
||||||
text->updateFont(state);
|
text->updateFont(state);
|
||||||
|
|
||||||
currentFont = fontEngine->getFont (state->getFont(), doc, printing, xref);
|
currentFont = fontEngine->getFont (state->getFont(), doc, printing, xref);
|
||||||
|
|
||||||
if (!currentFont)
|
if (!currentFont)
|
||||||
@ -680,7 +684,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
|
|||||||
|
|
||||||
use_show_text_glyphs = state->getFont()->hasToUnicodeCMap() &&
|
use_show_text_glyphs = state->getFont()->hasToUnicodeCMap() &&
|
||||||
cairo_surface_has_show_text_glyphs (cairo_get_target (cairo));
|
cairo_surface_has_show_text_glyphs (cairo_get_target (cairo));
|
||||||
|
|
||||||
double fontSize = state->getFontSize();
|
double fontSize = state->getFontSize();
|
||||||
double *m = state->getTextMat();
|
double *m = state->getTextMat();
|
||||||
/* NOTE: adjusting by a constant is hack. The correct solution
|
/* NOTE: adjusting by a constant is hack. The correct solution
|
||||||
@ -955,11 +959,11 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
|
|||||||
cairo_translate (cairo, -box.x1, -box.y1);
|
cairo_translate (cairo, -box.x1, -box.y1);
|
||||||
|
|
||||||
strokePathTmp = strokePathClip;
|
strokePathTmp = strokePathClip;
|
||||||
strokePathClip = nullptr;
|
strokePathClip = NULL;
|
||||||
adjusted_stroke_width_tmp = adjusted_stroke_width;
|
adjusted_stroke_width_tmp = adjusted_stroke_width;
|
||||||
maskTmp = mask;
|
maskTmp = mask;
|
||||||
mask = nullptr;
|
mask = NULL;
|
||||||
gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA->getXRef());
|
gfx = new Gfx(doc, this, resDict, &box, NULL, NULL, NULL, gfxA->getXRef());
|
||||||
if (paintType == 2)
|
if (paintType == 2)
|
||||||
inUncoloredPattern = gTrue;
|
inUncoloredPattern = gTrue;
|
||||||
gfx->display(str);
|
gfx->display(str);
|
||||||
@ -1356,7 +1360,7 @@ void CairoOutputDev::clipToStrokePath(GfxState *state) {
|
|||||||
strokePathClip->dashes = (double*) gmallocn (sizeof(double), strokePathClip->dash_count);
|
strokePathClip->dashes = (double*) gmallocn (sizeof(double), strokePathClip->dash_count);
|
||||||
cairo_get_dash (cairo, strokePathClip->dashes, &strokePathClip->dash_offset);
|
cairo_get_dash (cairo, strokePathClip->dashes, &strokePathClip->dash_offset);
|
||||||
} else {
|
} else {
|
||||||
strokePathClip->dashes = nullptr;
|
strokePathClip->dashes = NULL;
|
||||||
}
|
}
|
||||||
strokePathClip->cap = cairo_get_line_cap (cairo);
|
strokePathClip->cap = cairo_get_line_cap (cairo);
|
||||||
strokePathClip->join = cairo_get_line_join (cairo);
|
strokePathClip->join = cairo_get_line_join (cairo);
|
||||||
@ -1493,11 +1497,11 @@ void CairoOutputDev::endString(GfxState *state)
|
|||||||
}
|
}
|
||||||
cairo_path_destroy (textClipPath);
|
cairo_path_destroy (textClipPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// append the glyph path
|
// append the glyph path
|
||||||
cairo_glyph_path (cairo, glyphs, glyphCount);
|
cairo_glyph_path (cairo, glyphs, glyphCount);
|
||||||
|
|
||||||
// move the path back into textClipPath
|
// move the path back into textClipPath
|
||||||
// and clear the current path
|
// and clear the current path
|
||||||
textClipPath = cairo_copy_path (cairo);
|
textClipPath = cairo_copy_path (cairo);
|
||||||
cairo_new_path (cairo);
|
cairo_new_path (cairo);
|
||||||
@ -1508,12 +1512,12 @@ void CairoOutputDev::endString(GfxState *state)
|
|||||||
|
|
||||||
finish:
|
finish:
|
||||||
gfree (glyphs);
|
gfree (glyphs);
|
||||||
glyphs = nullptr;
|
glyphs = NULL;
|
||||||
if (use_show_text_glyphs) {
|
if (use_show_text_glyphs) {
|
||||||
gfree (clusters);
|
gfree (clusters);
|
||||||
clusters = nullptr;
|
clusters = NULL;
|
||||||
gfree (utf8);
|
gfree (utf8);
|
||||||
utf8 = nullptr;
|
utf8 = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1584,7 +1588,7 @@ void CairoOutputDev::endTextObject(GfxState *state) {
|
|||||||
cairo_clip (cairo_shape);
|
cairo_clip (cairo_shape);
|
||||||
}
|
}
|
||||||
cairo_path_destroy (textClipPath);
|
cairo_path_destroy (textClipPath);
|
||||||
textClipPath = nullptr;
|
textClipPath = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1616,7 +1620,7 @@ static
|
|||||||
cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, cairo_content_t content)
|
cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, cairo_content_t content)
|
||||||
{
|
{
|
||||||
cairo_pattern_t *pattern;
|
cairo_pattern_t *pattern;
|
||||||
cairo_surface_t *surface = nullptr;
|
cairo_surface_t *surface = NULL;
|
||||||
|
|
||||||
cairo_push_group_with_content (cairo, content);
|
cairo_push_group_with_content (cairo, content);
|
||||||
pattern = cairo_pop_group (cairo);
|
pattern = cairo_pop_group (cairo);
|
||||||
@ -1728,7 +1732,7 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbo
|
|||||||
cairo_paint_with_alpha (cairo, fill_opacity);
|
cairo_paint_with_alpha (cairo, fill_opacity);
|
||||||
}
|
}
|
||||||
cairo_pattern_destroy(mask);
|
cairo_pattern_destroy(mask);
|
||||||
mask = nullptr;
|
mask = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shape) {
|
if (shape) {
|
||||||
@ -1738,7 +1742,7 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbo
|
|||||||
cairo_set_source_rgb (cairo_shape, 0, 0, 0);
|
cairo_set_source_rgb (cairo_shape, 0, 0, 0);
|
||||||
}
|
}
|
||||||
cairo_pattern_destroy (shape);
|
cairo_pattern_destroy (shape);
|
||||||
shape = nullptr;
|
shape = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
popTransparencyGroup();
|
popTransparencyGroup();
|
||||||
@ -1886,7 +1890,7 @@ void CairoOutputDev::popTransparencyGroup() {
|
|||||||
/* we don't need to track the shape anymore because
|
/* we don't need to track the shape anymore because
|
||||||
* we are not above any knockout groups */
|
* we are not above any knockout groups */
|
||||||
cairo_destroy(cairo_shape);
|
cairo_destroy(cairo_shape);
|
||||||
cairo_shape = nullptr;
|
cairo_shape = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
groupColorSpaceStack = css->next;
|
groupColorSpaceStack = css->next;
|
||||||
@ -1897,7 +1901,7 @@ void CairoOutputDev::popTransparencyGroup() {
|
|||||||
void CairoOutputDev::clearSoftMask(GfxState * /*state*/) {
|
void CairoOutputDev::clearSoftMask(GfxState * /*state*/) {
|
||||||
if (mask)
|
if (mask)
|
||||||
cairo_pattern_destroy(mask);
|
cairo_pattern_destroy(mask);
|
||||||
mask = nullptr;
|
mask = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Taken from cairo/doc/tutorial/src/singular.c */
|
/* Taken from cairo/doc/tutorial/src/singular.c */
|
||||||
@ -1970,7 +1974,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
|
|||||||
GBool interpolate)
|
GBool interpolate)
|
||||||
{
|
{
|
||||||
if (interpolate)
|
if (interpolate)
|
||||||
return CAIRO_FILTER_BEST;
|
return CAIRO_FILTER_GOOD;
|
||||||
|
|
||||||
int orig_width = cairo_image_surface_get_width (image);
|
int orig_width = cairo_image_surface_get_width (image);
|
||||||
int orig_height = cairo_image_surface_get_height (image);
|
int orig_height = cairo_image_surface_get_height (image);
|
||||||
@ -1990,7 +1994,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
|
|||||||
if (scaled_width / orig_width >= 4 || scaled_height / orig_height >= 4)
|
if (scaled_width / orig_width >= 4 || scaled_height / orig_height >= 4)
|
||||||
return CAIRO_FILTER_NEAREST;
|
return CAIRO_FILTER_NEAREST;
|
||||||
|
|
||||||
return CAIRO_FILTER_BEST;
|
return CAIRO_FILTER_GOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
||||||
@ -2033,7 +2037,7 @@ void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
|
|||||||
|
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
cairo_get_matrix (cairo, &matrix);
|
cairo_get_matrix (cairo, &matrix);
|
||||||
//XXX: it is possible that we should only do sub pixel positioning if
|
//XXX: it is possible that we should only do sub pixel positioning if
|
||||||
// we are rendering fonts */
|
// we are rendering fonts */
|
||||||
if (!printing && prescaleImages
|
if (!printing && prescaleImages
|
||||||
/* not rotated */
|
/* not rotated */
|
||||||
@ -2086,7 +2090,7 @@ void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stre
|
|||||||
|
|
||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
cairo_get_matrix (cairo, &matrix);
|
cairo_get_matrix (cairo, &matrix);
|
||||||
//XXX: it is possible that we should only do sub pixel positioning if
|
//XXX: it is possible that we should only do sub pixel positioning if
|
||||||
// we are rendering fonts */
|
// we are rendering fonts */
|
||||||
if (!printing && prescaleImages && matrix.xy == 0.0 && matrix.yx == 0.0) {
|
if (!printing && prescaleImages && matrix.xy == 0.0 && matrix.yx == 0.0) {
|
||||||
drawImageMaskPrescaled(state, ref, str, width, height, invert, gFalse, inlineImg);
|
drawImageMaskPrescaled(state, ref, str, width, height, invert, gFalse, inlineImg);
|
||||||
@ -2458,7 +2462,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
|
|||||||
* cairo doesn't yet do minifaction filtering causing scaled down
|
* cairo doesn't yet do minifaction filtering causing scaled down
|
||||||
* images with CAIRO_FILTER_NEAREST to look really bad */
|
* images with CAIRO_FILTER_NEAREST to look really bad */
|
||||||
cairo_pattern_set_filter (pattern,
|
cairo_pattern_set_filter (pattern,
|
||||||
interpolate ? CAIRO_FILTER_BEST : CAIRO_FILTER_FAST);
|
interpolate ? CAIRO_FILTER_GOOD : CAIRO_FILTER_FAST);
|
||||||
|
|
||||||
if (state->getFillColorSpace()->getMode() == csPattern) {
|
if (state->getFillColorSpace()->getMode() == csPattern) {
|
||||||
cairo_matrix_init_translate (&matrix, 0, scaledHeight);
|
cairo_matrix_init_translate (&matrix, 0, scaledHeight);
|
||||||
@ -2588,7 +2592,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
|
|||||||
* so check its underlying color space as well */
|
* so check its underlying color space as well */
|
||||||
int is_identity_transform;
|
int is_identity_transform;
|
||||||
is_identity_transform = colorMap->getColorSpace()->getMode() == csDeviceRGB ||
|
is_identity_transform = colorMap->getColorSpace()->getMode() == csDeviceRGB ||
|
||||||
(colorMap->getColorSpace()->getMode() == csICCBased &&
|
(colorMap->getColorSpace()->getMode() == csICCBased &&
|
||||||
((GfxICCBasedColorSpace*)colorMap->getColorSpace())->getAlt()->getMode() == csDeviceRGB);
|
((GfxICCBasedColorSpace*)colorMap->getColorSpace())->getAlt()->getMode() == csDeviceRGB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2766,7 +2770,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
|
|||||||
|
|
||||||
cairo_surface_mark_dirty (image);
|
cairo_surface_mark_dirty (image);
|
||||||
|
|
||||||
setMimeData(state, str, ref, colorMap, image, height);
|
setMimeData(state, str, ref, colorMap, image);
|
||||||
|
|
||||||
pattern = cairo_pattern_create_for_surface (image);
|
pattern = cairo_pattern_create_for_surface (image);
|
||||||
cairo_surface_destroy (image);
|
cairo_surface_destroy (image);
|
||||||
@ -2920,7 +2924,7 @@ GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
|
|||||||
if (!globalsStr->isStream())
|
if (!globalsStr->isStream())
|
||||||
return gTrue;
|
return gTrue;
|
||||||
|
|
||||||
if (setMimeIdFromRef(image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, nullptr,
|
if (setMimeIdFromRef(image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, NULL,
|
||||||
jb2Str->getGlobalsStreamRef()))
|
jb2Str->getGlobalsStreamRef()))
|
||||||
return gFalse;
|
return gFalse;
|
||||||
|
|
||||||
@ -2940,38 +2944,8 @@ GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
|
||||||
GBool CairoOutputDev::setMimeDataForCCITTParams(Stream *str,
|
|
||||||
cairo_surface_t *image, int height)
|
|
||||||
{
|
|
||||||
CCITTFaxStream *ccittStr = static_cast<CCITTFaxStream *>(str);
|
|
||||||
|
|
||||||
GooString params;
|
|
||||||
params.appendf("Columns={0:d}", ccittStr->getColumns());
|
|
||||||
params.appendf(" Rows={0:d}", height);
|
|
||||||
params.appendf(" K={0:d}", ccittStr->getEncoding());
|
|
||||||
params.appendf(" EndOfLine={0:d}", ccittStr->getEndOfLine() ? 1 : 0);
|
|
||||||
params.appendf(" EncodedByteAlign={0:d}", ccittStr->getEncodedByteAlign() ? 1 : 0);
|
|
||||||
params.appendf(" EndOfBlock={0:d}", ccittStr->getEndOfBlock() ? 1 : 0);
|
|
||||||
params.appendf(" BlackIs1={0:d}", ccittStr->getBlackIs1() ? 1 : 0);
|
|
||||||
params.appendf(" DamagedRowsBeforeError={0:d}", ccittStr->getDamagedRowsBeforeError());
|
|
||||||
|
|
||||||
char *p = strdup(params.getCString());
|
|
||||||
if (cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_CCITT_FAX_PARAMS,
|
|
||||||
(const unsigned char*)p,
|
|
||||||
params.getLength(),
|
|
||||||
gfree, (void*)p))
|
|
||||||
{
|
|
||||||
gfree (p);
|
|
||||||
return gFalse;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gTrue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
|
void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
|
||||||
GfxImageColorMap *colorMap, cairo_surface_t *image, int height)
|
GfxImageColorMap *colorMap, cairo_surface_t *image)
|
||||||
{
|
{
|
||||||
char *strBuffer;
|
char *strBuffer;
|
||||||
int len;
|
int len;
|
||||||
@ -2994,18 +2968,13 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
|
|||||||
case strJBIG2:
|
case strJBIG2:
|
||||||
mime_type = CAIRO_MIME_TYPE_JBIG2;
|
mime_type = CAIRO_MIME_TYPE_JBIG2;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
|
||||||
case strCCITTFax:
|
|
||||||
mime_type = CAIRO_MIME_TYPE_CCITT_FAX;
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = str->getDict()->lookup("ColorSpace");
|
obj = str->getDict()->lookup("ColorSpace");
|
||||||
colorSpace = GfxColorSpace::parse(nullptr, &obj, this, state);
|
colorSpace = GfxColorSpace::parse(NULL, &obj, this, state);
|
||||||
|
|
||||||
// colorspace in stream dict may be different from colorspace in jpx
|
// colorspace in stream dict may be different from colorspace in jpx
|
||||||
// data
|
// data
|
||||||
@ -3042,11 +3011,6 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
|
||||||
if (strKind == strCCITTFax && !setMimeDataForCCITTParams(str, image, height))
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (getStreamData (str->getNextStream(), &strBuffer, &len)) {
|
if (getStreamData (str->getNextStream(), &strBuffer, &len)) {
|
||||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||||
|
|
||||||
@ -3084,10 +3048,10 @@ public:
|
|||||||
GBool printing,
|
GBool printing,
|
||||||
GfxImageColorMap *colorMapA,
|
GfxImageColorMap *colorMapA,
|
||||||
int *maskColorsA) {
|
int *maskColorsA) {
|
||||||
cairo_surface_t *image = nullptr;
|
cairo_surface_t *image = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lookup = nullptr;
|
lookup = NULL;
|
||||||
colorMap = colorMapA;
|
colorMap = colorMapA;
|
||||||
maskColors = maskColorsA;
|
maskColors = maskColorsA;
|
||||||
width = widthA;
|
width = widthA;
|
||||||
@ -3130,22 +3094,7 @@ public:
|
|||||||
bool needsCustomDownscaling = true;
|
bool needsCustomDownscaling = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (printing) {
|
if (!needsCustomDownscaling || printing || scaledWidth >= width || scaledHeight >= height) {
|
||||||
if (width > MAX_PRINT_IMAGE_SIZE || height > MAX_PRINT_IMAGE_SIZE) {
|
|
||||||
if (width > height) {
|
|
||||||
scaledWidth = MAX_PRINT_IMAGE_SIZE;
|
|
||||||
scaledHeight = MAX_PRINT_IMAGE_SIZE * (double)height/width;
|
|
||||||
} else {
|
|
||||||
scaledHeight = MAX_PRINT_IMAGE_SIZE;
|
|
||||||
scaledWidth = MAX_PRINT_IMAGE_SIZE * (double)width/height;
|
|
||||||
}
|
|
||||||
needsCustomDownscaling = true;
|
|
||||||
} else {
|
|
||||||
needsCustomDownscaling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!needsCustomDownscaling || scaledWidth >= width || scaledHeight >= height) {
|
|
||||||
// No downscaling. Create cairo image containing the source image data.
|
// No downscaling. Create cairo image containing the source image data.
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
ptrdiff_t stride;
|
ptrdiff_t stride;
|
||||||
@ -3204,7 +3153,7 @@ public:
|
|||||||
current_row++;
|
current_row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(pix == nullptr)) {
|
if (unlikely(pix == NULL)) {
|
||||||
memset(row_data, 0, width*4);
|
memset(row_data, 0, width*4);
|
||||||
if (!imageError) {
|
if (!imageError) {
|
||||||
error(errInternal, -1, "Bad image stream");
|
error(errInternal, -1, "Bad image stream");
|
||||||
@ -3259,7 +3208,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
|||||||
cairo_matrix_t matrix;
|
cairo_matrix_t matrix;
|
||||||
int width, height;
|
int width, height;
|
||||||
int scaledWidth, scaledHeight;
|
int scaledWidth, scaledHeight;
|
||||||
cairo_filter_t filter = CAIRO_FILTER_BEST;
|
cairo_filter_t filter = CAIRO_FILTER_GOOD;
|
||||||
RescaleDrawImage rescale;
|
RescaleDrawImage rescale;
|
||||||
|
|
||||||
LOG (printf ("drawImage %dx%d\n", widthA, heightA));
|
LOG (printf ("drawImage %dx%d\n", widthA, heightA));
|
||||||
@ -3275,17 +3224,8 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
|||||||
if (width == widthA && height == heightA)
|
if (width == widthA && height == heightA)
|
||||||
filter = getFilterForSurface (image, interpolate);
|
filter = getFilterForSurface (image, interpolate);
|
||||||
|
|
||||||
if (!inlineImg) { /* don't read stream twice if it is an inline image */
|
if (!inlineImg) /* don't read stream twice if it is an inline image */
|
||||||
// cairo 1.15.10 allows mime image data to have different size to cairo image
|
setMimeData(state, str, ref, colorMap, image);
|
||||||
// mime image size will be scaled to same size as cairo image
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
|
||||||
bool requireSameSize = false;
|
|
||||||
#else
|
|
||||||
bool requireSameSize = true;
|
|
||||||
#endif
|
|
||||||
if (!requireSameSize || (width == widthA && height == heightA))
|
|
||||||
setMimeData(state, str, ref, colorMap, image, heightA);
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern = cairo_pattern_create_for_surface (image);
|
pattern = cairo_pattern_create_for_surface (image);
|
||||||
cairo_surface_destroy (image);
|
cairo_surface_destroy (image);
|
||||||
@ -3310,7 +3250,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
|||||||
} else if (mask) {
|
} else if (mask) {
|
||||||
maskPattern = cairo_pattern_reference (mask);
|
maskPattern = cairo_pattern_reference (mask);
|
||||||
} else {
|
} else {
|
||||||
maskPattern = nullptr;
|
maskPattern = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_save (cairo);
|
cairo_save (cairo);
|
||||||
@ -3355,11 +3295,11 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
|||||||
|
|
||||||
CairoImageOutputDev::CairoImageOutputDev()
|
CairoImageOutputDev::CairoImageOutputDev()
|
||||||
{
|
{
|
||||||
images = nullptr;
|
images = NULL;
|
||||||
numImages = 0;
|
numImages = 0;
|
||||||
size = 0;
|
size = 0;
|
||||||
imgDrawCbk = nullptr;
|
imgDrawCbk = NULL;
|
||||||
imgDrawCbkData = nullptr;
|
imgDrawCbkData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CairoImageOutputDev::~CairoImageOutputDev()
|
CairoImageOutputDev::~CairoImageOutputDev()
|
||||||
@ -3372,7 +3312,7 @@ CairoImageOutputDev::~CairoImageOutputDev()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CairoImageOutputDev::saveImage(CairoImage *image)
|
void CairoImageOutputDev::saveImage(CairoImage *image)
|
||||||
{
|
{
|
||||||
if (numImages >= size) {
|
if (numImages >= size) {
|
||||||
size += 16;
|
size += 16;
|
||||||
images = (CairoImage **) greallocn (images, size, sizeof (CairoImage *));
|
images = (CairoImage **) greallocn (images, size, sizeof (CairoImage *));
|
||||||
@ -3432,7 +3372,7 @@ void CairoImageOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *st
|
|||||||
CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, interpolate, inlineImg);
|
CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, interpolate, inlineImg);
|
||||||
image->setImage (surface);
|
image->setImage (surface);
|
||||||
|
|
||||||
setCairo (nullptr);
|
setCairo (NULL);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
@ -3465,7 +3405,7 @@ void CairoImageOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref,
|
|||||||
}
|
}
|
||||||
image->setImage (surface);
|
image->setImage (surface);
|
||||||
|
|
||||||
setCairo (nullptr);
|
setCairo (NULL);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
@ -3491,11 +3431,11 @@ void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
|
|||||||
setCairo (cr);
|
setCairo (cr);
|
||||||
cairo_translate (cr, 0, height);
|
cairo_translate (cr, 0, height);
|
||||||
cairo_scale (cr, width, -height);
|
cairo_scale (cr, width, -height);
|
||||||
|
|
||||||
CairoOutputDev::drawImage(state, ref, str, width, height, colorMap, interpolate, maskColors, inlineImg);
|
CairoOutputDev::drawImage(state, ref, str, width, height, colorMap, interpolate, maskColors, inlineImg);
|
||||||
image->setImage (surface);
|
image->setImage (surface);
|
||||||
|
|
||||||
setCairo (nullptr);
|
setCairo (NULL);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
@ -3526,12 +3466,12 @@ void CairoImageOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stre
|
|||||||
setCairo (cr);
|
setCairo (cr);
|
||||||
cairo_translate (cr, 0, height);
|
cairo_translate (cr, 0, height);
|
||||||
cairo_scale (cr, width, -height);
|
cairo_scale (cr, width, -height);
|
||||||
|
|
||||||
CairoOutputDev::drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate,
|
CairoOutputDev::drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate,
|
||||||
maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate);
|
maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate);
|
||||||
image->setImage (surface);
|
image->setImage (surface);
|
||||||
|
|
||||||
setCairo (nullptr);
|
setCairo (NULL);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
@ -3561,12 +3501,12 @@ void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *
|
|||||||
setCairo (cr);
|
setCairo (cr);
|
||||||
cairo_translate (cr, 0, height);
|
cairo_translate (cr, 0, height);
|
||||||
cairo_scale (cr, width, -height);
|
cairo_scale (cr, width, -height);
|
||||||
|
|
||||||
CairoOutputDev::drawMaskedImage(state, ref, str, width, height, colorMap, interpolate,
|
CairoOutputDev::drawMaskedImage(state, ref, str, width, height, colorMap, interpolate,
|
||||||
maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate);
|
maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate);
|
||||||
image->setImage (surface);
|
image->setImage (surface);
|
||||||
|
|
||||||
setCairo (nullptr);
|
setCairo (NULL);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
18
3rdparty/poppler/git/CairoOutputDev.h
vendored
18
3rdparty/poppler/git/CairoOutputDev.h
vendored
@ -23,13 +23,21 @@
|
|||||||
// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
||||||
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
||||||
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
|
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
|
||||||
// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
|
|
||||||
//
|
//
|
||||||
// To see a description of the changes please see the Changelog file that
|
// To see a description of the changes please see the Changelog file that
|
||||||
// came with your tarball or type make ChangeLog if you are building from git
|
// came with your tarball or type make ChangeLog if you are building from git
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
|
||||||
|
// Copied on 2019/March/26
|
||||||
|
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
|
||||||
|
// Corrected <config.h> includes to <poppler-config.h>
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#ifndef CAIROOUTPUTDEV_H
|
#ifndef CAIROOUTPUTDEV_H
|
||||||
#define CAIROOUTPUTDEV_H
|
#define CAIROOUTPUTDEV_H
|
||||||
|
|
||||||
@ -64,9 +72,6 @@ public:
|
|||||||
// Destructor.
|
// Destructor.
|
||||||
~CairoImage ();
|
~CairoImage ();
|
||||||
|
|
||||||
CairoImage(const CairoImage &) = delete;
|
|
||||||
CairoImage& operator=(const CairoImage &) = delete;
|
|
||||||
|
|
||||||
// Set the image cairo surface
|
// Set the image cairo surface
|
||||||
void setImage (cairo_surface_t *image);
|
void setImage (cairo_surface_t *image);
|
||||||
|
|
||||||
@ -287,14 +292,11 @@ protected:
|
|||||||
GBool interpolate);
|
GBool interpolate);
|
||||||
GBool getStreamData (Stream *str, char **buffer, int *length);
|
GBool getStreamData (Stream *str, char **buffer, int *length);
|
||||||
void setMimeData(GfxState *state, Stream *str, Object *ref,
|
void setMimeData(GfxState *state, Stream *str, Object *ref,
|
||||||
GfxImageColorMap *colorMap, cairo_surface_t *image, int height);
|
GfxImageColorMap *colorMap, cairo_surface_t *image);
|
||||||
void fillToStrokePathClip(GfxState *state);
|
void fillToStrokePathClip(GfxState *state);
|
||||||
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
|
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
|
||||||
GBool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
|
GBool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
|
||||||
#endif
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
|
|
||||||
GBool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height);
|
|
||||||
#endif
|
#endif
|
||||||
static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
|
static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
|
||||||
|
|
||||||
|
14
3rdparty/poppler/git/CairoRescaleBox.cc
vendored
14
3rdparty/poppler/git/CairoRescaleBox.cc
vendored
@ -38,6 +38,14 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
|
||||||
|
// Copied on 2019/March/26
|
||||||
|
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
|
||||||
|
// Corrected <config.h> includes to <poppler-config.h>
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
/* This implements a box filter that supports non-integer box sizes */
|
/* This implements a box filter that supports non-integer box sizes */
|
||||||
|
|
||||||
@ -271,9 +279,9 @@ GBool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
|
|||||||
int dest_y;
|
int dest_y;
|
||||||
int src_y = 0;
|
int src_y = 0;
|
||||||
uint32_t *scanline;
|
uint32_t *scanline;
|
||||||
int *x_coverage = nullptr;
|
int *x_coverage = NULL;
|
||||||
int *y_coverage = nullptr;
|
int *y_coverage = NULL;
|
||||||
uint32_t *temp_buf = nullptr;
|
uint32_t *temp_buf = NULL;
|
||||||
GBool retval = gFalse;
|
GBool retval = gFalse;
|
||||||
unsigned int *dest;
|
unsigned int *dest;
|
||||||
int dst_stride;
|
int dst_stride;
|
||||||
|
13
3rdparty/poppler/git/CairoRescaleBox.h
vendored
13
3rdparty/poppler/git/CairoRescaleBox.h
vendored
@ -30,13 +30,21 @@
|
|||||||
// under GPL version 2 or later
|
// under GPL version 2 or later
|
||||||
//
|
//
|
||||||
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
|
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
|
||||||
// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
|
|
||||||
//
|
//
|
||||||
// To see a description of the changes please see the Changelog file that
|
// To see a description of the changes please see the Changelog file that
|
||||||
// came with your tarball or type make ChangeLog if you are building from git
|
// came with your tarball or type make ChangeLog if you are building from git
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//
|
||||||
|
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
|
||||||
|
// Copied on 2019/March/26
|
||||||
|
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
|
||||||
|
// Corrected <config.h> includes to <poppler-config.h>
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#ifndef CAIRO_RESCALE_BOX_H
|
#ifndef CAIRO_RESCALE_BOX_H
|
||||||
#define CAIRO_RESCALE_BOX_H
|
#define CAIRO_RESCALE_BOX_H
|
||||||
|
|
||||||
@ -49,9 +57,6 @@ public:
|
|||||||
CairoRescaleBox() {};
|
CairoRescaleBox() {};
|
||||||
virtual ~CairoRescaleBox() {};
|
virtual ~CairoRescaleBox() {};
|
||||||
|
|
||||||
CairoRescaleBox(const CairoRescaleBox &) = delete;
|
|
||||||
CairoRescaleBox& operator=(const CairoRescaleBox &) = delete;
|
|
||||||
|
|
||||||
virtual GBool downScaleImage(unsigned orig_width, unsigned orig_height,
|
virtual GBool downScaleImage(unsigned orig_width, unsigned orig_height,
|
||||||
signed scaled_width, signed scaled_height,
|
signed scaled_width, signed scaled_height,
|
||||||
unsigned short int start_column, unsigned short int start_row,
|
unsigned short int start_column, unsigned short int start_row,
|
||||||
|
@ -239,7 +239,7 @@ void CairoBackgroundRenderer::setMimeData(GfxState *state, Stream *str, Object *
|
|||||||
{
|
{
|
||||||
if (param.svg_embed_bitmap)
|
if (param.svg_embed_bitmap)
|
||||||
{
|
{
|
||||||
CairoOutputDev::setMimeData(state, str, ref, colorMap, image, cairo_image_surface_get_height (image));
|
CairoOutputDev::setMimeData(state, str, ref, colorMap, image);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user