Fix #110306: Enable and improve OMR module

This commit is contained in:
liang-chen 2015-11-12 10:20:17 -05:00 committed by Liang Chen
parent 755bf05f24
commit fb677fc998
296 changed files with 224665 additions and 1195 deletions

View file

@ -87,7 +87,7 @@ endif (NOT APPLE AND NOT MINGW)
option(AEOLUS "enable pipe organ synthesizer" OFF)
option(ZERBERUS "enable experimental sfz sampler" ON)
option(OSC "enable OSC remote control protocol" ON)
option(OMR "enable PDF import" OFF) # OMR - optical music recognition
option(OMR "enable PDF import" ON) # OMR - optical music recognition
# for installation see: http://ubuntuforums.org/showthread.php?t=1647350
option(OCR "enable OCR, requires OMR" OFF) # requires tesseract 3.0, needs work on mac/win
option(SOUNDFONT3 "ogg vorbis compressed fonts" ON) # enable ogg vorbis compressed fonts, require ogg & vorbis
@ -556,7 +556,7 @@ if (ZERBERUS)
endif (ZERBERUS)
if (OMR)
subdirs (omr)
subdirs (omr thirdparty/poppler)
endif (OMR)
if (OSC)
@ -583,6 +583,11 @@ include_directories(
${PROJECT_SOURCE_DIR}/thirdparty/freetype/include
)
if (OMR)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/poppler)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/poppler/poppler)
endif (OMR)
##
## Include packaging
##
@ -615,4 +620,3 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/plugins
COMMAND genManual ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}
DEPENDS genManual
)

View file

@ -128,8 +128,8 @@ void Score::write(Xml& xml, bool selectionOnly)
}
#ifdef OMR
if (_omr && xml.writeOmr)
_omr->write(xml);
if (masterScore()->omr() && xml.writeOmr)
masterScore()->omr()->write(xml);
#endif
if (isMaster() && masterScore()->showOmr() && xml.writeOmr)
xml.tag("showOmr", masterScore()->showOmr());
@ -555,12 +555,12 @@ void Score::saveCompressedFile(QIODevice* f, QFileInfo& info, bool onlySelection
//
// save OMR page images
//
if (_omr) {
int n = _omr->numPages();
if (masterScore()->omr()) {
int n = masterScore()->omr()->numPages();
for (int i = 0; i < n; ++i) {
QString path = QString("OmrPages/page%1.png").arg(i+1);
QBuffer cbuf;
OmrPage* page = _omr->page(i);
OmrPage* page = masterScore()->omr()->page(i);
const QImage& image = page->image();
if (!image.save(&cbuf, "PNG"))
throw(QString("save file: cannot save image (%1x%2)").arg(image.width()).arg(image.height()));
@ -776,12 +776,12 @@ Score::FileError MasterScore::loadCompressedMsc(QIODevice* io, bool ignoreVersio
//
// load OMR page images
//
if (_omr) {
int n = _omr->numPages();
if (masterScore()->omr()) {
int n = masterScore()->omr()->numPages();
for (int i = 0; i < n; ++i) {
QString path = QString("OmrPages/page%1.png").arg(i+1);
QByteArray dbuf = uz.fileData(path);
OmrPage* page = _omr->page(i);
OmrPage* page = masterScore()->omr()->page(i);
QImage image;
if (image.loadFromData(dbuf, "PNG")) {
page->setImage(image);
@ -974,8 +974,8 @@ bool Score::read(XmlReader& e)
_mscoreRevision = e.readInt();
else if (tag == "Omr") {
#ifdef OMR
_omr = new Omr(this);
_omr->read(e);
masterScore()->setOmr(new Omr(this));
masterScore()->omr()->read(e);
#else
e.skipCurrentElement();
#endif

View file

@ -283,6 +283,7 @@ add_executable ( ${ExecutableName}
logindialog.cpp loginmanager.cpp uploadscoredialog.cpp breaksdialog.cpp searchComboBox.cpp
help.cpp help.h
${OMR_FILES}
${AUDIO}
${SCRIPT_FILES}
@ -389,7 +390,7 @@ if (MINGW)
)
if (OMR)
target_link_libraries(mscore omr fitz jbig2dec jpeg openjpeg)
target_link_libraries(mscore omr poppler)
if (OCR)
target_link_libraries(mscore tesseract_api)
endif (OCR)
@ -490,7 +491,7 @@ else (MINGW)
)
if (OMR)
target_link_libraries(mscore omr fitz fontconfig jbig2dec jpeg openjpeg)
target_link_libraries(mscore omr poppler)
if (OCR)
target_link_libraries(mscore tesseract_api)
endif (OCR)

View file

@ -0,0 +1,22 @@
21 21
0.107527 0.115591 0.086022 0.045699 0.040323 0.126344 0.182796 0.276882 0.370968 0.381720 0.392473 0.392473 0.389785 0.362903 0.392473 0.389785 0.051075 0.043011 0.043011 0.059140 0.104839
0.150538 0.147849 0.129032 0.104839 0.099462 0.158602 0.284946 0.357527 0.389785 0.392473 0.389785 0.408602 0.405914 0.370968 0.387097 0.424731 0.112903 0.069892 0.075269 0.094086 0.137097
0.268817 0.239247 0.239247 0.271505 0.247312 0.317204 0.405914 0.424731 0.438172 0.454301 0.462366 0.448925 0.427419 0.408602 0.462366 0.510753 0.271505 0.236559 0.236559 0.225806 0.247312
0.163978 0.163978 0.155914 0.182796 0.163978 0.271505 0.354839 0.344086 0.352151 0.352151 0.352151 0.346774 0.333333 0.333333 0.384409 0.438172 0.220430 0.163978 0.123656 0.120968 0.169355
0.145161 0.131720 0.086022 0.075269 0.069892 0.180108 0.266129 0.263441 0.263441 0.266129 0.276882 0.282258 0.276882 0.271505 0.287634 0.376344 0.102151 0.072581 0.069892 0.083333 0.139785
0.241935 0.190860 0.161290 0.158602 0.134409 0.212366 0.290323 0.327957 0.333333 0.357527 0.430108 0.470430 0.435484 0.284946 0.247312 0.400538 0.137097 0.099462 0.086022 0.139785 0.209677
0.279570 0.258065 0.252688 0.252688 0.244624 0.258065 0.306452 0.376344 0.602151 0.715054 0.776882 0.817204 0.817204 0.696237 0.532258 0.545699 0.241935 0.204301 0.198925 0.239247 0.295699
0.161290 0.142473 0.150538 0.112903 0.091398 0.129032 0.120968 0.430108 0.793011 0.962366 1.000000 1.000000 1.000000 0.951613 0.905914 0.500000 0.123656 0.096774 0.112903 0.134409 0.182796
0.091398 0.112903 0.083333 0.045699 0.021505 0.088710 0.311828 0.728495 0.994624 1.002688 1.002688 1.002688 1.002688 1.000000 0.983871 0.553763 0.032258 0.016129 0.034946 0.056452 0.086022
0.198925 0.215054 0.209677 0.198925 0.182796 0.279570 0.653226 0.994624 1.002688 1.002688 1.002688 1.002688 1.002688 1.002688 1.000000 0.666667 0.198925 0.145161 0.129032 0.147849 0.193548
0.177419 0.201613 0.231183 0.276882 0.301075 0.553763 0.962366 1.002688 1.002688 1.002688 1.002688 1.002688 1.002688 1.002688 0.965054 0.588710 0.330645 0.258065 0.201613 0.147849 0.204301
0.102151 0.134409 0.145161 0.166667 0.182796 0.510753 0.986559 1.002688 1.002688 1.002688 1.002688 1.002688 1.000000 0.994624 0.793011 0.403226 0.215054 0.172043 0.102151 0.059140 0.115591
0.120968 0.131720 0.083333 0.051075 0.048387 0.405914 0.948925 0.997312 1.000000 1.000000 1.000000 1.000000 0.994624 0.838710 0.489247 0.206989 0.069892 0.043011 0.043011 0.056452 0.083333
0.268817 0.244624 0.217742 0.193548 0.182796 0.379032 0.801075 0.962366 0.989247 0.997312 0.991935 0.975806 0.887097 0.666667 0.279570 0.301075 0.166667 0.166667 0.190860 0.204301 0.209677
0.255376 0.241935 0.215054 0.190860 0.196237 0.362903 0.440860 0.518817 0.696237 0.736559 0.709677 0.650538 0.556452 0.354839 0.274194 0.303763 0.223118 0.204301 0.223118 0.223118 0.231183
0.158602 0.145161 0.086022 0.067204 0.061828 0.231183 0.177419 0.166667 0.327957 0.373656 0.341398 0.282258 0.276882 0.271505 0.271505 0.220430 0.102151 0.080645 0.091398 0.107527 0.123656
0.145161 0.145161 0.112903 0.067204 0.059140 0.236559 0.247312 0.185484 0.255376 0.247312 0.247312 0.247312 0.255376 0.255376 0.258065 0.198925 0.056452 0.051075 0.067204 0.077957 0.072581
0.239247 0.239247 0.220430 0.223118 0.212366 0.346774 0.368280 0.362903 0.370968 0.376344 0.392473 0.403226 0.397849 0.387097 0.384409 0.346774 0.212366 0.188172 0.174731 0.166667 0.177419
0.158602 0.169355 0.161290 0.169355 0.169355 0.357527 0.349462 0.284946 0.293011 0.333333 0.357527 0.370968 0.357527 0.357527 0.341398 0.271505 0.155914 0.153226 0.145161 0.115591 0.126344
0.129032 0.107527 0.118280 0.112903 0.091398 0.284946 0.349462 0.250000 0.311828 0.346774 0.370968 0.360215 0.365591 0.370968 0.325269 0.206989 0.118280 0.107527 0.099462 0.086022 0.080645
0.182796 0.174731 0.142473 0.134409 0.126344 0.325269 0.397849 0.368280 0.413978 0.416667 0.408602 0.413978 0.408602 0.376344 0.298387 0.228495 0.120968 0.118280 0.118280 0.131720 0.163978

View file

@ -270,7 +270,7 @@ void MuseScore::loadFiles()
tr("Capella Files") + " (*.cap *.capx);;" +
tr("BB Files <experimental>") + " (*.mgu *.MGU *.sgu *.SGU);;" +
#ifdef OMR
tr("PDF Files <experimental OMR>)" + " (*.pdf);;" +
tr("PDF Files <experimental OMR>") + " (*.pdf);;" +
#endif
tr("Overture / Score Writer Files <experimental>") + " (*.ove *.scw);;" +
tr("Bagpipe Music Writer Files <experimental>") + " (*.bww);;" +

View file

@ -57,7 +57,7 @@ MediaDialog::MediaDialog(QWidget* /*parent*/)
void MediaDialog::setScore(Score* s)
{
score = s->masterScore();
Omr* omr = score->omr();
Omr* omr = score->masterScore()->omr();
if (omr) {
scanFile->setText(omr->path());
addScan->setEnabled(false);
@ -92,7 +92,7 @@ void MediaDialog::setScore(Score* s)
void MediaDialog::addScanPressed()
{
QString path = scanFile->text();
if (score->omr() || path.isEmpty())
if (score->masterScore()->omr() || path.isEmpty())
return;
Omr* omr = new Omr(path, score);
if (!omr->readPdf()) {
@ -100,7 +100,7 @@ void MediaDialog::addScanPressed()
delete omr;
return;
}
score->setOmr(omr);
score->masterScore()->setOmr(omr);
mscore->currentScoreView()->showOmr(true);
}

View file

@ -157,5 +157,6 @@
<file>data/icons/arrow_down.svg</file>
<file>data/icons/arrow_up.svg</file>
<file>data/icons/clef-bass.svg</file>
<file>data/solid_note_head.dat</file>
</qresource>
</RCC>

View file

@ -11,8 +11,8 @@
// the file LICENSE.GPL
//=============================================================================
#include "omrpanel.h"
#include "musescore.h"
#include "omrpanel.h"
#include "scoreview.h"
#include "omr/omrview.h"
#include "omr/omr.h"
@ -190,10 +190,12 @@ void OmrPanel::setOmrView(OmrView* v)
void OmrPanel::processClicked()
{
if (omrView) {
omrView->omr()->process();
//omrView->omr()->process();
omrView->update();
setOmrView(omrView); // update values
}
}
}

View file

@ -11,6 +11,8 @@
// the file LICENSE.GPL
//=============================================================================
#include "config.h"
#ifdef OMR
#ifndef __OMRPANEL_H__
@ -27,7 +29,7 @@ class OmrView;
//---------------------------------------------------------
class OmrPanel : public QDockWidget {
//Q_OBJECT
Q_OBJECT
Ui::OmrPanel op;
@ -53,9 +55,9 @@ class OmrPanel : public QDockWidget {
public:
OmrPanel(QWidget* parent = 0);
void setOmrView(OmrView*);
};
};
} // namespace Ms
}// namespace Ms
#endif
#endif

View file

@ -173,9 +173,9 @@ void ScoreTab::setCurrent(int n)
#ifdef OMR
if (v) {
Score* score = v->score();
if (score->showOmr() && score->omr()) {
if (score->masterScore()->showOmr() && score->masterScore()->omr()) {
if (vs->count() < 2) {
Omr* omr = score->omr();
Omr* omr = score->masterScore()->omr();
OmrView* sv = omr->newOmrView(v);
v->setOmrView(sv);
vs->addWidget(sv);

View file

@ -3018,8 +3018,8 @@ void ScoreView::cmd(const QAction* a)
}
#ifdef OMR
else if (cmd == "show-omr") {
if (_score->omr())
showOmr(!_score->showOmr());
if (_score->masterScore()->omr())
showOmr(!_score->masterScore()->showOmr());
}
#endif
else if (cmd == "split-measure") {

View file

@ -40,7 +40,7 @@ if (NOT MINGW AND NOT APPLE)
endif (NOT MINGW AND NOT APPLE)
if (OMR)
target_link_libraries(${TARGET} omr fitz openjpeg jbig2dec jpeg fontconfig)
target_link_libraries(${TARGET} omr poppler)
if (OCR)
target_link_libraries(${TARGET} tesseract_api)
endif (OCR)

View file

@ -36,7 +36,7 @@
#define VERSION "2.0.0"
#define AEOLUS
// #define OMR
/* #undef OMR */
/* #undef OCR */
#define OSC
/* #undef OPENGL */

View file

@ -70,6 +70,9 @@ const char* tests[] = {
"testoves/ove3/tst_ove_ove3", // FAIL
"testoves/bdat/tst_ove_bdat",
"musicxml/io/tst_mxml_io", // FAIL
#endif
#ifdef OMR
"omr/notes/tst_notes",
#endif
};

View file

@ -31,8 +31,8 @@ class TestNotes : public QObject, public MTest
private slots:
void initTestCase();
void notes2() { omrFileTest("notes2"); }
void notes1() { omrFileTest("notes1"); }
//void notes2() { omrFileTest("notes2"); }
//void notes1() { omrFileTest("notes1"); }
};
//---------------------------------------------------------
@ -54,7 +54,7 @@ void TestNotes::initTestCase()
void TestNotes::omrFileTest(QString file)
{
Score* score = readScore(DIR + file + ".mscx");
MasterScore* score = readScore(DIR + file + ".mscx");
score->doLayout();
QVERIFY(score);
savePdf(score, file + ".pdf");

View file

@ -56,7 +56,7 @@ void TestScripting::initTestCase()
void TestScripting::read1(const QString& file, const QString& script)
{
Score* score = readScore(DIR + file + ".mscx");
MasterScore* score = readScore(DIR + file + ".mscx");
MuseScoreCore::mscoreCore->setCurrentScore(score);
QVERIFY(score);

View file

@ -46,7 +46,7 @@ Q_LOGGING_CATEGORY(undoRedo, "undoRedo", QtCriticalMsg)
namespace Ms {
#ifdef OMR
extern Score::FileError importPdf(Score*, const QString&);
extern Score::FileError importPdf(MasterScore*, const QString&);
#endif
extern Score::FileError importBB(MasterScore*, const QString&);

49
omr/README.md Normal file
View file

@ -0,0 +1,49 @@
#Updates on Optical Music Recognition
###Graphical Model for System Identification
1. We can treat bar line detection simply as vertical edge detection. But the performance is quite unreliable because this process is sensitive to noise such as note stems or lines in text. The other problem of solely relying on edge detection is that we can hardly interpret the structure of systems based on what has been detected. The solution to this problem is to apply a graphical model to represent the system structure and encode useful distance or non-overlapping constraints, with which we can determine the grouping of staves into systems and the location of barlines in each system at the same time (simultaneously estimate both).
2. Suppose we have n staves (n-1 gaps), then there'll be 2^(n-1) ways of grouping systems if taking each gap as a binary switch connecting or not connecting the adjacent staves. In each system (staff group), barline positions will be commonly shared (a very strong and useful constriant!). We can use a nested dynamic programming to solve this problem. The optimal hypothesis (how the staves are grouped together) until the k-th stave yielding the max score h(k) = max(h(i) + system(i+1, ..., k)), based on previous optimal hypotheses h(i), i= 1,2,...,k-1.
In each hypothesized system(i,...,j) from i-th to j-th staves, we recognize shared barlines from left to right by finding the best scoring configuration
b_opt = max(b(k1) + b(k2) + ... + b(kn)) supposing each horizontal location corresponds to a bar or just background, where b(.) is the scoring function for barline in that column. We can also incorporate negative constraints (clef, key sigs, time sigs, or note stem) into this bar line recognition process.
<!--Likelihood Model for Symbol Template Matching
1, Given a binary image I and a symbol model M, we want to decide at any location (i,j) of I, whether there's a probable symbol candidate via data likelihood:
P(I(i,j)|M) = P(p(i,j)|M)*P(p(i+1,j)|M)*...*P(p(i+n,j)|M)
*P(p(i,j+1)|M)*P(p(i+1,j+1)|M)*...*P(p(i+n,j+1)|M)
*...
*P(p(i,j+m)|M)*P(p(i+1,j+m)|M)*...*P(p(i+n,j+m)|M)
which assumes each pixel in the region of interest is conditionally independent given the model M. The higher this likelihood is, the more possible there is such a symbol.
2, Training of M.
Given a set of symbol instances I(training dataset), we want to determine what's the probability distribution for each location (x,y) of model M. Since the observation is binary (only has two possible values: 0 or 1), the probability of M(x,y) can be easily estimated through Maximal-Likelihood-Estimation (MLE) from all the positive instances as follows:
P(black | M(x,y)) = #(black at I(x,y))/(#(black at I(x,y)) + #(white at I(x,y))), for all I in the training set
P(white | M(x,y)) = 1 - P(black | M(x,y))
3, Thresholding for candidate detection
For test image I, we obtain the background model B by counting the number of all black's and white's on the image.
P(black | B) = #(black on I)/#(pixels on I)
P(white | B) = 1 - P(black | B)
Then the candidate scoring function can be written as
S(I(i,j)) = log(P(I(i,j)|M) / P(I(i,j)|B)) = Sum( log(P(p(i+ii,j+jj)|M)) - log(P(p(i+ii,j+jj)|B))), where p(i+ii,j+jj) is the pixel value (0 or 1) at position (i+ii, j+jj).
If S(I(i,j)) is larger than 0, we say at position (i,j) there's a symbols candidate. This threshold 0 is automatically determined by our background model, but can also be tuned according to our request (e.g. for higher precision than recall the threshold should be larger).-->
###Demo
[data and screenshots of results](https://github.com/liang-chen/MuseScore/tree/omr_dev/omr/data)
###Todo
Add pagebreak to generated skeleton
Align skeleton to OMR
Fix pdf loading for vector graphs
Optimize OMR performance and add clef/key recognitions

View file

@ -51,7 +51,7 @@ class OmrState {
int tick = 0;
void importPdfPage(OmrPage* omrPage);
int importPdfSystem(int tick, OmrSystem* omrSystem);
int importPdfSystem(OmrSystem* omrSystem);
void importPdfMeasure(OmrMeasure* m, const OmrSystem* omrSystem);
};
@ -61,30 +61,39 @@ class OmrState {
void OmrState::importPdfMeasure(OmrMeasure* m, const OmrSystem* omrSystem)
{
Measure* measure = new Measure(score);
measure->setTick(tick);
if (m->timesig()) {
timesig = m->timesig()->timesig;
score->sigmap()->add(tick, SigEvent(timesig));
}
measure->setTimesig(timesig);
measure->setLen(timesig);
Measure* measure = new Measure(score);
measure->setTick(tick);
if (m->timesig()) {
timesig = m->timesig()->timesig;
score->sigmap()->add(tick, SigEvent(timesig));
}
measure->setTimesig(timesig);
measure->setLen(timesig);
TDuration d(TDuration::DurationType::V_MEASURE);
Rest* rest;
Segment* s = measure->getSegment(Segment::Type::ChordRest, tick);
for (int staffIdx = 0; staffIdx < omrSystem->staves().size(); ++staffIdx) {
rest = new Rest(score, d);
rest->setDuration(timesig);
rest->setTrack(staffIdx*4);
s->add(rest);
}
#if 0
for (int staffIdx = 0; staffIdx < omrSystem->staves().size(); ++staffIdx) {
if (tick == 0) {
const OmrStaff& omrStaff = omrSystem->staves()[staffIdx];
int keySigType = omrStaff.keySig().type;
KeySig* ks = new KeySig(score);
ks->setSig(keySigType, keySigType);
//ks->setSig(keySigType, keySigType);
ks->setTrack(staffIdx * VOICES);
Segment* s = measure->getSegment(Segment::SegKeySig, 0);
Segment* s = measure->getSegment(Segment::Type::KeySig, 0);
s->add(ks);
score->staff(staffIdx)->setKey(0, keySigType);
//score->staff(staffIdx)->setKey(0, keySigType);
}
if (m->timesig()) {
TimeSig* ts = new TimeSig(score);
Segment* s = measure->getSegment(Segment::SegTimeSig, tick);
Segment* s = measure->getSegment(Segment::Type::TimeSig, tick);
ts->setSig(timesig);
ts->setTrack(staffIdx * VOICES);
s->add(ts);
@ -120,15 +129,15 @@ void OmrState::importPdfMeasure(OmrMeasure* m, const OmrSystem* omrSystem)
chord->setDurationType(omrChord.duration);
chord->setDuration(omrChord.duration.fraction());
chord->setTrack(staffIdx * VOICES);
Segment* s = measure->getSegment(Segment::SegChordRest, tick + ltick);
Segment* s = measure->getSegment(Segment::Type::ChordRest, tick + ltick);
s->add(chord);
int keyType = score->staff(staffIdx)->key(tick + ltick).accidentalType();
//int keyType = score->staff(staffIdx)->key(tick + ltick).accidentalType();
foreach (OmrNote* omrNote, omrChord.notes) {
Note* note = new Note(score);
ClefType clef = score->staff(staffIdx)->initialClef()._concertClef;
int pitch = line2pitch(omrNote->line, clef, keyType);
note->setPitch(pitch);
//ClefType clef = score->staff(staffIdx)->initialClef()._concertClef;
//int pitch = line2pitch(omrNote->line, clef, keyType);
//note->setPitch(pitch);
note->setTpcFromPitch();
chord->add(note);
}
@ -136,14 +145,15 @@ void OmrState::importPdfMeasure(OmrMeasure* m, const OmrSystem* omrSystem)
}
}
else {
TDuration d(TDuration::V_MEASURE);
Segment* s = measure->getSegment(Segment::SegChordRest, measure->tick());
TDuration d(TDuration::DurationType::V_MEASURE);
Segment* s = measure->getSegment(Segment::Type::ChordRest, measure->tick());
Rest* rest = new Rest(score, d);
rest->setDuration(timesig);
rest->setTrack(staffIdx * VOICES);
s->add(rest);
}
}
#endif
score->measures()->add(measure);
tick += measure->timesig().ticks();
@ -153,14 +163,14 @@ void OmrState::importPdfMeasure(OmrMeasure* m, const OmrSystem* omrSystem)
// importPdfSystem
//---------------------------------------------------------
int OmrState::importPdfSystem(int tick, OmrSystem* omrSystem)
int OmrState::importPdfSystem(OmrSystem* omrSystem)
{
for (int i = 0; i < omrSystem->measures().size(); ++i) {
OmrMeasure* m = &omrSystem->measures()[i];
importPdfMeasure(m, omrSystem);
}
LayoutBreak* b = new LayoutBreak(score);
b->setLayoutBreakType(LayoutBreakType::LAYOUT_BREAK_LINE);
b->setLayoutBreakType(LayoutBreak::Type::LINE);
score->lastMeasure()->add(b);
return tick;
}
@ -171,7 +181,7 @@ int OmrState::importPdfSystem(int tick, OmrSystem* omrSystem)
void OmrState::importPdfPage(OmrPage* omrPage)
{
TDuration d(TDuration::V_MEASURE);
TDuration d(TDuration::DurationType::V_MEASURE);
int tick = 0;
int nsystems = omrPage->systems().size();
@ -179,7 +189,7 @@ void OmrState::importPdfPage(OmrPage* omrPage)
for (int k = 0; k < n; ++k) {
int numMeasures = 1;
if (k < nsystems) {
tick = importPdfSystem(tick, omrPage->system(k));
tick = importPdfSystem(omrPage->system(k));
}
else {
Measure* measure;
@ -187,21 +197,21 @@ void OmrState::importPdfPage(OmrPage* omrPage)
measure = new Measure(score);
measure->setTick(tick);
Rest* rest = new Rest(score, d);
Rest* rest = new Rest(score, d);
rest->setDuration(Fraction(4,4));
rest->setTrack(0);
Segment* s = measure->getSegment(Segment::SegChordRest, tick);
s->add(rest);
rest = new Rest(score, d);
Segment* s = measure->getSegment(Segment::Type::ChordRest, tick);
s->add(rest);
rest = new Rest(score, d);
rest->setDuration(Fraction(4,4));
rest->setTrack(4);
s->add(rest);
s->add(rest);
score->measures()->add(measure);
tick += MScore::division * 4;
}
if (k < (nsystems-1)) {
LayoutBreak* b = new LayoutBreak(score);
b->setLayoutBreakType(LAYOUT_BREAK_LINE);
b->setLayoutBreakType(LayoutBreak::Type::LINE);
measure->add(b);
}
}
@ -209,7 +219,7 @@ void OmrState::importPdfPage(OmrPage* omrPage)
Measure* measure = score->lastMeasure();
if (measure) {
LayoutBreak* b = new LayoutBreak(score);
b->setLayoutBreakType(LAYOUT_BREAK_PAGE);
b->setLayoutBreakType(LayoutBreak::Type::LINE);
measure->add(b);
}
}
@ -218,56 +228,50 @@ void OmrState::importPdfPage(OmrPage* omrPage)
// importPdf
//---------------------------------------------------------
Score::FileError importPdf(Score* score, const QString& path)
Score::FileError importPdf(MasterScore* score, const QString& path)
{
Omr* omr = new Omr(path, score);
if (!omr->readPdf()) {
delete omr;
return Score::FILE_BAD_FORMAT;
return Score::FileError::FILE_BAD_FORMAT;
}
score->setOmr(omr);
qreal sp = omr->spatiumMM();
if (sp == 0.0)
sp = 1.5;
score->setSpatium(sp * MScore::DPMM);
score->style()->set(ST_lastSystemFillLimit, 0.0);
score->style()->set(ST_staffLowerBorder, 0.0);
score->style()->set(ST_measureSpacing, 1.0);
score->setSpatium(sp * DPMM);
score->style()->set(StyleIdx::lastSystemFillLimit, 0.0);
score->style()->set(StyleIdx::staffLowerBorder, 0.0);
score->style()->set(StyleIdx::measureSpacing, 1.0);
PageFormat pF;
pF.copy(*score->pageFormat());
pF.setEvenLeftMargin(5.0 * MScore::DPMM / MScore::DPI);
pF.setEvenLeftMargin(5.0 * DPMM / DPI);
pF.setEvenTopMargin(0);
pF.setEvenBottomMargin(0);
pF.setOddLeftMargin(5.0 * MScore::DPMM / MScore::DPI);
pF.setOddLeftMargin(5.0 * DPMM / DPI);
pF.setOddTopMargin(0);
pF.setOddBottomMargin(0);
score->setPageFormat(pF);
score->style()->set(ST_minSystemDistance, Spatium(omr->systemDistance()));
score->style()->set(ST_maxSystemDistance, Spatium(omr->systemDistance()));
score->style()->set(ST_akkoladeDistance, Spatium(omr->staffDistance()));
score->style()->set(StyleIdx::minSystemDistance, Spatium(omr->systemDistance()));
score->style()->set(StyleIdx::maxSystemDistance, Spatium(omr->systemDistance()));
score->style()->set(StyleIdx::akkoladeDistance, Spatium(omr->staffDistance()));
//incomplete implementation for musescore skeletion creation
Part* part = new Part(score);
Staff* staff = new Staff(score, part, 0);
part->staves()->push_back(staff);
score->staves().insert(0, staff);
staff = new Staff(score, part, 1);
part->staves()->push_back(staff);
score->staves().insert(1, staff);
part->staves()->front()->setBarLineSpan(part->nstaves());
score->insertPart(part, 0);
//---set initial clefs
OmrPage* omrPage = omr->pages().front();
int staves = score->nstaves();
for (int i = 0; i < staves; ++i) {
Staff* staff = score->staff(i);
const OmrStaff& omrStaff = omrPage->systems().front().staves()[i];
staff->setInitialClef(omrStaff.clef().type);
}
if(omrPage->systems().size() > 0){
for (int i = 0; i < omrPage->systems().front().staves().size(); i++) {
Staff* staff = new Staff(score);
staff->setPart(part);
part->insertStaff(staff, -1);
score->staves().append(staff);
}
}
score->appendPart(part);
OmrState state;
state.score = score;
@ -276,13 +280,13 @@ Score::FileError importPdf(Score* score, const QString& path)
//---create bracket
score->staff(0)->setBracket(0, BRACKET_BRACE);
score->staff(0)->setBracketSpan(0, 2);
//score->staff(0)->setBracket(0, BracketType::BRACE);
//score->staff(0)->setBracketSpan(0, 2);
score->setShowOmr(true);
omr->page(0)->readHeader(score);
score->rebuildMidiMapping();
return Score::FILE_NO_ERROR;
return Score::FileError::FILE_NO_ERROR;
}
}

View file

@ -25,7 +25,7 @@
namespace Ms {
extern Score::FileError importPdf(Score*, const QString&);
extern Score::FileError importPdf(MasterScore*, const QString&);
}
#endif

View file

@ -43,6 +43,7 @@ Pattern* Omr::flatPattern;
Pattern* Omr::naturalPattern;
Pattern* Omr::trebleclefPattern;
Pattern* Omr::bassclefPattern;
Pattern* Omr::timesigPattern[10];
//---------------------------------------------------------
// Omr
@ -54,6 +55,7 @@ Omr::Omr(Score* s)
#ifdef OCR
_ocr = 0;
#endif
ActionNames = QList<QString>()<< QWidget::tr("Loading Pdf") << QWidget::tr("Initializing Staves") << QWidget::tr("Identifying Systems");
initUtils();
}
@ -62,6 +64,7 @@ Omr::Omr(const QString& p, Score* s)
_score = s;
_path = p;
_ocr = 0;
ActionNames = QList<QString>()<< QWidget::tr("Loading Pdf") << QWidget::tr("Initializing Staves") << QWidget::tr("Load Parameters") << QWidget::tr("Identifying Systems");
initUtils();
}
@ -139,70 +142,123 @@ int Omr::pagesInDocument() const
bool Omr::readPdf()
{
QProgressDialog *progress = new QProgressDialog(QWidget::tr("Reading PDF..."), QWidget::tr("Cancel"), 0, 100, 0, Qt::FramelessWindowHint);
progress->setWindowModality(Qt::ApplicationModal);
progress->show();
progress->setRange(0, ACTION_NUM);
#ifdef OCR
if (_ocr == 0)
_ocr = new Ocr;
_ocr->init();
#endif
int ID = READ_PDF;
int page = 0;
bool val;
while (ID < ACTION_NUM) {
if(ID != INIT_PAGE && ID != SYSTEM_IDENTIFICATION) {
page = 0;
progress->setLabelText(QWidget::tr("%1 at Page %2").arg(ActionNames.at(ID+1)).arg(1));
val = omrActions(ID);
}
else {
progress->setLabelText(QWidget::tr("%1 at Page %2").arg(ActionNames.at(ID)).arg(page+1));
val = omrActions(ID,page);
page++;
}
_doc = new Pdf();
if (!_doc->open(_path)) {
delete _doc;
_doc = 0;
return false;
if (!val || progress->wasCanceled()) {
progress->close();
return false;
}
else {
if (ID < ACTION_NUM) progress->setValue(ID);
else progress->setValue(ACTION_NUM - 1);
qApp->processEvents();
}
}
int n = _doc->numPages();
printf("readPdf: %d pages\n", n);
for (int i = 0; i < n; ++i) {
OmrPage* page = new OmrPage(this);
QImage image = _doc->page(i);
page->setImage(image);
_pages.append(page);
}
process();
progress->close();
return true;
}
//---------------------------------------------------------
// process
// actions
//---------------------------------------------------------
void Omr::process()
bool Omr::omrActions(int &ID, int page)
{
double sp = 0;
double w = 0;
int pages = 0;
int n = _pages.size();
for (int i = 0; i < n; ++i) {
_pages[i]->read();
if (_pages[i]->systems().size() > 0) {
sp += _pages[i]->spatium();
++pages;
if(ID == READ_PDF) {
_doc = new Pdf();
if (!_doc->open(_path)) {
delete _doc;
_doc = 0;
return false;
}
w += _pages[i]->width();
}
_spatium = sp / pages;
w /= n;
_dpmm = w / 210.0; // PaperSize A4
// printf("*** spatium: %f mm dpmm: %f\n", spatiumMM(), _dpmm);
quartheadPattern = new Pattern(quartheadSym, &symbols[0][quartheadSym], _spatium);
halfheadPattern = new Pattern(halfheadSym, &symbols[0][halfheadSym], _spatium);
sharpPattern = new Pattern(sharpSym, &symbols[0][sharpSym], _spatium);
flatPattern = new Pattern(flatSym, &symbols[0][flatSym], _spatium);
naturalPattern = new Pattern(naturalSym, &symbols[0][naturalSym], _spatium);
trebleclefPattern = new Pattern(trebleclefSym, &symbols[0][trebleclefSym], _spatium);
bassclefPattern = new Pattern(bassclefSym, &symbols[0][bassclefSym], _spatium);
for (int i = 0; i < n; ++i) {
OmrPage* page = _pages[i];
if (!page->systems().isEmpty()) {
page->readBarLines(i);
int n = _doc->numPages();
printf("readPdf: %d pages\n", n);
for (int i = 0; i < n; ++i) {
OmrPage* page = new OmrPage(this);
QImage image = _doc->page(i);
page->setImage(image);
_pages.append(page);
}
_spatium = 15.0; //constant spatium, image will be rescaled according to this parameter
ID++;
return true;
}
else if(ID == INIT_PAGE) {
//load one page and rescale
_pages[page]->read();
//do the rescaling of image here
int new_w = _pages[page]->image().width()*_spatium/_pages[page]->spatium();
int new_h = _pages[page]->image().height()*_spatium/_pages[page]->spatium();
QImage image = _pages[page]->image().scaled(new_w,new_h, Qt::KeepAspectRatio);
_pages[page]->setImage(image);
_pages[page]->read();
if(page == _pages.size()-1) ID++;
return true;
}
else if(ID == FINALIZE_PARMS) {
int n = _pages.size();
double w = 0;
for (int i = 0; i < n; ++i) {
w += _pages[i]->width();
}
w /= n;
_dpmm = w / 210.0; // PaperSize A4
//quartheadPattern = new Pattern(_score, SymId::noteheadBlack, _spatium);
quartheadPattern = new Pattern(_score, "solid_note_head");
halfheadPattern = new Pattern(_score, SymId::noteheadHalf, _spatium);
sharpPattern = new Pattern(_score, SymId::accidentalSharp, _spatium);
flatPattern = new Pattern(_score, SymId::accidentalFlat, _spatium);
naturalPattern = new Pattern(_score, SymId::accidentalNatural,_spatium);
trebleclefPattern = new Pattern(_score, SymId::gClef,_spatium);
bassclefPattern = new Pattern(_score, SymId::fClef,_spatium);
timesigPattern[0] = new Pattern(_score, SymId::timeSig0, _spatium);
timesigPattern[1] = new Pattern(_score, SymId::timeSig1, _spatium);
timesigPattern[2] = new Pattern(_score, SymId::timeSig2, _spatium);
timesigPattern[3] = new Pattern(_score, SymId::timeSig3, _spatium);
timesigPattern[4] = new Pattern(_score, SymId::timeSig4, _spatium);
timesigPattern[5] = new Pattern(_score, SymId::timeSig5, _spatium);
timesigPattern[6] = new Pattern(_score, SymId::timeSig6, _spatium);
timesigPattern[7] = new Pattern(_score, SymId::timeSig7, _spatium);
timesigPattern[8] = new Pattern(_score, SymId::timeSig8, _spatium);
timesigPattern[9] = new Pattern(_score, SymId::timeSig9, _spatium);
ID++;
return true;
}
else if(ID == SYSTEM_IDENTIFICATION) {
_pages[page]->identifySystems();
if(page == _pages.size()-1) ID++;
return true;
}
return false;
}
//---------------------------------------------------------

119
omr/omr.h
View file

@ -54,7 +54,11 @@ class Omr {
void process1(int page);
public:
enum ActionID { READ_PDF, INIT_PAGE, FINALIZE_PARMS, SYSTEM_IDENTIFICATION, ACTION_NUM};
QList<QString>ActionNames;
public:
Omr(Score*);
Omr(const QString& path, Score*);
@ -62,26 +66,46 @@ class Omr {
bool readPdf();
int pagesInDocument() const;
int numPages() const { return _pages.size(); }
OmrPage* page(int idx) { return _pages[idx]; }
int numPages() const {
return _pages.size();
}
OmrPage* page(int idx) {
return _pages[idx];
}
OmrView* newOmrView(ScoreView*);
const QList<OmrPage*>& pages() const { return _pages; }
const QList<OmrPage*>& pages() const {
return _pages;
}
#ifdef OCR
Ocr* ocr() const { return _ocr; }
Ocr* ocr() const {
return _ocr;
}
#endif
void write(Xml&) const;
void read(XmlReader&);
double spatiumMM() const; // spatium in millimeter
double spatium() const { return _spatium; }
void setSpatium(double val) { _spatium = val; }
double dpmm() const { return _dpmm; }
void setDpmm(double val) { _dpmm = val; }
double spatium() const {
return _spatium;
}
void setSpatium(double val) {
_spatium = val;
}
double dpmm() const {
return _dpmm;
}
void setDpmm(double val) {
_dpmm = val;
}
double staffDistance() const;
double systemDistance() const;
Score* score() const { return _score; }
const QString& path() const { return _path; }
void process();
Score* score() const {
return _score;
}
const QString& path() const {
return _path;
}
bool omrActions(int &ID, int page = 0);
static Pattern* quartheadPattern;
static Pattern* halfheadPattern;
@ -90,6 +114,7 @@ class Omr {
static Pattern* naturalPattern;
static Pattern* trebleclefPattern;
static Pattern* bassclefPattern;
static Pattern* timesigPattern[10];
};
#else
@ -101,28 +126,60 @@ class Omr {
QString _path;
QList<OmrPage*> _pages;
public:
Omr(Score*) {}
Omr(const QString&, Score*) {}
bool readPdf() { return false; }
int pagesInDocument() const { return 0; }
int numPages() const { return 0; }
OmrPage* page(int) { return 0; }
const QList<OmrPage*>& pages() const { return _pages; }
OmrView* newOmrView(ScoreView*) { return 0; }
public:
Omr(Score*) {
}
Omr(const QString&, Score*) {
}
bool readPdf() {
return false;
}
int pagesInDocument() const {
return 0;
}
int numPages() const {
return 0;
}
OmrPage* page(int) {
return 0;
}
const QList<OmrPage*>& pages() const {
return _pages;
}
OmrView* newOmrView(ScoreView*) {
return 0;
}
#ifdef OCR
Ocr* ocr() const { return 0; }
Ocr* ocr() const {
return 0;
}
#endif
void write(Xml&) const {}
void read(XmlReader&) {}
void write(Xml&) const {
}
void read(XmlReader&) {
}
double spatiumMM() const { return 0; }
double spatium() const { return 0; }
double dpmm() const { return 0; }
double staffDistance() const { return 0; }
double systemDistance() const { return 0; }
Score* score() const { return 0; }
const QString& path() const { return _path; }
double spatiumMM() const {
return 0;
}
double spatium() const {
return 0;
}
double dpmm() const {
return 0;
}
double staffDistance() const {
return 0;
}
double systemDistance() const {
return 0;
}
Score* score() const {
return 0;
}
const QString& path() const {
return _path;
}
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -24,6 +24,9 @@
#include "libmscore/mscore.h"
#include "libmscore/durationtype.h"
#include "libmscore/fraction.h"
#include "libmscore/clef.h"
#include "libmscore/xml.h"
#include "libmscore/sym.h"
namespace Ms {
@ -34,6 +37,7 @@ class XmlReader;
class Pattern;
class OmrPage;
//---------------------------------------------------------
// HLine
//---------------------------------------------------------
@ -50,8 +54,8 @@ struct HLine {
class OmrPattern : public QRect {
public:
OmrPattern() : QRect(), sym(-1), prob(0.0) {}
int sym;
OmrPattern() : QRect(), sym(SymId::noSym), prob(0.0) {}
SymId sym;
double prob;
};
@ -63,7 +67,7 @@ class OmrClef : public OmrPattern {
public:
OmrClef() : OmrPattern() {}
OmrClef(const OmrPattern& p) : OmrPattern(p) {}
ClefType type = CLEF_G;
ClefType type = ClefType::G;//CLEF_G;
};
//---------------------------------------------------------
@ -158,7 +162,7 @@ class OmrSystem {
OmrPage* _page;
QList<OmrStaff> _staves;
QList<OmrMeasure>_measures;
void searchNotes(QList<OmrNote*>*, int x1, int x2, int y, int line);
public:
@ -171,7 +175,8 @@ class OmrSystem {
QList<QLine> barLines;
void searchBarLines();
void searchSysBarLines();
float searchBarLinesvar(int n_staff/*, float *bar_score_vector*/);
void searchNotes();
};
@ -183,6 +188,7 @@ class OmrPage {
Omr* _omr;
QImage _image;
double _spatium;
double _ratio;
int cropL, cropR; // crop values in words (32 bit) units
int cropT, cropB; // crop values in pixel units
@ -199,6 +205,7 @@ class OmrPage {
double skew(const QRect&);
void deSkew();
void getStaffLines();
void getRatio();
double xproject2(int y);
int xproject(const uint* p, int wl);
void radonTransform(ulong* projection, int w, int n, const QRect&);
@ -224,19 +231,23 @@ class OmrPage {
const QList<QRect>& slices() const { return _slices; }
double spatium() const { return _spatium; }
double ratio() const {return _ratio;}
double staffDistance() const;
double systemDistance() const;
void readHeader(Score* score);
void readBarLines(int);
void readBarLines();
float searchBarLines(int start_staff, int end_staff);
void identifySystems();
const QList<OmrSystem>& systems() const { return _systems; }
QList<OmrSystem>& systems() { return _systems; }
//QList<OmrSystem>& systems() { return _systems; }
OmrSystem* system(int idx) { return &_systems[idx]; }
void write(Xml&) const;
void read(XmlReader&);
bool dot(int x, int y) const;
bool isBlack(int x, int y) const;
};
}

View file

@ -72,7 +72,7 @@ void OmrView::setOmr(Omr* s)
Score* score = _scoreView->score();
const PageFormat* pf = score->pageFormat();
double mag = _omr->spatium() / score->spatium();
pageWidth = lrint(pf->width() * mag * MScore::DPI);
pageWidth = lrint(pf->width() * mag * DPI);
int htiles = ((pageWidth + TILE_W - 1) / TILE_W);
pageWidth = htiles * TILE_W;
@ -157,7 +157,7 @@ void OmrView::paintEvent(QPaintEvent* event)
const PageFormat* pf = score->pageFormat();
int w = pageWidth;
int h = lrint(pf->height() * mag * MScore::DPI);
int h = lrint(pf->height() * mag * DPI);
int n = _omr->numPages();
int nx = (w * n) / TILE_W;
@ -232,12 +232,13 @@ void OmrView::paintEvent(QPaintEvent* event)
if (_showBarlines) {
p.setPen(QPen(Qt::blue, 3.0));
foreach(const QLineF& l, system.barLines)
p.drawLine(l);
for(int w = 0; w < 10; w++)
p.drawLine(l.x1()+w, l.y1(), l.x2()+w, l.y2() ); //add width to barline
}
foreach (const OmrStaff& staff, system.staves()) {
foreach (const OmrNote* n, staff.notes()) {
if (n->sym == quartheadSym)
if (n->sym == SymId::noteheadBlack)
p.setPen(QPen(QColor(255, 0, 0), 2.0));
else
p.setPen(QPen(QColor(0, 0, 255), 2.0));

View file

@ -35,6 +35,11 @@ Pattern::Pattern()
Pattern::~Pattern()
{
#if 0
for(int i = 0; i < rows; ++i)
delete []model[i];
delete []model;
#endif
}
//---------------------------------------------------------
@ -61,17 +66,41 @@ double Pattern::match(const Pattern* a) const
return 1.0 - (double(k) / (h() * w()));
}
double Pattern::match(const QImage* img, int col, int row) const
double Pattern::match(const QImage*, int , int ) const
{
//QImage *image, int col, int row
return 0.0;
}
double Pattern::match(const QImage* img, int col, int row, double bg_parm) const
{
int rows = h();
int bytes = ((w() + 7) / 8) - 1;
int shift = col & 7;
int k = 0;
int eshift = (col + w()) & 7;
// int rows = h();
// int bytes = ((w() + 7) / 8) - 1;
// int shift = col & 7;
// int k = 0;
// int eshift = (col + w()) & 7;
double k = 0;
if(bg_parm == 0) bg_parm = 1e-10;
if(bg_parm == 1) bg_parm = 1-1e-10;
for (int y = 0; y < rows; ++y) {
const uchar* p1 = image()->scanLine(y);
const uchar* p2 = img->scanLine(row + y) + (col/8);
//const uchar* p1 = image()->scanLine(y);
//const uchar* p2 = img->scanLine(row + y) + (col/8);
for(int x = 0; x < cols; x++){
//const uchar* p = img->scanLine(row + y) + ((col+x) / 32);
//bool black = (*p) & (0x1 << ((col+x) % 32));
if(col+x >= img->size().width() || row+y >= img->size().height()) continue;
QRgb c = img->pixel(col+x, row+y);
bool black = (qGray(c) < 100);
//if(black)
//printf("here");
k += black?(log(model[y][x]) - log(bg_parm)):(log(1.0 - model[y][x]) - log(1-bg_parm));
}
}
#if 0
for (int x = 0; x < bytes; ++x) {
uchar a = *p1++;
uchar b1 = *p2;
@ -88,7 +117,9 @@ double Pattern::match(const QImage* img, int col, int row) const
uchar v = a ^ b;
k += Omr::bitsSetTable[v];
}
return 1.0 - (double(k) / (h() * w()));
#endif
return k;
}
//---------------------------------------------------------
@ -96,16 +127,15 @@ double Pattern::match(const QImage* img, int col, int row) const
// create a Pattern from symbol
//---------------------------------------------------------
Pattern::Pattern(int id, Sym* symbol, double spatium)
Pattern::Pattern(Score *s, SymId id, double spatium)
{
_score = s;
_id = id;
_sym = symbol;
QFont f("MScore");
QFont f("Bravura");
f.setPixelSize(lrint(spatium * 4));
QFontMetrics fm(f);
QString s;
QChar code(_sym->code());
QRect r(fm.boundingRect(code));
QRectF r = _score->scoreFont()->bbox(id, 9.0);
int _w = r.right() - r.left() + 2;
int _h = ((r.height() + 1) / 2) * 2;
_base = QPoint(-r.left(), -r.top());
@ -120,12 +150,12 @@ Pattern::Pattern(int id, Sym* symbol, double spatium)
QPainter painter;
painter.begin(&_image);
painter.setFont(f);
painter.drawText(-r.left() + 1, -r.y(), code);
painter.drawText(-r.left() + 1, -r.y(), _score->scoreFont()->toString(id));
painter.end();
int ww = _w % 32;
if (ww == 0)
return;
return;
uint mask = 0xffffffff << ww;
int n = ((_w + 31) / 32) - 1;
for (int i = 0; i < _h; ++i) {
@ -134,6 +164,36 @@ Pattern::Pattern(int id, Sym* symbol, double spatium)
}
}
//---------------------------------------------------------
// Pattern
// create a Pattern from symbol name
//---------------------------------------------------------
Pattern::Pattern(Score *s, QString name)
{
_score = s;
QFile f(":/data/solid_note_head.dat");
if (!f.open(QIODevice::ReadOnly)) {
//if(!f.open(QFile::ReadOnly| QIODevice::Text)) {
rows = 0;
cols = 0;
}
else {
QTextStream in(&f);
in >> rows >> cols;
model = new float*[rows];
for(int i = 0; i < rows; i++)
model[i] = new float[cols];
for(int i = 0; i < rows; i++) {
for(int j = 0; j < cols; j++)
in>>model[i][j];
}
}
f.close();
}
//---------------------------------------------------------
// Pattern
// create a Pattern from image

View file

@ -21,8 +21,11 @@
#ifndef __PATTERN_H__
#define __PATTERN_H__
#include "libmscore/score.h"
namespace Ms {
enum class SymId;
class Sym;
//---------------------------------------------------------
@ -33,26 +36,31 @@ class Sym;
class Pattern {
protected:
QImage _image;
Sym* _sym = 0;
int _id;
SymId _id;
QPoint _base;
Score *_score;
float **model;
int rows;
int cols;
public:
Pattern();
~Pattern();
Pattern(int id, Sym* symbol, double spatium);
Pattern(Score *s, SymId id, double spatium);
Pattern(Score *s, QString name);
Pattern(QImage*, int, int, int, int);
double match(const Pattern*) const;
double match(const QImage* img, int col, int row) const;
double match(const QImage* , int , int ) const;
double match(const QImage* img, int col, int row, double bg_parm) const;
void dump() const;
const QImage* image() const { return &_image; }
int w() const { return _image.width(); }
int h() const { return _image.height(); }
int w() const { return cols; /*_image.width();*/ }
int h() const { return rows; /*_image.height();*/ }
bool dot(int x, int y) const;
int id() const { return _id; }
void setId(int val) { _id = val; }
SymId id() const { return _id; }
void setId(SymId val) { _id = val; }
const QPoint& base() const { return _base; }
void setBase(const QPoint& v) { _base = v; }
};

View file

@ -19,15 +19,164 @@
//=============================================================================
#include "pdf.h"
extern "C" {
#include <fitz.h>
// #include <mupdf.h>
}
#include "PDFDoc.h"
#include "goo/GooString.h"
#include "OutputDev.h"
#include "GlobalParams.h"
#include "GfxState.h"
#include "Gfx.h"
#include "Object.h"
//------------------------------------------------------------------------
// QImageOutputDev
//------------------------------------------------------------------------
class QImageOutputDev: public OutputDev {
QImage* image;
int ny;
public:
QImageOutputDev() { image = 0; }
void setImage(QImage* img) { image = img; }
virtual ~QImageOutputDev() {}
virtual GBool interpretType3Chars() { return gFalse; }
virtual GBool needNonText() { return gTrue; }
// 0,0 is top left corner
virtual GBool upsideDown() { return gFalse; }
virtual GBool useDrawChar() { return gFalse; }
//----- image drawing
virtual void drawImage(GfxState *state, Object *ref, Stream *str,
int width, int height, GfxImageColorMap *colorMap,
GBool interpolate, int *maskColors, GBool inlineImg);
// virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
// int width, int height,
// GfxImageColorMap *colorMap,
// GBool interpolate,
// Stream *maskStr, int maskWidth, int maskHeight,
// GBool maskInvert, GBool maskInterpolate);
// virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
// int width, int height,
// GfxImageColorMap *colorMap,
// GBool interpolate,
// Stream *maskStr,
// int maskWidth, int maskHeight,
// GfxImageColorMap *maskColorMap,
// GBool maskInterpolate);
};
//---------------------------------------------------------
// drawImage
//---------------------------------------------------------
void QImageOutputDev::drawImage(GfxState* state, Object* , Stream* str,
int width, int height, GfxImageColorMap* colorMap, GBool, int*, GBool)
{
if (colorMap->getNumPixelComps() == 1 && colorMap->getBits() == 1) {
double* ctm = state->getCTM();
double xmag = width/ctm[0];
double ymag = height/ctm[3];
double xoff = (ctm[2]+ctm[4]) * xmag;
int ph = state->getPageHeight() * ymag;
int yoff = int(ph - (ctm[3]+ctm[5]) * ymag);
//yoff needs to be > 0
if(yoff < 0)
yoff = 0;
printf("Image %4d %4d at %5f %4d mag %f %f\n",
width, height, xoff, yoff, xmag, ymag);
bool invertBits = colorMap->getDecodeLow(0) == 0.0;
if (image->isNull()) {
#if 0
int pw = state->getPageWidth() * xmag;
pw = ((pw+31)/32) * 32;
int ph = state->getPageHeight() * ymag;
#endif
int pw = width;
int ph = height;
pw = ((pw+31)/32) * 32;
*image = QImage(pw, ph, QImage::Format_MonoLSB);
QVector<QRgb> ct(2);
ct[0] = qRgb(255, 255, 255);
ct[1] = qRgb(0, 0, 0);
image->setColorTable(ct);
image->fill(0);
ny = yoff;
printf(" bytes %d\n", (pw * ph) / 8);
}
// copy the stream
str->reset(); // initialize stream
if (yoff != ny)
printf(" ***next image does not fit, gap %d\n", yoff - ny);
yoff = ny;
int stride = (width + 7) / 8;
// uchar mask = 0xff << (stride * 8 - width);
int qstride = image->bytesPerLine();
uchar* p = image->bits();
printf("Image stride %d qstride %d yoff %d bytes %d\n",
stride, qstride, yoff, height * stride);
for (int y = 0; y < height; ++y) {
p = image->scanLine(y + yoff);
for (int x = 0; x < stride; ++x) {
static unsigned char invert[16] = {
0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
};
uchar c = str->getChar();
if (invertBits)
c = ~c;
*p++ = (invert[c & 15] << 4) | invert[(c >> 4) & 15];
}
//TODO p[-1] &= ~mask;
}
str->close();
ny += height;
}
else {
printf("Color Image ================%d %d - %d %d\n", width, height,
colorMap->getNumPixelComps(), colorMap->getBits());
#if 0
fprintf(f, "P6\n");
fprintf(f, "%d %d\n", width, height);
fprintf(f, "255\n");
// initialize stream
ImageStream* imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), colorMap->getBits());
imgStr->reset();
// for each line...
for (int y = 0; y < height; ++y) {
// write the line
Guchar *p = imgStr->getLine();
for (int x = 0; x < width; ++x) {
GfxRGB rgb;
colorMap->getRGB(p, &rgb);
fputc(colToByte(rgb.r), f);
fputc(colToByte(rgb.g), f);
fputc(colToByte(rgb.b), f);
p += colorMap->getNumPixelComps();
}
}
#endif
}
}
namespace Ms {
int Pdf::references;
static fz_context* ctx;
//---------------------------------------------------------
// numPages
@ -35,7 +184,7 @@ static fz_context* ctx;
int Pdf::numPages() const
{
return fz_count_pages(doc);
return _doc->getNumPages();
}
//---------------------------------------------------------
@ -44,10 +193,10 @@ int Pdf::numPages() const
Pdf::Pdf()
{
if (references == 0)
ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED); // 256MB cache
imgOut = 0;
globalParams = new GlobalParams();
++references;
doc = 0;
}
//---------------------------------------------------------
@ -56,15 +205,8 @@ Pdf::Pdf()
bool Pdf::open(const QString& path)
{
char* name = path.toLatin1().data();
fz_try(ctx) {
doc = fz_open_document(ctx, name);
}
fz_catch(ctx) {
fz_close_document(doc);
doc = 0;
return false;
}
GooString* fileName = new GooString(qPrintable(path));
_doc = new PDFDoc(fileName, 0, 0);
return true;
}
@ -74,14 +216,11 @@ bool Pdf::open(const QString& path)
Pdf::~Pdf()
{
if (doc)
fz_close_document(doc);
doc = 0;
if(_doc)
delete(_doc);
if(globalParams)
delete(globalParams);
--references;
if (references == 0) {
fz_free_context(ctx);
ctx = 0;
}
}
//---------------------------------------------------------
@ -90,7 +229,29 @@ Pdf::~Pdf()
QImage Pdf::page(int i)
{
fz_page* page = fz_load_page(doc, i);
if (imgOut == 0)
imgOut = new QImageOutputDev();
QImage image;
imgOut->setImage(&image);
// useMediaBox, crop, printing
_doc->displayPage(imgOut, i+1, 1200.0, 1200.0, 0, gTrue, gFalse, gFalse);
/*PDFRectangle r(0,0,_doc->getPageMediaHeight(i+1), _doc->getPageCropWidth(i+1));
GfxState *state = new GfxState(1200.0, 1200.0, &r, 0, imgOut->upsideDown());
//Stream *str = Gfx::buildImageStream();
GfxColorSpace *colorSpace = new GfxDeviceGrayColorSpace();
//Dict *dict = str->getDict();
//Object obj1, obj2;
// get size
//dict->lookup("Width", &obj1);
//dict->lookup("Height", &obj2);
Object obj;
obj.initNull();
//_doc->getDocInfo(&obj);
GfxImageColorMap *colorMap = new GfxImageColorMap(1, &obj, colorSpace);
imgOut->drawImage(state, NULL, _doc->getBaseStream(), 50, 50, colorMap, gTrue, NULL, gTrue);*/
/*fz_page* page = fz_load_page(ctx, doc, i);
if (page == 0) {
printf("cannot load page %d\n", i);
return QImage();
@ -99,7 +260,7 @@ QImage Pdf::page(int i)
const float zoom = resolution / 72.0;
fz_rect bounds;
fz_bound_page(doc, page, &bounds);
fz_bound_page(ctx, page, &bounds);
fz_matrix ctm;
fz_pre_scale(fz_rotate(&ctm, 0.0), zoom, zoom);
@ -108,12 +269,12 @@ QImage Pdf::page(int i)
fz_rect tbounds;
tbounds = bounds;
fz_round_rect(&ibounds, fz_transform_rect(&tbounds, &ctm));
fz_pixmap* pix = fz_new_pixmap_with_bbox(ctx, fz_device_gray, &ibounds);
fz_pixmap* pix = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), &ibounds);
fz_clear_pixmap_with_value(ctx, pix, 255);
fz_device* dev = fz_new_draw_device(ctx, pix);
fz_run_page(doc, page, dev, &ctm, NULL);
fz_free_device(dev);
fz_run_page(ctx, page, dev, &ctm, NULL);
fz_drop_device(ctx,dev);
dev = NULL;
int w = fz_pixmap_width(ctx, pix);
@ -156,7 +317,7 @@ QImage Pdf::page(int i)
data |= 0x80;
}
}
fz_drop_pixmap(ctx, pix);
fz_drop_pixmap(ctx, pix);*/
return image;
}
}

View file

@ -21,7 +21,8 @@
#ifndef __PDF_H__
#define __PDF_H__
typedef struct fz_document_s fz_document;
class PDFDoc;
class QImageOutputDev;
namespace Ms {
@ -31,8 +32,8 @@ namespace Ms {
class Pdf {
static int references;
fz_document* doc;
PDFDoc* _doc;
QImageOutputDev* imgOut;
public:
Pdf();
bool open(const QString& path);

5
thirdparty/poppler/AUTHORS vendored Normal file
View file

@ -0,0 +1,5 @@
xpdf is written by Derek Noonburg <derekn@foolabs.com>
libpoppler is a fork of xpdf-3.00
Current Maintainer: Albert Astals Cid <aacid@kde.org>

132
thirdparty/poppler/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,132 @@
add_library(poppler STATIC
poppler/Annot.cc
poppler/Array.cc
poppler/BuiltinFont.cc
poppler/BuiltinFontTables.cc
poppler/CachedFile.cc
#poppler/CairoFontEngine.cc
#poppler/CairoOutputDev.cc
#poppler/CairoRescaleBox.cc
poppler/Catalog.cc
poppler/CharCodeToUnicode.cc
poppler/CMap.cc
#poppler/CurlCachedFile.cc
#poppler/CurlPDFDocBuilder.cc
poppler/DateInfo.cc
#poppler/DCTStream.cc
poppler/Decrypt.cc
poppler/Dict.cc
poppler/Error.cc
poppler/FileSpec.cc
#poppler/FlateStream.cc
poppler/FontEncodingTables.cc
poppler/Form.cc
poppler/FontInfo.cc
poppler/Function.cc
poppler/Gfx.cc
poppler/GfxFont.cc
poppler/GfxState.cc
poppler/GlobalParams.cc
#poppler/GlobalParamsWin.cc
poppler/Hints.cc
poppler/JArithmeticDecoder.cc
poppler/JBIG2Stream.cc
#poppler/JPEG2000Stream.cc
poppler/JPXStream.cc
poppler/Lexer.cc
poppler/Linearization.cc
poppler/Link.cc
poppler/LocalPDFDocBuilder.cc
poppler/MarkedContentOutputDev.cc
poppler/Movie.cc
poppler/NameToCharCode.cc
poppler/Object.cc
poppler/OptionalContent.cc
poppler/Outline.cc
poppler/OutputDev.cc
poppler/Page.cc
poppler/PageLabelInfo.h
poppler/PageLabelInfo.cc
poppler/PageTransition.cc
poppler/Parser.cc
poppler/PDFDoc.cc
poppler/PDFDocEncoding.cc
poppler/PDFDocFactory.cc
poppler/PopplerCache.cc
poppler/PreScanOutputDev.cc
poppler/ProfileData.cc
poppler/PSOutputDev.cc
poppler/PSTokenizer.cc
poppler/Rendition.cc
poppler/SecurityHandler.cc
poppler/Sound.cc
poppler/SplashOutputDev.cc
poppler/StdinCachedFile.cc
poppler/StdinPDFDocBuilder.cc
poppler/Stream.cc
poppler/strtok_r.cpp
poppler/StructElement.cc
poppler/StructTreeRoot.cc
poppler/TextOutputDev.cc
poppler/UnicodeMap.cc
poppler/UnicodeTypeTable.cc
poppler/UTF.cc
poppler/ViewerPreferences.cc
poppler/XRef.cc
goo/FixedPoint.cc
goo/gfile.cc
goo/gmem.cc
goo/gmempp.cc
goo/GooHash.cc
goo/GooList.cc
goo/GooString.cc
goo/GooTimer.cc
goo/grandom.cc
goo/gstrtod.cc
goo/ImgWriter.cc
goo/JpegWriter.cc
goo/NetPBMWriter.cc
#goo/PNGWriter.cc
goo/TiffWriter.cc
fofi/FoFiBase.cc
fofi/FoFiEncodings.cc
fofi/FoFiIdentifier.cc
fofi/FoFiTrueType.cc
fofi/FoFiType1.cc
fofi/FoFiType1C.cc
splash/Splash.cc
splash/SplashBitmap.cc
splash/SplashClip.cc
splash/SplashFont.cc
splash/SplashFontEngine.cc
splash/SplashFontFile.cc
splash/SplashFontFileID.cc
splash/SplashFTFont.cc
splash/SplashFTFontEngine.cc
splash/SplashFTFontFile.cc
splash/SplashPath.cc
splash/SplashPattern.cc
splash/SplashScreen.cc
splash/SplashState.cc
splash/SplashT1Font.cc
splash/SplashT1FontEngine.cc
splash/SplashT1FontFile.cc
splash/SplashXPath.cc
splash/SplashXPathScanner.cc
)
set_target_properties(poppler
PROPERTIES
COMPILE_FLAGS
"-O2 -Wno-write-strings -ansi -Wnon-virtual-dtor -Woverloaded-virtual"
)
include_directories(
${PROJECT_SOURCE_DIR}/thirdparty/poppler/goo
${PROJECT_SOURCE_DIR}/thirdparty/poppler/fofi
${PROJECT_SOURCE_DIR}/thirdparty/poppler/splash
)

339
thirdparty/poppler/COPYING vendored Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

59324
thirdparty/poppler/ChangeLog vendored Normal file

File diff suppressed because it is too large Load diff

236
thirdparty/poppler/INSTALL vendored Normal file
View file

@ -0,0 +1,236 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PREFIX', the package will
use PREFIX as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

2460
thirdparty/poppler/NEWS vendored Normal file

File diff suppressed because it is too large Load diff

39
thirdparty/poppler/README vendored Normal file
View file

@ -0,0 +1,39 @@
This is poppler, a PDF rendering library.
Poppler is a fork of the xpdf PDF viewer developed by Derek Noonburg
of Glyph and Cog, LLC. The purpose of forking xpdf is twofold.
First, we want to provide PDF rendering functionality as a shared
library, to centralize the maintenance effort. Today a number of
applications incorporate the xpdf code base, and whenever a security
issue is discovered, all these applications exchange patches and put
out new releases. In turn, all distributions must package and release
new version of these xpdf based viewers. It's safe to say that
there's a lot of duplicated effort with the current situation. Even if
poppler in the short term introduces yet another xpdf derived code
base to the world, we hope that over time these applications will
adopt poppler. After all, we only need one application to use poppler
to break even.
Second, we would like to move libpoppler forward in a number of areas
that don't fit within the goals of xpdf. By design, xpdf depends on
very few libraries and runs a wide range of X based platforms. This
is a strong feature and reasonable design goal. However, with poppler
we would like to replace parts of xpdf that are now available as
standard components of modern Unix desktop environments. One such
example is fontconfig, which solves the problem of matching and
locating fonts on the system, in a standardized and well understood
way. Another example is cairo, which provides high quality 2D
rendering. See the file TODO for a list of planned changes.
Please note that xpdf, and thus poppler, is licensed under the GPL,
not the LGPL. Consequently, any application using poppler must also
be licensed under the GPL. If you want to incorporate Xpdf based PDF
rendering in a closed source product, please contact Glyph & Cog
(www.glyphandcog.com) for commercial licensing options. Note that
this only allows you to use xpdf in a closed source product,
not poppler itself.
Kristian Høgsberg, Feb. 27, 2005
See the README-XPDF for the original xpdf-3.03 README.

423
thirdparty/poppler/README-XPDF vendored Normal file
View file

@ -0,0 +1,423 @@
Xpdf
====
version 3.03
2011-aug-15
The Xpdf software and documentation are
copyright 1996-2011 Glyph & Cog, LLC.
Email: derekn@foolabs.com
WWW: http://www.foolabs.com/xpdf/
The PDF data structures, operators, and specification are
copyright 1985-2006 Adobe Systems Inc.
What is Xpdf?
-------------
Xpdf is an open source viewer for Portable Document Format (PDF)
files. (These are also sometimes also called 'Acrobat' files, from
the name of Adobe's PDF software.) The Xpdf project also includes a
PDF text extractor, PDF-to-PostScript converter, and various other
utilities.
Xpdf runs under the X Window System on UNIX, VMS, and OS/2. The non-X
components (pdftops, pdftotext, etc.) also run on Windows and Mac OSX
systems and should run on pretty much any system with a decent C++
compiler. Xpdf will run on 32-bit and 64-bit machines.
License & Distribution
----------------------
Xpdf is licensed under the GNU General Pulbic License (GPL), version 2
or 3. This means that you can distribute derivatives of Xpdf under
any of the following:
- GPL v2 only
- GPL v3 only
- GPL v2 or v3
The Xpdf source package includes the text of both GPL versions:
COPYING for GPL v2, COPYING3 for GPL v3.
Please note that Xpdf is NOT licensed under "any later version" of the
GPL, as I have no idea what those versions will look like.
If you are redistributing unmodified copies of Xpdf (or any of the
Xpdf tools) in binary form, you need to include all of the
documentation: README, man pages (or help files), COPYING, and
COPYING3.
If you want to incorporate the Xpdf source code into another program
(or create a modified version of Xpdf), and you are distributing that
program, you have two options: release your program under the GPL (v2
and/or v3), or purchase a commercial Xpdf source license.
If you're interested in commercial licensing, please see the Glyph &
Cog web site:
http://www.glyphandcog.com/
Compatibility
-------------
Xpdf is developed and tested on Linux.
In addition, it has been compiled by others on Solaris, AIX, HP-UX,
Digital Unix, Irix, and numerous other Unix implementations, as well
as VMS and OS/2. It should work on pretty much any system which runs
X11 and has Unix-like libraries. You'll need ANSI C++ and C compilers
to compile it.
The non-X components of Xpdf (pdftops, pdftotext, pdfinfo, pdffonts,
pdfdetach, pdftoppm, and pdfimages) can also be compiled on Windows
and Mac OSX systems. See the Xpdf web page for details.
If you compile Xpdf for a system not listed on the web page, please
let me know. If you're willing to make your binary available by ftp
or on the web, I'll be happy to add a link from the Xpdf web page. I
have decided not to host any binaries I didn't compile myself (for
disk space and support reasons).
If you can't get Xpdf to compile on your system, send me email and
I'll try to help.
Xpdf has been ported to the Acorn, Amiga, BeOS, and EPOC. See the
Xpdf web page for links.
Getting Xpdf
------------
The latest version is available from:
http://www.foolabs.com/xpdf/
or:
ftp://ftp.foolabs.com/pub/xpdf/
Source code and several precompiled executables are available.
Announcements of new versions are posted to comp.text.pdf and emailed
to a list of people. If you'd like to receive email notification of
new versions, just let me know.
Running Xpdf
------------
To run xpdf, simply type:
xpdf file.pdf
To generate a PostScript file, hit the "print" button in xpdf, or run
pdftops:
pdftops file.pdf
To generate a plain text file, run pdftotext:
pdftotext file.pdf
There are five additional utilities (which are fully described in
their man pages):
pdfinfo -- dumps a PDF file's Info dictionary (plus some other
useful information)
pdffonts -- lists the fonts used in a PDF file along with various
information for each font
pdfdetach -- lists or extracts embedded files (attachments) from a
PDF file
pdftoppm -- converts a PDF file to a series of PPM/PGM/PBM-format
bitmaps
pdfimages -- extracts the images from a PDF file
Command line options and many other details are described in the man
pages (xpdf(1), etc.) and the VMS help files (xpdf.hlp, etc.).
All of these utilities read an optional configuration file: see the
xpdfrc(5) man page.
Upgrading from Xpdf 3.02 (and earlier)
--------------------------------------
The font configuration system has been changed. Previous versions
used mostly separate commands to configure fonts for display and for
PostScript output. As of 3.03, configuration options that make sense
for both display and PS output have been unified.
The following xpdfrc commands have been removed:
* displayFontT1, displayFontTT: replaced with fontFile
* displayNamedCIDFontT1, displayNamedCIDFontTT: replaced with fontFile
* displayCIDFontT1, displayCIDFontTT: replaced with fontFileCC
* psFont: replaced with psResidentFont
* psNamedFont16: replaced with psResidentFont16
* psFont16: replaced with psResidentFontCC
See the xpdfrc(5) man page for more information on the new commands.
Pdftops will now embed external 16-bit fonts (configured with the
fontFileCC command) when the PDF file refers to a non-embedded font.
It does not do any subsetting (yet), so the resulting PS files will be
large.
Compiling Xpdf
--------------
See the separate file, INSTALL.
Bugs
----
If you find a bug in Xpdf, i.e., if it prints an error message,
crashes, or incorrectly displays a document, and you don't see that
bug listed here, please send me email, with a pointer (URL, ftp site,
etc.) to the PDF file.
Acknowledgments
---------------
Thanks to:
* Patrick Voigt for help with the remote server code.
* Patrick Moreau, Martin P.J. Zinser, and David Mathog for the VMS
port.
* David Boldt and Rick Rodgers for sample man pages.
* Brendan Miller for the icon idea.
* Olly Betts for help testing pdftotext.
* Peter Ganten for the OS/2 port.
* Michael Richmond for the Win32 port of pdftops and pdftotext and the
xpdf/cygwin/XFree86 build instructions.
* Frank M. Siegert for improvements in the PostScript code.
* Leo Smiers for the decryption patches.
* Rainer Menzner for creating t1lib, and for helping me adapt it to
xpdf.
* Pine Tree Systems A/S for funding the OPI and EPS support in
pdftops.
* Easy Software Products for funding several improvements to the
PostScript output code.
* Tom Kacvinsky for help with FreeType and for being my interface to
the FreeType team.
* Theppitak Karoonboonyanan for help with Thai support.
* Leonard Rosenthol for help and contributions on a bunch of things.
* Alexandros Diamantidis and Maria Adaloglou for help with Greek
support.
* Lawrence Lai for help with the CJK Unicode maps.
Various people have contributed modifications made for use by the
pdftex project:
* Han The Thanh
* Martin Schröder of ArtCom GmbH
References
----------
Adobe Systems Inc., _PDF Reference, sixth edition: Adobe Portable
Document Format version 1.7_.
http://www.adobe.com/devnet/pdf/pdf_reference.html
[The manual for PDF version 1.7.]
Adobe Systems Inc., "Errata for the PDF Reference, sixth edition,
version 1.7", October 16, 2006.
http://www.adobe.com/devnet/pdf/pdf_reference.html
[The errata for the PDF 1.7 spec.]
Adobe Systems Inc., _PostScript Language Reference_, 3rd ed.
Addison-Wesley, 1999, ISBN 0-201-37922-8.
[The official PostScript manual.]
Adobe Systems, Inc., _The Type 42 Font Format Specification_,
Adobe Developer Support Technical Specification #5012. 1998.
http://partners.adobe.com/asn/developer/pdfs/tn/5012.Type42_Spec.pdf
[Type 42 is the format used to embed TrueType fonts in PostScript
files.]
Adobe Systems, Inc., _Adobe CMap and CIDFont Files Specification_,
Adobe Developer Support Technical Specification #5014. 1995.
http://www.adobe.com/supportservice/devrelations/PDFS/TN/5014.CIDFont_Spec.pdf
[CMap file format needed for Japanese and Chinese font support.]
Adobe Systems, Inc., _Adobe-Japan1-4 Character Collection for
CID-Keyed Fonts_, Adobe Developer Support Technical Note #5078.
2000.
http://partners.adobe.com/asn/developer/PDFS/TN/5078.CID_Glyph.pdf
[The Adobe Japanese character set.]
Adobe Systems, Inc., _Adobe-GB1-4 Character Collection for
CID-Keyed Fonts_, Adobe Developer Support Technical Note #5079.
2000.
http://partners.adobe.com/asn/developer/pdfs/tn/5079.Adobe-GB1-4.pdf
[The Adobe Chinese GB (simplified) character set.]
Adobe Systems, Inc., _Adobe-CNS1-3 Character Collection for
CID-Keyed Fonts_, Adobe Developer Support Technical Note #5080.
2000.
http://partners.adobe.com/asn/developer/PDFS/TN/5080.CNS_CharColl.pdf
[The Adobe Chinese CNS (traditional) character set.]
Adobe Systems Inc., _Supporting the DCT Filters in PostScript Level
2_, Adobe Developer Support Technical Note #5116. 1992.
http://www.adobe.com/supportservice/devrelations/PDFS/TN/5116.PS2_DCT.PDF
[Description of the DCTDecode filter parameters.]
Adobe Systems Inc., _Open Prepress Interface (OPI) Specification -
Version 2.0_, Adobe Developer Support Technical Note #5660. 2000.
http://partners.adobe.com/asn/developer/PDFS/TN/5660.OPI_2.0.pdf
Adobe Systems Inc., CMap files.
ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/
[The actual CMap files for the 16-bit CJK encodings.]
Adobe Systems Inc., Unicode glyph lists.
http://partners.adobe.com/asn/developer/type/unicodegn.html
http://partners.adobe.com/asn/developer/type/glyphlist.txt
http://partners.adobe.com/asn/developer/type/corporateuse.txt
http://partners.adobe.com/asn/developer/type/zapfdingbats.txt
[Mappings between character names to Unicode.]
Adobe Systems Inc., OpenType Specification v. 1.4.
http://partners.adobe.com/public/developer/opentype/index_spec.html
[The OpenType font format spec.]
Aldus Corp., _OPI: Open Prepress Interface Specification 1.3_. 1993.
http://partners.adobe.com/asn/developer/PDFS/TN/OPI_13.pdf
Anonymous, RC4 source code.
ftp://ftp.ox.ac.uk/pub/crypto/misc/rc4.tar.gz
ftp://idea.sec.dsi.unimi.it/pub/crypt/code/rc4.tar.gz
[This is the algorithm used to encrypt PDF files.]
T. Boutell, et al., "PNG (Portable Network Graphics) Specification,
Version 1.0". RFC 2083.
[PDF uses the PNG filter algorithms.]
CCITT, "Information Technology - Digital Compression and Coding of
Continuous-tone Still Images - Requirements and Guidelines", CCITT
Recommendation T.81.
http://www.w3.org/Graphics/JPEG/
[The official JPEG spec.]
A. Chernov, "Registration of a Cyrillic Character Set". RFC 1489.
[Documentation for the KOI8-R Cyrillic encoding.]
Roman Czyborra, "The ISO 8859 Alphabet Soup".
http://czyborra.com/charsets/iso8859.html
[Documentation on the various ISO 859 encodings.]
L. Peter Deutsch, "ZLIB Compressed Data Format Specification version
3.3". RFC 1950.
[Information on the general format used in FlateDecode streams.]
L. Peter Deutsch, "DEFLATE Compressed Data Format Specification
version 1.3". RFC 1951.
[The definition of the compression algorithm used in FlateDecode
streams.]
Morris Dworkin, "Recommendation for Block Cipher Modes of Operation",
National Institute of Standards, NIST Special Publication 800-38A,
2001.
[The cipher block chaining (CBC) mode used with AES in PDF files.]
Federal Information Processing Standards Publication 197 (FIPS PUBS
197), "Advanced Encryption Standard (AES)", November 26, 2001.
[AES encryption, used in PDF 1.6.]
Jim Flowers, "X Logical Font Description Conventions", Version 1.5, X
Consortium Standard, X Version 11, Release 6.1.
ftp://ftp.x.org/pub/R6.1/xc/doc/hardcopy/XLFD/xlfd.PS.Z
[The official specification of X font descriptors, including font
transformation matrices.]
Foley, van Dam, Feiner, and Hughes, _Computer Graphics: Principles and
Practice_, 2nd ed. Addison-Wesley, 1990, ISBN 0-201-12110-7.
[Colorspace conversion functions, Bezier spline math.]
Robert L. Hummel, _Programmer's Technical Reference: Data and Fax
Communications_. Ziff-Davis Press, 1993, ISBN 1-56276-077-7.
[CCITT Group 3 and 4 fax decoding.]
ISO/IEC, _Information technology -- Lossy/lossless coding of bi-level
images_. ISO/IEC 14492, First edition (2001-12-15).
http://webstore.ansi.org/
[The official JBIG2 standard. The final draft of this spec is
available from http://www.jpeg.org/jbighomepage.html.]
ISO/IEC, _Information technology -- JPEG 2000 image coding system --
Part 1: Core coding system_. ISO/IEC 15444-1, First edition
(2000-12-15).
http://webstore.ansi.org/
[The official JPEG 2000 standard. The final committee draft of this
spec is available from http://www.jpeg.org/JPEG2000.html, but there
were changes made to the bitstream format between that draft and the
published spec.]
ITU, "Standardization of Group 3 facsimile terminals for document
transmission", ITU-T Recommendation T.4, 1999.
ITU, "Facsimile coding schemes and coding control functions for Group 4
facsimile apparatus", ITU-T Recommendation T.6, 1993.
http://www.itu.int/
[The official Group 3 and 4 fax standards - used by the CCITTFaxDecode
stream, as well as the JBIG2Decode stream.]
B. Kaliski, "PKCS #5: Password-Based Cryptography Specification,
Version 2.0". RFC 2898.
[Defines the padding scheme used with AES encryption in PDF files.]
Christoph Loeffler, Adriaan Ligtenberg, George S. Moschytz, "Practical
Fast 1-D DCT Algorithms with 11 Multiplications". IEEE Intl. Conf. on
Acoustics, Speech & Signal Processing, 1989, 988-991.
[The fast IDCT algorithm used in the DCTDecode filter.]
Microsoft, _TrueType 1.0 Font Files_, rev. 1.66. 1995.
http://www.microsoft.com/typography/tt/tt.htm
[The TrueType font spec (in MS Word format, naturally).]
V. Ostromoukhov, R.D. Hersch, "Stochastic Clustered-Dot Dithering",
Conf. Color Imaging: Device-Independent Color, Color Hardcopy, and
Graphic Arts IV, 1999, SPIE Vol. 3648, 496-505.
http://diwww.epfl.ch/w3lsp/publications/colour/scd.html
[The stochastic dithering algorithm used in Xpdf.]
P. Peterlin, "ISO 8859-2 (Latin 2) Resources".
http://sizif.mf.uni-lj.si/linux/cee/iso8859-2.html
[This is a web page with all sorts of useful Latin-2 character set and
font information.]
Charles Poynton, "Color FAQ".
http://www.inforamp.net/~poynton/ColorFAQ.html
[The mapping from the CIE 1931 (XYZ) color space to RGB.]
R. Rivest, "The MD5 Message-Digest Algorithm". RFC 1321.
[MD5 is used in PDF document encryption.]
Thai Industrial Standard, "Standard for Thai Character Codes for
Computers", TIS-620-2533 (1990).
http://www.nectec.or.th/it-standards/std620/std620.htm
[The TIS-620 Thai encoding.]
Unicode Consortium, "Unicode Home Page".
http://www.unicode.org/
[Online copy of the Unicode spec.]
W3C Recommendation, "PNG (Portable Network Graphics) Specification
Version 1.0".
http://www.w3.org/Graphics/PNG/
[Defines the PNG image predictor.]
Gregory K. Wallace, "The JPEG Still Picture Compression Standard".
ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz
[Good description of the JPEG standard. Also published in CACM, April
1991, and submitted to IEEE Transactions on Consumer Electronics.]
F. Yergeau, "UTF-8, a transformation format of ISO 10646". RFC 2279.
[A commonly used Unicode encoding.]

277
thirdparty/poppler/config.h vendored Normal file
View file

@ -0,0 +1,277 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* Build against libcurl. */
/* #undef ENABLE_LIBCURL */
/* Use libjpeg instead of builtin jpeg decoder. */
/* #undef ENABLE_LIBJPEG */
/* Use libopenjpeg instead of builtin jpeg2000 decoder. */
#define ENABLE_LIBOPENJPEG 1
/* Build against libpng. */
//#define ENABLE_LIBPNG 1
/* Build against libtiff. */
/* #undef ENABLE_LIBTIFF */
/* Do not hardcode the library location */
/* #undef ENABLE_RELOCATABLE */
/* Use zlib instead of builtin zlib decoder. */
/* #undef ENABLE_ZLIB */
/* Use cairo for rendering. */
/* #undef HAVE_CAIRO */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
/* #undef HAVE_FCNTL_H */
/* Have FreeType2 include files */
#define HAVE_FREETYPE_H 1
/* Define to 1 if you have the `fseek64' function. */
/* #undef HAVE_FSEEK64 */
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#define HAVE_FSEEKO 1
/* Define to 1 if you have the `ftell64' function. */
/* #undef HAVE_FTELL64 */
/* Defines if gettimeofday is available on your system */
#define HAVE_GETTIMEOFDAY 1
/* Defines if gmtime_r is available on your system */
//#define HAVE_GMTIME_R 1
/* Define if you have the iconv() function and it works. */
#define HAVE_ICONV 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `tiff' library (-ltiff). */
/* #undef HAVE_LIBTIFF */
/* Define to 1 if you have the `z' library (-lz). */
/* #undef HAVE_LIBZ */
/* Defines if localtime_r is available on your system */
#define HAVE_LOCALTIME_R 1
/* Define to 1 if you have the `lseek64' function. */
/* #undef HAVE_LSEEK64 */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mkstemp' function. */
#define HAVE_MKSTEMP 1
/* Define to 1 if you have the `mkstemps' function. */
#define HAVE_MKSTEMPS 1
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the <openjpeg.h> header file. */
/* #undef HAVE_OPENJPEG_H */
/* Define to 1 if you have the `popen' function. */
#define HAVE_POPEN 1
/* Define to 1 if you have the `pread64' function. */
/* #undef HAVE_PREAD64 */
/* Define if you have POSIX threads libraries and header files. */
#define HAVE_PTHREAD 1
/* Have PTHREAD_PRIO_INHERIT. */
#define HAVE_PTHREAD_PRIO_INHERIT 1
/* Defines if rand_r is available on your system */
//#define HAVE_RAND_R 1
/* Use splash for rendering. */
#define HAVE_SPLASH 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strcat_s' function. */
/* #undef HAVE_STRCAT_S */
/* Define to 1 if you have the `strcpy_s' function. */
/* #undef HAVE_STRCPY_S */
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/mman.h> header file. */
/* #undef HAVE_SYS_MMAN_H */
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <tiffio.h> header file. */
/* #undef HAVE_TIFFIO_H */
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <zlib.h> header file. */
/* #undef HAVE_ZLIB_H */
/* Define as const if the declaration of iconv() needs const. */
#define ICONV_CONST
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Enable multithreading support. */
#define MULTITHREADED 1
/* Generate OPI comments in PS output. */
#define OPI_SUPPORT 1
/* Name of package */
#define PACKAGE "poppler"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "https://bugs.freedesktop.org/enter_bug.cgi?product=poppler"
/* Define to the full name of this package. */
#define PACKAGE_NAME "poppler"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "poppler 0.38.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "poppler"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.38.0"
/* Poppler data dir */
#define POPPLER_DATADIR "/usr/share/poppler"
/* Support for curl based doc builder is compiled in. */
/* #undef POPPLER_HAS_CURL_SUPPORT */
/* Defines the poppler version */
#define POPPLER_VERSION "0.38.0"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
/* #undef PTHREAD_CREATE_JOINABLE */
/* Include support for CMYK rasterization */
/* #undef SPLASH_CMYK */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Enable word list support. */
#define TEXTOUT_WORD_LIST 1
/* Defines if use cms */
//#define USE_CMS 1
/* Use fixed point arithmetic in the Splash backend */
/* #undef USE_FIXEDPOINT */
/* Use single precision arithmetic in the Splash backend */
/* #undef USE_FLOAT */
/* Defines if use lcms1 */
/* #undef USE_LCMS1 */
/* Defined if using openjpeg1 */
#define USE_OPENJPEG1 1
/* Defined if using openjpeg2 */
/* #undef USE_OPENJPEG2 */
/* Version number of package */
#define VERSION "0.40.0"
/* Use fontconfig font configuration backend */
//#define WITH_FONTCONFIGURATION_FONTCONFIG 1
/* Use win32 font configuration backend */
/* #undef WITH_FONTCONFIGURATION_WIN32 */
/* OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag. */
#define WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG 1
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
/*
* jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system
* headers and I'm too lazy to write a configure test as long as only
* unixware is related
*/
#ifdef _UNIXWARE
#define HAVE_BOOLEAN
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
/* #undef _LARGEFILE_SOURCE */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */

201
thirdparty/poppler/fofi/FoFiBase.cc vendored Normal file
View file

@ -0,0 +1,201 @@
//========================================================================
//
// FoFiBase.cc
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2008 Ed Avis <eda@waniasset.com>
// Copyright (C) 2011 Jim Meyering <jim@meyering.net>
//
// 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
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdio.h>
#include <limits.h>
#include "goo/gmem.h"
#include "poppler/Error.h"
#include "FoFiBase.h"
//------------------------------------------------------------------------
// FoFiBase
//------------------------------------------------------------------------
FoFiBase::FoFiBase(char *fileA, int lenA, GBool freeFileDataA) {
fileData = file = (Guchar *)fileA;
len = lenA;
freeFileData = freeFileDataA;
}
FoFiBase::~FoFiBase() {
if (freeFileData) {
gfree(fileData);
}
}
char *FoFiBase::readFile(char *fileName, int *fileLen) {
FILE *f;
char *buf;
int n;
if (!(f = fopen(fileName, "rb"))) {
error(errIO, -1, "Cannot open '{0:s}'", fileName);
return NULL;
}
if (fseek(f, 0, SEEK_END) != 0) {
error(errIO, -1, "Cannot seek to end of '{0:s}'", fileName);
fclose(f);
return NULL;
}
n = (int)ftell(f);
if (n < 0) {
error(errIO, -1, "Cannot determine length of '{0:s}'", fileName);
fclose(f);
return NULL;
}
if (fseek(f, 0, SEEK_SET) != 0) {
error(errIO, -1, "Cannot seek to start of '{0:s}'", fileName);
fclose(f);
return NULL;
}
buf = (char *)gmalloc(n);
if ((int)fread(buf, 1, n, f) != n) {
gfree(buf);
fclose(f);
return NULL;
}
fclose(f);
*fileLen = n;
return buf;
}
int FoFiBase::getS8(int pos, GBool *ok) {
int x;
if (pos < 0 || pos >= len) {
*ok = gFalse;
return 0;
}
x = file[pos];
if (x & 0x80) {
x |= ~0xff;
}
return x;
}
int FoFiBase::getU8(int pos, GBool *ok) {
if (pos < 0 || pos >= len) {
*ok = gFalse;
return 0;
}
return file[pos];
}
int FoFiBase::getS16BE(int pos, GBool *ok) {
int x;
if (pos < 0 || pos+1 >= len || pos > INT_MAX - 1) {
*ok = gFalse;
return 0;
}
x = file[pos];
x = (x << 8) + file[pos+1];
if (x & 0x8000) {
x |= ~0xffff;
}
return x;
}
int FoFiBase::getU16BE(int pos, GBool *ok) {
int x;
if (pos < 0 || pos+1 >= len || pos > INT_MAX - 1) {
*ok = gFalse;
return 0;
}
x = file[pos];
x = (x << 8) + file[pos+1];
return x;
}
int FoFiBase::getS32BE(int pos, GBool *ok) {
int x;
if (pos < 0 || pos+3 >= len || pos > INT_MAX - 3) {
*ok = gFalse;
return 0;
}
x = file[pos];
x = (x << 8) + file[pos+1];
x = (x << 8) + file[pos+2];
x = (x << 8) + file[pos+3];
if (x & 0x80000000) {
x |= ~0xffffffff;
}
return x;
}
Guint FoFiBase::getU32BE(int pos, GBool *ok) {
Guint x;
if (pos < 0 || pos+3 >= len || pos > INT_MAX - 3) {
*ok = gFalse;
return 0;
}
x = file[pos];
x = (x << 8) + file[pos+1];
x = (x << 8) + file[pos+2];
x = (x << 8) + file[pos+3];
return x;
}
Guint FoFiBase::getU32LE(int pos, GBool *ok) {
Guint x;
if (pos < 0 || pos+3 >= len || pos > INT_MAX - 3) {
*ok = gFalse;
return 0;
}
x = file[pos+3];
x = (x << 8) + file[pos+2];
x = (x << 8) + file[pos+1];
x = (x << 8) + file[pos];
return x;
}
Guint FoFiBase::getUVarBE(int pos, int size, GBool *ok) {
Guint x;
int i;
if (pos < 0 || pos + size > len || pos > INT_MAX - size) {
*ok = gFalse;
return 0;
}
x = 0;
for (i = 0; i < size; ++i) {
x = (x << 8) + file[pos + i];
}
return x;
}
GBool FoFiBase::checkRegion(int pos, int size) {
return pos >= 0 &&
pos + size >= pos &&
pos + size <= len;
}

56
thirdparty/poppler/fofi/FoFiBase.h vendored Normal file
View file

@ -0,0 +1,56 @@
//========================================================================
//
// FoFiBase.h
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef FOFIBASE_H
#define FOFIBASE_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "goo/gtypes.h"
//------------------------------------------------------------------------
typedef void (*FoFiOutputFunc)(void *stream, const char *data, int len);
//------------------------------------------------------------------------
// FoFiBase
//------------------------------------------------------------------------
class FoFiBase {
public:
virtual ~FoFiBase();
protected:
FoFiBase(char *fileA, int lenA, GBool freeFileDataA);
static char *readFile(char *fileName, int *fileLen);
// S = signed / U = unsigned
// 8/16/32/Var = word length, in bytes
// BE = big endian
int getS8(int pos, GBool *ok);
int getU8(int pos, GBool *ok);
int getS16BE(int pos, GBool *ok);
int getU16BE(int pos, GBool *ok);
int getS32BE(int pos, GBool *ok);
Guint getU32BE(int pos, GBool *ok);
Guint getU32LE(int pos, GBool *ok);
Guint getUVarBE(int pos, int size, GBool *ok);
GBool checkRegion(int pos, int size);
Guchar *fileData;
Guchar *file;
int len;
GBool freeFileData;
};
#endif

994
thirdparty/poppler/fofi/FoFiEncodings.cc vendored Normal file
View file

@ -0,0 +1,994 @@
//========================================================================
//
// FoFiEncodings.cc
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include "FoFiEncodings.h"
//------------------------------------------------------------------------
// Type 1 and 1C font data
//------------------------------------------------------------------------
const char *fofiType1StandardEncoding[256] = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"space",
"exclam",
"quotedbl",
"numbersign",
"dollar",
"percent",
"ampersand",
"quoteright",
"parenleft",
"parenright",
"asterisk",
"plus",
"comma",
"hyphen",
"period",
"slash",
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"colon",
"semicolon",
"less",
"equal",
"greater",
"question",
"at",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"bracketleft",
"backslash",
"bracketright",
"asciicircum",
"underscore",
"quoteleft",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"braceleft",
"bar",
"braceright",
"asciitilde",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"exclamdown",
"cent",
"sterling",
"fraction",
"yen",
"florin",
"section",
"currency",
"quotesingle",
"quotedblleft",
"guillemotleft",
"guilsinglleft",
"guilsinglright",
"fi",
"fl",
NULL,
"endash",
"dagger",
"daggerdbl",
"periodcentered",
NULL,
"paragraph",
"bullet",
"quotesinglbase",
"quotedblbase",
"quotedblright",
"guillemotright",
"ellipsis",
"perthousand",
NULL,
"questiondown",
NULL,
"grave",
"acute",
"circumflex",
"tilde",
"macron",
"breve",
"dotaccent",
"dieresis",
NULL,
"ring",
"cedilla",
NULL,
"hungarumlaut",
"ogonek",
"caron",
"emdash",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"AE",
NULL,
"ordfeminine",
NULL,
NULL,
NULL,
NULL,
"Lslash",
"Oslash",
"OE",
"ordmasculine",
NULL,
NULL,
NULL,
NULL,
NULL,
"ae",
NULL,
NULL,
NULL,
"dotlessi",
NULL,
NULL,
"lslash",
"oslash",
"oe",
"germandbls",
NULL,
NULL,
NULL,
NULL
};
const char *fofiType1ExpertEncoding[256] = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"space",
"exclamsmall",
"Hungarumlautsmall",
NULL,
"dollaroldstyle",
"dollarsuperior",
"ampersandsmall",
"Acutesmall",
"parenleftsuperior",
"parenrightsuperior",
"twodotenleader",
"onedotenleader",
"comma",
"hyphen",
"period",
"fraction",
"zerooldstyle",
"oneoldstyle",
"twooldstyle",
"threeoldstyle",
"fouroldstyle",
"fiveoldstyle",
"sixoldstyle",
"sevenoldstyle",
"eightoldstyle",
"nineoldstyle",
"colon",
"semicolon",
"commasuperior",
"threequartersemdash",
"periodsuperior",
"questionsmall",
NULL,
"asuperior",
"bsuperior",
"centsuperior",
"dsuperior",
"esuperior",
NULL,
NULL,
NULL,
"isuperior",
NULL,
NULL,
"lsuperior",
"msuperior",
"nsuperior",
"osuperior",
NULL,
NULL,
"rsuperior",
"ssuperior",
"tsuperior",
NULL,
"ff",
"fi",
"fl",
"ffi",
"ffl",
"parenleftinferior",
NULL,
"parenrightinferior",
"Circumflexsmall",
"hyphensuperior",
"Gravesmall",
"Asmall",
"Bsmall",
"Csmall",
"Dsmall",
"Esmall",
"Fsmall",
"Gsmall",
"Hsmall",
"Ismall",
"Jsmall",
"Ksmall",
"Lsmall",
"Msmall",
"Nsmall",
"Osmall",
"Psmall",
"Qsmall",
"Rsmall",
"Ssmall",
"Tsmall",
"Usmall",
"Vsmall",
"Wsmall",
"Xsmall",
"Ysmall",
"Zsmall",
"colonmonetary",
"onefitted",
"rupiah",
"Tildesmall",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"exclamdownsmall",
"centoldstyle",
"Lslashsmall",
NULL,
NULL,
"Scaronsmall",
"Zcaronsmall",
"Dieresissmall",
"Brevesmall",
"Caronsmall",
NULL,
"Dotaccentsmall",
NULL,
NULL,
"Macronsmall",
NULL,
NULL,
"figuredash",
"hypheninferior",
NULL,
NULL,
"Ogoneksmall",
"Ringsmall",
"Cedillasmall",
NULL,
NULL,
NULL,
"onequarter",
"onehalf",
"threequarters",
"questiondownsmall",
"oneeighth",
"threeeighths",
"fiveeighths",
"seveneighths",
"onethird",
"twothirds",
NULL,
NULL,
"zerosuperior",
"onesuperior",
"twosuperior",
"threesuperior",
"foursuperior",
"fivesuperior",
"sixsuperior",
"sevensuperior",
"eightsuperior",
"ninesuperior",
"zeroinferior",
"oneinferior",
"twoinferior",
"threeinferior",
"fourinferior",
"fiveinferior",
"sixinferior",
"seveninferior",
"eightinferior",
"nineinferior",
"centinferior",
"dollarinferior",
"periodinferior",
"commainferior",
"Agravesmall",
"Aacutesmall",
"Acircumflexsmall",
"Atildesmall",
"Adieresissmall",
"Aringsmall",
"AEsmall",
"Ccedillasmall",
"Egravesmall",
"Eacutesmall",
"Ecircumflexsmall",
"Edieresissmall",
"Igravesmall",
"Iacutesmall",
"Icircumflexsmall",
"Idieresissmall",
"Ethsmall",
"Ntildesmall",
"Ogravesmall",
"Oacutesmall",
"Ocircumflexsmall",
"Otildesmall",
"Odieresissmall",
"OEsmall",
"Oslashsmall",
"Ugravesmall",
"Uacutesmall",
"Ucircumflexsmall",
"Udieresissmall",
"Yacutesmall",
"Thornsmall",
"Ydieresissmall"
};
//------------------------------------------------------------------------
// Type 1C font data
//------------------------------------------------------------------------
const char *fofiType1CStdStrings[391] = {
".notdef",
"space",
"exclam",
"quotedbl",
"numbersign",
"dollar",
"percent",
"ampersand",
"quoteright",
"parenleft",
"parenright",
"asterisk",
"plus",
"comma",
"hyphen",
"period",
"slash",
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"colon",
"semicolon",
"less",
"equal",
"greater",
"question",
"at",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"bracketleft",
"backslash",
"bracketright",
"asciicircum",
"underscore",
"quoteleft",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"braceleft",
"bar",
"braceright",
"asciitilde",
"exclamdown",
"cent",
"sterling",
"fraction",
"yen",
"florin",
"section",
"currency",
"quotesingle",
"quotedblleft",
"guillemotleft",
"guilsinglleft",
"guilsinglright",
"fi",
"fl",
"endash",
"dagger",
"daggerdbl",
"periodcentered",
"paragraph",
"bullet",
"quotesinglbase",
"quotedblbase",
"quotedblright",
"guillemotright",
"ellipsis",
"perthousand",
"questiondown",
"grave",
"acute",
"circumflex",
"tilde",
"macron",
"breve",
"dotaccent",
"dieresis",
"ring",
"cedilla",
"hungarumlaut",
"ogonek",
"caron",
"emdash",
"AE",
"ordfeminine",
"Lslash",
"Oslash",
"OE",
"ordmasculine",
"ae",
"dotlessi",
"lslash",
"oslash",
"oe",
"germandbls",
"onesuperior",
"logicalnot",
"mu",
"trademark",
"Eth",
"onehalf",
"plusminus",
"Thorn",
"onequarter",
"divide",
"brokenbar",
"degree",
"thorn",
"threequarters",
"twosuperior",
"registered",
"minus",
"eth",
"multiply",
"threesuperior",
"copyright",
"Aacute",
"Acircumflex",
"Adieresis",
"Agrave",
"Aring",
"Atilde",
"Ccedilla",
"Eacute",
"Ecircumflex",
"Edieresis",
"Egrave",
"Iacute",
"Icircumflex",
"Idieresis",
"Igrave",
"Ntilde",
"Oacute",
"Ocircumflex",
"Odieresis",
"Ograve",
"Otilde",
"Scaron",
"Uacute",
"Ucircumflex",
"Udieresis",
"Ugrave",
"Yacute",
"Ydieresis",
"Zcaron",
"aacute",
"acircumflex",
"adieresis",
"agrave",
"aring",
"atilde",
"ccedilla",
"eacute",
"ecircumflex",
"edieresis",
"egrave",
"iacute",
"icircumflex",
"idieresis",
"igrave",
"ntilde",
"oacute",
"ocircumflex",
"odieresis",
"ograve",
"otilde",
"scaron",
"uacute",
"ucircumflex",
"udieresis",
"ugrave",
"yacute",
"ydieresis",
"zcaron",
"exclamsmall",
"Hungarumlautsmall",
"dollaroldstyle",
"dollarsuperior",
"ampersandsmall",
"Acutesmall",
"parenleftsuperior",
"parenrightsuperior",
"twodotenleader",
"onedotenleader",
"zerooldstyle",
"oneoldstyle",
"twooldstyle",
"threeoldstyle",
"fouroldstyle",
"fiveoldstyle",
"sixoldstyle",
"sevenoldstyle",
"eightoldstyle",
"nineoldstyle",
"commasuperior",
"threequartersemdash",
"periodsuperior",
"questionsmall",
"asuperior",
"bsuperior",
"centsuperior",
"dsuperior",
"esuperior",
"isuperior",
"lsuperior",
"msuperior",
"nsuperior",
"osuperior",
"rsuperior",
"ssuperior",
"tsuperior",
"ff",
"ffi",
"ffl",
"parenleftinferior",
"parenrightinferior",
"Circumflexsmall",
"hyphensuperior",
"Gravesmall",
"Asmall",
"Bsmall",
"Csmall",
"Dsmall",
"Esmall",
"Fsmall",
"Gsmall",
"Hsmall",
"Ismall",
"Jsmall",
"Ksmall",
"Lsmall",
"Msmall",
"Nsmall",
"Osmall",
"Psmall",
"Qsmall",
"Rsmall",
"Ssmall",
"Tsmall",
"Usmall",
"Vsmall",
"Wsmall",
"Xsmall",
"Ysmall",
"Zsmall",
"colonmonetary",
"onefitted",
"rupiah",
"Tildesmall",
"exclamdownsmall",
"centoldstyle",
"Lslashsmall",
"Scaronsmall",
"Zcaronsmall",
"Dieresissmall",
"Brevesmall",
"Caronsmall",
"Dotaccentsmall",
"Macronsmall",
"figuredash",
"hypheninferior",
"Ogoneksmall",
"Ringsmall",
"Cedillasmall",
"questiondownsmall",
"oneeighth",
"threeeighths",
"fiveeighths",
"seveneighths",
"onethird",
"twothirds",
"zerosuperior",
"foursuperior",
"fivesuperior",
"sixsuperior",
"sevensuperior",
"eightsuperior",
"ninesuperior",
"zeroinferior",
"oneinferior",
"twoinferior",
"threeinferior",
"fourinferior",
"fiveinferior",
"sixinferior",
"seveninferior",
"eightinferior",
"nineinferior",
"centinferior",
"dollarinferior",
"periodinferior",
"commainferior",
"Agravesmall",
"Aacutesmall",
"Acircumflexsmall",
"Atildesmall",
"Adieresissmall",
"Aringsmall",
"AEsmall",
"Ccedillasmall",
"Egravesmall",
"Eacutesmall",
"Ecircumflexsmall",
"Edieresissmall",
"Igravesmall",
"Iacutesmall",
"Icircumflexsmall",
"Idieresissmall",
"Ethsmall",
"Ntildesmall",
"Ogravesmall",
"Oacutesmall",
"Ocircumflexsmall",
"Otildesmall",
"Odieresissmall",
"OEsmall",
"Oslashsmall",
"Ugravesmall",
"Uacutesmall",
"Ucircumflexsmall",
"Udieresissmall",
"Yacutesmall",
"Thornsmall",
"Ydieresissmall",
"001.000",
"001.001",
"001.002",
"001.003",
"Black",
"Bold",
"Book",
"Light",
"Medium",
"Regular",
"Roman",
"Semibold"
};
Gushort fofiType1CISOAdobeCharset[229] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228
};
Gushort fofiType1CExpertCharset[166] = {
0, 1, 229, 230, 231, 232, 233, 234, 235, 236,
237, 238, 13, 14, 15, 99, 239, 240, 241, 242,
243, 244, 245, 246, 247, 248, 27, 28, 249, 250,
251, 252, 253, 254, 255, 256, 257, 258, 259, 260,
261, 262, 263, 264, 265, 266, 109, 110, 267, 268,
269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
289, 290, 291, 292, 293, 294, 295, 296, 297, 298,
299, 300, 301, 302, 303, 304, 305, 306, 307, 308,
309, 310, 311, 312, 313, 314, 315, 316, 317, 318,
158, 155, 163, 319, 320, 321, 322, 323, 324, 325,
326, 150, 164, 169, 327, 328, 329, 330, 331, 332,
333, 334, 335, 336, 337, 338, 339, 340, 341, 342,
343, 344, 345, 346, 347, 348, 349, 350, 351, 352,
353, 354, 355, 356, 357, 358, 359, 360, 361, 362,
363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378
};
Gushort fofiType1CExpertSubsetCharset[87] = {
0, 1, 231, 232, 235, 236, 237, 238, 13, 14,
15, 99, 239, 240, 241, 242, 243, 244, 245, 246,
247, 248, 27, 28, 249, 250, 251, 253, 254, 255,
256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
266, 109, 110, 267, 268, 269, 270, 272, 300, 301,
302, 305, 314, 315, 158, 155, 163, 320, 321, 322,
323, 324, 325, 326, 150, 164, 169, 327, 328, 329,
330, 331, 332, 333, 334, 335, 336, 337, 338, 339,
340, 341, 342, 343, 344, 345, 346
};

34
thirdparty/poppler/fofi/FoFiEncodings.h vendored Normal file
View file

@ -0,0 +1,34 @@
//========================================================================
//
// FoFiEncodings.h
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef FOFIENCODINGS_H
#define FOFIENCODINGS_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "goo/gtypes.h"
//------------------------------------------------------------------------
// Type 1 and 1C font data
//------------------------------------------------------------------------
extern const char *fofiType1StandardEncoding[256];
extern const char *fofiType1ExpertEncoding[256];
//------------------------------------------------------------------------
// Type 1C font data
//------------------------------------------------------------------------
extern const char *fofiType1CStdStrings[391];
extern Gushort fofiType1CISOAdobeCharset[229];
extern Gushort fofiType1CExpertCharset[166];
extern Gushort fofiType1CExpertSubsetCharset[87];
#endif

View file

@ -0,0 +1,648 @@
//========================================================================
//
// FoFiIdentifier.cc
//
// Copyright 2009 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2013 Christoph Duelli <duelli@melosgmbh.de>
//
// 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
//
//========================================================================
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "goo/gtypes.h"
#include "FoFiIdentifier.h"
//------------------------------------------------------------------------
namespace { // do not pollute global namespace
class Reader {
public:
virtual ~Reader() {}
// Read one byte. Returns -1 if past EOF.
virtual int getByte(int pos) = 0;
// Read a big-endian unsigned 16-bit integer. Fills in *val and
// returns true if successful.
virtual GBool getU16BE(int pos, int *val) = 0;
// Read a big-endian unsigned 32-bit integer. Fills in *val and
// returns true if successful.
virtual GBool getU32BE(int pos, Guint *val) = 0;
// Read a little-endian unsigned 32-bit integer. Fills in *val and
// returns true if successful.
virtual GBool getU32LE(int pos, Guint *val) = 0;
// Read a big-endian unsigned <size>-byte integer, where 1 <= size
// <= 4. Fills in *val and returns true if successful.
virtual GBool getUVarBE(int pos, int size, Guint *val) = 0;
// Compare against a string. Returns true if equal.
virtual GBool cmp(int pos, const char *s) = 0;
};
//------------------------------------------------------------------------
class MemReader: public Reader {
public:
static MemReader *make(char *bufA, int lenA);
virtual ~MemReader();
virtual int getByte(int pos);
virtual GBool getU16BE(int pos, int *val);
virtual GBool getU32BE(int pos, Guint *val);
virtual GBool getU32LE(int pos, Guint *val);
virtual GBool getUVarBE(int pos, int size, Guint *val);
virtual GBool cmp(int pos, const char *s);
private:
MemReader(char *bufA, int lenA);
char *buf;
int len;
};
MemReader *MemReader::make(char *bufA, int lenA) {
return new MemReader(bufA, lenA);
}
MemReader::MemReader(char *bufA, int lenA) {
buf = bufA;
len = lenA;
}
MemReader::~MemReader() {
}
int MemReader::getByte(int pos) {
if (pos < 0 || pos >= len) {
return -1;
}
return buf[pos] & 0xff;
}
GBool MemReader::getU16BE(int pos, int *val) {
if (pos < 0 || pos > len - 2) {
return gFalse;
}
*val = ((buf[pos] & 0xff) << 8) +
(buf[pos+1] & 0xff);
return gTrue;
}
GBool MemReader::getU32BE(int pos, Guint *val) {
if (pos < 0 || pos > len - 4) {
return gFalse;
}
*val = ((buf[pos] & 0xff) << 24) +
((buf[pos+1] & 0xff) << 16) +
((buf[pos+2] & 0xff) << 8) +
(buf[pos+3] & 0xff);
return gTrue;
}
GBool MemReader::getU32LE(int pos, Guint *val) {
if (pos < 0 || pos > len - 4) {
return gFalse;
}
*val = (buf[pos] & 0xff) +
((buf[pos+1] & 0xff) << 8) +
((buf[pos+2] & 0xff) << 16) +
((buf[pos+3] & 0xff) << 24);
return gTrue;
}
GBool MemReader::getUVarBE(int pos, int size, Guint *val) {
int i;
if (size < 1 || size > 4 || pos < 0 || pos > len - size) {
return gFalse;
}
*val = 0;
for (i = 0; i < size; ++i) {
*val = (*val << 8) + (buf[pos + i] & 0xff);
}
return gTrue;
}
GBool MemReader::cmp(int pos, const char *s) {
int n;
n = (int)strlen(s);
if (pos < 0 || len < n || pos > len - n) {
return gFalse;
}
return !memcmp(buf + pos, s, n);
}
//------------------------------------------------------------------------
class FileReader: public Reader {
public:
static FileReader *make(char *fileName);
virtual ~FileReader();
virtual int getByte(int pos);
virtual GBool getU16BE(int pos, int *val);
virtual GBool getU32BE(int pos, Guint *val);
virtual GBool getU32LE(int pos, Guint *val);
virtual GBool getUVarBE(int pos, int size, Guint *val);
virtual GBool cmp(int pos, const char *s);
private:
FileReader(FILE *fA);
GBool fillBuf(int pos, int len);
FILE *f;
char buf[1024];
int bufPos, bufLen;
};
FileReader *FileReader::make(char *fileName) {
FILE *fA;
if (!(fA = fopen(fileName, "rb"))) {
return NULL;
}
return new FileReader(fA);
}
FileReader::FileReader(FILE *fA) {
f = fA;
bufPos = 0;
bufLen = 0;
}
FileReader::~FileReader() {
fclose(f);
}
int FileReader::getByte(int pos) {
if (!fillBuf(pos, 1)) {
return -1;
}
return buf[pos - bufPos] & 0xff;
}
GBool FileReader::getU16BE(int pos, int *val) {
if (!fillBuf(pos, 2)) {
return gFalse;
}
*val = ((buf[pos - bufPos] & 0xff) << 8) +
(buf[pos - bufPos + 1] & 0xff);
return gTrue;
}
GBool FileReader::getU32BE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
}
*val = ((buf[pos - bufPos] & 0xff) << 24) +
((buf[pos - bufPos + 1] & 0xff) << 16) +
((buf[pos - bufPos + 2] & 0xff) << 8) +
(buf[pos - bufPos + 3] & 0xff);
return gTrue;
}
GBool FileReader::getU32LE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
}
*val = (buf[pos - bufPos] & 0xff) +
((buf[pos - bufPos + 1] & 0xff) << 8) +
((buf[pos - bufPos + 2] & 0xff) << 16) +
((buf[pos - bufPos + 3] & 0xff) << 24);
return gTrue;
}
GBool FileReader::getUVarBE(int pos, int size, Guint *val) {
int i;
if (size < 1 || size > 4 || !fillBuf(pos, size)) {
return gFalse;
}
*val = 0;
for (i = 0; i < size; ++i) {
*val = (*val << 8) + (buf[pos - bufPos + i] & 0xff);
}
return gTrue;
}
GBool FileReader::cmp(int pos, const char *s) {
int n;
n = (int)strlen(s);
if (!fillBuf(pos, n)) {
return gFalse;
}
return !memcmp(buf - bufPos + pos, s, n);
}
GBool FileReader::fillBuf(int pos, int len) {
if (pos < 0 || len < 0 || len > (int)sizeof(buf) ||
pos > INT_MAX - (int)sizeof(buf)) {
return gFalse;
}
if (pos >= bufPos && pos + len <= bufPos + bufLen) {
return gTrue;
}
if (fseek(f, pos, SEEK_SET)) {
return gFalse;
}
bufPos = pos;
bufLen = (int)fread(buf, 1, sizeof(buf), f);
if (bufLen < len) {
return gFalse;
}
return gTrue;
}
//------------------------------------------------------------------------
class StreamReader: public Reader {
public:
static StreamReader *make(int (*getCharA)(void *data), void *dataA);
virtual ~StreamReader();
virtual int getByte(int pos);
virtual GBool getU16BE(int pos, int *val);
virtual GBool getU32BE(int pos, Guint *val);
virtual GBool getU32LE(int pos, Guint *val);
virtual GBool getUVarBE(int pos, int size, Guint *val);
virtual GBool cmp(int pos, const char *s);
private:
StreamReader(int (*getCharA)(void *data), void *dataA);
GBool fillBuf(int pos, int len);
int (*getChar)(void *data);
void *data;
int streamPos;
char buf[1024];
int bufPos, bufLen;
};
StreamReader *StreamReader::make(int (*getCharA)(void *data), void *dataA) {
return new StreamReader(getCharA, dataA);
}
StreamReader::StreamReader(int (*getCharA)(void *data), void *dataA) {
getChar = getCharA;
data = dataA;
streamPos = 0;
bufPos = 0;
bufLen = 0;
}
StreamReader::~StreamReader() {
}
int StreamReader::getByte(int pos) {
if (!fillBuf(pos, 1)) {
return -1;
}
return buf[pos - bufPos] & 0xff;
}
GBool StreamReader::getU16BE(int pos, int *val) {
if (!fillBuf(pos, 2)) {
return gFalse;
}
*val = ((buf[pos - bufPos] & 0xff) << 8) +
(buf[pos - bufPos + 1] & 0xff);
return gTrue;
}
GBool StreamReader::getU32BE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
}
*val = ((buf[pos - bufPos] & 0xff) << 24) +
((buf[pos - bufPos + 1] & 0xff) << 16) +
((buf[pos - bufPos + 2] & 0xff) << 8) +
(buf[pos - bufPos + 3] & 0xff);
return gTrue;
}
GBool StreamReader::getU32LE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
}
*val = (buf[pos - bufPos] & 0xff) +
((buf[pos - bufPos + 1] & 0xff) << 8) +
((buf[pos - bufPos + 2] & 0xff) << 16) +
((buf[pos - bufPos + 3] & 0xff) << 24);
return gTrue;
}
GBool StreamReader::getUVarBE(int pos, int size, Guint *val) {
int i;
if (size < 1 || size > 4 || !fillBuf(pos, size)) {
return gFalse;
}
*val = 0;
for (i = 0; i < size; ++i) {
*val = (*val << 8) + (buf[pos - bufPos + i] & 0xff);
}
return gTrue;
}
GBool StreamReader::cmp(int pos, const char *s) {
int n;
n = (int)strlen(s);
if (!fillBuf(pos, n)) {
return gFalse;
}
return !memcmp(buf - bufPos + pos, s, n);
}
GBool StreamReader::fillBuf(int pos, int len) {
int c;
if (pos < 0 || len < 0 || len > (int)sizeof(buf) ||
pos > INT_MAX - (int)sizeof(buf)) {
return gFalse;
}
if (pos < bufPos) {
return gFalse;
}
// if requested region will not fit in the current buffer...
if (pos + len > bufPos + (int)sizeof(buf)) {
// if the start of the requested data is already in the buffer, move
// it to the start of the buffer
if (pos < bufPos + bufLen) {
bufLen -= pos - bufPos;
memmove(buf, buf + (pos - bufPos), bufLen);
bufPos = pos;
// otherwise discard data from the
// stream until we get to the requested position
} else {
bufPos += bufLen;
bufLen = 0;
while (bufPos < pos) {
if ((c = (*getChar)(data)) < 0) {
return gFalse;
}
++bufPos;
}
}
}
// read the rest of the requested data
while (bufPos + bufLen < pos + len) {
if ((c = (*getChar)(data)) < 0) {
return gFalse;
}
buf[bufLen++] = (char)c;
}
return gTrue;
}
}
//------------------------------------------------------------------------
static FoFiIdentifierType identify(Reader *reader);
static FoFiIdentifierType identifyOpenType(Reader *reader);
static FoFiIdentifierType identifyCFF(Reader *reader, int start);
FoFiIdentifierType FoFiIdentifier::identifyMem(char *file, int len) {
MemReader *reader;
FoFiIdentifierType type;
if (!(reader = MemReader::make(file, len))) {
return fofiIdError;
}
type = identify(reader);
delete reader;
return type;
}
FoFiIdentifierType FoFiIdentifier::identifyFile(char *fileName) {
FileReader *reader;
FoFiIdentifierType type;
if (!(reader = FileReader::make(fileName))) {
return fofiIdError;
}
type = identify(reader);
delete reader;
return type;
}
FoFiIdentifierType FoFiIdentifier::identifyStream(int (*getChar)(void *data),
void *data) {
StreamReader *reader;
FoFiIdentifierType type;
if (!(reader = StreamReader::make(getChar, data))) {
return fofiIdError;
}
type = identify(reader);
delete reader;
return type;
}
static FoFiIdentifierType identify(Reader *reader) {
Guint n;
//----- PFA
if (reader->cmp(0, "%!PS-AdobeFont-1") ||
reader->cmp(0, "%!FontType1")) {
return fofiIdType1PFA;
}
//----- PFB
if (reader->getByte(0) == 0x80 &&
reader->getByte(1) == 0x01 &&
reader->getU32LE(2, &n)) {
if ((n >= 16 && reader->cmp(6, "%!PS-AdobeFont-1")) ||
(n >= 11 && reader->cmp(6, "%!FontType1"))) {
return fofiIdType1PFB;
}
}
//----- TrueType
if ((reader->getByte(0) == 0x00 &&
reader->getByte(1) == 0x01 &&
reader->getByte(2) == 0x00 &&
reader->getByte(3) == 0x00) ||
(reader->getByte(0) == 0x74 && // 'true'
reader->getByte(1) == 0x72 &&
reader->getByte(2) == 0x75 &&
reader->getByte(3) == 0x65)) {
return fofiIdTrueType;
}
if (reader->getByte(0) == 0x74 && // 'ttcf'
reader->getByte(1) == 0x74 &&
reader->getByte(2) == 0x63 &&
reader->getByte(3) == 0x66) {
return fofiIdTrueTypeCollection;
}
//----- OpenType
if (reader->getByte(0) == 0x4f && // 'OTTO
reader->getByte(1) == 0x54 &&
reader->getByte(2) == 0x54 &&
reader->getByte(3) == 0x4f) {
return identifyOpenType(reader);
}
//----- CFF
if (reader->getByte(0) == 0x01 &&
reader->getByte(1) == 0x00) {
return identifyCFF(reader, 0);
}
// some tools embed CFF fonts with an extra whitespace char at the
// beginning
if (reader->getByte(1) == 0x01 &&
reader->getByte(2) == 0x00) {
return identifyCFF(reader, 1);
}
return fofiIdUnknown;
}
static FoFiIdentifierType identifyOpenType(Reader *reader) {
FoFiIdentifierType type;
Guint offset;
int nTables, i;
if (!reader->getU16BE(4, &nTables)) {
return fofiIdUnknown;
}
for (i = 0; i < nTables; ++i) {
if (reader->cmp(12 + i*16, "CFF ")) {
if (reader->getU32BE(12 + i*16 + 8, &offset) &&
offset < (Guint)INT_MAX) {
type = identifyCFF(reader, (int)offset);
if (type == fofiIdCFF8Bit) {
type = fofiIdOpenTypeCFF8Bit;
} else if (type == fofiIdCFFCID) {
type = fofiIdOpenTypeCFFCID;
}
return type;
}
return fofiIdUnknown;
}
}
return fofiIdUnknown;
}
static FoFiIdentifierType identifyCFF(Reader *reader, int start) {
Guint offset0, offset1;
int hdrSize, offSize0, offSize1, pos, endPos, b0, n, i;
//----- read the header
if (reader->getByte(start) != 0x01 ||
reader->getByte(start + 1) != 0x00) {
return fofiIdUnknown;
}
if ((hdrSize = reader->getByte(start + 2)) < 0) {
return fofiIdUnknown;
}
if ((offSize0 = reader->getByte(start + 3)) < 1 || offSize0 > 4) {
return fofiIdUnknown;
}
pos = start + hdrSize;
if (pos < 0) {
return fofiIdUnknown;
}
//----- skip the name index
if (!reader->getU16BE(pos, &n)) {
return fofiIdUnknown;
}
if (n == 0) {
pos += 2;
} else {
if ((offSize1 = reader->getByte(pos + 2)) < 1 || offSize1 > 4) {
return fofiIdUnknown;
}
if (!reader->getUVarBE(pos + 3 + n * offSize1, offSize1, &offset1) ||
offset1 > (Guint)INT_MAX) {
return fofiIdUnknown;
}
pos += 3 + (n + 1) * offSize1 + (int)offset1 - 1;
}
if (pos < 0) {
return fofiIdUnknown;
}
//----- parse the top dict index
if (!reader->getU16BE(pos, &n) || n < 1) {
return fofiIdUnknown;
}
if ((offSize1 = reader->getByte(pos + 2)) < 1 || offSize1 > 4) {
return fofiIdUnknown;
}
if (!reader->getUVarBE(pos + 3, offSize1, &offset0) ||
offset0 > (Guint)INT_MAX ||
!reader->getUVarBE(pos + 3 + offSize1, offSize1, &offset1) ||
offset1 > (Guint)INT_MAX ||
offset0 > offset1) {
return fofiIdUnknown;
}
pos = pos + 3 + (n + 1) * offSize1 + (int)offset0 - 1;
endPos = pos + 3 + (n + 1) * offSize1 + (int)offset1 - 1;
if (pos < 0 || endPos < 0 || pos > endPos) {
return fofiIdUnknown;
}
//----- parse the top dict, look for ROS as first entry
// for a CID font, the top dict starts with:
// <int> <int> <int> ROS
for (i = 0; i < 3; ++i) {
b0 = reader->getByte(pos++);
if (b0 == 0x1c) {
pos += 2;
} else if (b0 == 0x1d) {
pos += 4;
} else if (b0 >= 0xf7 && b0 <= 0xfe) {
pos += 1;
} else if (b0 < 0x20 || b0 > 0xf6) {
return fofiIdCFF8Bit;
}
if (pos >= endPos || pos < 0) {
return fofiIdCFF8Bit;
}
}
if (pos + 1 < endPos &&
reader->getByte(pos) == 12 &&
reader->getByte(pos + 1) == 30) {
return fofiIdCFFCID;
} else {
return fofiIdCFF8Bit;
}
}

View file

@ -0,0 +1,42 @@
//========================================================================
//
// FoFiIdentifier.h
//
// Copyright 2009 Glyph & Cog, LLC
//
//========================================================================
#ifndef FOFIIDENTIFIER_H
#define FOFIIDENTIFIER_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
//------------------------------------------------------------------------
// FoFiIdentifier
//------------------------------------------------------------------------
enum FoFiIdentifierType {
fofiIdType1PFA, // Type 1 font in PFA format
fofiIdType1PFB, // Type 1 font in PFB format
fofiIdCFF8Bit, // 8-bit CFF font
fofiIdCFFCID, // CID CFF font
fofiIdTrueType, // TrueType font
fofiIdTrueTypeCollection, // TrueType collection
fofiIdOpenTypeCFF8Bit, // OpenType wrapper with 8-bit CFF font
fofiIdOpenTypeCFFCID, // OpenType wrapper with CID CFF font
fofiIdUnknown, // unknown type
fofiIdError // error in reading the file
};
class FoFiIdentifier {
public:
static FoFiIdentifierType identifyMem(char *file, int len);
static FoFiIdentifierType identifyFile(char *fileName);
static FoFiIdentifierType identifyStream(int (*getChar)(void *data),
void *data);
};
#endif

1863
thirdparty/poppler/fofi/FoFiTrueType.cc vendored Normal file

File diff suppressed because it is too large Load diff

209
thirdparty/poppler/fofi/FoFiTrueType.h vendored Normal file
View file

@ -0,0 +1,209 @@
//========================================================================
//
// FoFiTrueType.h
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2011, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
//
// 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
//
//========================================================================
#ifndef FOFITRUETYPE_H
#define FOFITRUETYPE_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "stddef.h"
#include "goo/gtypes.h"
#include "FoFiBase.h"
class GooString;
class GooHash;
struct TrueTypeTable;
struct TrueTypeCmap;
//------------------------------------------------------------------------
// FoFiTrueType
//------------------------------------------------------------------------
class FoFiTrueType: public FoFiBase {
public:
// Create a FoFiTrueType object from a memory buffer.
static FoFiTrueType *make(char *fileA, int lenA, int faceIndexA=0);
// Create a FoFiTrueType object from a file on disk.
static FoFiTrueType *load(char *fileName, int faceIndexA=0);
virtual ~FoFiTrueType();
// Returns true if this an OpenType font containing CFF data, false
// if it's a TrueType font (or OpenType font with TrueType data).
GBool isOpenTypeCFF() { return openTypeCFF; }
// Return the number of cmaps defined by this font.
int getNumCmaps();
// Return the platform ID of the <i>th cmap.
int getCmapPlatform(int i);
// Return the encoding ID of the <i>th cmap.
int getCmapEncoding(int i);
// Return the index of the cmap for <platform>, <encoding>. Returns
// -1 if there is no corresponding cmap.
int findCmap(int platform, int encoding);
// Return the GID corresponding to <c> according to the <i>th cmap.
int mapCodeToGID(int i, Guint c);
// map gid to vertical glyph gid if exist.
// if not exist return original gid
Guint mapToVertGID(Guint orgGID);
// Returns the GID corresponding to <name> according to the post
// table. Returns 0 if there is no mapping for <name> or if the
// font does not have a post table.
int mapNameToGID(char *name);
// Return the mapping from CIDs to GIDs, and return the number of
// CIDs in *<nCIDs>. This is only useful for CID fonts. (Only
// useful for OpenType CFF fonts.)
int *getCIDToGIDMap(int *nCIDs);
// Returns the least restrictive embedding licensing right (as
// defined by the TrueType spec):
// * 4: OS/2 table is missing or invalid
// * 3: installable embedding
// * 2: editable embedding
// * 1: preview & print embedding
// * 0: restricted license embedding
int getEmbeddingRights();
// Return the font matrix as an array of six numbers. (Only useful
// for OpenType CFF fonts.)
void getFontMatrix(double *mat);
// Convert to a Type 42 font, suitable for embedding in a PostScript
// file. <psName> will be used as the PostScript font name (so we
// don't need to depend on the 'name' table in the font). The
// <encoding> array specifies the mapping from char codes to names.
// If <encoding> is NULL, the encoding is unknown or undefined. The
// <codeToGID> array specifies the mapping from char codes to GIDs.
// (Not useful for OpenType CFF fonts.)
void convertToType42(char *psName, char **encoding,
int *codeToGID,
FoFiOutputFunc outputFunc, void *outputStream);
// Convert to a Type 1 font, suitable for embedding in a PostScript
// file. This is only useful with 8-bit fonts. If <newEncoding> is
// not NULL, it will be used in place of the encoding in the Type 1C
// font. If <ascii> is true the eexec section will be hex-encoded,
// otherwise it will be left as binary data. If <psName> is
// non-NULL, it will be used as the PostScript font name. (Only
// useful for OpenType CFF fonts.)
void convertToType1(char *psName, const char **newEncoding, GBool ascii,
FoFiOutputFunc outputFunc, void *outputStream);
// Convert to a Type 2 CIDFont, suitable for embedding in a
// PostScript file. <psName> will be used as the PostScript font
// name (so we don't need to depend on the 'name' table in the
// font). The <cidMap> array maps CIDs to GIDs; it has <nCIDs>
// entries. (Not useful for OpenType CFF fonts.)
void convertToCIDType2(char *psName, int *cidMap, int nCIDs,
GBool needVerticalMetrics,
FoFiOutputFunc outputFunc, void *outputStream);
// Convert to a Type 0 CIDFont, suitable for embedding in a
// PostScript file. <psName> will be used as the PostScript font
// name. (Only useful for OpenType CFF fonts.)
void convertToCIDType0(char *psName, int *cidMap, int nCIDs,
FoFiOutputFunc outputFunc, void *outputStream);
// Convert to a Type 0 (but non-CID) composite font, suitable for
// embedding in a PostScript file. <psName> will be used as the
// PostScript font name (so we don't need to depend on the 'name'
// table in the font). The <cidMap> array maps CIDs to GIDs; it has
// <nCIDs> entries. (Not useful for OpenType CFF fonts.)
void convertToType0(char *psName, int *cidMap, int nCIDs,
GBool needVerticalMetrics,
FoFiOutputFunc outputFunc, void *outputStream);
// Convert to a Type 0 (but non-CID) composite font, suitable for
// embedding in a PostScript file. <psName> will be used as the
// PostScript font name. (Only useful for OpenType CFF fonts.)
void convertToType0(char *psName, int *cidMap, int nCIDs,
FoFiOutputFunc outputFunc, void *outputStream);
// Returns a pointer to the CFF font embedded in this OpenType font.
// If successful, sets *<start> and *<length>, and returns true.
// Otherwise returns false. (Only useful for OpenType CFF fonts).
GBool getCFFBlock(char **start, int *length);
// setup vert/vrt2 GSUB for default lang
int setupGSUB(const char *scriptName);
// setup vert/vrt2 GSUB for specified lang
int setupGSUB(const char *scriptName, const char* languageName);
private:
FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA);
void cvtEncoding(char **encoding,
FoFiOutputFunc outputFunc,
void *outputStream);
void cvtCharStrings(char **encoding,
int *codeToGID,
FoFiOutputFunc outputFunc,
void *outputStream);
void cvtSfnts(FoFiOutputFunc outputFunc,
void *outputStream, GooString *name,
GBool needVerticalMetrics,
int *maxUsedGlyph);
void dumpString(Guchar *s, int length,
FoFiOutputFunc outputFunc,
void *outputStream);
Guint computeTableChecksum(Guchar *data, int length);
void parse();
void readPostTable();
int seekTable(const char *tag);
Guint charToTag(const char *tagName);
Guint doMapToVertGID(Guint orgGID);
Guint scanLookupList(Guint listIndex, Guint orgGID);
Guint scanLookupSubTable(Guint subTable, Guint orgGID);
int checkGIDInCoverage(Guint coverage, Guint orgGID);
TrueTypeTable *tables;
int nTables;
TrueTypeCmap *cmaps;
int nCmaps;
int nGlyphs;
int locaFmt;
int bbox[4];
GooHash *nameToGID;
GBool openTypeCFF;
GBool parsedOk;
int faceIndex;
Guint gsubFeatureTable;
Guint gsubLookupList;
};
#endif

359
thirdparty/poppler/fofi/FoFiType1.cc vendored Normal file
View file

@ -0,0 +1,359 @@
//========================================================================
//
// FoFiType1.cc
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005, 2008, 2010 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2010 Jakub Wilk <jwilk@jwilk.net>
// Copyright (C) 2014 Carlos Garcia Campos <carlosgc@gnome.org>
//
// 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
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <string.h>
#include "goo/gmem.h"
#include "goo/GooLikely.h"
#include "FoFiEncodings.h"
#include "FoFiType1.h"
#include "poppler/Error.h"
//------------------------------------------------------------------------
// FoFiType1
//------------------------------------------------------------------------
FoFiType1 *FoFiType1::make(char *fileA, int lenA) {
return new FoFiType1(fileA, lenA, gFalse);
}
FoFiType1 *FoFiType1::load(char *fileName) {
char *fileA;
int lenA;
if (!(fileA = FoFiBase::readFile(fileName, &lenA))) {
return NULL;
}
return new FoFiType1(fileA, lenA, gTrue);
}
FoFiType1::FoFiType1(char *fileA, int lenA, GBool freeFileDataA):
FoFiBase(fileA, lenA, freeFileDataA)
{
name = NULL;
encoding = NULL;
fontMatrix[0] = 0.001;
fontMatrix[1] = 0;
fontMatrix[2] = 0;
fontMatrix[3] = 0.001;
fontMatrix[4] = 0;
fontMatrix[5] = 0;
parsed = gFalse;
undoPFB();
}
FoFiType1::~FoFiType1() {
int i;
if (name) {
gfree(name);
}
if (encoding && encoding != fofiType1StandardEncoding) {
for (i = 0; i < 256; ++i) {
gfree(encoding[i]);
}
gfree(encoding);
}
}
char *FoFiType1::getName() {
if (!parsed) {
parse();
}
return name;
}
char **FoFiType1::getEncoding() {
if (!parsed) {
parse();
}
return encoding;
}
void FoFiType1::getFontMatrix(double *mat) {
int i;
if (!parsed) {
parse();
}
for (i = 0; i < 6; ++i) {
mat[i] = fontMatrix[i];
}
}
void FoFiType1::writeEncoded(const char **newEncoding,
FoFiOutputFunc outputFunc, void *outputStream) {
char buf[512];
char *line, *line2, *p;
int i;
// copy everything up to the encoding
for (line = (char *)file;
line && strncmp(line, "/Encoding", 9);
line = getNextLine(line)) ;
if (!line) {
// no encoding - just copy the whole font file
(*outputFunc)(outputStream, (char *)file, len);
return;
}
(*outputFunc)(outputStream, (char *)file, line - (char *)file);
// write the new encoding
(*outputFunc)(outputStream, "/Encoding 256 array\n", 20);
(*outputFunc)(outputStream,
"0 1 255 {1 index exch /.notdef put} for\n", 40);
for (i = 0; i < 256; ++i) {
if (newEncoding[i]) {
sprintf(buf, "dup %d /%s put\n", i, newEncoding[i]);
(*outputFunc)(outputStream, buf, strlen(buf));
}
}
(*outputFunc)(outputStream, "readonly def\n", 13);
// find the end of the encoding data
//~ this ought to parse PostScript tokens
if (!strncmp(line, "/Encoding StandardEncoding def", 30)) {
line = getNextLine(line);
} else {
// skip "/Encoding" + one whitespace char,
// then look for 'def' preceded by PostScript whitespace
p = line + 10;
line = NULL;
for (; p < (char *)file + len; ++p) {
if ((*p == ' ' || *p == '\t' || *p == '\x0a' ||
*p == '\x0d' || *p == '\x0c' || *p == '\0') &&
p + 4 <= (char *)file + len &&
!strncmp(p + 1, "def", 3)) {
line = p + 4;
break;
}
}
}
// some fonts have two /Encoding entries in their dictionary, so we
// check for a second one here
if (line) {
for (line2 = line, i = 0;
i < 20 && line2 && strncmp(line2, "/Encoding", 9);
line2 = getNextLine(line2), ++i) ;
if (i < 20 && line2) {
(*outputFunc)(outputStream, line, line2 - line);
if (!strncmp(line2, "/Encoding StandardEncoding def", 30)) {
line = getNextLine(line2);
} else {
// skip "/Encoding" + one whitespace char,
// then look for 'def' preceded by PostScript whitespace
p = line2 + 10;
line = NULL;
for (; p < (char *)file + len; ++p) {
if ((*p == ' ' || *p == '\t' || *p == '\x0a' ||
*p == '\x0d' || *p == '\x0c' || *p == '\0') &&
p + 4 <= (char *)file + len &&
!strncmp(p + 1, "def", 3)) {
line = p + 4;
break;
}
}
}
}
// copy everything after the encoding
if (line) {
(*outputFunc)(outputStream, line, ((char *)file + len) - line);
}
}
}
char *FoFiType1::getNextLine(char *line) {
while (line < (char *)file + len && *line != '\x0a' && *line != '\x0d') {
++line;
}
if (line < (char *)file + len && *line == '\x0d') {
++line;
}
if (line < (char *)file + len && *line == '\x0a') {
++line;
}
if (line >= (char *)file + len) {
return NULL;
}
return line;
}
void FoFiType1::parse() {
char *line, *line1, *p, *p2;
char buf[256];
char c;
int n, code, base, i, j;
char *tokptr;
GBool gotMatrix;
gotMatrix = gFalse;
for (i = 1, line = (char *)file;
i <= 100 && line && (!name || !encoding);
++i) {
// get font name
if (!name && !strncmp(line, "/FontName", 9)) {
strncpy(buf, line, 255);
buf[255] = '\0';
if ((p = strchr(buf+9, '/')) &&
(p = strtok_r(p+1, " \t\n\r", &tokptr))) {
name = copyString(p);
}
line = getNextLine(line);
// get encoding
} else if (!encoding &&
!strncmp(line, "/Encoding StandardEncoding def", 30)) {
encoding = (char **)fofiType1StandardEncoding;
} else if (!encoding &&
!strncmp(line, "/Encoding 256 array", 19)) {
encoding = (char **)gmallocn(256, sizeof(char *));
for (j = 0; j < 256; ++j) {
encoding[j] = NULL;
}
for (j = 0, line = getNextLine(line);
j < 300 && line && (line1 = getNextLine(line));
++j, line = line1) {
if ((n = (int)(line1 - line)) > 255) {
error(errSyntaxWarning, -1, "FoFiType1::parse a line has more than 255 characters, we don't support this");
n = 255;
}
strncpy(buf, line, n);
buf[n] = '\0';
for (p = buf; *p == ' ' || *p == '\t'; ++p) ;
if (!strncmp(p, "dup", 3)) {
while (1) {
p += 3;
for (; *p == ' ' || *p == '\t'; ++p) ;
code = 0;
if (*p == '8' && p[1] == '#') {
base = 8;
p += 2;
} else if (*p >= '0' && *p <= '9') {
base = 10;
} else {
break;
}
for (; *p >= '0' && *p < '0' + base && code < INT_MAX / (base + (*p - '0')); ++p) {
code = code * base + (*p - '0');
}
for (; *p == ' ' || *p == '\t'; ++p) ;
if (*p != '/') {
break;
}
++p;
for (p2 = p; *p2 && *p2 != ' ' && *p2 != '\t'; ++p2) ;
if (code >= 0 && code < 256) {
c = *p2;
*p2 = '\0';
encoding[code] = copyString(p);
*p2 = c;
}
for (p = p2; *p == ' ' || *p == '\t'; ++p) ;
if (strncmp(p, "put", 3)) {
break;
}
for (p += 3; *p == ' ' || *p == '\t'; ++p) ;
if (strncmp(p, "dup", 3)) {
break;
}
}
} else {
if (strtok_r(buf, " \t", &tokptr) &&
(p = strtok_r(NULL, " \t\n\r", &tokptr)) && !strcmp(p, "def")) {
break;
}
}
}
//~ check for getinterval/putinterval junk
} else if (!gotMatrix && !strncmp(line, "/FontMatrix", 11)) {
strncpy(buf, line + 11, 255);
buf[255] = '\0';
if ((p = strchr(buf, '['))) {
++p;
if ((p2 = strchr(p, ']'))) {
*p2 = '\0';
for (j = 0; j < 6; ++j) {
if ((p = strtok(j == 0 ? p : (char *)NULL, " \t\n\r"))) {
fontMatrix[j] = atof(p);
} else {
break;
}
}
}
}
gotMatrix = gTrue;
} else {
line = getNextLine(line);
}
}
parsed = gTrue;
}
// Undo the PFB encoding, i.e., remove the PFB headers.
void FoFiType1::undoPFB() {
GBool ok;
Guchar *file2;
int pos1, pos2, type;
Guint segLen;
ok = gTrue;
if (getU8(0, &ok) != 0x80 || !ok) {
return;
}
file2 = (Guchar *)gmalloc(len);
pos1 = pos2 = 0;
while (getU8(pos1, &ok) == 0x80 && ok) {
type = getU8(pos1 + 1, &ok);
if (type < 1 || type > 2 || !ok) {
break;
}
segLen = getU32LE(pos1 + 2, &ok);
pos1 += 6;
if (!ok || !checkRegion(pos1, segLen)) {
break;
}
memcpy(file2 + pos2, file + pos1, segLen);
pos1 += segLen;
pos2 += segLen;
}
if (freeFileData) {
gfree(fileData);
}
file = fileData = file2;
freeFileData = gTrue;
len = pos2;
}

62
thirdparty/poppler/fofi/FoFiType1.h vendored Normal file
View file

@ -0,0 +1,62 @@
//========================================================================
//
// FoFiType1.h
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef FOFITYPE1_H
#define FOFITYPE1_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "goo/gtypes.h"
#include "FoFiBase.h"
//------------------------------------------------------------------------
// FoFiType1
//------------------------------------------------------------------------
class FoFiType1: public FoFiBase {
public:
// Create a FoFiType1 object from a memory buffer.
static FoFiType1 *make(char *fileA, int lenA);
// Create a FoFiType1 object from a file on disk.
static FoFiType1 *load(char *fileName);
virtual ~FoFiType1();
// Return the font name.
char *getName();
// Return the encoding, as an array of 256 names (any of which may
// be NULL).
char **getEncoding();
// Return the font matrix as an array of six numbers.
void getFontMatrix(double *mat);
// Write a version of the Type 1 font file with a new encoding.
void writeEncoded(const char **newEncoding,
FoFiOutputFunc outputFunc, void *outputStream);
private:
FoFiType1(char *fileA, int lenA, GBool freeFileDataA);
char *getNextLine(char *line);
void parse();
void undoPFB();
char *name;
char **encoding;
double fontMatrix[6];
GBool parsed;
};
#endif

2745
thirdparty/poppler/fofi/FoFiType1C.cc vendored Normal file

File diff suppressed because it is too large Load diff

266
thirdparty/poppler/fofi/FoFiType1C.h vendored Normal file
View file

@ -0,0 +1,266 @@
//========================================================================
//
// FoFiType1C.h
//
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
//
// 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
//
//========================================================================
#ifndef FOFITYPE1C_H
#define FOFITYPE1C_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "goo/gtypes.h"
#include "FoFiBase.h"
class GooString;
//------------------------------------------------------------------------
struct Type1CIndex {
int pos; // absolute position in file
int len; // length (number of entries)
int offSize; // offset size
int startPos; // position of start of index data - 1
int endPos; // position one byte past end of the index
};
struct Type1CIndexVal {
int pos; // absolute position in file
int len; // length, in bytes
};
struct Type1CTopDict {
int firstOp;
int versionSID;
int noticeSID;
int copyrightSID;
int fullNameSID;
int familyNameSID;
int weightSID;
int isFixedPitch;
double italicAngle;
double underlinePosition;
double underlineThickness;
int paintType;
int charstringType;
double fontMatrix[6];
GBool hasFontMatrix; // CID fonts are allowed to put their
// FontMatrix in the FD instead of the
// top dict
int uniqueID;
double fontBBox[4];
double strokeWidth;
int charsetOffset;
int encodingOffset;
int charStringsOffset;
int privateSize;
int privateOffset;
// CIDFont entries
int registrySID;
int orderingSID;
int supplement;
int fdArrayOffset;
int fdSelectOffset;
};
#define type1CMaxBlueValues 14
#define type1CMaxOtherBlues 10
#define type1CMaxStemSnap 12
struct Type1CPrivateDict {
double fontMatrix[6];
GBool hasFontMatrix;
int blueValues[type1CMaxBlueValues];
int nBlueValues;
int otherBlues[type1CMaxOtherBlues];
int nOtherBlues;
int familyBlues[type1CMaxBlueValues];
int nFamilyBlues;
int familyOtherBlues[type1CMaxOtherBlues];
int nFamilyOtherBlues;
double blueScale;
int blueShift;
int blueFuzz;
double stdHW;
GBool hasStdHW;
double stdVW;
GBool hasStdVW;
double stemSnapH[type1CMaxStemSnap];
int nStemSnapH;
double stemSnapV[type1CMaxStemSnap];
int nStemSnapV;
GBool forceBold;
GBool hasForceBold;
double forceBoldThreshold;
int languageGroup;
double expansionFactor;
int initialRandomSeed;
int subrsOffset;
double defaultWidthX;
GBool defaultWidthXFP;
double nominalWidthX;
GBool nominalWidthXFP;
};
struct Type1COp {
GBool isNum; // true -> number, false -> operator
GBool isFP; // true -> floating point number, false -> int
union {
double num; // if num is true
int op; // if num is false
};
};
struct Type1CEexecBuf {
FoFiOutputFunc outputFunc;
void *outputStream;
GBool ascii; // ASCII encoding?
Gushort r1; // eexec encryption key
int line; // number of eexec chars left on current line
};
//------------------------------------------------------------------------
// FoFiType1C
//------------------------------------------------------------------------
class FoFiType1C: public FoFiBase {
public:
// Create a FoFiType1C object from a memory buffer.
static FoFiType1C *make(char *fileA, int lenA);
// Create a FoFiType1C object from a file on disk.
static FoFiType1C *load(char *fileName);
virtual ~FoFiType1C();
// Return the font name.
char *getName();
// Return the encoding, as an array of 256 names (any of which may
// be NULL). This is only useful with 8-bit fonts.
char **getEncoding();
// Get the glyph names.
int getNumGlyphs() { return nGlyphs; }
GooString *getGlyphName(int gid);
// Return the mapping from CIDs to GIDs, and return the number of
// CIDs in *<nCIDs>. This is only useful for CID fonts.
int *getCIDToGIDMap(int *nCIDs);
// Return the font matrix as an array of six numbers.
void getFontMatrix(double *mat);
// Convert to a Type 1 font, suitable for embedding in a PostScript
// file. This is only useful with 8-bit fonts. If <newEncoding> is
// not NULL, it will be used in place of the encoding in the Type 1C
// font. If <ascii> is true the eexec section will be hex-encoded,
// otherwise it will be left as binary data. If <psName> is non-NULL,
// it will be used as the PostScript font name.
void convertToType1(char *psName, const char **newEncoding, GBool ascii,
FoFiOutputFunc outputFunc, void *outputStream);
// Convert to a Type 0 CIDFont, suitable for embedding in a
// PostScript file. <psName> will be used as the PostScript font
// name. There are three cases for the CID-to-GID mapping:
// (1) if <codeMap> is non-NULL, then it is the CID-to-GID mapping
// (2) if <codeMap> is NULL and this is a CID CFF font, then the
// font's internal CID-to-GID mapping is used
// (3) is <codeMap> is NULL and this is an 8-bit CFF font, then
// the identity CID-to-GID mapping is used
void convertToCIDType0(char *psName, int *codeMap, int nCodes,
FoFiOutputFunc outputFunc, void *outputStream);
// Convert to a Type 0 (but non-CID) composite font, suitable for
// embedding in a PostScript file. <psName> will be used as the
// PostScript font name. There are three cases for the CID-to-GID
// mapping:
// (1) if <codeMap> is non-NULL, then it is the CID-to-GID mapping
// (2) if <codeMap> is NULL and this is a CID CFF font, then the
// font's internal CID-to-GID mapping is used
// (3) is <codeMap> is NULL and this is an 8-bit CFF font, then
// the identity CID-to-GID mapping is used
void convertToType0(char *psName, int *codeMap, int nCodes,
FoFiOutputFunc outputFunc, void *outputStream);
private:
FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
void eexecCvtGlyph(Type1CEexecBuf *eb, const char *glyphName,
int offset, int nBytes,
Type1CIndex *subrIdx,
Type1CPrivateDict *pDict);
void cvtGlyph(int offset, int nBytes, GooString *charBuf,
Type1CIndex *subrIdx, Type1CPrivateDict *pDict,
GBool top);
void cvtGlyphWidth(GBool useOp, GooString *charBuf,
Type1CPrivateDict *pDict);
void cvtNum(double x, GBool isFP, GooString *charBuf);
void eexecWrite(Type1CEexecBuf *eb, const char *s);
void eexecWriteCharstring(Type1CEexecBuf *eb, Guchar *s, int n);
void writePSString(char *s, FoFiOutputFunc outputFunc, void *outputStream);
GBool parse();
void readTopDict();
void readFD(int offset, int length, Type1CPrivateDict *pDict);
void readPrivateDict(int offset, int length, Type1CPrivateDict *pDict);
void readFDSelect();
void buildEncoding();
GBool readCharset();
int getOp(int pos, GBool charstring, GBool *ok);
int getDeltaIntArray(int *arr, int maxLen);
int getDeltaFPArray(double *arr, int maxLen);
void getIndex(int pos, Type1CIndex *idx, GBool *ok);
void getIndexVal(Type1CIndex *idx, int i, Type1CIndexVal *val, GBool *ok);
char *getString(int sid, char *buf, GBool *ok);
GooString *name;
char **encoding;
Type1CIndex nameIdx;
Type1CIndex topDictIdx;
Type1CIndex stringIdx;
Type1CIndex gsubrIdx;
Type1CIndex charStringsIdx;
Type1CTopDict topDict;
Type1CPrivateDict *privateDicts;
int nGlyphs;
int nFDs;
Guchar *fdSelect;
Gushort *charset;
Gushort charsetLength;
int gsubrBias;
GBool parsedOk;
Type1COp ops[49]; // operands and operator
int nOps; // number of operands
int nHints; // number of hints for the current glyph
GBool firstOp; // true if we haven't hit the first op yet
GBool openPath; // true if there is an unclosed path
};
#endif

28
thirdparty/poppler/fofi/Makefile.am vendored Normal file
View file

@ -0,0 +1,28 @@
noinst_LTLIBRARIES = libfofi.la
if ENABLE_XPDF_HEADERS
poppler_fofi_includedir = $(includedir)/poppler/fofi
poppler_fofi_include_HEADERS = \
FoFiBase.h \
FoFiEncodings.h \
FoFiTrueType.h \
FoFiType1.h \
FoFiIdentifier.h \
FoFiType1C.h
endif
libfofi_la_SOURCES = \
FoFiBase.cc \
FoFiBase.h \
FoFiEncodings.cc \
FoFiEncodings.h \
FoFiTrueType.cc \
FoFiTrueType.h \
FoFiType1.cc \
FoFiType1.h \
FoFiType1C.cc \
FoFiIdentifier.cc \
FoFiType1C.h
libfofi_la_CPPFLAGS = \
-I$(top_srcdir)

831
thirdparty/poppler/fofi/Makefile.in vendored Normal file
View file

@ -0,0 +1,831 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = fofi
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/define-dir.m4 $(top_srcdir)/m4/gtk-doc.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/introspection.m4 \
$(top_srcdir)/m4/libjpeg.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am \
$(am__poppler_fofi_include_HEADERS_DIST) $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h \
$(top_builddir)/poppler/poppler-config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libfofi_la_LIBADD =
am_libfofi_la_OBJECTS = libfofi_la-FoFiBase.lo \
libfofi_la-FoFiEncodings.lo libfofi_la-FoFiTrueType.lo \
libfofi_la-FoFiType1.lo libfofi_la-FoFiType1C.lo \
libfofi_la-FoFiIdentifier.lo
libfofi_la_OBJECTS = $(am_libfofi_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/poppler
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_@AM_V@)
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
am__v_CXX_0 = @echo " CXX " $@;
am__v_CXX_1 =
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libfofi_la_SOURCES)
DIST_SOURCES = $(libfofi_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__poppler_fofi_include_HEADERS_DIST = FoFiBase.h FoFiEncodings.h \
FoFiTrueType.h FoFiType1.h FoFiIdentifier.h FoFiType1C.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(poppler_fofi_includedir)"
HEADERS = $(poppler_fofi_include_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CAIRO_CFLAGS = @CAIRO_CFLAGS@
CAIRO_FEATURE = @CAIRO_FEATURE@
CAIRO_LIBS = @CAIRO_LIBS@
CAIRO_REQ = @CAIRO_REQ@
CAIRO_VERSION = @CAIRO_VERSION@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
FREETYPE_CONFIG = @FREETYPE_CONFIG@
FREETYPE_LIBS = @FREETYPE_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GLIB_REQ = @GLIB_REQ@
GLIB_REQUIRED = @GLIB_REQUIRED@
GREP = @GREP@
GTKDOC_CHECK = @GTKDOC_CHECK@
GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
GTKDOC_MKPDF = @GTKDOC_MKPDF@
GTKDOC_REBASE = @GTKDOC_REBASE@
GTK_TEST_CFLAGS = @GTK_TEST_CFLAGS@
GTK_TEST_LIBS = @GTK_TEST_LIBS@
HTML_DIR = @HTML_DIR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@
INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@
INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@
INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@
INTROSPECTION_LIBS = @INTROSPECTION_LIBS@
INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
LCMS_CFLAGS = @LCMS_CFLAGS@
LCMS_LIBS = @LCMS_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBCURL_CFLAGS = @LIBCURL_CFLAGS@
LIBCURL_LIBS = @LIBCURL_LIBS@
LIBICONV = @LIBICONV@
LIBJPEG_CFLAGS = @LIBJPEG_CFLAGS@
LIBJPEG_LIBS = @LIBJPEG_LIBS@
LIBOBJS = @LIBOBJS@
LIBOPENJPEG_CFLAGS = @LIBOPENJPEG_CFLAGS@
LIBOPENJPEG_LIBS = @LIBOPENJPEG_LIBS@
LIBPNG_CFLAGS = @LIBPNG_CFLAGS@
LIBPNG_LIBS = @LIBPNG_LIBS@
LIBS = @LIBS@
LIBTIFF_CFLAGS = @LIBTIFF_CFLAGS@
LIBTIFF_LIBS = @LIBTIFF_LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MOCQT4 = @MOCQT4@
MOCQT42 = @MOCQT42@
MOCQT5 = @MOCQT5@
MOCQT52 = @MOCQT52@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PC_REQUIRES = @PC_REQUIRES@
PC_REQUIRES_PRIVATE = @PC_REQUIRES_PRIVATE@
PDFTOCAIRO_CFLAGS = @PDFTOCAIRO_CFLAGS@
PDFTOCAIRO_LIBS = @PDFTOCAIRO_LIBS@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POPPLER_DATADIR = @POPPLER_DATADIR@
POPPLER_GLIB_CFLAGS = @POPPLER_GLIB_CFLAGS@
POPPLER_GLIB_DISABLE_DEPRECATED = @POPPLER_GLIB_DISABLE_DEPRECATED@
POPPLER_GLIB_DISABLE_SINGLE_INCLUDES = @POPPLER_GLIB_DISABLE_SINGLE_INCLUDES@
POPPLER_GLIB_LIBS = @POPPLER_GLIB_LIBS@
POPPLER_MAJOR_VERSION = @POPPLER_MAJOR_VERSION@
POPPLER_MICRO_VERSION = @POPPLER_MICRO_VERSION@
POPPLER_MINOR_VERSION = @POPPLER_MINOR_VERSION@
POPPLER_QT4_CFLAGS = @POPPLER_QT4_CFLAGS@
POPPLER_QT4_CXXFLAGS = @POPPLER_QT4_CXXFLAGS@
POPPLER_QT4_LIBS = @POPPLER_QT4_LIBS@
POPPLER_QT4_TEST_CFLAGS = @POPPLER_QT4_TEST_CFLAGS@
POPPLER_QT4_TEST_LIBS = @POPPLER_QT4_TEST_LIBS@
POPPLER_QT5_CFLAGS = @POPPLER_QT5_CFLAGS@
POPPLER_QT5_CXXFLAGS = @POPPLER_QT5_CXXFLAGS@
POPPLER_QT5_LIBS = @POPPLER_QT5_LIBS@
POPPLER_QT5_TEST_CFLAGS = @POPPLER_QT5_TEST_CFLAGS@
POPPLER_QT5_TEST_LIBS = @POPPLER_QT5_TEST_LIBS@
POPPLER_VERSION = @POPPLER_VERSION@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
QTCHOOSER = @QTCHOOSER@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TESTDATADIR = @TESTDATADIR@
VERSION = @VERSION@
XMKMF = @XMKMF@
X_CFLAGS = @X_CFLAGS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
ZLIB_LIBS = @ZLIB_LIBS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
auto_import_flags = @auto_import_flags@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
create_shared_lib = @create_shared_lib@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
win32_libs = @win32_libs@
noinst_LTLIBRARIES = libfofi.la
@ENABLE_XPDF_HEADERS_TRUE@poppler_fofi_includedir = $(includedir)/poppler/fofi
@ENABLE_XPDF_HEADERS_TRUE@poppler_fofi_include_HEADERS = \
@ENABLE_XPDF_HEADERS_TRUE@ FoFiBase.h \
@ENABLE_XPDF_HEADERS_TRUE@ FoFiEncodings.h \
@ENABLE_XPDF_HEADERS_TRUE@ FoFiTrueType.h \
@ENABLE_XPDF_HEADERS_TRUE@ FoFiType1.h \
@ENABLE_XPDF_HEADERS_TRUE@ FoFiIdentifier.h \
@ENABLE_XPDF_HEADERS_TRUE@ FoFiType1C.h
libfofi_la_SOURCES = \
FoFiBase.cc \
FoFiBase.h \
FoFiEncodings.cc \
FoFiEncodings.h \
FoFiTrueType.cc \
FoFiTrueType.h \
FoFiType1.cc \
FoFiType1.h \
FoFiType1C.cc \
FoFiIdentifier.cc \
FoFiType1C.h
libfofi_la_CPPFLAGS = \
-I$(top_srcdir)
all: all-am
.SUFFIXES:
.SUFFIXES: .cc .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign fofi/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign fofi/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libfofi.la: $(libfofi_la_OBJECTS) $(libfofi_la_DEPENDENCIES) $(EXTRA_libfofi_la_DEPENDENCIES)
$(AM_V_CXXLD)$(CXXLINK) $(libfofi_la_OBJECTS) $(libfofi_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfofi_la-FoFiBase.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfofi_la-FoFiEncodings.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfofi_la-FoFiIdentifier.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfofi_la-FoFiTrueType.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfofi_la-FoFiType1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfofi_la-FoFiType1C.Plo@am__quote@
.cc.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
.cc.obj:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cc.lo:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
libfofi_la-FoFiBase.lo: FoFiBase.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libfofi_la-FoFiBase.lo -MD -MP -MF $(DEPDIR)/libfofi_la-FoFiBase.Tpo -c -o libfofi_la-FoFiBase.lo `test -f 'FoFiBase.cc' || echo '$(srcdir)/'`FoFiBase.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libfofi_la-FoFiBase.Tpo $(DEPDIR)/libfofi_la-FoFiBase.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='FoFiBase.cc' object='libfofi_la-FoFiBase.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libfofi_la-FoFiBase.lo `test -f 'FoFiBase.cc' || echo '$(srcdir)/'`FoFiBase.cc
libfofi_la-FoFiEncodings.lo: FoFiEncodings.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libfofi_la-FoFiEncodings.lo -MD -MP -MF $(DEPDIR)/libfofi_la-FoFiEncodings.Tpo -c -o libfofi_la-FoFiEncodings.lo `test -f 'FoFiEncodings.cc' || echo '$(srcdir)/'`FoFiEncodings.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libfofi_la-FoFiEncodings.Tpo $(DEPDIR)/libfofi_la-FoFiEncodings.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='FoFiEncodings.cc' object='libfofi_la-FoFiEncodings.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libfofi_la-FoFiEncodings.lo `test -f 'FoFiEncodings.cc' || echo '$(srcdir)/'`FoFiEncodings.cc
libfofi_la-FoFiTrueType.lo: FoFiTrueType.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libfofi_la-FoFiTrueType.lo -MD -MP -MF $(DEPDIR)/libfofi_la-FoFiTrueType.Tpo -c -o libfofi_la-FoFiTrueType.lo `test -f 'FoFiTrueType.cc' || echo '$(srcdir)/'`FoFiTrueType.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libfofi_la-FoFiTrueType.Tpo $(DEPDIR)/libfofi_la-FoFiTrueType.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='FoFiTrueType.cc' object='libfofi_la-FoFiTrueType.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libfofi_la-FoFiTrueType.lo `test -f 'FoFiTrueType.cc' || echo '$(srcdir)/'`FoFiTrueType.cc
libfofi_la-FoFiType1.lo: FoFiType1.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libfofi_la-FoFiType1.lo -MD -MP -MF $(DEPDIR)/libfofi_la-FoFiType1.Tpo -c -o libfofi_la-FoFiType1.lo `test -f 'FoFiType1.cc' || echo '$(srcdir)/'`FoFiType1.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libfofi_la-FoFiType1.Tpo $(DEPDIR)/libfofi_la-FoFiType1.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='FoFiType1.cc' object='libfofi_la-FoFiType1.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libfofi_la-FoFiType1.lo `test -f 'FoFiType1.cc' || echo '$(srcdir)/'`FoFiType1.cc
libfofi_la-FoFiType1C.lo: FoFiType1C.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libfofi_la-FoFiType1C.lo -MD -MP -MF $(DEPDIR)/libfofi_la-FoFiType1C.Tpo -c -o libfofi_la-FoFiType1C.lo `test -f 'FoFiType1C.cc' || echo '$(srcdir)/'`FoFiType1C.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libfofi_la-FoFiType1C.Tpo $(DEPDIR)/libfofi_la-FoFiType1C.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='FoFiType1C.cc' object='libfofi_la-FoFiType1C.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libfofi_la-FoFiType1C.lo `test -f 'FoFiType1C.cc' || echo '$(srcdir)/'`FoFiType1C.cc
libfofi_la-FoFiIdentifier.lo: FoFiIdentifier.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libfofi_la-FoFiIdentifier.lo -MD -MP -MF $(DEPDIR)/libfofi_la-FoFiIdentifier.Tpo -c -o libfofi_la-FoFiIdentifier.lo `test -f 'FoFiIdentifier.cc' || echo '$(srcdir)/'`FoFiIdentifier.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libfofi_la-FoFiIdentifier.Tpo $(DEPDIR)/libfofi_la-FoFiIdentifier.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='FoFiIdentifier.cc' object='libfofi_la-FoFiIdentifier.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libfofi_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libfofi_la-FoFiIdentifier.lo `test -f 'FoFiIdentifier.cc' || echo '$(srcdir)/'`FoFiIdentifier.cc
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-poppler_fofi_includeHEADERS: $(poppler_fofi_include_HEADERS)
@$(NORMAL_INSTALL)
@list='$(poppler_fofi_include_HEADERS)'; test -n "$(poppler_fofi_includedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(poppler_fofi_includedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(poppler_fofi_includedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(poppler_fofi_includedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(poppler_fofi_includedir)" || exit $$?; \
done
uninstall-poppler_fofi_includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(poppler_fofi_include_HEADERS)'; test -n "$(poppler_fofi_includedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(poppler_fofi_includedir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(poppler_fofi_includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-poppler_fofi_includeHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-poppler_fofi_includeHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-poppler_fofi_includeHEADERS install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-poppler_fofi_includeHEADERS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

135
thirdparty/poppler/goo/FixedPoint.cc vendored Normal file
View file

@ -0,0 +1,135 @@
//========================================================================
//
// FixedPoint.cc
//
// Fixed point type, with C++ operators.
//
// Copyright 2004 Glyph & Cog, LLC
//
//========================================================================
#include <config.h>
#if USE_FIXEDPOINT
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include "FixedPoint.h"
#define ln2 ((FixedPoint)0.69314718)
#define ln2 ((FixedPoint)0.69314718)
FixedPoint FixedPoint::sqrt(FixedPoint x) {
FixedPoint y0, y1, z;
if (x.val <= 0) {
y1.val = 0;
} else {
y1.val = x.val == 1 ? 2 : x.val >> 1;
do {
y0.val = y1.val;
z = x / y0;
y1.val = (y0.val + z.val) >> 1;
} while (::abs(y0.val - y1.val) > 1);
}
return y1;
}
FixedPoint FixedPoint::pow(FixedPoint x, FixedPoint y) {
FixedPoint t, t2, lnx0, lnx, z0, z;
int d, n, i;
if (y.val <= 0) {
z.val = 0;
} else {
// y * ln(x)
t = (x - 1) / (x + 1);
t2 = t * t;
d = 1;
lnx = 0;
do {
lnx0 = lnx;
lnx += t / d;
t *= t2;
d += 2;
} while (::abs(lnx.val - lnx0.val) > 2);
lnx.val <<= 1;
t = y * lnx;
// exp(y * ln(x))
n = floor(t / ln2);
t -= ln2 * n;
t2 = t;
d = 1;
i = 1;
z = 1;
do {
z0 = z;
z += t2 / d;
t2 *= t;
++i;
d *= i;
} while (::abs(z.val - z0.val) > 2 && d < (1 << fixptShift));
if (n >= 0) {
z.val <<= n;
} else if (n < 0) {
z.val >>= -n;
}
}
return z;
}
int FixedPoint::mul(int x, int y) {
FixPtInt64 z;
z = ((FixPtInt64)x * y) >> fixptShift;
if (z > 0x7fffffffLL) {
return 0x7fffffff;
} else if (z < -0x80000000LL) {
return 0x80000000;
} else {
return (int)z;
}
}
int FixedPoint::div(int x, int y) {
FixPtInt64 z;
z = ((FixPtInt64)x << fixptShift) / y;
if (z > 0x7fffffffLL) {
return 0x7fffffff;
} else if (z < -0x80000000LL) {
return 0x80000000;
} else {
return (int)z;
}
}
GBool FixedPoint::divCheck(FixedPoint x, FixedPoint y, FixedPoint *result) {
FixPtInt64 z;
z = ((FixPtInt64)x.val << fixptShift) / y.val;
if ((z == 0 && x != 0) ||
z >= ((FixPtInt64)1 << 31) || z < -((FixPtInt64)1 << 31)) {
return gFalse;
}
result->val = z;
return gTrue;
}
GBool FixedPoint::checkDet(FixedPoint m11, FixedPoint m12,
FixedPoint m21, FixedPoint m22,
FixedPoint epsilon) {
FixPtInt64 det, e;
det = (FixPtInt64)m11.val * (FixPtInt64)m22.val
- (FixPtInt64)m12.val * (FixPtInt64)m21.val;
e = (FixPtInt64)epsilon.val << fixptShift;
// NB: this comparison has to be >= not > because epsilon can be
// truncated to zero as a fixed point value.
return det >= e || det <= -e;
}
#endif // USE_FIXEDPOINT

166
thirdparty/poppler/goo/FixedPoint.h vendored Normal file
View file

@ -0,0 +1,166 @@
//========================================================================
//
// FixedPoint.h
//
// Fixed point type, with C++ operators.
//
// Copyright 2004 Glyph & Cog, LLC
//
//========================================================================
#ifndef FIXEDPOINT_H
#define FIXEDPOINT_H
#include "poppler-config.h"
#if USE_FIXEDPOINT
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include <stdio.h>
#include <stdlib.h>
#include "gtypes.h"
#define fixptShift 16
#define fixptMaskL ((1 << fixptShift) - 1)
#define fixptMaskH (~fixptMaskL)
typedef long long FixPtInt64;
class FixedPoint {
public:
FixedPoint() { val = 0; }
FixedPoint(const FixedPoint &x) { val = x.val; }
FixedPoint(double x) { val = (int)(x * (1 << fixptShift) + 0.5); }
FixedPoint(int x) { val = x << fixptShift; }
FixedPoint(long x) { val = x << fixptShift; }
operator float()
{ return (float) val * ((float)1 / (float)(1 << fixptShift)); }
operator double()
{ return (double) val * (1.0 / (double)(1 << fixptShift)); }
operator int()
{ return val >> fixptShift; }
int get16Dot16() { return val; }
FixedPoint operator =(FixedPoint x) { val = x.val; return *this; }
int operator ==(FixedPoint x) { return val == x.val; }
int operator ==(double x) { return *this == (FixedPoint)x; }
int operator ==(int x) { return *this == (FixedPoint)x; }
int operator ==(long x) { return *this == (FixedPoint)x; }
int operator !=(FixedPoint x) { return val != x.val; }
int operator !=(double x) { return *this != (FixedPoint)x; }
int operator !=(int x) { return *this != (FixedPoint)x; }
int operator !=(long x) { return *this != (FixedPoint)x; }
int operator <(FixedPoint x) { return val < x.val; }
int operator <(double x) { return *this < (FixedPoint)x; }
int operator <(int x) { return *this < (FixedPoint)x; }
int operator <(long x) { return *this < (FixedPoint)x; }
int operator <=(FixedPoint x) { return val <= x.val; }
int operator <=(double x) { return *this <= (FixedPoint)x; }
int operator <=(int x) { return *this <= (FixedPoint)x; }
int operator <=(long x) { return *this <= (FixedPoint)x; }
int operator >(FixedPoint x) { return val > x.val; }
int operator >(double x) { return *this > (FixedPoint)x; }
int operator >(int x) { return *this > (FixedPoint)x; }
int operator >(long x) { return *this > (FixedPoint)x; }
int operator >=(FixedPoint x) { return val >= x.val; }
int operator >=(double x) { return *this >= (FixedPoint)x; }
int operator >=(int x) { return *this >= (FixedPoint)x; }
int operator >=(long x) { return *this >= (FixedPoint)x; }
FixedPoint operator -() { return make(-val); }
FixedPoint operator +(FixedPoint x) { return make(val + x.val); }
FixedPoint operator +(double x) { return *this + (FixedPoint)x; }
FixedPoint operator +(int x) { return *this + (FixedPoint)x; }
FixedPoint operator +(long x) { return *this + (FixedPoint)x; }
FixedPoint operator +=(FixedPoint x) { val = val + x.val; return *this; }
FixedPoint operator +=(double x) { return *this += (FixedPoint)x; }
FixedPoint operator +=(int x) { return *this += (FixedPoint)x; }
FixedPoint operator +=(long x) { return *this += (FixedPoint)x; }
FixedPoint operator -(FixedPoint x) { return make(val - x.val); }
FixedPoint operator -(double x) { return *this - (FixedPoint)x; }
FixedPoint operator -(int x) { return *this - (FixedPoint)x; }
FixedPoint operator -(long x) { return *this - (FixedPoint)x; }
FixedPoint operator -=(FixedPoint x) { val = val - x.val; return *this; }
FixedPoint operator -=(double x) { return *this -= (FixedPoint)x; }
FixedPoint operator -=(int x) { return *this -= (FixedPoint)x; }
FixedPoint operator -=(long x) { return *this -= (FixedPoint)x; }
FixedPoint operator *(FixedPoint x) { return make(mul(val, x.val)); }
FixedPoint operator *(double x) { return *this * (FixedPoint)x; }
FixedPoint operator *(int x) { return *this * (FixedPoint)x; }
FixedPoint operator *(long x) { return *this * (FixedPoint)x; }
FixedPoint operator *=(FixedPoint x) { val = mul(val, x.val); return *this; }
FixedPoint operator *=(double x) { return *this *= (FixedPoint)x; }
FixedPoint operator *=(int x) { return *this *= (FixedPoint)x; }
FixedPoint operator *=(long x) { return *this *= (FixedPoint)x; }
FixedPoint operator /(FixedPoint x) { return make(div(val, x.val)); }
FixedPoint operator /(double x) { return *this / (FixedPoint)x; }
FixedPoint operator /(int x) { return *this / (FixedPoint)x; }
FixedPoint operator /(long x) { return *this / (FixedPoint)x; }
FixedPoint operator /=(FixedPoint x) { val = div(val, x.val); return *this; }
FixedPoint operator /=(double x) { return *this /= (FixedPoint)x; }
FixedPoint operator /=(int x) { return *this /= (FixedPoint)x; }
FixedPoint operator /=(long x) { return *this /= (FixedPoint)x; }
static FixedPoint abs(FixedPoint x) { return make(::abs(x.val)); }
static int floor(FixedPoint x) { return x.val >> fixptShift; }
static int ceil(FixedPoint x)
{ return (x.val & fixptMaskL) ? ((x.val >> fixptShift) + 1)
: (x.val >> fixptShift); }
static int round(FixedPoint x)
{ return (x.val + (1 << (fixptShift - 1))) >> fixptShift; }
// Computes (x+y)/2 avoiding overflow and LSbit accuracy issues.
static FixedPoint avg(FixedPoint x, FixedPoint y)
{ return make((x.val >> 1) + (y.val >> 1) + ((x.val | y.val) & 1)); }
static FixedPoint sqrt(FixedPoint x);
static FixedPoint pow(FixedPoint x, FixedPoint y);
// Compute *result = x/y; return false if there is an underflow or
// overflow.
static GBool divCheck(FixedPoint x, FixedPoint y, FixedPoint *result);
// Compute abs(m11*m22 - m12*m21) >= epsilon, handling the case
// where the multiplications overflow.
static GBool checkDet(FixedPoint m11, FixedPoint m12,
FixedPoint m21, FixedPoint m22,
FixedPoint epsilon);
private:
static FixedPoint make(int valA) { FixedPoint x; x.val = valA; return x; }
static int mul(int x, int y);
static int div(int x, int y);
int val; // fixed point: (n-fixptShift).(fixptShift)
};
#endif // USE_FIXEDPOINT
#endif

384
thirdparty/poppler/goo/GooHash.cc vendored Normal file
View file

@ -0,0 +1,384 @@
//========================================================================
//
// GooHash.cc
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include "gmem.h"
#include "GooString.h"
#include "GooHash.h"
//------------------------------------------------------------------------
struct GooHashBucket {
GooString *key;
union {
void *p;
int i;
} val;
GooHashBucket *next;
};
struct GooHashIter {
int h;
GooHashBucket *p;
};
//------------------------------------------------------------------------
GooHash::GooHash(GBool deleteKeysA) {
int h;
deleteKeys = deleteKeysA;
size = 7;
tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *));
for (h = 0; h < size; ++h) {
tab[h] = NULL;
}
len = 0;
}
GooHash::~GooHash() {
GooHashBucket *p;
int h;
for (h = 0; h < size; ++h) {
while (tab[h]) {
p = tab[h];
tab[h] = p->next;
if (deleteKeys) {
delete p->key;
}
delete p;
}
}
gfree(tab);
}
void GooHash::add(GooString *key, void *val) {
GooHashBucket *p;
int h;
// expand the table if necessary
if (len >= size) {
expand();
}
// add the new symbol
p = new GooHashBucket;
p->key = key;
p->val.p = val;
h = hash(key);
p->next = tab[h];
tab[h] = p;
++len;
}
void GooHash::add(GooString *key, int val) {
GooHashBucket *p;
int h;
// expand the table if necessary
if (len >= size) {
expand();
}
// add the new symbol
p = new GooHashBucket;
p->key = key;
p->val.i = val;
h = hash(key);
p->next = tab[h];
tab[h] = p;
++len;
}
void GooHash::replace(GooString *key, void *val) {
GooHashBucket *p;
int h;
if ((p = find(key, &h))) {
p->val.p = val;
if (deleteKeys) {
delete key;
}
} else {
add(key, val);
}
}
void GooHash::replace(GooString *key, int val) {
GooHashBucket *p;
int h;
if ((p = find(key, &h))) {
p->val.i = val;
if (deleteKeys) {
delete key;
}
} else {
add(key, val);
}
}
void *GooHash::lookup(GooString *key) {
GooHashBucket *p;
int h;
if (!(p = find(key, &h))) {
return NULL;
}
return p->val.p;
}
int GooHash::lookupInt(GooString *key) {
GooHashBucket *p;
int h;
if (!(p = find(key, &h))) {
return 0;
}
return p->val.i;
}
void *GooHash::lookup(const char *key) {
GooHashBucket *p;
int h;
if (!(p = find(key, &h))) {
return NULL;
}
return p->val.p;
}
int GooHash::lookupInt(const char *key) {
GooHashBucket *p;
int h;
if (!(p = find(key, &h))) {
return 0;
}
return p->val.i;
}
void *GooHash::remove(GooString *key) {
GooHashBucket *p;
GooHashBucket **q;
void *val;
int h;
if (!(p = find(key, &h))) {
return NULL;
}
q = &tab[h];
while (*q != p) {
q = &((*q)->next);
}
*q = p->next;
if (deleteKeys) {
delete p->key;
}
val = p->val.p;
delete p;
--len;
return val;
}
int GooHash::removeInt(GooString *key) {
GooHashBucket *p;
GooHashBucket **q;
int val;
int h;
if (!(p = find(key, &h))) {
return 0;
}
q = &tab[h];
while (*q != p) {
q = &((*q)->next);
}
*q = p->next;
if (deleteKeys) {
delete p->key;
}
val = p->val.i;
delete p;
--len;
return val;
}
void *GooHash::remove(const char *key) {
GooHashBucket *p;
GooHashBucket **q;
void *val;
int h;
if (!(p = find(key, &h))) {
return NULL;
}
q = &tab[h];
while (*q != p) {
q = &((*q)->next);
}
*q = p->next;
if (deleteKeys) {
delete p->key;
}
val = p->val.p;
delete p;
--len;
return val;
}
int GooHash::removeInt(const char *key) {
GooHashBucket *p;
GooHashBucket **q;
int val;
int h;
if (!(p = find(key, &h))) {
return 0;
}
q = &tab[h];
while (*q != p) {
q = &((*q)->next);
}
*q = p->next;
if (deleteKeys) {
delete p->key;
}
val = p->val.i;
delete p;
--len;
return val;
}
void GooHash::startIter(GooHashIter **iter) {
*iter = new GooHashIter;
(*iter)->h = -1;
(*iter)->p = NULL;
}
GBool GooHash::getNext(GooHashIter **iter, GooString **key, void **val) {
if (!*iter) {
return gFalse;
}
if ((*iter)->p) {
(*iter)->p = (*iter)->p->next;
}
while (!(*iter)->p) {
if (++(*iter)->h == size) {
delete *iter;
*iter = NULL;
return gFalse;
}
(*iter)->p = tab[(*iter)->h];
}
*key = (*iter)->p->key;
*val = (*iter)->p->val.p;
return gTrue;
}
GBool GooHash::getNext(GooHashIter **iter, GooString **key, int *val) {
if (!*iter) {
return gFalse;
}
if ((*iter)->p) {
(*iter)->p = (*iter)->p->next;
}
while (!(*iter)->p) {
if (++(*iter)->h == size) {
delete *iter;
*iter = NULL;
return gFalse;
}
(*iter)->p = tab[(*iter)->h];
}
*key = (*iter)->p->key;
*val = (*iter)->p->val.i;
return gTrue;
}
void GooHash::killIter(GooHashIter **iter) {
delete *iter;
*iter = NULL;
}
void GooHash::expand() {
GooHashBucket **oldTab;
GooHashBucket *p;
int oldSize, h, i;
oldSize = size;
oldTab = tab;
size = 2*size + 1;
tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *));
for (h = 0; h < size; ++h) {
tab[h] = NULL;
}
for (i = 0; i < oldSize; ++i) {
while (oldTab[i]) {
p = oldTab[i];
oldTab[i] = oldTab[i]->next;
h = hash(p->key);
p->next = tab[h];
tab[h] = p;
}
}
gfree(oldTab);
}
GooHashBucket *GooHash::find(GooString *key, int *h) {
GooHashBucket *p;
*h = hash(key);
for (p = tab[*h]; p; p = p->next) {
if (!p->key->cmp(key)) {
return p;
}
}
return NULL;
}
GooHashBucket *GooHash::find(const char *key, int *h) {
GooHashBucket *p;
*h = hash(key);
for (p = tab[*h]; p; p = p->next) {
if (!p->key->cmp(key)) {
return p;
}
}
return NULL;
}
int GooHash::hash(GooString *key) {
const char *p;
unsigned int h;
int i;
h = 0;
for (p = key->getCString(), i = 0; i < key->getLength(); ++p, ++i) {
h = 17 * h + (int)(*p & 0xff);
}
return (int)(h % size);
}
int GooHash::hash(const char *key) {
const char *p;
unsigned int h;
h = 0;
for (p = key; *p; ++p) {
h = 17 * h + (int)(*p & 0xff);
}
return (int)(h % size);
}

92
thirdparty/poppler/goo/GooHash.h vendored Normal file
View file

@ -0,0 +1,92 @@
//========================================================================
//
// GooHash.h
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
//
// 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
//
//========================================================================
#ifndef GHASH_H
#define GHASH_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
class GooString;
struct GooHashBucket;
struct GooHashIter;
//------------------------------------------------------------------------
class GooHash {
public:
GooHash(GBool deleteKeysA = gFalse);
~GooHash();
void add(GooString *key, void *val);
void add(GooString *key, int val);
void replace(GooString *key, void *val);
void replace(GooString *key, int val);
void *lookup(GooString *key);
int lookupInt(GooString *key);
void *lookup(const char *key);
int lookupInt(const char *key);
void *remove(GooString *key);
int removeInt(GooString *key);
void *remove(const char *key);
int removeInt(const char *key);
int getLength() { return len; }
void startIter(GooHashIter **iter);
GBool getNext(GooHashIter **iter, GooString **key, void **val);
GBool getNext(GooHashIter **iter, GooString **key, int *val);
void killIter(GooHashIter **iter);
private:
GooHash(const GooHash &other);
GooHash& operator=(const GooHash &other);
void expand();
GooHashBucket *find(GooString *key, int *h);
GooHashBucket *find(const char *key, int *h);
int hash(GooString *key);
int hash(const char *key);
GBool deleteKeys; // set if key strings should be deleted
int size; // number of buckets
int len; // number of entries
GooHashBucket **tab;
};
#define deleteGooHash(hash, T) \
do { \
GooHash *_hash = (hash); \
{ \
GooHashIter *_iter; \
GooString *_key; \
void *_p; \
_hash->startIter(&_iter); \
while (_hash->getNext(&_iter, &_key, &_p)) { \
delete (T*)_p; \
} \
delete _hash; \
} \
} while(0)
#endif

22
thirdparty/poppler/goo/GooLikely.h vendored Normal file
View file

@ -0,0 +1,22 @@
//========================================================================
//
// GooLikely.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2008 Kees Cook <kees@outflux.net>
//
//========================================================================
#ifndef GOOLIKELY_H
#define GOOLIKELY_H
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
# define likely(x) __builtin_expect((x), 1)
# define unlikely(x) __builtin_expect((x), 0)
#else
# define likely(x) (x)
# define unlikely(x) (x)
#endif
#endif

122
thirdparty/poppler/goo/GooList.cc vendored Normal file
View file

@ -0,0 +1,122 @@
//========================================================================
//
// GooList.cc
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <string.h>
#include "gmem.h"
#include "GooList.h"
//------------------------------------------------------------------------
// GooList
//------------------------------------------------------------------------
GooList::GooList() {
size = 8;
data = (void **)gmallocn(size, sizeof(void*));
length = 0;
inc = 0;
}
GooList::GooList(int sizeA) {
size = sizeA ? sizeA : 8;
data = (void **)gmallocn(size, sizeof(void*));
length = 0;
inc = 0;
}
GooList::~GooList() {
gfree(data);
}
GooList *GooList::copy() {
GooList *ret;
ret = new GooList(length);
ret->length = length;
memcpy(ret->data, data, length * sizeof(void *));
ret->inc = inc;
return ret;
}
void GooList::append(void *p) {
if (length >= size) {
expand();
}
data[length++] = p;
}
void GooList::append(GooList *list) {
int i;
while (length + list->length > size) {
expand();
}
for (i = 0; i < list->length; ++i) {
data[length++] = list->data[i];
}
}
void GooList::insert(int i, void *p) {
if (length >= size) {
expand();
}
if (i < 0) {
i = 0;
}
if (i < length) {
memmove(data+i+1, data+i, (length - i) * sizeof(void *));
}
data[i] = p;
++length;
}
void *GooList::del(int i) {
void *p;
p = data[i];
if (i < length - 1) {
memmove(data+i, data+i+1, (length - i - 1) * sizeof(void *));
}
--length;
if (size - length >= ((inc > 0) ? inc : size/2)) {
shrink();
}
return p;
}
void GooList::sort(int (*cmp)(const void *obj1, const void *obj2)) {
qsort(data, length, sizeof(void *), cmp);
}
void GooList::reverse() {
void *t;
int n, i;
n = length / 2;
for (i = 0; i < n; ++i) {
t = data[i];
data[i] = data[length - 1 - i];
data[length - 1 - i] = t;
}
}
void GooList::expand() {
size += (inc > 0) ? inc : size;
data = (void **)greallocn(data, size, sizeof(void*));
}
void GooList::shrink() {
size -= (inc > 0) ? inc : size/2;
data = (void **)greallocn(data, size, sizeof(void*));
}

120
thirdparty/poppler/goo/GooList.h vendored Normal file
View file

@ -0,0 +1,120 @@
//========================================================================
//
// GooList.h
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
//
// 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
//
//========================================================================
#ifndef GLIST_H
#define GLIST_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "gtypes.h"
//------------------------------------------------------------------------
// GooList
//------------------------------------------------------------------------
class GooList {
public:
// Create an empty list.
GooList();
// Create an empty list with space for <size1> elements.
GooList(int sizeA);
// Destructor - does not free pointed-to objects.
~GooList();
//----- general
// Get the number of elements.
int getLength() { return length; }
// Returns a (shallow) copy of this list.
GooList *copy();
//----- ordered list support
// Return the <i>th element.
// Assumes 0 <= i < length.
void *get(int i) { return data[i]; }
// Replace the <i>th element.
// Assumes 0 <= i < length.
void put(int i, void *p) { data[i] = p; }
// Append an element to the end of the list.
void append(void *p);
// Append another list to the end of this one.
void append(GooList *list);
// Insert an element at index <i>.
// Assumes 0 <= i <= length.
void insert(int i, void *p);
// Deletes and returns the element at index <i>.
// Assumes 0 <= i < length.
void *del(int i);
// Sort the list accoring to the given comparison function.
// NB: this sorts an array of pointers, so the pointer args need to
// be double-dereferenced.
void sort(int (*cmp)(const void *ptr1, const void *ptr2));
// Reverse the list.
void reverse();
//----- control
// Set allocation increment to <inc>. If inc > 0, that many
// elements will be allocated every time the list is expanded.
// If inc <= 0, the list will be doubled in size.
void setAllocIncr(int incA) { inc = incA; }
private:
GooList(const GooList &other);
GooList& operator=(const GooList &other);
void expand();
void shrink();
void **data; // the list elements
int size; // size of data array
int length; // number of elements on list
int inc; // allocation increment
};
#define deleteGooList(list, T) \
do { \
GooList *_list = (list); \
{ \
int _i; \
for (_i = 0; _i < _list->getLength(); ++_i) { \
delete (T*)_list->get(_i); \
} \
delete _list; \
} \
} while (0)
#endif

85
thirdparty/poppler/goo/GooMutex.h vendored Normal file
View file

@ -0,0 +1,85 @@
//========================================================================
//
// GooMutex.h
//
// Portable mutex macros.
//
// Copyright 2002-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com>
// Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com>
// Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de>
//
// 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
//
//========================================================================
#ifndef GMUTEX_H
#define GMUTEX_H
// Usage:
//
// GooMutex m;
// gInitMutex(&m);
// ...
// gLockMutex(&m);
// ... critical section ...
// gUnlockMutex(&m);
// ...
// gDestroyMutex(&m);
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
typedef CRITICAL_SECTION GooMutex;
#define gInitMutex(m) InitializeCriticalSection(m)
#define gDestroyMutex(m) DeleteCriticalSection(m)
#define gLockMutex(m) EnterCriticalSection(m)
#define gUnlockMutex(m) LeaveCriticalSection(m)
#else // assume pthreads
#include <pthread.h>
typedef pthread_mutex_t GooMutex;
inline void gInitMutex(GooMutex *m) {
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(m, &mutexattr);
pthread_mutexattr_destroy(&mutexattr);
}
#define gDestroyMutex(m) pthread_mutex_destroy(m)
#define gLockMutex(m) pthread_mutex_lock(m)
#define gUnlockMutex(m) pthread_mutex_unlock(m)
#endif
class MutexLocker {
public:
MutexLocker(GooMutex *mutexA) : mutex(mutexA) { gLockMutex(mutex); }
~MutexLocker() { gUnlockMutex(mutex); }
private:
GooMutex *mutex;
};
#endif

962
thirdparty/poppler/goo/GooString.cc vendored Normal file
View file

@ -0,0 +1,962 @@
//========================================================================
//
// GooString.cc
//
// Simple variable-length string type.
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2008-2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2011 Kenji Uno <ku@digitaldolphins.jp>
// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2012 Pino Toscano <pino@kde.org>
// Copyright (C) 2013 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2015 William Bader <williambader@hotmail.com>
//
// 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
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <math.h>
#include "gmem.h"
#include "GooString.h"
static const int MAXIMUM_DOUBLE_PREC = 16;
//------------------------------------------------------------------------
union GooStringFormatArg {
int i;
Guint ui;
long l;
Gulong ul;
#ifdef LLONG_MAX
long long ll;
#endif
#ifdef ULLONG_MAX
unsigned long long ull;
#endif
double f;
char c;
char *s;
GooString *gs;
};
enum GooStringFormatType {
fmtIntDecimal,
fmtIntHex,
fmtIntHexUpper,
fmtIntOctal,
fmtIntBinary,
fmtUIntDecimal,
fmtUIntHex,
fmtUIntHexUpper,
fmtUIntOctal,
fmtUIntBinary,
fmtLongDecimal,
fmtLongHex,
fmtLongHexUpper,
fmtLongOctal,
fmtLongBinary,
fmtULongDecimal,
fmtULongHex,
fmtULongHexUpper,
fmtULongOctal,
fmtULongBinary,
#ifdef LLONG_MAX
fmtLongLongDecimal,
fmtLongLongHex,
fmtLongLongHexUpper,
fmtLongLongOctal,
fmtLongLongBinary,
#endif
#ifdef ULLONG_MAX
fmtULongLongDecimal,
fmtULongLongHex,
fmtULongLongHexUpper,
fmtULongLongOctal,
fmtULongLongBinary,
#endif
fmtDouble,
fmtDoubleTrimSmallAware,
fmtDoubleTrim,
fmtChar,
fmtString,
fmtGooString,
fmtSpace
};
static const char *formatStrings[] = {
"d", "x", "X", "o", "b", "ud", "ux", "uX", "uo", "ub",
"ld", "lx", "lX", "lo", "lb", "uld", "ulx", "ulX", "ulo", "ulb",
#ifdef LLONG_MAX
"lld", "llx", "llX", "llo", "llb",
#endif
#ifdef ULLONG_MAX
"ulld", "ullx", "ullX", "ullo", "ullb",
#endif
"f", "gs", "g",
"c",
"s",
"t",
"w",
NULL
};
//------------------------------------------------------------------------
int inline GooString::roundedSize(int len) {
int delta;
if (len <= STR_STATIC_SIZE-1)
return STR_STATIC_SIZE;
delta = len < 256 ? 7 : 255;
return ((len + 1) + delta) & ~delta;
}
// Make sure that the buffer is big enough to contain <newLength> characters
// plus terminating 0.
// We assume that if this is being called from the constructor, <s> was set
// to NULL and <length> was set to 0 to indicate unused string before calling us.
void inline GooString::resize(int newLength) {
char *s1 = s;
if (!s || (roundedSize(length) != roundedSize(newLength))) {
// requires re-allocating data for string
if (newLength < STR_STATIC_SIZE) {
s1 = sStatic;
} else {
// allocate a rounded amount
if (s == sStatic)
s1 = (char*)gmalloc(roundedSize(newLength));
else
s1 = (char*)grealloc(s, roundedSize(newLength));
}
if (s == sStatic || s1 == sStatic) {
// copy the minimum, we only need to if are moving to or
// from sStatic.
// assert(s != s1) the roundedSize condition ensures this
if (newLength < length) {
memcpy(s1, s, newLength);
} else {
memcpy(s1, s, length);
}
if (s != sStatic)
gfree(s);
}
}
s = s1;
length = newLength;
s[length] = '\0';
}
GooString* GooString::Set(const char *s1, int s1Len, const char *s2, int s2Len)
{
int newLen = 0;
char *p;
if (s1) {
if (CALC_STRING_LEN == s1Len) {
s1Len = strlen(s1);
} else
assert(s1Len >= 0);
newLen += s1Len;
}
if (s2) {
if (CALC_STRING_LEN == s2Len) {
s2Len = strlen(s2);
} else
assert(s2Len >= 0);
newLen += s2Len;
}
resize(newLen);
p = s;
if (s1) {
memcpy(p, s1, s1Len);
p += s1Len;
}
if (s2) {
memcpy(p, s2, s2Len);
p += s2Len;
}
return this;
}
GooString::GooString() {
s = NULL;
length = 0;
Set(NULL);
}
GooString::GooString(const char *sA) {
s = NULL;
length = 0;
Set(sA, CALC_STRING_LEN);
}
GooString::GooString(const char *sA, int lengthA) {
s = NULL;
length = 0;
Set(sA, lengthA);
}
GooString::GooString(GooString *str, int idx, int lengthA) {
s = NULL;
length = 0;
assert(idx + lengthA <= str->length);
Set(str->getCString() + idx, lengthA);
}
GooString::GooString(const GooString *str) {
s = NULL;
length = 0;
Set(str->getCString(), str->length);
}
GooString::GooString(GooString *str1, GooString *str2) {
s = NULL;
length = 0;
Set(str1->getCString(), str1->length, str2->getCString(), str2->length);
}
GooString *GooString::fromInt(int x) {
char buf[24]; // enough space for 64-bit ints plus a little extra
char *p;
int len;
formatInt(x, buf, sizeof(buf), gFalse, 0, 10, &p, &len);
return new GooString(p, len);
}
GooString *GooString::format(const char *fmt, ...) {
va_list argList;
GooString *s;
s = new GooString();
va_start(argList, fmt);
s->appendfv(fmt, argList);
va_end(argList);
return s;
}
GooString *GooString::formatv(const char *fmt, va_list argList) {
GooString *s;
s = new GooString();
s->appendfv(fmt, argList);
return s;
}
GooString::~GooString() {
if (s != sStatic)
gfree(s);
}
GooString *GooString::clear() {
resize(0);
return this;
}
GooString *GooString::append(char c) {
return append((const char*)&c, 1);
}
GooString *GooString::append(GooString *str) {
return append(str->getCString(), str->getLength());
}
GooString *GooString::append(const char *str, int lengthA) {
int prevLen = length;
if (CALC_STRING_LEN == lengthA)
lengthA = strlen(str);
resize(length + lengthA);
memcpy(s + prevLen, str, lengthA);
return this;
}
GooString *GooString::appendf(const char *fmt, ...) {
va_list argList;
va_start(argList, fmt);
appendfv(fmt, argList);
va_end(argList);
return this;
}
GooString *GooString::appendfv(const char *fmt, va_list argList) {
GooStringFormatArg *args;
int argsLen, argsSize;
GooStringFormatArg arg;
int idx, width, prec;
GBool reverseAlign, zeroFill;
GooStringFormatType ft;
char buf[65];
int len, i;
const char *p0, *p1;
char *str;
GooStringFormatArg argsBuf[ 8 ];
argsLen = 0;
argsSize = sizeof(argsBuf) / sizeof(argsBuf[0]);
args = argsBuf;
p0 = fmt;
while (*p0) {
if (*p0 == '{') {
++p0;
if (*p0 == '{') {
++p0;
append('{');
} else {
// parse the format string
if (!(*p0 >= '0' && *p0 <= '9')) {
break;
}
idx = *p0 - '0';
for (++p0; *p0 >= '0' && *p0 <= '9'; ++p0) {
idx = 10 * idx + (*p0 - '0');
}
if (*p0 != ':') {
break;
}
++p0;
if (*p0 == '-') {
reverseAlign = gTrue;
++p0;
} else {
reverseAlign = gFalse;
}
width = 0;
zeroFill = *p0 == '0';
for (; *p0 >= '0' && *p0 <= '9'; ++p0) {
width = 10 * width + (*p0 - '0');
}
if (width < 0) {
width = 0;
}
if (*p0 == '.') {
++p0;
prec = 0;
for (; *p0 >= '0' && *p0 <= '9'; ++p0) {
prec = 10 * prec + (*p0 - '0');
}
} else {
prec = 0;
}
for (ft = (GooStringFormatType)0;
formatStrings[ft];
ft = (GooStringFormatType)(ft + 1)) {
if (!strncmp(p0, formatStrings[ft], strlen(formatStrings[ft]))) {
break;
}
}
if (!formatStrings[ft]) {
break;
}
p0 += strlen(formatStrings[ft]);
if (*p0 != '}') {
break;
}
++p0;
// fetch the argument
if (idx > argsLen) {
break;
}
if (idx == argsLen) {
if (argsLen == argsSize) {
argsSize *= 2;
if (args == argsBuf) {
args = (GooStringFormatArg *)gmallocn(argsSize, sizeof(GooStringFormatArg));
memcpy(args, argsBuf, argsLen * sizeof(GooStringFormatArg));
} else {
args = (GooStringFormatArg *)greallocn(args, argsSize,
sizeof(GooStringFormatArg));
}
}
switch (ft) {
case fmtIntDecimal:
case fmtIntHex:
case fmtIntHexUpper:
case fmtIntOctal:
case fmtIntBinary:
case fmtSpace:
args[argsLen].i = va_arg(argList, int);
break;
case fmtUIntDecimal:
case fmtUIntHex:
case fmtUIntHexUpper:
case fmtUIntOctal:
case fmtUIntBinary:
args[argsLen].ui = va_arg(argList, Guint);
break;
case fmtLongDecimal:
case fmtLongHex:
case fmtLongHexUpper:
case fmtLongOctal:
case fmtLongBinary:
args[argsLen].l = va_arg(argList, long);
break;
case fmtULongDecimal:
case fmtULongHex:
case fmtULongHexUpper:
case fmtULongOctal:
case fmtULongBinary:
args[argsLen].ul = va_arg(argList, Gulong);
break;
#ifdef LLONG_MAX
case fmtLongLongDecimal:
case fmtLongLongHex:
case fmtLongLongHexUpper:
case fmtLongLongOctal:
case fmtLongLongBinary:
args[argsLen].ll = va_arg(argList, long long);
break;
#endif
#ifdef ULLONG_MAX
case fmtULongLongDecimal:
case fmtULongLongHex:
case fmtULongLongHexUpper:
case fmtULongLongOctal:
case fmtULongLongBinary:
args[argsLen].ull = va_arg(argList, unsigned long long);
break;
#endif
case fmtDouble:
case fmtDoubleTrim:
case fmtDoubleTrimSmallAware:
args[argsLen].f = va_arg(argList, double);
break;
case fmtChar:
args[argsLen].c = (char)va_arg(argList, int);
break;
case fmtString:
args[argsLen].s = va_arg(argList, char *);
break;
case fmtGooString:
args[argsLen].gs = va_arg(argList, GooString *);
break;
}
++argsLen;
}
// format the argument
arg = args[idx];
switch (ft) {
case fmtIntDecimal:
formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 10, &str, &len);
break;
case fmtIntHex:
formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 16, &str, &len);
break;
case fmtIntHexUpper:
formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 16, &str, &len,
gTrue);
break;
case fmtIntOctal:
formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 8, &str, &len);
break;
case fmtIntBinary:
formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 2, &str, &len);
break;
case fmtUIntDecimal:
formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 10,
&str, &len);
break;
case fmtUIntHex:
formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 16,
&str, &len);
break;
case fmtUIntHexUpper:
formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 16,
&str, &len, gTrue);
break;
case fmtUIntOctal:
formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 8, &str, &len);
break;
case fmtUIntBinary:
formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 2, &str, &len);
break;
case fmtLongDecimal:
formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 10, &str, &len);
break;
case fmtLongHex:
formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 16, &str, &len);
break;
case fmtLongHexUpper:
formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 16, &str, &len,
gTrue);
break;
case fmtLongOctal:
formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 8, &str, &len);
break;
case fmtLongBinary:
formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 2, &str, &len);
break;
case fmtULongDecimal:
formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 10,
&str, &len);
break;
case fmtULongHex:
formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 16,
&str, &len);
break;
case fmtULongHexUpper:
formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 16,
&str, &len, gTrue);
break;
case fmtULongOctal:
formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 8, &str, &len);
break;
case fmtULongBinary:
formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 2, &str, &len);
break;
#ifdef LLONG_MAX
case fmtLongLongDecimal:
formatInt(arg.ll, buf, sizeof(buf), zeroFill, width, 10, &str, &len);
break;
case fmtLongLongHex:
formatInt(arg.ll, buf, sizeof(buf), zeroFill, width, 16, &str, &len);
break;
case fmtLongLongHexUpper:
formatInt(arg.ll, buf, sizeof(buf), zeroFill, width, 16, &str, &len,
gTrue);
break;
case fmtLongLongOctal:
formatInt(arg.ll, buf, sizeof(buf), zeroFill, width, 8, &str, &len);
break;
case fmtLongLongBinary:
formatInt(arg.ll, buf, sizeof(buf), zeroFill, width, 2, &str, &len);
break;
#endif
#ifdef ULLONG_MAX
case fmtULongLongDecimal:
formatUInt(arg.ull, buf, sizeof(buf), zeroFill, width, 10,
&str, &len);
break;
case fmtULongLongHex:
formatUInt(arg.ull, buf, sizeof(buf), zeroFill, width, 16,
&str, &len);
break;
case fmtULongLongHexUpper:
formatUInt(arg.ull, buf, sizeof(buf), zeroFill, width, 16,
&str, &len, gTrue);
break;
case fmtULongLongOctal:
formatUInt(arg.ull, buf, sizeof(buf), zeroFill, width, 8,
&str, &len);
break;
case fmtULongLongBinary:
formatUInt(arg.ull, buf, sizeof(buf), zeroFill, width, 2,
&str, &len);
break;
#endif
case fmtDouble:
formatDouble(arg.f, buf, sizeof(buf), prec, gFalse, &str, &len);
break;
case fmtDoubleTrim:
formatDouble(arg.f, buf, sizeof(buf), prec, gTrue, &str, &len);
break;
case fmtDoubleTrimSmallAware:
formatDoubleSmallAware(arg.f, buf, sizeof(buf), prec, gTrue, &str, &len);
break;
case fmtChar:
buf[0] = arg.c;
str = buf;
len = 1;
reverseAlign = !reverseAlign;
break;
case fmtString:
str = arg.s;
len = strlen(str);
reverseAlign = !reverseAlign;
break;
case fmtGooString:
str = arg.gs->getCString();
len = arg.gs->getLength();
reverseAlign = !reverseAlign;
break;
case fmtSpace:
str = buf;
len = 0;
width = arg.i;
break;
}
// append the formatted arg, handling width and alignment
if (!reverseAlign && len < width) {
for (i = len; i < width; ++i) {
append(' ');
}
}
append(str, len);
if (reverseAlign && len < width) {
for (i = len; i < width; ++i) {
append(' ');
}
}
}
} else if (*p0 == '}') {
++p0;
if (*p0 == '}') {
++p0;
}
append('}');
} else {
for (p1 = p0 + 1; *p1 && *p1 != '{' && *p1 != '}'; ++p1) ;
append(p0, p1 - p0);
p0 = p1;
}
}
if (args != argsBuf) {
gfree(args);
}
return this;
}
static const char lowerCaseDigits[17] = "0123456789abcdef";
static const char upperCaseDigits[17] = "0123456789ABCDEF";
#ifdef LLONG_MAX
void GooString::formatInt(long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase) {
#else
void GooString::formatInt(long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase) {
#endif
const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits;
GBool neg;
int start, i, j;
#ifdef LLONG_MAX
unsigned long long abs_x;
#else
unsigned long abs_x;
#endif
i = bufSize;
if ((neg = x < 0)) {
abs_x = -x;
} else {
abs_x = x;
}
start = neg ? 1 : 0;
if (abs_x == 0) {
buf[--i] = '0';
} else {
while (i > start && abs_x) {
buf[--i] = vals[abs_x % base];
abs_x /= base;
}
}
if (zeroFill) {
for (j = bufSize - i; i > start && j < width - start; ++j) {
buf[--i] = '0';
}
}
if (neg) {
buf[--i] = '-';
}
*p = buf + i;
*len = bufSize - i;
}
#ifdef ULLONG_MAX
void GooString::formatUInt(unsigned long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase) {
#else
void GooString::formatUInt(Gulong x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase) {
#endif
const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits;
int i, j;
i = bufSize;
if (x == 0) {
buf[--i] = '0';
} else {
while (i > 0 && x) {
buf[--i] = vals[x % base];
x /= base;
}
}
if (zeroFill) {
for (j = bufSize - i; i > 0 && j < width; ++j) {
buf[--i] = '0';
}
}
*p = buf + i;
*len = bufSize - i;
}
void GooString::formatDouble(double x, char *buf, int bufSize, int prec,
GBool trim, char **p, int *len) {
GBool neg, started;
double x2;
int d, i, j;
if ((neg = x < 0)) {
x = -x;
}
x = floor(x * pow(10.0, prec) + 0.5);
i = bufSize;
started = !trim;
for (j = 0; j < prec && i > 1; ++j) {
x2 = floor(0.1 * (x + 0.5));
d = (int)floor(x - 10 * x2 + 0.5);
if (started || d != 0) {
buf[--i] = '0' + d;
started = gTrue;
}
x = x2;
}
if (i > 1 && started) {
buf[--i] = '.';
}
if (i > 1) {
do {
x2 = floor(0.1 * (x + 0.5));
d = (int)floor(x - 10 * x2 + 0.5);
buf[--i] = '0' + d;
x = x2;
} while (i > 1 && x);
}
if (neg) {
buf[--i] = '-';
}
*p = buf + i;
*len = bufSize - i;
}
void GooString::formatDoubleSmallAware(double x, char *buf, int bufSize, int prec,
GBool trim, char **p, int *len)
{
double absX = fabs(x);
if (absX >= 0.1) {
formatDouble(x, buf, bufSize, prec, trim, p, len);
} else {
while (absX < 0.1 && prec < MAXIMUM_DOUBLE_PREC)
{
absX = absX * 10;
prec++;
}
formatDouble(x, buf, bufSize, prec, trim, p, len);
}
}
GooString *GooString::insert(int i, char c) {
return insert(i, (const char*)&c, 1);
}
GooString *GooString::insert(int i, GooString *str) {
return insert(i, str->getCString(), str->getLength());
}
GooString *GooString::insert(int i, const char *str, int lengthA) {
int prevLen = length;
if (CALC_STRING_LEN == lengthA)
lengthA = strlen(str);
resize(length + lengthA);
memmove(s+i+lengthA, s+i, prevLen-i);
memcpy(s+i, str, lengthA);
return this;
}
GooString *GooString::del(int i, int n) {
int j;
if (i >= 0 && n > 0 && i + n > 0) {
if (i + n > length) {
n = length - i;
}
for (j = i; j <= length - n; ++j) {
s[j] = s[j + n];
}
resize(length - n);
}
return this;
}
GooString *GooString::upperCase() {
int i;
for (i = 0; i < length; ++i) {
if (islower(s[i]))
s[i] = toupper(s[i]);
}
return this;
}
GooString *GooString::lowerCase() {
int i;
for (i = 0; i < length; ++i) {
if (isupper(s[i]))
s[i] = tolower(s[i]);
}
return this;
}
int GooString::cmp(GooString *str) const {
int n1, n2, i, x;
char *p1, *p2;
n1 = length;
n2 = str->length;
for (i = 0, p1 = s, p2 = str->s; i < n1 && i < n2; ++i, ++p1, ++p2) {
x = *p1 - *p2;
if (x != 0) {
return x;
}
}
return n1 - n2;
}
int GooString::cmpN(GooString *str, int n) const {
int n1, n2, i, x;
char *p1, *p2;
n1 = length;
n2 = str->length;
for (i = 0, p1 = s, p2 = str->s;
i < n1 && i < n2 && i < n;
++i, ++p1, ++p2) {
x = *p1 - *p2;
if (x != 0) {
return x;
}
}
if (i == n) {
return 0;
}
return n1 - n2;
}
int GooString::cmp(const char *sA) const {
int n1, i, x;
const char *p1, *p2;
n1 = length;
for (i = 0, p1 = s, p2 = sA; i < n1 && *p2; ++i, ++p1, ++p2) {
x = *p1 - *p2;
if (x != 0) {
return x;
}
}
if (i < n1) {
return 1;
}
if (*p2) {
return -1;
}
return 0;
}
int GooString::cmpN(const char *sA, int n) const {
int n1, i, x;
const char *p1, *p2;
n1 = length;
for (i = 0, p1 = s, p2 = sA; i < n1 && *p2 && i < n; ++i, ++p1, ++p2) {
x = *p1 - *p2;
if (x != 0) {
return x;
}
}
if (i == n) {
return 0;
}
if (i < n1) {
return 1;
}
if (*p2) {
return -1;
}
return 0;
}
GBool GooString::endsWith(const char *suffix) const {
int suffixLen = strlen(suffix);
if (length < suffixLen)
return gFalse;
return strcmp(s + length - suffixLen, suffix) == 0;
}
GBool GooString::hasUnicodeMarker(void)
{
return length > 1 && (s[0] & 0xff) == 0xfe && (s[1] & 0xff) == 0xff;
}
GooString *GooString::sanitizedName(GBool psmode)
{
GooString *name;
char buf[8];
int i;
char c;
name = new GooString();
if (psmode)
{
// ghostscript chokes on names that begin with out-of-limits
// numbers, e.g., 1e4foo is handled correctly (as a name), but
// 1e999foo generates a limitcheck error
c = getChar(0);
if (c >= '0' && c <= '9') {
name->append('f');
}
}
for (i = 0; i < getLength(); ++i) {
c = getChar(i);
if (c <= (char)0x20 || c >= (char)0x7f ||
c == ' ' ||
c == '(' || c == ')' || c == '<' || c == '>' ||
c == '[' || c == ']' || c == '{' || c == '}' ||
c == '/' || c == '%' || c == '#') {
sprintf(buf, "#%02x", c & 0xff);
name->append(buf);
} else {
name->append(c);
}
}
return name;
}

218
thirdparty/poppler/goo/GooString.h vendored Normal file
View file

@ -0,0 +1,218 @@
//========================================================================
//
// GooString.h
//
// Simple variable-length string type.
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008-2010, 2012, 2014 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2015 Adam Reichold <adam.reichold@t-online.de>
//
// 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
//
//========================================================================
#ifndef GooString_H
#define GooString_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include <limits.h> // for LLONG_MAX and ULLONG_MAX
#include <stdarg.h>
#include <stdlib.h> // for NULL
#include "gtypes.h"
#ifdef __clang__
# define GOOSTRING_FORMAT __attribute__((__annotate__("gooformat")))
#else
# define GOOSTRING_FORMAT
#endif
class GooString {
public:
// a special value telling that the length of the string is not given
// so it must be calculated from the strings
static const int CALC_STRING_LEN = -1;
// Create an empty string.
GooString();
// Create a string from a C string.
explicit GooString(const char *sA);
// Create a string from <lengthA> chars at <sA>. This string
// can contain null characters.
GooString(const char *sA, int lengthA);
// Create a string from <lengthA> chars at <idx> in <str>.
GooString(GooString *str, int idx, int lengthA);
// Set content of a string to concatination of <s1> and <s2>. They can both
// be NULL. if <s1Len> or <s2Len> is CALC_STRING_LEN, then length of the string
// will be calculated with strlen(). Otherwise we assume they are a valid
// length of string (or its substring)
GooString* Set(const char *s1, int s1Len=CALC_STRING_LEN, const char *s2=NULL, int s2Len=CALC_STRING_LEN);
// Copy a string.
explicit GooString(const GooString *str);
GooString *copy() const { return new GooString(this); }
// Concatenate two strings.
GooString(GooString *str1, GooString *str2);
// Convert an integer to a string.
static GooString *fromInt(int x);
// Create a formatted string. Similar to printf, but without the
// string overflow issues. Formatting elements consist of:
// {<arg>:[<width>][.<precision>]<type>}
// where:
// - <arg> is the argument number (arg 0 is the first argument
// following the format string) -- NB: args must be first used in
// order; they can be reused in any order
// - <width> is the field width -- negative to reverse the alignment;
// starting with a leading zero to zero-fill (for integers)
// - <precision> is the number of digits to the right of the decimal
// point (for floating point numbers)
// - <type> is one of:
// d, x, X, o, b -- int in decimal, lowercase hex, uppercase hex, octal, binary
// ud, ux, uX, uo, ub -- unsigned int
// ld, lx, lX, lo, lb, uld, ulx, ulX, ulo, ulb -- long, unsigned long
// lld, llx, llX, llo, llb, ulld, ullx, ullX, ullo, ullb
// -- long long, unsigned long long
// f, g, gs -- floating point (float or double)
// f -- always prints trailing zeros (eg 1.0 with .2f will print 1.00)
// g -- omits trailing zeros and, if possible, the dot (eg 1.0 shows up as 1)
// gs -- is like g, but treats <precision> as number of significant
// digits to show (eg 0.0123 with .2gs will print 0.012)
// c -- character (char, short or int)
// s -- string (char *)
// t -- GooString *
// w -- blank space; arg determines width
// To get literal curly braces, use {{ or }}.
static GooString *format(const char *fmt, ...) GOOSTRING_FORMAT;
static GooString *formatv(const char *fmt, va_list argList);
// Destructor.
~GooString();
// Get length.
int getLength() const { return length; }
// Get C string.
char *getCString() { return s; }
const char *getCString() const { return s; }
// Get <i>th character.
char getChar(int i) const { return s[i]; }
// Change <i>th character.
void setChar(int i, char c) { s[i] = c; }
// Clear string to zero length.
GooString *clear();
// Append a character or string.
GooString *append(char c);
GooString *append(GooString *str);
GooString *append(const char *str, int lengthA=CALC_STRING_LEN);
// Append a formatted string.
GooString *appendf(const char *fmt, ...) GOOSTRING_FORMAT;
GooString *appendfv(const char *fmt, va_list argList);
// Insert a character or string.
GooString *insert(int i, char c);
GooString *insert(int i, GooString *str);
GooString *insert(int i, const char *str, int lengthA=CALC_STRING_LEN);
// Delete a character or range of characters.
GooString *del(int i, int n = 1);
// Convert string to all-upper/all-lower case.
GooString *upperCase();
GooString *lowerCase();
// Compare two strings: -1:< 0:= +1:>
int cmp(GooString *str) const;
int cmpN(GooString *str, int n) const;
int cmp(const char *sA) const;
int cmpN(const char *sA, int n) const;
// Return true if string ends with suffix
GBool endsWith(const char *suffix) const;
GBool hasUnicodeMarker(void);
// Sanitizes the string so that it does
// not contain any ( ) < > [ ] { } / %
// The postscript mode also has some more strict checks
// The caller owns the return value
GooString *sanitizedName(GBool psmode);
private:
GooString(const GooString &other);
GooString& operator=(const GooString &other);
// You can tweak the final object size for different time/space tradeoffs.
// In libc malloc(), rounding is 16 so it's best to choose a value that
// is a multiple of 16.
class MemoryLayout {
char c[sizeof(char*)];
int i;
char* s;
};
static const int STR_FINAL_SIZE = 32;
static const int STR_STATIC_SIZE = STR_FINAL_SIZE - sizeof(MemoryLayout) + sizeof(char*);
int roundedSize(int len);
char sStatic[STR_STATIC_SIZE];
int length;
char *s;
void resize(int newLength);
#ifdef LLONG_MAX
static void formatInt(long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase = gFalse);
#else
static void formatInt(long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase = gFalse);
#endif
#ifdef ULLONG_MAX
static void formatUInt(unsigned long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase = gFalse);
#else
static void formatUInt(Gulong x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
char **p, int *len, GBool upperCase = gFalse);
#endif
static void formatDouble(double x, char *buf, int bufSize, int prec,
GBool trim, char **p, int *len);
static void formatDoubleSmallAware(double x, char *buf, int bufSize, int prec,
GBool trim, char **p, int *len);
};
#endif

95
thirdparty/poppler/goo/GooTimer.cc vendored Normal file
View file

@ -0,0 +1,95 @@
//========================================================================
//
// GooTimer.cc
//
// This file is licensed under GPLv2 or later
//
// Copyright 2005 Jonathan Blandford <jrb@redhat.com>
// Copyright 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright 2010 Hib Eris <hib@hiberis.nl>
// Inspired by gtimer.c in glib, which is Copyright 2000 by the GLib Team
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include "GooTimer.h"
#include <string.h>
#define USEC_PER_SEC 1000000
//------------------------------------------------------------------------
// GooTimer
//------------------------------------------------------------------------
GooTimer::GooTimer() {
start();
}
void GooTimer::start() {
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&start_time, NULL);
#elif defined(_WIN32)
QueryPerformanceCounter(&start_time);
#endif
active = true;
}
void GooTimer::stop() {
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&end_time, NULL);
#elif defined(_WIN32)
QueryPerformanceCounter(&end_time);
#endif
active = false;
}
#ifdef HAVE_GETTIMEOFDAY
double GooTimer::getElapsed()
{
double total;
struct timeval elapsed;
if (active)
gettimeofday(&end_time, NULL);
if (start_time.tv_usec > end_time.tv_usec) {
end_time.tv_usec += USEC_PER_SEC;
end_time.tv_sec--;
}
elapsed.tv_usec = end_time.tv_usec - start_time.tv_usec;
elapsed.tv_sec = end_time.tv_sec - start_time.tv_sec;
total = elapsed.tv_sec + ((double) elapsed.tv_usec / 1e6);
if (total < 0)
total = 0;
return total;
}
#elif defined(_WIN32)
double GooTimer::getElapsed()
{
LARGE_INTEGER freq;
double time_in_secs;
QueryPerformanceFrequency(&freq);
if (active)
QueryPerformanceCounter(&end_time);
time_in_secs = (double)(end_time.QuadPart-start_time.QuadPart)/(double)freq.QuadPart;
return time_in_secs * 1000.0;
}
#else
double GooTimer::getElapsed()
{
#warning "no support for GooTimer"
return 0;
}
#endif

62
thirdparty/poppler/goo/GooTimer.h vendored Normal file
View file

@ -0,0 +1,62 @@
//========================================================================
//
// GooTimer.cc
//
// This file is licensed under GPLv2 or later
//
// Copyright 2005 Jonathan Blandford <jrb@redhat.com>
// Copyright 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright 2010 Hib Eris <hib@hiberis.nl>
// Copyright 2011 Albert Astals cid <aacid@kde.org>
// Copyright 2014 Bogdan Cristea <cristeab@gmail.com>
// Copyright 2014 Peter Breitenlohner <peb@mppmu.mpg.de>
// Inspired by gtimer.c in glib, which is Copyright 2000 by the GLib Team
//
//========================================================================
#ifndef GOOTIMER_H
#define GOOTIMER_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "poppler-config.h"
#include "gtypes.h"
#ifdef HAVE_GETTIMEOFDAY
#include <sys/time.h>
#endif
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#endif
//------------------------------------------------------------------------
// GooTimer
//------------------------------------------------------------------------
class GooTimer {
public:
// Create a new timer.
GooTimer();
void start();
void stop();
double getElapsed();
private:
#ifdef HAVE_GETTIMEOFDAY
struct timeval start_time;
struct timeval end_time;
#elif defined(_WIN32)
LARGE_INTEGER start_time;
LARGE_INTEGER end_time;
#endif
GBool active;
};
#endif

15
thirdparty/poppler/goo/ImgWriter.cc vendored Normal file
View file

@ -0,0 +1,15 @@
//========================================================================
//
// ImgWriter.cpp
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
//
//========================================================================
#include "ImgWriter.h"
ImgWriter::~ImgWriter()
{
}

33
thirdparty/poppler/goo/ImgWriter.h vendored Normal file
View file

@ -0,0 +1,33 @@
//========================================================================
//
// ImgWriter.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2010 Brian Cameron <brian.cameron@oracle.com>
// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de>
//
//========================================================================
#ifndef IMGWRITER_H
#define IMGWRITER_H
#include <stdio.h>
class ImgWriter
{
public:
virtual ~ImgWriter();
virtual bool init(FILE *f, int width, int height, int hDPI, int vDPI) = 0;
virtual bool writePointers(unsigned char **rowPointers, int rowCount) = 0;
virtual bool writeRow(unsigned char **row) = 0;
virtual bool close() = 0;
virtual bool supportCMYK() { return false; }
};
#endif

184
thirdparty/poppler/goo/JpegWriter.cc vendored Normal file
View file

@ -0,0 +1,184 @@
//========================================================================
//
// JpegWriter.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2010, 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org>
// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de>
//
//========================================================================
#include "JpegWriter.h"
#ifdef ENABLE_LIBJPEG
extern "C" {
#include <jpeglib.h>
}
#include "poppler/Error.h"
struct JpegWriterPrivate {
bool progressive;
int quality;
JpegWriter::Format format;
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
};
void outputMessage(j_common_ptr cinfo)
{
char buffer[JMSG_LENGTH_MAX];
// Create the message
(*cinfo->err->format_message) (cinfo, buffer);
// Send it to poppler's error handler
error(errInternal, -1, "{0:s}", buffer);
}
JpegWriter::JpegWriter(int q, bool p, Format formatA)
{
priv = new JpegWriterPrivate;
priv->progressive = p;
priv->quality = q;
priv->format = formatA;
}
JpegWriter::JpegWriter(Format formatA)
{
priv = new JpegWriterPrivate;
priv->progressive = false;
priv->quality = -1;
priv->format = formatA;
}
JpegWriter::~JpegWriter()
{
// cleanup
jpeg_destroy_compress(&priv->cinfo);
delete priv;
}
bool JpegWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
{
// Setup error handler
priv->cinfo.err = jpeg_std_error(&priv->jerr);
priv->jerr.output_message = &outputMessage;
// Initialize libjpeg
jpeg_create_compress(&priv->cinfo);
// First set colorspace and call jpeg_set_defaults() since
// jpeg_set_defaults() sets default values for all fields in
// cinfo based on the colorspace.
switch (priv->format) {
case RGB:
priv->cinfo.in_color_space = JCS_RGB;
break;
case GRAY:
priv->cinfo.in_color_space = JCS_GRAYSCALE;
break;
case CMYK:
priv->cinfo.in_color_space = JCS_CMYK;
break;
default:
return false;
}
jpeg_set_defaults(&priv->cinfo);
// Set destination file
jpeg_stdio_dest(&priv->cinfo, f);
// Set libjpeg configuration
priv->cinfo.image_width = width;
priv->cinfo.image_height = height;
priv->cinfo.density_unit = 1; // dots per inch
priv->cinfo.X_density = hDPI;
priv->cinfo.Y_density = vDPI;
switch (priv->format) {
case GRAY:
priv->cinfo.input_components = 1;
break;
case RGB:
priv->cinfo.input_components = 3;
break;
case CMYK:
priv->cinfo.input_components = 4;
jpeg_set_colorspace(&priv->cinfo, JCS_YCCK);
priv->cinfo.write_JFIF_header = TRUE;
break;
default:
return false;
}
// Set quality
if (priv->quality >= 0 && priv->quality <= 100) {
jpeg_set_quality(&priv->cinfo, priv->quality, TRUE);
}
// Use progressive mode
if (priv->progressive) {
jpeg_simple_progression(&priv->cinfo);
}
// Get ready for data
jpeg_start_compress(&priv->cinfo, TRUE);
return true;
}
bool JpegWriter::writePointers(unsigned char **rowPointers, int rowCount)
{
if (priv->format == CMYK) {
for (int y = 0; y < rowCount; y++) {
unsigned char *row = rowPointers[y];
for (unsigned int x = 0; x < priv->cinfo.image_width; x++) {
for (int n = 0; n < 4; n++) {
*row = 0xff - *row;
row++;
}
}
}
}
// Write all rows to the file
jpeg_write_scanlines(&priv->cinfo, rowPointers, rowCount);
return true;
}
bool JpegWriter::writeRow(unsigned char **rowPointer)
{
if (priv->format == CMYK) {
unsigned char *row = rowPointer[0];
for (unsigned int x = 0; x < priv->cinfo.image_width; x++) {
for (int n = 0; n < 4; n++) {
*row = 0xff - *row;
row++;
}
}
}
// Write the row to the file
jpeg_write_scanlines(&priv->cinfo, rowPointer, 1);
return true;
}
bool JpegWriter::close()
{
jpeg_finish_compress(&priv->cinfo);
return true;
}
bool JpegWriter::supportCMYK()
{
return priv->format == CMYK;
}
#endif

59
thirdparty/poppler/goo/JpegWriter.h vendored Normal file
View file

@ -0,0 +1,59 @@
//========================================================================
//
// JpegWriter.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2010, 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2010 Jürg Billeter <j@bitron.ch>
// Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org>
// Copyright (C) 2010 Brian Cameron <brian.cameron@oracle.com>
// Copyright (C) 2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de>
//
//========================================================================
#ifndef JPEGWRITER_H
#define JPEGWRITER_H
#include "poppler-config.h"
#ifdef ENABLE_LIBJPEG
#include <sys/types.h>
#include "ImgWriter.h"
struct JpegWriterPrivate;
class JpegWriter : public ImgWriter
{
public:
/* RGB - 3 bytes/pixel
* GRAY - 1 byte/pixel
* CMYK - 4 bytes/pixel
*/
enum Format { RGB, GRAY, CMYK };
JpegWriter(int quality, bool progressive, Format format = RGB);
JpegWriter(Format format = RGB);
~JpegWriter();
bool init(FILE *f, int width, int height, int hDPI, int vDPI);
bool writePointers(unsigned char **rowPointers, int rowCount);
bool writeRow(unsigned char **row);
bool close();
bool supportCMYK();
private:
JpegWriter(const JpegWriter &other);
JpegWriter& operator=(const JpegWriter &other);
JpegWriterPrivate *priv;
};
#endif
#endif

66
thirdparty/poppler/goo/Makefile.am vendored Normal file
View file

@ -0,0 +1,66 @@
noinst_LTLIBRARIES = libgoo.la
if ENABLE_XPDF_HEADERS
poppler_goo_includedir = $(includedir)/poppler/goo
poppler_goo_include_HEADERS = \
GooHash.h \
GooList.h \
GooTimer.h \
GooMutex.h \
GooString.h \
gtypes.h \
gmem.h \
gfile.h \
FixedPoint.h \
NetPBMWriter.h \
PNGWriter.h \
JpegWriter.h \
TiffWriter.h \
ImgWriter.h \
GooLikely.h \
gstrtod.h \
grandom.h
endif
libgoo_la_SOURCES = \
gfile.cc \
gmempp.cc \
GooHash.cc \
GooList.cc \
GooTimer.cc \
GooString.cc \
gmem.cc \
FixedPoint.cc \
NetPBMWriter.cc \
PNGWriter.cc \
JpegWriter.cc \
TiffWriter.cc \
ImgWriter.cc \
gtypes_p.h \
gstrtod.cc \
grandom.cc
if BUILD_LIBJPEG
libjpeg_includes = $(LIBJPEG_CFLAGS)
endif
if BUILD_LIBTIFF
libtiff_includes = $(LIBTIFF_CFLAGS)
endif
if BUILD_LIBOPENJPEG
libjpeg2000_includes = $(LIBOPENJPEG_CFLAGS)
endif
if BUILD_LIBPNG
libpng_includes = $(LIBPNG_CFLAGS)
endif
libgoo_la_CPPFLAGS = \
-I$(top_srcdir) \
$(libjpeg_includes) \
$(libtiff_includes) \
$(libjpeg2000_includes) \
$(libpng_includes)

932
thirdparty/poppler/goo/Makefile.in vendored Normal file
View file

@ -0,0 +1,932 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = goo
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/define-dir.m4 $(top_srcdir)/m4/gtk-doc.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/introspection.m4 \
$(top_srcdir)/m4/libjpeg.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am \
$(am__poppler_goo_include_HEADERS_DIST) $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h \
$(top_builddir)/poppler/poppler-config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libgoo_la_LIBADD =
am_libgoo_la_OBJECTS = libgoo_la-gfile.lo libgoo_la-gmempp.lo \
libgoo_la-GooHash.lo libgoo_la-GooList.lo \
libgoo_la-GooTimer.lo libgoo_la-GooString.lo libgoo_la-gmem.lo \
libgoo_la-FixedPoint.lo libgoo_la-NetPBMWriter.lo \
libgoo_la-PNGWriter.lo libgoo_la-JpegWriter.lo \
libgoo_la-TiffWriter.lo libgoo_la-ImgWriter.lo \
libgoo_la-gstrtod.lo libgoo_la-grandom.lo
libgoo_la_OBJECTS = $(am_libgoo_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/poppler
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_@AM_V@)
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
am__v_CXX_0 = @echo " CXX " $@;
am__v_CXX_1 =
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libgoo_la_SOURCES)
DIST_SOURCES = $(libgoo_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__poppler_goo_include_HEADERS_DIST = GooHash.h GooList.h GooTimer.h \
GooMutex.h GooString.h gtypes.h gmem.h gfile.h FixedPoint.h \
NetPBMWriter.h PNGWriter.h JpegWriter.h TiffWriter.h \
ImgWriter.h GooLikely.h gstrtod.h grandom.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(poppler_goo_includedir)"
HEADERS = $(poppler_goo_include_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CAIRO_CFLAGS = @CAIRO_CFLAGS@
CAIRO_FEATURE = @CAIRO_FEATURE@
CAIRO_LIBS = @CAIRO_LIBS@
CAIRO_REQ = @CAIRO_REQ@
CAIRO_VERSION = @CAIRO_VERSION@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
FREETYPE_CONFIG = @FREETYPE_CONFIG@
FREETYPE_LIBS = @FREETYPE_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GLIB_REQ = @GLIB_REQ@
GLIB_REQUIRED = @GLIB_REQUIRED@
GREP = @GREP@
GTKDOC_CHECK = @GTKDOC_CHECK@
GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
GTKDOC_MKPDF = @GTKDOC_MKPDF@
GTKDOC_REBASE = @GTKDOC_REBASE@
GTK_TEST_CFLAGS = @GTK_TEST_CFLAGS@
GTK_TEST_LIBS = @GTK_TEST_LIBS@
HTML_DIR = @HTML_DIR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@
INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@
INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@
INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@
INTROSPECTION_LIBS = @INTROSPECTION_LIBS@
INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
LCMS_CFLAGS = @LCMS_CFLAGS@
LCMS_LIBS = @LCMS_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBCURL_CFLAGS = @LIBCURL_CFLAGS@
LIBCURL_LIBS = @LIBCURL_LIBS@
LIBICONV = @LIBICONV@
LIBJPEG_CFLAGS = @LIBJPEG_CFLAGS@
LIBJPEG_LIBS = @LIBJPEG_LIBS@
LIBOBJS = @LIBOBJS@
LIBOPENJPEG_CFLAGS = @LIBOPENJPEG_CFLAGS@
LIBOPENJPEG_LIBS = @LIBOPENJPEG_LIBS@
LIBPNG_CFLAGS = @LIBPNG_CFLAGS@
LIBPNG_LIBS = @LIBPNG_LIBS@
LIBS = @LIBS@
LIBTIFF_CFLAGS = @LIBTIFF_CFLAGS@
LIBTIFF_LIBS = @LIBTIFF_LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MOCQT4 = @MOCQT4@
MOCQT42 = @MOCQT42@
MOCQT5 = @MOCQT5@
MOCQT52 = @MOCQT52@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PC_REQUIRES = @PC_REQUIRES@
PC_REQUIRES_PRIVATE = @PC_REQUIRES_PRIVATE@
PDFTOCAIRO_CFLAGS = @PDFTOCAIRO_CFLAGS@
PDFTOCAIRO_LIBS = @PDFTOCAIRO_LIBS@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POPPLER_DATADIR = @POPPLER_DATADIR@
POPPLER_GLIB_CFLAGS = @POPPLER_GLIB_CFLAGS@
POPPLER_GLIB_DISABLE_DEPRECATED = @POPPLER_GLIB_DISABLE_DEPRECATED@
POPPLER_GLIB_DISABLE_SINGLE_INCLUDES = @POPPLER_GLIB_DISABLE_SINGLE_INCLUDES@
POPPLER_GLIB_LIBS = @POPPLER_GLIB_LIBS@
POPPLER_MAJOR_VERSION = @POPPLER_MAJOR_VERSION@
POPPLER_MICRO_VERSION = @POPPLER_MICRO_VERSION@
POPPLER_MINOR_VERSION = @POPPLER_MINOR_VERSION@
POPPLER_QT4_CFLAGS = @POPPLER_QT4_CFLAGS@
POPPLER_QT4_CXXFLAGS = @POPPLER_QT4_CXXFLAGS@
POPPLER_QT4_LIBS = @POPPLER_QT4_LIBS@
POPPLER_QT4_TEST_CFLAGS = @POPPLER_QT4_TEST_CFLAGS@
POPPLER_QT4_TEST_LIBS = @POPPLER_QT4_TEST_LIBS@
POPPLER_QT5_CFLAGS = @POPPLER_QT5_CFLAGS@
POPPLER_QT5_CXXFLAGS = @POPPLER_QT5_CXXFLAGS@
POPPLER_QT5_LIBS = @POPPLER_QT5_LIBS@
POPPLER_QT5_TEST_CFLAGS = @POPPLER_QT5_TEST_CFLAGS@
POPPLER_QT5_TEST_LIBS = @POPPLER_QT5_TEST_LIBS@
POPPLER_VERSION = @POPPLER_VERSION@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
QTCHOOSER = @QTCHOOSER@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TESTDATADIR = @TESTDATADIR@
VERSION = @VERSION@
XMKMF = @XMKMF@
X_CFLAGS = @X_CFLAGS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
ZLIB_LIBS = @ZLIB_LIBS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
auto_import_flags = @auto_import_flags@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
create_shared_lib = @create_shared_lib@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
win32_libs = @win32_libs@
noinst_LTLIBRARIES = libgoo.la
@ENABLE_XPDF_HEADERS_TRUE@poppler_goo_includedir = $(includedir)/poppler/goo
@ENABLE_XPDF_HEADERS_TRUE@poppler_goo_include_HEADERS = \
@ENABLE_XPDF_HEADERS_TRUE@ GooHash.h \
@ENABLE_XPDF_HEADERS_TRUE@ GooList.h \
@ENABLE_XPDF_HEADERS_TRUE@ GooTimer.h \
@ENABLE_XPDF_HEADERS_TRUE@ GooMutex.h \
@ENABLE_XPDF_HEADERS_TRUE@ GooString.h \
@ENABLE_XPDF_HEADERS_TRUE@ gtypes.h \
@ENABLE_XPDF_HEADERS_TRUE@ gmem.h \
@ENABLE_XPDF_HEADERS_TRUE@ gfile.h \
@ENABLE_XPDF_HEADERS_TRUE@ FixedPoint.h \
@ENABLE_XPDF_HEADERS_TRUE@ NetPBMWriter.h \
@ENABLE_XPDF_HEADERS_TRUE@ PNGWriter.h \
@ENABLE_XPDF_HEADERS_TRUE@ JpegWriter.h \
@ENABLE_XPDF_HEADERS_TRUE@ TiffWriter.h \
@ENABLE_XPDF_HEADERS_TRUE@ ImgWriter.h \
@ENABLE_XPDF_HEADERS_TRUE@ GooLikely.h \
@ENABLE_XPDF_HEADERS_TRUE@ gstrtod.h \
@ENABLE_XPDF_HEADERS_TRUE@ grandom.h
libgoo_la_SOURCES = \
gfile.cc \
gmempp.cc \
GooHash.cc \
GooList.cc \
GooTimer.cc \
GooString.cc \
gmem.cc \
FixedPoint.cc \
NetPBMWriter.cc \
PNGWriter.cc \
JpegWriter.cc \
TiffWriter.cc \
ImgWriter.cc \
gtypes_p.h \
gstrtod.cc \
grandom.cc
@BUILD_LIBJPEG_TRUE@libjpeg_includes = $(LIBJPEG_CFLAGS)
@BUILD_LIBTIFF_TRUE@libtiff_includes = $(LIBTIFF_CFLAGS)
@BUILD_LIBOPENJPEG_TRUE@libjpeg2000_includes = $(LIBOPENJPEG_CFLAGS)
@BUILD_LIBPNG_TRUE@libpng_includes = $(LIBPNG_CFLAGS)
libgoo_la_CPPFLAGS = \
-I$(top_srcdir) \
$(libjpeg_includes) \
$(libtiff_includes) \
$(libjpeg2000_includes) \
$(libpng_includes)
all: all-am
.SUFFIXES:
.SUFFIXES: .cc .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign goo/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign goo/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libgoo.la: $(libgoo_la_OBJECTS) $(libgoo_la_DEPENDENCIES) $(EXTRA_libgoo_la_DEPENDENCIES)
$(AM_V_CXXLD)$(CXXLINK) $(libgoo_la_OBJECTS) $(libgoo_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-FixedPoint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-GooHash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-GooList.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-GooString.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-GooTimer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-ImgWriter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-JpegWriter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-NetPBMWriter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-PNGWriter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-TiffWriter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-gfile.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-gmem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-gmempp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-grandom.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgoo_la-gstrtod.Plo@am__quote@
.cc.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
.cc.obj:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cc.lo:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
libgoo_la-gfile.lo: gfile.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-gfile.lo -MD -MP -MF $(DEPDIR)/libgoo_la-gfile.Tpo -c -o libgoo_la-gfile.lo `test -f 'gfile.cc' || echo '$(srcdir)/'`gfile.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-gfile.Tpo $(DEPDIR)/libgoo_la-gfile.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gfile.cc' object='libgoo_la-gfile.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-gfile.lo `test -f 'gfile.cc' || echo '$(srcdir)/'`gfile.cc
libgoo_la-gmempp.lo: gmempp.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-gmempp.lo -MD -MP -MF $(DEPDIR)/libgoo_la-gmempp.Tpo -c -o libgoo_la-gmempp.lo `test -f 'gmempp.cc' || echo '$(srcdir)/'`gmempp.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-gmempp.Tpo $(DEPDIR)/libgoo_la-gmempp.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gmempp.cc' object='libgoo_la-gmempp.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-gmempp.lo `test -f 'gmempp.cc' || echo '$(srcdir)/'`gmempp.cc
libgoo_la-GooHash.lo: GooHash.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-GooHash.lo -MD -MP -MF $(DEPDIR)/libgoo_la-GooHash.Tpo -c -o libgoo_la-GooHash.lo `test -f 'GooHash.cc' || echo '$(srcdir)/'`GooHash.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-GooHash.Tpo $(DEPDIR)/libgoo_la-GooHash.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='GooHash.cc' object='libgoo_la-GooHash.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-GooHash.lo `test -f 'GooHash.cc' || echo '$(srcdir)/'`GooHash.cc
libgoo_la-GooList.lo: GooList.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-GooList.lo -MD -MP -MF $(DEPDIR)/libgoo_la-GooList.Tpo -c -o libgoo_la-GooList.lo `test -f 'GooList.cc' || echo '$(srcdir)/'`GooList.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-GooList.Tpo $(DEPDIR)/libgoo_la-GooList.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='GooList.cc' object='libgoo_la-GooList.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-GooList.lo `test -f 'GooList.cc' || echo '$(srcdir)/'`GooList.cc
libgoo_la-GooTimer.lo: GooTimer.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-GooTimer.lo -MD -MP -MF $(DEPDIR)/libgoo_la-GooTimer.Tpo -c -o libgoo_la-GooTimer.lo `test -f 'GooTimer.cc' || echo '$(srcdir)/'`GooTimer.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-GooTimer.Tpo $(DEPDIR)/libgoo_la-GooTimer.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='GooTimer.cc' object='libgoo_la-GooTimer.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-GooTimer.lo `test -f 'GooTimer.cc' || echo '$(srcdir)/'`GooTimer.cc
libgoo_la-GooString.lo: GooString.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-GooString.lo -MD -MP -MF $(DEPDIR)/libgoo_la-GooString.Tpo -c -o libgoo_la-GooString.lo `test -f 'GooString.cc' || echo '$(srcdir)/'`GooString.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-GooString.Tpo $(DEPDIR)/libgoo_la-GooString.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='GooString.cc' object='libgoo_la-GooString.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-GooString.lo `test -f 'GooString.cc' || echo '$(srcdir)/'`GooString.cc
libgoo_la-gmem.lo: gmem.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-gmem.lo -MD -MP -MF $(DEPDIR)/libgoo_la-gmem.Tpo -c -o libgoo_la-gmem.lo `test -f 'gmem.cc' || echo '$(srcdir)/'`gmem.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-gmem.Tpo $(DEPDIR)/libgoo_la-gmem.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gmem.cc' object='libgoo_la-gmem.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-gmem.lo `test -f 'gmem.cc' || echo '$(srcdir)/'`gmem.cc
libgoo_la-FixedPoint.lo: FixedPoint.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-FixedPoint.lo -MD -MP -MF $(DEPDIR)/libgoo_la-FixedPoint.Tpo -c -o libgoo_la-FixedPoint.lo `test -f 'FixedPoint.cc' || echo '$(srcdir)/'`FixedPoint.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-FixedPoint.Tpo $(DEPDIR)/libgoo_la-FixedPoint.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='FixedPoint.cc' object='libgoo_la-FixedPoint.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-FixedPoint.lo `test -f 'FixedPoint.cc' || echo '$(srcdir)/'`FixedPoint.cc
libgoo_la-NetPBMWriter.lo: NetPBMWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-NetPBMWriter.lo -MD -MP -MF $(DEPDIR)/libgoo_la-NetPBMWriter.Tpo -c -o libgoo_la-NetPBMWriter.lo `test -f 'NetPBMWriter.cc' || echo '$(srcdir)/'`NetPBMWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-NetPBMWriter.Tpo $(DEPDIR)/libgoo_la-NetPBMWriter.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='NetPBMWriter.cc' object='libgoo_la-NetPBMWriter.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-NetPBMWriter.lo `test -f 'NetPBMWriter.cc' || echo '$(srcdir)/'`NetPBMWriter.cc
libgoo_la-PNGWriter.lo: PNGWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-PNGWriter.lo -MD -MP -MF $(DEPDIR)/libgoo_la-PNGWriter.Tpo -c -o libgoo_la-PNGWriter.lo `test -f 'PNGWriter.cc' || echo '$(srcdir)/'`PNGWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-PNGWriter.Tpo $(DEPDIR)/libgoo_la-PNGWriter.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='PNGWriter.cc' object='libgoo_la-PNGWriter.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-PNGWriter.lo `test -f 'PNGWriter.cc' || echo '$(srcdir)/'`PNGWriter.cc
libgoo_la-JpegWriter.lo: JpegWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-JpegWriter.lo -MD -MP -MF $(DEPDIR)/libgoo_la-JpegWriter.Tpo -c -o libgoo_la-JpegWriter.lo `test -f 'JpegWriter.cc' || echo '$(srcdir)/'`JpegWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-JpegWriter.Tpo $(DEPDIR)/libgoo_la-JpegWriter.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='JpegWriter.cc' object='libgoo_la-JpegWriter.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-JpegWriter.lo `test -f 'JpegWriter.cc' || echo '$(srcdir)/'`JpegWriter.cc
libgoo_la-TiffWriter.lo: TiffWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-TiffWriter.lo -MD -MP -MF $(DEPDIR)/libgoo_la-TiffWriter.Tpo -c -o libgoo_la-TiffWriter.lo `test -f 'TiffWriter.cc' || echo '$(srcdir)/'`TiffWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-TiffWriter.Tpo $(DEPDIR)/libgoo_la-TiffWriter.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='TiffWriter.cc' object='libgoo_la-TiffWriter.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-TiffWriter.lo `test -f 'TiffWriter.cc' || echo '$(srcdir)/'`TiffWriter.cc
libgoo_la-ImgWriter.lo: ImgWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-ImgWriter.lo -MD -MP -MF $(DEPDIR)/libgoo_la-ImgWriter.Tpo -c -o libgoo_la-ImgWriter.lo `test -f 'ImgWriter.cc' || echo '$(srcdir)/'`ImgWriter.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-ImgWriter.Tpo $(DEPDIR)/libgoo_la-ImgWriter.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ImgWriter.cc' object='libgoo_la-ImgWriter.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-ImgWriter.lo `test -f 'ImgWriter.cc' || echo '$(srcdir)/'`ImgWriter.cc
libgoo_la-gstrtod.lo: gstrtod.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-gstrtod.lo -MD -MP -MF $(DEPDIR)/libgoo_la-gstrtod.Tpo -c -o libgoo_la-gstrtod.lo `test -f 'gstrtod.cc' || echo '$(srcdir)/'`gstrtod.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-gstrtod.Tpo $(DEPDIR)/libgoo_la-gstrtod.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gstrtod.cc' object='libgoo_la-gstrtod.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-gstrtod.lo `test -f 'gstrtod.cc' || echo '$(srcdir)/'`gstrtod.cc
libgoo_la-grandom.lo: grandom.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libgoo_la-grandom.lo -MD -MP -MF $(DEPDIR)/libgoo_la-grandom.Tpo -c -o libgoo_la-grandom.lo `test -f 'grandom.cc' || echo '$(srcdir)/'`grandom.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgoo_la-grandom.Tpo $(DEPDIR)/libgoo_la-grandom.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='grandom.cc' object='libgoo_la-grandom.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libgoo_la-grandom.lo `test -f 'grandom.cc' || echo '$(srcdir)/'`grandom.cc
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-poppler_goo_includeHEADERS: $(poppler_goo_include_HEADERS)
@$(NORMAL_INSTALL)
@list='$(poppler_goo_include_HEADERS)'; test -n "$(poppler_goo_includedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(poppler_goo_includedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(poppler_goo_includedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(poppler_goo_includedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(poppler_goo_includedir)" || exit $$?; \
done
uninstall-poppler_goo_includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(poppler_goo_include_HEADERS)'; test -n "$(poppler_goo_includedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(poppler_goo_includedir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(poppler_goo_includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-poppler_goo_includeHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-poppler_goo_includeHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-poppler_goo_includeHEADERS install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-poppler_goo_includeHEADERS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

84
thirdparty/poppler/goo/NetPBMWriter.cc vendored Normal file
View file

@ -0,0 +1,84 @@
//========================================================================
//
// NetPBMWriter.h
//
// Copyright 1998-2003 Glyph & Cog, LLC
//
//========================================================================
//
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005, 2007, 2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006 Rainer Keller <class321@gmx.de>
// Copyright (C) 2008 Timothy Lee <timothy.lee@siriushk.com>
// Copyright (C) 2008 Vasile Gaburici <gaburici@cs.umd.edu>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2009 William Bader <williambader@hotmail.com>
// Copyright (C) 2010 Jakob Voss <jakob.voss@gbv.de>
// Copyright (C) 2012, 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2013 Thomas Fischer <fischer@unix-ag.uni-kl.de>
//
// 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
//
//========================================================================
#include "poppler-config.h"
#include "NetPBMWriter.h"
// Writer for the NetPBM formats (PBM and PPM)
// This format is documented at:
// http://netpbm.sourceforge.net/doc/pbm.html
// http://netpbm.sourceforge.net/doc/ppm.html
NetPBMWriter::NetPBMWriter(Format formatA) : format(formatA)
{
}
bool NetPBMWriter::init(FILE *f, int widthA, int heightA, int , int )
{
file = f;
width = widthA;
if (format == MONOCHROME) {
fprintf(file, "P4\n");
fprintf(file, "%d %d\n", widthA, heightA);
} else {
fprintf(file, "P6\n");
fprintf(file, "%d %d\n", widthA, heightA);
fprintf(file, "255\n");
}
return true;
}
bool NetPBMWriter::writePointers(unsigned char **rowPointers, int rowCount)
{
for (int i = 0; i < rowCount; i++)
writeRow(&rowPointers[i]);
return true;
}
bool NetPBMWriter::writeRow(unsigned char **row)
{
if (format == MONOCHROME) {
// PBM uses 0 = white, 1 = black so we need to invert the colors
int size = (width + 7)/8;
for (int i = 0; i < size; i++)
fputc((*row)[i] ^ 0xff, file);
} else {
fwrite(*row, 1, width*3, file);
}
return true;
}
bool NetPBMWriter::close()
{
return true;
}

52
thirdparty/poppler/goo/NetPBMWriter.h vendored Normal file
View file

@ -0,0 +1,52 @@
//========================================================================
//
// NetPBMWriter.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010, 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2010 Brian Cameron <brian.cameron@oracle.com>
// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de>
//
//========================================================================
#ifndef NETPBMWRITER_H
#define NETPBMWRITER_H
#include "poppler-config.h"
#include "ImgWriter.h"
// Writer for the NetPBM formats (PBM and PPM)
// This format is documented at:
// http://netpbm.sourceforge.net/doc/pbm.html
// http://netpbm.sourceforge.net/doc/ppm.html
class NetPBMWriter : public ImgWriter
{
public:
/* RGB - 3 bytes/pixel
* MONOCHROME - 8 pixels/byte
*/
enum Format { RGB, MONOCHROME };
NetPBMWriter(Format formatA = RGB);
~NetPBMWriter() {};
bool init(FILE *f, int width, int height, int , int );
bool writePointers(unsigned char **rowPointers, int rowCount);
bool writeRow(unsigned char **row);
bool close();
private:
FILE *file;
Format format;
int width;
};
#endif

189
thirdparty/poppler/goo/PNGWriter.cc vendored Normal file
View file

@ -0,0 +1,189 @@
//========================================================================
//
// PNGWriter.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2009 Warren Toomey <wkt@tuhs.org>
// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com>
// Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2010, 2011, 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2011 Thomas Klausner <wiz@danbala.tuwien.ac.at>
// Copyright (C) 2012 Pino Toscano <pino@kde.org>
//
//========================================================================
#include "PNGWriter.h"
#ifdef ENABLE_LIBPNG
#include <zlib.h>
#include <stdlib.h>
#include <string.h>
#include "poppler/Error.h"
#include "goo/gmem.h"
#include <png.h>
struct PNGWriterPrivate {
PNGWriter::Format format;
png_structp png_ptr;
png_infop info_ptr;
unsigned char *icc_data;
int icc_data_size;
char *icc_name;
bool sRGB_profile;
};
PNGWriter::PNGWriter(Format formatA)
{
priv = new PNGWriterPrivate;
priv->format = formatA;
priv->icc_data = NULL;
priv->icc_data_size = 0;
priv->icc_name = NULL;
priv->sRGB_profile = false;
}
PNGWriter::~PNGWriter()
{
/* cleanup heap allocation */
png_destroy_write_struct(&priv->png_ptr, &priv->info_ptr);
if (priv->icc_data) {
gfree(priv->icc_data);
free(priv->icc_name);
}
delete priv;
}
void PNGWriter::setICCProfile(const char *name, unsigned char *data, int size)
{
priv->icc_data = (unsigned char *)gmalloc(size);
memcpy(priv->icc_data, data, size);
priv->icc_data_size = size;
priv->icc_name = strdup(name);
}
void PNGWriter::setSRGBProfile()
{
priv->sRGB_profile = true;
}
bool PNGWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
{
/* libpng changed the png_set_iCCP() prototype in 1.5.0 */
#if PNG_LIBPNG_VER < 10500
png_charp icc_data_ptr = (png_charp)priv->icc_data;
#else
png_const_bytep icc_data_ptr = (png_const_bytep)priv->icc_data;
#endif
/* initialize stuff */
priv->png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!priv->png_ptr) {
error(errInternal, -1, "png_create_write_struct failed");
return false;
}
priv->info_ptr = png_create_info_struct(priv->png_ptr);
if (!priv->info_ptr) {
error(errInternal, -1, "png_create_info_struct failed");
return false;
}
if (setjmp(png_jmpbuf(priv->png_ptr))) {
error(errInternal, -1, "png_jmpbuf failed");
return false;
}
/* write header */
png_init_io(priv->png_ptr, f);
if (setjmp(png_jmpbuf(priv->png_ptr))) {
error(errInternal, -1, "Error during writing header");
return false;
}
// Set up the type of PNG image and the compression level
png_set_compression_level(priv->png_ptr, Z_BEST_COMPRESSION);
// Silence silly gcc
png_byte bit_depth = -1;
png_byte color_type = -1;
switch (priv->format) {
case RGB:
bit_depth = 8;
color_type = PNG_COLOR_TYPE_RGB;
break;
case RGBA:
bit_depth = 8;
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
break;
case GRAY:
bit_depth = 8;
color_type = PNG_COLOR_TYPE_GRAY;
break;
case MONOCHROME:
bit_depth = 1;
color_type = PNG_COLOR_TYPE_GRAY;
break;
}
png_byte interlace_type = PNG_INTERLACE_NONE;
png_set_IHDR(priv->png_ptr, priv->info_ptr, width, height, bit_depth, color_type, interlace_type, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_set_pHYs(priv->png_ptr, priv->info_ptr, hDPI/0.0254, vDPI/0.0254, PNG_RESOLUTION_METER);
if (priv->icc_data)
png_set_iCCP(priv->png_ptr, priv->info_ptr, priv->icc_name, PNG_COMPRESSION_TYPE_BASE, icc_data_ptr, priv->icc_data_size);
else if (priv->sRGB_profile)
png_set_sRGB(priv->png_ptr, priv->info_ptr, PNG_sRGB_INTENT_RELATIVE);
png_write_info(priv->png_ptr, priv->info_ptr);
if (setjmp(png_jmpbuf(priv->png_ptr))) {
error(errInternal, -1, "error during writing png info bytes");
return false;
}
return true;
}
bool PNGWriter::writePointers(unsigned char **rowPointers, int )
{
png_write_image(priv->png_ptr, rowPointers);
/* write bytes */
if (setjmp(png_jmpbuf(priv->png_ptr))) {
error(errInternal, -1, "Error during writing bytes");
return false;
}
return true;
}
bool PNGWriter::writeRow(unsigned char **row)
{
// Write the row to the file
png_write_rows(priv->png_ptr, row, 1);
if (setjmp(png_jmpbuf(priv->png_ptr))) {
error(errInternal, -1, "error during png row write");
return false;
}
return true;
}
bool PNGWriter::close()
{
/* end write */
png_write_end(priv->png_ptr, priv->info_ptr);
if (setjmp(png_jmpbuf(priv->png_ptr))) {
error(errInternal, -1, "Error during end of write");
return false;
}
return true;
}
#endif

61
thirdparty/poppler/goo/PNGWriter.h vendored Normal file
View file

@ -0,0 +1,61 @@
//========================================================================
//
// PNGWriter.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2009 Warren Toomey <wkt@tuhs.org>
// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com>
// Copyright (C) 2009, 2011-2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2010, 2011, 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2012 Pino Toscano <pino@kde.org>
//
//========================================================================
#ifndef PNGWRITER_H
#define PNGWRITER_H
#include "poppler-config.h"
#ifdef ENABLE_LIBPNG
#include "ImgWriter.h"
struct PNGWriterPrivate;
class PNGWriter : public ImgWriter
{
public:
/* RGB - 3 bytes/pixel
* RGBA - 4 bytes/pixel
* GRAY - 1 byte/pixel
* MONOCHROME - 8 pixels/byte
*/
enum Format { RGB, RGBA, GRAY, MONOCHROME };
PNGWriter(Format format = RGB);
~PNGWriter();
void setICCProfile(const char *name, unsigned char *data, int size);
void setSRGBProfile();
bool init(FILE *f, int width, int height, int hDPI, int vDPI);
bool writePointers(unsigned char **rowPointers, int);
bool writeRow(unsigned char **row);
bool close();
private:
PNGWriter(const PNGWriter &other);
PNGWriter& operator=(const PNGWriter &other);
PNGWriterPrivate *priv;
};
#endif
#endif

236
thirdparty/poppler/goo/TiffWriter.cc vendored Normal file
View file

@ -0,0 +1,236 @@
//========================================================================
//
// TiffWriter.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2010, 2012 William Bader <williambader@hotmail.com>
// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2012 Pino Toscano <pino@kde.org>
// Copyright (C) 2014 Steven Lee <roc.sky@gmail.com>
//
//========================================================================
#include "TiffWriter.h"
#if ENABLE_LIBTIFF
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
extern "C" {
#include <tiffio.h>
}
struct TiffWriterPrivate {
TIFF *f; // LibTiff file context
int numRows; // number of rows in the image
int curRow; // number of rows written
const char *compressionString; // compression type
TiffWriter::Format format; // format of image data
};
TiffWriter::~TiffWriter()
{
delete priv;
}
TiffWriter::TiffWriter(Format formatA)
{
priv = new TiffWriterPrivate;
priv->f = NULL;
priv->numRows = 0;
priv->curRow = 0;
priv->compressionString = NULL;
priv->format = formatA;
}
// Set the compression type
void TiffWriter::setCompressionString(const char *compressionStringArg)
{
priv->compressionString = compressionStringArg;
}
// Write a TIFF file.
bool TiffWriter::init(FILE *openedFile, int width, int height, int hDPI, int vDPI)
{
unsigned int compression;
uint16 photometric = 0;
uint32 rowsperstrip = (uint32) -1;
int bitspersample;
uint16 samplesperpixel = 0;
const struct compression_name_tag {
const char *compressionName; // name of the compression option from the command line
unsigned int compressionCode; // internal libtiff code
const char *compressionDescription; // descriptive name
} compressionList[] = {
{ "none", COMPRESSION_NONE, "no compression" },
{ "ccittrle", COMPRESSION_CCITTRLE, "CCITT modified Huffman RLE" },
{ "ccittfax3", COMPRESSION_CCITTFAX3,"CCITT Group 3 fax encoding" },
{ "ccittt4", COMPRESSION_CCITT_T4, "CCITT T.4 (TIFF 6 name)" },
{ "ccittfax4", COMPRESSION_CCITTFAX4, "CCITT Group 4 fax encoding" },
{ "ccittt6", COMPRESSION_CCITT_T6, "CCITT T.6 (TIFF 6 name)" },
{ "lzw", COMPRESSION_LZW, "Lempel-Ziv & Welch" },
{ "ojpeg", COMPRESSION_OJPEG, "!6.0 JPEG" },
{ "jpeg", COMPRESSION_JPEG, "%JPEG DCT compression" },
{ "next", COMPRESSION_NEXT, "NeXT 2-bit RLE" },
{ "packbits", COMPRESSION_PACKBITS, "Macintosh RLE" },
{ "ccittrlew", COMPRESSION_CCITTRLEW, "CCITT modified Huffman RLE w/ word alignment" },
{ "deflate", COMPRESSION_DEFLATE, "Deflate compression" },
{ "adeflate", COMPRESSION_ADOBE_DEFLATE, "Deflate compression, as recognized by Adobe" },
{ "dcs", COMPRESSION_DCS, "Kodak DCS encoding" },
{ "jbig", COMPRESSION_JBIG, "ISO JBIG" },
{ "jp2000", COMPRESSION_JP2000, "Leadtools JPEG2000" },
{ NULL, 0, NULL }
};
// Initialize
priv->f = NULL;
priv->curRow = 0;
// Store the number of rows
priv->numRows = height;
// Set the compression
compression = COMPRESSION_NONE;
if (priv->compressionString == NULL || strcmp(priv->compressionString, "") == 0) {
compression = COMPRESSION_NONE;
} else {
int i;
for (i = 0; compressionList[i].compressionName != NULL; i++) {
if (strcmp(priv->compressionString, compressionList[i].compressionName) == 0) {
compression = compressionList[i].compressionCode;
break;
}
}
if (compressionList[i].compressionName == NULL) {
fprintf(stderr, "TiffWriter: Unknown compression type '%.10s', using 'none'.\n", priv->compressionString);
fprintf(stderr, "Known compression types (the tiff library might not support every type)\n");
for (i = 0; compressionList[i].compressionName != NULL; i++) {
fprintf(stderr, "%10s %s\n", compressionList[i].compressionName, compressionList[i].compressionDescription);
}
}
}
// Set bits per sample, samples per pixel, and photometric type from format
bitspersample = (priv->format == MONOCHROME ? 1 : 8);
switch (priv->format) {
case MONOCHROME:
case GRAY:
samplesperpixel = 1;
photometric = PHOTOMETRIC_MINISBLACK;
break;
case RGB:
samplesperpixel = 3;
photometric = PHOTOMETRIC_RGB;
break;
case RGBA_PREMULTIPLIED:
samplesperpixel = 4;
photometric = PHOTOMETRIC_RGB;
break;
case CMYK:
samplesperpixel = 4;
photometric = PHOTOMETRIC_SEPARATED;
break;
}
// Open the file
if (openedFile == NULL) {
fprintf(stderr, "TiffWriter: No output file given.\n");
return false;
}
#ifdef _WIN32
//Convert C Library handle to Win32 Handle
priv->f = TIFFFdOpen(_get_osfhandle(fileno(openedFile)), "-", "w");
#else
priv->f = TIFFFdOpen(fileno(openedFile), "-", "w");
#endif
if (!priv->f) {
return false;
}
// Set TIFF tags
TIFFSetField(priv->f, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(priv->f, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(priv->f, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(priv->f, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
TIFFSetField(priv->f, TIFFTAG_BITSPERSAMPLE, bitspersample);
TIFFSetField(priv->f, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(priv->f, TIFFTAG_PHOTOMETRIC, photometric);
TIFFSetField(priv->f, TIFFTAG_COMPRESSION, (uint16) compression);
TIFFSetField(priv->f, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(priv->f, rowsperstrip));
TIFFSetField(priv->f, TIFFTAG_XRESOLUTION, (double) hDPI);
TIFFSetField(priv->f, TIFFTAG_YRESOLUTION, (double) vDPI);
TIFFSetField(priv->f, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
if (priv->format == RGBA_PREMULTIPLIED) {
uint16 extra = EXTRASAMPLE_ASSOCALPHA;
TIFFSetField(priv->f, TIFFTAG_EXTRASAMPLES, 1, &extra);
}
if (priv->format == CMYK) {
TIFFSetField(priv->f, TIFFTAG_INKSET, INKSET_CMYK);
TIFFSetField(priv->f, TIFFTAG_NUMBEROFINKS, 4);
}
return true;
}
bool TiffWriter::writePointers(unsigned char **rowPointers, int rowCount)
{
// Write all rows to the file
for (int row = 0; row < rowCount; row++) {
if (TIFFWriteScanline(priv->f, rowPointers[row], row, 0) < 0) {
fprintf(stderr, "TiffWriter: Error writing tiff row %d\n", row);
return false;
}
}
return true;
}
bool TiffWriter::writeRow(unsigned char **rowData)
{
// Add a single row
if (TIFFWriteScanline(priv->f, *rowData, priv->curRow, 0) < 0) {
fprintf(stderr, "TiffWriter: Error writing tiff row %d\n", priv->curRow);
return false;
}
priv->curRow++;
return true;
}
bool TiffWriter::close()
{
// Close the file
TIFFClose(priv->f);
return true;
}
#endif

60
thirdparty/poppler/goo/TiffWriter.h vendored Normal file
View file

@ -0,0 +1,60 @@
//========================================================================
//
// TiffWriter.h
//
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2010, 2012 William Bader <williambader@hotmail.com>
// Copyright (C) 2011, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2012 Pino Toscano <pino@kde.org>
//
//========================================================================
#ifndef TIFFWRITER_H
#define TIFFWRITER_H
#include "poppler-config.h"
#ifdef ENABLE_LIBTIFF
#include <sys/types.h>
#include "ImgWriter.h"
struct TiffWriterPrivate;
class TiffWriter : public ImgWriter
{
public:
/* RGB - 3 bytes/pixel
* RGBA_PREMULTIPLIED - 4 bytes/pixel premultiplied by alpha
* GRAY - 1 byte/pixel
* MONOCHROME - 8 pixels/byte
* CMYK - 4 bytes/pixel
*/
enum Format { RGB, RGBA_PREMULTIPLIED, GRAY, MONOCHROME, CMYK };
TiffWriter(Format format = RGB);
~TiffWriter();
void setCompressionString(const char *compressionStringArg);
bool init(FILE *openedFile, int width, int height, int hDPI, int vDPI);
bool writePointers(unsigned char **rowPointers, int rowCount);
bool writeRow(unsigned char **rowData);
bool supportCMYK() { return true; }
bool close();
private:
TiffWriter(const TiffWriter &other);
TiffWriter& operator=(const TiffWriter &other);
TiffWriterPrivate *priv;
};
#endif
#endif

811
thirdparty/poppler/goo/gfile.cc vendored Normal file
View file

@ -0,0 +1,811 @@
//========================================================================
//
// gfile.cc
//
// Miscellaneous file and directory name manipulation.
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2008 Adam Batkin <adam@batkin.net>
// Copyright (C) 2008, 2010, 2012, 2013 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2009, 2012, 2014 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
// Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com>
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
//
// 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
//
//========================================================================
#include <config.h>
#ifdef _WIN32
# include <time.h>
#else
# if defined(MACOS)
# include <sys/stat.h>
# elif !defined(ACORN)
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
# endif
# include <time.h>
# include <limits.h>
# include <string.h>
# if !defined(VMS) && !defined(ACORN) && !defined(MACOS)
# include <pwd.h>
# endif
# if defined(VMS) && (__DECCXX_VER < 50200000)
# include <unixlib.h>
# endif
#endif // _WIN32
#include <stdio.h>
#include <limits>
#include "GooString.h"
#include "gfile.h"
// Some systems don't define this, so just make it something reasonably
// large.
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
//------------------------------------------------------------------------
GooString *getCurrentDir() {
char buf[PATH_MAX+1];
#if defined(__EMX__)
if (_getcwd2(buf, sizeof(buf)))
#elif defined(_WIN32)
if (GetCurrentDirectory(sizeof(buf), buf))
#elif defined(ACORN)
if (strcpy(buf, "@"))
#elif defined(MACOS)
if (strcpy(buf, ":"))
#else
if (getcwd(buf, sizeof(buf)))
#endif
return new GooString(buf);
return new GooString();
}
GooString *appendToPath(GooString *path, const char *fileName) {
#if defined(VMS)
//---------- VMS ----------
//~ this should handle everything necessary for file
//~ requesters, but it's certainly not complete
char *p0, *p1, *p2;
char *q1;
p0 = path->getCString();
p1 = p0 + path->getLength() - 1;
if (!strcmp(fileName, "-")) {
if (*p1 == ']') {
for (p2 = p1; p2 > p0 && *p2 != '.' && *p2 != '['; --p2) ;
if (*p2 == '[')
++p2;
path->del(p2 - p0, p1 - p2);
} else if (*p1 == ':') {
path->append("[-]");
} else {
path->clear();
path->append("[-]");
}
} else if ((q1 = strrchr(fileName, '.')) && !strncmp(q1, ".DIR;", 5)) {
if (*p1 == ']') {
path->insert(p1 - p0, '.');
path->insert(p1 - p0 + 1, fileName, q1 - fileName);
} else if (*p1 == ':') {
path->append('[');
path->append(']');
path->append(fileName, q1 - fileName);
} else {
path->clear();
path->append(fileName, q1 - fileName);
}
} else {
if (*p1 != ']' && *p1 != ':')
path->clear();
path->append(fileName);
}
return path;
#elif defined(_WIN32)
//---------- Win32 ----------
GooString *tmp;
char buf[256];
char *fp;
tmp = new GooString(path);
tmp->append('/');
tmp->append(fileName);
GetFullPathName(tmp->getCString(), sizeof(buf), buf, &fp);
delete tmp;
path->clear();
path->append(buf);
return path;
#elif defined(ACORN)
//---------- RISCOS ----------
char *p;
int i;
path->append(".");
i = path->getLength();
path->append(fileName);
for (p = path->getCString() + i; *p; ++p) {
if (*p == '/') {
*p = '.';
} else if (*p == '.') {
*p = '/';
}
}
return path;
#elif defined(MACOS)
//---------- MacOS ----------
char *p;
int i;
path->append(":");
i = path->getLength();
path->append(fileName);
for (p = path->getCString() + i; *p; ++p) {
if (*p == '/') {
*p = ':';
} else if (*p == '.') {
*p = ':';
}
}
return path;
#elif defined(__EMX__)
//---------- OS/2+EMX ----------
int i;
// appending "." does nothing
if (!strcmp(fileName, "."))
return path;
// appending ".." goes up one directory
if (!strcmp(fileName, "..")) {
for (i = path->getLength() - 2; i >= 0; --i) {
if (path->getChar(i) == '/' || path->getChar(i) == '\\' ||
path->getChar(i) == ':')
break;
}
if (i <= 0) {
if (path->getChar(0) == '/' || path->getChar(0) == '\\') {
path->del(1, path->getLength() - 1);
} else if (path->getLength() >= 2 && path->getChar(1) == ':') {
path->del(2, path->getLength() - 2);
} else {
path->clear();
path->append("..");
}
} else {
if (path->getChar(i-1) == ':')
++i;
path->del(i, path->getLength() - i);
}
return path;
}
// otherwise, append "/" and new path component
if (path->getLength() > 0 &&
path->getChar(path->getLength() - 1) != '/' &&
path->getChar(path->getLength() - 1) != '\\')
path->append('/');
path->append(fileName);
return path;
#else
//---------- Unix ----------
int i;
// appending "." does nothing
if (!strcmp(fileName, "."))
return path;
// appending ".." goes up one directory
if (!strcmp(fileName, "..")) {
for (i = path->getLength() - 2; i >= 0; --i) {
if (path->getChar(i) == '/')
break;
}
if (i <= 0) {
if (path->getChar(0) == '/') {
path->del(1, path->getLength() - 1);
} else {
path->clear();
path->append("..");
}
} else {
path->del(i, path->getLength() - i);
}
return path;
}
// otherwise, append "/" and new path component
if (path->getLength() > 0 &&
path->getChar(path->getLength() - 1) != '/')
path->append('/');
path->append(fileName);
return path;
#endif
}
GooString *grabPath(char *fileName) {
#ifdef VMS
//---------- VMS ----------
char *p;
if ((p = strrchr(fileName, ']')))
return new GooString(fileName, p + 1 - fileName);
if ((p = strrchr(fileName, ':')))
return new GooString(fileName, p + 1 - fileName);
return new GooString();
#elif defined(__EMX__) || defined(_WIN32)
//---------- OS/2+EMX and Win32 ----------
char *p;
if ((p = strrchr(fileName, '/')))
return new GooString(fileName, p - fileName);
if ((p = strrchr(fileName, '\\')))
return new GooString(fileName, p - fileName);
if ((p = strrchr(fileName, ':')))
return new GooString(fileName, p + 1 - fileName);
return new GooString();
#elif defined(ACORN)
//---------- RISCOS ----------
char *p;
if ((p = strrchr(fileName, '.')))
return new GooString(fileName, p - fileName);
return new GooString();
#elif defined(MACOS)
//---------- MacOS ----------
char *p;
if ((p = strrchr(fileName, ':')))
return new GooString(fileName, p - fileName);
return new GooString();
#else
//---------- Unix ----------
char *p;
if ((p = strrchr(fileName, '/')))
return new GooString(fileName, p - fileName);
return new GooString();
#endif
}
GBool isAbsolutePath(char *path) {
#ifdef VMS
//---------- VMS ----------
return strchr(path, ':') ||
(path[0] == '[' && path[1] != '.' && path[1] != '-');
#elif defined(__EMX__) || defined(_WIN32)
//---------- OS/2+EMX and Win32 ----------
return path[0] == '/' || path[0] == '\\' || path[1] == ':';
#elif defined(ACORN)
//---------- RISCOS ----------
return path[0] == '$';
#elif defined(MACOS)
//---------- MacOS ----------
return path[0] != ':';
#else
//---------- Unix ----------
return path[0] == '/';
#endif
}
time_t getModTime(char *fileName) {
#ifdef _WIN32
//~ should implement this, but it's (currently) only used in xpdf
return 0;
#else
struct stat statBuf;
if (stat(fileName, &statBuf)) {
return 0;
}
return statBuf.st_mtime;
#endif
}
GBool openTempFile(GooString **name, FILE **f, const char *mode) {
#if defined(_WIN32)
//---------- Win32 ----------
char *tempDir;
GooString *s, *s2;
FILE *f2;
int t, i;
// this has the standard race condition problem, but I haven't found
// a better way to generate temp file names with extensions on
// Windows
if ((tempDir = getenv("TEMP"))) {
s = new GooString(tempDir);
s->append('\\');
} else {
s = new GooString();
}
s->appendf("x_{0:d}_{1:d}_",
(int)GetCurrentProcessId(), (int)GetCurrentThreadId());
t = (int)time(NULL);
for (i = 0; i < 1000; ++i) {
s2 = s->copy()->appendf("{0:d}", t + i);
if (!(f2 = fopen(s2->getCString(), "r"))) {
if (!(f2 = fopen(s2->getCString(), mode))) {
delete s2;
delete s;
return gFalse;
}
*name = s2;
*f = f2;
delete s;
return gTrue;
}
fclose(f2);
delete s2;
}
delete s;
return gFalse;
#elif defined(VMS) || defined(__EMX__) || defined(ACORN) || defined(MACOS)
//---------- non-Unix ----------
char *s;
// There is a security hole here: an attacker can create a symlink
// with this file name after the tmpnam call and before the fopen
// call. I will happily accept fixes to this function for non-Unix
// OSs.
if (!(s = tmpnam(NULL))) {
return gFalse;
}
*name = new GooString(s);
if (!(*f = fopen((*name)->getCString(), mode))) {
delete (*name);
*name = NULL;
return gFalse;
}
return gTrue;
#else
//---------- Unix ----------
char *s;
int fd;
#if HAVE_MKSTEMP
if ((s = getenv("TMPDIR"))) {
*name = new GooString(s);
} else {
*name = new GooString("/tmp");
}
(*name)->append("/XXXXXX");
fd = mkstemp((*name)->getCString());
#else // HAVE_MKSTEMP
if (!(s = tmpnam(NULL))) {
return gFalse;
}
*name = new GooString(s);
fd = open((*name)->getCString(), O_WRONLY | O_CREAT | O_EXCL, 0600);
#endif // HAVE_MKSTEMP
if (fd < 0 || !(*f = fdopen(fd, mode))) {
delete *name;
*name = NULL;
return gFalse;
}
return gTrue;
#endif
}
#ifdef WIN32
GooString *fileNameToUTF8(char *path) {
GooString *s;
char *p;
s = new GooString();
for (p = path; *p; ++p) {
if (*p & 0x80) {
s->append((char)(0xc0 | ((*p >> 6) & 0x03)));
s->append((char)(0x80 | (*p & 0x3f)));
} else {
s->append(*p);
}
}
return s;
}
GooString *fileNameToUTF8(wchar_t *path) {
GooString *s;
wchar_t *p;
s = new GooString();
for (p = path; *p; ++p) {
if (*p < 0x80) {
s->append((char)*p);
} else if (*p < 0x800) {
s->append((char)(0xc0 | ((*p >> 6) & 0x1f)));
s->append((char)(0x80 | (*p & 0x3f)));
} else {
s->append((char)(0xe0 | ((*p >> 12) & 0x0f)));
s->append((char)(0x80 | ((*p >> 6) & 0x3f)));
s->append((char)(0x80 | (*p & 0x3f)));
}
}
return s;
}
#endif
FILE *openFile(const char *path, const char *mode) {
#ifdef WIN32
OSVERSIONINFO version;
wchar_t wPath[_MAX_PATH + 1];
char nPath[_MAX_PATH + 1];
wchar_t wMode[8];
const char *p;
size_t i;
// NB: _wfopen is only available in NT
version.dwOSVersionInfoSize = sizeof(version);
GetVersionEx(&version);
if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
for (p = path, i = 0; *p && i < _MAX_PATH; ++i) {
if ((p[0] & 0xe0) == 0xc0 &&
p[1] && (p[1] & 0xc0) == 0x80) {
wPath[i] = (wchar_t)(((p[0] & 0x1f) << 6) |
(p[1] & 0x3f));
p += 2;
} else if ((p[0] & 0xf0) == 0xe0 &&
p[1] && (p[1] & 0xc0) == 0x80 &&
p[2] && (p[2] & 0xc0) == 0x80) {
wPath[i] = (wchar_t)(((p[0] & 0x0f) << 12) |
((p[1] & 0x3f) << 6) |
(p[2] & 0x3f));
p += 3;
} else {
wPath[i] = (wchar_t)(p[0] & 0xff);
p += 1;
}
}
wPath[i] = (wchar_t)0;
for (i = 0; (i < sizeof(mode) - 1) && mode[i]; ++i) {
wMode[i] = (wchar_t)(mode[i] & 0xff);
}
wMode[i] = (wchar_t)0;
return _wfopen(wPath, wMode);
} else {
for (p = path, i = 0; *p && i < _MAX_PATH; ++i) {
if ((p[0] & 0xe0) == 0xc0 &&
p[1] && (p[1] & 0xc0) == 0x80) {
nPath[i] = (char)(((p[0] & 0x1f) << 6) |
(p[1] & 0x3f));
p += 2;
} else if ((p[0] & 0xf0) == 0xe0 &&
p[1] && (p[1] & 0xc0) == 0x80 &&
p[2] && (p[2] & 0xc0) == 0x80) {
nPath[i] = (char)(((p[1] & 0x3f) << 6) |
(p[2] & 0x3f));
p += 3;
} else {
nPath[i] = p[0];
p += 1;
}
}
nPath[i] = '\0';
return fopen(nPath, mode);
}
#else
return fopen(path, mode);
#endif
}
char *getLine(char *buf, int size, FILE *f) {
int c, i;
i = 0;
while (i < size - 1) {
if ((c = fgetc(f)) == EOF) {
break;
}
buf[i++] = (char)c;
if (c == '\x0a') {
break;
}
if (c == '\x0d') {
c = fgetc(f);
if (c == '\x0a' && i < size - 1) {
buf[i++] = (char)c;
} else if (c != EOF) {
ungetc(c, f);
}
break;
}
}
buf[i] = '\0';
if (i == 0) {
return NULL;
}
return buf;
}
int Gfseek(FILE *f, Goffset offset, int whence) {
#if HAVE_FSEEKO
return fseeko(f, offset, whence);
#elif HAVE_FSEEK64
return fseek64(f, offset, whence);
#elif defined(__MINGW32__)
return fseeko64(f, offset, whence);
#elif _WIN32
return _fseeki64(f, offset, whence);
#else
return fseek(f, offset, whence);
#endif
}
Goffset Gftell(FILE *f) {
#if HAVE_FSEEKO
return ftello(f);
#elif HAVE_FSEEK64
return ftell64(f);
#elif defined(__MINGW32__)
return ftello64(f);
#elif _WIN32
return _ftelli64(f);
#else
return ftell(f);
#endif
}
Goffset GoffsetMax() {
#if HAVE_FSEEKO
return (std::numeric_limits<off_t>::max)();
#elif HAVE_FSEEK64 || defined(__MINGW32__)
return (std::numeric_limits<off64_t>::max)();
#elif _WIN32
return (std::numeric_limits<__int64>::max)();
#else
return (std::numeric_limits<long>::max)();
#endif
}
//------------------------------------------------------------------------
// GooFile
//------------------------------------------------------------------------
#ifdef _WIN32
int GooFile::read(char *buf, int n, Goffset offset) const {
DWORD m;
LARGE_INTEGER largeInteger = {0};
largeInteger.QuadPart = offset;
OVERLAPPED overlapped = {0};
overlapped.Offset = largeInteger.LowPart;
overlapped.OffsetHigh = largeInteger.HighPart;
return FALSE == ReadFile(handle, buf, n, &m, &overlapped) ? -1 : m;
}
Goffset GooFile::size() const {
LARGE_INTEGER size = {(DWORD)-1,-1};
GetFileSizeEx(handle, &size);
return size.QuadPart;
}
GooFile* GooFile::open(const GooString *fileName) {
HANDLE handle = CreateFile(fileName->getCString(),
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
return handle == INVALID_HANDLE_VALUE ? NULL : new GooFile(handle);
}
GooFile* GooFile::open(const wchar_t *fileName) {
HANDLE handle = CreateFileW(fileName,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
return handle == INVALID_HANDLE_VALUE ? NULL : new GooFile(handle);
}
#else
int GooFile::read(char *buf, int n, Goffset offset) const {
#ifdef HAVE_PREAD64
return pread64(fd, buf, n, offset);
#else
return pread(fd, buf, n, offset);
#endif
}
Goffset GooFile::size() const {
#ifdef HAVE_LSEEK64
return lseek64(fd, 0, SEEK_END);
#else
return lseek(fd, 0, SEEK_END);
#endif
}
GooFile* GooFile::open(const GooString *fileName) {
#ifdef VMS
int fd = ::open(fileName->getCString(), Q_RDONLY, "ctx=stm");
#else
int fd = ::open(fileName->getCString(), O_RDONLY);
#endif
return fd < 0 ? NULL : new GooFile(fd);
}
#endif // _WIN32
//------------------------------------------------------------------------
// GDir and GDirEntry
//------------------------------------------------------------------------
GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) {
#ifdef VMS
char *p;
#elif defined(_WIN32)
DWORD fa;
#elif defined(ACORN)
#else
struct stat st;
#endif
name = new GooString(nameA);
dir = gFalse;
fullPath = new GooString(dirPath);
appendToPath(fullPath, nameA);
if (doStat) {
#ifdef VMS
if (!strcmp(nameA, "-") ||
((p = strrchr(nameA, '.')) && !strncmp(p, ".DIR;", 5)))
dir = gTrue;
#elif defined(ACORN)
#else
#ifdef _WIN32
fa = GetFileAttributes(fullPath->getCString());
dir = (fa != 0xFFFFFFFF && (fa & FILE_ATTRIBUTE_DIRECTORY));
#else
if (stat(fullPath->getCString(), &st) == 0)
dir = S_ISDIR(st.st_mode);
#endif
#endif
}
}
GDirEntry::~GDirEntry() {
delete fullPath;
delete name;
}
GDir::GDir(char *name, GBool doStatA) {
path = new GooString(name);
doStat = doStatA;
#if defined(_WIN32)
GooString *tmp;
tmp = path->copy();
tmp->append("/*.*");
hnd = FindFirstFile(tmp->getCString(), &ffd);
delete tmp;
#elif defined(ACORN)
#elif defined(MACOS)
#else
dir = opendir(name);
#ifdef VMS
needParent = strchr(name, '[') != NULL;
#endif
#endif
}
GDir::~GDir() {
delete path;
#if defined(_WIN32)
if (hnd != INVALID_HANDLE_VALUE) {
FindClose(hnd);
hnd = INVALID_HANDLE_VALUE;
}
#elif defined(ACORN)
#elif defined(MACOS)
#else
if (dir)
closedir(dir);
#endif
}
GDirEntry *GDir::getNextEntry() {
GDirEntry *e = NULL;
#if defined(_WIN32)
if (hnd != INVALID_HANDLE_VALUE) {
e = new GDirEntry(path->getCString(), ffd.cFileName, doStat);
if (!FindNextFile(hnd, &ffd)) {
FindClose(hnd);
hnd = INVALID_HANDLE_VALUE;
}
}
#elif defined(ACORN)
#elif defined(MACOS)
#elif defined(VMS)
struct dirent *ent;
if (dir) {
if (needParent) {
e = new GDirEntry(path->getCString(), "-", doStat);
needParent = gFalse;
return e;
}
ent = readdir(dir);
if (ent) {
e = new GDirEntry(path->getCString(), ent->d_name, doStat);
}
}
#else
struct dirent *ent;
if (dir) {
do {
ent = readdir(dir);
}
while (ent && (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")));
if (ent) {
e = new GDirEntry(path->getCString(), ent->d_name, doStat);
}
}
#endif
return e;
}
void GDir::rewind() {
#ifdef _WIN32
GooString *tmp;
if (hnd != INVALID_HANDLE_VALUE)
FindClose(hnd);
tmp = path->copy();
tmp->append("/*.*");
hnd = FindFirstFile(tmp->getCString(), &ffd);
delete tmp;
#elif defined(ACORN)
#elif defined(MACOS)
#else
if (dir)
rewinddir(dir);
#ifdef VMS
needParent = strchr(path->getCString(), '[') != NULL;
#endif
#endif
}

209
thirdparty/poppler/goo/gfile.h vendored Normal file
View file

@ -0,0 +1,209 @@
//========================================================================
//
// gfile.h
//
// Miscellaneous file and directory name manipulation.
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2009, 2011, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
// Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com>
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com>
// Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de>
//
// 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
//
//========================================================================
#ifndef GFILE_H
#define GFILE_H
#include "poppler-config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
extern "C" {
#if defined(_WIN32)
# include <sys/stat.h>
# ifdef FPTEX
# include <win32lib.h>
# else
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include <windows.h>
# endif
#elif defined(ACORN)
#elif defined(MACOS)
# include <ctime.h>
#else
# include <unistd.h>
# include <sys/types.h>
# ifdef VMS
# include "vms_dirent.h"
# elif HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(d) strlen((d)->d_name)
# else
# define dirent direct
# define NAMLEN(d) (d)->d_namlen
# if HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
# if HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif
# if HAVE_NDIR_H
# include <ndir.h>
# endif
# endif
#endif
}
#include "gtypes.h"
class GooString;
//------------------------------------------------------------------------
// Get current directory.
extern GooString *getCurrentDir();
// Append a file name to a path string. <path> may be an empty
// string, denoting the current directory). Returns <path>.
extern GooString *appendToPath(GooString *path, const char *fileName);
// Grab the path from the front of the file name. If there is no
// directory component in <fileName>, returns an empty string.
extern GooString *grabPath(char *fileName);
// Is this an absolute path or file name?
extern GBool isAbsolutePath(char *path);
// Get the modification time for <fileName>. Returns 0 if there is an
// error.
extern time_t getModTime(char *fileName);
// Create a temporary file and open it for writing. If <ext> is not
// NULL, it will be used as the file name extension. Returns both the
// name and the file pointer. For security reasons, all writing
// should be done to the returned file pointer; the file may be
// reopened later for reading, but not for writing. The <mode> string
// should be "w" or "wb". Returns true on success.
extern GBool openTempFile(GooString **name, FILE **f, const char *mode);
#ifdef WIN32
// Convert a file name from Latin-1 to UTF-8.
extern GooString *fileNameToUTF8(char *path);
// Convert a file name from UCS-2 to UTF-8.
extern GooString *fileNameToUTF8(wchar_t *path);
#endif
// Open a file. On Windows, this converts the path from UTF-8 to
// UCS-2 and calls _wfopen (if available). On other OSes, this simply
// calls fopen.
extern FILE *openFile(const char *path, const char *mode);
// Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
// conventions.
extern char *getLine(char *buf, int size, FILE *f);
// Like fseek/ftell but uses platform specific variants that support large files
extern int Gfseek(FILE *f, Goffset offset, int whence);
extern Goffset Gftell(FILE *f);
// Largest offset supported by Gfseek/Gftell
extern Goffset GoffsetMax();
//------------------------------------------------------------------------
// GooFile
//------------------------------------------------------------------------
class GooFile
{
public:
int read(char *buf, int n, Goffset offset) const;
Goffset size() const;
static GooFile *open(const GooString *fileName);
#ifdef _WIN32
static GooFile *open(const wchar_t *fileName);
~GooFile() { CloseHandle(handle); }
private:
GooFile(HANDLE handleA): handle(handleA) {}
HANDLE handle;
#else
~GooFile() { close(fd); }
private:
GooFile(int fdA) : fd(fdA) {}
int fd;
#endif // _WIN32
};
//------------------------------------------------------------------------
// GDir and GDirEntry
//------------------------------------------------------------------------
class GDirEntry {
public:
GDirEntry(char *dirPath, char *nameA, GBool doStat);
~GDirEntry();
GooString *getName() { return name; }
GooString *getFullPath() { return fullPath; }
GBool isDir() { return dir; }
private:
GDirEntry(const GDirEntry &other);
GDirEntry& operator=(const GDirEntry &other);
GooString *name; // dir/file name
GooString *fullPath;
GBool dir; // is it a directory?
};
class GDir {
public:
GDir(char *name, GBool doStatA = gTrue);
~GDir();
GDirEntry *getNextEntry();
void rewind();
private:
GDir(const GDir &other);
GDir& operator=(const GDir &other);
GooString *path; // directory path
GBool doStat; // call stat() for each entry?
#if defined(_WIN32)
WIN32_FIND_DATA ffd;
HANDLE hnd;
#elif defined(ACORN)
#elif defined(MACOS)
#else
DIR *dir; // the DIR structure from opendir()
#ifdef VMS
GBool needParent; // need to return an entry for [-]
#endif
#endif
};
#endif

326
thirdparty/poppler/goo/gmem.cc vendored Normal file
View file

@ -0,0 +1,326 @@
/*
* gmem.c
*
* Memory routines with out-of-memory checking.
*
* Copyright 1996-2003 Glyph & Cog, LLC
*/
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2007-2010, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org>
//
// 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
//
//========================================================================
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <limits.h>
#include "gmem.h"
#ifdef DEBUG_MEM
typedef struct _GMemHdr {
unsigned int magic;
int size;
int index;
struct _GMemHdr *next, *prev;
} GMemHdr;
#define gMemHdrSize ((sizeof(GMemHdr) + 7) & ~7)
#define gMemTrlSize (sizeof(long))
#define gMemMagic 0xabcd9999
#if gmemTrlSize==8
#define gMemDeadVal 0xdeadbeefdeadbeefUL
#else
#define gMemDeadVal 0xdeadbeefUL
#endif
/* round data size so trailer will be aligned */
#define gMemDataSize(size) \
((((size) + gMemTrlSize - 1) / gMemTrlSize) * gMemTrlSize)
static GMemHdr *gMemHead = NULL;
static GMemHdr *gMemTail = NULL;
static int gMemIndex = 0;
static int gMemAlloc = 0;
static int gMemInUse = 0;
#endif /* DEBUG_MEM */
inline static void *gmalloc(size_t size, bool checkoverflow) {
#ifdef DEBUG_MEM
int size1;
char *mem;
GMemHdr *hdr;
void *data;
unsigned long *trl, *p;
if (size == 0) {
return NULL;
}
size1 = gMemDataSize(size);
if (!(mem = (char *)malloc(size1 + gMemHdrSize + gMemTrlSize))) {
fprintf(stderr, "Out of memory\n");
if (checkoverflow) return NULL;
else exit(1);
}
hdr = (GMemHdr *)mem;
data = (void *)(mem + gMemHdrSize);
trl = (unsigned long *)(mem + gMemHdrSize + size1);
hdr->magic = gMemMagic;
hdr->size = size;
hdr->index = gMemIndex++;
if (gMemTail) {
gMemTail->next = hdr;
hdr->prev = gMemTail;
gMemTail = hdr;
} else {
hdr->prev = NULL;
gMemHead = gMemTail = hdr;
}
hdr->next = NULL;
++gMemAlloc;
gMemInUse += size;
for (p = (unsigned long *)data; p <= trl; ++p) {
*p = gMemDeadVal;
}
return data;
#else
void *p;
if (size == 0) {
return NULL;
}
if (!(p = malloc(size))) {
fprintf(stderr, "Out of memory\n");
if (checkoverflow) return NULL;
else exit(1);
}
return p;
#endif
}
void *gmalloc(size_t size) {
return gmalloc(size, false);
}
void *gmalloc_checkoverflow(size_t size) {
return gmalloc(size, true);
}
inline static void *grealloc(void *p, size_t size, bool checkoverflow) {
#ifdef DEBUG_MEM
GMemHdr *hdr;
void *q;
int oldSize;
if (size == 0) {
if (p) {
gfree(p);
}
return NULL;
}
if (p) {
hdr = (GMemHdr *)((char *)p - gMemHdrSize);
oldSize = hdr->size;
q = gmalloc(size, checkoverflow);
memcpy(q, p, size < oldSize ? size : oldSize);
gfree(p);
} else {
q = gmalloc(size, checkoverflow);
}
return q;
#else
void *q;
if (size == 0) {
if (p) {
free(p);
}
return NULL;
}
if (p) {
q = realloc(p, size);
} else {
q = malloc(size);
}
if (!q) {
fprintf(stderr, "Out of memory\n");
if (checkoverflow) return NULL;
else exit(1);
}
return q;
#endif
}
void *grealloc(void *p, size_t size) {
return grealloc(p, size, false);
}
void *grealloc_checkoverflow(void *p, size_t size) {
return grealloc(p, size, true);
}
inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow) {
int n;
if (nObjs == 0) {
return NULL;
}
n = nObjs * objSize;
if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) {
fprintf(stderr, "Bogus memory allocation size\n");
if (checkoverflow) return NULL;
else exit(1);
}
return gmalloc(n, checkoverflow);
}
void *gmallocn(int nObjs, int objSize) {
return gmallocn(nObjs, objSize, false);
}
void *gmallocn_checkoverflow(int nObjs, int objSize) {
return gmallocn(nObjs, objSize, true);
}
inline static void *gmallocn3(int a, int b, int c, bool checkoverflow) {
int n = a * b;
if (b <= 0 || a < 0 || a >= INT_MAX / b) {
fprintf(stderr, "Bogus memory allocation size\n");
if (checkoverflow) return NULL;
else exit(1);
}
return gmallocn(n, c, checkoverflow);
}
void *gmallocn3(int a, int b, int c) {
return gmallocn3(a, b, c, false);
}
void *gmallocn3_checkoverflow(int a, int b, int c) {
return gmallocn3(a, b, c, true);
}
inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) {
int n;
if (nObjs == 0) {
if (p) {
gfree(p);
}
return NULL;
}
n = nObjs * objSize;
if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) {
fprintf(stderr, "Bogus memory allocation size\n");
if (checkoverflow) {
gfree(p);
return NULL;
} else {
exit(1);
}
}
return grealloc(p, n, checkoverflow);
}
void *greallocn(void *p, int nObjs, int objSize) {
return greallocn(p, nObjs, objSize, false);
}
void *greallocn_checkoverflow(void *p, int nObjs, int objSize) {
return greallocn(p, nObjs, objSize, true);
}
void gfree(void *p) {
#ifdef DEBUG_MEM
int size;
GMemHdr *hdr;
unsigned long *trl, *clr;
if (p) {
hdr = (GMemHdr *)((char *)p - gMemHdrSize);
if (hdr->magic == gMemMagic &&
((hdr->prev == NULL) == (hdr == gMemHead)) &&
((hdr->next == NULL) == (hdr == gMemTail))) {
if (hdr->prev) {
hdr->prev->next = hdr->next;
} else {
gMemHead = hdr->next;
}
if (hdr->next) {
hdr->next->prev = hdr->prev;
} else {
gMemTail = hdr->prev;
}
--gMemAlloc;
gMemInUse -= hdr->size;
size = gMemDataSize(hdr->size);
trl = (unsigned long *)((char *)hdr + gMemHdrSize + size);
if (*trl != gMemDeadVal) {
fprintf(stderr, "Overwrite past end of block %d at address %p\n",
hdr->index, p);
}
for (clr = (unsigned long *)hdr; clr <= trl; ++clr) {
*clr = gMemDeadVal;
}
free(hdr);
} else {
fprintf(stderr, "Attempted to free bad address %p\n", p);
}
}
#else
if (p) {
free(p);
}
#endif
}
#ifdef DEBUG_MEM
void gMemReport(FILE *f) {
GMemHdr *p;
fprintf(f, "%d memory allocations in all\n", gMemIndex);
if (gMemAlloc > 0) {
fprintf(f, "%d memory blocks left allocated:\n", gMemAlloc);
fprintf(f, " index size\n");
fprintf(f, "-------- --------\n");
for (p = gMemHead; p; p = p->next) {
fprintf(f, "%8d %8d\n", p->index, p->size);
}
} else {
fprintf(f, "No memory blocks left allocated\n");
}
}
#endif
char *copyString(const char *s) {
char *s1;
s1 = (char *)gmalloc(strlen(s) + 1);
strcpy(s1, s);
return s1;
}
char *gstrndup(const char *s, size_t n) {
char *s1 = (char*)gmalloc(n + 1); /* cannot return NULL for size > 0 */
s1[n] = '\0';
memcpy(s1, s, n);
return s1;
}

92
thirdparty/poppler/goo/gmem.h vendored Normal file
View file

@ -0,0 +1,92 @@
/*
* gmem.h
*
* Memory routines with out-of-memory checking.
*
* Copyright 1996-2003 Glyph & Cog, LLC
*/
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2007-2010 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org>
//
// 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
//
//========================================================================
#ifndef GMEM_H
#define GMEM_H
#include <stdio.h>
#include "poppler-config.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Same as malloc, but prints error message and exits if malloc()
* returns NULL.
*/
extern void *gmalloc(size_t size);
extern void *gmalloc_checkoverflow(size_t size);
/*
* Same as realloc, but prints error message and exits if realloc()
* returns NULL. If <p> is NULL, calls malloc instead of realloc().
*/
extern void *grealloc(void *p, size_t size);
extern void *grealloc_checkoverflow(size_t size);
/*
* These are similar to gmalloc and grealloc, but take an object count
* and size. The result is similar to allocating nObjs * objSize
* bytes, but there is an additional error check that the total size
* doesn't overflow an int.
* The gmallocn_checkoverflow variant returns NULL instead of exiting
* the application if a overflow is detected
*/
extern void *gmallocn(int nObjs, int objSize);
extern void *gmallocn_checkoverflow(int nObjs, int objSize);
extern void *gmallocn3(int a, int b, int c);
extern void *gmallocn3_checkoverflow(int a, int b, int c);
extern void *greallocn(void *p, int nObjs, int objSize);
extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize);
/*
* Same as free, but checks for and ignores NULL pointers.
*/
extern void gfree(void *p);
#ifdef DEBUG_MEM
/*
* Report on unfreed memory.
*/
extern void gMemReport(FILE *f);
#else
#define gMemReport(f)
#endif
/*
* Allocate memory and copy a string into it.
*/
extern char *copyString(const char *s);
/*
* Allocate memory and copy a limited-length string to it.
*/
extern char *gstrndup(const char *s, size_t n);
#ifdef __cplusplus
}
#endif
#endif

32
thirdparty/poppler/goo/gmempp.cc vendored Normal file
View file

@ -0,0 +1,32 @@
//========================================================================
//
// gmempp.cc
//
// Use gmalloc/gfree for C++ new/delete operators.
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
#include <config.h>
#include "gmem.h"
#ifdef DEBUG_MEM
void *operator new(size_t size) {
return gmalloc((int)size);
}
void *operator new[](size_t size) {
return gmalloc((int)size);
}
void operator delete(void *p) {
gfree(p);
}
void operator delete[](void *p) {
gfree(p);
}
#endif

70
thirdparty/poppler/goo/grandom.cc vendored Normal file
View file

@ -0,0 +1,70 @@
/*
* grandom.cc
*
* This file is licensed under the GPLv2 or later
*
* Pseudo-random number generation
*
* Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
*/
#include <config.h>
#include "grandom.h"
#include "gtypes.h"
#ifdef HAVE_RAND_R // rand_r backend (POSIX)
static GBool initialized = gFalse;
#include <stdlib.h>
#include <time.h>
static unsigned int seed;
static void initialize() {
if (!initialized) {
seed = time(NULL);
initialized = gTrue;
}
}
void grandom_fill(Guchar *buff, int size)
{
initialize();
while (size--)
*buff++ = rand_r(&seed) % 256;
}
double grandom_double()
{
initialize();
return rand_r(&seed) / (1 + (double)RAND_MAX);
}
#else // srand+rand backend (unsafe, because it may interfere with the application)
static GBool initialized = gFalse;
#include <stdlib.h>
#include <time.h>
static void initialize() {
if (!initialized) {
srand(time(NULL));
initialized = gTrue;
}
}
void grandom_fill(Guchar *buff, int size)
{
initialize();
while (size--)
*buff++ = rand() % 256;
}
double grandom_double()
{
initialize();
return rand() / (1 + (double)RAND_MAX);
}
#endif

34
thirdparty/poppler/goo/grandom.h vendored Normal file
View file

@ -0,0 +1,34 @@
/*
* grandom.h
*
* This file is licensed under the GPLv2 or later
*
* Pseudo-random number generation
*
* Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
*/
#ifndef GRANDOM_H
#define GRANDOM_H
#include "gtypes.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Fills the given buffer with random bytes
*/
extern void grandom_fill(Guchar *buff, int size);
/*
* Returns a random number in [0,1)
*/
extern double grandom_double();
#ifdef __cplusplus
}
#endif
#endif

147
thirdparty/poppler/goo/gstrtod.cc vendored Normal file
View file

@ -0,0 +1,147 @@
/* This file is part of Libspectre.
*
* Copyright (C) 2007, 2012 Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* This function comes from spectre-utils from libspectre */
#include "gstrtod.h"
#include <locale.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#define ascii_isspace(c) \
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
#define ascii_isdigit(c) \
(c >= '0' && c <= '9')
double gatof(const char *nptr)
{
return gstrtod(nptr, NULL);
}
double gstrtod(const char *nptr, char **endptr)
{
char *fail_pos;
double val;
struct lconv *locale_data;
const char *decimal_point;
int decimal_point_len;
const char *p, *decimal_point_pos;
const char *end = NULL; /* Silence gcc */
int strtod_errno;
fail_pos = NULL;
locale_data = localeconv ();
decimal_point = locale_data->decimal_point;
decimal_point_len = strlen (decimal_point);
decimal_point_pos = NULL;
end = NULL;
if (decimal_point[0] != '.' || decimal_point[1] != 0) {
p = nptr;
/* Skip leading space */
while (ascii_isspace (*p))
p++;
/* Skip leading optional sign */
if (*p == '+' || *p == '-')
p++;
if (ascii_isdigit (*p) || *p == '.') {
while (ascii_isdigit (*p))
p++;
if (*p == '.')
decimal_point_pos = p++;
while (ascii_isdigit (*p))
p++;
if (*p == 'e' || *p == 'E')
p++;
if (*p == '+' || *p == '-')
p++;
while (ascii_isdigit (*p))
p++;
end = p;
}
/* For the other cases, we need not convert the decimal point */
}
if (decimal_point_pos) {
char *copy, *c;
/* We need to convert the '.' to the locale specific decimal point */
copy = (char *) malloc (end - nptr + 1 + decimal_point_len);
c = copy;
memcpy (c, nptr, decimal_point_pos - nptr);
c += decimal_point_pos - nptr;
memcpy (c, decimal_point, decimal_point_len);
c += decimal_point_len;
memcpy (c, decimal_point_pos + 1, end - (decimal_point_pos + 1));
c += end - (decimal_point_pos + 1);
*c = 0;
errno = 0;
val = strtod (copy, &fail_pos);
strtod_errno = errno;
if (fail_pos) {
if (fail_pos - copy > decimal_point_pos - nptr)
fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1);
else
fail_pos = (char *)nptr + (fail_pos - copy);
}
free (copy);
} else if (end) {
char *copy;
copy = (char *) malloc (end - (char *)nptr + 1);
memcpy (copy, nptr, end - nptr);
*(copy + (end - (char *)nptr)) = 0;
errno = 0;
val = strtod (copy, &fail_pos);
strtod_errno = errno;
if (fail_pos) {
fail_pos = (char *)nptr + (fail_pos - copy);
}
free (copy);
} else {
errno = 0;
val = strtod (nptr, &fail_pos);
strtod_errno = errno;
}
if (endptr)
*endptr = fail_pos;
errno = strtod_errno;
return val;
}

43
thirdparty/poppler/goo/gstrtod.h vendored Normal file
View file

@ -0,0 +1,43 @@
/* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* This function comes from spectre-utils from libspectre */
#ifndef GSTRTOD_H
#define GSTRTOD_H
#ifdef __cplusplus
extern "C" {
#endif
/* This function behaves like the standard atof()/(strtod() function
* does in the C locale. It does this without actually changing
* the current locale, since that would not be thread-safe.
* A limitation of the implementation is that this function
* will still accept localized versions of infinities and NANs.
*/
double gatof(const char *nptr);
double gstrtod(const char *nptr, char **endptr);
#ifdef __cplusplus
}
#endif
#endif

52
thirdparty/poppler/goo/gtypes.h vendored Normal file
View file

@ -0,0 +1,52 @@
/*
* gtypes.h
*
* Some useful simple types.
*
* Copyright 1996-2003 Glyph & Cog, LLC
*/
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2010 Patrick Spendrin <ps_ml@gmx.de>
// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
//
// 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
//
//========================================================================
#ifndef GTYPES_H
#define GTYPES_H
#include "poppler-config.h"
/*
* These have stupid names to avoid conflicts with some (but not all)
* C++ compilers which define them.
*/
typedef bool GBool;
#define gTrue true
#define gFalse false
#ifdef _MSC_VER
#pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
#endif
/*
* These have stupid names to avoid conflicts with <sys/types.h>,
* which on various systems defines some random subset of these.
*/
typedef unsigned char Guchar;
typedef unsigned short Gushort;
typedef unsigned int Guint;
typedef unsigned long Gulong;
typedef long long Goffset;
#endif

30
thirdparty/poppler/goo/gtypes_p.h vendored Normal file
View file

@ -0,0 +1,30 @@
/*
* gtypes_p.h
*
* Some useful simple types.
*
* Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com>
*/
#ifndef GTYPES_P_H
#define GTYPES_P_H
#include "config.h"
/*
* Define precise integer types.
*/
#if HAVE_STDINT_H
#include <stdint.h>
#elif _MSC_VER
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
#endif

7279
thirdparty/poppler/poppler/Annot.cc vendored Normal file

File diff suppressed because it is too large Load diff

1609
thirdparty/poppler/poppler/Annot.h vendored Normal file

File diff suppressed because it is too large Load diff

152
thirdparty/poppler/poppler/Array.cc vendored Normal file
View file

@ -0,0 +1,152 @@
//========================================================================
//
// Array.cc
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Albert Astals Cid <aacid@kde.org>
//
// 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
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <stddef.h>
#include "goo/gmem.h"
#include "Object.h"
#include "Array.h"
#if MULTITHREADED
# define arrayLocker() MutexLocker locker(&mutex)
#else
# define arrayLocker()
#endif
//------------------------------------------------------------------------
// Array
//------------------------------------------------------------------------
Array::Array(XRef *xrefA) {
xref = xrefA;
elems = NULL;
size = length = 0;
ref = 1;
#if MULTITHREADED
gInitMutex(&mutex);
#endif
}
Array::~Array() {
int i;
for (i = 0; i < length; ++i)
elems[i].free();
gfree(elems);
#if MULTITHREADED
gDestroyMutex(&mutex);
#endif
}
Object *Array::copy(XRef *xrefA, Object *obj) {
arrayLocker();
obj->initArray(xrefA);
for (int i = 0; i < length; ++i) {
Object obj1;
obj->arrayAdd(elems[i].copy(&obj1));
}
return obj;
}
int Array::incRef() {
arrayLocker();
++ref;
return ref;
}
int Array::decRef() {
arrayLocker();
--ref;
return ref;
}
void Array::add(Object *elem) {
arrayLocker();
if (length == size) {
if (length == 0) {
size = 8;
} else {
size *= 2;
}
elems = (Object *)greallocn(elems, size, sizeof(Object));
}
elems[length] = *elem;
++length;
}
void Array::remove(int i) {
arrayLocker();
if (i < 0 || i >= length) {
#ifdef DEBUG_MEM
abort();
#else
return;
#endif
}
--length;
memmove( elems + i, elems + i + 1, sizeof(elems[0]) * (length - i) );
}
Object *Array::get(int i, Object *obj, int recursion) {
if (i < 0 || i >= length) {
#ifdef DEBUG_MEM
abort();
#else
return obj->initNull();
#endif
}
return elems[i].fetch(xref, obj, recursion);
}
Object *Array::getNF(int i, Object *obj) {
if (i < 0 || i >= length) {
#ifdef DEBUG_MEM
abort();
#else
return obj->initNull();
#endif
}
return elems[i].copy(obj);
}
GBool Array::getString(int i, GooString *string)
{
Object obj;
if (getNF(i, &obj)->isString()) {
string->clear();
string->append(obj.getString());
obj.free();
return gTrue;
} else {
obj.free();
return gFalse;
}
}

84
thirdparty/poppler/poppler/Array.h vendored Normal file
View file

@ -0,0 +1,84 @@
//========================================================================
//
// Array.h
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
//
// 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
//
//========================================================================
#ifndef ARRAY_H
#define ARRAY_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "poppler-config.h"
#include "Object.h"
#include "goo/GooMutex.h"
class XRef;
//------------------------------------------------------------------------
// Array
//------------------------------------------------------------------------
class Array {
public:
// Constructor.
Array(XRef *xrefA);
// Destructor.
~Array();
// Reference counting.
int incRef();
int decRef();
// Get number of elements.
int getLength() { return length; }
// Copy array with new xref
Object *copy(XRef *xrefA, Object *obj);
// Add an element.
void add(Object *elem);
// Remove an element by position
void remove(int i);
// Accessors.
Object *get(int i, Object *obj, int resursion = 0);
Object *getNF(int i, Object *obj);
GBool getString(int i, GooString *string);
private:
XRef *xref; // the xref table for this PDF file
Object *elems; // array of elements
int size; // size of <elems> array
int length; // number of elements in array
int ref; // reference count
#if MULTITHREADED
GooMutex mutex;
#endif
};
#endif

View file

@ -0,0 +1,65 @@
//========================================================================
//
// BuiltinFont.cc
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdlib.h>
#include <string.h>
#include "goo/gmem.h"
#include "FontEncodingTables.h"
#include "BuiltinFont.h"
//------------------------------------------------------------------------
BuiltinFontWidths::BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA) {
int i, h;
size = sizeA;
tab = (BuiltinFontWidth **)gmallocn(size, sizeof(BuiltinFontWidth *));
for (i = 0; i < size; ++i) {
tab[i] = NULL;
}
for (i = 0; i < sizeA; ++i) {
h = hash(widths[i].name);
widths[i].next = tab[h];
tab[h] = &widths[i];
}
}
BuiltinFontWidths::~BuiltinFontWidths() {
gfree(tab);
}
GBool BuiltinFontWidths::getWidth(const char *name, Gushort *width) {
int h;
BuiltinFontWidth *p;
h = hash(name);
for (p = tab[h]; p; p = p->next) {
if (!strcmp(p->name, name)) {
*width = p->width;
return gTrue;
}
}
return gFalse;
}
int BuiltinFontWidths::hash(const char *name) {
const char *p;
unsigned int h;
h = 0;
for (p = name; *p; ++p) {
h = 17 * h + (int)(*p & 0xff);
}
return (int)(h % size);
}

View file

@ -0,0 +1,55 @@
//========================================================================
//
// BuiltinFont.h
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef BUILTINFONT_H
#define BUILTINFONT_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "goo/gtypes.h"
struct BuiltinFont;
class BuiltinFontWidths;
//------------------------------------------------------------------------
struct BuiltinFont {
const char *name;
const char **defaultBaseEnc;
short ascent;
short descent;
short bbox[4];
BuiltinFontWidths *widths;
};
//------------------------------------------------------------------------
struct BuiltinFontWidth {
const char *name;
Gushort width;
BuiltinFontWidth *next;
};
class BuiltinFontWidths {
public:
BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA);
~BuiltinFontWidths();
GBool getWidth(const char *name, Gushort *width);
private:
int hash(const char *name);
BuiltinFontWidth **tab;
int size;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
//========================================================================
//
// BuiltinFontTables.h
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef BUILTINFONTTABLES_H
#define BUILTINFONTTABLES_H
#include "BuiltinFont.h"
#define nBuiltinFonts 14
#define nBuiltinFontSubsts 12
extern BuiltinFont builtinFonts[nBuiltinFonts];
extern BuiltinFont *builtinFontSubst[nBuiltinFontSubsts];
extern void initBuiltinFontTables();
extern void freeBuiltinFontTables();
#endif

598
thirdparty/poppler/poppler/CMap.cc vendored Normal file
View file

@ -0,0 +1,598 @@
//========================================================================
//
// CMap.cc
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2008 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008, 2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2013 Fabio D'Urso <fabiodurso@hotmail.it>
//
// 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
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "goo/gmem.h"
#include "goo/gfile.h"
#include "goo/GooString.h"
#include "Error.h"
#include "GlobalParams.h"
#include "PSTokenizer.h"
#include "CMap.h"
#include "Object.h"
//------------------------------------------------------------------------
struct CMapVectorEntry {
GBool isVector;
union {
CMapVectorEntry *vector;
CID cid;
};
};
//------------------------------------------------------------------------
static int getCharFromFile(void *data) {
return fgetc((FILE *)data);
}
static int getCharFromStream(void *data) {
return ((Stream *)data)->getChar();
}
//------------------------------------------------------------------------
CMap *CMap::parse(CMapCache *, GooString *collectionA, Object *obj) {
CMap *cMap;
GooString *cMapNameA;
if (obj->isName()) {
cMapNameA = new GooString(obj->getName());
if (!(cMap = globalParams->getCMap(collectionA, cMapNameA))) {
error(errSyntaxError, -1,
"Unknown CMap '{0:t}' for character collection '{1:t}'",
cMapNameA, collectionA);
}
delete cMapNameA;
} else if (obj->isStream()) {
if (!(cMap = CMap::parse(NULL, collectionA, obj->getStream()))) {
error(errSyntaxError, -1, "Invalid CMap in Type 0 font");
}
} else {
error(errSyntaxError, -1, "Invalid Encoding in Type 0 font");
return NULL;
}
return cMap;
}
CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
GooString *cMapNameA) {
FILE *f;
CMap *cMap;
if (!(f = globalParams->findCMapFile(collectionA, cMapNameA))) {
// Check for an identity CMap.
if (!cMapNameA->cmp("Identity") || !cMapNameA->cmp("Identity-H")) {
return new CMap(collectionA->copy(), cMapNameA->copy(), 0);
}
if (!cMapNameA->cmp("Identity-V")) {
return new CMap(collectionA->copy(), cMapNameA->copy(), 1);
}
error(errSyntaxError, -1,
"Couldn't find '{0:t}' CMap file for '{1:t}' collection",
cMapNameA, collectionA);
return NULL;
}
cMap = new CMap(collectionA->copy(), cMapNameA->copy());
cMap->parse2(cache, &getCharFromFile, f);
fclose(f);
return cMap;
}
CMap *CMap::parse(CMapCache *cache, GooString *collectionA, Stream *str) {
Object obj1;
CMap *cMap;
cMap = new CMap(collectionA->copy(), NULL);
if (!str->getDict()->lookup("UseCMap", &obj1)->isNull()) {
cMap->useCMap(cache, &obj1);
}
obj1.free();
str->reset();
cMap->parse2(cache, &getCharFromStream, str);
str->close();
return cMap;
}
CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
GooString *cMapNameA, Stream *stream) {
FILE *f = NULL;
CMap *cmap;
PSTokenizer *pst;
char tok1[256], tok2[256], tok3[256];
int n1, n2, n3;
Guint start, end, code;
if (stream) {
stream->reset();
pst = new PSTokenizer(&getCharFromStream, stream);
} else {
if (!(f = globalParams->findCMapFile(collectionA, cMapNameA))) {
// Check for an identity CMap.
if (!cMapNameA->cmp("Identity") || !cMapNameA->cmp("Identity-H")) {
return new CMap(collectionA->copy(), cMapNameA->copy(), 0);
}
if (!cMapNameA->cmp("Identity-V")) {
return new CMap(collectionA->copy(), cMapNameA->copy(), 1);
}
error(errSyntaxError, -1, "Couldn't find '{0:t}' CMap file for '{1:t}' collection",
cMapNameA, collectionA);
return NULL;
}
pst = new PSTokenizer(&getCharFromFile, f);
}
cmap = new CMap(collectionA->copy(), cMapNameA->copy());
pst->getToken(tok1, sizeof(tok1), &n1);
while (pst->getToken(tok2, sizeof(tok2), &n2)) {
if (!strcmp(tok2, "usecmap")) {
if (tok1[0] == '/') {
cmap->useCMap(cache, tok1 + 1);
}
pst->getToken(tok1, sizeof(tok1), &n1);
} else if (!strcmp(tok1, "/WMode")) {
cmap->wMode = atoi(tok2);
pst->getToken(tok1, sizeof(tok1), &n1);
} else if (!strcmp(tok2, "begincidchar")) {
while (pst->getToken(tok1, sizeof(tok1), &n1)) {
if (!strcmp(tok1, "endcidchar")) {
break;
}
if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcidchar")) {
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
break;
}
if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
n1 >= 4 && (n1 & 1) == 0)) {
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
continue;
}
tok1[n1 - 1] = '\0';
if (sscanf(tok1 + 1, "%x", &code) != 1) {
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
continue;
}
n1 = (n1 - 2) / 2;
cmap->addCIDs(code, code, n1, (CID)atoi(tok2));
}
pst->getToken(tok1, sizeof(tok1), &n1);
} else if (!strcmp(tok2, "begincidrange")) {
while (pst->getToken(tok1, sizeof(tok1), &n1)) {
if (!strcmp(tok1, "endcidrange")) {
break;
}
if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcidrange") ||
!pst->getToken(tok3, sizeof(tok3), &n3) ||
!strcmp(tok3, "endcidrange")) {
error(errSyntaxError, -1, "Illegal entry in cidrange block in CMap");
break;
}
if (tok1[0] == '<' && tok2[0] == '<' &&
n1 == n2 && n1 >= 4 && (n1 & 1) == 0) {
tok1[n1 - 1] = tok2[n1 - 1] = '\0';
sscanf(tok1 + 1, "%x", &start);
sscanf(tok2 + 1, "%x", &end);
n1 = (n1 - 2) / 2;
cmap->addCIDs(start, end, n1, (CID)atoi(tok3));
}
}
pst->getToken(tok1, sizeof(tok1), &n1);
} else {
strcpy(tok1, tok2);
}
}
delete pst;
if (f) {
fclose(f);
}
return cmap;
}
void CMap::parse2(CMapCache *cache, int (*getCharFunc)(void *), void *data) {
PSTokenizer *pst;
char tok1[256], tok2[256], tok3[256];
int n1, n2, n3;
Guint start, end, code;
pst = new PSTokenizer(getCharFunc, data);
pst->getToken(tok1, sizeof(tok1), &n1);
while (pst->getToken(tok2, sizeof(tok2), &n2)) {
if (!strcmp(tok2, "usecmap")) {
if (tok1[0] == '/') {
useCMap(cache, tok1 + 1);
}
pst->getToken(tok1, sizeof(tok1), &n1);
} else if (!strcmp(tok1, "/WMode")) {
wMode = atoi(tok2);
pst->getToken(tok1, sizeof(tok1), &n1);
} else if (!strcmp(tok2, "begincidchar")) {
while (pst->getToken(tok1, sizeof(tok1), &n1)) {
if (!strcmp(tok1, "endcidchar")) {
break;
}
if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcidchar")) {
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
break;
}
if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
n1 >= 4 && (n1 & 1) == 0)) {
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
continue;
}
tok1[n1 - 1] = '\0';
if (sscanf(tok1 + 1, "%x", &code) != 1) {
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
continue;
}
n1 = (n1 - 2) / 2;
addCIDs(code, code, n1, (CID)atoi(tok2));
}
pst->getToken(tok1, sizeof(tok1), &n1);
} else if (!strcmp(tok2, "begincidrange")) {
while (pst->getToken(tok1, sizeof(tok1), &n1)) {
if (!strcmp(tok1, "endcidrange")) {
break;
}
if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcidrange") ||
!pst->getToken(tok3, sizeof(tok3), &n3) ||
!strcmp(tok3, "endcidrange")) {
error(errSyntaxError, -1, "Illegal entry in cidrange block in CMap");
break;
}
if (tok1[0] == '<' && tok2[0] == '<' &&
n1 == n2 && n1 >= 4 && (n1 & 1) == 0) {
tok1[n1 - 1] = tok2[n1 - 1] = '\0';
sscanf(tok1 + 1, "%x", &start);
sscanf(tok2 + 1, "%x", &end);
n1 = (n1 - 2) / 2;
addCIDs(start, end, n1, (CID)atoi(tok3));
}
}
pst->getToken(tok1, sizeof(tok1), &n1);
} else {
strcpy(tok1, tok2);
}
}
delete pst;
}
CMap::CMap(GooString *collectionA, GooString *cMapNameA) {
int i;
collection = collectionA;
cMapName = cMapNameA;
isIdent = gFalse;
wMode = 0;
vector = (CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry));
for (i = 0; i < 256; ++i) {
vector[i].isVector = gFalse;
vector[i].cid = 0;
}
refCnt = 1;
#if MULTITHREADED
gInitMutex(&mutex);
#endif
}
CMap::CMap(GooString *collectionA, GooString *cMapNameA, int wModeA) {
collection = collectionA;
cMapName = cMapNameA;
isIdent = gTrue;
wMode = wModeA;
vector = NULL;
refCnt = 1;
#if MULTITHREADED
gInitMutex(&mutex);
#endif
}
void CMap::useCMap(CMapCache *cache, char *useName) {
GooString *useNameStr;
CMap *subCMap;
useNameStr = new GooString(useName);
// if cache is non-NULL, we already have a lock, and we can use
// CMapCache::getCMap() directly; otherwise, we need to use
// GlobalParams::getCMap() in order to acqure the lock need to use
// GlobalParams::getCMap
if (cache) {
subCMap = cache->getCMap(collection, useNameStr, NULL);
} else {
subCMap = globalParams->getCMap(collection, useNameStr);
}
delete useNameStr;
if (!subCMap) {
return;
}
isIdent = subCMap->isIdent;
if (subCMap->vector) {
copyVector(vector, subCMap->vector);
}
subCMap->decRefCnt();
}
void CMap::useCMap(CMapCache *cache, Object *obj) {
CMap *subCMap;
subCMap = CMap::parse(cache, collection, obj);
if (!subCMap) {
return;
}
isIdent = subCMap->isIdent;
if (subCMap->vector) {
copyVector(vector, subCMap->vector);
}
subCMap->decRefCnt();
}
void CMap::copyVector(CMapVectorEntry *dest, CMapVectorEntry *src) {
int i, j;
for (i = 0; i < 256; ++i) {
if (src[i].isVector) {
if (!dest[i].isVector) {
dest[i].isVector = gTrue;
dest[i].vector =
(CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry));
for (j = 0; j < 256; ++j) {
dest[i].vector[j].isVector = gFalse;
dest[i].vector[j].cid = 0;
}
}
copyVector(dest[i].vector, src[i].vector);
} else {
if (dest[i].isVector) {
error(errSyntaxError, -1, "Collision in usecmap");
} else {
dest[i].cid = src[i].cid;
}
}
}
}
void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) {
CMapVectorEntry *vec;
CID cid;
int byte;
Guint i, j;
vec = vector;
for (i = nBytes - 1; i >= 1; --i) {
byte = (start >> (8 * i)) & 0xff;
if (!vec[byte].isVector) {
vec[byte].isVector = gTrue;
vec[byte].vector =
(CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry));
for (j = 0; j < 256; ++j) {
vec[byte].vector[j].isVector = gFalse;
vec[byte].vector[j].cid = 0;
}
}
vec = vec[byte].vector;
}
cid = firstCID;
for (byte = (int)(start & 0xff); byte <= (int)(end & 0xff); ++byte) {
if (vec[byte].isVector) {
error(errSyntaxError, -1,
"Invalid CID ({0:ux} - {1:ux} [{2:ud} bytes]) in CMap",
start, end, nBytes);
} else {
vec[byte].cid = cid;
}
++cid;
}
}
CMap::~CMap() {
delete collection;
delete cMapName;
if (vector) {
freeCMapVector(vector);
}
#if MULTITHREADED
gDestroyMutex(&mutex);
#endif
}
void CMap::freeCMapVector(CMapVectorEntry *vec) {
int i;
for (i = 0; i < 256; ++i) {
if (vec[i].isVector) {
freeCMapVector(vec[i].vector);
}
}
gfree(vec);
}
void CMap::incRefCnt() {
#if MULTITHREADED
gLockMutex(&mutex);
#endif
++refCnt;
#if MULTITHREADED
gUnlockMutex(&mutex);
#endif
}
void CMap::decRefCnt() {
GBool done;
#if MULTITHREADED
gLockMutex(&mutex);
#endif
done = --refCnt == 0;
#if MULTITHREADED
gUnlockMutex(&mutex);
#endif
if (done) {
delete this;
}
}
GBool CMap::match(GooString *collectionA, GooString *cMapNameA) {
return !collection->cmp(collectionA) && !cMapName->cmp(cMapNameA);
}
CID CMap::getCID(char *s, int len, CharCode *c, int *nUsed) {
CMapVectorEntry *vec;
CharCode cc;
int n, i;
vec = vector;
cc = 0;
n = 0;
while (vec && n < len) {
i = s[n++] & 0xff;
cc = (cc << 8) | i;
if (!vec[i].isVector) {
*c = cc;
*nUsed = n;
return vec[i].cid;
}
vec = vec[i].vector;
}
if (isIdent && len >= 2) {
// identity CMap
*nUsed = 2;
*c = cc = ((s[0] & 0xff) << 8) + (s[1] & 0xff);
return cc;
}
*nUsed = 1;
*c = s[0] & 0xff;
return 0;
}
void CMap::setReverseMapVector(Guint startCode, CMapVectorEntry *vec,
Guint *rmap, Guint rmapSize, Guint ncand) {
int i;
if (vec == 0) return;
for (i = 0;i < 256;i++) {
if (vec[i].isVector) {
setReverseMapVector((startCode+i) << 8,
vec[i].vector,rmap,rmapSize,ncand);
} else {
Guint cid = vec[i].cid;
if (cid < rmapSize) {
Guint cand;
for (cand = 0;cand < ncand;cand++) {
Guint code = startCode+i;
Guint idx = cid*ncand+cand;
if (rmap[idx] == 0) {
rmap[idx] = code;
break;
} else if (rmap[idx] == code) {
break;
}
}
}
}
}
}
void CMap::setReverseMap(Guint *rmap, Guint rmapSize, Guint ncand) {
setReverseMapVector(0,vector,rmap,rmapSize,ncand);
}
//------------------------------------------------------------------------
CMapCache::CMapCache() {
int i;
for (i = 0; i < cMapCacheSize; ++i) {
cache[i] = NULL;
}
}
CMapCache::~CMapCache() {
int i;
for (i = 0; i < cMapCacheSize; ++i) {
if (cache[i]) {
cache[i]->decRefCnt();
}
}
}
CMap *CMapCache::getCMap(GooString *collection, GooString *cMapName, Stream *stream) {
CMap *cmap;
int i, j;
if (cache[0] && cache[0]->match(collection, cMapName)) {
cache[0]->incRefCnt();
return cache[0];
}
for (i = 1; i < cMapCacheSize; ++i) {
if (cache[i] && cache[i]->match(collection, cMapName)) {
cmap = cache[i];
for (j = i; j >= 1; --j) {
cache[j] = cache[j - 1];
}
cache[0] = cmap;
cmap->incRefCnt();
return cmap;
}
}
if ((cmap = CMap::parse(this, collection, cMapName, stream))) {
if (cache[cMapCacheSize - 1]) {
cache[cMapCacheSize - 1]->decRefCnt();
}
for (j = cMapCacheSize - 1; j >= 1; --j) {
cache[j] = cache[j - 1];
}
cache[0] = cmap;
cmap->incRefCnt();
return cmap;
}
return NULL;
}

145
thirdparty/poppler/poppler/CMap.h vendored Normal file
View file

@ -0,0 +1,145 @@
//========================================================================
//
// CMap.h
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2008 Koji Otani <sho@bbr.jp>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
//
// 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
//
//========================================================================
#ifndef CMAP_H
#define CMAP_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include "poppler-config.h"
#include "goo/gtypes.h"
#include "CharTypes.h"
#if MULTITHREADED
#include "goo/GooMutex.h"
#endif
class GooString;
class Object;
struct CMapVectorEntry;
class CMapCache;
class Stream;
//------------------------------------------------------------------------
class CMap {
public:
// Parse a CMap from <obj>, which can be a name or a stream. Sets
// the initial reference count to 1. Returns NULL on failure.
static CMap *parse(CMapCache *, GooString *collectionA, Object *obj);
// Create the CMap specified by <collection> and <cMapName>. Sets
// the initial reference count to 1. Returns NULL on failure.
static CMap *parse(CMapCache *cache, GooString *collectionA,
GooString *cMapNameA);
// Parse a CMap from <str>. Sets the initial reference count to 1.
// Returns NULL on failure.
static CMap *parse(CMapCache *cache, GooString *collectionA, Stream *str);
// Create the CMap specified by <collection> and <cMapName>. Sets
// the initial reference count to 1.
// Stream is a stream containing the CMap, can be NULL and
// this means the CMap will be searched in the CMap files
// Returns NULL on failure.
static CMap *parse(CMapCache *cache, GooString *collectionA,
GooString *cMapNameA, Stream *stream);
~CMap();
void incRefCnt();
void decRefCnt();
// Return collection name (<registry>-<ordering>).
GooString *getCollection() { return collection; }
GooString *getCMapName() { return cMapName; }
// Return true if this CMap matches the specified <collectionA>, and
// <cMapNameA>.
GBool match(GooString *collectionA, GooString *cMapNameA);
// Return the CID corresponding to the character code starting at
// <s>, which contains <len> bytes. Sets *<c> to the char code, and
// *<nUsed> to the number of bytes used by the char code.
CID getCID(char *s, int len, CharCode *c, int *nUsed);
// Return the writing mode (0=horizontal, 1=vertical).
int getWMode() { return wMode; }
void setReverseMap(Guint *rmap, Guint rmapSize, Guint ncand);
private:
void parse2(CMapCache *cache, int (*getCharFunc)(void *), void *data);
CMap(GooString *collectionA, GooString *cMapNameA);
CMap(GooString *collectionA, GooString *cMapNameA, int wModeA);
void useCMap(CMapCache *cache, char *useName);
void useCMap(CMapCache *cache, Object *obj);
void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src);
void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID);
void freeCMapVector(CMapVectorEntry *vec);
void setReverseMapVector(Guint startCode, CMapVectorEntry *vec,
Guint *rmap, Guint rmapSize, Guint ncand);
GooString *collection;
GooString *cMapName;
GBool isIdent; // true if this CMap is an identity mapping,
// or is based on one (via usecmap)
int wMode; // writing mode (0=horizontal, 1=vertical)
CMapVectorEntry *vector; // vector for first byte (NULL for
// identity CMap)
int refCnt;
#if MULTITHREADED
GooMutex mutex;
#endif
};
//------------------------------------------------------------------------
#define cMapCacheSize 4
class CMapCache {
public:
CMapCache();
~CMapCache();
// Get the <cMapName> CMap for the specified character collection.
// Increments its reference count; there will be one reference for
// the cache plus one for the caller of this function.
// Stream is a stream containing the CMap, can be NULL and
// this means the CMap will be searched in the CMap files
// Returns NULL on failure.
CMap *getCMap(GooString *collection, GooString *cMapName, Stream *stream);
private:
CMap *cache[cMapCacheSize];
};
#endif

257
thirdparty/poppler/poppler/CachedFile.cc vendored Normal file
View file

@ -0,0 +1,257 @@
//========================================================================
//
// CachedFile.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright 2009 Stefan Thomas <thomas@eload24.com>
// Copyright 2010, 2011 Hib Eris <hib@hiberis.nl>
// Copyright 2010 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2013 Julien Nabet <serval2412@yahoo.fr>
//
//========================================================================
#include <config.h>
#include "CachedFile.h"
//------------------------------------------------------------------------
// CachedFile
//------------------------------------------------------------------------
CachedFile::CachedFile(CachedFileLoader *cachedFileLoaderA, GooString *uriA)
{
uri = uriA;
loader = cachedFileLoaderA;
streamPos = 0;
chunks = new std::vector<Chunk>();
length = 0;
length = loader->init(uri, this);
refCnt = 1;
if (length != ((size_t) -1)) {
chunks->resize(length/CachedFileChunkSize + 1);
}
else {
error(errInternal, -1, "Failed to initialize file cache for '{0:t}'.", uri);
chunks->resize(0);
}
}
CachedFile::~CachedFile()
{
delete uri;
delete loader;
delete chunks;
}
void CachedFile::incRefCnt() {
refCnt++;
}
void CachedFile::decRefCnt() {
if (--refCnt == 0)
delete this;
}
long int CachedFile::tell() {
return streamPos;
}
int CachedFile::seek(long int offset, int origin)
{
if (origin == SEEK_SET) {
streamPos = offset;
} else if (origin == SEEK_CUR) {
streamPos += offset;
} else {
streamPos = length + offset;
}
if (streamPos > length) {
streamPos = 0;
return 1;
}
return 0;
}
int CachedFile::cache(const std::vector<ByteRange> &origRanges)
{
std::vector<int> loadChunks;
int numChunks = length/CachedFileChunkSize + 1;
std::vector<bool> chunkNeeded(numChunks);
int startChunk, endChunk;
std::vector<ByteRange> chunk_ranges, all;
ByteRange range;
const std::vector<ByteRange> *ranges = &origRanges;
if (ranges->empty()) {
range.offset = 0;
range.length = length;
all.push_back(range);
ranges = &all;
}
for (int i = 0; i < numChunks; ++i)
chunkNeeded[i] = false;
for (size_t i = 0; i < ranges->size(); i++) {
if ((*ranges)[i].length == 0) continue;
if ((*ranges)[i].offset >= length) continue;
size_t start = (*ranges)[i].offset;
size_t end = start + (*ranges)[i].length - 1;
if (end >= length) end = length - 1;
startChunk = start / CachedFileChunkSize;
endChunk = end / CachedFileChunkSize;
for (int chunk = startChunk; chunk <= endChunk; chunk++) {
if ((*chunks)[chunk].state == chunkStateNew) {
chunkNeeded[chunk] = true;
}
}
}
int chunk = 0;
while (chunk < numChunks) {
while (!chunkNeeded[chunk] && (++chunk != numChunks)) ;
if (chunk == numChunks) break;
startChunk = chunk;
loadChunks.push_back(chunk);
while ((++chunk != numChunks) && chunkNeeded[chunk]) {
loadChunks.push_back(chunk);
}
endChunk = chunk - 1;
range.offset = startChunk * CachedFileChunkSize;
range.length = (endChunk - startChunk + 1) * CachedFileChunkSize;
chunk_ranges.push_back(range);
}
if (chunk_ranges.size() > 0) {
CachedFileWriter writer =
CachedFileWriter(this, &loadChunks);
return loader->load(chunk_ranges, &writer);
}
return 0;
}
size_t CachedFile::read(void *ptr, size_t unitsize, size_t count)
{
size_t bytes = unitsize*count;
if (length < (streamPos + bytes)) {
bytes = length - streamPos;
}
if (bytes == 0) return 0;
// Load data
if (cache(streamPos, bytes) != 0) return 0;
// Copy data to buffer
size_t toCopy = bytes;
while (toCopy) {
int chunk = streamPos / CachedFileChunkSize;
int offset = streamPos % CachedFileChunkSize;
size_t len = CachedFileChunkSize-offset;
if (len > toCopy)
len = toCopy;
memcpy(ptr, (*chunks)[chunk].data + offset, len);
streamPos += len;
toCopy -= len;
ptr = (char*)ptr + len;
}
return bytes;
}
int CachedFile::cache(size_t offset, size_t length)
{
std::vector<ByteRange> r;
ByteRange range;
range.offset = offset;
range.length = length;
r.push_back(range);
return cache(r);
}
//------------------------------------------------------------------------
// CachedFileWriter
//------------------------------------------------------------------------
CachedFileWriter::CachedFileWriter(CachedFile *cachedFileA, std::vector<int> *chunksA)
{
cachedFile = cachedFileA;
chunks = chunksA;
if (chunks) {
offset = 0;
it = (*chunks).begin();
}
}
CachedFileWriter::~CachedFileWriter()
{
}
size_t CachedFileWriter::write(const char *ptr, size_t size)
{
const char *cp = ptr;
size_t len = size;
size_t nfree, ncopy;
size_t written = 0;
size_t chunk;
if (!len) return 0;
while (len) {
if (chunks) {
if (offset == CachedFileChunkSize) {
++it;
if (it == (*chunks).end()) return written;
offset = 0;
}
chunk = *it;
} else {
offset = cachedFile->length % CachedFileChunkSize;
chunk = cachedFile->length / CachedFileChunkSize;
}
if (chunk >= cachedFile->chunks->size()) {
cachedFile->chunks->resize(chunk + 1);
}
nfree = CachedFileChunkSize - offset;
ncopy = (len >= nfree) ? nfree : len;
memcpy(&((*cachedFile->chunks)[chunk].data[offset]), cp, ncopy);
len -= ncopy;
cp += ncopy;
offset += ncopy;
written += ncopy;
if (!chunks) {
cachedFile->length += ncopy;
}
if (offset == CachedFileChunkSize) {
(*cachedFile->chunks)[chunk].state = CachedFile::chunkStateLoaded;
}
}
if ((chunk == (cachedFile->length / CachedFileChunkSize)) &&
(offset == (cachedFile->length % CachedFileChunkSize))) {
(*cachedFile->chunks)[chunk].state = CachedFile::chunkStateLoaded;
}
return written;
}
//------------------------------------------------------------------------

146
thirdparty/poppler/poppler/CachedFile.h vendored Normal file
View file

@ -0,0 +1,146 @@
//========================================================================
//
// CachedFile.h
//
// Caching files support.
//
// This file is licensed under the GPLv2 or later
//
// Copyright 2009 Stefan Thomas <thomas@eload24.com>
// Copyright 2010 Hib Eris <hib@hiberis.nl>
// Copyright 2010 Albert Astals Cid <aacid@kde.org>
//
//========================================================================
#ifndef CACHEDFILE_H
#define CACHEDFILE_H
#include "poppler-config.h"
#include "goo/gtypes.h"
#include "Object.h"
#include "Stream.h"
#include <vector>
//------------------------------------------------------------------------
#define CachedFileChunkSize 8192 // This should be a multiple of cachedStreamBufSize
class GooString;
class CachedFileLoader;
//------------------------------------------------------------------------
// CachedFile
//
// CachedFile gives FILE-like access to a document at a specified URI.
// In the constructor, you specify a CachedFileLoader that handles loading
// the data from the document. The CachedFile requests no more data then it
// needs from the CachedFileLoader.
//------------------------------------------------------------------------
class CachedFile {
friend class CachedFileWriter;
public:
CachedFile(CachedFileLoader *cacheLoader, GooString *uri);
Guint getLength() { return length; }
long int tell();
int seek(long int offset, int origin);
size_t read(void * ptr, size_t unitsize, size_t count);
size_t write(const char *ptr, size_t size, size_t fromByte);
int cache(const std::vector<ByteRange> &ranges);
// Reference counting.
void incRefCnt();
void decRefCnt();
private:
~CachedFile();
enum ChunkState {
chunkStateNew = 0,
chunkStateLoaded
};
typedef struct {
ChunkState state;
char data[CachedFileChunkSize];
} Chunk;
int cache(size_t offset, size_t length);
CachedFileLoader *loader;
GooString *uri;
size_t length;
size_t streamPos;
std::vector<Chunk> *chunks;
int refCnt; // reference count
};
//------------------------------------------------------------------------
// CachedFileWriter
//
// CachedFileWriter handles sequential writes to a CachedFile.
// On construction, you specify the CachedFile and the chunks of it to which data
// should be written.
//------------------------------------------------------------------------
class CachedFileWriter {
public:
// Construct a CachedFile Writer.
// The caller is responsible for deleting the cachedFile and chunksA.
CachedFileWriter(CachedFile *cachedFile, std::vector<int> *chunksA);
~CachedFileWriter();
// Writes size bytes from ptr to cachedFile, returns number of bytes written.
size_t write(const char *ptr, size_t size);
private:
CachedFile *cachedFile;
std::vector<int> *chunks;
std::vector<int>::iterator it;
size_t offset;
};
//------------------------------------------------------------------------
// CachedFileLoader
//
// CachedFileLoader is an abstact class that specifies the interface for
// loadng data from an URI into a CachedFile.
//------------------------------------------------------------------------
class CachedFileLoader {
public:
virtual ~CachedFileLoader() {};
// Initializes the file load.
// Returns the length of the file.
// The caller is responsible for deleting uri and cachedFile.
virtual size_t init(GooString *uri, CachedFile *cachedFile) = 0;
// Loads speficified byte ranges and passes it to the writer to store them.
// Returns 0 on success, Anything but 0 on failure.
// The caller is responsible for deleting the writer.
virtual int load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer) = 0;
};
//------------------------------------------------------------------------
#endif

View file

@ -0,0 +1,832 @@
//========================================================================
//
// CairoFontEngine.cc
//
// Copyright 2003 Glyph & Cog, LLC
// Copyright 2004 Red Hat, Inc
//
//========================================================================
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005, 2009, 2012, 2013, 2015 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
// Copyright (C) 2008, 2012, 2014 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2009 Darren Kenny <darren.kenny@sun.com>
// Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
// Copyright (C) 2010 Jan Kümmel <jan+freedesktop@snorc.org>
// Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2015 Jason Crain <jason@aquaticape.us>
//
// 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
//
//========================================================================
#include <config.h>
#include "config.h"
#include <string.h>
#include "CairoFontEngine.h"
#include "CairoOutputDev.h"
#include "GlobalParams.h"
#include <fofi/FoFiTrueType.h>
#include <fofi/FoFiType1C.h>
#include "goo/gfile.h"
#include "Error.h"
#include "XRef.h"
#include "Gfx.h"
#include "Page.h"
#if HAVE_FCNTL_H && HAVE_SYS_MMAN_H && HAVE_SYS_STAT_H
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#define CAN_CHECK_OPEN_FACES 1
#endif
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#if MULTITHREADED
# define fontEngineLocker() MutexLocker locker(&mutex)
#else
# define fontEngineLocker()
#endif
//------------------------------------------------------------------------
// CairoFont
//------------------------------------------------------------------------
CairoFont::CairoFont(Ref ref,
cairo_font_face_t *cairo_font_face,
int *codeToGID,
Guint codeToGIDLen,
GBool substitute,
GBool printing) : ref(ref),
cairo_font_face(cairo_font_face),
codeToGID(codeToGID),
codeToGIDLen(codeToGIDLen),
substitute(substitute),
printing(printing) { }
CairoFont::~CairoFont() {
cairo_font_face_destroy (cairo_font_face);
gfree(codeToGID);
}
GBool
CairoFont::matches(Ref &other, GBool printingA) {
return (other.num == ref.num && other.gen == ref.gen);
}
cairo_font_face_t *
CairoFont::getFontFace(void) {
return cairo_font_face;
}
unsigned long
CairoFont::getGlyph(CharCode code,
Unicode *u, int uLen) {
FT_UInt gid;
if (codeToGID && code < codeToGIDLen) {
gid = (FT_UInt)codeToGID[code];
} else {
gid = (FT_UInt)code;
}
return gid;
}
double
CairoFont::getSubstitutionCorrection(GfxFont *gfxFont)
{
double w1, w2;
CharCode code;
char *name;
// for substituted fonts: adjust the font matrix -- compare the
// width of 'm' in the original font and the substituted font
if (isSubstitute() && !gfxFont->isCIDFont()) {
for (code = 0; code < 256; ++code) {
if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) &&
name[0] == 'm' && name[1] == '\0') {
break;
}
}
if (code < 256) {
w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code);
{
cairo_matrix_t m;
cairo_matrix_init_identity(&m);
cairo_font_options_t *options = cairo_font_options_create();
cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF);
cairo_scaled_font_t *scaled_font = cairo_scaled_font_create(cairo_font_face, &m, &m, options);
cairo_text_extents_t extents;
cairo_scaled_font_text_extents(scaled_font, "m", &extents);
cairo_scaled_font_destroy(scaled_font);
cairo_font_options_destroy(options);
w2 = extents.x_advance;
}
if (!gfxFont->isSymbolic()) {
// if real font is substantially narrower than substituted
// font, reduce the font size accordingly
if (w1 > 0.01 && w1 < 0.9 * w2) {
w1 /= w2;
return w1;
}
}
}
}
return 1.0;
}
//------------------------------------------------------------------------
// CairoFreeTypeFont
//------------------------------------------------------------------------
static cairo_user_data_key_t _ft_cairo_key;
static void
_ft_done_face_uncached (void *closure)
{
FT_Face face = (FT_Face) closure;
FT_Done_Face (face);
}
static GBool
_ft_new_face_uncached (FT_Library lib,
const char *filename,
char *font_data,
int font_data_len,
FT_Face *face_out,
cairo_font_face_t **font_face_out)
{
FT_Face face;
cairo_font_face_t *font_face;
if (font_data == NULL) {
if (FT_New_Face (lib, filename, 0, &face))
return gFalse;
} else {
if (FT_New_Memory_Face (lib, (unsigned char *)font_data, font_data_len, 0, &face))
return gFalse;
}
font_face = cairo_ft_font_face_create_for_ft_face (face,
FT_LOAD_NO_HINTING |
FT_LOAD_NO_BITMAP);
if (cairo_font_face_set_user_data (font_face,
&_ft_cairo_key,
face,
_ft_done_face_uncached))
{
_ft_done_face_uncached (face);
cairo_font_face_destroy (font_face);
return gFalse;
}
*face_out = face;
*font_face_out = font_face;
return gTrue;
}
#if CAN_CHECK_OPEN_FACES
static struct _ft_face_data {
struct _ft_face_data *prev, *next, **head;
int fd;
unsigned long hash;
size_t size;
unsigned char *bytes;
FT_Library lib;
FT_Face face;
cairo_font_face_t *font_face;
} *_ft_open_faces;
static unsigned long
_djb_hash (const unsigned char *bytes, size_t len)
{
unsigned long hash = 5381;
while (len--) {
unsigned char c = *bytes++;
hash *= 33;
hash ^= c;
}
return hash;
}
static GBool
_ft_face_data_equal (struct _ft_face_data *a, struct _ft_face_data *b)
{
if (a->lib != b->lib)
return gFalse;
if (a->size != b->size)
return gFalse;
if (a->hash != b->hash)
return gFalse;
return memcmp (a->bytes, b->bytes, a->size) == 0;
}
static void
_ft_done_face (void *closure)
{
struct _ft_face_data *data = (struct _ft_face_data *) closure;
if (data->next)
data->next->prev = data->prev;
if (data->prev)
data->prev->next = data->next;
else
_ft_open_faces = data->next;
if (data->fd != -1) {
#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4)
munmap ((char*)data->bytes, data->size);
#else
munmap (data->bytes, data->size);
#endif
close (data->fd);
} else {
gfree (data->bytes);
}
FT_Done_Face (data->face);
gfree (data);
}
static GBool
_ft_new_face (FT_Library lib,
const char *filename,
char *font_data,
int font_data_len,
FT_Face *face_out,
cairo_font_face_t **font_face_out)
{
struct _ft_face_data *l;
struct stat st;
struct _ft_face_data tmpl;
tmpl.fd = -1;
if (font_data == NULL) {
/* if we fail to mmap the file, just pass it to FreeType instead */
tmpl.fd = open (filename, O_RDONLY);
if (tmpl.fd == -1)
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
if (fstat (tmpl.fd, &st) == -1) {
close (tmpl.fd);
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
}
tmpl.bytes = (unsigned char *) mmap (NULL, st.st_size,
PROT_READ, MAP_PRIVATE,
tmpl.fd, 0);
if (tmpl.bytes == MAP_FAILED) {
close (tmpl.fd);
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
}
tmpl.size = st.st_size;
} else {
tmpl.bytes = (unsigned char*) font_data;
tmpl.size = font_data_len;
}
/* check to see if this is a duplicate of any of the currently open fonts */
tmpl.lib = lib;
tmpl.hash = _djb_hash (tmpl.bytes, tmpl.size);
for (l = _ft_open_faces; l; l = l->next) {
if (_ft_face_data_equal (l, &tmpl)) {
if (tmpl.fd != -1) {
#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4)
munmap ((char*)tmpl.bytes, tmpl.size);
#else
munmap (tmpl.bytes, tmpl.size);
#endif
close (tmpl.fd);
} else {
gfree (tmpl.bytes);
}
*face_out = l->face;
*font_face_out = cairo_font_face_reference (l->font_face);
return gTrue;
}
}
/* not a dup, open and insert into list */
if (FT_New_Memory_Face (lib,
(FT_Byte *) tmpl.bytes, tmpl.size,
0, &tmpl.face))
{
if (tmpl.fd != -1) {
#if defined(__SUNPRO_CC) && defined(__sun) && defined(__SVR4)
munmap ((char*)tmpl.bytes, tmpl.size);
#else
munmap (tmpl.bytes, tmpl.size);
#endif
close (tmpl.fd);
}
return gFalse;
}
l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data));
*l = tmpl;
l->prev = NULL;
l->next = _ft_open_faces;
if (_ft_open_faces)
_ft_open_faces->prev = l;
_ft_open_faces = l;
l->font_face = cairo_ft_font_face_create_for_ft_face (tmpl.face,
FT_LOAD_NO_HINTING |
FT_LOAD_NO_BITMAP);
if (cairo_font_face_set_user_data (l->font_face,
&_ft_cairo_key,
l,
_ft_done_face))
{
cairo_font_face_destroy (l->font_face);
_ft_done_face (l);
return gFalse;
}
*face_out = l->face;
*font_face_out = l->font_face;
return gTrue;
}
#else
#define _ft_new_face _ft_new_face_uncached
#endif
CairoFreeTypeFont::CairoFreeTypeFont(Ref ref,
cairo_font_face_t *cairo_font_face,
int *codeToGID,
Guint codeToGIDLen,
GBool substitute) : CairoFont(ref,
cairo_font_face,
codeToGID,
codeToGIDLen,
substitute,
gTrue) { }
CairoFreeTypeFont::~CairoFreeTypeFont() { }
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
FT_Library lib, GBool useCIDs) {
Object refObj, strObj;
GooString *fileName;
char *fileNameC;
char *font_data;
int font_data_len;
int i, n;
GfxFontType fontType;
GfxFontLoc *fontLoc;
char **enc;
const char *name;
FoFiTrueType *ff;
FoFiType1C *ff1c;
Ref ref;
FT_Face face;
cairo_font_face_t *font_face;
int *codeToGID;
Guint codeToGIDLen;
codeToGID = NULL;
codeToGIDLen = 0;
font_data = NULL;
font_data_len = 0;
fileName = NULL;
fileNameC = NULL;
GBool substitute = gFalse;
ref = *gfxFont->getID();
fontType = gfxFont->getType();
if (!(fontLoc = gfxFont->locateFont(xref, NULL))) {
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
}
// embedded font
if (fontLoc->locType == gfxFontLocEmbedded) {
font_data = gfxFont->readEmbFontFile(xref, &font_data_len);
if (NULL == font_data)
goto err2;
// external font
} else { // gfxFontLocExternal
fileName = fontLoc->path;
fontType = fontLoc->fontType;
substitute = gTrue;
}
if (fileName != NULL) {
fileNameC = fileName->getCString();
}
switch (fontType) {
case fontType1:
case fontType1C:
case fontType1COT:
if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) {
error(errSyntaxError, -1, "could not create type1 face");
goto err2;
}
enc = ((Gfx8BitFont *)gfxFont)->getEncoding();
codeToGID = (int *)gmallocn(256, sizeof(int));
codeToGIDLen = 256;
for (i = 0; i < 256; ++i) {
codeToGID[i] = 0;
if ((name = enc[i])) {
codeToGID[i] = FT_Get_Name_Index(face, (char*)name);
if (codeToGID[i] == 0) {
name = GfxFont::getAlternateName(name);
if (name) {
codeToGID[i] = FT_Get_Name_Index(face, (char*)name);
}
}
}
}
break;
case fontCIDType2:
case fontCIDType2OT:
codeToGID = NULL;
n = 0;
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
if (n) {
codeToGID = (int *)gmallocn(n, sizeof(int));
memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
n * sizeof(int));
}
} else {
if (font_data != NULL) {
ff = FoFiTrueType::make(font_data, font_data_len);
} else {
ff = FoFiTrueType::load(fileNameC);
}
if (! ff)
goto err2;
codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
delete ff;
}
codeToGIDLen = n;
/* Fall through */
case fontTrueType:
if (font_data != NULL) {
ff = FoFiTrueType::make(font_data, font_data_len);
} else {
ff = FoFiTrueType::load(fileNameC);
}
if (! ff) {
error(errSyntaxError, -1, "failed to load truetype font\n");
goto err2;
}
/* This might be set already for the CIDType2 case */
if (fontType == fontTrueType) {
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
codeToGIDLen = 256;
}
delete ff;
if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) {
error(errSyntaxError, -1, "could not create truetype face\n");
goto err2;
}
break;
case fontCIDType0:
case fontCIDType0C:
codeToGID = NULL;
codeToGIDLen = 0;
if (!useCIDs)
{
if (font_data != NULL) {
ff1c = FoFiType1C::make(font_data, font_data_len);
} else {
ff1c = FoFiType1C::load(fileNameC);
}
if (ff1c) {
codeToGID = ff1c->getCIDToGIDMap((int *)&codeToGIDLen);
delete ff1c;
}
}
if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) {
error(errSyntaxError, -1, "could not create cid face\n");
goto err2;
}
break;
default:
fprintf (stderr, "font type %d not handled\n", (int)fontType);
goto err2;
break;
}
delete fontLoc;
return new CairoFreeTypeFont(ref,
font_face,
codeToGID, codeToGIDLen,
substitute);
err2:
/* hmm? */
delete fontLoc;
gfree (codeToGID);
gfree (font_data);
fprintf (stderr, "some font thing failed\n");
return NULL;
}
//------------------------------------------------------------------------
// CairoType3Font
//------------------------------------------------------------------------
static const cairo_user_data_key_t type3_font_key = {0};
typedef struct _type3_font_info {
GfxFont *font;
PDFDoc *doc;
CairoFontEngine *fontEngine;
GBool printing;
XRef *xref;
} type3_font_info_t;
static void
_free_type3_font_info(void *closure)
{
type3_font_info_t *info = (type3_font_info_t *) closure;
info->font->decRefCnt();
free (info);
}
static cairo_status_t
_init_type3_glyph (cairo_scaled_font_t *scaled_font,
cairo_t *cr,
cairo_font_extents_t *extents)
{
type3_font_info_t *info;
GfxFont *font;
double *mat;
info = (type3_font_info_t *)
cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
&type3_font_key);
font = info->font;
mat = font->getFontBBox();
extents->ascent = mat[3]; /* y2 */
extents->descent = -mat[3]; /* -y1 */
extents->height = extents->ascent + extents->descent;
extents->max_x_advance = mat[2] - mat[1]; /* x2 - x1 */
extents->max_y_advance = 0;
return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t
_render_type3_glyph (cairo_scaled_font_t *scaled_font,
unsigned long glyph,
cairo_t *cr,
cairo_text_extents_t *metrics)
{
Dict *charProcs;
Object charProc;
CairoOutputDev *output_dev;
cairo_matrix_t matrix, invert_y_axis;
double *mat;
double wx, wy;
PDFRectangle box;
type3_font_info_t *info;
GfxFont *font;
Dict *resDict;
Gfx *gfx;
info = (type3_font_info_t *)
cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
&type3_font_key);
font = info->font;
resDict = ((Gfx8BitFont *)font)->getResources();
charProcs = ((Gfx8BitFont *)(info->font))->getCharProcs();
if (!charProcs)
return CAIRO_STATUS_USER_FONT_ERROR;
if ((int)glyph >= charProcs->getLength())
return CAIRO_STATUS_USER_FONT_ERROR;
mat = font->getFontMatrix();
matrix.xx = mat[0];
matrix.yx = mat[1];
matrix.xy = mat[2];
matrix.yy = mat[3];
matrix.x0 = mat[4];
matrix.y0 = mat[5];
cairo_matrix_init_scale (&invert_y_axis, 1, -1);
cairo_matrix_multiply (&matrix, &matrix, &invert_y_axis);
cairo_transform (cr, &matrix);
output_dev = new CairoOutputDev();
output_dev->setCairo(cr);
output_dev->setPrinting(info->printing);
mat = font->getFontBBox();
box.x1 = mat[0];
box.y1 = mat[1];
box.x2 = mat[2];
box.y2 = mat[3];
gfx = new Gfx(info->doc, output_dev, resDict, &box, NULL);
output_dev->startDoc(info->doc, info->fontEngine);
output_dev->startPage (1, gfx->getState(), gfx->getXRef());
output_dev->setInType3Char(gTrue);
gfx->display(charProcs->getVal(glyph, &charProc));
output_dev->getType3GlyphWidth (&wx, &wy);
cairo_matrix_transform_distance (&matrix, &wx, &wy);
metrics->x_advance = wx;
metrics->y_advance = wy;
if (output_dev->hasType3GlyphBBox()) {
double *bbox = output_dev->getType3GlyphBBox();
cairo_matrix_transform_point (&matrix, &bbox[0], &bbox[1]);
cairo_matrix_transform_point (&matrix, &bbox[2], &bbox[3]);
metrics->x_bearing = bbox[0];
metrics->y_bearing = bbox[1];
metrics->width = bbox[2] - bbox[0];
metrics->height = bbox[3] - bbox[1];
}
delete gfx;
delete output_dev;
charProc.free();
return CAIRO_STATUS_SUCCESS;
}
CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
CairoFontEngine *fontEngine,
GBool printing, XRef *xref) {
Object refObj, strObj;
type3_font_info_t *info;
cairo_font_face_t *font_face;
Ref ref;
int *codeToGID;
Guint codeToGIDLen;
int i, j;
char **enc;
Dict *charProcs;
char *name;
charProcs = ((Gfx8BitFont *)gfxFont)->getCharProcs();
info = (type3_font_info_t *) malloc(sizeof(*info));
ref = *gfxFont->getID();
font_face = cairo_user_font_face_create();
cairo_user_font_face_set_init_func (font_face, _init_type3_glyph);
cairo_user_font_face_set_render_glyph_func (font_face, _render_type3_glyph);
gfxFont->incRefCnt();
info->font = gfxFont;
info->doc = doc;
info->fontEngine = fontEngine;
info->printing = printing;
info->xref = xref;
cairo_font_face_set_user_data (font_face, &type3_font_key, (void *) info, _free_type3_font_info);
enc = ((Gfx8BitFont *)gfxFont)->getEncoding();
codeToGID = (int *)gmallocn(256, sizeof(int));
codeToGIDLen = 256;
for (i = 0; i < 256; ++i) {
codeToGID[i] = 0;
if (charProcs && (name = enc[i])) {
for (j = 0; j < charProcs->getLength(); j++) {
if (strcmp(name, charProcs->getKey(j)) == 0) {
codeToGID[i] = j;
}
}
}
}
return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref);
}
CairoType3Font::CairoType3Font(Ref ref,
PDFDoc *doc,
cairo_font_face_t *cairo_font_face,
int *codeToGID,
Guint codeToGIDLen,
GBool printing, XRef *xref) : CairoFont(ref,
cairo_font_face,
codeToGID,
codeToGIDLen,
gFalse,
printing),
doc(doc) { }
CairoType3Font::~CairoType3Font() { }
GBool
CairoType3Font::matches(Ref &other, GBool printingA) {
return (other.num == ref.num && other.gen == ref.gen && printing == printingA);
}
//------------------------------------------------------------------------
// CairoFontEngine
//------------------------------------------------------------------------
CairoFontEngine::CairoFontEngine(FT_Library libA) {
int i;
lib = libA;
for (i = 0; i < cairoFontCacheSize; ++i) {
fontCache[i] = NULL;
}
FT_Int major, minor, patch;
// as of FT 2.1.8, CID fonts are indexed by CID instead of GID
FT_Library_Version(lib, &major, &minor, &patch);
useCIDs = major > 2 ||
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
#if MULTITHREADED
gInitMutex(&mutex);
#endif
}
CairoFontEngine::~CairoFontEngine() {
int i;
for (i = 0; i < cairoFontCacheSize; ++i) {
if (fontCache[i])
delete fontCache[i];
}
#if MULTITHREADED
gDestroyMutex(&mutex);
#endif
}
CairoFont *
CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref) {
int i, j;
Ref ref;
CairoFont *font;
GfxFontType fontType;
fontEngineLocker();
ref = *gfxFont->getID();
for (i = 0; i < cairoFontCacheSize; ++i) {
font = fontCache[i];
if (font && font->matches(ref, printing)) {
for (j = i; j > 0; --j) {
fontCache[j] = fontCache[j-1];
}
fontCache[0] = font;
return font;
}
}
fontType = gfxFont->getType();
if (fontType == fontType3)
font = CairoType3Font::create (gfxFont, doc, this, printing, xref);
else
font = CairoFreeTypeFont::create (gfxFont, xref, lib, useCIDs);
//XXX: if font is null should we still insert it into the cache?
if (fontCache[cairoFontCacheSize - 1]) {
delete fontCache[cairoFontCacheSize - 1];
}
for (j = cairoFontCacheSize - 1; j > 0; --j) {
fontCache[j] = fontCache[j-1];
}
fontCache[0] = font;
return font;
}

Some files were not shown because too many files have changed in this diff Show more