diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2013-04-04 16:15:32 +0000 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2013-04-04 16:15:32 +0000 |
commit | 7ae4f3a4bad94230ffba68bceb27b269b8fa04c4 (patch) | |
tree | 01b22a668189f35814046e5d67ee467d3d390f81 /Build | |
parent | 5a7a4e71861fd6c6cc2d03100a0daf7f1c4161de (diff) |
XeTeX updates
git-svn-id: svn://tug.org/texlive/trunk@29639 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp | 45 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp | 33 |
2 files changed, 46 insertions, 32 deletions
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp index 676759a0cc4..fd13178e858 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp @@ -48,9 +48,6 @@ authorization from the copyright holders. #include FT_ADVANCES_H FT_Library gFreeTypeLibrary = 0; -// FT_LOAD_NO_BITMAP is needed to work around: -// http://lists.gnu.org/archive/html/freetype/2013-03/msg00009.html -static int ftLoadFlags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; XeTeXFontInst::XeTeXFontInst(const char* pathname, int index, float pointSize, int &status) : fPointSize(pointSize) @@ -101,7 +98,7 @@ _get_glyph_advance(FT_Face face, FT_UInt gid, bool vertical) { FT_Error error; FT_Fixed advance; - int flags = ftLoadFlags; + int flags = FT_LOAD_NO_SCALE; if (vertical) flags |= FT_LOAD_VERTICAL_LAYOUT; @@ -110,7 +107,7 @@ _get_glyph_advance(FT_Face face, FT_UInt gid, bool vertical) if (error) advance = 0; else - advance = advance >> 10; + advance = advance; /* FreeType's vertical metrics grows downward */ if (vertical) @@ -134,16 +131,26 @@ _get_glyph_v_advance(hb_font_t*, void *font_data, hb_codepoint_t gid, void*) static hb_bool_t _get_glyph_h_origin(hb_font_t*, void *font_data, hb_codepoint_t gid, hb_position_t *x, hb_position_t *y, void*) { + // horizontal origin is (0, 0) return true; } static hb_bool_t _get_glyph_v_origin(hb_font_t*, void *font_data, hb_codepoint_t gid, hb_position_t *x, hb_position_t *y, void*) { + // vertical origin is (0, 0) for now + return true; + + // TODO + // Keep the code below for reference, for now we want to keep vertical + // origin at (0, 0) for compatibility with pre-0.9999. + // Reconsider this (e.g. using BASE table) when we get around overhauling + // the text directionality model and implementing real vertical typesetting. + FT_Face face = (FT_Face) font_data; FT_Error error; - error = FT_Load_Glyph (face, gid, ftLoadFlags); + error = FT_Load_Glyph (face, gid, FT_LOAD_NO_SCALE); if (!error) { *x = face->glyph->metrics.horiBearingX - face->glyph->metrics.vertBearingX; *y = face->glyph->metrics.horiBearingY - (-face->glyph->metrics.vertBearingY); @@ -181,7 +188,7 @@ _get_glyph_extents(hb_font_t*, void *font_data, hb_codepoint_t gid, hb_glyph_ext FT_Face face = (FT_Face) font_data; FT_Error error; - error = FT_Load_Glyph (face, gid, ftLoadFlags); + error = FT_Load_Glyph (face, gid, FT_LOAD_NO_SCALE); if (!error) { extents->x_bearing = face->glyph->metrics.horiBearingX; extents->y_bearing = face->glyph->metrics.horiBearingY; @@ -199,7 +206,7 @@ _get_glyph_contour_point(hb_font_t*, void *font_data, hb_codepoint_t gid, unsign FT_Error error; bool ret = false; - error = FT_Load_Glyph (face, gid, ftLoadFlags); + error = FT_Load_Glyph (face, gid, FT_LOAD_NO_SCALE); if (!error) { if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) { if (point_index < (unsigned int) face->glyph->outline.n_points) { @@ -213,6 +220,19 @@ _get_glyph_contour_point(hb_font_t*, void *font_data, hb_codepoint_t gid, unsign return ret; } +static hb_bool_t +_get_glyph_name(hb_font_t *, void *font_data, hb_codepoint_t gid, char *name, unsigned int size, void *) +{ + FT_Face face = (FT_Face) font_data; + bool ret = false; + + ret = !FT_Get_Glyph_Name (face, gid, name, size); + if (ret && (size && !*name)) + ret = false; + + return ret; +} + static hb_font_funcs_t * _get_font_funcs(void) { @@ -227,6 +247,7 @@ _get_font_funcs(void) hb_font_funcs_set_glyph_v_kerning_func (funcs, _get_glyph_v_kerning, NULL, NULL); hb_font_funcs_set_glyph_extents_func (funcs, _get_glyph_extents, NULL, NULL); hb_font_funcs_set_glyph_contour_point_func (funcs, _get_glyph_contour_point, NULL, NULL); + hb_font_funcs_set_glyph_name_func (funcs, _get_glyph_name, NULL, NULL); return funcs; } @@ -296,8 +317,6 @@ XeTeXFontInst::initialize(const char* pathname, int index, int &status) delete[] afm; } - FT_Set_Char_Size(ftFace, fPointSize * 64, 0, 0, 0); - char buf[20]; if (index > 0) sprintf(buf, ":%d", index); @@ -328,9 +347,7 @@ XeTeXFontInst::initialize(const char* pathname, int index, int &status) hb_face_destroy(hbFace); hb_font_set_funcs(hbFont, _get_font_funcs(), ftFace, NULL); - hb_font_set_scale(hbFont, - ((uint64_t) ftFace->size->metrics.x_scale * (uint64_t) fUnitsPerEM) >> 16, - ((uint64_t) ftFace->size->metrics.y_scale * (uint64_t) fUnitsPerEM) >> 16); + hb_font_set_scale(hbFont, fUnitsPerEM, fUnitsPerEM); // We don’t want device tables adjustments hb_font_set_ppem(hbFont, 0, 0); @@ -414,7 +431,7 @@ XeTeXFontInst::getNumGlyphs() const float XeTeXFontInst::getGlyphWidth(GlyphID gid) { - return _get_glyph_advance(ftFace, gid, false) / 64.0; + return unitsToPoints(_get_glyph_advance(ftFace, gid, false)); } void diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp index 0788ee19d3e..c87b84416d1 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp @@ -708,7 +708,7 @@ layoutChars(XeTeXLayoutEngine engine, uint16_t chars[], int32_t offset, int32_t 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_format_t format = HB_BUFFER_SERIALIZE_FORMAT_JSON; hb_buffer_serialize_glyphs (engine->hbBuffer, 0, glyphCount, buf, sizeof(buf), &consumed, hbFont, format, flags); if (consumed) @@ -736,9 +736,9 @@ getGlyphAdvances(XeTeXLayoutEngine engine, float advances[]) for (int i = 0; i < glyphCount; i++) { if (engine->font->getLayoutDirVertical()) - advances[i] = hbPositions[i].y_advance / 64.0; + advances[i] = engine->font->unitsToPoints(hbPositions[i].y_advance); else - advances[i] = hbPositions[i].x_advance / 64.0; + advances[i] = engine->font->unitsToPoints(hbPositions[i].x_advance); } } @@ -752,26 +752,23 @@ getGlyphPositions(XeTeXLayoutEngine engine, float positions[]) float x = 0, y = 0; if (engine->font->getLayoutDirVertical()) { - /* XXX I'm not sure about the code below, but it seems to math the - * behaviour of old code */ - x += hbPositions[0].y_offset / 64.0; /* hack to compensate offset of 1st glyph */ for (i = 0; i < glyphCount; i++) { - positions[2*i] = -(x - (hbPositions[i].y_offset / 64.0)); /* negative is forwards */ - positions[2*i+1] = hbPositions[i].x_advance / 64.0; - x += hbPositions[i].y_advance / 64.0; + positions[2*i] = - engine->font->unitsToPoints(x + hbPositions[i].y_offset); /* negative is forwards */ + positions[2*i+1] = engine->font->unitsToPoints(y - hbPositions[i].x_offset); + x += hbPositions[i].y_advance; + y += hbPositions[i].x_advance; } - x -= hbPositions[glyphCount-1].y_offset / 64.0; - positions[2*i] = -x; - positions[2*i+1] = y; + positions[2*i] = - engine->font->unitsToPoints(x); + positions[2*i+1] = engine->font->unitsToPoints(y); } else { for (i = 0; i < glyphCount; i++) { - positions[2*i] = x + hbPositions[i].x_offset / 64.0; - positions[2*i+1] = -(y + hbPositions[i].y_offset / 64.0); /* negative is upwards */ - x += hbPositions[i].x_advance / 64.0; - y += hbPositions[i].y_advance / 64.0; + positions[2*i] = engine->font->unitsToPoints(x + hbPositions[i].x_offset); + positions[2*i+1] = - engine->font->unitsToPoints(y + hbPositions[i].y_offset); /* negative is upwards */ + x += hbPositions[i].x_advance; + y += hbPositions[i].y_advance; } - positions[2*i] = x; - positions[2*i+1] = -y; + positions[2*i] = engine->font->unitsToPoints(x); + positions[2*i+1] = - engine->font->unitsToPoints(y); } if (engine->extend != 1.0 || engine->slant != 0.0) |