1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

Merge pull request #13 from stephengaito/fontforge-update

Fontforge update (update pdf2htmlEX's dependence upon fontforge to fontforge version 20190801) in the pdf2htmlEX development repository
This commit is contained in:
stephengaito 2019-12-13 09:12:42 +00:00 committed by GitHub
commit 7b6f22f636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 155 additions and 1568 deletions

View File

@ -17,7 +17,11 @@ echo ""
# see: https://github.com/travis-ci/travis-ci/issues/5301 (unfixed)
#
if [ -n "$PYTHON_CFLAGS" ] ; then
export PYTHON_CFLAGS="$(pkg-config --cflags python) $PYTHON_CFLAGS"
export PYTHON_CFLAGS="$(python3-config --cflags) $PYTHON_CFLAGS"
fi
if [ -n "$PYTHON_LIBS" ] ; then
export PYTHON_LIBS="$(python3-config --ldflags) $PYTHON_LIBS"
fi
echo ""
@ -26,21 +30,34 @@ echo "-------------------------------"
echo $PYTHON_CFLAGS
echo "-------------------------------"
echo ""
echo ""
echo "PYTHON_LIBS:"
echo "-------------------------------"
echo $PYTHON_LIBS
echo "-------------------------------"
echo ""
# Can use "configure --disable-silent-rules" to debug configuration/make
# problems
#
cd fontforge
./bootstrap
./configure
./configure \
--prefix=/usr/local \
--enable-python-scripting=3 \
--disable-dependency-tracking \
--disable-silent-rules \
--without-x
# Apply any patches required for fontforge raw sources before we make
#
for APATCHFILE in $(ls ../patches/fontforge-$FONTFORGE_VERSION-*)
do
echo "patching fontforge using [$APATCHFILE]"
patch -p 1 < $APATCHFILE
done
#for APATCHFILE in $(ls ../patches/fontforge-$FONTFORGE_VERSION-*)
#do
# echo "patching fontforge using [$APATCHFILE]"
# patch -p 1 < $APATCHFILE
#done
make $MAKE_PARALLEL

View File

@ -10,7 +10,7 @@ export MAKE_PARALLEL="-j $(nproc)"
# choose one of the following...
#
export PDF2HTMLEX_BRANCH=newBuildSystem
export PDF2HTMLEX_BRANCH=fontforge-update
# export PDF2HTMLEX_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
################

View File

@ -24,4 +24,4 @@ sudo apt-get $UNATTENDED install \
liblcms2-dev \
libxml2-dev \
libuninameslist-dev \
libpython-dev
python3-dev

View File

@ -3,7 +3,7 @@
# This bash script automates the process of getting the original pdf2htmlEX
# source
PDF2HTMLEX_BRANCH=newBuildSystem
PDF2HTMLEX_BRANCH=fontforge-update
echo ""
echo "-------------------------------------------------------------------"

0
buildScripts/uploadImages Normal file → Executable file
View File

View File

@ -6,8 +6,8 @@
#export POPPLER_VERSION=poppler-0.82.0
export POPPLER_VERSION=poppler-0.81.0
#export FONTFORGE_VERSION=20190801
export FONTFORGE_VERSION=20170731
export FONTFORGE_VERSION=20190801
#export FONTFORGE_VERSION=20170731
if [ -z "$PDF2HTMLEX_BRANCH" ]; then
export PDF2HTMLEX_BRANCH="$(git rev-parse --abbrev-ref HEAD)"

View File

@ -59,6 +59,7 @@ endif()
pkg_check_modules(FONTFORGE REQUIRED libfontforge>=2.0.0)
include_directories(${FONTFORGE_INCLUDE_DIRS})
link_directories(${FONTFORGE_LIBRARY_DIRS})
set(FONTFORGE_LIBRARIES ${FONTFORGE_LIBRARIES} -lgutils)
set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${FONTFORGE_LIBRARIES})
# debug build flags (overwrite default cmake debug flags)

View File

