diff options
author | Jonathan Kew <jfkthame@googlemail.com> | 2006-09-07 10:00:56 +0000 |
---|---|---|
committer | Jonathan Kew <jfkthame@googlemail.com> | 2006-09-07 10:00:56 +0000 |
commit | bc784de6a2b45e06374f41e4c658fb7d77fa04b8 (patch) | |
tree | 849bb11cd3b3cfd0bb5a703506382ad374d8fd37 | |
parent | 9a4cd922ac26125fc6de1f680a8ffca74af04956 (diff) |
xetex source update, synced with xetex repo rev.365
git-svn-id: svn://tug.org/texlive/trunk@2093 c570f23f-e606-0410-a88d-b1316a301751
18 files changed, 512 insertions, 448 deletions
diff --git a/Build/source/texk/web2c/xetexdir/LICENSE.txt b/Build/source/texk/web2c/xetexdir/LICENSE.txt new file mode 100644 index 00000000000..ed7486edc2e --- /dev/null +++ b/Build/source/texk/web2c/xetexdir/LICENSE.txt @@ -0,0 +1,31 @@ +/****************************************************************************\ + The XeTeX typesetting system + (an extended version of Donald Knuth's TeX) + written by Jonathan Kew + + The XeTeX changes/additions are copyright (c) 1994-2006 by SIL International + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL SIL INTERNATIONAL BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of SIL International +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in this Software without prior written +authorization from SIL International. +\****************************************************************************/ diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp index b11138b920b..c598b9c96a1 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp @@ -56,9 +56,8 @@ authorization from SIL International. #include <string.h> -XeTeXFontInst::XeTeXFontInst(PlatformFontRef fontRef, float pointSize, LEErrorCode &status) - : fFontRef(fontRef) - , fPointSize(pointSize) +XeTeXFontInst::XeTeXFontInst(float pointSize, LEErrorCode &status) + : fPointSize(pointSize) , fUnitsPerEM(0) , fAscent(0) , fDescent(0) @@ -71,6 +70,7 @@ XeTeXFontInst::XeTeXFontInst(PlatformFontRef fontRef, float pointSize, LEErrorCo , fNumGlyphs(0) , fNumGlyphsInited(false) , fVertical(false) + , fFilename(NULL) { // the concrete subclass is responsible to call initialize() } @@ -291,5 +291,8 @@ XeTeXFontInst::mapGlyphToIndex(const char* glyphName) const { le_uint32 len; const char *p = (const char*)readFontTable(LE_POST_TABLE_TAG, len); - return findGlyphInPostTable(p, len, glyphName); + if (p != NULL) + return findGlyphInPostTable(p, len, glyphName); + else + return 0; } diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h index d158186b66f..a30d7c4b238 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h @@ -64,8 +64,6 @@ extern "C" { class XeTeXFontInst : public LEFontInstance, protected FontTableCache { protected: - PlatformFontRef fFontRef; - float fPointSize; le_int32 fUnitsPerEM; @@ -88,6 +86,8 @@ protected: bool fVertical; // false = horizontal, true = vertical + char *fFilename; // actually holds [filename:index], as used in xetex + virtual const void *readTable(LETag tag, le_uint32 *length) const = 0; void deleteTable(const void *table) const; void getMetrics(); @@ -98,17 +98,19 @@ protected: const void *readFontTable(LETag tableTag, le_uint32& len) const; public: - XeTeXFontInst(PlatformFontRef fontRef, float pointSize, LEErrorCode &status); + XeTeXFontInst(float pointSize, LEErrorCode &status); virtual ~XeTeXFontInst(); - virtual PlatformFontRef getFontRef() const - { return fFontRef; } - virtual void initialize(LEErrorCode &status); virtual const void *getFontTable(LETag tableTag) const; + virtual const char *getFilename() const + { + return fFilename; + } + virtual void setLayoutDirVertical(bool vertical); virtual bool getLayoutDirVertical() const diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp index 499ed7d19b0..cc56442be24 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp @@ -29,24 +29,25 @@ authorization from SIL International. \****************************************************************************/ /* - * file name: XeTeXFontInst_FC.cpp + * file name: XeTeXFontInst_FT2.cpp * * created on: 2005-10-25 * created by: Jonathan Kew */ -#include "XeTeXFontInst_FC.h" +#include "XeTeXFontInst_FT2.h" #include FT_TRUETYPE_TABLES_H #include FT_TYPE1_TABLES_H #include FT_GLYPH_H -static FT_Library gLibrary = 0; +#include <string.h> +FT_Library gFreeTypeLibrary = 0; -XeTeXFontInst_FC::XeTeXFontInst_FC(FcPattern* pattern, float pointSize, LEErrorCode &status) - : XeTeXFontInst(pattern, pointSize, status) +XeTeXFontInst_FT2::XeTeXFontInst_FT2(const char* pathname, int index, float pointSize, LEErrorCode &status) + : XeTeXFontInst(pointSize, status) , face(0) , fFreeTypeOnly(false) { @@ -55,30 +56,50 @@ XeTeXFontInst_FC::XeTeXFontInst_FC(FcPattern* pattern, float pointSize, LEErrorC } FT_Error err; - if (!gLibrary) { - err = FT_Init_FreeType(&gLibrary); + if (!gFreeTypeLibrary) { + err = FT_Init_FreeType(&gFreeTypeLibrary); if (err != 0) { fprintf(stderr, "FreeType initialization failed! (%d)\n", err); exit(1); } } - - FcChar8* pathname = 0; - FcPatternGetString(pattern, FC_FILE, 0, &pathname); - int index; - FcPatternGetInteger(pattern, FC_INDEX, 0, &index); - err = FT_New_Face(gLibrary, (char*)pathname, index, &face); + err = FT_New_Face(gFreeTypeLibrary, (char*)pathname, index, &face); if (err != 0) { status = LE_FONT_FILE_NOT_FOUND_ERROR; return; } + /* for non-sfnt-packaged fonts (presumably Type 1), see if there is an AFM file we can attach */ + if (index == 0 && !FT_IS_SFNT(face)) { + char* afm = new char[strlen((const char*)pathname) + 5]; // room to append ".afm" + strcpy(afm, (const char*)pathname); + char* p = strrchr(afm, '.'); + if (p == NULL || strlen(p) != 4 || tolower(*(p+1)) != 'p' || tolower(*(p+2)) != 'f') + strcat(afm, ".afm"); // append .afm if the extension didn't seem to be .pf[ab] + else + strcpy(p, ".afm"); // else replace extension with .afm + FT_Attach_File(face, afm); // ignore error code; AFM might not exist + delete[] afm; + fFreeTypeOnly = true; + } + initialize(status); + + if (LE_FAILURE(status)) + return; + + char buf[20]; + if (index > 0) + sprintf(buf, ":%d", index); + else + buf[0] = 0; + fFilename = new char[strlen(pathname) + 2 + strlen(buf) + 1]; + sprintf(fFilename, "[%s%s]", pathname, buf); } -XeTeXFontInst_FC::~XeTeXFontInst_FC() +XeTeXFontInst_FT2::~XeTeXFontInst_FT2() { if (face != 0) { FT_Done_Face(face); @@ -86,7 +107,7 @@ XeTeXFontInst_FC::~XeTeXFontInst_FC() } } -void XeTeXFontInst_FC::initialize(LEErrorCode &status) +void XeTeXFontInst_FT2::initialize(LEErrorCode &status) { if (face == 0) { status = LE_FONT_FILE_NOT_FOUND_ERROR; @@ -116,7 +137,7 @@ void XeTeXFontInst_FC::initialize(LEErrorCode &status) return; } -const void *XeTeXFontInst_FC::readTable(LETag tag, le_uint32 *length) const +const void *XeTeXFontInst_FT2::readTable(LETag tag, le_uint32 *length) const { *length = 0; FT_ULong tmpLength = 0; @@ -137,24 +158,8 @@ const void *XeTeXFontInst_FC::readTable(LETag tag, le_uint32 *length) const return table; } -char* XeTeXFontInst_FC::getPSName() const -{ - if (face == NULL) - return NULL; - - const char* facePSName = FT_Get_Postscript_Name(face); - if (facePSName == NULL) - return NULL; - - le_uint32 length = strlen(facePSName); - char* name = (char*)xmalloc(length + 1); - strcpy(name, facePSName); - - return name; -} - void -XeTeXFontInst_FC::getGlyphBounds(LEGlyphID gid, GlyphBBox* bbox) +XeTeXFontInst_FT2::getGlyphBounds(LEGlyphID gid, GlyphBBox* bbox) { bbox->xMin = bbox->yMin = bbox->xMax = bbox->yMax = 0.0; @@ -176,7 +181,7 @@ XeTeXFontInst_FC::getGlyphBounds(LEGlyphID gid, GlyphBBox* bbox) } LEGlyphID -XeTeXFontInst_FC::mapCharToGlyph(LEUnicode32 ch) const +XeTeXFontInst_FT2::mapCharToGlyph(LEUnicode32 ch) const { if (!fFreeTypeOnly) return XeTeXFontInst::mapCharToGlyph(ch); @@ -185,13 +190,13 @@ XeTeXFontInst_FC::mapCharToGlyph(LEUnicode32 ch) const } le_uint16 -XeTeXFontInst_FC::getNumGlyphs() const +XeTeXFontInst_FT2::getNumGlyphs() const { return face->num_glyphs; } void -XeTeXFontInst_FC::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +XeTeXFontInst_FT2::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const { if (!fFreeTypeOnly) XeTeXFontInst::getGlyphAdvance(glyph, advance); @@ -208,10 +213,22 @@ XeTeXFontInst_FC::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const } LEGlyphID -XeTeXFontInst_FC::mapGlyphToIndex(const char* glyphName) const +XeTeXFontInst_FT2::mapGlyphToIndex(const char* glyphName) const { LEGlyphID rval = FT_Get_Name_Index(face, const_cast<char*>(glyphName)); if (rval == 0) rval = XeTeXFontInst::mapGlyphToIndex(glyphName); return rval; } + +void +XeTeXFontInst_FT2::getKernPair(LEGlyphID leftGlyph, LEGlyphID rightGlyph, LEPoint &kern) const +{ + FT_Vector kerning; + if (FT_Get_Kerning(face, leftGlyph, rightGlyph, FT_KERNING_UNSCALED, &kerning) == 0) { + kern.fX = kerning.x; + kern.fY = kerning.y; + } + else + kern.fX = kern.fY = 0; +} diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h index fc88f509c13..fb439114ab9 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h @@ -29,24 +29,22 @@ authorization from SIL International. \****************************************************************************/ /* - * file name: XeTeXFontInst_FC.h + * file name: XeTeXFontInst_FT2.h * * created on: 2005-10-25 * created by: Jonathan Kew */ -#ifndef __XeTeXFontInst_FC_H -#define __XeTeXFontInst_FC_H +#ifndef __XeTeXFontInst_FT2_H +#define __XeTeXFontInst_FT2_H #include "XeTeXFontInst.h" -#include <fontconfig/fontconfig.h> - #include <ft2build.h> #include FT_FREETYPE_H -class XeTeXFontInst_FC : public XeTeXFontInst +class XeTeXFontInst_FT2 : public XeTeXFontInst { protected: @@ -56,14 +54,12 @@ protected: bool fFreeTypeOnly; public: - XeTeXFontInst_FC(FcPattern* pattern, float pointSize, LEErrorCode &status); + XeTeXFontInst_FT2(const char* filename, int index, float pointSize, LEErrorCode &status); - virtual ~XeTeXFontInst_FC(); + virtual ~XeTeXFontInst_FT2(); virtual void initialize(LEErrorCode &status); - virtual char* getPSName() const; // returns a malloced string - virtual void getGlyphBounds(LEGlyphID gid, GlyphBBox* bbox); // overrides of XeTeXFontInst methods, in case it's not an sfnt @@ -71,6 +67,7 @@ public: virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; virtual LEGlyphID mapGlyphToIndex(const char* glyphName) const; + virtual void getKernPair(LEGlyphID leftGlyph, LEGlyphID rightGlyph, LEPoint &kern) const; }; #endif diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp index 2fb44248152..de8d17b748b 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp @@ -40,7 +40,8 @@ authorization from SIL International. #include "XeTeX_ext.h" XeTeXFontInst_Mac::XeTeXFontInst_Mac(ATSFontRef atsFont, float pointSize, LEErrorCode &status) - : XeTeXFontInst(atsFont, pointSize, status) + : XeTeXFontInst(pointSize, status) + , fFontRef(atsFont) , fStyle(0) { if (LE_FAILURE(status)) { diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h index bc3b8831e8b..c91c2b03a34 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h @@ -48,6 +48,7 @@ class XeTeXFontInst_Mac : public XeTeXFontInst protected: const void *readTable(LETag tag, le_uint32 *length) const; + ATSFontRef fFontRef; ATSUStyle fStyle; public: diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp index e6a3efdbdbb..63d9567222f 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp @@ -31,7 +31,7 @@ authorization from SIL International. #ifdef XETEX_MAC #include "XeTeXFontMgr_Mac.h" #else -#include "XeTeXFontMgr_Linux.h" +#include "XeTeXFontMgr_FC.h" #endif #include "XeTeXLayoutInterface.h" @@ -62,7 +62,7 @@ XeTeXFontMgr::GetFontManager() #ifdef XETEX_MAC sFontManager = new XeTeXFontMgr_Mac; #else - sFontManager = new XeTeXFontMgr_Linux; + sFontManager = new XeTeXFontMgr_FC; #endif sFontManager->initialize(); } @@ -371,15 +371,6 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize) } const char* -XeTeXFontMgr::getPSName(PlatformFontRef font) const -{ - std::map<PlatformFontRef,Font*>::const_iterator i = platformRefToFont.find(font); - if (i == platformRefToFont.end()) - die("internal error %d in XeTeXFontMgr", 1); - return i->second->psName->c_str(); -} - -const char* XeTeXFontMgr::getFullName(PlatformFontRef font) const { std::map<PlatformFontRef,Font*>::const_iterator i = platformRefToFont.find(font); diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h index 4a540fc644a..b82194afb07 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h @@ -75,9 +75,6 @@ public: // SIDE EFFECT: edits /variant/ string in-place removing /B or /I - const char* getPSName(PlatformFontRef font) const; - // return PostScript name of a font, suitable for use in the .xdv file - const char* getFullName(PlatformFontRef font) const; // return the full name of the font, suitable for use in XeTeX source // without requiring style qualifiers diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp index c10fc81f985..5f94c3d5fa4 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp @@ -28,7 +28,12 @@ use or other dealings in this Software without prior written authorization from SIL International. \****************************************************************************/ -#include "XeTeXFontMgr_Linux.h" +#include "XeTeXFontMgr_FC.h" + +/* allow compilation with old Fontconfig header */ +#ifndef FC_FULLNAME +#define FC_FULLNAME "fullname" +#endif #include FT_SFNT_NAMES_H #include FT_TRUETYPE_IDS_H @@ -45,6 +50,8 @@ static UConverter* macRomanConv = NULL; static UConverter* utf16beConv = NULL; static UConverter* utf8Conv = NULL; +extern FT_Library gFreeTypeLibrary; /* shared with XeTeXFontInst_FT2 */ + static char* convertToUtf8(UConverter* conv, const unsigned char* name, int len) { @@ -71,7 +78,7 @@ static int bufSize = -1; } XeTeXFontMgr::NameCollection* -XeTeXFontMgr_Linux::readNames(FcPattern* pat) +XeTeXFontMgr_FC::readNames(FcPattern* pat) { NameCollection* names = new NameCollection; @@ -83,7 +90,7 @@ XeTeXFontMgr_Linux::readNames(FcPattern* pat) return names; FT_Face face; - if (FT_New_Face(ftLib, pathname, index, &face) != 0) + if (FT_New_Face(gFreeTypeLibrary, pathname, index, &face) != 0) return names; const char* name = FT_Get_Postscript_Name(face); @@ -177,7 +184,7 @@ XeTeXFontMgr_Linux::readNames(FcPattern* pat) } void -XeTeXFontMgr_Linux::getOpSizeRecAndStyleFlags(Font* theFont) +XeTeXFontMgr_FC::getOpSizeRecAndStyleFlags(Font* theFont) { XeTeXFontMgr::getOpSizeRecAndStyleFlags(theFont); @@ -195,7 +202,7 @@ XeTeXFontMgr_Linux::getOpSizeRecAndStyleFlags(Font* theFont) } void -XeTeXFontMgr_Linux::searchForHostPlatformFonts(const std::string& name) +XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) { static bool cacheAll = false; static FcFontSet* allFonts = NULL; @@ -283,14 +290,14 @@ XeTeXFontMgr_Linux::searchForHostPlatformFonts(const std::string& name) } void -XeTeXFontMgr_Linux::initialize() +XeTeXFontMgr_FC::initialize() { if (FcInit() == FcFalse) { fprintf(stderr, "fontconfig initialization failed!\n"); exit(9); } - if (FT_Init_FreeType(&ftLib) != 0) { + if (gFreeTypeLibrary == 0 && FT_Init_FreeType(&gFreeTypeLibrary) != 0) { fprintf(stderr, "FreeType initialization failed!\n"); exit(9); } @@ -306,7 +313,7 @@ XeTeXFontMgr_Linux::initialize() } void -XeTeXFontMgr_Linux::terminate() +XeTeXFontMgr_FC::terminate() { if (macRomanConv != NULL) ucnv_close(macRomanConv); diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.h b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h index bea40c3deea..764b7ec1d0e 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h @@ -28,18 +28,18 @@ use or other dealings in this Software without prior written authorization from SIL International. \****************************************************************************/ -#ifndef __XETEX_FONT_MGR_LINUX_H -#define __XETEX_FONT_MGR_LINUX_H +#ifndef __XETEX_FONT_MGR_FC_H +#define __XETEX_FONT_MGR_FC_H #include "XeTeXFontMgr.h" -class XeTeXFontMgr_Linux +class XeTeXFontMgr_FC : public XeTeXFontMgr { public: - XeTeXFontMgr_Linux() + XeTeXFontMgr_FC() { } - virtual ~XeTeXFontMgr_Linux() + virtual ~XeTeXFontMgr_FC() { } protected: @@ -51,9 +51,6 @@ protected: virtual void searchForHostPlatformFonts(const std::string& name); virtual NameCollection* readNames(FcPattern* pat); - -private: - FT_Library ftLib; }; -#endif /* __XETEX_FONT_MGR_LINUX_H */ +#endif /* __XETEX_FONT_MGR_FC_H */ diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp index 9a9a48713a7..89bae840bac 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp @@ -34,9 +34,8 @@ authorization from SIL International. #include "XeTeXFontInst.h" #ifdef XETEX_MAC #include "XeTeXFontInst_Mac.h" -#else -#include "XeTeXFontInst_FC.h" #endif +#include "XeTeXFontInst_FT2.h" #include "XeTeXFontMgr.h" @@ -53,6 +52,7 @@ struct XeTeXLayoutEngine_rec { LayoutEngine* layoutEngine; XeTeXFontInst* font; + PlatformFontRef fontRef; UInt32 scriptTag; UInt32 languageTag; UInt32* addedFeatures; @@ -100,7 +100,11 @@ XeTeXFont createFont(PlatformFontRef fontRef, Fixed pointSize) #ifdef XETEX_MAC XeTeXFontInst* font = new XeTeXFontInst_Mac((ATSFontRef)fontRef, Fix2X(pointSize), status); #else - XeTeXFontInst* font = new XeTeXFontInst_FC((FcPattern*)fontRef, Fix2X(pointSize), status); + FcChar8* pathname = 0; + FcPatternGetString(fontRef, FC_FILE, 0, &pathname); + int index; + FcPatternGetInteger(fontRef, FC_INDEX, 0, &index); + XeTeXFontInst* font = new XeTeXFontInst_FT2((const char*)pathname, index, Fix2X(pointSize), status); #endif if (LE_FAILURE(status)) { delete font; @@ -109,14 +113,20 @@ XeTeXFont createFont(PlatformFontRef fontRef, Fixed pointSize) return (XeTeXFont)font; } -void setFontLayoutDir(XeTeXFont font, int vertical) +XeTeXFont createFontFromFile(const char* filename, int index, Fixed pointSize) { - ((XeTeXFontInst*)font)->setLayoutDirVertical(vertical != 0); + LEErrorCode status = LE_NO_ERROR; + XeTeXFontInst* font = new XeTeXFontInst_FT2(filename, index, Fix2X(pointSize), status); + if (LE_FAILURE(status)) { + delete font; + return NULL; + } + return (XeTeXFont)font; } -PlatformFontRef getFontRef(XeTeXLayoutEngine engine) +void setFontLayoutDir(XeTeXFont font, int vertical) { - return engine->font->getFontRef(); + ((XeTeXFontInst*)font)->setLayoutDirVertical(vertical != 0); } PlatformFontRef findFontByName(const char* name, char* var, double size) @@ -134,9 +144,9 @@ const char* getFullName(PlatformFontRef fontRef) return XeTeXFontMgr::GetFontManager()->getFullName(fontRef); } -const char* getPSName(PlatformFontRef fontRef) +const char* getFontFilename(XeTeXLayoutEngine engine) { - return XeTeXFontMgr::GetFontManager()->getPSName(fontRef); + return engine->font->getFilename(); } void getNames(PlatformFontRef fontRef, const char** psName, const char** famName, const char** styName) @@ -144,6 +154,11 @@ void getNames(PlatformFontRef fontRef, const char** psName, const char** famName XeTeXFontMgr::GetFontManager()->getNames(fontRef, psName, famName, styName); } +PlatformFontRef getFontRef(XeTeXLayoutEngine engine) +{ + return engine->fontRef; +} + void deleteFont(XeTeXFont font) { delete (XeTeXFontInst*)font; @@ -317,11 +332,12 @@ XeTeXFont getFont(XeTeXLayoutEngine engine) return (XeTeXFont)(engine->font); } -XeTeXLayoutEngine createLayoutEngine(XeTeXFont font, UInt32 scriptTag, UInt32 languageTag, +XeTeXLayoutEngine createLayoutEngine(PlatformFontRef fontRef, XeTeXFont font, UInt32 scriptTag, UInt32 languageTag, UInt32* addFeatures, UInt32* removeFeatures, UInt32 rgbValue) { LEErrorCode status = LE_NO_ERROR; XeTeXLayoutEngine result = new XeTeXLayoutEngine_rec; + result->fontRef = fontRef; result->font = (XeTeXFontInst*)font; result->scriptTag = scriptTag; result->languageTag = languageTag; diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h index ccfbbe531ec..cc4d2d8a8de 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h @@ -55,15 +55,17 @@ XeTeXFont createFont(ATSFontRef atsFont, Fixed pointSize); // appropriate functions for other platforms XeTeXFont createFont(PlatformFontRef fontRef, Fixed pointSize); #endif +XeTeXFont createFontFromFile(const char* filename, int index, Fixed pointSize); void setFontLayoutDir(XeTeXFont font, int vertical); -PlatformFontRef getFontRef(XeTeXLayoutEngine engine); PlatformFontRef findFontByName(const char* name, char* var, double size); char getReqEngine(); const char* getFullName(PlatformFontRef fontRef); -const char* getPSName(PlatformFontRef fontRef); + +const char* getFontFilename(XeTeXLayoutEngine engine); + void getNames(PlatformFontRef fontRef, const char** psName, const char** famName, const char** styName); void deleteFont(XeTeXFont font); @@ -81,12 +83,13 @@ UInt32 getIndFeature(XeTeXFont font, UInt32 script, UInt32 language, UInt32 inde float getGlyphWidth(XeTeXFont font, UInt32 gid); UInt32 countGlyphs(XeTeXFont font); -XeTeXLayoutEngine createLayoutEngine(XeTeXFont font, UInt32 scriptTag, UInt32 languageTag, +XeTeXLayoutEngine createLayoutEngine(PlatformFontRef fontRef, XeTeXFont font, UInt32 scriptTag, UInt32 languageTag, UInt32* addFeatures, UInt32* removeFeatures, UInt32 rgbValue); void deleteLayoutEngine(XeTeXLayoutEngine engine); XeTeXFont getFont(XeTeXLayoutEngine engine); +PlatformFontRef getFontRef(XeTeXLayoutEngine engine); SInt32 layoutChars(XeTeXLayoutEngine engine, UInt16* chars, SInt32 offset, SInt32 count, SInt32 max, char rightToLeft, float x, float y, SInt32* status); diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c index 99db577faca..0a7eb956a6e 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c +++ b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c @@ -443,7 +443,7 @@ read_tag(const char* cp) } static void* -loadOTfont(XeTeXFont font, Fixed scaled_size, const char* cp1) +loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const char* cp1) { XeTeXLayoutEngine engine; UInt32 scriptTag = kLatin; @@ -637,7 +637,7 @@ loadOTfont(XeTeXFont font, Fixed scaled_size, const char* cp1) if ((loadedfontflags & FONT_FLAGS_VERTICAL) != 0) setFontLayoutDir(font, 1); - engine = createLayoutEngine(font, scriptTag, languageTag, addFeatures, removeFeatures, rgbValue); + engine = createLayoutEngine(fontRef, font, scriptTag, languageTag, addFeatures, removeFeatures, rgbValue); if (engine == 0) { deleteFont(font); if (addFeatures) @@ -656,14 +656,35 @@ splitFontName(char* name, char** var, char** feat, char** end) { *var = NULL; *feat = NULL; - while (*name) { - if (*name == '/' && *var == NULL && *feat == NULL) - *var = name; - else if (*name == ':' && *feat == NULL) - *feat = name; + if (*name == '[') { ++name; + int withinFileName = 1; + while (*name) { + if (withinFileName && *name == ']') { + withinFileName = 0; + if (*var == NULL) + *var = name; + } + else if (*name == ':') { + if (withinFileName && *var == NULL) + *var = name; + else if (!withinFileName && *feat == NULL) + *feat = name; + } + ++name; + } + *end = name; + } + else { + while (*name) { + if (*name == '/' && *var == NULL && *feat == NULL) + *var = name; + else if (*name == ':' && *feat == NULL) + *feat = name; + ++name; + } + *end = name; } - *end = name; if (*feat == NULL) *feat = name; if (*var == NULL) @@ -707,54 +728,77 @@ findnativefont(unsigned char* uname, long scaled_size) featString[end - feat - 1] = 0; } - fontRef = findFontByName(nameString, varString, Fix2X(scaled_size)); - - if (fontRef != 0) { - /* update nameoffile to the full name of the font, for error messages during font loading */ - const char* fullName = getFullName(fontRef); - namelength = strlen(fullName); - if (featString != NULL) - namelength += strlen(featString) + 1; - if (varString != NULL) - namelength += strlen(varString) + 1; - free(nameoffile); - nameoffile = xmalloc(namelength + 4); /* +2 would be correct: initial space, final NUL */ - nameoffile[0] = ' '; - strcpy((char*)nameoffile + 1, fullName); - + // check for "[filename]" form, don't search maps in this case + if (nameString[0] == '[') { + char* path = kpse_find_file(nameString + 1, kpse_opentype_format, 0); + if (path == NULL) + path = kpse_find_file(nameString + 1, kpse_truetype_format, 0); + if (path == NULL) + path = kpse_find_file(nameString + 1, kpse_type1_format, 0); + if (path != NULL) { + int index = 0; + if (varString != NULL) { + char* cp; + for (cp = varString; *cp && isdigit(*cp); ++cp) + index = index * 10 + *cp - '0'; + } + font = createFontFromFile(path, index, scaled_size); + if (font != NULL) { + rval = loadOTfont(0, font, scaled_size, featString); + if (rval == 0) + deleteFont(font); + } + } + } + else { + fontRef = findFontByName(nameString, varString, Fix2X(scaled_size)); + + if (fontRef != 0) { + /* update nameoffile to the full name of the font, for error messages during font loading */ + const char* fullName = getFullName(fontRef); + namelength = strlen(fullName); + if (featString != NULL) + namelength += strlen(featString) + 1; + if (varString != NULL) + namelength += strlen(varString) + 1; + free(nameoffile); + nameoffile = xmalloc(namelength + 4); /* +2 would be correct: initial space, final NUL */ + nameoffile[0] = ' '; + strcpy((char*)nameoffile + 1, fullName); + #ifdef XETEX_MAC - /* decide whether to use AAT or OpenType rendering with this font */ - if (getReqEngine() == 'A') - goto load_aat; + /* decide whether to use AAT or OpenType rendering with this font */ + if (getReqEngine() == 'A') + goto load_aat; #endif - - font = createFont(fontRef, scaled_size); - if (font != 0) { + + font = createFont(fontRef, scaled_size); + if (font != 0) { #ifdef XETEX_MAC - if (getReqEngine() == 'I' || getFontTablePtr(font, kGSUB) != 0 || getFontTablePtr(font, kGPOS) != 0) + if (getReqEngine() == 'I' || getFontTablePtr(font, kGSUB) != 0 || getFontTablePtr(font, kGPOS) != 0) #endif - rval = loadOTfont(font, scaled_size, featString); - if (rval == 0) - deleteFont(font); - } - + rval = loadOTfont(fontRef, font, scaled_size, featString); + if (rval == 0) + deleteFont(font); + } + #ifdef XETEX_MAC - if (rval == 0) { - load_aat: - rval = loadAATfont(fontRef, scaled_size, featString); - } + if (rval == 0) { + load_aat: + rval = loadAATfont(fontRef, scaled_size, featString); + } #endif - - /* append the style and feature strings, so that \show\fontID will give a full result */ - if (varString != NULL && *varString != 0) { - strcat((char*)nameoffile + 1, "/"); - strcat((char*)nameoffile + 1, varString); - } - if (featString != NULL && *featString != 0) { - strcat((char*)nameoffile + 1, ":"); - strcat((char*)nameoffile + 1, featString); + /* append the style and feature strings, so that \show\fontID will give a full result */ + if (varString != NULL && *varString != 0) { + strcat((char*)nameoffile + 1, "/"); + strcat((char*)nameoffile + 1, varString); + } + if (featString != NULL && *featString != 0) { + strcat((char*)nameoffile + 1, ":"); + strcat((char*)nameoffile + 1, featString); + } + namelength = strlen((char*)nameoffile + 1); } - namelength = strlen((char*)nameoffile + 1); } if (varString != NULL) @@ -978,8 +1022,6 @@ makeXDVGlyphArrayData(void* pNode) long makefontdef(long f) { - PlatformFontRef fontRef; - UInt16 flags = 0; UInt32 variationCount = 0; UInt32 rgba; @@ -992,6 +1034,7 @@ makefontdef(long f) UInt8 styLen; int fontDefLength; char* cp; + PlatformFontRef fontRef = 0; #ifdef XETEX_MAC ATSUStyle style = NULL; @@ -1005,6 +1048,8 @@ makefontdef(long f) ATSUGetAttribute(style, kATSUFontTag, sizeof(ATSUFontID), &fontID, 0); fontRef = FMGetATSFontRefFromFont(fontID); + getNames(fontRef, &psName, &famName, &styName); + /* returns ptrs to strings that belong to the font - do not free! */ ATSUVerticalCharacterType vert; ATSUGetAttribute(style, kATSUVerticalCharacterTag, sizeof(ATSUVerticalCharacterType), &vert, 0); @@ -1025,6 +1070,13 @@ makefontdef(long f) engine = (XeTeXLayoutEngine)fontlayoutengine[f]; fontRef = getFontRef(engine); + if (fontRef != 0) + getNames(fontRef, &psName, &famName, &styName); + else { + psName = getFontFilename(engine); + famName = ""; + styName = ""; + } rgba = getRgbValue(engine); if ((fontflags[f] & FONT_FLAGS_VERTICAL) != 0) @@ -1037,9 +1089,6 @@ makefontdef(long f) exit(3); } - getNames(fontRef, &psName, &famName, &styName); - /* returns ptrs to strings that belong to the font - do not free! */ - psLen = strlen(psName); famLen = strlen(famName); styLen = strlen(styName); @@ -2133,11 +2182,27 @@ open_dvi_output(FILE** fptr) return open_output(fptr, FOPEN_WBIN_MODE); } else { - char* cmd2 = concat(outputdriver, " -o \""); - char* cmd = concat3(cmd2, (char*)nameoffile+1, "\""); - free(cmd2); + const char *p = (const char*)nameoffile+1; + char *cmd, *q; + int len = strlen(p); + while (*p) + if (*p++ == '\"') + ++len; + len += strlen(outputdriver); + len += 8; /* space for -o flag, quotes, NUL */ + cmd = xmalloc(len); + strcpy(cmd, outputdriver); + strcat(cmd, " -o \""); + q = cmd + strlen(cmd); + for (p = (const char*)nameoffile+1; *p; p++) { + if (*p == '\"') + *q++ = '\\'; + *q++ = *p; + } + *q++ = '\"'; + *q = '\0'; if (papersize != 0) { - cmd2 = concat3(cmd, " -p ", papersize); + char* cmd2 = concat3(cmd, " -p ", papersize); free(cmd); cmd = cmd2; } diff --git a/Build/source/texk/web2c/xetexdir/cpl1.0.txt b/Build/source/texk/web2c/xetexdir/cpl1.0.txt deleted file mode 100644 index c9990a7ea45..00000000000 --- a/Build/source/texk/web2c/xetexdir/cpl1.0.txt +++ /dev/null @@ -1,213 +0,0 @@ -Common Public License Version 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC -LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM -CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - - a) in the case of the initial Contributor, the initial code and -documentation distributed under this Agreement, and - - b) in the case of each subsequent Contributor: - - i) changes to the Program, and - - ii) additions to the Program; - - where such changes and/or additions to the Program originate from and are -distributed by that particular Contributor. A Contribution 'originates' from a -Contributor if it was added to the Program by such Contributor itself or anyone -acting on such Contributor's behalf. Contributions do not include additions to -the Program which: (i) are separate modules of software distributed in -conjunction with the Program under their own license agreement, and (ii) are not -derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are -necessarily infringed by the use or sale of its Contribution alone or when -combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, -including all Contributors. - -2. GRANT OF RIGHTS - - a) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free copyright license to -reproduce, prepare derivative works of, publicly display, publicly perform, -distribute and sublicense the Contribution of such Contributor, if any, and such -derivative works, in source code and object code form. - - b) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed -Patents to make, use, sell, offer to sell, import and otherwise transfer the -Contribution of such Contributor, if any, in source code and object code form. -This patent license shall apply to the combination of the Contribution and the -Program if, at the time the Contribution is added by the Contributor, such -addition of the Contribution causes such combination to be covered by the -Licensed Patents. The patent license shall not apply to any other combinations -which include the Contribution. No hardware per se is licensed hereunder. - - c) Recipient understands that although each Contributor grants the licenses -to its Contributions set forth herein, no assurances are provided by any -Contributor that the Program does not infringe the patent or other intellectual -property rights of any other entity. Each Contributor disclaims any liability to -Recipient for claims brought by any other entity based on infringement of -intellectual property rights or otherwise. As a condition to exercising the -rights and licenses granted hereunder, each Recipient hereby assumes sole -responsibility to secure any other intellectual property rights needed, if any. -For example, if a third party patent license is required to allow Recipient to -distribute the Program, it is Recipient's responsibility to acquire that license -before distributing the Program. - - d) Each Contributor represents that to its knowledge it has sufficient -copyright rights in its Contribution, if any, to grant the copyright license set -forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its -own license agreement, provided that: - - a) it complies with the terms and conditions of this Agreement; and - - b) its license agreement: - - i) effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title and -non-infringement, and implied warranties or conditions of merchantability and -fitness for a particular purpose; - - ii) effectively excludes on behalf of all Contributors all liability for -damages, including direct, indirect, special, incidental and consequential -damages, such as lost profits; - - iii) states that any provisions which differ from this Agreement are offered -by that Contributor alone and not by any other party; and - - iv) states that source code for the Program is available from such -Contributor, and informs licensees how to obtain it in a reasonable manner on or -through a medium customarily used for software exchange. - -When the Program is made available in source code form: - - a) it must be made available under this Agreement; and - - b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the -Program. - -Each Contributor must identify itself as the originator of its Contribution, if -any, in a manner that reasonably allows subsequent Recipients to identify the -originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with -respect to end users, business partners and the like. While this license is -intended to facilitate the commercial use of the Program, the Contributor who -includes the Program in a commercial product offering should do so in a manner -which does not create potential liability for other Contributors. Therefore, if -a Contributor includes the Program in a commercial product offering, such -Contributor ("Commercial Contributor") hereby agrees to defend and indemnify -every other Contributor ("Indemnified Contributor") against any losses, damages -and costs (collectively "Losses") arising from claims, lawsuits and other legal -actions brought by a third party against the Indemnified Contributor to the -extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor to -control, and cooperate with the Commercial Contributor in, the defense and any -related settlement negotiations. The Indemnified Contributor may participate in -any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product -offering, Product X. That Contributor is then a Commercial Contributor. If that -Commercial Contributor then makes performance claims, or offers warranties -related to Product X, those performance claims and warranties are such -Commercial Contributor's responsibility alone. Under this section, the -Commercial Contributor would have to defend claims against the other -Contributors related to those performance claims and warranties, and if a court -requires any other Contributor to pay any damages as a result, the Commercial -Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR -IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each -Recipient is solely responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its exercise of -rights under this Agreement, including but not limited to the risks and costs of -program errors, compliance with applicable laws, damage to or loss of data, -programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY -CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST -PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS -GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable -law, it shall not affect the validity or enforceability of the remainder of the -terms of this Agreement, and without further action by the parties hereto, such -provision shall be reformed to the minimum extent necessary to make such -provision valid and enforceable. - -If Recipient institutes patent litigation against a Contributor with respect to -a patent applicable to software (including a cross-claim or counterclaim in a -lawsuit), then any patent licenses granted by that Contributor to such Recipient -under this Agreement shall terminate as of the date such litigation is filed. In -addition, if Recipient institutes patent litigation against any entity -(including a cross-claim or counterclaim in a lawsuit) alleging that the Program -itself (excluding combinations of the Program with other software or hardware) -infringes such Recipient's patent(s), then such Recipient's rights granted under -Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to -comply with any of the material terms or conditions of this Agreement and does -not cure such failure in a reasonable period of time after becoming aware of -such noncompliance. If all Recipient's rights under this Agreement terminate, -Recipient agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient's obligations under this Agreement -and any licenses granted by Recipient relating to the Program shall continue and -survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in -order to avoid inconsistency the Agreement is copyrighted and may only be -modified in the following manner. The Agreement Steward reserves the right to -publish new versions (including revisions) of this Agreement from time to time. -No one other than the Agreement Steward has the right to modify this Agreement. -IBM is the initial Agreement Steward. IBM may assign the responsibility to serve -as the Agreement Steward to a suitable separate entity. Each new version of the -Agreement will be given a distinguishing version number. The Program (including -Contributions) may always be distributed subject to the version of the Agreement -under which it was received. In addition, after a new version of the Agreement -is published, Contributor may elect to distribute the Program (including its -Contributions) under the new version. Except as expressly stated in Sections -2(a) and 2(b) above, Recipient receives no rights or licenses to the -intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the -intellectual property laws of the United States of America. No party to this -Agreement will bring a legal action under this Agreement more than one year -after the cause of action arose. Each party waives its rights to a jury trial in -any resulting litigation. diff --git a/Build/source/texk/web2c/xetexdir/pdfimage.cpp b/Build/source/texk/web2c/xetexdir/pdfimage.cpp index 26d1bc79196..c5eb2fedcec 100644 --- a/Build/source/texk/web2c/xetexdir/pdfimage.cpp +++ b/Build/source/texk/web2c/xetexdir/pdfimage.cpp @@ -40,7 +40,7 @@ pdf_get_rect(char* filename, int page_num, int pdf_box, realrect* box) if (page_num > pages) page_num = pages; if (page_num < 0) - page_num = pages + 1 - page_num; + page_num = pages + 1 + page_num; if (page_num < 1) page_num = 1; diff --git a/Build/source/texk/web2c/xetexdir/xetex-new.ch b/Build/source/texk/web2c/xetexdir/xetex-new.ch index 8c8bf117e14..7f76fbdcd6b 100644 --- a/Build/source/texk/web2c/xetexdir/xetex-new.ch +++ b/Build/source/texk/web2c/xetexdir/xetex-new.ch @@ -199,15 +199,6 @@ system libraries. @z @x -@!eight_bit_p:c_int_type; {make all characters printable by default} -@!halt_on_error_p:c_int_type; {stop at first error} -@!quoted_filename:boolean; {current filename is quoted} -@y -@!eight_bit_p:c_int_type; {make all characters printable by default} -@!halt_on_error_p:c_int_type; {stop at first error} -@z - -@x @* \[4] String handling. @y @* \[4] String handling. @@ -1304,6 +1295,13 @@ else begin k:=str_start_macro(s); l:=str_start_macro(s+1)-k; @z @x +primitive("mathaccent",math_accent,0);@/ +@y +primitive("mathaccent",math_accent,0);@/ +primitive("XeTeXmathaccent",math_accent,1);@/ +@z + +@x primitive("mathchar",math_char_num,0);@/ @!@:math_char_}{\.{\\mathchar} primitive@> @y @@ -1327,6 +1325,13 @@ end_cs_name: print_esc("endcsname"); @z @x +math_accent: print_esc("mathaccent"); +@y +math_accent: if chr_code=1 then print_esc("XeTeXmathaccent") + else print_esc("mathaccent"); +@z + +@x math_char_num: print_esc("mathchar"); @y math_char_num: if chr_code=2 then print_esc("XeTeXextmathchar") @@ -1742,7 +1747,9 @@ else if m=math_code_base then scanned_result(ho(math_code(cur_val)))(int_val) @y if m=math_code_base then begin cur_val1:=ho(math_code(cur_val)); - if (math_class_field(cur_val1)>8) or + if is_active_math_char(cur_val1) then + cur_val1:=@"8000 + else if (math_class_field(cur_val1)>8) or (math_fam_field(cur_val1)>15) or (math_char_field(cur_val1)>255) then begin print_err("Extended mathchar used as mathchar"); @@ -1796,15 +1803,19 @@ end @z @x +procedure scan_eight_bit_int; +begin scan_int; if (cur_val<0)or(cur_val>255) then -@y -if (cur_val<0)or(cur_val>biggest_reg) then -@z - -@x + begin print_err("Bad register code"); +@.Bad register code@> help2("A register number must be between 0 and 255.")@/ @y - help2("A register number must be between 0 and 65535.")@/ +procedure scan_eight_bit_int; {only used for insertion numbers now} +begin scan_int; +if (cur_val<0)or(cur_val>255) then + begin print_err("Bad register code"); +@.Bad register code@> + help2("An insertion number must be between 0 and 255.")@/ @z @x @@ -2069,6 +2080,12 @@ eTeX_revision_code: print(eTeX_revision); @z @x +job_name_code: print(job_name); +@y +job_name_code: print_file_name(job_name, 0, 0); +@z + +@x @!read_file:array[0..15] of alpha_file; {used for \.{\\read}} @y @!read_file:array[0..15] of unicode_file; {used for \.{\\read}} @@ -2128,7 +2145,7 @@ includes spaces is ``quoted'' somehow. @x begin area_delimiter:=0; ext_delimiter:=0; quoted_filename:=false; @y -begin area_delimiter:=0; ext_delimiter:=0; +begin area_delimiter:=0; ext_delimiter:=0; quoted_filename:=false; file_name_quote_char:=0; @z @@ -2140,36 +2157,20 @@ else if c="""" then begin quoted_filename:=not quoted_filename; more_name:=true; end -else begin str_room(1); append_char(c); {contribute |c| to the current string} - if IS_DIR_SEP(c) then - begin area_delimiter:=cur_length; ext_delimiter:=0; - end - else if c="." then ext_delimiter:=cur_length; - more_name:=true; - end; -end; @y @p function more_name(@!c:ASCII_code):boolean; -begin if stop_at_space and (c=" ") then more_name:=false -else begin - if (cur_length=0) and stop_at_space - and ((c="'") or (c="""") or (c="(")) then begin - if c="(" then file_name_quote_char:=")" else file_name_quote_char:=c; - stop_at_space:=false; more_name:=true; +begin if stop_at_space and (c=" ") and (file_name_quote_char=0) then + more_name:=false +else if stop_at_space and (file_name_quote_char<>0) and (c=file_name_quote_char) then begin + file_name_quote_char:=0; + more_name:=true; end - else if (file_name_quote_char<>0) and (c=file_name_quote_char) then begin - stop_at_space:=true; more_name:=false; +else if stop_at_space and (file_name_quote_char=0) and ((c="""") or (c="'") or (c="(")) then begin + if c="(" then file_name_quote_char:=")" + else file_name_quote_char:=c; + quoted_filename:=true; + more_name:=true; end - else begin - str_room(1); append_char(c); {contribute |c| to the current string} - if IS_DIR_SEP(c) then - begin area_delimiter:=cur_length; ext_delimiter:=0; - end - else if c="." then ext_delimiter:=cur_length; - more_name:=true; - end; -end; -end; @z @x @@ -2313,7 +2314,77 @@ if must_quote then print_char(""""); end; @y procedure print_file_name(@!n,@!a,@!e:integer); -begin slow_print(a); slow_print(n); slow_print(e); +var @!must_quote: boolean; {whether to quote the filename} +@!quote_char: integer; {current quote char (single or double)} +@!j:pool_pointer; {index into |str_pool|} +begin +must_quote:=false; +quote_char:=0; +if a<>0 then begin + j:=str_start_macro(a); + while ((not must_quote) or (quote_char=0)) and (j<>str_start_macro(a+1)) do begin + if (str_pool[j]=" ") then must_quote:=true + else if (str_pool[j]="""") or (str_pool[j]="'") then begin + must_quote:=true; + quote_char:="""" + "'" - str_pool[j]; + end; + incr(j); + end; +end; +if n<>0 then begin + j:=str_start_macro(n); + while ((not must_quote) or (quote_char=0)) and (j<>str_start_macro(n+1)) do begin + if (str_pool[j]=" ") then must_quote:=true + else if (str_pool[j]="""") or (str_pool[j]="'") then begin + must_quote:=true; + quote_char:="""" + "'" - str_pool[j]; + end; + incr(j); + end; +end; +if e<>0 then begin + j:=str_start_macro(e); + while ((not must_quote) or (quote_char=0)) and (j<>str_start_macro(e+1)) do begin + if (str_pool[j]=" ") then must_quote:=true + else if (str_pool[j]="""") or (str_pool[j]="'") then begin + must_quote:=true; + quote_char:="""" + "'" - str_pool[j]; + end; + incr(j); + end; +end; +if must_quote then begin + if quote_char=0 then quote_char:=""""; + print_char(quote_char); +end; +if a<>0 then + for j:=str_start_macro(a) to str_start_macro(a+1)-1 do begin + if str_pool[j]=quote_char then begin + print(quote_char); + quote_char:="""" + "'" - quote_char; + print(quote_char); + end; + print(str_pool[j]); + end; +if n<>0 then + for j:=str_start_macro(n) to str_start_macro(n+1)-1 do begin + if str_pool[j]=quote_char then begin + print(quote_char); + quote_char:="""" + "'" - quote_char; + print(quote_char); + end; + print(str_pool[j]); + end; +if e<>0 then + for j:=str_start_macro(e) to str_start_macro(e+1)-1 do begin + if str_pool[j]=quote_char then begin + print(quote_char); + quote_char:="""" + "'" - quote_char; + print(quote_char); + end; + print(str_pool[j]); + end; +if quote_char<>0 then print_char(quote_char); end; @z @@ -2524,7 +2595,7 @@ loop@+begin if (cur_cmd>other_char)or(cur_chr>biggest_char) then @y file_opened:=false; pack_file_name(nom,aire,cur_ext); -if file_name_quote_char<>0 then begin +if quoted_filename then begin { quoted name, so try for a native font } g:=load_native_font(u,nom,aire,s); if g=null_font then goto bad_tfm else goto done; @@ -2952,7 +3023,7 @@ if not no_pdf_output then fflush(dvi_file); @x print_nl("Output written on "); print_file_name(0, output_file_name, 0); @y - print_nl("Output written on "); print_file_name(output_file_name, "", ""); + print_nl("Output written on "); print(output_file_name); @z @x @@ -3091,7 +3162,8 @@ if is_native_font(f) then begin b:=new_null_box; p:=new_native_character(f, c); list_ptr(b):=p; - height(b):=height(p); depth(b):=depth(p); width(b):=width(p); + height(b):=height(p); width(b):=width(p); + if depth(p)<0 then depth(b):=0 else depth(b):=depth(p); end else begin q:=char_info(f)(c); hd:=height_depth(q); @@ -3141,6 +3213,52 @@ end else begin if (qo(cur_c)>=font_bc[cur_f])and(qo(cur_c)<=font_ec[cur_f]) then @z @x +procedure make_math_accent(@!q:pointer); +label done,done1; +var p,@!x,@!y:pointer; {temporary registers for box construction} +@!a:integer; {address of lig/kern instruction} +@!c:quarterword; {accent character} +@!f:internal_font_number; {its font} +@!i:four_quarters; {its |char_info|} +@!s:scaled; {amount to skew the accent to the right} +@!h:scaled; {height of character being accented} +@!delta:scaled; {space to remove between accent and accentee} +@!w:scaled; {width of the accentee, not including sub/superscripts} +begin fetch(accent_chr(q)); +if char_exists(cur_i) then + begin i:=cur_i; c:=cur_c; f:=cur_f;@/ + @<Compute the amount of skew@>; + x:=clean_box(nucleus(q),cramped_style(cur_style)); w:=width(x); h:=height(x); + @<Switch to a larger accent if available and appropriate@>; +@y +procedure make_math_accent(@!q:pointer); +label done,done1; +var p,@!x,@!y:pointer; {temporary registers for box construction} +@!a:integer; {address of lig/kern instruction} +@!c:integer; {accent character} +@!f:internal_font_number; {its font} +@!i:four_quarters; {its |char_info|} +@!s:scaled; {amount to skew the accent to the right} +@!h:scaled; {height of character being accented} +@!delta:scaled; {space to remove between accent and accentee} +@!w:scaled; {width of the accentee, not including sub/superscripts} +begin fetch(accent_chr(q)); +x:=null; +if is_native_font(cur_f) then + begin c:=cur_c; f:=cur_f; + s:=0; {@<Compute the amount of skew@>;} + x:=clean_box(nucleus(q),cramped_style(cur_style)); w:=width(x); h:=height(x); + end +else if char_exists(cur_i) then + begin i:=cur_i; c:=cur_c; f:=cur_f;@/ + @<Compute the amount of skew@>; + x:=clean_box(nucleus(q),cramped_style(cur_style)); w:=width(x); h:=height(x); + @<Switch to a larger accent if available and appropriate@>; + end; +if x<>null then begin +@z + +@x character(nucleus(r)):=rem_byte(cur_i); fam(nucleus(r)):=fam(nucleus(q));@/ @y @@ -3402,14 +3520,18 @@ first letter. @y begin if subtype(s) = native_word_node then begin - c := get_native_char(s, 0); - hf := native_font(s); - prev_s := s; - goto done2; - end else begin - @<Advance \(p)past a whatsit node in the \(p)pre-hyphenation loop@>; - goto continue; - end + { we only consider the node if it contains at least one letter, otherwise we'll skip it } + for l:=0 to native_length(s) - 1 do begin + c := get_native_char(s, l); + if lc_code(c) <> 0 then begin + hf := native_font(s); + prev_s := s; + goto done2; + end + end + end; + @<Advance \(p)past a whatsit node in the \(p)pre-hyphenation loop@>; + goto continue @z @x @@ -4138,10 +4260,29 @@ large_char_field(p) := cur_val1 mod @"10000; @z @x +procedure math_ac; +@y +procedure math_ac; +var c: integer; +@z + +@x +scan_fifteen_bit_int; character(accent_chr(tail)):=qi(cur_val mod 256); if (cur_val>=var_code)and fam_in_range then fam(accent_chr(tail)):=cur_fam else fam(accent_chr(tail)):=(cur_val div 256) mod 16; @y +if cur_chr=1 then begin + scan_math_class_int; c := set_class_field(cur_val); + scan_math_fam_int; c := c + set_family_field(cur_val); + scan_usv_num; cur_val := cur_val + c; +end +else begin + scan_fifteen_bit_int; + cur_val := set_class_field(cur_val div @"1000) + + set_family_field((cur_val mod @"1000) div @"100) + + (cur_val mod @"100); +end; character(accent_chr(tail)):=qi(cur_val mod @"10000); if (is_var_family(cur_val))and fam_in_range then plane_and_fam_field(accent_chr(tail)):=cur_fam else plane_and_fam_field(accent_chr(tail)):=math_fam_field(cur_val); @@ -4380,11 +4521,13 @@ set_font:begin print("select font "); read_open[n]:=just_open; @y and u_open_in(read_file[n], kpse_tex_format, XeTeX_default_input_mode, XeTeX_default_input_encoding) then - begin k:=1; + begin + make_utf16_name; name_in_progress:=true; begin_name; stop_at_space:=false; - while (k<=name_length)and(more_name(name_of_file[k])) do + k:=0; + while (k<name_length16)and(more_name(name_of_file16[k])) do incr(k); stop_at_space:=true; end_name; @@ -4522,7 +4665,7 @@ k:=biggest_lang+1; @x print_file_name(0, log_name, 0); print_char("."); @y - print_file_name(log_name, "", ""); print_char("."); + print(log_name); print_char("."); @z @x diff --git a/Build/source/texk/web2c/xetexdir/xetex.mk b/Build/source/texk/web2c/xetexdir/xetex.mk index 321ea17686f..dd8f4123c82 100644 --- a/Build/source/texk/web2c/xetexdir/xetex.mk +++ b/Build/source/texk/web2c/xetexdir/xetex.mk @@ -11,28 +11,28 @@ xetex = @XETEX@ xetex # On Mac OS X: @XETEX_MACOSX@ xetex_platform_o = XeTeX_mac.o XeTeXFontMgr_Mac.o -@XETEX_MACOSX@ xetex_platform_layout_o = XeTeXFontInst_Mac.o -@XETEX_MACOSX@ xetex_platform_layout_cxx = XeTeXFontInst_Mac.cpp +@XETEX_MACOSX@ xetex_platform_layout_o = XeTeXFontInst_Mac.o XeTeXFontInst_FT2.o +@XETEX_MACOSX@ xetex_platform_layout_cxx = XeTeXFontInst_Mac.cpp XeTeXFontInst_FT2.cpp @XETEX_MACOSX@ xetex_images_o = @XETEX_MACOSX@ XETEX_DEFINES = -DXETEX_MAC @XETEX_MACOSX@ EXTRALIBS = -framework Carbon -framework Cocoa -framework QuickTime -@XETEX_MACOSX@ EXTRADEPS = +@XETEX_MACOSX@ EXTRADEPS = # On non-Mac platforms: -@XETEX_GENERIC@ xetex_platform_o = XeTeXFontMgr_Linux.o -@XETEX_GENERIC@ xetex_platform_layout_o = XeTeXFontInst_FC.o -@XETEX_GENERIC@ xetex_platform_layout_cxx = XeTeXFontInst_FC.cpp +@XETEX_GENERIC@ xetex_platform_o = XeTeXFontMgr_FC.o +@XETEX_GENERIC@ xetex_platform_layout_o = XeTeXFontInst_FT2.o +@XETEX_GENERIC@ xetex_platform_layout_cxx = XeTeXFontInst_FT2.cpp @XETEX_GENERIC@ xetex_images_o = mfileio.o numbers.o pdfimage.o bmpimage.o jpegimage.o pngimage.o XeTeX_pic.o @XETEX_GENERIC@ XETEX_DEFINES = -DXETEX_OTHER @XETEX_GENERIC@ # FIXME: FontConfig not yet handled by configure -@XETEX_GENERIC@ EXTRALIBS = @LDFREETYPE2@ @LDLIBXPDF@ @LDLIBPNG@ -lfontconfig +@XETEX_GENERIC@ EXTRALIBS = @LDLIBXPDF@ @LDLIBPNG@ -lfontconfig -@XETEX_GENERIC@ EXTRADEPS = @FREETYPE2DEP@ @LIBXPDFDEP@ @LIBPNGDEP@ +@XETEX_GENERIC@ EXTRADEPS = @LIBXPDFDEP@ @LIBPNGDEP@ ### end of platform-specific setup @@ -50,7 +50,9 @@ LIBPNGDEP=@LIBPNGDEP@ LIBPNGDIR=../../libs/libpng LIBPNGSRCDIR=$(srcdir)/$(LIBPNGDIR) +LDFREETYPE2 = @LDFREETYPE2@ FTFLAGS = @FREETYPE2CPPFLAGS@ +FREETYPE2DEP = @FREETYPE2DEP@ FREETYPE2DIR = ../../libs/freetype2 FREETYPE2SRCDIR = $(srcdir)/$(FREETYPE2DIR) @@ -71,15 +73,22 @@ ICUSRCDIR=$(srcdir)/$(ICUDIR) ICUCFLAGS = @ICUCPPFLAGS@ -DLE_USE_CMEMORY +ZLIBCPPFLAGS = @ZLIBCPPFLAGS@ +LDZLIB = @LDZLIB@ + +ZLIBDIR = ../../libs/zlib +ZLIBSRCDIR = $(srcdir)/$(ZLIBDIR) + +xetexlibs = $(LDICU) $(LDTECKIT) $(LDFREETYPE2) $(LDZLIB) # Font-related headers XeTeXFontHdrs = \ $(srcdir)/xetexdir/FontTableCache.h \ $(srcdir)/xetexdir/XeTeXFontInst.h \ - $(srcdir)/xetexdir/XeTeXFontInst_FC.h \ + $(srcdir)/xetexdir/XeTeXFontInst_FT2.h \ $(srcdir)/xetexdir/XeTeXFontInst_Mac.h \ $(srcdir)/xetexdir/XeTeXFontMgr.h \ - $(srcdir)/xetexdir/XeTeXFontMgr_Linux.h \ + $(srcdir)/xetexdir/XeTeXFontMgr_FC.h \ $(srcdir)/xetexdir/XeTeXFontMgr_Mac.h \ $(srcdir)/xetexdir/XeTeXLayoutInterface.h \ $(srcdir)/xetexdir/XeTeXOTLayoutEngine.h @@ -152,7 +161,7 @@ XeTeXOTLayoutEngine.o: $(srcdir)/xetexdir/XeTeXOTLayoutEngine.cpp $(XeTeXFontHdr XeTeXFontMgr.o: $(srcdir)/xetexdir/XeTeXFontMgr.cpp $(XeTeXFontHdrs) $(CXX) $(ICUCFLAGS) $(FTFLAGS) $(ALL_CXXFLAGS) $(XETEX_DEFINES) -c $< -o $@ -XeTeXFontMgr_Linux.o: $(srcdir)/xetexdir/XeTeXFontMgr_Linux.cpp $(XeTeXFontHdrs) +XeTeXFontMgr_FC.o: $(srcdir)/xetexdir/XeTeXFontMgr_FC.cpp $(XeTeXFontHdrs) $(CXX) $(ICUCFLAGS) $(FTFLAGS) $(ALL_CXXFLAGS) $(XETEX_DEFINES) -c $< -o $@ XeTeXFontMgr_Mac.o: $(srcdir)/xetexdir/XeTeXFontMgr_Mac.mm $(XeTeXFontHdrs) @@ -167,12 +176,9 @@ XeTeXFontInst.o: $(srcdir)/xetexdir/XeTeXFontInst.cpp $(XeTeXFontHdrs) $(CXX) $(ICUCFLAGS) $(FTFLAGS) $(ALL_CXXFLAGS) $(XETEX_DEFINES) -c $< -o $@ XeTeXFontInst_Mac.o: $(srcdir)/xetexdir/XeTeXFontInst_Mac.cpp $(XeTeXFontHdrs) $(CXX) $(ICUCFLAGS) $(ALL_CXXFLAGS) $(XETEX_DEFINES) -c $< -o $@ -XeTeXFontInst_FC.o: $(srcdir)/xetexdir/XeTeXFontInst_FC.cpp $(XeTeXFontHdrs) +XeTeXFontInst_FT2.o: $(srcdir)/xetexdir/XeTeXFontInst_FT2.cpp $(XeTeXFontHdrs) $(CXX) $(ICUCFLAGS) $(FTFLAGS) $(ALL_CXXFLAGS) $(XETEX_DEFINES) -c $< -o $@ - -xetexlibs = $(LDICU) $(LDTECKIT) - # special rules for files that need the TECkit headers as well XeTeX_ext.o: $(srcdir)/xetexdir/XeTeX_ext.c xetexd.h $(compile) $(ICUCFLAGS) $(FTFLAGS) $(TECKITFLAGS) $(ALL_CFLAGS) $(XETEX_DEFINES) -c $< -o $@ @@ -186,7 +192,7 @@ trans.o: $(srcdir)/xetexdir/trans.c xetex: $(xetex_o) $(xetex_add_o) $(xetex_images_o) $(xetex_ot_layout_o) $(xetexlibs) $(EXTRADEPS) $(kpathsea_cxx_link) $(xetex_o) $(xetex_add_o) $(xetex_images_o) $(xetex_ot_layout_o) \ $(socketlibs) $(LOADLIBES) \ - $(xetexlibs) $(EXTRALIBS) -lz + $(xetexlibs) $(EXTRALIBS) # C file dependencies $(xetex_c) xetexcoerce.h xetexd.h: xetex.p $(web2c_texmf) |