From bc784de6a2b45e06374f41e4c658fb7d77fa04b8 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Thu, 7 Sep 2006 10:00:56 +0000 Subject: xetex source update, synced with xetex repo rev.365 git-svn-id: svn://tug.org/texlive/trunk@2093 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/xetexdir/LICENSE.txt | 31 ++ Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp | 11 +- Build/source/texk/web2c/xetexdir/XeTeXFontInst.h | 14 +- .../texk/web2c/xetexdir/XeTeXFontInst_FC.cpp | 217 -------------- .../source/texk/web2c/xetexdir/XeTeXFontInst_FC.h | 76 ----- .../texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp | 234 +++++++++++++++ .../source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h | 73 +++++ .../texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp | 3 +- .../source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h | 1 + Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp | 13 +- Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h | 3 - .../source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp | 324 +++++++++++++++++++++ Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h | 56 ++++ .../texk/web2c/xetexdir/XeTeXFontMgr_Linux.cpp | 317 -------------------- .../texk/web2c/xetexdir/XeTeXFontMgr_Linux.h | 59 ---- .../texk/web2c/xetexdir/XeTeXLayoutInterface.cpp | 36 ++- .../texk/web2c/xetexdir/XeTeXLayoutInterface.h | 9 +- Build/source/texk/web2c/xetexdir/XeTeX_ext.c | 181 ++++++++---- Build/source/texk/web2c/xetexdir/cpl1.0.txt | 213 -------------- Build/source/texk/web2c/xetexdir/pdfimage.cpp | 2 +- Build/source/texk/web2c/xetexdir/xetex-new.ch | 259 ++++++++++++---- Build/source/texk/web2c/xetexdir/xetex.mk | 38 ++- 22 files changed, 1117 insertions(+), 1053 deletions(-) create mode 100644 Build/source/texk/web2c/xetexdir/LICENSE.txt delete mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.cpp delete mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.h create mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp create mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h create mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp create mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h delete mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.cpp delete mode 100644 Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.h delete mode 100644 Build/source/texk/web2c/xetexdir/cpl1.0.txt (limited to 'Build/source') 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 -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_FC.cpp deleted file mode 100644 index 499ed7d19b0..00000000000 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/****************************************************************************\ - Part of the XeTeX typesetting system - copyright (c) 1994-2006 by SIL International - written by Jonathan Kew - -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. -\****************************************************************************/ - -/* - * file name: XeTeXFontInst_FC.cpp - * - * created on: 2005-10-25 - * created by: Jonathan Kew - */ - - -#include "XeTeXFontInst_FC.h" - -#include FT_TRUETYPE_TABLES_H -#include FT_TYPE1_TABLES_H -#include FT_GLYPH_H - -static FT_Library gLibrary = 0; - - -XeTeXFontInst_FC::XeTeXFontInst_FC(FcPattern* pattern, float pointSize, LEErrorCode &status) - : XeTeXFontInst(pattern, pointSize, status) - , face(0) - , fFreeTypeOnly(false) -{ - if (LE_FAILURE(status)) { - return; - } - - FT_Error err; - if (!gLibrary) { - err = FT_Init_FreeType(&gLibrary); - 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); - - if (err != 0) { - status = LE_FONT_FILE_NOT_FOUND_ERROR; - return; - } - - initialize(status); -} - -XeTeXFontInst_FC::~XeTeXFontInst_FC() -{ - if (face != 0) { - FT_Done_Face(face); - face = 0; - } -} - -void XeTeXFontInst_FC::initialize(LEErrorCode &status) -{ - if (face == 0) { - status = LE_FONT_FILE_NOT_FOUND_ERROR; - return; - } - - XeTeXFontInst::initialize(status); - - if (LE_FAILURE(status)) { - /* font can ONLY be used via FreeType APIs, not direct table access */ - fFreeTypeOnly = true; - status = LE_NO_ERROR; - - /* fill in fields that XeTeXFontInst::initialize failed to get for us */ - fUnitsPerEM = face->units_per_EM; - fAscent = yUnitsToPoints(face->ascender); - fDescent = yUnitsToPoints(face->descender); -// fLeading = ; - fItalicAngle = 0; - PS_FontInfoRec font_info; - if (FT_Get_PS_Font_Info(face, &font_info) == 0) { - // will return error if it wasn't a PS font - fItalicAngle = font_info.italic_angle; - } - } - - return; -} - -const void *XeTeXFontInst_FC::readTable(LETag tag, le_uint32 *length) const -{ - *length = 0; - FT_ULong tmpLength = 0; - FT_Error err = FT_Load_Sfnt_Table(face, tag, 0, NULL, &tmpLength); - if (err != 0) - return NULL; - - void* table = LE_NEW_ARRAY(char, tmpLength); - if (table != NULL) { - err = FT_Load_Sfnt_Table(face, tag, 0, (FT_Byte*)table, &tmpLength); - if (err != 0) { - LE_DELETE_ARRAY(table); - return NULL; - } - *length = tmpLength; - } - - 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) -{ - bbox->xMin = bbox->yMin = bbox->xMax = bbox->yMax = 0.0; - - FT_Error err = FT_Load_Glyph(face, gid, FT_LOAD_NO_SCALE); - if (err != 0) - return; - - FT_Glyph glyph; - err = FT_Get_Glyph(face->glyph, &glyph); - if (err == 0) { - FT_BBox ft_bbox; - FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_UNSCALED, &ft_bbox); - bbox->xMin = ft_bbox.xMin * fPointSize / fUnitsPerEM; - bbox->yMin = ft_bbox.yMin * fPointSize / fUnitsPerEM; - bbox->xMax = ft_bbox.xMax * fPointSize / fUnitsPerEM; - bbox->yMax = ft_bbox.yMax * fPointSize / fUnitsPerEM; - FT_Done_Glyph(glyph); - } -} - -LEGlyphID -XeTeXFontInst_FC::mapCharToGlyph(LEUnicode32 ch) const -{ - if (!fFreeTypeOnly) - return XeTeXFontInst::mapCharToGlyph(ch); - - return FT_Get_Char_Index(face, ch); -} - -le_uint16 -XeTeXFontInst_FC::getNumGlyphs() const -{ - return face->num_glyphs; -} - -void -XeTeXFontInst_FC::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const -{ - if (!fFreeTypeOnly) - XeTeXFontInst::getGlyphAdvance(glyph, advance); - else { - FT_Error err = FT_Load_Glyph(face, glyph, FT_LOAD_NO_SCALE); - if (err != 0) { - advance.fX = advance.fY = 0; - } - else { - advance.fX = fVertical ? 0 : face->glyph->metrics.horiAdvance * fPointSize / fUnitsPerEM; - advance.fY = fVertical ? face->glyph->metrics.vertAdvance * fPointSize / fUnitsPerEM : 0; - } - } -} - -LEGlyphID -XeTeXFontInst_FC::mapGlyphToIndex(const char* glyphName) const -{ - LEGlyphID rval = FT_Get_Name_Index(face, const_cast(glyphName)); - if (rval == 0) - rval = XeTeXFontInst::mapGlyphToIndex(glyphName); - return rval; -} diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.h deleted file mode 100644 index fc88f509c13..00000000000 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FC.h +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************\ - Part of the XeTeX typesetting system - copyright (c) 1994-2006 by SIL International - written by Jonathan Kew - -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. -\****************************************************************************/ - -/* - * file name: XeTeXFontInst_FC.h - * - * created on: 2005-10-25 - * created by: Jonathan Kew - */ - - -#ifndef __XeTeXFontInst_FC_H -#define __XeTeXFontInst_FC_H - -#include "XeTeXFontInst.h" - -#include - -#include -#include FT_FREETYPE_H - -class XeTeXFontInst_FC : public XeTeXFontInst -{ -protected: - - const void * readTable(LETag tag, le_uint32 *length) const; - - FT_Face face; - bool fFreeTypeOnly; - -public: - XeTeXFontInst_FC(FcPattern* pattern, float pointSize, LEErrorCode &status); - - virtual ~XeTeXFontInst_FC(); - - 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 - virtual le_uint16 getNumGlyphs() const; - virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; - virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; - virtual LEGlyphID mapGlyphToIndex(const char* glyphName) const; -}; - -#endif diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp new file mode 100644 index 00000000000..cc56442be24 --- /dev/null +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp @@ -0,0 +1,234 @@ +/****************************************************************************\ + Part of the XeTeX typesetting system + copyright (c) 1994-2006 by SIL International + written by Jonathan Kew + +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. +\****************************************************************************/ + +/* + * file name: XeTeXFontInst_FT2.cpp + * + * created on: 2005-10-25 + * created by: Jonathan Kew + */ + + +#include "XeTeXFontInst_FT2.h" + +#include FT_TRUETYPE_TABLES_H +#include FT_TYPE1_TABLES_H +#include FT_GLYPH_H + +#include + +FT_Library gFreeTypeLibrary = 0; + +XeTeXFontInst_FT2::XeTeXFontInst_FT2(const char* pathname, int index, float pointSize, LEErrorCode &status) + : XeTeXFontInst(pointSize, status) + , face(0) + , fFreeTypeOnly(false) +{ + if (LE_FAILURE(status)) { + return; + } + + FT_Error err; + if (!gFreeTypeLibrary) { + err = FT_Init_FreeType(&gFreeTypeLibrary); + if (err != 0) { + fprintf(stderr, "FreeType initialization failed! (%d)\n", err); + exit(1); + } + } + + 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_FT2::~XeTeXFontInst_FT2() +{ + if (face != 0) { + FT_Done_Face(face); + face = 0; + } +} + +void XeTeXFontInst_FT2::initialize(LEErrorCode &status) +{ + if (face == 0) { + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + XeTeXFontInst::initialize(status); + + if (LE_FAILURE(status)) { + /* font can ONLY be used via FreeType APIs, not direct table access */ + fFreeTypeOnly = true; + status = LE_NO_ERROR; + + /* fill in fields that XeTeXFontInst::initialize failed to get for us */ + fUnitsPerEM = face->units_per_EM; + fAscent = yUnitsToPoints(face->ascender); + fDescent = yUnitsToPoints(face->descender); +// fLeading = ; + fItalicAngle = 0; + PS_FontInfoRec font_info; + if (FT_Get_PS_Font_Info(face, &font_info) == 0) { + // will return error if it wasn't a PS font + fItalicAngle = font_info.italic_angle; + } + } + + return; +} + +const void *XeTeXFontInst_FT2::readTable(LETag tag, le_uint32 *length) const +{ + *length = 0; + FT_ULong tmpLength = 0; + FT_Error err = FT_Load_Sfnt_Table(face, tag, 0, NULL, &tmpLength); + if (err != 0) + return NULL; + + void* table = LE_NEW_ARRAY(char, tmpLength); + if (table != NULL) { + err = FT_Load_Sfnt_Table(face, tag, 0, (FT_Byte*)table, &tmpLength); + if (err != 0) { + LE_DELETE_ARRAY(table); + return NULL; + } + *length = tmpLength; + } + + return table; +} + +void +XeTeXFontInst_FT2::getGlyphBounds(LEGlyphID gid, GlyphBBox* bbox) +{ + bbox->xMin = bbox->yMin = bbox->xMax = bbox->yMax = 0.0; + + FT_Error err = FT_Load_Glyph(face, gid, FT_LOAD_NO_SCALE); + if (err != 0) + return; + + FT_Glyph glyph; + err = FT_Get_Glyph(face->glyph, &glyph); + if (err == 0) { + FT_BBox ft_bbox; + FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_UNSCALED, &ft_bbox); + bbox->xMin = ft_bbox.xMin * fPointSize / fUnitsPerEM; + bbox->yMin = ft_bbox.yMin * fPointSize / fUnitsPerEM; + bbox->xMax = ft_bbox.xMax * fPointSize / fUnitsPerEM; + bbox->yMax = ft_bbox.yMax * fPointSize / fUnitsPerEM; + FT_Done_Glyph(glyph); + } +} + +LEGlyphID +XeTeXFontInst_FT2::mapCharToGlyph(LEUnicode32 ch) const +{ + if (!fFreeTypeOnly) + return XeTeXFontInst::mapCharToGlyph(ch); + + return FT_Get_Char_Index(face, ch); +} + +le_uint16 +XeTeXFontInst_FT2::getNumGlyphs() const +{ + return face->num_glyphs; +} + +void +XeTeXFontInst_FT2::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +{ + if (!fFreeTypeOnly) + XeTeXFontInst::getGlyphAdvance(glyph, advance); + else { + FT_Error err = FT_Load_Glyph(face, glyph, FT_LOAD_NO_SCALE); + if (err != 0) { + advance.fX = advance.fY = 0; + } + else { + advance.fX = fVertical ? 0 : face->glyph->metrics.horiAdvance * fPointSize / fUnitsPerEM; + advance.fY = fVertical ? face->glyph->metrics.vertAdvance * fPointSize / fUnitsPerEM : 0; + } + } +} + +LEGlyphID +XeTeXFontInst_FT2::mapGlyphToIndex(const char* glyphName) const +{ + LEGlyphID rval = FT_Get_Name_Index(face, const_cast(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_FT2.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h new file mode 100644 index 00000000000..fb439114ab9 --- /dev/null +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h @@ -0,0 +1,73 @@ +/****************************************************************************\ + Part of the XeTeX typesetting system + copyright (c) 1994-2006 by SIL International + written by Jonathan Kew + +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. +\****************************************************************************/ + +/* + * file name: XeTeXFontInst_FT2.h + * + * created on: 2005-10-25 + * created by: Jonathan Kew + */ + + +#ifndef __XeTeXFontInst_FT2_H +#define __XeTeXFontInst_FT2_H + +#include "XeTeXFontInst.h" + +#include +#include FT_FREETYPE_H + +class XeTeXFontInst_FT2 : public XeTeXFontInst +{ +protected: + + const void * readTable(LETag tag, le_uint32 *length) const; + + FT_Face face; + bool fFreeTypeOnly; + +public: + XeTeXFontInst_FT2(const char* filename, int index, float pointSize, LEErrorCode &status); + + virtual ~XeTeXFontInst_FT2(); + + virtual void initialize(LEErrorCode &status); + + virtual void getGlyphBounds(LEGlyphID gid, GlyphBBox* bbox); + + // overrides of XeTeXFontInst methods, in case it's not an sfnt + virtual le_uint16 getNumGlyphs() const; + 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(); } @@ -370,15 +370,6 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize) return font->fontRef; } -const char* -XeTeXFontMgr::getPSName(PlatformFontRef font) const -{ - std::map::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 { 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_FC.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp new file mode 100644 index 00000000000..5f94c3d5fa4 --- /dev/null +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp @@ -0,0 +1,324 @@ +/****************************************************************************\ + Part of the XeTeX typesetting system + copyright (c) 1994-2006 by SIL International + written by Jonathan Kew + +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. +\****************************************************************************/ + +#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 + +#include "unicode/ucnv.h" + +#define kFontFamilyName 1 +#define kFontStyleName 2 +#define kFontFullName 4 +#define kPreferredFamilyName 16 +#define kPreferredSubfamilyName 17 + +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) +{ +static char* buffer1 = NULL; +static char* buffer2 = NULL; +static int bufSize = -1; + + if (2 * (len + 1) > bufSize) { + if (buffer1 != NULL) { + delete[] buffer1; + delete[] buffer2; + } + bufSize = 2 * len + 100; + buffer1 = new char[bufSize]; + buffer2 = new char[bufSize]; + } + + UErrorCode status = U_ZERO_ERROR; + len = ucnv_toUChars(conv, (UChar*)buffer1, bufSize, (const char*)name, len, &status); + len = ucnv_fromUChars(utf8Conv, buffer2, bufSize, (UChar*)buffer1, len, &status); + buffer2[len] = 0; + + return buffer2; +} + +XeTeXFontMgr::NameCollection* +XeTeXFontMgr_FC::readNames(FcPattern* pat) +{ + NameCollection* names = new NameCollection; + + char* pathname; + if (FcPatternGetString(pat, FC_FILE, 0, (FcChar8**)&pathname) == FcTrue) + return names; + int index; + if (FcPatternGetInteger(pat, FC_INDEX, 0, &index) == FcTrue) + return names; + + FT_Face face; + if (FT_New_Face(gFreeTypeLibrary, pathname, index, &face) != 0) + return names; + + const char* name = FT_Get_Postscript_Name(face); + if (name == NULL) + return names; + names->psName = name; + + // for sfnt containers, we'll read the name table ourselves, not rely on Fontconfig + if (FT_IS_SFNT(face)) { + std::list familyNames; + std::list subFamilyNames; + FT_SfntName nameRec; + for (index = 0; index < FT_Get_Sfnt_Name_Count(face); ++index) { + char* utf8name = NULL; + if (FT_Get_Sfnt_Name(face, index, &nameRec) != 0) + continue; + switch (nameRec.name_id) { + case kFontFullName: + case kFontFamilyName: + case kFontStyleName: + case kPreferredFamilyName: + case kPreferredSubfamilyName: + { + bool preferredName = false; + if (nameRec.platform_id == TT_PLATFORM_MACINTOSH + && nameRec.encoding_id == TT_MAC_ID_ROMAN && nameRec.language_id == 0) { + utf8name = convertToUtf8(macRomanConv, nameRec.string, nameRec.string_len); + preferredName = true; + } + else if ((nameRec.platform_id == TT_PLATFORM_APPLE_UNICODE) + || (nameRec.platform_id == TT_PLATFORM_MICROSOFT)) + utf8name = convertToUtf8(utf16beConv, nameRec.string, nameRec.string_len); + + if (utf8name != NULL) { + std::list* nameList = NULL; + switch (nameRec.name_id) { + case kFontFullName: + nameList = &names->fullNames; + break; + case kFontFamilyName: + nameList = &names->familyNames; + break; + case kFontStyleName: + nameList = &names->styleNames; + break; + case kPreferredFamilyName: + nameList = &familyNames; + break; + case kPreferredSubfamilyName: + nameList = &subFamilyNames; + break; + } + if (preferredName) + prependToList(nameList, utf8name); + else + appendToList(nameList, utf8name); + } + } + break; + } + } + if (familyNames.size() > 0) + names->familyNames = familyNames; + if (subFamilyNames.size() > 0) + names->styleNames = subFamilyNames; + } + else { + index = 0; + while (FcPatternGetString(pat, FC_FULLNAME, index++, (FcChar8**)&name) == FcFalse) + appendToList(&names->fullNames, name); + index = 0; + while (FcPatternGetString(pat, FC_FAMILY, index++, (FcChar8**)&name) == FcFalse) + appendToList(&names->familyNames, name); + index = 0; + while (FcPatternGetString(pat, FC_STYLE, index++, (FcChar8**)&name) == FcFalse) + appendToList(&names->styleNames, name); + + if (names->fullNames.size() == 0) { + std::string fullName(names->familyNames.front()); + if (names->styleNames.size() > 0) { + fullName += " "; + fullName += names->styleNames.front(); + } + names->fullNames.push_back(fullName); + } + } + + FT_Done_Face(face); + + return names; +} + +void +XeTeXFontMgr_FC::getOpSizeRecAndStyleFlags(Font* theFont) +{ + XeTeXFontMgr::getOpSizeRecAndStyleFlags(theFont); + + if (theFont->weight == 0 && theFont->width == 0) { + // try to get values from FontConfig, as it apparently wasn't an sfnt + FcPattern* pat = theFont->fontRef; + int value; + if (FcPatternGetInteger(pat, FC_WEIGHT, 0, &value) == FcFalse) + theFont->weight = value; + if (FcPatternGetInteger(pat, FC_WIDTH, 0, &value) == FcFalse) + theFont->width = value; + if (FcPatternGetInteger(pat, FC_SLANT, 0, &value) == FcFalse) + theFont->slant = value; + } +} + +void +XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) +{ + static bool cacheAll = false; + static FcFontSet* allFonts = NULL; + + if (cacheAll) // we've already loaded everything on an earlier search + return; + + if (allFonts == NULL) { + FcPattern* pat = FcNameParse((const FcChar8*)":outline=true"); + FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_FILE, FC_INDEX, + FC_FULLNAME, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL); + + allFonts = FcFontList(FcConfigGetCurrent(), pat, os); + + FcObjectSetDestroy(os); + FcPatternDestroy(pat); + } + + std::string famName; + int hyph = name.find('-'); + if (hyph > 0 && hyph < name.length() - 1) + famName.assign(name.begin(), name.begin() + hyph); + else + hyph = 0; + + bool found = false; + while (1) { + for (int f = 0; f < allFonts->nfont; ++f) { + restart: + FcPattern* pat = allFonts->fonts[f]; + if (platformRefToFont.find(pat) != platformRefToFont.end()) + continue; + + if (cacheAll) { + // failed to find it via FC; add everything to our maps (potentially slow) as a last resort + NameCollection* names = readNames(pat); + addToMaps(pat, names); + delete names; + continue; + } + + char* s; + int i; + for (i = 0; FcPatternGetString(pat, FC_FULLNAME, i, (FcChar8**)&s) == FcFalse; ++i) { + if (name == s) { + NameCollection* names = readNames(pat); + addToMaps(pat, names); + delete names; + found = true; + goto next_font; + } + } + + for (i = 0; FcPatternGetString(pat, FC_FAMILY, i, (FcChar8**)&s) == FcFalse; ++i) { + if (name == s || (hyph && famName == s)) { + NameCollection* names = readNames(pat); + addToMaps(pat, names); + delete names; + found = true; + goto next_font; + } + char* t; + for (int j = 0; FcPatternGetString(pat, FC_STYLE, j, (FcChar8**)&t) == FcFalse; ++j) { + std::string full(s); + full += " "; + full += t; + if (name == full) { + // need to ensure we'll pick up the whole family + famName = s; + hyph = 1; + f = 0; + goto restart; + } + } + } + + next_font: + ; + } + + if (found || cacheAll) + break; + cacheAll = true; + } +} + +void +XeTeXFontMgr_FC::initialize() +{ + if (FcInit() == FcFalse) { + fprintf(stderr, "fontconfig initialization failed!\n"); + exit(9); + } + + if (gFreeTypeLibrary == 0 && FT_Init_FreeType(&gFreeTypeLibrary) != 0) { + fprintf(stderr, "FreeType initialization failed!\n"); + exit(9); + } + + UErrorCode err = U_ZERO_ERROR; + macRomanConv = ucnv_open("macintosh", &err); + utf16beConv = ucnv_open("UTF16BE", &err); + utf8Conv = ucnv_open("UTF8", &err); + if (err != 0) { + fprintf(stderr, "internal error; cannot read font names\n"); + exit(3); + } +} + +void +XeTeXFontMgr_FC::terminate() +{ + if (macRomanConv != NULL) + ucnv_close(macRomanConv); + if (utf16beConv != NULL) + ucnv_close(utf16beConv); + if (utf8Conv != NULL) + ucnv_close(utf8Conv); +} diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h new file mode 100644 index 00000000000..764b7ec1d0e --- /dev/null +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h @@ -0,0 +1,56 @@ +/****************************************************************************\ + Part of the XeTeX typesetting system + copyright (c) 1994-2006 by SIL International + written by Jonathan Kew + +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. +\****************************************************************************/ + +#ifndef __XETEX_FONT_MGR_FC_H +#define __XETEX_FONT_MGR_FC_H + +#include "XeTeXFontMgr.h" + +class XeTeXFontMgr_FC + : public XeTeXFontMgr +{ +public: + XeTeXFontMgr_FC() + { } + virtual ~XeTeXFontMgr_FC() + { } + +protected: + + virtual void initialize(); + virtual void terminate(); + + virtual void getOpSizeRecAndStyleFlags(Font* theFont); + virtual void searchForHostPlatformFonts(const std::string& name); + + virtual NameCollection* readNames(FcPattern* pat); +}; + +#endif /* __XETEX_FONT_MGR_FC_H */ diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.cpp deleted file mode 100644 index c10fc81f985..00000000000 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/****************************************************************************\ - Part of the XeTeX typesetting system - copyright (c) 1994-2006 by SIL International - written by Jonathan Kew - -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. -\****************************************************************************/ - -#include "XeTeXFontMgr_Linux.h" - -#include FT_SFNT_NAMES_H -#include FT_TRUETYPE_IDS_H - -#include "unicode/ucnv.h" - -#define kFontFamilyName 1 -#define kFontStyleName 2 -#define kFontFullName 4 -#define kPreferredFamilyName 16 -#define kPreferredSubfamilyName 17 - -static UConverter* macRomanConv = NULL; -static UConverter* utf16beConv = NULL; -static UConverter* utf8Conv = NULL; - -static char* -convertToUtf8(UConverter* conv, const unsigned char* name, int len) -{ -static char* buffer1 = NULL; -static char* buffer2 = NULL; -static int bufSize = -1; - - if (2 * (len + 1) > bufSize) { - if (buffer1 != NULL) { - delete[] buffer1; - delete[] buffer2; - } - bufSize = 2 * len + 100; - buffer1 = new char[bufSize]; - buffer2 = new char[bufSize]; - } - - UErrorCode status = U_ZERO_ERROR; - len = ucnv_toUChars(conv, (UChar*)buffer1, bufSize, (const char*)name, len, &status); - len = ucnv_fromUChars(utf8Conv, buffer2, bufSize, (UChar*)buffer1, len, &status); - buffer2[len] = 0; - - return buffer2; -} - -XeTeXFontMgr::NameCollection* -XeTeXFontMgr_Linux::readNames(FcPattern* pat) -{ - NameCollection* names = new NameCollection; - - char* pathname; - if (FcPatternGetString(pat, FC_FILE, 0, (FcChar8**)&pathname) == FcTrue) - return names; - int index; - if (FcPatternGetInteger(pat, FC_INDEX, 0, &index) == FcTrue) - return names; - - FT_Face face; - if (FT_New_Face(ftLib, pathname, index, &face) != 0) - return names; - - const char* name = FT_Get_Postscript_Name(face); - if (name == NULL) - return names; - names->psName = name; - - // for sfnt containers, we'll read the name table ourselves, not rely on Fontconfig - if (FT_IS_SFNT(face)) { - std::list familyNames; - std::list subFamilyNames; - FT_SfntName nameRec; - for (index = 0; index < FT_Get_Sfnt_Name_Count(face); ++index) { - char* utf8name = NULL; - if (FT_Get_Sfnt_Name(face, index, &nameRec) != 0) - continue; - switch (nameRec.name_id) { - case kFontFullName: - case kFontFamilyName: - case kFontStyleName: - case kPreferredFamilyName: - case kPreferredSubfamilyName: - { - bool preferredName = false; - if (nameRec.platform_id == TT_PLATFORM_MACINTOSH - && nameRec.encoding_id == TT_MAC_ID_ROMAN && nameRec.language_id == 0) { - utf8name = convertToUtf8(macRomanConv, nameRec.string, nameRec.string_len); - preferredName = true; - } - else if ((nameRec.platform_id == TT_PLATFORM_APPLE_UNICODE) - || (nameRec.platform_id == TT_PLATFORM_MICROSOFT)) - utf8name = convertToUtf8(utf16beConv, nameRec.string, nameRec.string_len); - - if (utf8name != NULL) { - std::list* nameList = NULL; - switch (nameRec.name_id) { - case kFontFullName: - nameList = &names->fullNames; - break; - case kFontFamilyName: - nameList = &names->familyNames; - break; - case kFontStyleName: - nameList = &names->styleNames; - break; - case kPreferredFamilyName: - nameList = &familyNames; - break; - case kPreferredSubfamilyName: - nameList = &subFamilyNames; - break; - } - if (preferredName) - prependToList(nameList, utf8name); - else - appendToList(nameList, utf8name); - } - } - break; - } - } - if (familyNames.size() > 0) - names->familyNames = familyNames; - if (subFamilyNames.size() > 0) - names->styleNames = subFamilyNames; - } - else { - index = 0; - while (FcPatternGetString(pat, FC_FULLNAME, index++, (FcChar8**)&name) == FcFalse) - appendToList(&names->fullNames, name); - index = 0; - while (FcPatternGetString(pat, FC_FAMILY, index++, (FcChar8**)&name) == FcFalse) - appendToList(&names->familyNames, name); - index = 0; - while (FcPatternGetString(pat, FC_STYLE, index++, (FcChar8**)&name) == FcFalse) - appendToList(&names->styleNames, name); - - if (names->fullNames.size() == 0) { - std::string fullName(names->familyNames.front()); - if (names->styleNames.size() > 0) { - fullName += " "; - fullName += names->styleNames.front(); - } - names->fullNames.push_back(fullName); - } - } - - FT_Done_Face(face); - - return names; -} - -void -XeTeXFontMgr_Linux::getOpSizeRecAndStyleFlags(Font* theFont) -{ - XeTeXFontMgr::getOpSizeRecAndStyleFlags(theFont); - - if (theFont->weight == 0 && theFont->width == 0) { - // try to get values from FontConfig, as it apparently wasn't an sfnt - FcPattern* pat = theFont->fontRef; - int value; - if (FcPatternGetInteger(pat, FC_WEIGHT, 0, &value) == FcFalse) - theFont->weight = value; - if (FcPatternGetInteger(pat, FC_WIDTH, 0, &value) == FcFalse) - theFont->width = value; - if (FcPatternGetInteger(pat, FC_SLANT, 0, &value) == FcFalse) - theFont->slant = value; - } -} - -void -XeTeXFontMgr_Linux::searchForHostPlatformFonts(const std::string& name) -{ - static bool cacheAll = false; - static FcFontSet* allFonts = NULL; - - if (cacheAll) // we've already loaded everything on an earlier search - return; - - if (allFonts == NULL) { - FcPattern* pat = FcNameParse((const FcChar8*)":outline=true"); - FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_FILE, FC_INDEX, - FC_FULLNAME, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL); - - allFonts = FcFontList(FcConfigGetCurrent(), pat, os); - - FcObjectSetDestroy(os); - FcPatternDestroy(pat); - } - - std::string famName; - int hyph = name.find('-'); - if (hyph > 0 && hyph < name.length() - 1) - famName.assign(name.begin(), name.begin() + hyph); - else - hyph = 0; - - bool found = false; - while (1) { - for (int f = 0; f < allFonts->nfont; ++f) { - restart: - FcPattern* pat = allFonts->fonts[f]; - if (platformRefToFont.find(pat) != platformRefToFont.end()) - continue; - - if (cacheAll) { - // failed to find it via FC; add everything to our maps (potentially slow) as a last resort - NameCollection* names = readNames(pat); - addToMaps(pat, names); - delete names; - continue; - } - - char* s; - int i; - for (i = 0; FcPatternGetString(pat, FC_FULLNAME, i, (FcChar8**)&s) == FcFalse; ++i) { - if (name == s) { - NameCollection* names = readNames(pat); - addToMaps(pat, names); - delete names; - found = true; - goto next_font; - } - } - - for (i = 0; FcPatternGetString(pat, FC_FAMILY, i, (FcChar8**)&s) == FcFalse; ++i) { - if (name == s || (hyph && famName == s)) { - NameCollection* names = readNames(pat); - addToMaps(pat, names); - delete names; - found = true; - goto next_font; - } - char* t; - for (int j = 0; FcPatternGetString(pat, FC_STYLE, j, (FcChar8**)&t) == FcFalse; ++j) { - std::string full(s); - full += " "; - full += t; - if (name == full) { - // need to ensure we'll pick up the whole family - famName = s; - hyph = 1; - f = 0; - goto restart; - } - } - } - - next_font: - ; - } - - if (found || cacheAll) - break; - cacheAll = true; - } -} - -void -XeTeXFontMgr_Linux::initialize() -{ - if (FcInit() == FcFalse) { - fprintf(stderr, "fontconfig initialization failed!\n"); - exit(9); - } - - if (FT_Init_FreeType(&ftLib) != 0) { - fprintf(stderr, "FreeType initialization failed!\n"); - exit(9); - } - - UErrorCode err = U_ZERO_ERROR; - macRomanConv = ucnv_open("macintosh", &err); - utf16beConv = ucnv_open("UTF16BE", &err); - utf8Conv = ucnv_open("UTF8", &err); - if (err != 0) { - fprintf(stderr, "internal error; cannot read font names\n"); - exit(3); - } -} - -void -XeTeXFontMgr_Linux::terminate() -{ - if (macRomanConv != NULL) - ucnv_close(macRomanConv); - if (utf16beConv != NULL) - ucnv_close(utf16beConv); - if (utf8Conv != NULL) - ucnv_close(utf8Conv); -} diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.h b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.h deleted file mode 100644 index bea40c3deea..00000000000 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Linux.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************\ - Part of the XeTeX typesetting system - copyright (c) 1994-2006 by SIL International - written by Jonathan Kew - -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. -\****************************************************************************/ - -#ifndef __XETEX_FONT_MGR_LINUX_H -#define __XETEX_FONT_MGR_LINUX_H - -#include "XeTeXFontMgr.h" - -class XeTeXFontMgr_Linux - : public XeTeXFontMgr -{ -public: - XeTeXFontMgr_Linux() - { } - virtual ~XeTeXFontMgr_Linux() - { } - -protected: - - virtual void initialize(); - virtual void terminate(); - - virtual void getOpSizeRecAndStyleFlags(Font* theFont); - virtual void searchForHostPlatformFonts(const std::string& name); - - virtual NameCollection* readNames(FcPattern* pat); - -private: - FT_Library ftLib; -}; - -#endif /* __XETEX_FONT_MGR_LINUX_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 @@ -198,15 +198,6 @@ system libraries. @!bound_default:integer; {temporary for setup} @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 @@ -1303,6 +1294,13 @@ else begin k:=str_start[s]; l:=str_start[s+1]-k; 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@> @@ -1326,6 +1324,13 @@ end_cs_name: if chr_code = 10 then print_esc("endmubyte") 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 @@ -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 @@ -2068,6 +2079,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 @@ -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); @@ -3140,6 +3212,52 @@ end else begin if (qo(cur_c)>=font_bc[cur_f])and(qo(cur_c)<=font_ec[cur_f]) then @!cur_c:integer; {the |character| field of a |math_char|} @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;@/ + @; + x:=clean_box(nucleus(q),cramped_style(cur_style)); w:=width(x); h:=height(x); + @; +@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; {@;} + 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;@/ + @; + x:=clean_box(nucleus(q),cramped_style(cur_style)); w:=width(x); h:=height(x); + @; + end; +if x<>null then begin +@z + @x character(nucleus(r)):=rem_byte(cur_i); fam(nucleus(r)):=fam(nucleus(q));@/ @@ -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 - @; - 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; + @; + 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