@ -75,7 +75,7 @@ namespace pdf2htmlEX {
struct HTMLRenderer : OutputDev
{
HTMLRenderer(Param & param);
HTMLRenderer(const char* progPath, Param & param);
virtual ~HTMLRenderer();
void process(PDFDoc * doc);

View File

@ -41,7 +41,7 @@ using std::abs;
using std::cerr;
using std::endl;
HTMLRenderer::HTMLRenderer(Param & param)
HTMLRenderer::HTMLRenderer(const char* progPath, Param & param)
:OutputDev()
,param(param)
,html_text_page(param, all_manager)
@ -56,7 +56,7 @@ HTMLRenderer::HTMLRenderer(Param & param)
globalParams->setErrQuiet(true);
}
ffw_init(param.debug);
ffw_init(progPath, param.debug);
cur_mapping.resize(0x10000);
cur_mapping2.resize(0x100);

View File

@ -439,7 +439,7 @@ int main(int argc, char **argv)
param.last_page = min<int>(max<int>(param.last_page, param.first_page), doc->getNumPages());
unique_ptr<HTMLRenderer>(new HTMLRenderer(param))->process(doc);
unique_ptr<HTMLRenderer>(new HTMLRenderer(argv[0], param))->process(doc);
finished = true;
}

View File

