Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FOFI_DIR = $(XDIR)fofi/
GOO_DIR = $(XDIR)goo/
XPDF_DIR = $(XDIR)xpdf/

PY_SRC = src/xpydf/PdfLoader.cc src/xpydf/ImageInfoDev.cc src/xpydf/ImageDataDev.cc
PY_SRC = src/xpydf/PdfLoader.cc src/xpydf/ImageInfoDev.cc src/xpydf/ImageDataDev.cc src/xpydf/FontOutputDev.cc
SPLASH_SRC = $(wildcard $(SPLASH_DIR)*.cc)
FOFI_SRC = $(wildcard $(FOFI_DIR)*.cc)

Expand Down
6 changes: 4 additions & 2 deletions src/xpdf-4.04/xpdf/GfxFont.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1283,15 +1283,17 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GString *nameA,
}
}
}

// construct the char code -> Unicode mapping object
ctu = CharCodeToUnicode::make8BitToUnicode(toUnicode);

// merge in a ToUnicode CMap, if there is one -- this overwrites
// existing entries in ctu, i.e., the ToUnicode CMap takes
// precedence, but the other encoding info is allowed to fill in any
// holes
readToUnicodeCMap(fontDict, 8, ctu);
if (globalParams->getReadUnicodeCMap()) {
readToUnicodeCMap(fontDict, 8, ctu);
}

