summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-01-04 12:31:34 +0000
committerKhaled Hosny <khaledhosny@eglug.org>2013-01-04 12:31:34 +0000
commit4df64d32d4610ccbd0b7b14bf91ed6011e15da84 (patch)
treecdc86447d47668bde1bb012fb7dcb9e5cf18ccd5 /Build
parentd2c5e254ccfe8964b45b564eac45b47b4dc4fa0a (diff)
More XeTeX fixes
git-svn-id: svn://tug.org/texlive/trunk@28727 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/xetexdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp6
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp80
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h14
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeX_ext.c90
-rw-r--r--Build/source/texk/web2c/xetexdir/xetex.web2
6 files changed, 124 insertions, 72 deletions
diff --git a/Build/source/texk/web2c/xetexdir/ChangeLog b/Build/source/texk/web2c/xetexdir/ChangeLog
index 499775b91a2..96cc4ff9654 100644
--- a/Build/source/texk/web2c/xetexdir/ChangeLog
+++ b/Build/source/texk/web2c/xetexdir/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-04 Khaled Hosny <khaledhosny@eglug.org>
+
+ Merge changes from XeTeX repository.
+
2013-01-04 Peter Breitenlohner <peb@mppmu.mpg.de>
* XeTeX_ext.c: Use xcalloc() and strncpy() instead of strndup()
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
index 3521a6b9b35..51297c6d4aa 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
@@ -39,6 +39,12 @@ authorization from the copyright holders.
#include "XeTeXswap.h"
#include "sfnt.h"
+#ifdef _MSC_VER
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+#endif
+
extern "C" {
extern Fixed loadedfontdesignsize;
}
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
index f01b5b1699e..ce6ee2cb78b 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
@@ -2,7 +2,7 @@
Part of the XeTeX typesetting system
Copyright (c) 1994-2008 by SIL International
Copyright (c) 2009-2012 by Jonathan Kew
- Copyright (c) 2012 by Khaled Hosny
+ Copyright (c) 2012, 2013 by Khaled Hosny
SIL Author(s): Jonathan Kew
@@ -44,6 +44,12 @@ authorization from the copyright holders.
#include "XeTeXFontMgr.h"
#include "XeTeXswap.h"
+#ifdef _MSC_VER
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+#endif
+
struct XeTeXLayoutEngine_rec
{
XeTeXFontInst* font;
@@ -51,7 +57,8 @@ struct XeTeXLayoutEngine_rec
char* script;
char* language;
hb_feature_t* features;
- char** shapers;
+ char** ShaperList; // the requested shapers
+ char* shaper; // the actually used shaper
int nFeatures;
UInt32 rgbValue;
float extend;
@@ -250,6 +257,7 @@ UInt32 countScriptLanguages(XeTeXFont font, UInt32 script)
return hb_ot_layout_script_get_language_tags (face, tableTag, i, 0, NULL, NULL);
}
}
+ return 0;
}
UInt32 getIndScriptLanguage(XeTeXFont font, UInt32 script, UInt32 index)
@@ -274,6 +282,7 @@ UInt32 getIndScriptLanguage(XeTeXFont font, UInt32 script, UInt32 index)
return 0;
}
}
+ return 0;
}
UInt32 countFeatures(XeTeXFont font, UInt32 script, UInt32 language)
@@ -561,7 +570,8 @@ XeTeXLayoutEngine createLayoutEngine(PlatformFontRef fontRef, XeTeXFont font, ch
result->script = script;
result->language = language;
result->features = features;
- result->shapers = shapers;
+ result->ShaperList = shapers;
+ result->shaper = NULL;
result->nFeatures = nFeatures;
result->rgbValue = rgbValue;
result->extend = extend;
@@ -581,9 +591,14 @@ void deleteLayoutEngine(XeTeXLayoutEngine engine)
int layoutChars(XeTeXLayoutEngine engine, UInt16 chars[], SInt32 offset, SInt32 count, SInt32 max,
bool rightToLeft)
{
+ bool res;
hb_script_t script = HB_SCRIPT_INVALID;
hb_language_t language = HB_LANGUAGE_INVALID;
hb_direction_t direction = HB_DIRECTION_LTR;
+ hb_segment_properties_t segment_props;
+ hb_shape_plan_t *shape_plan;
+ hb_font_t* hbFont = engine->font->hbFont;
+ hb_face_t* hbFace = hb_font_get_face(hbFont);
if (engine->font->getLayoutDirVertical())
direction = HB_DIRECTION_TTB;
@@ -602,15 +617,45 @@ int layoutChars(XeTeXLayoutEngine engine, UInt16 chars[], SInt32 offset, SInt32
hb_buffer_set_script(engine->hbBuffer, script);
hb_buffer_set_language(engine->hbBuffer, language);
- hb_shape_full(engine->font->hbFont, engine->hbBuffer, engine->features, engine->nFeatures, engine->shapers);
+ hb_buffer_guess_segment_properties(engine->hbBuffer);
+ hb_buffer_get_segment_properties(engine->hbBuffer, &segment_props);
+
+ shape_plan = hb_shape_plan_create_cached(hbFace, &segment_props, engine->features, engine->nFeatures, engine->ShaperList);
+ res = hb_shape_plan_execute(shape_plan, hbFont, engine->hbBuffer, engine->features, engine->nFeatures);
+
+ if (res) {
+ engine->shaper = strdup(hb_shape_plan_get_shaper(shape_plan));
+ hb_buffer_set_content_type(engine->hbBuffer, HB_BUFFER_CONTENT_TYPE_GLYPHS);
+ } else {
+ // all selected shapers failed, retrying with default
+ // we don't use _cached here as the cached plain will always fail.
+ hb_shape_plan_destroy(shape_plan);
+ shape_plan = hb_shape_plan_create(hbFace, &segment_props, engine->features, engine->nFeatures, NULL);
+ res = hb_shape_plan_execute(shape_plan, hbFont, engine->hbBuffer, engine->features, engine->nFeatures);
+
+ if (res) {
+ engine->shaper = strdup(hb_shape_plan_get_shaper(shape_plan));
+ hb_buffer_set_content_type(engine->hbBuffer, HB_BUFFER_CONTENT_TYPE_GLYPHS);
+ } else {
+ fprintf(stderr, "\nERROR: all shapers failed\n");
+ exit(3);
+ }
+ }
+
+ hb_shape_plan_destroy(shape_plan);
+
int glyphCount = hb_buffer_get_length(engine->hbBuffer);
#ifdef DEBUG
char buf[1024];
unsigned int consumed;
+
+ printf ("shaper: %s\n", engine->shaper);
+
hb_buffer_serialize_flags_t flags = HB_BUFFER_SERIALIZE_FLAGS_DEFAULT;
+ hb_buffer_serialize_format_t format = HB_BUFFER_SERIALIZE_FORMAT_TEXT;
- hb_buffer_serialize_glyphs (engine->hbBuffer, 0, glyphCount, buf, sizeof(buf), &consumed, engine->font->hbFont, HB_BUFFER_SERIALIZE_FORMAT_JSON, flags);
+ hb_buffer_serialize_glyphs (engine->hbBuffer, 0, glyphCount, buf, sizeof(buf), &consumed, hbFont, format, flags);
if (consumed)
printf ("buffer glyphs: %s\n", buf);
#endif
@@ -942,22 +987,27 @@ findNextGraphiteBreak(void)
}
}
-int usingGraphite(XeTeXLayoutEngine engine)
+bool usingGraphite(XeTeXLayoutEngine engine)
{
- return 0;
+ if (strcmp("graphite2", engine->shaper) == 0)
+ return true;
+ else
+ return false;
}
-int usingOpenType(XeTeXLayoutEngine engine)
+bool usingOpenType(XeTeXLayoutEngine engine)
{
- return engine->hbBuffer != NULL;
+ if (strcmp("ot", engine->shaper) == 0)
+ return true;
+ else
+ return false;
}
-int isOpenTypeMathFont(XeTeXLayoutEngine engine)
+bool isOpenTypeMathFont(XeTeXLayoutEngine engine)
{
- if (usingOpenType(engine)) {
- if (engine->font->getFontTable(kMATH) != NULL)
- return 1;
- }
- return 0;
+ if (engine->font->getFontTable(kMATH) != NULL)
+ return true;
+ else
+ return false;
}
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h
index 119bccbadec..d02c066edac 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h
+++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h
@@ -2,7 +2,7 @@
Part of the XeTeX typesetting system
Copyright (c) 1994-2008 by SIL International
Copyright (c) 2009 by Jonathan Kew
- Copyright (c) 2012 by Khaled Hosny
+ Copyright (c) 2012, 2013 by Khaled Hosny
SIL Author(s): Jonathan Kew
@@ -49,7 +49,13 @@ typedef struct XeTeXLayoutEngine_rec* XeTeXLayoutEngine;
#include "XeTeX_ext.h"
#include "XeTeXFontMgr.h"
+#ifdef _MSC_VER
+#ifndef __cplusplus
+typedef int bool;
+#endif
+#else
#include <stdbool.h>
+#endif
#include <hb.h>
#include <hb-ot.h>
#include <hb-ft.h>
@@ -158,9 +164,9 @@ int getFontCharRange(XeTeXLayoutEngine engine, int reqFirst);
bool initGraphiteBreaking(XeTeXLayoutEngine engine, const UniChar* txtPtr, int txtLen);
int findNextGraphiteBreak(void);
-int usingOpenType(XeTeXLayoutEngine engine);
-int usingGraphite(XeTeXLayoutEngine engine);
-int isOpenTypeMathFont(XeTeXLayoutEngine engine);
+bool usingOpenType(XeTeXLayoutEngine engine);
+bool usingGraphite(XeTeXLayoutEngine engine);
+bool isOpenTypeMathFont(XeTeXLayoutEngine engine);
bool findGraphiteFeature(XeTeXLayoutEngine engine, const char* s, const char* e, int* f, int* v);
diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
index 0334e2880d0..2c7cd172265 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
+++ b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
@@ -455,6 +455,7 @@ static int brkLocaleStrNum = 0;
void
linebreakstart(int f, integer localeStrNum, const UniChar* text, integer textLength)
{
+ UErrorCode status;
char* locale = (char*)gettexstring(localeStrNum);
if (fontarea[f] == OTGR_FONT_FLAG && strcmp(locale, "G") == 0) {
@@ -464,7 +465,7 @@ linebreakstart(int f, integer localeStrNum, const UniChar* text, integer textLen
return;
}
- UErrorCode status = 0;
+ status = 0;
if ((localeStrNum != brkLocaleStrNum) && (brkIter != NULL)) {
ubrk_close(brkIter);
@@ -709,53 +710,20 @@ read_double(const char** s)
return neg ? -val : val;
}
-static char*
-read_str_tag(const char* cp)
-{
- char tag[5];
- int i;
- for (i = 0; i < 4; ++i) {
- if (*cp && /* *cp < 128 && */ *cp != ',' && *cp != ';' && *cp != ':') {
- tag[i] = *cp;
- ++cp;
- }
- else
- tag[i] = ' ';
- }
- tag[4] = '\0';
- return tag;
-}
-
-static UInt32
-read_tag(const char* cp, char padChar)
-{
- UInt32 tag = 0;
- int i;
- for (i = 0; i < 4; ++i) {
- tag <<= 8;
- if (*cp && /* *cp < 128 && */ *cp != ',' && *cp != ';' && *cp != ':') {
- tag += *(unsigned char*)cp;
- ++cp;
- }
- else
- tag += padChar;
- }
- return tag;
-}
-
static hb_tag_t
read_tag_with_param(const char* cp, int* param)
{
- char tag[4];
+ const char* cp2;
+ hb_tag_t tag;
int i;
- for (i = 0; i < 4; ++i) {
- if (*cp && /* *cp < 128 && */ *cp != ',' && *cp != ';' && *cp != ':') {
- tag[i] = *cp;
- ++cp;
- }
- else
- tag[i] = ' ';
- }
+
+ cp2 = cp;
+ while (*cp2 && (*cp2 != ':') && (*cp2 != ';') && (*cp2 != ',') && (*cp2 != '='))
+ ++cp2;
+
+ tag = hb_tag_from_string(cp, cp2 - cp);
+
+ cp = cp2;
if (*cp == '=') {
int neg = 0;
++cp;
@@ -770,7 +738,8 @@ read_tag_with_param(const char* cp, int* param)
if (neg)
*param = -(*param);
}
- return HB_TAG(tag[0],tag[1],tag[2],tag[3]);
+
+ return tag;
}
unsigned int
@@ -907,6 +876,22 @@ readFeatureNumber(const char* s, const char* e, int* f, int* v)
return true;
}
+#ifdef _MSC_VER
+static char *strndup (const char *str, size_t n)
+{
+ char *ret;
+ size_t len = strlen (str);
+
+ if (n < len)
+ len = n;
+ ret = (char *) malloc (len + 1);
+ if (!ret)
+ return NULL;
+ ret[len] = '\0';
+ return (char *) memcpy (ret, str, len);
+}
+#endif
+
static void*
loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const char* cp1)
{
@@ -960,7 +945,8 @@ loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const cha
cp3 = cp1 + 6;
if (*cp3 != '=')
goto bad_option;
- script = read_str_tag(cp3 + 1);
+ ++cp3;
+ script = strndup(cp3, cp2 - cp3);
goto next_option;
}
@@ -968,19 +954,18 @@ loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const cha
cp3 = cp1 + 8;
if (*cp3 != '=')
goto bad_option;
- language = read_str_tag(cp3 + 1);
+ ++cp3;
+ language = strndup(cp3, cp2 - cp3);
goto next_option;
}
if (strncmp(cp1, "shaper", 6) == 0) {
- char* tmpStr;
cp3 = cp1 + 6;
if (*cp3 != '=')
goto bad_option;
- cp3 = cp1 + 7;
+ ++cp3;
shapers = xrealloc(shapers, (nShapers + 1) * sizeof(char *));
- tmpStr = xcalloc(1, cp2 - cp3 + 1);
- shapers[nShapers++] = strncpy(tmpStr, cp3, cp2 - cp3);
+ shapers[nShapers++] = strndup(cp3, cp2 - cp3);
goto next_option;
}
@@ -1023,7 +1008,8 @@ loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const cha
}
if (*cp1 == '-') {
- tag = hb_tag_from_string(read_str_tag(cp1 + 1), -1);
+ ++cp1;
+ tag = hb_tag_from_string(cp1, cp2 - cp1);
features = xrealloc(features, (nFeatures + 1) * sizeof(hb_feature_t));
features[nFeatures].tag = tag;
features[nFeatures].value = 0;
diff --git a/Build/source/texk/web2c/xetexdir/xetex.web b/Build/source/texk/web2c/xetexdir/xetex.web
index f8de399a567..50554cd5a5b 100644
--- a/Build/source/texk/web2c/xetexdir/xetex.web
+++ b/Build/source/texk/web2c/xetexdir/xetex.web
@@ -26783,7 +26783,7 @@ primitive("uccode",def_code,uc_code_base);
primitive("sfcode",def_code,sf_code_base);
@!@:sf_code_}{\.{\\sfcode} primitive@>
primitive("XeTeXcharclass",XeTeX_def_code,sf_code_base);
-@!@:U_char_class_}{\.{\\XeTeXcharclass} primitive@>
+@!@:XeTeX_char_class_}{\.{\\XeTeXcharclass} primitive@>
primitive("delcode",def_code,del_code_base);
@!@:del_code_}{\.{\\delcode} primitive@>
primitive("XeTeXdelcodenum",XeTeX_def_code,del_code_base);