@ -18,19 +18,21 @@
#include "SignalHandler.h"
#include "ffw.h"
#include "fontforge-2.0.20170731/autowidth.h"
#include "fontforge-2.0.20170731/bitmapchar.h"
#include "fontforge-2.0.20170731/cvimages.h"
#include "fontforge-2.0.20170731/encoding.h"
#include "fontforge-2.0.20170731/fvfonts.h"
#include "fontforge-2.0.20170731/namelist.h"
#include "fontforge-2.0.20170731/savefont.h"
#include "fontforge-2.0.20170731/splineorder2.h"
#include "fontforge-2.0.20170731/splineutil.h"
#include "fontforge-2.0.20170731/splineutil2.h"
#include "fontforge-2.0.20170731/start.h"
#include "fontforge-2.0.20170731/tottf.h"
#include "ffw.h" // needed for:
#include "gfile.h" // FindProgDir
#include "fontforge-version-extras.h" // FONTFORGE_GIT_VERSION
#include "fontforge-20190801/autowidth.h" // FVRemoveKerns
#include "fontforge-20190801/bitmapchar.h" // SFReplaceEncodingBDFProps
#include "fontforge-20190801/cvimages.h" // FVImportImages
#include "fontforge-20190801/encoding.h" // (helpful as we have a name conflict)
#include "fontforge-20190801/fvfonts.h" // SFFindSlot
#include "fontforge-20190801/namelist.h" // UniFromName
#include "fontforge-20190801/savefont.h" // GenerateScript
#include "fontforge-20190801/splineorder2.h" // SFConvertToOrder2
#include "fontforge-20190801/splineutil.h" // AltUniFree
#include "fontforge-20190801/splineutil2.h" // SplineFontNew
#include "fontforge-20190801/start.h" // InitSimpleStuff
#include "fontforge-20190801/tottf.h" // SFDefaultOS2Info
static real EPS=1e-6;
@ -66,9 +68,11 @@ static void dumb_logwarning(const char * format, ...) { }
static void dumb_post_error(const char * title, const char * error, ...) { }
void ffw_init(int debug)
void ffw_init(const char* progPath, int debug)
{
ffwSetAction("initialize");
char *localProgPath = strdup(progPath);
FindProgDir(localProgPath);
InitSimpleStuff();
if ( default_encoding==NULL )
default_encoding=FindOrMakeEncoding("ISO8859-1");
@ -126,7 +130,7 @@ const FFWVersionInfo* ffw_get_version_info(void)
ffwVersionInfo.gitVersion = FONTFORGE_GIT_VERSION;
ffwVersionInfo.majorVersion = xstr(FONTFORGE_VERSION_MAJOR);
ffwVersionInfo.minorVersion = xstr(FONTFORGE_VERSION_MINOR);
ffwVersionInfo.versionDate = FONTFORGE_VERSIONDATE;
ffwVersionInfo.versionDate = FONTFORGE_VERSION;
return &ffwVersionInfo;
}
@ -145,15 +149,18 @@ void ffw_load_font(const char * filename)
assert((cur_fv == NULL) && "Previous font is not destroyed");
char * _filename = strcopy(filename);
SplineFont * font = LoadSplineFont(_filename, 1);
SplineFont * font = LoadSplineFont(_filename, of_fstypepermitted);
free(_filename);
if(!font)
err("Cannot load font %s\n", filename);
if(!font->fv)
if(!font->fv) {
assert(fv_interface && "fv_interface not initialized!");
FVAppend(_FontViewCreate(font));
}
assert(font->fv);
@ -170,9 +177,9 @@ void ffw_load_font(const char * filename)
ffwClearAction();
}
/*
* Fight again dirty stuffs
*/
//
// Fight again dirty stuffs
//
void ffw_prepare_font(void)
{
ffwSetAction("prepare");
@ -181,10 +188,10 @@ void ffw_prepare_font(void)
FVRemoveKerns(cur_fv);
FVRemoveVKerns(cur_fv);
/*
* Remove Alternate Unicodes
* We never use them because we will do a force encoding
*/
//
// Remove Alternate Unicodes
// We never use them because we will do a force encoding
//
int i;
SplineFont * sf = cur_fv->sf;
for(i = 0; i < sf->glyphcnt; ++i)
@ -201,10 +208,10 @@ void ffw_prepare_font(void)
}
}
/*
* Wipe out font name
* browsers may rejects fonts with malformed font names
*/
//
// Wipe out font name
// browsers may rejects fonts with malformed font names
//
free(sf->fontname);
sf->fontname = strcopy("");
ffwClearAction();
@ -226,6 +233,7 @@ void ffw_save(const char * filename)
err("Cannot save font to %s\n", filename);
ffwClearAction();
}
void ffw_close(void)
{
ffwSetAction("close");
@ -347,14 +355,14 @@ void ffw_cidflatten(void)
return;
}
ffwSetAction("flatten the cid in");
SFFlatten(cur_fv->sf->cidmaster);
SFFlatten(&(cur_fv->sf->cidmaster));
ffwClearAction();
}
/*
* There is no check if a glyph with the same unicode exists!
* TODO: let FontForge fill in the standard glyph name <- or maybe this might cause collision?
*/
//
// There is no check if a glyph with the same unicode exists!
// TODO: let FontForge fill in the standard glyph name <- or maybe this might cause collision?
//
void ffw_add_empty_char(int32_t unicode, int width)
{
ffwSetAction("add an empty character to");
@ -424,17 +432,17 @@ void ffw_set_metric(double ascent, double descent)
if(a < 0) a = 0;
if(d > 0) d = 0;
/*
sf->ascent = min(a, em);
sf->descent = em - bb.maxy;
*/
//
//sf->ascent = min(a, em);
//sf->descent = em - bb.maxy;
//
/*
* The embedded fonts are likely to have inconsistent values for the 3 sets of ascent/descent
* PDF viewers don't care, since they don't even use these values
* But have to unify them, for different browsers on different platforms
* Things may become easier when there are CSS rules for baseline-based positioning.
*/
//
// The embedded fonts are likely to have inconsistent values for the 3 sets of ascent/descent
// PDF viewers don't care, since they don't even use these values
// But have to unify them, for different browsers on different platforms
// Things may become easier when there are CSS rules for baseline-based positioning.
//
info->os2_winascent = a;
info->os2_typoascent = a;
info->hhead_ascent = a;
@ -454,9 +462,9 @@ void ffw_set_metric(double ascent, double descent)
ffwClearAction();
}
/*
* TODO:bitmap, reference have not been considered in this function
*/
//
// TODO:bitmap, reference have not been considered in this function
//
void ffw_set_widths(int * width_list, int mapping_len,
int stretch_narrow, int squeeze_wide)
{
@ -475,9 +483,9 @@ void ffw_set_widths(int * width_list, int mapping_len,
int imax = min(mapping_len, map->enccount);
for(i = 0; i < imax; ++i)
{
/*
* Don't mess with it if the glyphs is not used.
*/
//
// Don't mess with it if the glyphs is not used.
//
if(width_list[i] == -1)
{
continue;

View File

@ -21,7 +21,7 @@ extern "C" {
////////////////////////
// global
void ffw_init(int debug);
void ffw_init(const char* progPath, int debug);
void ffw_finalize(void);
typedef struct ffw_version_info {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
# FontForge: the missing headers
The FontForge header files in this directory are taken from the
FontForge-20190801 release.
They are headers which are not usually installed by the FontForge make
system.
## Required headers
- `autowidth.h` required for FVRemoveKerns
- `bitmapchar.h` required for SFReplaceEncodingBDFProps
- `cvimages.h` required for FVImportImages
- `fvfonts.h` required for SFFindSlot
- `namelist.h` required for UniFromName
- `savefont.h` required for GenerateScript
- `splineorder2.h` required for SFConvertToOrder2
- `splineutil.h` required for AltUniFree
- `splineutil2.h` required for SplineFontNew
- `start.h` required for InitSimpleStuff
- `tottf.h` required for SFDefaultOS2Info
## Helpful headers
- `encoding.h` conflicts with an existing header in the src/util directory.

View File

@ -3,8 +3,8 @@
#include "baseviews.h"
#include "gimage.h"
#include "splinefont.h"
#include "sd.h"
#include "splinefont.h"
extern GImage *ImageAlterClut(GImage *image);
extern int FVImportImages(FontViewBase *fv, char *path, int format, int toback, int flags);

View File

@ -61,7 +61,7 @@ extern int CIDFromName(char *name, SplineFont *cidmaster);
extern int CountOfEncoding(Encoding *encoding_name);
extern int MaxCID(struct cidmap *map);
extern int NameUni2CID(struct cidmap *map, int uni, const char *name);
extern int SFFlattenByCMap(SplineFont *sf, char *cmapname);
extern int SFFlattenByCMap(SplineFont **sf, char *cmapname);
extern int SFForceEncoding(SplineFont *sf, EncMap *old, Encoding *new_enc);
extern int SFReencode(SplineFont *sf, const char *encname, int force);
extern SplineFont *CIDFlatten(SplineFont *cidmaster, SplineChar **glyphs, int charcnt);

View File

@ -8,6 +8,7 @@ extern char **AllNamelistNames(void);
extern char **SFTemporaryRenameGlyphsToNamelist(SplineFont *sf, NameList *new);
extern const char *RenameGlyphToNamelist(char *buffer, SplineChar *sc, NameList *old, NameList *new, char **sofar);
extern const char *StdGlyphName(char *buffer, int uni, enum uni_interp interp, NameList *for_this_font);
extern const char *StdGlyphNameBoundsCheck(char *buffer, int uni, enum uni_interp interp, NameList *for_this_font);
extern int UniFromName(const char *name, enum uni_interp interp, Encoding *encname);
extern NameList *DefaultNameListForNewFonts(void);
extern NameList *LoadNamelist(char *filename);

View File

@ -32,6 +32,36 @@
#include "splinefont.h"
enum fm_flags { fm_flag_afm = 0x1,
fm_flag_pfm = 0x2,
fm_flag_shortps = 0x4,
fm_flag_nopshints = 0x8,
fm_flag_apple = 0x10,
fm_flag_pfed_comments = 0x20,
fm_flag_pfed_colors = 0x40,
fm_flag_opentype = 0x80,
fm_flag_glyphmap = 0x100,
fm_flag_TeXtable = 0x200,
fm_flag_ofm = 0x400,
fm_flag_applemode = 0x800,
// fm_flag_??? = 0x1000,
fm_flag_symbol = 0x2000,
fm_flag_dummyDSIG = 0x4000,
// fm_flag_??? = 0x8000,
fm_flag_tfm = 0x10000,
fm_flag_nohintsubs = 0x20000,
fm_flag_noflex = 0x40000,
fm_flag_nottfhints = 0x80000,
fm_flag_restrict256 = 0x100000,
fm_flag_round = 0x200000,
fm_flag_afmwithmarks = 0x400000,
fm_flag_pfed_lookups = 0x800000,
fm_flag_pfed_guides = 0x1000000,
fm_flag_pfed_layers = 0x2000000,
fm_flag_winkern = 0x4000000,
fm_flag_nomacnames = 0x8000000,
};
extern const char (*savefont_extensions[]), (*bitmapextensions[]);
extern int old_sfnt_flags;

View File

@ -1,6 +1,7 @@
#ifndef FONTFORGE_SPLINEUTIL_H
#define FONTFORGE_SPLINEUTIL_H
#include "glif_name_hash.h"
#include "psfont.h"
#include "splinefont.h"
#include "ttfinstrs.h"
@ -56,6 +57,8 @@ extern int SplineExistsInSS(Spline *s, SplineSet *ss);
extern int SplinePointIsACorner(SplinePoint *sp);
extern int SplineSetIntersect(SplineSet *spl, Spline **_spline, Spline **_spline2);
extern int SplineSetsRemoveAnnoyingExtrema(SplineSet *ss, bigreal err);
extern int SplineRemoveWildControlPoints(Spline *s, bigreal distratio);
extern int SplineSetsRemoveWildControlPoints(SplineSet *ss, bigreal distratio);
/* Two lines intersect in at most 1 point */
/* Two quadratics intersect in at most 4 points */
@ -130,6 +133,7 @@ extern void GlyphVariantsFree(struct glyphvariants *gv);
extern void GradientFree(struct gradient *grad);
extern void GrowBufferAdd(GrowBuf *gb, int ch);
extern void GrowBufferAddStr(GrowBuf *gb, char *str);
extern void GuidelineSetFree(GuidelineSet *gl);
extern void ImageListsFree(ImageList *imgs);
extern void JstfLangFree(struct jstf_lang *jl);
extern void JustifyFree(Justify *just);
@ -172,7 +176,6 @@ extern void SFInstanciateRefs(SplineFont *sf);
extern void SFReinstanciateRefs(SplineFont *sf);
extern void SFRemoveAnchorClass(SplineFont *sf, AnchorClass *an);
extern void SFRemoveSavedTable(SplineFont *sf, uint32 tag);
extern void SPLCategorizePointsKeepCorners(SplinePointList *spl);
extern void SplineCharFindBounds(SplineChar *sc, DBounds *bounds);
extern void SplineCharFreeContents(SplineChar *sc);
extern void SplineCharLayerFindBounds(SplineChar *sc, int layer, DBounds *bounds);
@ -206,12 +209,9 @@ extern void TTFLangNamesFree(struct ttflangname *l);
extern void TtfTablesFree(struct ttf_table *tab);
extern void ValDevFree(ValDevTab *adjust);
#ifdef FF_UTHASH_GLIF_NAMES
struct glif_name_index;
extern int KerningClassSeekByAbsoluteIndex(const struct splinefont *sf, int seek_index, struct kernclass **okc, int *oisv, int *oisr, int *ooffset);
extern int HashKerningClassNames(SplineFont *sf, struct glif_name_index * class_name_hash);
extern int HashKerningClassNamesCaps(SplineFont *sf, struct glif_name_index * class_name_hash);
extern int HashKerningClassNamesFlex(SplineFont *sf, struct glif_name_index * class_name_hash, int capitalize);
#endif /* FF_UTHASH_GLIF_NAMES */
#endif /* FONTFORGE_SPLINEUTIL_H */