// look for a Unicode-to-Unicode mapping
if (name && (utu = globalParams->getUnicodeToUnicode(name))) {
Expand Down
17 changes: 17 additions & 0 deletions src/xpdf-4.04/xpdf/GlobalParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ GlobalParams::GlobalParams(const char *cfgFileName) {
defaultPrinter = NULL;
mapNumericCharNames = gTrue;
mapUnknownCharNames = gFalse;
readUnicodeCMap = gTrue;
mapExtTrueTypeFontsViaUnicode = gTrue;
useTrueTypeUnicodeMapping = gFalse;
droppedFonts = new GHash(gTrue);
Expand Down Expand Up @@ -3268,6 +3269,16 @@ GBool GlobalParams::getMapUnknownCharNames() {
return map;
}

GBool GlobalParams::getReadUnicodeCMap() {
GBool read;

lockGlobalParams;
read = readUnicodeCMap;
unlockGlobalParams;

return read;
}

GBool GlobalParams::getMapExtTrueTypeFontsViaUnicode() {
GBool map;

Expand Down Expand Up @@ -3793,6 +3804,12 @@ void GlobalParams::setMapUnknownCharNames(GBool map) {
unlockGlobalParams;
}

void GlobalParams::setReadUnicodeCMap(GBool read) {
lockGlobalParams;
readUnicodeCMap = read;
unlockGlobalParams;
}

void GlobalParams::setMapExtTrueTypeFontsViaUnicode(GBool map) {
lockGlobalParams;
mapExtTrueTypeFontsViaUnicode = map;
Expand Down
3 changes: 3 additions & 0 deletions src/xpdf-4.04/xpdf/GlobalParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ class GlobalParams {
GString *getDefaultPrinter();
GBool getMapNumericCharNames();
GBool getMapUnknownCharNames();
GBool getReadUnicodeCMap();
GBool getMapExtTrueTypeFontsViaUnicode();
GBool getUseTrueTypeUnicodeMapping();
GBool isDroppedFont(const char *fontName);
Expand Down Expand Up @@ -400,6 +401,7 @@ class GlobalParams {
void setOverprintPreview(GBool preview);
void setMapNumericCharNames(GBool map);
void setMapUnknownCharNames(GBool map);
void setReadUnicodeCMap(GBool map);
void setMapExtTrueTypeFontsViaUnicode(GBool map);
void setTabStateFile(char *tabStateFileA);
void setPrintCommands(GBool printCommandsA);
Expand Down Expand Up @@ -589,6 +591,7 @@ class GlobalParams {
// from the viewer)
GBool mapNumericCharNames; // map numeric char names (from font subsets)?
GBool mapUnknownCharNames; // map unknown char names?
GBool readUnicodeCMap; // Read the unicode c map?
GBool mapExtTrueTypeFontsViaUnicode; // map char codes to GID via Unicode
// for external TrueType fonts?
GBool useTrueTypeUnicodeMapping; // use the Unicode cmaps in TrueType
Expand Down
46 changes: 7 additions & 39 deletions src/xpdf-4.04/xpdf/TextOutputDev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,38 +203,6 @@ static inline double dmax(double x, double y) {
// TextChar
//------------------------------------------------------------------------

class TextChar {
public:

TextChar(Unicode cA, int charPosA, int charLenA,
double xMinA, double yMinA, double xMaxA, double yMaxA,
int rotA, GBool rotatedA, GBool clippedA, GBool invisibleA,
TextFontInfo *fontA, double fontSizeA,
double colorRA, double colorGA, double colorBA);

static int cmpX(const void *p1, const void *p2);
static int cmpY(const void *p1, const void *p2);
static int cmpCharPos(const void *p1, const void *p2);

Unicode c;
int charPos;
int charLen;
double xMin, yMin, xMax, yMax;
TextFontInfo *font;
double fontSize;
double colorR,
colorG,
colorB;

// group the byte-size fields to minimize object size
Guchar rot;
char rotated;
char clipped;
char invisible;
char spaceAfter;
char overlap;
};

TextChar::TextChar(Unicode cA, int charPosA, int charLenA,
double xMinA, double yMinA, double xMaxA, double yMaxA,
int rotA, GBool rotatedA, GBool clippedA, GBool invisibleA,
Expand Down Expand Up @@ -1559,13 +1527,13 @@ void TextPage::addChar(GfxState *state, double x, double y,
} else {
j = i;
}
chars->append(new TextChar(uBuf[j], charPos, nBytes,
xMin, yMin, xMax, yMax,
curRot, rotated, clipped,
state->getRender() == 3 || alpha < 0.001,
curFont, curFontSize,
colToDbl(rgb.r), colToDbl(rgb.g),
colToDbl(rgb.b)));
chars->append(textCharType(uBuf[j], charPos, nBytes,
xMin, yMin, xMax, yMax,
curRot, rotated, clipped,
state->getRender() == 3 || alpha < 0.001,
curFont, curFontSize,
colToDbl(rgb.r), colToDbl(rgb.g),
colToDbl(rgb.b)));
}
}

Expand Down
86 changes: 69 additions & 17 deletions src/xpdf-4.04/xpdf/TextOutputDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,42 @@ class TextFontInfo {
friend class TextWord;
};

//------------------------------------------------------------------------
// TextChar
//------------------------------------------------------------------------

class TextChar {
public:

TextChar(Unicode cA, int charPosA, int charLenA,
double xMinA, double yMinA, double xMaxA, double yMaxA,
int rotA, GBool rotatedA, GBool clippedA, GBool invisibleA,
TextFontInfo *fontA, double fontSizeA,
double colorRA, double colorGA, double colorBA);

static int cmpX(const void *p1, const void *p2);
static int cmpY(const void *p1, const void *p2);
static int cmpCharPos(const void *p1, const void *p2);

Unicode c;
int charPos;
int charLen;
double xMin, yMin, xMax, yMax;
TextFontInfo *font;
double fontSize;
double colorR,
colorG,
colorB;

// group the byte-size fields to minimize object size
Guchar rot;
char rotated;
char clipped;
char invisible;
char spaceAfter;
char overlap;
};

//------------------------------------------------------------------------
// TextWord
//------------------------------------------------------------------------
Expand Down Expand Up @@ -235,7 +271,7 @@ class TextLine {
double getEdge(int idx) { return edge[idx]; }
GBool getHyphenated() { return hyphenated; }

private:
public:

static int cmpX(const void *p1, const void *p2);

Expand Down Expand Up @@ -386,7 +422,7 @@ class TextPage {
public:

TextPage(TextOutputControl *controlA);
~TextPage();
virtual ~TextPage();

// Write contents of page to a stream.
void write(void *outputStream, TextOutputFunc outputFunc);
Expand Down Expand Up @@ -492,20 +528,25 @@ class TextPage {
void removeChars(double xMin, double yMin, double xMax, double yMax,
double xOverlapThresh, double yOverlapThresh);

private:
public:
virtual TextChar *textCharType(Unicode cA, int charPosA, int charLenA,
double xMinA, double yMinA, double xMaxA, double yMaxA,
int rotA, GBool rotatedA, GBool clippedA, GBool invisibleA,
TextFontInfo *fontA, double fontSizeA,
double colorRA, double colorGA, double colorBA
) {
return new TextChar(cA, charPosA, charLenA, xMinA, yMinA, xMaxA, yMaxA,
rotA, rotatedA, clippedA, invisibleA, fontA, fontSizeA,
colorRA, colorGA, colorBA);
}
virtual void encodeFragment(Unicode *text, int len, UnicodeMap *uMap,
GBool primaryLR, GString *s);

virtual void computeLinePhysWidth(TextLine *line, UnicodeMap *uMap);

void startPage(GfxState *state);
void clear();
void updateFont(GfxState *state);
void addChar(GfxState *state, double x, double y,
double dx, double dy,
CharCode c, int nBytes, Unicode *u, int uLen);
void incCharCount(int nChars);
void beginActualText(GfxState *state, Unicode *u, int uLen);
void endActualText(GfxState *state);
void addUnderline(double x0, double y0, double x1, double y1);
void addLink(double xMin, double yMin, double xMax, double yMax,
Link *link);

// output
void writeReadingOrder(void *outputStream,
Expand Down Expand Up @@ -538,8 +579,18 @@ class TextPage {
UnicodeMap *uMap,
char *space, int spaceLen,
char *eol, int eolLen);
void encodeFragment(Unicode *text, int len, UnicodeMap *uMap,
GBool primaryLR, GString *s);

private:

void startPage(GfxState *state);
void clear();
void updateFont(GfxState *state);
void incCharCount(int nChars);
void beginActualText(GfxState *state, Unicode *u, int uLen);
void endActualText(GfxState *state);
void addUnderline(double x0, double y0, double x1, double y1);
void addLink(double xMin, double yMin, double xMax, double yMax,
Link *link);
GBool unicodeEffectiveTypeLOrNum(Unicode u, Unicode left, Unicode right);
GBool unicodeEffectiveTypeR(Unicode u, Unicode left, Unicode right);

Expand Down Expand Up @@ -593,7 +644,6 @@ class TextPage {
int getCharDirection(TextChar *ch, TextChar *left, TextChar *right);
int assignPhysLayoutPositions(GList *columns);
void assignLinePhysPositions(GList *columns);
void computeLinePhysWidth(TextLine *line, UnicodeMap *uMap);
int assignColumnPhysPositions(GList *columns);
void buildSuperLines(TextBlock *blk, GList *superLines);
void assignSimpleLayoutPositions(GList *superLines, UnicodeMap *uMap);
Expand Down Expand Up @@ -784,6 +834,10 @@ class TextOutputDev: public OutputDev {
// Turn extra processing for HTML conversion on or off.
void enableHTMLExtras(GBool html) { control.html = html; }

protected:
TextPage *text; // text for the current page
TextOutputControl control; // formatting parameters

private:

void generateBOM();
Expand All @@ -792,8 +846,6 @@ class TextOutputDev: public OutputDev {
void *outputStream; // output stream
GBool needClose; // need to close the output file?
// (only if outputStream is a FILE*)
TextPage *text; // text for the current page
TextOutputControl control; // formatting parameters
GBool ok; // set up ok?
};

Expand Down
Loading