summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-03-06 22:43:23 +0000
committerKhaled Hosny <khaledhosny@eglug.org>2013-03-06 22:43:23 +0000
commit2fb851202b1da73113b967586b130f59ee5491dd (patch)
treea85b08eb844b14e9b567c8cb73752ac40019c9c9 /Build
parent6eaf934f7aad57a32b0166d28dabff1fccf151d6 (diff)
Sync XeTeX
git-svn-id: svn://tug.org/texlive/trunk@29299 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/Makefile.in139
-rw-r--r--Build/source/texk/web2c/xetexdir/FontTableCache.cpp142
-rw-r--r--Build/source/texk/web2c/xetexdir/FontTableCache.h78
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp457
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontInst.h117
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp252
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h76
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp152
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h21
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp35
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h2
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp9
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Mac.mm4
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp443
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h17
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp14
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeX_ext.c316
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeX_ext.h19
-rw-r--r--Build/source/texk/web2c/xetexdir/XeTeX_mac.c309
-rw-r--r--Build/source/texk/web2c/xetexdir/am/xetex.am8
-rw-r--r--Build/source/texk/web2c/xetexdir/appleGlyphNames.c293
-rw-r--r--Build/source/texk/web2c/xetexdir/sfnt.h169
-rw-r--r--Build/source/texk/web2c/xetexdir/xetex.web84
23 files changed, 1071 insertions, 2085 deletions
diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in
index 921237f506a..08b734af8dd 100644
--- a/Build/source/texk/web2c/Makefile.in
+++ b/Build/source/texk/web2c/Makefile.in
@@ -640,23 +640,20 @@ libukanji_a_OBJECTS = $(am_libukanji_a_OBJECTS)
libxetex_a_AR = $(AR) $(ARFLAGS)
libxetex_a_LIBADD =
am__libxetex_a_SOURCES_DIST = xetexdir/MathTable.h \
- xetexdir/FontTableCache.cpp xetexdir/FontTableCache.h \
xetexdir/XeTeXFontInst.cpp xetexdir/XeTeXFontInst.h \
- xetexdir/XeTeXFontInst_FT2.cpp xetexdir/XeTeXFontInst_FT2.h \
xetexdir/XeTeXFontMgr.cpp xetexdir/XeTeXFontMgr.h \
xetexdir/XeTeXLayoutInterface.cpp \
xetexdir/XeTeXLayoutInterface.h xetexdir/XeTeXOTMath.cpp \
xetexdir/XeTeXOTMath.h xetexdir/XeTeX_ext.c \
- xetexdir/XeTeX_ext.h xetexdir/XeTeXswap.h xetexdir/sfnt.h \
- xetexdir/trans.c xetexdir/trans.h xetexdir/hz.cpp \
- xetexdir/xetex.h xetexdir/XeTeXFontInst_Mac.cpp \
- xetexdir/XeTeXFontInst_Mac.h xetexdir/XeTeXFontMgr_Mac.mm \
- xetexdir/XeTeXFontMgr_Mac.h xetexdir/XeTeX_mac.c \
- xetexdir/XeTeXFontMgr_FC.cpp xetexdir/XeTeXFontMgr_FC.h \
- xetexdir/XeTeX_pic.c xetexdir/bmpimage.c xetexdir/bmpimage.h \
- xetexdir/jpegimage.c xetexdir/jpegimage.h \
- xetexdir/pdfimage.cpp xetexdir/pdfimage.h xetexdir/pngimage.c \
- xetexdir/pngimage.h
+ xetexdir/XeTeX_ext.h xetexdir/XeTeXswap.h xetexdir/trans.c \
+ xetexdir/trans.h xetexdir/hz.cpp xetexdir/xetex.h \
+ xetexdir/XeTeXFontInst_Mac.cpp xetexdir/XeTeXFontInst_Mac.h \
+ xetexdir/XeTeXFontMgr_Mac.mm xetexdir/XeTeXFontMgr_Mac.h \
+ xetexdir/XeTeX_mac.c xetexdir/XeTeXFontMgr_FC.cpp \
+ xetexdir/XeTeXFontMgr_FC.h xetexdir/XeTeX_pic.c \
+ xetexdir/bmpimage.c xetexdir/bmpimage.h xetexdir/jpegimage.c \
+ xetexdir/jpegimage.h xetexdir/pdfimage.cpp xetexdir/pdfimage.h \
+ xetexdir/pngimage.c xetexdir/pngimage.h
@XETEX_MACOSX_TRUE@am__objects_7 = xetexdir/libxetex_a-XeTeXFontInst_Mac.$(OBJEXT) \
@XETEX_MACOSX_TRUE@ xetexdir/libxetex_a-XeTeXFontMgr_Mac.$(OBJEXT) \
@XETEX_MACOSX_TRUE@ xetexdir/libxetex_a-XeTeX_mac.$(OBJEXT)
@@ -666,9 +663,7 @@ am__libxetex_a_SOURCES_DIST = xetexdir/MathTable.h \
@XETEX_MACOSX_FALSE@ xetexdir/libxetex_a-jpegimage.$(OBJEXT) \
@XETEX_MACOSX_FALSE@ xetexdir/libxetex_a-pdfimage.$(OBJEXT) \
@XETEX_MACOSX_FALSE@ xetexdir/libxetex_a-pngimage.$(OBJEXT)
-am_libxetex_a_OBJECTS = xetexdir/libxetex_a-FontTableCache.$(OBJEXT) \
- xetexdir/libxetex_a-XeTeXFontInst.$(OBJEXT) \
- xetexdir/libxetex_a-XeTeXFontInst_FT2.$(OBJEXT) \
+am_libxetex_a_OBJECTS = xetexdir/libxetex_a-XeTeXFontInst.$(OBJEXT) \
xetexdir/libxetex_a-XeTeXFontMgr.$(OBJEXT) \
xetexdir/libxetex_a-XeTeXLayoutInterface.$(OBJEXT) \
xetexdir/libxetex_a-XeTeXOTMath.$(OBJEXT) \
@@ -1898,40 +1893,40 @@ EXTRA_DIST = PROJECTS cftests cpascal.h help.h w2c/config.h \
$(libluatex_web) luatexdir/ChangeLog luatexdir/NEWS \
luatexdir/font/subfont.txt $(xetex_web_srcs) $(xetex_ch_srcs) \
xetexdir/xetex.defines xetexdir/unicode-char-prep.pl \
- xetexdir/appleGlyphNames.c xetexdir/ChangeLog $(xetex_tests) \
- xetexdir/COPYING xetexdir/xewebmac.tex omegaware/README \
- omegaware/ChangeLog $(odvicopy_sources) $(odvitype_sources) \
- $(ofm2opl_sources) $(opl2ofm_sources) $(otangle_sources) \
- omegaware/ovf2ovp.web omegaware/ovf2ovp.up \
- omegaware/ovf2ovp.ch omegaware/ovp2ovf.web \
- omegaware/ovp2ovf.up omegaware/ovp2ovf.ch $(OTANGLE_tests) \
- $(OMFONTS_tests) omegaware/tests/level1.opl \
- omegaware/tests/ofontd1.dvi omegaware/tests/ofontd1.typ \
- omegaware/tests/ofontd2.dvi omegaware/tests/ofontd2.typ \
- omegaware/tests/ofontd3.dvi omegaware/tests/ofontd3.typ \
- omegaware/tests/ofontr1.vf omegaware/tests/ofontr2.ovf \
- omegaware/tests/ofontr3.ovf omegaware/tests/ofontv4.vf \
- omegaware/tests/ofontv5.ovf omegaware/tests/ofontv6.ovf \
- omegaware/tests/ofontd0.dtl omegaware/tests/ofontd0.dvi \
- omegaware/tests/ofontd0.typ omegaware/tests/ofontr0.tfm \
- omegaware/tests/ofontr1.tfm omegaware/tests/ofontr2.ofm \
- omegaware/tests/ofontr3.ofm omegaware/tests/ofontv4.tfm \
- omegaware/tests/ofontv5.ofm omegaware/tests/ofontv6.ofm \
- omegaware/tests/ofontr0.pl omegaware/tests/ofontr1.pl \
- omegaware/tests/ofontr1.vpl omegaware/tests/ofontr2.opl \
- omegaware/tests/ofontr2.ovp omegaware/tests/ofontr3.opl \
- omegaware/tests/ofontr3.ovp omegaware/tests/ofontv4.pl \
- omegaware/tests/ofontv4.vpl omegaware/tests/ofontv5.opl \
- omegaware/tests/ofontv5.ovp omegaware/tests/ofontv6.opl \
- omegaware/tests/ofontv6.ovp omegaware/tests/Cherokee.pl \
- omegaware/tests/OCherokee.ovp omegaware/tests/realnum.opl \
- omegaware/tests/realnum.out omegaware/tests/repeat.opl \
- omegaware/tests/repeated.opl omegaware/tests/sample.out \
- omegaware/tests/sample.ovp omegaware/tests/sample0-h.opl \
- omegaware/tests/specialhex.ovp $(aleph_web_srcs) \
- $(aleph_ch_srcs) alephdir/ChangeLog alephdir/aleph.defines \
- alephdir/aleph.version $(aleph_tests) synctexdir/ChangeLog \
- synctexdir/README.txt synctexdir/synctex_parser_readme.txt \
+ xetexdir/ChangeLog $(xetex_tests) xetexdir/COPYING \
+ xetexdir/xewebmac.tex omegaware/README omegaware/ChangeLog \
+ $(odvicopy_sources) $(odvitype_sources) $(ofm2opl_sources) \
+ $(opl2ofm_sources) $(otangle_sources) omegaware/ovf2ovp.web \
+ omegaware/ovf2ovp.up omegaware/ovf2ovp.ch \
+ omegaware/ovp2ovf.web omegaware/ovp2ovf.up \
+ omegaware/ovp2ovf.ch $(OTANGLE_tests) $(OMFONTS_tests) \
+ omegaware/tests/level1.opl omegaware/tests/ofontd1.dvi \
+ omegaware/tests/ofontd1.typ omegaware/tests/ofontd2.dvi \
+ omegaware/tests/ofontd2.typ omegaware/tests/ofontd3.dvi \
+ omegaware/tests/ofontd3.typ omegaware/tests/ofontr1.vf \
+ omegaware/tests/ofontr2.ovf omegaware/tests/ofontr3.ovf \
+ omegaware/tests/ofontv4.vf omegaware/tests/ofontv5.ovf \
+ omegaware/tests/ofontv6.ovf omegaware/tests/ofontd0.dtl \
+ omegaware/tests/ofontd0.dvi omegaware/tests/ofontd0.typ \
+ omegaware/tests/ofontr0.tfm omegaware/tests/ofontr1.tfm \
+ omegaware/tests/ofontr2.ofm omegaware/tests/ofontr3.ofm \
+ omegaware/tests/ofontv4.tfm omegaware/tests/ofontv5.ofm \
+ omegaware/tests/ofontv6.ofm omegaware/tests/ofontr0.pl \
+ omegaware/tests/ofontr1.pl omegaware/tests/ofontr1.vpl \
+ omegaware/tests/ofontr2.opl omegaware/tests/ofontr2.ovp \
+ omegaware/tests/ofontr3.opl omegaware/tests/ofontr3.ovp \
+ omegaware/tests/ofontv4.pl omegaware/tests/ofontv4.vpl \
+ omegaware/tests/ofontv5.opl omegaware/tests/ofontv5.ovp \
+ omegaware/tests/ofontv6.opl omegaware/tests/ofontv6.ovp \
+ omegaware/tests/Cherokee.pl omegaware/tests/OCherokee.ovp \
+ omegaware/tests/realnum.opl omegaware/tests/realnum.out \
+ omegaware/tests/repeat.opl omegaware/tests/repeated.opl \
+ omegaware/tests/sample.out omegaware/tests/sample.ovp \
+ omegaware/tests/sample0-h.opl omegaware/tests/specialhex.ovp \
+ $(aleph_web_srcs) $(aleph_ch_srcs) alephdir/ChangeLog \
+ alephdir/aleph.defines alephdir/aleph.version $(aleph_tests) \
+ synctexdir/ChangeLog synctexdir/README.txt \
+ synctexdir/synctex_parser_readme.txt \
synctexdir/synctex_parser_version.txt synctexdir/tests \
synctexdir/synctex-common.h synctexdir/synctex.c \
synctexdir/synctex.defines synctexdir/synctex.h \
@@ -2943,16 +2938,14 @@ libxetex_a_CPPFLAGS = $(xetex_cppflags)
libxetex_a_CFLAGS = # $(WARNING_CFLAGS)
libxetex_a_CXXFLAGS = # $(WARNING_CXXFLAGS)
libxetex_a_OBJCXXFLAGS = # $(WARNING_OBJCXXFLAGS)
-libxetex_a_SOURCES = xetexdir/MathTable.h xetexdir/FontTableCache.cpp \
- xetexdir/FontTableCache.h xetexdir/XeTeXFontInst.cpp \
- xetexdir/XeTeXFontInst.h xetexdir/XeTeXFontInst_FT2.cpp \
- xetexdir/XeTeXFontInst_FT2.h xetexdir/XeTeXFontMgr.cpp \
+libxetex_a_SOURCES = xetexdir/MathTable.h xetexdir/XeTeXFontInst.cpp \
+ xetexdir/XeTeXFontInst.h xetexdir/XeTeXFontMgr.cpp \
xetexdir/XeTeXFontMgr.h xetexdir/XeTeXLayoutInterface.cpp \
xetexdir/XeTeXLayoutInterface.h xetexdir/XeTeXOTMath.cpp \
xetexdir/XeTeXOTMath.h xetexdir/XeTeX_ext.c \
- xetexdir/XeTeX_ext.h xetexdir/XeTeXswap.h xetexdir/sfnt.h \
- xetexdir/trans.c xetexdir/trans.h xetexdir/hz.cpp \
- xetexdir/xetex.h $(am__append_72) $(am__append_73)
+ xetexdir/XeTeX_ext.h xetexdir/XeTeXswap.h xetexdir/trans.c \
+ xetexdir/trans.h xetexdir/hz.cpp xetexdir/xetex.h \
+ $(am__append_72) $(am__append_73)
# We must create xetexd.h etc. before building the libxetex_a_OBJECTS.
libxetex_prereq = xetexd.h $(xetex_dependencies)
@@ -3866,12 +3859,8 @@ xetexdir/$(am__dirstamp):
xetexdir/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) xetexdir/$(DEPDIR)
@: > xetexdir/$(DEPDIR)/$(am__dirstamp)
-xetexdir/libxetex_a-FontTableCache.$(OBJEXT): \
- xetexdir/$(am__dirstamp) xetexdir/$(DEPDIR)/$(am__dirstamp)
xetexdir/libxetex_a-XeTeXFontInst.$(OBJEXT): xetexdir/$(am__dirstamp) \
xetexdir/$(DEPDIR)/$(am__dirstamp)
-xetexdir/libxetex_a-XeTeXFontInst_FT2.$(OBJEXT): \
- xetexdir/$(am__dirstamp) xetexdir/$(DEPDIR)/$(am__dirstamp)
xetexdir/libxetex_a-XeTeXFontMgr.$(OBJEXT): xetexdir/$(am__dirstamp) \
xetexdir/$(DEPDIR)/$(am__dirstamp)
xetexdir/libxetex_a-XeTeXLayoutInterface.$(OBJEXT): \
@@ -4648,9 +4637,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@uptexdir/$(DEPDIR)/libukanji_a-kanji.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@uptexdir/$(DEPDIR)/libukanji_a-kanji_dump.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@uptexdir/$(DEPDIR)/uptex-uptexextra.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@xetexdir/$(DEPDIR)/libxetex_a-FontTableCache.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_FT2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_Mac.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontMgr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontMgr_FC.Po@am__quote@
@@ -9490,20 +9477,6 @@ pdftexdir/libpdftex_a-pdftoepdf.obj: pdftexdir/pdftoepdf.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpdftex_a_CPPFLAGS) $(CPPFLAGS) $(libpdftex_a_CXXFLAGS) $(CXXFLAGS) -c -o pdftexdir/libpdftex_a-pdftoepdf.obj `if test -f 'pdftexdir/pdftoepdf.cc'; then $(CYGPATH_W) 'pdftexdir/pdftoepdf.cc'; else $(CYGPATH_W) '$(srcdir)/pdftexdir/pdftoepdf.cc'; fi`
-xetexdir/libxetex_a-FontTableCache.o: xetexdir/FontTableCache.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -MT xetexdir/libxetex_a-FontTableCache.o -MD -MP -MF xetexdir/$(DEPDIR)/libxetex_a-FontTableCache.Tpo -c -o xetexdir/libxetex_a-FontTableCache.o `test -f 'xetexdir/FontTableCache.cpp' || echo '$(srcdir)/'`xetexdir/FontTableCache.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) xetexdir/$(DEPDIR)/libxetex_a-FontTableCache.Tpo xetexdir/$(DEPDIR)/libxetex_a-FontTableCache.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='xetexdir/FontTableCache.cpp' object='xetexdir/libxetex_a-FontTableCache.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -c -o xetexdir/libxetex_a-FontTableCache.o `test -f 'xetexdir/FontTableCache.cpp' || echo '$(srcdir)/'`xetexdir/FontTableCache.cpp
-
-xetexdir/libxetex_a-FontTableCache.obj: xetexdir/FontTableCache.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -MT xetexdir/libxetex_a-FontTableCache.obj -MD -MP -MF xetexdir/$(DEPDIR)/libxetex_a-FontTableCache.Tpo -c -o xetexdir/libxetex_a-FontTableCache.obj `if test -f 'xetexdir/FontTableCache.cpp'; then $(CYGPATH_W) 'xetexdir/FontTableCache.cpp'; else $(CYGPATH_W) '$(srcdir)/xetexdir/FontTableCache.cpp'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) xetexdir/$(DEPDIR)/libxetex_a-FontTableCache.Tpo xetexdir/$(DEPDIR)/libxetex_a-FontTableCache.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='xetexdir/FontTableCache.cpp' object='xetexdir/libxetex_a-FontTableCache.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -c -o xetexdir/libxetex_a-FontTableCache.obj `if test -f 'xetexdir/FontTableCache.cpp'; then $(CYGPATH_W) 'xetexdir/FontTableCache.cpp'; else $(CYGPATH_W) '$(srcdir)/xetexdir/FontTableCache.cpp'; fi`
-
xetexdir/libxetex_a-XeTeXFontInst.o: xetexdir/XeTeXFontInst.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -MT xetexdir/libxetex_a-XeTeXFontInst.o -MD -MP -MF xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst.Tpo -c -o xetexdir/libxetex_a-XeTeXFontInst.o `test -f 'xetexdir/XeTeXFontInst.cpp' || echo '$(srcdir)/'`xetexdir/XeTeXFontInst.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst.Tpo xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst.Po
@@ -9518,20 +9491,6 @@ xetexdir/libxetex_a-XeTeXFontInst.obj: xetexdir/XeTeXFontInst.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -c -o xetexdir/libxetex_a-XeTeXFontInst.obj `if test -f 'xetexdir/XeTeXFontInst.cpp'; then $(CYGPATH_W) 'xetexdir/XeTeXFontInst.cpp'; else $(CYGPATH_W) '$(srcdir)/xetexdir/XeTeXFontInst.cpp'; fi`
-xetexdir/libxetex_a-XeTeXFontInst_FT2.o: xetexdir/XeTeXFontInst_FT2.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -MT xetexdir/libxetex_a-XeTeXFontInst_FT2.o -MD -MP -MF xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_FT2.Tpo -c -o xetexdir/libxetex_a-XeTeXFontInst_FT2.o `test -f 'xetexdir/XeTeXFontInst_FT2.cpp' || echo '$(srcdir)/'`xetexdir/XeTeXFontInst_FT2.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_FT2.Tpo xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_FT2.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='xetexdir/XeTeXFontInst_FT2.cpp' object='xetexdir/libxetex_a-XeTeXFontInst_FT2.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -c -o xetexdir/libxetex_a-XeTeXFontInst_FT2.o `test -f 'xetexdir/XeTeXFontInst_FT2.cpp' || echo '$(srcdir)/'`xetexdir/XeTeXFontInst_FT2.cpp
-
-xetexdir/libxetex_a-XeTeXFontInst_FT2.obj: xetexdir/XeTeXFontInst_FT2.cpp
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -MT xetexdir/libxetex_a-XeTeXFontInst_FT2.obj -MD -MP -MF xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_FT2.Tpo -c -o xetexdir/libxetex_a-XeTeXFontInst_FT2.obj `if test -f 'xetexdir/XeTeXFontInst_FT2.cpp'; then $(CYGPATH_W) 'xetexdir/XeTeXFontInst_FT2.cpp'; else $(CYGPATH_W) '$(srcdir)/xetexdir/XeTeXFontInst_FT2.cpp'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_FT2.Tpo xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontInst_FT2.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='xetexdir/XeTeXFontInst_FT2.cpp' object='xetexdir/libxetex_a-XeTeXFontInst_FT2.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -c -o xetexdir/libxetex_a-XeTeXFontInst_FT2.obj `if test -f 'xetexdir/XeTeXFontInst_FT2.cpp'; then $(CYGPATH_W) 'xetexdir/XeTeXFontInst_FT2.cpp'; else $(CYGPATH_W) '$(srcdir)/xetexdir/XeTeXFontInst_FT2.cpp'; fi`
-
xetexdir/libxetex_a-XeTeXFontMgr.o: xetexdir/XeTeXFontMgr.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libxetex_a_CPPFLAGS) $(CPPFLAGS) $(libxetex_a_CXXFLAGS) $(CXXFLAGS) -MT xetexdir/libxetex_a-XeTeXFontMgr.o -MD -MP -MF xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontMgr.Tpo -c -o xetexdir/libxetex_a-XeTeXFontMgr.o `test -f 'xetexdir/XeTeXFontMgr.cpp' || echo '$(srcdir)/'`xetexdir/XeTeXFontMgr.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontMgr.Tpo xetexdir/$(DEPDIR)/libxetex_a-XeTeXFontMgr.Po
diff --git a/Build/source/texk/web2c/xetexdir/FontTableCache.cpp b/Build/source/texk/web2c/xetexdir/FontTableCache.cpp
deleted file mode 100644
index 48b0520aed7..00000000000
--- a/Build/source/texk/web2c/xetexdir/FontTableCache.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************\
- Part of the XeTeX typesetting system
- Copyright (c) 1994-2008 by SIL International
- Copyright (c) 2009 by Jonathan Kew
-
- SIL Author(s): 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 THE COPYRIGHT HOLDERS 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 the copyright holders
-shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written
-authorization from the copyright holders.
-\****************************************************************************/
-
-/* from ICU sample code, extended by JK for XeTeX */
-
-/*
- **********************************************************************
- * Copyright (C) 2003, International Business Machines
- * Corporation and others. All Rights Reserved.
- **********************************************************************
- */
-
-#include "FontTableCache.h"
-
-#define TABLE_CACHE_INIT 5
-#define TABLE_CACHE_GROW 5
-
-struct FontTableCacheEntry
-{
- OTTag tag;
- const void *table;
- uint32_t size;
-};
-
-FontTableCache::FontTableCache()
- : fTableCacheCurr(0), fTableCacheSize(TABLE_CACHE_INIT)
-{
- initialize();
-}
-
-void
-FontTableCache::initialize()
-{
- fTableCache = (FontTableCacheEntry *) xmalloc((fTableCacheSize) * sizeof(FontTableCacheEntry));
-
- if (fTableCache == NULL) {
- fTableCacheSize = 0;
- return;
- }
-}
-
-FontTableCache::~FontTableCache()
-{
- dispose();
-}
-
-void FontTableCache::dispose()
-{
- for (int i = fTableCacheCurr - 1; i >= 0; i -= 1) {
- free((void *) (fTableCache[i].table));
- }
-
- free(fTableCache);
-
- fTableCacheCurr = 0;
-}
-
-const void *FontTableCache::find(OTTag tableTag, uint32_t *tableSize) const
-{
- int lo = 0, hi = fTableCacheCurr;
- while (lo < hi) {
- int i = (lo + hi) >> 1;
- const FontTableCacheEntry *e = fTableCache + i;
- if (e->tag < tableTag)
- lo = i + 1;
- else if (e->tag > tableTag)
- hi = i;
- else {
- if (tableSize != NULL)
- *tableSize = e->size;
- return e->table;
- }
- }
-
- uint32_t length;
- const void *table = readFontTable(tableTag, length);
-
- ((FontTableCache *) this)->add(tableTag, table, length);
- if (tableSize != NULL)
- *tableSize = length;
-
- return table;
-}
-
-void FontTableCache::add(OTTag tableTag, const void *table, uint32_t length)
-{
- if (fTableCacheCurr >= fTableCacheSize) {
- int32_t newSize = fTableCacheSize + TABLE_CACHE_GROW;
-
- fTableCache = (FontTableCacheEntry *) realloc(fTableCache, newSize * sizeof(FontTableCacheEntry));
- fTableCacheSize = newSize;
- }
-
- int i;
- for (i = fTableCacheCurr; i > 0; --i) {
- if (fTableCache[i-1].tag < tableTag)
- break;
- fTableCache[i] = fTableCache[i-1];
- }
- fTableCache[i].tag = tableTag;
- fTableCache[i].table = table;
- fTableCache[i].size = length;
-
- fTableCacheCurr += 1;
-}
-
-void FontTableCache::flush()
-{
- if (fTableCacheSize > 0) {
- dispose();
- initialize();
- }
-}
diff --git a/Build/source/texk/web2c/xetexdir/FontTableCache.h b/Build/source/texk/web2c/xetexdir/FontTableCache.h
deleted file mode 100644
index a11419e2748..00000000000
--- a/Build/source/texk/web2c/xetexdir/FontTableCache.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************\
- Part of the XeTeX typesetting system
- Copyright (c) 1994-2008 by SIL International
- Copyright (c) 2009 by Jonathan Kew
-
- SIL Author(s): 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 THE COPYRIGHT HOLDERS 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 the copyright holders
-shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written
-authorization from the copyright holders.
-\****************************************************************************/
-
-/* from ICU sample code, extended by JK for XeTeX */
-
-/*
- **********************************************************************
- * Copyright (C) 2003, International Business Machines
- * Corporation and others. All Rights Reserved.
- **********************************************************************
- */
-
-#ifndef __FONTTABLECACHE_H
-
-#define __FONTTABLECACHE_H
-
-#include "XeTeX_ext.h"
-
-struct FontTableCacheEntry;
-
-class FontTableCache
-{
-public:
- FontTableCache();
-
- virtual ~FontTableCache();
-
- const void *find(OTTag tableTag, uint32_t *tableSize = NULL) const;
-
- void flush();
-
-protected:
- virtual const void *readFontTable(OTTag tableTag) const = 0;
- virtual const void *readFontTable(OTTag tableTag, uint32_t &length) const = 0;
-
-private:
-
- void initialize();
- void dispose();
-
- void add(OTTag tableTag, const void *table, uint32_t length);
-
- FontTableCacheEntry *fTableCache;
- int32_t fTableCacheCurr;
- int32_t fTableCacheSize;
-};
-
-#endif
-
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp
index 837640d1d48..fb214097de4 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.cpp
@@ -41,176 +41,381 @@ authorization from the copyright holders.
#include "XeTeXFontInst.h"
#include "XeTeXLayoutInterface.h"
-#include "XeTeXswap.h"
-
#include "XeTeX_ext.h"
-#include "sfnt.h"
-
#include <string.h>
+#include FT_GLYPH_H
+#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(float pointSize, int &status)
+XeTeXFontInst::XeTeXFontInst(const char* pathname, int index, float pointSize, int &status)
: fPointSize(pointSize)
, fUnitsPerEM(0)
, fAscent(0)
, fDescent(0)
+ , fCapHeight(0)
+ , fXHeight(0)
, fItalicAngle(0)
- , fMetricsTable(NULL)
- , fNumLongMetrics(0)
- , fNumGlyphs(0)
- , fNumGlyphsInited(false)
, fVertical(false)
, fFilename(NULL)
+ , ftFace(0)
, hbFont(NULL)
+ , fMath(NULL)
{
- // the concrete subclass is responsible to call initialize()
+ if (pathname != NULL)
+ initialize(pathname, index, status);
}
XeTeXFontInst::~XeTeXFontInst()
{
- if (fMetricsTable != NULL)
- deleteTable(fMetricsTable);
+ if (ftFace != 0) {
+ FT_Done_Face(ftFace);
+ ftFace = 0;
+ }
+ hb_font_destroy(hbFont);
}
-void XeTeXFontInst::initialize(int &status)
-{
- const HEADTable *headTable = NULL;
- const HHEATable *dirHeadTable = NULL;
- const POSTTable *postTable = NULL;
-
- // dispose of any cached metrics table
- if (fMetricsTable != NULL) {
- deleteTable(fMetricsTable);
- fMetricsTable = NULL;
- }
-
- // read unitsPerEm from 'head' table
- headTable = (const HEADTable *) readFontTable(kHEAD);
+/* HarfBuzz font functions */
- if (headTable == NULL) {
- status = 1;
- goto error_exit;
- }
+static hb_bool_t
+_get_glyph(hb_font_t*, void *font_data, hb_codepoint_t ch, hb_codepoint_t vs, hb_codepoint_t *gid, void*)
+{
+ FT_Face face = (FT_Face) font_data;
+ *gid = 0;
- fUnitsPerEM = SWAP(headTable->unitsPerEm);
- deleteTable(headTable);
+ if (vs)
+ *gid = FT_Face_GetCharVariantIndex (face, ch, vs);
- // we use the fact that 'hhea' and 'vhea' have the same format!
- dirHeadTable = (const HHEATable *) readFontTable(fVertical ? kVHEA : kHHEA);
+ if (*gid == 0)
+ *gid = FT_Get_Char_Index (face, ch);
- if (dirHeadTable == NULL) {
- status = 1;
- goto error_exit;
- }
+ return *gid != 0;
+}
- fAscent = unitsToPoints((float)(int16_t)SWAP(dirHeadTable->ascent));
- fDescent = unitsToPoints((float)(int16_t)SWAP(dirHeadTable->descent));
+static FT_Fixed
+_get_glyph_advance(FT_Face face, FT_UInt gid, bool vertical)
+{
+ FT_Error error;
+ FT_Fixed advance;
+ int flags = ftLoadFlags;
- fNumLongMetrics = SWAP(dirHeadTable->numOfLongHorMetrics);
+ if (vertical)
+ flags |= FT_LOAD_VERTICAL_LAYOUT;
- deleteTable(dirHeadTable);
+ error = FT_Get_Advance(face, gid, ftLoadFlags, &advance);
+ if (error)
+ advance = 0;
+ else
+ advance = advance >> 10;
- postTable = (const POSTTable *) readFontTable(kPOST);
+ return advance;
+}
- if (postTable != NULL) {
- fItalicAngle = Fix2D(SWAP(uint32_t(postTable->italicAngle)));
- deleteTable(postTable);
- }
+static hb_position_t
+_get_glyph_h_advance(hb_font_t*, void *font_data, hb_codepoint_t gid, void*)
+{
+ return _get_glyph_advance((FT_Face) font_data, gid, false);
+}
- return;
+static hb_position_t
+_get_glyph_v_advance(hb_font_t*, void *font_data, hb_codepoint_t gid, void*)
+{
+ return _get_glyph_advance((FT_Face) font_data, gid, true);
+}
-error_exit:
- return;
+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*)
+{
+ return true;
}
-void XeTeXFontInst::setLayoutDirVertical(bool vertical)
+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*)
{
- fVertical = vertical;
- int status = 0;
- initialize(status);
+ FT_Face face = (FT_Face) font_data;
+ FT_Error error;
+
+ error = FT_Load_Glyph (face, gid, ftLoadFlags);
+ if (!error) {
+ *x = face->glyph->metrics.horiBearingX - face->glyph->metrics.vertBearingX;
+ *y = face->glyph->metrics.horiBearingY - (-face->glyph->metrics.vertBearingY);
+ }
+
+ return !error;
}
-void XeTeXFontInst::deleteTable(const void *table) const
+static hb_position_t
+_get_glyph_h_kerning(hb_font_t*, void *font_data, hb_codepoint_t gid1, hb_codepoint_t gid2, void*)
{
- free((void *) table);
+ FT_Face face = (FT_Face) font_data;
+ FT_Error error;
+ FT_Vector kerning;
+ hb_position_t ret;
+
+ error = FT_Get_Kerning (face, gid1, gid2, FT_KERNING_UNFITTED, &kerning);
+ if (error)
+ ret = 0;
+ else
+ ret = kerning.x;
}
-const void *XeTeXFontInst::getFontTable(OTTag tableTag) const
+static hb_position_t
+_get_glyph_v_kerning(hb_font_t*, void *font_data, hb_codepoint_t gid1, hb_codepoint_t gid2, void*)
{
- return FontTableCache::find(tableTag);
+ /* FreeType does not support vertical kerning */
+ return 0;
}
-const void *XeTeXFontInst::getFontTable(OTTag tableTag, uint32_t *length) const
+static hb_bool_t
+_get_glyph_extents(hb_font_t*, void *font_data, hb_codepoint_t gid, hb_glyph_extents_t *extents, void*)
{
- return FontTableCache::find(tableTag, length);
+ FT_Face face = (FT_Face) font_data;
+ FT_Error error;
+
+ error = FT_Load_Glyph (face, gid, ftLoadFlags);
+ if (!error) {
+ extents->x_bearing = face->glyph->metrics.horiBearingX;
+ extents->y_bearing = face->glyph->metrics.horiBearingY;
+ extents->width = face->glyph->metrics.width;
+ extents->height = -face->glyph->metrics.height;
+ }
+
+ return !error;
}
-const void *XeTeXFontInst::readFontTable(OTTag tableTag) const
+static hb_bool_t
+_get_glyph_contour_point(hb_font_t*, void *font_data, hb_codepoint_t gid, unsigned int point_index, hb_position_t *x, hb_position_t *y, void*)
{
- uint32_t len;
+ FT_Face face = (FT_Face) font_data;
+ FT_Error error;
+ bool ret = false;
+
+ error = FT_Load_Glyph (face, gid, ftLoadFlags);
+ if (!error) {
+ if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
+ if (point_index < (unsigned int) face->glyph->outline.n_points) {
+ *x = face->glyph->outline.points[point_index].x;
+ *y = face->glyph->outline.points[point_index].y;
+ ret = true;
+ }
+ }
+ }
- return readTable(tableTag, &len);
+ return ret;
}
-const void *XeTeXFontInst::readFontTable(OTTag tableTag, uint32_t& len) const
+static hb_font_funcs_t *
+_get_font_funcs(void)
{
- return readTable(tableTag, &len);
+ static hb_font_funcs_t* funcs = hb_font_funcs_create();
+
+ hb_font_funcs_set_glyph_func (funcs, _get_glyph, NULL, NULL);
+ hb_font_funcs_set_glyph_h_advance_func (funcs, _get_glyph_h_advance, NULL, NULL);
+ hb_font_funcs_set_glyph_v_advance_func (funcs, _get_glyph_v_advance, NULL, NULL);
+ hb_font_funcs_set_glyph_h_origin_func (funcs, _get_glyph_h_origin, NULL, NULL);
+ hb_font_funcs_set_glyph_v_origin_func (funcs, _get_glyph_v_origin, NULL, NULL);
+ hb_font_funcs_set_glyph_h_kerning_func (funcs, _get_glyph_h_kerning, NULL, NULL);
+ 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);
+
+ return funcs;
}
-uint16_t XeTeXFontInst::getNumGlyphs() const
+static hb_blob_t *
+_get_table(hb_face_t *, hb_tag_t tag, void *user_data)
{
- if (!fNumGlyphsInited) {
- const MAXPTable *maxpTable = (MAXPTable *) readFontTable(kMAXP);
-
- if (maxpTable != NULL) {
- XeTeXFontInst *realThis = (XeTeXFontInst *) this;
- realThis->fNumGlyphs = SWAP(maxpTable->numGlyphs);
- deleteTable(maxpTable);
- realThis->fNumGlyphsInited = true;
+ FT_Face face = (FT_Face) user_data;
+ FT_ULong length = 0;
+ FT_Byte *table;
+ FT_Error error;
+ hb_blob_t* blob = NULL;
+
+ error = FT_Load_Sfnt_Table(face, tag, 0, NULL, &length);
+ if (!error) {
+ table = (FT_Byte *) xmalloc(length * sizeof(char));
+ if (table != NULL) {
+ error = FT_Load_Sfnt_Table(face, tag, 0, (FT_Byte*)table, &length);
+ if (!error) {
+ blob = hb_blob_create((const char*) table, length, HB_MEMORY_MODE_WRITABLE, table, free);
+ } else {
+ free(table);
+ }
}
- }
+ }
- return fNumGlyphs;
+ return blob;
}
-void XeTeXFontInst::getGlyphAdvance(GlyphID glyph, realpoint &advance) const
+void
+XeTeXFontInst::initialize(const char* pathname, int index, int &status)
{
- if (fMetricsTable == NULL) {
- XeTeXFontInst *realThis = (XeTeXFontInst *) this;
- // we use the fact that 'hmtx' and 'vmtx' have the same format
- realThis->fMetricsTable = (const HMTXTable *) readFontTable(fVertical ? kVMTX : kHMTX);
- }
-
- uint16_t index = glyph;
+ TT_Postscript *postTable;
+ TT_OS2* os2Table;
+ FT_Error error;
+ hb_face_t *hbFace;
+
+ if (!gFreeTypeLibrary) {
+ error = FT_Init_FreeType(&gFreeTypeLibrary);
+ if (error) {
+ fprintf(stderr, "FreeType initialization failed! (%d)\n", error);
+ exit(1);
+ }
+ }
- if (glyph >= getNumGlyphs() || fMetricsTable == NULL) {
- advance.x = advance.y = 0;
+ error = FT_New_Face(gFreeTypeLibrary, (char*)pathname, index, &ftFace);
+ if (error) {
+ status = 1;
return;
}
- if (glyph >= fNumLongMetrics) {
- index = fNumLongMetrics - 1;
- }
+ if (!FT_IS_SCALABLE(ftFace)) {
+ status = 1;
+ 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(ftFace)) {
+ 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(ftFace, afm); // ignore error code; AFM might not exist
+ delete[] afm;
+ }
+
+ FT_Set_Char_Size(ftFace, fPointSize * 64, 0, 0, 0);
+
+ 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);
+ fUnitsPerEM = ftFace->units_per_EM;
+ fAscent = unitsToPoints(ftFace->ascender);
+ fDescent = unitsToPoints(ftFace->descender);
+
+ postTable = (TT_Postscript *) getFontTable(ft_sfnt_post);
+ if (postTable != NULL) {
+ fItalicAngle = Fix2D(postTable->italicAngle);
+ }
+
+ os2Table = (TT_OS2*) getFontTable(ft_sfnt_os2);
+ if (os2Table) {
+ fCapHeight = unitsToPoints(os2Table->sCapHeight);
+ fXHeight = unitsToPoints(os2Table->sxHeight);
+ }
+
+ hbFace = hb_face_create_for_tables(_get_table, ftFace, NULL);
+ hb_face_set_index(hbFace, index);
+ hb_face_set_upem(hbFace, fUnitsPerEM);
+ hbFont = hb_font_create(hbFace);
+ 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_ppem(hbFont, ftFace->size->metrics.x_ppem, ftFace->size->metrics.y_ppem);
+
+ return;
+}
- advance.x = unitsToPoints(SWAP(fMetricsTable->hMetrics[index].advanceWidth));
- advance.y = 0;
+void
+XeTeXFontInst::setLayoutDirVertical(bool vertical)
+{
+ fVertical = vertical;
+}
+
+const void *
+XeTeXFontInst::getFontTable(OTTag tag) const
+{
+ FT_ULong tmpLength = 0;
+ FT_Error error = FT_Load_Sfnt_Table(ftFace, tag, 0, NULL, &tmpLength);
+ if (error)
+ return NULL;
+
+ void* table = xmalloc(tmpLength * sizeof(char));
+ if (table != NULL) {
+ error = FT_Load_Sfnt_Table(ftFace, tag, 0, (FT_Byte*)table, &tmpLength);
+ if (error) {
+ free((void *) table);
+ return NULL;
+ }
+ }
+
+ return table;
+}
+
+const char *
+XeTeXFontInst::getMathTable()
+{
+ if (fMath == NULL)
+ fMath = (const char*) getFontTable(MATH_TAG);
+ return fMath;
+}
+
+const void *
+XeTeXFontInst::getFontTable(FT_Sfnt_Tag tag) const
+{
+ return FT_Get_Sfnt_Table(ftFace, tag);
+}
+
+void
+XeTeXFontInst::getGlyphBounds(GlyphID gid, GlyphBBox* bbox)
+{
+ bbox->xMin = bbox->yMin = bbox->xMax = bbox->yMax = 0.0;
+
+ FT_Error error = FT_Load_Glyph(ftFace, gid, FT_LOAD_NO_SCALE);
+ if (error)
+ return;
+
+ FT_Glyph glyph;
+ error = FT_Get_Glyph(ftFace->glyph, &glyph);
+ if (error == 0) {
+ FT_BBox ft_bbox;
+ FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_UNSCALED, &ft_bbox);
+ bbox->xMin = unitsToPoints(ft_bbox.xMin);
+ bbox->yMin = unitsToPoints(ft_bbox.yMin);
+ bbox->xMax = unitsToPoints(ft_bbox.xMax);
+ bbox->yMax = unitsToPoints(ft_bbox.yMax);
+ FT_Done_Glyph(glyph);
+ }
+}
+
+GlyphID
+XeTeXFontInst::mapCharToGlyph(UChar32 ch) const
+{
+ return FT_Get_Char_Index(ftFace, ch);
+}
+
+uint16_t
+XeTeXFontInst::getNumGlyphs() const
+{
+ return ftFace->num_glyphs;
}
float
XeTeXFontInst::getGlyphWidth(GlyphID gid)
{
- realpoint advance;
- getGlyphAdvance(gid, advance);
- return advance.x;
+ return _get_glyph_advance(ftFace, gid, false) / 64.0;
}
void
XeTeXFontInst::getGlyphHeightDepth(GlyphID gid, float* ht, float* dp)
{
- GlyphBBox bbox;
+ GlyphBBox bbox;
getGlyphBounds(gid, &bbox);
-
+
if (ht)
*ht = bbox.yMax;
if (dp)
@@ -220,54 +425,70 @@ XeTeXFontInst::getGlyphHeightDepth(GlyphID gid, float* ht, float* dp)
void
XeTeXFontInst::getGlyphSidebearings(GlyphID gid, float* lsb, float* rsb)
{
- realpoint adv;
- getGlyphAdvance(gid, adv);
+ float width = getGlyphWidth(gid);
- GlyphBBox bbox;
+ GlyphBBox bbox;
getGlyphBounds(gid, &bbox);
if (lsb)
*lsb = bbox.xMin;
if (rsb)
- *rsb = adv.x - bbox.xMax;
+ *rsb = width - bbox.xMax;
}
float
XeTeXFontInst::getGlyphItalCorr(GlyphID gid)
{
- float rval = 0.0;
+ float rval = 0.0;
- realpoint adv;
- getGlyphAdvance(gid, adv);
+ float width = getGlyphWidth(gid);
- GlyphBBox bbox;
+ GlyphBBox bbox;
getGlyphBounds(gid, &bbox);
- if (bbox.xMax > adv.x)
- rval = bbox.xMax - adv.x;
+ if (bbox.xMax > width)
+ rval = bbox.xMax - width;
return rval;
}
GlyphID
XeTeXFontInst::mapGlyphToIndex(const char* glyphName) const
- /* default implementation, may be overridden (e.g. by Freetype-based XeTeXFontInst_ */
{
- uint32_t len;
- const char *p = (const char*)readFontTable(kPOST, len);
- if (p != NULL)
- return findGlyphInPostTable(p, len, glyphName);
- else
- return 0;
+ return FT_Get_Name_Index(ftFace, const_cast<char*>(glyphName));
}
const char*
XeTeXFontInst::getGlyphName(GlyphID gid, int& nameLen)
{
- uint32_t len;
- const char *p = (const char*)readFontTable(kPOST, len);
- if (p != NULL)
- return getGlyphNamePtr(p, len, gid, &nameLen);
- else
+ if (FT_HAS_GLYPH_NAMES(ftFace)) {
+ static char buffer[256];
+ FT_Get_Glyph_Name(ftFace, gid, buffer, 256);
+ nameLen = strlen(buffer);
+ return &buffer[0];
+ }
+ else {
+ nameLen = 0;
return NULL;
+ }
+}
+
+UChar32
+XeTeXFontInst::getFirstCharCode()
+{
+ FT_UInt gindex;
+ return FT_Get_First_Char(ftFace, &gindex);
+}
+
+UChar32
+XeTeXFontInst::getLastCharCode()
+{
+ FT_UInt gindex;
+ UChar32 ch = FT_Get_First_Char(ftFace, &gindex);
+ UChar32 prev = ch;
+ while (gindex != 0) {
+ prev = ch;
+ ch = FT_Get_Next_Char(ftFace, ch, &gindex);
+ }
+ return prev;
}
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h
index 811c8d53bb2..be2759ffd49 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst.h
@@ -44,108 +44,76 @@ authorization from the copyright holders.
#define __XeTeXFontInst_H
#include <stdio.h>
-
-#include "FontTableCache.h"
-
-#include "sfnt.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_TRUETYPE_TABLES_H
#include "XeTeXFontMgr.h"
#include "XeTeX_ext.h"
+#define MATH_TAG HB_TAG('M','A','T','H')
+
// create specific subclasses for each supported platform
-class XeTeXFontInst : protected FontTableCache
+class XeTeXFontInst
{
-friend class XeTeXGrFont;
-
protected:
- float fPointSize;
-
- int32_t fUnitsPerEM;
- float fAscent;
- float fDescent;
-
- float fDeviceScaleX;
- float fDeviceScaleY;
-
+ unsigned short fUnitsPerEM;
+ float fPointSize;
+ float fAscent;
+ float fDescent;
+ float fCapHeight;
+ float fXHeight;
float fItalicAngle;
- const HMTXTable *fMetricsTable;
- uint16_t fNumLongMetrics;
- uint16_t fNumGlyphs;
- bool fNumGlyphsInited;
-
bool fVertical; // false = horizontal, true = vertical
char *fFilename; // actually holds [filename:index], as used in xetex
- virtual const void *readTable(OTTag tag, uint32_t *length) const = 0;
- void deleteTable(const void *table) const;
- void getMetrics();
-
- const void *readFontTable(OTTag tableTag) const;
- const void *readFontTable(OTTag tableTag, uint32_t& len) const;
+ FT_Face ftFace;
+ hb_font_t* hbFont;
+ const char *fMath;
public:
- XeTeXFontInst(float pointSize, int &status);
-
- virtual ~XeTeXFontInst();
+ XeTeXFontInst(float pointSize, int &status);
+ XeTeXFontInst(const char* filename, int index, float pointSize, int &status);
- virtual void initialize(int &status);
+ virtual ~XeTeXFontInst();
- virtual const void *getFontTable(OTTag tableTag) const;
- virtual const void *getFontTable(OTTag tableTag, uint32_t* length) const;
+ void initialize(const char* pathname, int index, int &status);
- virtual const char *getFilename() const
- {
- return fFilename;
- }
-
- virtual void setLayoutDirVertical(bool vertical);
-
- virtual bool getLayoutDirVertical() const
- {
- return fVertical;
- };
-
- virtual int32_t getUnitsPerEM() const
- {
- return fUnitsPerEM;
- };
+ const void *getFontTable(OTTag tableTag) const;
+ const void *getFontTable(FT_Sfnt_Tag tableTag) const;
+ const char *getMathTable();
- virtual float getAscent() const
- {
- return fAscent;
- }
+ const char *getFilename() const { return fFilename; }
+ hb_font_t *getHbFont() const { return hbFont; }
+ void setLayoutDirVertical(bool vertical);
+ bool getLayoutDirVertical() const { return fVertical; };
- virtual float getDescent() const
- {
- return fDescent;
- }
+ float getPointSize() const { return fPointSize; };
+ float getAscent() const { return fAscent; }
+ float getDescent() const { return fDescent; }
+ float getCapHeight() const { return fCapHeight; }
+ float getXHeight() const { return fXHeight; }
+ float getItalicAngle() const { return fItalicAngle; }
- virtual GlyphID mapCharToGlyph(UChar32 ch) const = 0; /* must be implemented by subclass */
- virtual GlyphID mapGlyphToIndex(const char* glyphName) const;
+ GlyphID mapCharToGlyph(UChar32 ch) const;
+ GlyphID mapGlyphToIndex(const char* glyphName) const;
- virtual uint16_t getNumGlyphs() const;
+ uint16_t getNumGlyphs() const;
- virtual void getGlyphAdvance(GlyphID glyph, realpoint &advance) const;
-
- virtual void getGlyphBounds(GlyphID glyph, GlyphBBox *bbox) = 0; /* must be implemented by subclass */
+ void getGlyphBounds(GlyphID glyph, GlyphBBox* bbox);
float getGlyphWidth(GlyphID glyph);
void getGlyphHeightDepth(GlyphID glyph, float *ht, float* dp);
void getGlyphSidebearings(GlyphID glyph, float* lsb, float* rsb);
float getGlyphItalCorr(GlyphID glyph);
- virtual const char* getGlyphName(GlyphID gid, int& nameLen);
+ const char* getGlyphName(GlyphID gid, int& nameLen);
- virtual UChar32 getFirstCharCode() = 0; /* must be implemented by subclass */
- virtual UChar32 getLastCharCode() = 0; /* must be implemented by subclass */
-
- float getPointSize() const
- {
- return fPointSize;
- };
+ UChar32 getFirstCharCode();
+ UChar32 getLastCharCode();
float unitsToPoints(float units) const
{
@@ -156,13 +124,6 @@ public:
{
return (points * (float) fUnitsPerEM) / fPointSize;
}
-
- float getItalicAngle() const
- {
- return fItalicAngle;
- }
-
- hb_font_t* hbFont;
};
#endif
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp
deleted file mode 100644
index e7862e7d84f..00000000000
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/****************************************************************************\
- Part of the XeTeX typesetting system
- Copyright (c) 1994-2008 by SIL International
- Copyright (c) 2009 by Jonathan Kew
-
- SIL Author(s): 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 THE COPYRIGHT HOLDERS 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 the copyright holders
-shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written
-authorization from the copyright holders.
-\****************************************************************************/
-
-/*
- * 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 <string.h>
-
-FT_Library gFreeTypeLibrary = 0;
-
-XeTeXFontInst_FT2::XeTeXFontInst_FT2(const char* pathname, int index, float pointSize, int &status)
- : XeTeXFontInst(pointSize, status)
- , face(0)
-{
- if (status != 0) {
- 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 = 1;
- 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;
- }
-
- initialize(status);
-
- if (status != 0)
- return;
-
- FT_Set_Pixel_Sizes(face, pointSize, 0);
- hbFont = hb_ft_font_create(face, NULL);
-
- 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;
- }
- hb_font_destroy(hbFont);
-}
-
-void XeTeXFontInst_FT2::initialize(int &status)
-{
- if (face == 0) {
- status = 1;
- return;
- }
-
- XeTeXFontInst::initialize(status);
-
- if (status != 0) {
- /* font can ONLY be used via FreeType APIs, not direct table access */
- status = 0;
-
- /* fill in fields that XeTeXFontInst::initialize failed to get for us */
- fUnitsPerEM = face->units_per_EM;
- fAscent = unitsToPoints(face->ascender);
- fDescent = unitsToPoints(face->descender);
- 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(OTTag tag, uint32_t *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 = xmalloc(tmpLength * sizeof(char));
- if (table != NULL) {
- err = FT_Load_Sfnt_Table(face, tag, 0, (FT_Byte*)table, &tmpLength);
- if (err != 0) {
- free((void *) table);
- return NULL;
- }
- *length = tmpLength;
- }
-
- return table;
-}
-
-void
-XeTeXFontInst_FT2::getGlyphBounds(GlyphID 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 = unitsToPoints(ft_bbox.xMin);
- bbox->yMin = unitsToPoints(ft_bbox.yMin);
- bbox->xMax = unitsToPoints(ft_bbox.xMax);
- bbox->yMax = unitsToPoints(ft_bbox.yMax);
- FT_Done_Glyph(glyph);
- }
-}
-
-GlyphID
-XeTeXFontInst_FT2::mapCharToGlyph(UChar32 ch) const
-{
- return FT_Get_Char_Index(face, ch);
-}
-
-uint16_t
-XeTeXFontInst_FT2::getNumGlyphs() const
-{
- return face->num_glyphs;
-}
-
-void
-XeTeXFontInst_FT2::getGlyphAdvance(GlyphID glyph, realpoint &advance) const
-{
- FT_Error err = FT_Load_Glyph(face, glyph, FT_LOAD_NO_SCALE);
- if (err != 0) {
- advance.x = advance.y = 0;
- }
- else {
- advance.x = fVertical ? 0 : unitsToPoints(face->glyph->metrics.horiAdvance);
- advance.y = fVertical ? unitsToPoints(face->glyph->metrics.vertAdvance) : 0;
- }
-}
-
-GlyphID
-XeTeXFontInst_FT2::mapGlyphToIndex(const char* glyphName) const
-{
- GlyphID rval = FT_Get_Name_Index(face, const_cast<char*>(glyphName));
- if (rval == 0)
- rval = XeTeXFontInst::mapGlyphToIndex(glyphName);
- return rval;
-}
-
-const char*
-XeTeXFontInst_FT2::getGlyphName(GlyphID gid, int& nameLen)
-{
- if (FT_HAS_GLYPH_NAMES(face)) {
- static char buffer[256];
- FT_Get_Glyph_Name(face, gid, buffer, 256);
- nameLen = strlen(buffer);
- return &buffer[0];
- }
- else {
- nameLen = 0;
- return NULL;
- }
-}
-
-UChar32
-XeTeXFontInst_FT2::getFirstCharCode()
-{
- FT_UInt gindex;
- return FT_Get_First_Char(face, &gindex);
-}
-
-UChar32
-XeTeXFontInst_FT2::getLastCharCode()
-{
- FT_UInt gindex;
- UChar32 ch = FT_Get_First_Char(face, &gindex);
- UChar32 prev = ch;
- while (gindex != 0) {
- prev = ch;
- ch = FT_Get_Next_Char(face, ch, &gindex);
- }
- return prev;
-}
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h
deleted file mode 100644
index 570b6e54670..00000000000
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_FT2.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************\
- Part of the XeTeX typesetting system
- Copyright (c) 1994-2008 by SIL International
- Copyright (c) 2009 by Jonathan Kew
-
- SIL Author(s): 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 THE COPYRIGHT HOLDERS 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 the copyright holders
-shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written
-authorization from the copyright holders.
-\****************************************************************************/
-
-/*
- * 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 <ft2build.h>
-#include FT_FREETYPE_H
-
-class XeTeXFontInst_FT2 : public XeTeXFontInst
-{
-protected:
-
- const void * readTable(OTTag tag, uint32_t *length) const;
-
- FT_Face face;
-
-public:
- XeTeXFontInst_FT2(const char* filename, int index, float pointSize, int &status);
-
- virtual ~XeTeXFontInst_FT2();
-
- virtual void initialize(int &status);
-
- virtual void getGlyphBounds(GlyphID gid, GlyphBBox* bbox);
-
- // overrides of XeTeXFontInst methods, in case it's not an sfnt
- virtual uint16_t getNumGlyphs() const;
- virtual void getGlyphAdvance(GlyphID glyph, realpoint &advance) const;
- virtual GlyphID mapCharToGlyph(UChar32 ch) const;
- virtual GlyphID mapGlyphToIndex(const char* glyphName) const;
- virtual const char* getGlyphName(GlyphID gid, int& nameLen);
- virtual UChar32 getFirstCharCode();
- virtual UChar32 getLastCharCode();
-};
-
-#endif
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp
index 741ab5be0f3..f0e0fa47543 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.cpp
@@ -44,16 +44,10 @@ authorization from the copyright holders.
#include "XeTeX_ext.h"
XeTeXFontInst_Mac::XeTeXFontInst_Mac(CTFontDescriptorRef descriptor, float pointSize, int &status)
- : XeTeXFontInst(pointSize, status)
+ : XeTeXFontInst(NULL, 0, pointSize, status)
, fDescriptor(descriptor)
, fFontRef(0)
- , fFirstCharCode(-1)
- , fLastCharCode(-1)
{
- if (status != 0) {
- return;
- }
-
initialize(status);
}
@@ -65,62 +59,8 @@ XeTeXFontInst_Mac::~XeTeXFontInst_Mac()
CFRelease(fFontRef);
}
-static hb_bool_t _get_glyph(hb_font_t*, void* font, hb_codepoint_t ch, hb_codepoint_t vs, hb_codepoint_t* glyph, void*)
-{
- *glyph = mapCharToGlyphFromCTFont((CTFontRef) font, ch, vs);
- return !!glyph;
-}
-
-static hb_position_t _get_glyph_h_advance(hb_font_t*, void* font, hb_codepoint_t glyph, void*)
-{
- CGGlyph cgGlyph = glyph;
- float advance = CTFontGetAdvancesForGlyphs((CTFontRef) font, kCTFontHorizontalOrientation, &cgGlyph, 0, 1);
- return advance * 64;
-}
-
-static hb_position_t _get_glyph_v_advance(hb_font_t*, void* font, hb_codepoint_t glyph, void*)
-{
- CGGlyph cgGlyph = glyph;
- float advance = CTFontGetAdvancesForGlyphs((CTFontRef) font, kCTFontVerticalOrientation, &cgGlyph, 0, 1);
- return advance * 64;
-}
-
-static hb_bool_t _get_glyph_extents(hb_font_t*, void* font, hb_codepoint_t glyph, hb_glyph_extents_t* extents, void*)
-{
- GlyphBBox bbox;
- getGlyphBBoxFromCTFont((CTFontRef) font, glyph, &bbox);
- extents->x_bearing = bbox.xMin;
- extents->y_bearing = bbox.yMax;
- extents->width = bbox.xMax - bbox.xMin;
- extents->height = bbox.yMax - bbox.yMin;
-
- return true;
-}
-
-static hb_font_funcs_t* _get_font_funcs()
-{
- static hb_font_funcs_t* _font_funcs = 0;
- _font_funcs = hb_font_funcs_create();
- hb_font_funcs_set_glyph_func(_font_funcs, _get_glyph, 0, 0);
- hb_font_funcs_set_glyph_h_advance_func(_font_funcs, _get_glyph_h_advance, 0, 0);
- hb_font_funcs_set_glyph_v_advance_func(_font_funcs, _get_glyph_v_advance, 0, 0);
- hb_font_funcs_set_glyph_extents_func(_font_funcs, _get_glyph_extents, 0, 0);
- hb_font_funcs_make_immutable(_font_funcs);
-
- return _font_funcs;
-}
-
-static hb_blob_t* _get_font_table(hb_face_t*, hb_tag_t tag, void* userData)
-{
- XeTeXFontInst* font = (XeTeXFontInst*) userData;
- uint32_t length;
- const void *table = font->getFontTable((OTTag) tag, &length);
- if (!table || !length)
- return 0;
- return hb_blob_create((const char*) table, length, HB_MEMORY_MODE_READONLY, NULL, NULL);
-}
-
-void XeTeXFontInst_Mac::initialize(int &status)
+void
+XeTeXFontInst_Mac::initialize(int &status)
{
if (fDescriptor == 0) {
status = 1;
@@ -142,92 +82,14 @@ void XeTeXFontInst_Mac::initialize(int &status)
CFRelease(attributes);
fFontRef = CTFontCreateWithFontDescriptor(fDescriptor, fPointSize * 72.0 / 72.27, NULL);
if (fFontRef) {
- fFilename = getFileNameFromCTFont(fFontRef);
+ char *pathname;
+ int index;
+ pathname = getFileNameFromCTFont(fFontRef, &index);
- /* for HarfBuzz */
- hb_face_t* lFace = hb_face_create_for_tables(_get_font_table, this, 0);
- hb_face_set_upem (lFace, fUnitsPerEM);
- hbFont = hb_font_create(lFace);
- hb_font_set_funcs(hbFont, _get_font_funcs(), (void*) fFontRef, 0);
- hb_font_set_scale(hbFont, fPointSize, fPointSize);
- hb_font_set_ppem(hbFont, fPointSize, fPointSize);
+ XeTeXFontInst::initialize(pathname, index, status);
} else {
status = 1;
CFRelease(fDescriptor);
fDescriptor = 0;
}
-
- XeTeXFontInst::initialize(status);
-}
-
-const void *XeTeXFontInst_Mac::readTable(OTTag tag, uint32_t *length) const
-{
- if (!fFontRef) {
- *length = 0;
- return NULL;
- }
- CFDataRef tableData = CTFontCopyTable(fFontRef, tag, 0);
- if (!tableData) {
- *length = 0;
- return NULL;
- }
- *length = CFDataGetLength(tableData);
- UInt8* table = (UInt8*) xmalloc(*length * sizeof(UInt8));
- if (table != NULL)
- CFDataGetBytes(tableData, CFRangeMake(0, *length), table);
-
- return table;
-}
-
-void XeTeXFontInst_Mac::getGlyphBounds(GlyphID gid, GlyphBBox* bbox)
-{
- getGlyphBBoxFromCTFont(fFontRef, gid, bbox);
-}
-
-GlyphID
-XeTeXFontInst_Mac::mapCharToGlyph(UChar32 ch) const
-{
- return mapCharToGlyphFromCTFont(fFontRef, ch, 0);
-}
-
-GlyphID
-XeTeXFontInst_Mac::mapGlyphToIndex(const char* glyphName) const
-{
- GlyphID rval = XeTeXFontInst::mapGlyphToIndex(glyphName);
- if (rval)
- return rval;
- return GetGlyphIDFromCTFont(fFontRef, glyphName);
-}
-
-const char*
-XeTeXFontInst_Mac::getGlyphName(GlyphID gid, int& nameLen)
-{
- const char* rval = XeTeXFontInst::getGlyphName(gid, nameLen);
- if (rval)
- return rval;
- return GetGlyphNameFromCTFont(fFontRef, gid, &nameLen);
-}
-
-UChar32
-XeTeXFontInst_Mac::getFirstCharCode()
-{
- if (fFirstCharCode == -1) {
- int ch = 0;
- while (mapCharToGlyph(ch) == 0 && ch < 0x10ffff)
- ++ch;
- fFirstCharCode = ch;
- }
- return fFirstCharCode;
-}
-
-UChar32
-XeTeXFontInst_Mac::getLastCharCode()
-{
- if (fLastCharCode == -1) {
- int ch = 0x10ffff;
- while (mapCharToGlyph(ch) == 0 && ch > 0)
- --ch;
- fLastCharCode = ch;
- }
- return fLastCharCode;
}
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h
index f0c41ac4ac5..293613a517b 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontInst_Mac.h
@@ -49,30 +49,15 @@ authorization from the copyright holders.
class XeTeXFontInst_Mac : public XeTeXFontInst
{
protected:
- const void *readTable(OTTag tag, uint32_t *length) const;
-
CTFontDescriptorRef fDescriptor;
- CTFontRef fFontRef;
-
- int fFirstCharCode;
- int fLastCharCode;
+ CTFontRef fFontRef;
public:
- XeTeXFontInst_Mac(CTFontDescriptorRef descriptor, float pointSize, int &status);
+ XeTeXFontInst_Mac(CTFontDescriptorRef descriptor, float pointSize, int &status);
- virtual ~XeTeXFontInst_Mac();
+ virtual ~XeTeXFontInst_Mac();
virtual void initialize(int &status);
-
- virtual void getGlyphBounds(GlyphID gid, GlyphBBox* bbox);
-
- virtual GlyphID mapCharToGlyph(UChar32 ch) const;
- virtual GlyphID mapGlyphToIndex(const char* glyphName) const;
-
- virtual const char* getGlyphName(GlyphID gid, int& nameLen);
-
- virtual UChar32 getFirstCharCode();
- virtual UChar32 getLastCharCode();
};
#endif
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
index f07de6aedc3..48e03015407 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
@@ -36,8 +36,6 @@ authorization from the copyright holders.
#include "XeTeXFontMgr_FC.h"
#endif
#include "XeTeXFontInst.h"
-#include "XeTeXswap.h"
-#include "sfnt.h"
extern "C" {
extern Fixed loadedfontdesignsize;
@@ -219,12 +217,20 @@ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
varString.append("AAT");
goto skip_to_slash;
}
- if ((strncmp(cp, "OTF", 3) == 0) || (strncmp(cp, "ICU", 3) == 0)) {
+ if (strncmp(cp, "ICU", 3) == 0) { // for backword compatability
sReqEngine = 'O';
cp += 3;
if (varString.length() > 0 && *(varString.end() - 1) != '/')
varString.append("/");
- varString.append("OTF");
+ varString.append("OT");
+ goto skip_to_slash;
+ }
+ if (strncmp(cp, "OT", 2) == 0) {
+ sReqEngine = 'O';
+ cp += 2;
+ if (varString.length() > 0 && *(varString.end() - 1) != '/')
+ varString.append("/");
+ varString.append("OT");
goto skip_to_slash;
}
if (strncmp(cp, "GR", 2) == 0) {
@@ -463,7 +469,7 @@ XeTeXFontMgr::bestMatchFromFamily(const Family* fam, int wt, int wd, int slant)
const XeTeXFontMgr::OpSizeRec*
XeTeXFontMgr::getOpSize(XeTeXFont font)
{
- hb_font_t* hbFont = ((XeTeXFontInst*)font)->hbFont;
+ hb_font_t* hbFont = ((XeTeXFontInst*)font)->getHbFont();
if (hbFont != NULL) {
hb_face_t* face = hb_font_get_face(hbFont);
OpSizeRec* pSizeRec = (OpSizeRec*) xmalloc(sizeof(OpSizeRec));
@@ -515,28 +521,28 @@ XeTeXFontMgr::getOpSizeRecAndStyleFlags(Font* theFont)
}
done_size:
- const OS2TableHeader* os2Table = (const OS2TableHeader*)getFontTablePtr(font, kOS_2);
+ const TT_OS2* os2Table = (TT_OS2*)getFontTable(font, ft_sfnt_os2);
if (os2Table != NULL) {
- theFont->weight = SWAP(os2Table->usWeightClass);
- theFont->width = SWAP(os2Table->usWidthClass);
- uint16_t sel = SWAP(os2Table->fsSelection);
+ theFont->weight = os2Table->usWeightClass;
+ theFont->width = os2Table->usWidthClass;
+ uint16_t sel = os2Table->fsSelection;
theFont->isReg = (sel & (1 << 6)) != 0;
theFont->isBold = (sel & (1 << 5)) != 0;
theFont->isItalic = (sel & (1 << 0)) != 0;
}
- const HEADTable* headTable = (const HEADTable*)getFontTablePtr(font, kHEAD);
+ const TT_Header* headTable = (TT_Header*)getFontTable(font, ft_sfnt_head);
if (headTable != NULL) {
- uint16_t ms = SWAP(headTable->macStyle);
+ uint16_t ms = headTable->Mac_Style;
if ((ms & (1 << 0)) != 0)
theFont->isBold = true;
if ((ms & (1 << 1)) != 0)
theFont->isItalic = true;
}
- const POSTTable* postTable = (const POSTTable*)getFontTablePtr(font, kPOST);
+ const TT_Postscript* postTable = (const TT_Postscript*)getFontTable(font, ft_sfnt_post);
if (postTable != NULL) {
- theFont->slant = (int)(1000 * (tan(Fix2D(-SWAP(uint32_t(postTable->italicAngle))) * M_PI / 180.0)));
+ theFont->slant = (int)(1000 * (tan(Fix2D(-postTable->italicAngle) * M_PI / 180.0)));
}
deleteFont(font);
}
@@ -609,8 +615,7 @@ XeTeXFontMgr::addToMaps(PlatformFontRef platformFont, const NameCollection* name
family->maxWidth = thisFont->width;
family->minSlant = thisFont->slant;
family->maxSlant = thisFont->slant;
- }
- else {
+ } else {
family = iFam->second;
if (thisFont->weight < family->minWeight)
family->minWeight = thisFont->weight;
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
index 941e30d4d4e..6eb57eddcf3 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
@@ -65,7 +65,7 @@ public:
PlatformFontRef findFont(const char* name, char* variant, double ptSize);
// 1st arg is name as specified by user (C string, UTF-8)
- // 2nd is /B/I/AAT/OTF/ICU[/GR]/S=## qualifiers
+ // 2nd is /B/I/AAT/OT/ICU[/GR]/S=## qualifiers
// 1. try name given as "full name"
// 2. if there's a hyphen, split and try "family-style"
// 3. try as PostScript name
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp
index f487d509d50..16a471e35e8 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp
@@ -55,9 +55,9 @@ 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;
+ char* buffer1 = NULL;
+ char* buffer2 = NULL;
+ int bufSize = -1;
if (2 * (len + 1) > bufSize) {
if (buffer1 != NULL) {
@@ -156,8 +156,7 @@ XeTeXFontMgr_FC::readNames(FcPattern* pat)
names->familyNames = familyNames;
if (subFamilyNames.size() > 0)
names->styleNames = subFamilyNames;
- }
- else {
+ } else {
index = 0;
while (FcPatternGetString(pat, FC_FULLNAME, index++, (FcChar8**)&name) == FcResultMatch)
appendToList(&names->fullNames, name);
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Mac.mm b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Mac.mm
index 978b07d44a0..9cd84fbf1b3 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Mac.mm
+++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_Mac.mm
@@ -31,8 +31,6 @@ use or other dealings in this Software without prior written
authorization from the copyright holders.
\****************************************************************************/
-#ifdef XETEX_MAC // this file only for Mac OS X
-
#include "XeTeXFontMgr_Mac.h"
#include <Cocoa/Cocoa.h>
@@ -249,5 +247,3 @@ XeTeXFontMgr_Mac::getPlatformFontDesc(PlatformFontRef descriptor) const
path = "[unknown]";
return path;
}
-
-#endif // XETEX_MAC
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
index c55ba2cf008..e785f94e2d1 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
@@ -40,9 +40,7 @@ authorization from the copyright holders.
#ifdef XETEX_MAC
#include "XeTeXFontInst_Mac.h"
#endif
-#include "XeTeXFontInst_FT2.h"
#include "XeTeXFontMgr.h"
-#include "XeTeXswap.h"
struct XeTeXLayoutEngine_rec
{
@@ -90,12 +88,14 @@ cacheGlyphBBox(uint16_t fontID, uint16_t glyphID, const GlyphBBox* bbox)
}
/*******************************************************************/
-void terminatefontmanager()
+void
+terminatefontmanager()
{
XeTeXFontMgr::Terminate();
}
-XeTeXFont createFont(PlatformFontRef fontRef, Fixed pointSize)
+XeTeXFont
+createFont(PlatformFontRef fontRef, Fixed pointSize)
{
int status = 0;
#ifdef XETEX_MAC
@@ -105,7 +105,7 @@ XeTeXFont createFont(PlatformFontRef fontRef, Fixed pointSize)
FcPatternGetString(fontRef, FC_FILE, 0, &pathname);
int index;
FcPatternGetInteger(fontRef, FC_INDEX, 0, &index);
- XeTeXFontInst* font = new XeTeXFontInst_FT2((const char*)pathname, index, Fix2D(pointSize), status);
+ XeTeXFontInst* font = new XeTeXFontInst((const char*)pathname, index, Fix2D(pointSize), status);
#endif
if (status != 0) {
delete font;
@@ -114,10 +114,11 @@ XeTeXFont createFont(PlatformFontRef fontRef, Fixed pointSize)
return (XeTeXFont)font;
}
-XeTeXFont createFontFromFile(const char* filename, int index, Fixed pointSize)
+XeTeXFont
+createFontFromFile(const char* filename, int index, Fixed pointSize)
{
int status = 0;
- XeTeXFontInst* font = new XeTeXFontInst_FT2(filename, index, Fix2D(pointSize), status);
+ XeTeXFontInst* font = new XeTeXFontInst(filename, index, Fix2D(pointSize), status);
if (status != 0) {
delete font;
return NULL;
@@ -125,62 +126,80 @@ XeTeXFont createFontFromFile(const char* filename, int index, Fixed pointSize)
return (XeTeXFont)font;
}
-void setFontLayoutDir(XeTeXFont font, int vertical)
+void
+setFontLayoutDir(XeTeXFont font, int vertical)
{
((XeTeXFontInst*)font)->setLayoutDirVertical(vertical != 0);
}
-PlatformFontRef findFontByName(const char* name, char* var, double size)
+PlatformFontRef
+findFontByName(const char* name, char* var, double size)
{
return (XeTeXFontMgr::GetFontManager()->findFont(name, var, size));
}
-char getReqEngine()
+char
+getReqEngine()
{
return XeTeXFontMgr::GetFontManager()->getReqEngine();
}
-void setReqEngine(char reqEngine)
+void
+setReqEngine(char reqEngine)
{
XeTeXFontMgr::GetFontManager()->setReqEngine(reqEngine);
}
-const char* getFullName(PlatformFontRef fontRef)
+const char*
+getFullName(PlatformFontRef fontRef)
{
return XeTeXFontMgr::GetFontManager()->getFullName(fontRef);
}
-double getDesignSize(XeTeXFont font)
+double
+getDesignSize(XeTeXFont font)
{
return XeTeXFontMgr::GetFontManager()->getDesignSize(font);
}
-const char* getFontFilename(XeTeXLayoutEngine engine)
+const char*
+getFontFilename(XeTeXLayoutEngine engine)
{
return engine->font->getFilename();
}
-void getNames(PlatformFontRef fontRef, const char** psName, const char** famName, const char** styName)
+void
+getNames(PlatformFontRef fontRef, const char** psName, const char** famName, const char** styName)
{
XeTeXFontMgr::GetFontManager()->getNames(fontRef, psName, famName, styName);
}
-PlatformFontRef getFontRef(XeTeXLayoutEngine engine)
+PlatformFontRef
+getFontRef(XeTeXLayoutEngine engine)
{
return engine->fontRef;
}
-void deleteFont(XeTeXFont font)
+void
+deleteFont(XeTeXFont font)
{
delete (XeTeXFontInst*)font;
}
-void* getFontTablePtr(XeTeXFont font, uint32_t tableTag)
+void*
+getFontTablePtr(XeTeXFont font, uint32_t tableTag)
{
return const_cast<void*>(((XeTeXFontInst*)font)->getFontTable(tableTag));
}
-Fixed getSlant(XeTeXFont font)
+void*
+getFontTable(XeTeXFont font, FT_Sfnt_Tag tableTag)
+{
+ return const_cast<void*>(((XeTeXFontInst*)font)->getFontTable(tableTag));
+}
+
+Fixed
+getSlant(XeTeXFont font)
{
float italAngle = ((XeTeXFontInst*)font)->getItalicAngle();
return D2Fix(tan(-italAngle * M_PI / 180.0));
@@ -189,7 +208,7 @@ Fixed getSlant(XeTeXFont font)
static uint32_t
getLargerScriptListTable(XeTeXFont font, hb_tag_t** scriptList, hb_tag_t* tableTag)
{
- hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->hbFont);
+ hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont());
hb_tag_t* scriptListSub = NULL;
hb_tag_t* scriptListPos = NULL;
@@ -217,12 +236,14 @@ getLargerScriptListTable(XeTeXFont font, hb_tag_t** scriptList, hb_tag_t* tableT
}
}
-uint32_t countScripts(XeTeXFont font)
+uint32_t
+countScripts(XeTeXFont font)
{
return getLargerScriptListTable(font, NULL, NULL);
}
-uint32_t getIndScript(XeTeXFont font, uint32_t index)
+uint32_t
+getIndScript(XeTeXFont font, uint32_t index)
{
hb_tag_t* scriptList;
@@ -236,9 +257,10 @@ uint32_t getIndScript(XeTeXFont font, uint32_t index)
return 0;
}
-uint32_t countScriptLanguages(XeTeXFont font, uint32_t script)
+uint32_t
+countScriptLanguages(XeTeXFont font, uint32_t script)
{
- hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->hbFont);
+ hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont());
hb_tag_t* scriptList;
hb_tag_t tableTag;
@@ -254,9 +276,10 @@ uint32_t countScriptLanguages(XeTeXFont font, uint32_t script)
return 0;
}
-uint32_t getIndScriptLanguage(XeTeXFont font, uint32_t script, uint32_t index)
+uint32_t
+getIndScriptLanguage(XeTeXFont font, uint32_t script, uint32_t index)
{
- hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->hbFont);
+ hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont());
hb_tag_t* scriptList;
hb_tag_t tableTag;
@@ -279,9 +302,10 @@ uint32_t getIndScriptLanguage(XeTeXFont font, uint32_t script, uint32_t index)
return 0;
}
-uint32_t countFeatures(XeTeXFont font, uint32_t script, uint32_t language)
+uint32_t
+countFeatures(XeTeXFont font, uint32_t script, uint32_t language)
{
- hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->hbFont);
+ hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont());
uint32_t total = 0;
for (int i = 0; i < 2; ++i) {
@@ -297,9 +321,10 @@ uint32_t countFeatures(XeTeXFont font, uint32_t script, uint32_t language)
return total;
}
-uint32_t getIndFeature(XeTeXFont font, uint32_t script, uint32_t language, uint32_t index)
+uint32_t
+getIndFeature(XeTeXFont font, uint32_t script, uint32_t language, uint32_t index)
{
- hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->hbFont);
+ hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont());
for (int i = 0; i < 2; ++i) {
uint32_t scriptIndex, langIndex = 0;
@@ -321,11 +346,12 @@ uint32_t getIndFeature(XeTeXFont font, uint32_t script, uint32_t language, uint3
return 0;
}
-uint32_t countGraphiteFeatures(XeTeXLayoutEngine engine)
+uint32_t
+countGraphiteFeatures(XeTeXLayoutEngine engine)
{
uint32_t rval = 0;
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL)
@@ -334,11 +360,12 @@ uint32_t countGraphiteFeatures(XeTeXLayoutEngine engine)
return rval;
}
-uint32_t getGraphiteFeatureCode(XeTeXLayoutEngine engine, uint32_t index)
+uint32_t
+getGraphiteFeatureCode(XeTeXLayoutEngine engine, uint32_t index)
{
uint32_t rval = 0;
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL) {
@@ -349,11 +376,12 @@ uint32_t getGraphiteFeatureCode(XeTeXLayoutEngine engine, uint32_t index)
return rval;
}
-uint32_t countGraphiteFeatureSettings(XeTeXLayoutEngine engine, uint32_t featureID)
+uint32_t
+countGraphiteFeatureSettings(XeTeXLayoutEngine engine, uint32_t featureID)
{
uint32_t rval = 0;
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL) {
@@ -364,11 +392,12 @@ uint32_t countGraphiteFeatureSettings(XeTeXLayoutEngine engine, uint32_t feature
return rval;
}
-uint32_t getGraphiteFeatureSettingCode(XeTeXLayoutEngine engine, uint32_t featureID, uint32_t index)
+uint32_t
+getGraphiteFeatureSettingCode(XeTeXLayoutEngine engine, uint32_t featureID, uint32_t index)
{
uint32_t rval = 0;
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL) {
@@ -379,10 +408,33 @@ uint32_t getGraphiteFeatureSettingCode(XeTeXLayoutEngine engine, uint32_t featur
return rval;
}
+uint32_t
+getGraphiteFeatureDefaultSetting(XeTeXLayoutEngine engine, uint32_t featureID)
+{
+ uint32_t rval = 0;
+
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
+ gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
+
+ if (grFace != NULL) {
+ hb_tag_t lang = HB_TAG_NONE;
+
+ if (engine->language != NULL)
+ lang = hb_tag_from_string(engine->language, -1);
+
+ const gr_feature_ref* feature = gr_face_find_fref(grFace, featureID);
+ gr_feature_val *featureValues = gr_face_featureval_for_lang (grFace, lang);
+
+ rval = gr_fref_feature_value(feature, featureValues);
+ }
+
+ return rval;
+}
+
char *
getGraphiteFeatureLabel(XeTeXLayoutEngine engine, uint32_t featureID)
{
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL) {
@@ -399,7 +451,7 @@ getGraphiteFeatureLabel(XeTeXLayoutEngine engine, uint32_t featureID)
char *
getGraphiteFeatureSettingLabel(XeTeXLayoutEngine engine, uint32_t featureID, uint32_t settingID)
{
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL) {
@@ -419,7 +471,7 @@ getGraphiteFeatureSettingLabel(XeTeXLayoutEngine engine, uint32_t featureID, uin
bool
findGraphiteFeature(XeTeXLayoutEngine engine, const char* s, const char* e, hb_tag_t* f, int* v)
- /* s...e is a "feature[=setting]" string; look for this in the font */
+ /* s...e is a "feature=setting" string; look for this in the font */
{
*f = 0;
*v = 0;
@@ -437,12 +489,9 @@ findGraphiteFeature(XeTeXLayoutEngine engine, const char* s, const char* e, hb_t
while (cp < e && (*cp == ' ' || *cp == '\t'))
++cp;
- if (cp >= e) {
- // no setting was specified, so we just use the first
- // XXX the default is not always the first?
- *v = 1;
- return true;
- }
+ if (cp == e)
+ /* no setting was specified */
+ return false;
*v = findGraphiteFeatureSettingNamed(engine, *f, cp, e - cp);
if (*v == -1)
@@ -451,11 +500,12 @@ findGraphiteFeature(XeTeXLayoutEngine engine, const char* s, const char* e, hb_t
return true;
}
-long findGraphiteFeatureNamed(XeTeXLayoutEngine engine, const char* name, int namelength)
+long
+findGraphiteFeatureNamed(XeTeXLayoutEngine engine, const char* name, int namelength)
{
long rval = -1;
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL) {
@@ -482,11 +532,12 @@ long findGraphiteFeatureNamed(XeTeXLayoutEngine engine, const char* name, int na
return rval;
}
-long findGraphiteFeatureSettingNamed(XeTeXLayoutEngine engine, uint32_t id, const char* name, int namelength)
+long
+findGraphiteFeatureSettingNamed(XeTeXLayoutEngine engine, uint32_t id, const char* name, int namelength)
{
long rval = -1;
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
if (grFace != NULL) {
@@ -513,7 +564,8 @@ long findGraphiteFeatureSettingNamed(XeTeXLayoutEngine engine, uint32_t id, cons
return rval;
}
-float getGlyphWidth(XeTeXFont font, uint32_t gid)
+float
+getGlyphWidth(XeTeXFont font, uint32_t gid)
{
return ((XeTeXFontInst*)font)->getGlyphWidth(gid);
}
@@ -524,29 +576,34 @@ countGlyphs(XeTeXFont font)
return ((XeTeXFontInst*)font)->getNumGlyphs();
}
-XeTeXFont getFont(XeTeXLayoutEngine engine)
+XeTeXFont
+getFont(XeTeXLayoutEngine engine)
{
return (XeTeXFont)(engine->font);
}
-float getExtendFactor(XeTeXLayoutEngine engine)
+float
+getExtendFactor(XeTeXLayoutEngine engine)
{
return engine->extend;
}
-float getSlantFactor(XeTeXLayoutEngine engine)
+float
+getSlantFactor(XeTeXLayoutEngine engine)
{
return engine->slant;
}
-float getEmboldenFactor(XeTeXLayoutEngine engine)
+float
+getEmboldenFactor(XeTeXLayoutEngine engine)
{
return engine->embolden;
}
-XeTeXLayoutEngine createLayoutEngine(PlatformFontRef fontRef, XeTeXFont font, char* script, char* language,
- hb_feature_t* features, int nFeatures, char **shapers, uint32_t rgbValue,
- float extend, float slant, float embolden)
+XeTeXLayoutEngine
+createLayoutEngine(PlatformFontRef fontRef, XeTeXFont font, char* script, char* language,
+ hb_feature_t* features, int nFeatures, char **shapers, uint32_t rgbValue,
+ float extend, float slant, float embolden)
{
XeTeXLayoutEngine result = new XeTeXLayoutEngine_rec;
result->fontRef = fontRef;
@@ -566,13 +623,15 @@ XeTeXLayoutEngine createLayoutEngine(PlatformFontRef fontRef, XeTeXFont font, ch
return result;
}
-void deleteLayoutEngine(XeTeXLayoutEngine engine)
+void
+deleteLayoutEngine(XeTeXLayoutEngine engine)
{
hb_buffer_destroy(engine->hbBuffer);
delete engine->font;
}
-int layoutChars(XeTeXLayoutEngine engine, uint16_t chars[], int32_t offset, int32_t count, int32_t max,
+int
+layoutChars(XeTeXLayoutEngine engine, uint16_t chars[], int32_t offset, int32_t count, int32_t max,
bool rightToLeft)
{
bool res;
@@ -581,7 +640,7 @@ int layoutChars(XeTeXLayoutEngine engine, uint16_t chars[], int32_t offset, int3
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_font_t* hbFont = engine->font->getHbFont();
hb_face_t* hbFace = hb_font_get_face(hbFont);
if (engine->font->getLayoutDirVertical())
@@ -647,7 +706,8 @@ int layoutChars(XeTeXLayoutEngine engine, uint16_t chars[], int32_t offset, int3
return glyphCount;
}
-void getGlyphs(XeTeXLayoutEngine engine, uint32_t glyphs[])
+void
+getGlyphs(XeTeXLayoutEngine engine, uint32_t glyphs[])
{
int glyphCount = hb_buffer_get_length(engine->hbBuffer);
hb_glyph_info_t *hbGlyphs = hb_buffer_get_glyph_infos(engine->hbBuffer, NULL);
@@ -656,7 +716,22 @@ void getGlyphs(XeTeXLayoutEngine engine, uint32_t glyphs[])
glyphs[i] = hbGlyphs[i].codepoint;
}
-void getGlyphPositions(XeTeXLayoutEngine engine, float positions[])
+void
+getGlyphAdvances(XeTeXLayoutEngine engine, float advances[])
+{
+ int glyphCount = hb_buffer_get_length(engine->hbBuffer);
+ hb_glyph_position_t *hbPositions = hb_buffer_get_glyph_positions(engine->hbBuffer, NULL);
+
+ for (int i = 0; i < glyphCount; i++) {
+ if (engine->font->getLayoutDirVertical())
+ advances[i] = hbPositions[i].y_advance / 64.0;
+ else
+ advances[i] = hbPositions[i].x_advance / 64.0;
+ }
+}
+
+void
+getGlyphPositions(XeTeXLayoutEngine engine, float positions[])
{
int glyphCount = hb_buffer_get_length(engine->hbBuffer);
hb_glyph_position_t *hbPositions = hb_buffer_get_glyph_positions(engine->hbBuffer, NULL);
@@ -665,14 +740,15 @@ void getGlyphPositions(XeTeXLayoutEngine engine, float positions[])
float x = 0, y = 0;
if (engine->font->getLayoutDirVertical()) {
- // XXX this does not seem to match the old behaviour
- x -= hbPositions[0].y_offset / 64.0; // hack to compensate offset of 1st glyph
+ /* 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] = (y + hbPositions[i].x_offset / 64.0);
+ 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;
- y += hbPositions[i].x_advance / 64.0;
}
+ x -= hbPositions[glyphCount-1].y_offset / 64.0;
positions[2*i] = -x;
positions[2*i+1] = y;
} else {
@@ -691,18 +767,28 @@ void getGlyphPositions(XeTeXLayoutEngine engine, float positions[])
positions[2*i] = positions[2*i] * engine->extend - positions[2*i+1] * engine->slant;
}
-float getPointSize(XeTeXLayoutEngine engine)
+float
+getPointSize(XeTeXLayoutEngine engine)
{
return engine->font->getPointSize();
}
-void getAscentAndDescent(XeTeXLayoutEngine engine, float* ascent, float* descent)
+void
+getAscentAndDescent(XeTeXLayoutEngine engine, float* ascent, float* descent)
{
*ascent = engine->font->getAscent();
*descent = engine->font->getDescent();
}
-int getDefaultDirection(XeTeXLayoutEngine engine)
+void
+getCapAndXHeight(XeTeXLayoutEngine engine, float* capheight, float* xheight)
+{
+ *capheight = engine->font->getCapHeight();
+ *xheight = engine->font->getXHeight();
+}
+
+int
+getDefaultDirection(XeTeXLayoutEngine engine)
{
hb_script_t script = hb_buffer_get_script(engine->hbBuffer);
if (hb_script_get_horizontal_direction (script) == HB_DIRECTION_RTL)
@@ -711,12 +797,14 @@ int getDefaultDirection(XeTeXLayoutEngine engine)
return UBIDI_DEFAULT_LTR;
}
-uint32_t getRgbValue(XeTeXLayoutEngine engine)
+uint32_t
+getRgbValue(XeTeXLayoutEngine engine)
{
return engine->rgbValue;
}
-void getGlyphBounds(XeTeXLayoutEngine engine, uint32_t glyphID, GlyphBBox* bbox)
+void
+getGlyphBounds(XeTeXLayoutEngine engine, uint32_t glyphID, GlyphBBox* bbox)
{
engine->font->getGlyphBounds(glyphID, bbox);
if (engine->extend != 0.0) {
@@ -725,17 +813,20 @@ void getGlyphBounds(XeTeXLayoutEngine engine, uint32_t glyphID, GlyphBBox* bbox)
}
}
-float getGlyphWidthFromEngine(XeTeXLayoutEngine engine, uint32_t glyphID)
+float
+getGlyphWidthFromEngine(XeTeXLayoutEngine engine, uint32_t glyphID)
{
return engine->extend * engine->font->getGlyphWidth(glyphID);
}
-void getGlyphHeightDepth(XeTeXLayoutEngine engine, uint32_t glyphID, float* height, float* depth)
+void
+getGlyphHeightDepth(XeTeXLayoutEngine engine, uint32_t glyphID, float* height, float* depth)
{
engine->font->getGlyphHeightDepth(glyphID, height, depth);
}
-void getGlyphSidebearings(XeTeXLayoutEngine engine, uint32_t glyphID, float* lsb, float* rsb)
+void
+getGlyphSidebearings(XeTeXLayoutEngine engine, uint32_t glyphID, float* lsb, float* rsb)
{
engine->font->getGlyphSidebearings(glyphID, lsb, rsb);
if (engine->extend != 0.0) {
@@ -744,134 +835,18 @@ void getGlyphSidebearings(XeTeXLayoutEngine engine, uint32_t glyphID, float* lsb
}
}
-float getGlyphItalCorr(XeTeXLayoutEngine engine, uint32_t glyphID)
+float
+getGlyphItalCorr(XeTeXLayoutEngine engine, uint32_t glyphID)
{
return engine->extend * engine->font->getGlyphItalCorr(glyphID);
}
-uint32_t mapCharToGlyph(XeTeXLayoutEngine engine, uint32_t charCode)
+uint32_t
+mapCharToGlyph(XeTeXLayoutEngine engine, uint32_t charCode)
{
return engine->font->mapCharToGlyph(charCode);
}
-#include "appleGlyphNames.c"
-
-int
-findGlyphInPostTable(const char* buffer, int tableSize, const char* glyphName)
-{
- const POSTTable* p = (const POSTTable*)buffer;
- uint16_t g = 0;
- switch (SWAP(p->version)) {
- case 0x00010000:
- {
- const char* cp;
- while ((cp = appleGlyphNames[g]) != 0) {
- if (strcmp(glyphName, cp) == 0)
- return g;
- ++g;
- }
- }
- break;
-
- case 0x00020000:
- {
- const uint16_t* n = (uint16_t*)(p + 1);
- uint16_t numGlyphs = SWAP(*n++);
- const uint8_t* ps = (const uint8_t*)(n + numGlyphs);
- std::vector<std::string> newNames;
- while (ps < (const uint8_t*)buffer + tableSize) {
- newNames.push_back(std::string((char*)ps + 1, *ps));
- ps += *ps + 1;
- }
- for (g = 0; g < numGlyphs; ++g) {
- if (SWAP(*n) < 258) {
- if (strcmp(appleGlyphNames[SWAP(*n)], glyphName) == 0)
- return g;
- }
- else {
- if (strcmp(newNames[SWAP(*n) - 258].c_str(), glyphName) == 0)
- return g;
- }
- ++n;
- }
- }
- break;
-
- case 0x00028000:
- break;
-
- case 0x00030000:
- // TODO: see if it's a CFF OpenType font, and if so, get the glyph names from the CFF data
- break;
-
- case 0x00040000:
- break;
-
- default:
- break;
- }
-
- return 0;
-}
-
-const char*
-getGlyphNamePtr(const char* buffer, int tableSize, uint16_t gid, int* len)
-{
- const POSTTable* p = (const POSTTable*)buffer;
- switch (SWAP(p->version)) {
- case 0x00010000:
- {
- if (gid < 258) {
- *len = strlen(appleGlyphNames[gid]);
- return appleGlyphNames[gid];
- }
- }
- break;
-
- case 0x00020000:
- {
- const uint16_t* n = (uint16_t*)(p + 1);
- uint16_t numGlyphs = SWAP(*n++);
- const uint8_t* ps = (const uint8_t*)(n + numGlyphs);
- std::vector<const uint8_t*> namePtrs;
- while (ps < (const uint8_t*)buffer + tableSize) {
- namePtrs.push_back(ps);
- ps += *ps + 1;
- }
- if (gid < numGlyphs) {
- gid = SWAP(n[gid]);
- if (gid < 258) {
- *len = strlen(appleGlyphNames[gid]);
- return appleGlyphNames[gid];
- }
- else {
- ps = namePtrs[gid - 258];
- *len = *ps;
- return (char*)(ps + 1);
- }
- }
- }
- break;
-
- case 0x00028000:
- break;
-
- case 0x00030000:
- // TODO: see if it's a CFF OpenType font, and if so, get the glyph names from the CFF data
- break;
-
- case 0x00040000:
- break;
-
- default:
- break;
- }
-
- /* no name found */
- *len = 0;
- return NULL;
-}
-
int
getFontCharRange(XeTeXLayoutEngine engine, int reqFirst)
{
@@ -895,13 +870,14 @@ mapGlyphToIndex(XeTeXLayoutEngine engine, const char* glyphName)
static gr_segment* grSegment = NULL;
static const gr_slot* grPrevSlot = NULL;
+static int grTextLen;
bool
initGraphiteBreaking(XeTeXLayoutEngine engine, const uint16_t* txtPtr, int txtLen)
{
- hb_face_t* hbFace = hb_font_get_face(engine->font->hbFont);
+ hb_face_t* hbFace = hb_font_get_face(engine->font->getHbFont());
gr_face* grFace = hb_graphite2_face_get_gr_face(hbFace);
- gr_font* grFont = hb_graphite2_font_get_gr_font(engine->font->hbFont);
+ gr_font* grFont = hb_graphite2_font_get_gr_font(engine->font->getHbFont());
if (grFace != NULL && grFont != NULL) {
if (grSegment != NULL) {
gr_seg_destroy(grSegment);
@@ -917,19 +893,20 @@ initGraphiteBreaking(XeTeXLayoutEngine engine, const uint16_t* txtPtr, int txtLe
if (engine->language != NULL)
lang = hb_tag_from_string(engine->language, -1);
- gr_feature_val *grFeatures = gr_face_featureval_for_lang (grFace, lang);
+ gr_feature_val *grFeatureValues = gr_face_featureval_for_lang (grFace, lang);
int nFeatures = engine->nFeatures;
hb_feature_t *features = engine->features;
while (nFeatures--) {
const gr_feature_ref *fref = gr_face_find_fref (grFace, features->tag);
if (fref)
- gr_fref_set_feature_value (fref, features->value, grFeatures);
+ gr_fref_set_feature_value (fref, features->value, grFeatureValues);
features++;
}
- grSegment = gr_make_seg(grFont, grFace, script, grFeatures, gr_utf16, txtPtr, txtLen, 0);
+ grSegment = gr_make_seg(grFont, grFace, script, grFeatureValues, gr_utf16, txtPtr, txtLen, 0);
grPrevSlot = gr_seg_first_slot(grSegment);
+ grTextLen = txtLen;
return true;
}
@@ -940,39 +917,40 @@ initGraphiteBreaking(XeTeXLayoutEngine engine, const uint16_t* txtPtr, int txtLe
int
findNextGraphiteBreak(void)
{
- if (grSegment == NULL)
- return -1;
-
- // XXX: gr_cinfo_base() returns "code unit" index not char index, so this
- // is broken outside BMP
- if (grPrevSlot && grPrevSlot != gr_seg_last_slot(grSegment)) {
- const gr_slot* s;
- const gr_char_info* ci = NULL;
- for (s = gr_slot_next_in_segment(grPrevSlot); s != NULL; s = gr_slot_next_in_segment(s)) {
- int bw;
-
- ci = gr_seg_cinfo(grSegment, gr_slot_index(s));
- bw = gr_cinfo_break_weight(ci);
- if (bw < gr_breakNone && bw >= gr_breakBeforeWord) {
- grPrevSlot = s;
- return gr_cinfo_base(ci);
+ int ret = -1;
+
+ if (grSegment != NULL) {
+ if (grPrevSlot && grPrevSlot != gr_seg_last_slot(grSegment)) {
+ for (const gr_slot* s = gr_slot_next_in_segment(grPrevSlot); s != NULL; s = gr_slot_next_in_segment(s)) {
+ const gr_char_info* ci = NULL;
+ int bw;
+
+ ci = gr_seg_cinfo(grSegment, gr_slot_index(s));
+ bw = gr_cinfo_break_weight(ci);
+ if (bw < gr_breakNone && bw >= gr_breakBeforeWord) {
+ grPrevSlot = s;
+ ret = gr_cinfo_base(ci);
+ } else if (bw > gr_breakNone && bw <= gr_breakWord) {
+ grPrevSlot = gr_slot_next_in_segment(s);
+ ret = gr_cinfo_base(ci) + 1;
+ }
+
+ if (ret != -1)
+ break;
}
- if (bw > gr_breakNone && bw <= gr_breakWord) {
- grPrevSlot = gr_slot_next_in_segment(s);
- return gr_cinfo_base(ci) + 1;
+ if (ret == -1) {
+ grPrevSlot = gr_seg_last_slot(grSegment);
+ ret = grTextLen;
}
}
-
- grPrevSlot = gr_seg_last_slot(grSegment);
- ci = gr_seg_cinfo(grSegment, gr_slot_after(grPrevSlot));
- return gr_cinfo_base(ci) + 1;
- } else {
- return -1;
}
+
+ return ret;
}
-bool usingGraphite(XeTeXLayoutEngine engine)
+bool
+usingGraphite(XeTeXLayoutEngine engine)
{
if (engine->shaper != NULL && (strcmp("graphite2", engine->shaper) == 0))
return true;
@@ -980,7 +958,8 @@ bool usingGraphite(XeTeXLayoutEngine engine)
return false;
}
-bool usingOpenType(XeTeXLayoutEngine engine)
+bool
+usingOpenType(XeTeXLayoutEngine engine)
{
if (engine->shaper == NULL || (strcmp("ot", engine->shaper) == 0))
return true;
@@ -988,11 +967,11 @@ bool usingOpenType(XeTeXLayoutEngine engine)
return false;
}
-bool isOpenTypeMathFont(XeTeXLayoutEngine engine)
+bool
+isOpenTypeMathFont(XeTeXLayoutEngine engine)
{
- if (engine->font->getFontTable(kMATH) != NULL)
+ if (engine->font->getMathTable() != 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 a3e3ac2edae..245bcd2e4ad 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h
+++ b/Build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h
@@ -43,17 +43,21 @@ typedef struct XeTeXLayoutEngine_rec* XeTeXLayoutEngine;
};
#endif
-#include "XeTeX_ext.h"
-#include "XeTeXFontMgr.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_TRUETYPE_TABLES_H
+
#include <hb.h>
#include <hb-ot.h>
-#include <hb-ft.h>
#include <hb-icu.h>
#include <graphite2/Font.h>
#include <graphite2/Segment.h>
#include <hb-graphite2.h>
+#include "XeTeX_ext.h"
+#include "XeTeXFontMgr.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -84,6 +88,7 @@ double getDesignSize(XeTeXFont font);
void deleteFont(XeTeXFont font);
void* getFontTablePtr(XeTeXFont font, uint32_t tableTag);
+void* getFontTable(XeTeXFont font, FT_Sfnt_Tag tableTag);
Fixed getSlant(XeTeXFont font);
@@ -113,12 +118,13 @@ int layoutChars(XeTeXLayoutEngine engine, uint16_t* chars, int32_t offset, int32
bool rightToLeft);
void getGlyphs(XeTeXLayoutEngine engine, uint32_t* glyphs);
-
+void getGlyphAdvances(XeTeXLayoutEngine engine, float *advances);
void getGlyphPositions(XeTeXLayoutEngine engine, float* positions);
float getPointSize(XeTeXLayoutEngine engine);
void getAscentAndDescent(XeTeXLayoutEngine engine, float* ascent, float* descent);
+void getCapAndXHeight(XeTeXLayoutEngine engine, float* capheight, float* xheight);
int getDefaultDirection(XeTeXLayoutEngine engine);
@@ -138,8 +144,6 @@ uint32_t mapCharToGlyph(XeTeXLayoutEngine engine, uint32_t charCode);
int mapGlyphToIndex(XeTeXLayoutEngine engine, const char* glyphName);
-int findGlyphInPostTable(const char* p, int tableSize, const char* glyphName);
-
const char* getGlyphName(XeTeXFont font, uint16_t gid, int* len);
int getFontCharRange(XeTeXLayoutEngine engine, int reqFirst);
@@ -158,6 +162,7 @@ uint32_t countGraphiteFeatures(XeTeXLayoutEngine engine);
uint32_t getGraphiteFeatureCode(XeTeXLayoutEngine engine, uint32_t index);
uint32_t countGraphiteFeatureSettings(XeTeXLayoutEngine engine, uint32_t feature);
uint32_t getGraphiteFeatureSettingCode(XeTeXLayoutEngine engine, uint32_t feature, uint32_t index);
+uint32_t getGraphiteFeatureDefaultSetting(XeTeXLayoutEngine engine, uint32_t feature);
char* getGraphiteFeatureLabel(XeTeXLayoutEngine engine, uint32_t feature);
char* getGraphiteFeatureSettingLabel(XeTeXLayoutEngine engine, uint32_t feature, uint32_t setting);
long findGraphiteFeatureNamed(XeTeXLayoutEngine engine, const char* name, int namelength);
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp b/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp
index a2260a9271e..3d2bae0d1ca 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp
+++ b/Build/source/texk/web2c/xetexdir/XeTeXOTMath.cpp
@@ -69,7 +69,7 @@ static int32_t getCoverage(const Coverage* coverage, GlyphID g)
static int16_t getMathConstant(XeTeXFontInst* fontInst, mathConstantIndex whichConstant)
{
- const char* table = (const char*)fontInst->getFontTable(kMATH);
+ const char* table = fontInst->getMathTable();
if (table == NULL)
return 0;
@@ -223,7 +223,7 @@ get_ot_math_variant(int f, int g, int v, integer* adv, int horiz)
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]);
- const char* table = (const char*)font->getFontTable(kMATH);
+ const char* table = font->getMathTable();
if (table == NULL)
return rval;
@@ -261,7 +261,7 @@ get_ot_assembly_ptr(int f, int g, int horiz)
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]);
- const char* table = (const char*)font->getFontTable(kMATH);
+ const char* table = font->getMathTable();
if (table == NULL)
return rval;
@@ -298,7 +298,7 @@ get_ot_math_ital_corr(int f, int g)
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]);
- const char* table = (const char*)font->getFontTable(kMATH);
+ const char* table = font->getMathTable();
if (table == NULL)
return rval;
@@ -333,7 +333,7 @@ get_ot_math_accent_pos(int f, int g)
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]);
- const char* table = (const char*)font->getFontTable(kMATH);
+ const char* table = font->getMathTable();
if (table == NULL)
return rval;
@@ -370,7 +370,7 @@ ot_min_connector_overlap(int f)
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]);
- const char* table = (const char*)font->getFontTable(kMATH);
+ const char* table = font->getMathTable();
if (table == NULL)
return rval;
@@ -399,7 +399,7 @@ getMathKernAt(int f, int g, MathKernSide side, int height)
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXFontInst* font = (XeTeXFontInst*)getFont((XeTeXLayoutEngine)fontlayoutengine[f]);
- const char* table = (const char*)font->getFontTable(kMATH);
+ const char* table = font->getMathTable();
if (table == NULL)
return rval;
diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
index 058245e6274..aa637ff2f41 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
+++ b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c
@@ -87,7 +87,6 @@ authorization from the copyright holders.
#include <unicode/ucnv.h>
#include <assert.h>
-#include "sfnt.h"
/* tables/values used in UTF-8 interpretation -
code is based on ConvertUTF.[ch] sample code
@@ -239,8 +238,7 @@ setinputfileencoding(UFILE* f, integer mode, integer encodingData)
printcstring("'; reading as raw bytes");
enddiagnostic(1);
f->encodingMode = RAW;
- }
- else {
+ } else {
f->encodingMode = ICUMAPPING;
f->conversionData = cnv;
}
@@ -386,8 +384,7 @@ static uint32_t *utf32Buf = NULL;
last = first + outLen;
break;
}
- }
- else {
+ } else {
/* Recognize either LF or CR as a line terminator; skip initial LF if prev line ended with CR. */
i = get_uni_c(f);
if (f->skipNextLF) {
@@ -560,8 +557,7 @@ getencodingmodeandinfo(integer* info)
printcstring("'; reading as raw bytes");
enddiagnostic(1);
return RAW;
- }
- else {
+ } else {
ucnv_close(cnv);
*info = maketexstring(name);
return ICUMAPPING;
@@ -628,9 +624,9 @@ load_mapping_file(const char* s, const char* e, char byteMapping)
fontmappingwarning(buffer, strlen(buffer), 2); /* not loadable */
else if (gettracingfontsstate() > 1)
fontmappingwarning(buffer, strlen(buffer), 0); /* tracing */
- }
- else
+ } else {
fontmappingwarning(buffer, strlen(buffer), 1); /* not found */
+ }
free(buffer);
@@ -695,8 +691,7 @@ read_double(const char** s)
if (*cp == '-') {
neg = 1;
++cp;
- }
- else if (*cp == '+') {
+ } else if (*cp == '+') {
++cp;
}
@@ -855,7 +850,7 @@ readCommonFeatures(const char* feat, const char* end, float* extend, float* slan
static bool
readFeatureNumber(const char* s, const char* e, hb_tag_t* f, int* v)
- /* s...e is a "id[=setting]" string; */
+ /* s...e is a "id=setting" string; */
{
*f = 0;
*v = 0;
@@ -865,16 +860,10 @@ readFeatureNumber(const char* s, const char* e, hb_tag_t* f, int* v)
*f = *f * 10 + *s++ - '0';
while ((*s == ' ') || (*s == '\t'))
++s;
- if (*s++ != '=') {
- if (s >= e) {
- // no setting was specified, so we just use the first
- // XXX the default is not always the first?
- *v = 1;
- return true;
- } else {
- return false;
- }
- }
+ if (*s++ != '=')
+ /* no setting was specified */
+ return false;
+
if (*s < '0' || *s > '9')
return false;
while (*s >= '0' && *s <= '9')
@@ -931,7 +920,18 @@ loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const cha
int i;
- if (getReqEngine() == 'G') {
+ char reqEngine = getReqEngine();
+
+ if (reqEngine == 'O' || reqEngine == 'G') {
+ shapers = xrealloc(shapers, (nShapers + 1) * sizeof(char *));
+ if (reqEngine == 'O')
+ shapers[nShapers] = strdup("ot");
+ else if (reqEngine == 'G')
+ shapers[nShapers] = strdup("graphite2");
+ nShapers++;
+ }
+
+ if (reqEngine == 'G') {
/* create a default engine so we can query the font for Graphite features;
* because of font caching, it's cheap to discard this and create the real one later */
engine = createLayoutEngine(fontRef, font, script, language,
@@ -989,7 +989,7 @@ loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const cha
else if (i == -1)
goto bad_option;
- if (getReqEngine() == 'G') {
+ if (reqEngine == 'G') {
int value = 0;
if (readFeatureNumber(cp1, cp2, &tag, &value)
|| findGraphiteFeature(engine, cp1, cp2, &tag, &value)) {
@@ -1072,9 +1072,9 @@ loadOTfont(PlatformFontRef fontRef, XeTeXFont font, Fixed scaled_size, const cha
// only free these if creation failed, otherwise the engine now owns them
free(features);
free(shapers);
- }
- else
+ } else {
nativefonttypeflag = OTGR_FONT_FLAG;
+ }
return engine;
}
@@ -1096,8 +1096,7 @@ splitFontName(char* name, char** var, char** feat, char** end, int* index)
withinFileName = 0;
if (*var == NULL)
*var = name;
- }
- else if (*name == ':') {
+ } else if (*name == ':') {
if (withinFileName && *var == NULL
#ifdef WIN32
&& !((name - start == 1) && isalpha(*start))
@@ -1108,15 +1107,13 @@ splitFontName(char* name, char** var, char** feat, char** end, int* index)
while (*name >= '0' && *name <= '9')
*index = *index * 10 + *name++ - '0';
--name;
- }
- else if (!withinFileName && *feat == NULL)
+ } else if (!withinFileName && *feat == NULL)
*feat = name;
}
++name;
}
*end = name;
- }
- else {
+ } else {
while (*name) {
if (*name == '/' && *var == NULL && *feat == NULL)
*var = name;
@@ -1192,10 +1189,16 @@ findnativefont(unsigned char* uname, integer scaled_size)
if (font != NULL) {
loadedfontdesignsize = D2Fix(getDesignSize(font));
- if (varString && strncmp(varString, "/GR", 3) == 0)
- setReqEngine('G');
- else
- setReqEngine(0);
+ /* This is duplicated in XeTeXFontMgr::findFont! */
+ setReqEngine(0);
+ if (varString) {
+ if (strncmp(varString, "/AAT", 4) == 0)
+ setReqEngine('A');
+ else if ((strncmp(varString, "/OT", 3) == 0) || (strncmp(varString, "/ICU", 4) == 0))
+ setReqEngine('O');
+ else if (strncmp(varString, "/GR", 3) == 0)
+ setReqEngine('G');
+ }
rval = loadOTfont(0, font, scaled_size, featString);
if (rval == NULL)
@@ -1209,8 +1212,7 @@ findnativefont(unsigned char* uname, integer scaled_size)
}
}
}
- }
- else {
+ } else {
fontRef = findFontByName(nameString, varString, Fix2D(scaled_size));
if (fontRef != 0) {
@@ -1245,7 +1247,7 @@ findnativefont(unsigned char* uname, integer scaled_size)
#endif
font = createFont(fontRef, scaled_size);
- if (font != 0) {
+ if (font != NULL) {
#ifdef XETEX_MAC
if (getReqEngine() == 'O' || getReqEngine() == 'G' ||
getFontTablePtr(font, kGSUB) != NULL || getFontTablePtr(font, kGPOS) != NULL)
@@ -1257,8 +1259,10 @@ findnativefont(unsigned char* uname, integer scaled_size)
#ifdef XETEX_MAC
if (rval == NULL) {
- load_aat:
- rval = loadAATfont(fontRef, scaled_size, featString);
+load_aat:
+ if (font != NULL) {
+ rval = loadAATfont(fontRef, scaled_size, featString);
+ }
}
#endif
@@ -1305,7 +1309,6 @@ otgetfontmetrics(void* pEngine, scaled* ascent, scaled* descent, scaled* xheight
{
XeTeXLayoutEngine engine = (XeTeXLayoutEngine)pEngine;
float a, d;
- int glyphID;
getAscentAndDescent(engine, &a, &d);
*ascent = D2Fix(a);
@@ -1314,21 +1317,31 @@ otgetfontmetrics(void* pEngine, scaled* ascent, scaled* descent, scaled* xheight
*slant = D2Fix(Fix2D(getSlant(getFont(engine))) * getExtendFactor(engine)
+ getSlantFactor(engine));
- glyphID = mapCharToGlyph(engine, 'x');
- if (glyphID != 0) {
- getGlyphHeightDepth(engine, glyphID, &a, &d);
- *xheight = D2Fix(a);
+ /* get cap and x height from OS/2 table */
+ getCapAndXHeight(engine, &a, &d);
+ *capheight = D2Fix(a);
+ *xheight = D2Fix(d);
+
+ /* fallback in case the font does not have OS/2 table */
+ if (*xheight == 0) {
+ int glyphID = mapCharToGlyph(engine, 'x');
+ if (glyphID != 0) {
+ getGlyphHeightDepth(engine, glyphID, &a, &d);
+ *xheight = D2Fix(a);
+ } else {
+ *xheight = *ascent / 2; /* arbitrary figure if there's no 'x' in the font */
+ }
}
- else
- *xheight = *ascent / 2; /* arbitrary figure if there's no 'x' in the font */
- glyphID = mapCharToGlyph(engine, 'X');
- if (glyphID != 0) {
- getGlyphHeightDepth(engine, glyphID, &a, &d);
- *capheight = D2Fix(a);
+ if (*capheight == 0) {
+ int glyphID = mapCharToGlyph(engine, 'X');
+ if (glyphID != 0) {
+ getGlyphHeightDepth(engine, glyphID, &a, &d);
+ *capheight = D2Fix(a);
+ } else {
+ *capheight = *ascent; /* arbitrary figure if there's no 'X' in the font */
+ }
}
- else
- *capheight = *ascent; /* arbitrary figure if there's no 'X' in the font */
}
integer
@@ -1401,7 +1414,7 @@ otfontget2(integer what, void* pEngine, integer param1, integer param2)
return getGraphiteFeatureSettingCode(engine, param1, param2);
break;
case XeTeX_is_default_selector:
- return getGraphiteFeatureSettingCode(engine, param1, 1) == param2;
+ return getGraphiteFeatureDefaultSetting(engine, param1) == param2;
break;
}
@@ -1508,7 +1521,7 @@ makeXDVGlyphArrayData(void* pNode)
void* glyph_info;
FixedPoint* locations;
int opcode;
- Fixed wid;
+ Fixed width;
uint16_t glyphCount = native_glyph_count(p);
int i = glyphCount * native_glyph_info_size + 8; /* to guarantee enough space in the buffer */
@@ -1533,11 +1546,11 @@ makeXDVGlyphArrayData(void* pNode)
cp = (unsigned char*)xdvbuffer;
*cp++ = opcode;
- wid = node_width(p);
- *cp++ = (wid >> 24) & 0xff;
- *cp++ = (wid >> 16) & 0xff;
- *cp++ = (wid >> 8) & 0xff;
- *cp++ = wid & 0xff;
+ width = node_width(p);
+ *cp++ = (width >> 24) & 0xff;
+ *cp++ = (width >> 16) & 0xff;
+ *cp++ = (width >> 8) & 0xff;
+ *cp++ = width & 0xff;
*cp++ = (glyphCount >> 8) & 0xff;
*cp++ = glyphCount & 0xff;
@@ -1596,6 +1609,8 @@ makefontdef(integer f)
CGAffineTransform t;
CFNumberRef emboldenNumber;
CGFloat fSize;
+ char *pathname;
+ int index;
flags = XDV_FLAG_FONTTYPE_ATSUI;
attributes = (CFDictionaryRef) fontlayoutengine[f];
@@ -1606,8 +1621,17 @@ makefontdef(integer f)
CFRelease(variation);
}
- psName = getFileNameFromCTFont(font);
- if (psName) {
+ pathname = getFileNameFromCTFont(font, &index);
+ if (pathname) {
+ char buf[20];
+
+ if (index > 0)
+ sprintf(buf, ":%d", index);
+ else
+ buf[0] = '\0';
+
+ psName = xmalloc(strlen((char*) pathname) + 2 + strlen(buf) + 1);
+ sprintf((char*) psName, "[%s%s]", pathname, buf);
famName = "";
styName = "";
} else {
@@ -1633,8 +1657,7 @@ makefontdef(integer f)
fSize = CTFontGetSize(font);
size = D2Fix(fSize);
- }
- else
+ } else
#endif
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXLayoutEngine engine;
@@ -1659,8 +1682,7 @@ makefontdef(integer f)
embolden = getEmboldenFactor(engine);
size = D2Fix(getPointSize(engine));
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `make_font_def'\n");
exit(3);
}
@@ -1818,15 +1840,13 @@ getnativecharheightdepth(integer font, integer ch, scaled* height, scaled* depth
CFDictionaryRef attributes = (CFDictionaryRef)(fontlayoutengine[font]);
int gid = MapCharToGlyph_AAT(attributes, ch);
GetGlyphHeightDepth_AAT(attributes, gid, &ht, &dp);
- }
- else
+ } else
#endif
if (fontarea[font] == OTGR_FONT_FLAG) {
XeTeXLayoutEngine engine = (XeTeXLayoutEngine)fontlayoutengine[font];
int gid = mapCharToGlyph(engine, ch);
getGlyphHeightDepth(engine, gid, &ht, &dp);
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `get_native_char_height_depth`\n");
exit(3);
}
@@ -1868,15 +1888,13 @@ getnativecharsidebearings(integer font, integer ch, scaled* lsb, scaled* rsb)
CFDictionaryRef attributes = (CFDictionaryRef)(fontlayoutengine[font]);
int gid = MapCharToGlyph_AAT(attributes, ch);
GetGlyphSidebearings_AAT(attributes, gid, &l, &r);
- }
- else
+ } else
#endif
if (fontarea[font] == OTGR_FONT_FLAG) {
XeTeXLayoutEngine engine = (XeTeXLayoutEngine)fontlayoutengine[font];
int gid = mapCharToGlyph(engine, ch);
getGlyphSidebearings(engine, gid, &l, &r);
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `get_native_char_side_bearings'\n");
exit(3);
}
@@ -1898,8 +1916,7 @@ getglyphbounds(integer font, integer edge, integer gid)
GetGlyphSidebearings_AAT(attributes, gid, &a, &b);
else
GetGlyphHeightDepth_AAT(attributes, gid, &a, &b);
- }
- else
+ } else
#endif
if (fontarea[font] == OTGR_FONT_FLAG) {
XeTeXLayoutEngine engine = (XeTeXLayoutEngine)fontlayoutengine[font];
@@ -1907,8 +1924,7 @@ getglyphbounds(integer font, integer edge, integer gid)
getGlyphSidebearings(engine, gid, &a, &b);
else
getGlyphHeightDepth(engine, gid, &a, &b);
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `get_glyph_bounds'\n");
exit(3);
}
@@ -1935,15 +1951,13 @@ getnativecharwd(integer f, integer c)
CFDictionaryRef attributes = (CFDictionaryRef)(fontlayoutengine[f]);
int gid = MapCharToGlyph_AAT(attributes, c);
wd = D2Fix(GetGlyphWidth_AAT(attributes, gid));
- }
- else
+ } else
#endif
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXLayoutEngine engine = (XeTeXLayoutEngine)fontlayoutengine[f];
int gid = mapCharToGlyph(engine, c);
wd = D2Fix(getGlyphWidthFromEngine(engine, gid));
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `get_native_char_wd'\n");
exit(3);
}
@@ -1966,7 +1980,7 @@ void
store_justified_native_glyphs(void* node)
{
#ifdef XETEX_MAC /* this is only called for fonts used via ATSUI */
- (void)DoAtsuiLayout(node, 1);
+ (void)DoAATLayout(node, 1);
#endif
}
@@ -1982,9 +1996,8 @@ measure_native_node(void* pNode, int use_glyph_metrics)
#ifdef XETEX_MAC
if (fontarea[f] == AAT_FONT_FLAG) {
/* we're using this font in AAT mode, so fontlayoutengine[f] is actually a CFDictionaryRef */
- DoAtsuiLayout(node, 0);
- }
- else
+ DoAATLayout(node, 0);
+ } else
#endif
if (fontarea[f] == OTGR_FONT_FLAG) {
/* using this font in OT Layout mode, so fontlayoutengine[f] is actually a XeTeXLayoutEngine */
@@ -1993,7 +2006,8 @@ measure_native_node(void* pNode, int use_glyph_metrics)
FixedPoint* locations;
uint16_t* glyphIDs;
- int realGlyphCount = 0;
+ Fixed* glyphAdvances;
+ int totalGlyphCount = 0;
/* need to find direction runs within the text, and call layoutChars separately for each */
@@ -2001,6 +2015,7 @@ measure_native_node(void* pNode, int use_glyph_metrics)
float x, y;
void* glyph_info = 0;
static float* positions = 0;
+ static float* advances = 0;
static uint32_t* glyphs = 0;
UBiDi* pBiDi = ubidi_open();
@@ -2015,20 +2030,21 @@ measure_native_node(void* pNode, int use_glyph_metrics)
bothered to deal with the memory reallocation headache of doing it differently
*/
int nRuns = ubidi_countRuns(pBiDi, &errorCode);
- double wid = 0;
+ double width = 0;
int i, runIndex;
int32_t logicalStart, length;
for (runIndex = 0; runIndex < nRuns; ++runIndex) {
dir = ubidi_getVisualRun(pBiDi, runIndex, &logicalStart, &length);
- realGlyphCount += layoutChars(engine, txtPtr, logicalStart, length, txtLen, (dir == UBIDI_RTL));
+ totalGlyphCount += layoutChars(engine, txtPtr, logicalStart, length, txtLen, (dir == UBIDI_RTL));
}
- if (realGlyphCount > 0) {
+ if (totalGlyphCount > 0) {
double x, y;
- glyph_info = xmalloc(realGlyphCount * native_glyph_info_size);
+ glyph_info = xmalloc(totalGlyphCount * native_glyph_info_size);
locations = (FixedPoint*)glyph_info;
- glyphIDs = (uint16_t*)(locations + realGlyphCount);
- realGlyphCount = 0;
+ glyphIDs = (uint16_t*)(locations + totalGlyphCount);
+ glyphAdvances = xmalloc(totalGlyphCount * sizeof(Fixed));
+ totalGlyphCount = 0;
x = y = 0.0;
for (runIndex = 0; runIndex < nRuns; ++runIndex) {
@@ -2039,15 +2055,18 @@ measure_native_node(void* pNode, int use_glyph_metrics)
glyphs = xmalloc(nGlyphs * sizeof(uint32_t));
positions = xmalloc((nGlyphs * 2 + 2) * sizeof(float));
+ advances = xmalloc(nGlyphs * sizeof(float));
getGlyphs(engine, glyphs);
+ getGlyphAdvances(engine, advances);
getGlyphPositions(engine, positions);
for (i = 0; i < nGlyphs; ++i) {
- glyphIDs[realGlyphCount] = glyphs[i];
- locations[realGlyphCount].x = D2Fix(positions[2*i] + x);
- locations[realGlyphCount].y = D2Fix(positions[2*i+1] + y);
- ++realGlyphCount;
+ glyphIDs[totalGlyphCount] = glyphs[i];
+ locations[totalGlyphCount].x = D2Fix(positions[2*i] + x);
+ locations[totalGlyphCount].y = D2Fix(positions[2*i+1] + y);
+ glyphAdvances[totalGlyphCount] = D2Fix(advances[i]);
+ ++totalGlyphCount;
}
x += positions[2*i];
y += positions[2*i+1];
@@ -2055,36 +2074,39 @@ measure_native_node(void* pNode, int use_glyph_metrics)
free(glyphs);
free(positions);
}
- wid = x;
+ width = x;
}
- node_width(node) = D2Fix(wid);
- native_glyph_count(node) = realGlyphCount;
+ node_width(node) = D2Fix(width);
+ native_glyph_count(node) = totalGlyphCount;
native_glyph_info_ptr(node) = glyph_info;
- }
- else {
+ } else {
int i;
- realGlyphCount = layoutChars(engine, txtPtr, 0, txtLen, txtLen, (dir == UBIDI_RTL));
+ totalGlyphCount = layoutChars(engine, txtPtr, 0, txtLen, txtLen, (dir == UBIDI_RTL));
- glyphs = xmalloc(realGlyphCount * sizeof(uint32_t));
- positions = xmalloc((realGlyphCount * 2 + 2) * sizeof(float));
+ glyphs = xmalloc(totalGlyphCount * sizeof(uint32_t));
+ positions = xmalloc((totalGlyphCount * 2 + 2) * sizeof(float));
+ advances = xmalloc(totalGlyphCount * sizeof(float));
getGlyphs(engine, glyphs);
+ getGlyphAdvances(engine, advances);
getGlyphPositions(engine, positions);
- if (realGlyphCount > 0) {
- glyph_info = xmalloc(realGlyphCount * native_glyph_info_size);
+ if (totalGlyphCount > 0) {
+ glyph_info = xmalloc(totalGlyphCount * native_glyph_info_size);
locations = (FixedPoint*)glyph_info;
- glyphIDs = (uint16_t*)(locations + realGlyphCount);
- for (i = 0; i < realGlyphCount; ++i) {
+ glyphIDs = (uint16_t*)(locations + totalGlyphCount);
+ glyphAdvances = xmalloc(totalGlyphCount * sizeof(Fixed));
+ for (i = 0; i < totalGlyphCount; ++i) {
glyphIDs[i] = glyphs[i];
+ glyphAdvances[i] = D2Fix(advances[i]);
locations[i].x = D2Fix(positions[2*i]);
locations[i].y = D2Fix(positions[2*i+1]);
}
}
node_width(node) = D2Fix(positions[2*i]);
- native_glyph_count(node) = realGlyphCount;
+ native_glyph_count(node) = totalGlyphCount;
native_glyph_info_ptr(node) = glyph_info;
free(glyphs);
@@ -2098,8 +2120,8 @@ measure_native_node(void* pNode, int use_glyph_metrics)
Fixed lsDelta = 0;
Fixed lsUnit = fontletterspace[f];
int i;
- for (i = 0; i < realGlyphCount; ++i) {
- if (getGlyphWidth(getFont(engine), glyphIDs[i]) == 0 && lsDelta != 0)
+ for (i = 0; i < totalGlyphCount; ++i) {
+ if (glyphAdvances[i] == 0 && lsDelta != 0)
lsDelta -= lsUnit;
locations[i].x += lsDelta;
lsDelta += lsUnit;
@@ -2109,8 +2131,7 @@ measure_native_node(void* pNode, int use_glyph_metrics)
node_width(node) += lsDelta;
}
}
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `measure_native_node'\n");
exit(3);
}
@@ -2121,8 +2142,7 @@ measure_native_node(void* pNode, int use_glyph_metrics)
unless use_glyph_metrics is non-zero */
node_height(node) = heightbase[f];
node_depth(node) = depthbase[f];
- }
- else {
+ } else {
/* this iterates over the glyph data whether it comes from ATSUI or ICU layout */
FixedPoint* locations = (FixedPoint*)native_glyph_info_ptr(node);
uint16_t* glyphIDs = (uint16_t*)(locations + native_glyph_count(node));
@@ -2216,8 +2236,7 @@ measure_native_glyph(void* pNode, int use_glyph_metrics)
node_width(node) = D2Fix(GetGlyphWidth_AAT(attributes, gid));
if (use_glyph_metrics)
GetGlyphHeightDepth_AAT(attributes, gid, &ht, &dp);
- }
- else
+ } else
#endif
if (fontarea[f] == OTGR_FONT_FLAG) {
XeTeXLayoutEngine engine = (XeTeXLayoutEngine)fontlayoutengine[f];
@@ -2225,8 +2244,7 @@ measure_native_glyph(void* pNode, int use_glyph_metrics)
node_width(node) = D2Fix(getGlyphWidth(fontInst, gid));
if (use_glyph_metrics)
getGlyphHeightDepth(engine, gid, &ht, &dp);
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `measure_native_glyph'\n");
exit(3);
}
@@ -2234,8 +2252,7 @@ measure_native_glyph(void* pNode, int use_glyph_metrics)
if (use_glyph_metrics) {
node_height(node) = D2Fix(ht);
node_depth(node) = D2Fix(dp);
- }
- else {
+ } else {
node_height(node) = heightbase[f];
node_depth(node) = depthbase[f];
}
@@ -2359,14 +2376,15 @@ atsufontget1(int what, CFDictionaryRef attributes, int param)
case XeTeX_variation:
{
CFArrayRef axes = CTFontCopyVariationAxes(font);
- if (!axes)
- break;
- if (CFArrayGetCount(axes) > param) {
- CFDictionaryRef variation = CFArrayGetValueAtIndex(axes, param);
- CFNumberRef identifier = CFDictionaryGetValue(variation, kCTFontVariationAxisIdentifierKey);
- CFNumberGetValue(identifier, kCFNumberIntType, &rval);
+ if (axes) {
+ if (CFArrayGetCount(axes) > param) {
+ CFDictionaryRef variation = CFArrayGetValueAtIndex(axes, param);
+ CFNumberRef identifier = CFDictionaryGetValue(variation, kCTFontVariationAxisIdentifierKey);
+ if (identifier)
+ CFNumberGetValue(identifier, kCFNumberIntType, &rval);
+ }
+ CFRelease(axes);
}
- CFRelease(axes);
break;
}
@@ -2395,7 +2413,8 @@ atsufontget1(int what, CFDictionaryRef attributes, int param)
if (CFArrayGetCount(features) > param) {
CFDictionaryRef feature = CFArrayGetValueAtIndex(features, param);
CFNumberRef identifier = CFDictionaryGetValue(feature, kCTFontFeatureTypeIdentifierKey);
- CFNumberGetValue(identifier, kCFNumberIntType, &rval);
+ if (identifier)
+ CFNumberGetValue(identifier, kCFNumberIntType, &rval);
}
CFRelease(features);
}
@@ -2456,7 +2475,8 @@ atsufontget2(int what, CFDictionaryRef attributes, int param1, int param2)
CFNumberRef identifier;
selector = CFArrayGetValueAtIndex(selectors, param2);
identifier = CFDictionaryGetValue(selector, kCTFontFeatureSelectorIdentifierKey);
- CFNumberGetValue(identifier, kCFNumberIntType, &rval);
+ if (identifier)
+ CFNumberGetValue(identifier, kCFNumberIntType, &rval);
}
break;
case XeTeX_is_default_selector:
@@ -2495,7 +2515,8 @@ atsufontgetnamed(int what, CFDictionaryRef attributes)
(const char*)nameoffile + 1, namelength);
if (variation) {
CFNumberRef identifier = CFDictionaryGetValue(variation, kCTFontVariationAxisIdentifierKey);
- CFNumberGetValue(identifier, kCFNumberIntType, &rval);
+ if (identifier)
+ CFNumberGetValue(identifier, kCFNumberIntType, &rval);
}
CFRelease(axes);
}
@@ -2603,14 +2624,12 @@ printglyphname(integer font, integer gid)
#ifdef XETEX_MAC
if (fontarea[font] == AAT_FONT_FLAG) {
s = GetGlyphNameFromCTFont(fontFromInteger(font), gid, &len);
- }
- else
+ } else
#endif
if (fontarea[font] == OTGR_FONT_FLAG) {
XeTeXLayoutEngine engine = (XeTeXLayoutEngine)fontlayoutengine[font];
s = (char*)getGlyphName(getFont(engine), gid, &len);
- }
- else {
+ } else {
fprintf(stderr, "\n! Internal error: bad native font flag in `print_glyph_name'\n");
exit(3);
}
@@ -2641,12 +2660,10 @@ u_open_in(unicodefile* f, integer filefmt, const_string fopen_mode, integer mode
else if (B1 == 0 && B2 != 0) {
mode = UTF16BE;
rewind((*f)->f);
- }
- else if (B2 == 0 && B1 != 0) {
+ } else if (B2 == 0 && B1 != 0) {
mode = UTF16LE;
rewind((*f)->f);
- }
- else if (B1 == 0xef && B2 == 0xbb) {
+ } else if (B1 == 0xef && B2 == 0xbb) {
int B3 = getc((*f)->f);
if (B3 == 0xbf)
mode = UTF8;
@@ -2675,8 +2692,7 @@ open_dvi_output(FILE** fptr)
{
if (nopdfoutput) {
return open_output(fptr, FOPEN_WBIN_MODE);
- }
- else {
+ } else {
const char *p = (const char*)nameoffile+1;
char *cmd, *q;
int len = strlen(p);
@@ -2757,9 +2773,9 @@ dviclose(FILE* fptr)
if (nopdfoutput) {
if (fclose(fptr) != 0)
return errno;
- }
- else
+ } else {
return pclose(fptr);
+ }
return 0;
}
@@ -2820,8 +2836,7 @@ get_uni_c(UFILE* f)
rval = 0xfffd;
f->savedChar = lo;
}
- }
- else if (rval >= 0xdc00 && rval <= 0xdfff)
+ } else if (rval >= 0xdc00 && rval <= 0xdfff)
rval = 0xfffd;
}
break;
@@ -2839,8 +2854,7 @@ get_uni_c(UFILE* f)
rval = 0xfffd;
f->savedChar = lo;
}
- }
- else if (rval >= 0xdc00 && rval <= 0xdfff)
+ } else if (rval >= 0xdc00 && rval <= 0xdfff)
rval = 0xfffd;
}
break;
@@ -2889,9 +2903,9 @@ makeutf16name()
rval -= 0x10000;
*(t++) = 0xd800 + rval / 0x0400;
*(t++) = 0xdc00 + rval % 0x0400;
- }
- else
+ } else {
*(t++) = rval;
+ }
}
namelength16 = t - nameoffile16;
}
diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_ext.h b/Build/source/texk/web2c/xetexdir/XeTeX_ext.h
index dab8fba93a1..2abedb38d7e 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeX_ext.h
+++ b/Build/source/texk/web2c/xetexdir/XeTeX_ext.h
@@ -141,15 +141,6 @@ typedef uint16_t GlyphID;
/* OT-related constants we need */
#define kGSUB HB_TAG('G','S','U','B')
#define kGPOS HB_TAG('G','P','O','S')
-#define kMATH HB_TAG('M','A','T','H')
-#define kHEAD HB_TAG('h','e','a','d')
-#define kHHEA HB_TAG('h','h','e','a')
-#define kVHEA HB_TAG('v','h','e','a')
-#define kPOST HB_TAG('p','o','s','t')
-#define kHMTX HB_TAG('h','m','t','x')
-#define kVMTX HB_TAG('v','m','t','x')
-#define kMAXP HB_TAG('m','a','x','p')
-#define kOS_2 HB_TAG('O','S','/','2')
typedef struct
{
@@ -264,8 +255,6 @@ extern "C" {
double read_double(const char** s);
unsigned int read_rgb_a(const char** cp);
- const char* getGlyphNamePtr(const char* buffer, int tableSize, uint16_t gid, int* len);
-
int countpdffilepages();
int find_pic_file(char** path, realrect* bounds, int pdfBoxType, int page);
int u_open_in(unicodefile* f, integer filefmt, const char* fopen_mode, integer mode, integer encodingData);
@@ -299,7 +288,7 @@ typedef void* CFDictionaryRef; /* dummy declaration just so the stubs can compil
/* functions in XeTeX_mac.c */
void* loadAATfont(CTFontDescriptorRef descriptor, integer scaled_size, const char* cp1);
- void DoAtsuiLayout(void* node, int justify);
+ void DoAATLayout(void* node, int justify);
void GetGlyphBBox_AAT(CFDictionaryRef fontAttrs, uint16_t gid, GlyphBBox* bbox);
double GetGlyphWidth_AAT(CFDictionaryRef fontAttrs, uint16_t gid);
void GetGlyphHeightDepth_AAT(CFDictionaryRef fontAttrs, uint16_t gid, float* ht, float* dp);
@@ -308,18 +297,14 @@ typedef void* CFDictionaryRef; /* dummy declaration just so the stubs can compil
int MapCharToGlyph_AAT(CFDictionaryRef fontAttrs, UInt32 ch);
int MapGlyphToIndex_AAT(CFDictionaryRef attributes, const char* glyphName);
char* GetGlyphNameFromCTFont(CTFontRef ctFontRef, uint16_t gid, int* len);
- int GetGlyphIDFromCTFont(CTFontRef ctFontRef, const char* glyphName);
CFDictionaryRef findDictionaryInArray(CFArrayRef array, const void* nameKey, const char* name, int nameLength);
CFDictionaryRef findDictionaryInArrayWithIdentifier(CFArrayRef array, const void* identifierKey, int identifier);
CFNumberRef findSelectorByName(CFDictionaryRef feature, const char* name, int nameLength);
char* getNameFromCTFont(CTFontRef ctFontRef, CFStringRef nameKey);
- char* getFileNameFromCTFont(CTFontRef ctFontRef);
+ char* getFileNameFromCTFont(CTFontRef ctFontRef, int* index);
int GetFontCharRange_AAT(CFDictionaryRef fontAttrs, int reqFirst);
CTFontRef fontFromAttributes(CFDictionaryRef fontAttrs);
CTFontRef fontFromInteger(integer font);
- void getGlyphBBoxFromCTFont(CTFontRef ctFontRef, uint16_t gid, GlyphBBox* bbox);
- int mapCharToGlyphFromCTFont(CTFontRef font, UInt32 ch, UInt32 vs);
- double getGlyphWidthFromCTFont(CTFontRef font, uint16_t gid);
#endif
#ifdef __cplusplus
};
diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_mac.c b/Build/source/texk/web2c/xetexdir/XeTeX_mac.c
index edef3b570b7..e08556ff1b2 100644
--- a/Build/source/texk/web2c/xetexdir/XeTeX_mac.c
+++ b/Build/source/texk/web2c/xetexdir/XeTeX_mac.c
@@ -45,8 +45,6 @@ authorization from the copyright holders.
#include "XeTeX_ext.h"
#include "XeTeXLayoutInterface.h"
-#include "XeTeXswap.h"
-
static inline double
TeXtoPSPoints(double pts)
{
@@ -65,29 +63,31 @@ FixedPStoTeXPoints(double pts)
return D2Fix(PStoTeXPoints(pts));
}
-CTFontRef fontFromAttributes(CFDictionaryRef attributes)
+CTFontRef
+fontFromAttributes(CFDictionaryRef attributes)
{
return CFDictionaryGetValue(attributes, kCTFontAttributeName);
}
-CTFontRef fontFromInteger(integer font)
+CTFontRef
+fontFromInteger(integer font)
{
CFDictionaryRef attributes = (CFDictionaryRef) fontlayoutengine[font];
return fontFromAttributes(attributes);
}
void
-DoAtsuiLayout(void* p, int justify)
+DoAATLayout(void* p, int justify)
{
CFArrayRef glyphRuns;
CFIndex i, j, runCount;
- CFIndex totalGlyphCount;
- UInt16* realGlyphIDs, *glyphIDs;
+ CFIndex totalGlyphCount = 0;
+ UInt16* glyphIDs;
+ Fixed* glyphAdvances;
void* glyph_info;
FixedPoint* locations;
Fixed lsUnit, lsDelta;
- int realGlyphCount;
- CGFloat lastGlyphAdvance;
+ CGFloat width;
long txtLen;
const UniChar* txtPtr;
@@ -130,60 +130,84 @@ DoAtsuiLayout(void* p, int justify)
glyphRuns = CTLineGetGlyphRuns(line);
runCount = CFArrayGetCount(glyphRuns);
totalGlyphCount = CTLineGetGlyphCount(line);
- realGlyphIDs = xmalloc(totalGlyphCount * sizeof(UInt16));
- glyph_info = xmalloc(totalGlyphCount * native_glyph_info_size);
- locations = (FixedPoint*)glyph_info;
- lsUnit = justify ? 0 : fontletterspace[f];
- lsDelta = 0;
-
- realGlyphCount = 0;
- lastGlyphAdvance = 0;
- for (i = 0; i < runCount; i++) {
- CTRunRef run = CFArrayGetValueAtIndex(glyphRuns, i);
- CFIndex count = CTRunGetGlyphCount(run);
- // TODO(jjgod): Avoid unnecessary allocation with CTRunGetFoosPtr().
- CGGlyph* glyphs = (CGGlyph*) xmalloc(count * sizeof(CGGlyph));
- CGPoint* positions = (CGPoint*) xmalloc(count * sizeof(CGPoint));
- CGSize* advances = (CGSize*) xmalloc(count * sizeof(CGSize));
- CTRunGetGlyphs(run, CFRangeMake(0, 0), glyphs);
- CTRunGetPositions(run, CFRangeMake(0, 0), positions);
- CTRunGetAdvances(run, CFRangeMake(0, 0), advances);
- for (j = 0; j < count; j++) {
- if (glyphs[j] < 0xfffe) {
- realGlyphIDs[realGlyphCount] = glyphs[j];
- locations[realGlyphCount].x = FixedPStoTeXPoints(positions[j].x) + lsDelta;
- lastGlyphAdvance = advances[j].width;
- locations[realGlyphCount].y = FixedPStoTeXPoints(positions[j].y);
- lsDelta += lsUnit;
- realGlyphCount++;
+
+ if (totalGlyphCount > 0) {
+ glyph_info = xmalloc(totalGlyphCount * native_glyph_info_size);
+ locations = (FixedPoint*)glyph_info;
+ glyphIDs = (UInt16*)(locations + totalGlyphCount);
+ glyphAdvances = xmalloc(totalGlyphCount * sizeof(Fixed));
+ totalGlyphCount = 0;
+
+ width = 0;
+ for (i = 0; i < runCount; i++) {
+ CTRunRef run = CFArrayGetValueAtIndex(glyphRuns, i);
+ CFIndex count = CTRunGetGlyphCount(run);
+ CFDictionaryRef runAttributes = CTRunGetAttributes(run);
+ // TODO(jjgod): Avoid unnecessary allocation with CTRunGetFoosPtr().
+ CGGlyph* glyphs = (CGGlyph*) xmalloc(count * sizeof(CGGlyph));
+ CGPoint* positions = (CGPoint*) xmalloc(count * sizeof(CGPoint));
+ CGSize* advances = (CGSize*) xmalloc(count * sizeof(CGSize));
+ CGFloat runWidth = CTRunGetTypographicBounds(run, CFRangeMake(0, 0), NULL, NULL, NULL);
+ CTRunGetGlyphs(run, CFRangeMake(0, 0), glyphs);
+ CTRunGetPositions(run, CFRangeMake(0, 0), positions);
+ CTRunGetAdvances(run, CFRangeMake(0, 0), advances);
+ for (j = 0; j < count; j++) {
+ // XXX Core Text has that font cascading thing that will do
+ // font substitution for missing glyphs, which we do not want
+ // but I can not find a way to disable it yet, so if the font
+ // of the resulting run is not the same font we asked for, use
+ // the glyph at index 0 (usually .notdef) instead or we will be
+ // showing garbage or even invalid glyphs
+ if (fontFromAttributes(attributes) != fontFromAttributes(runAttributes))
+ glyphIDs[totalGlyphCount] = 0;
+ else
+ glyphIDs[totalGlyphCount] = glyphs[j];
+ locations[totalGlyphCount].x = FixedPStoTeXPoints(positions[j].x);
+ // XXX trasformation matrix changes y positions!
+ //locations[totalGlyphCount].y = FixedPStoTeXPoints(positions[j].y);
+ locations[totalGlyphCount].y = 0;
+ glyphAdvances[totalGlyphCount] = advances[j].width;
+ totalGlyphCount++;
}
+ width += FixedPStoTeXPoints(runWidth);
+ free(glyphs);
+ free(positions);
}
- free(advances);
- free(glyphs);
- free(positions);
}
- if (lsDelta != 0)
- lsDelta -= lsUnit;
- glyphIDs = (UInt16*)(locations + realGlyphCount);
- memcpy(glyphIDs, realGlyphIDs, realGlyphCount * sizeof(UInt16));
- free(realGlyphIDs);
-
- native_glyph_count(node) = realGlyphCount;
+ native_glyph_count(node) = totalGlyphCount;
native_glyph_info_ptr(node) = glyph_info;
if (!justify) {
- node_width(node) =
- (realGlyphCount > 0 ? locations[realGlyphCount - 1].x : 0) +
- FixedPStoTeXPoints(lastGlyphAdvance) +
- lsDelta;
+ node_width(node) = width;
+
+ if (totalGlyphCount > 0) {
+ /* this is essentially a copy from similar code in XeTeX_ext.c, easier
+ * to be done here */
+ if (fontletterspace[f] != 0) {
+ Fixed lsDelta = 0;
+ Fixed lsUnit = fontletterspace[f];
+ int i;
+ for (i = 0; i < totalGlyphCount; ++i) {
+ if (glyphAdvances[i] == 0 && lsDelta != 0)
+ lsDelta -= lsUnit;
+ locations[i].x += lsDelta;
+ lsDelta += lsUnit;
+ }
+ if (lsDelta != 0) {
+ lsDelta -= lsUnit;
+ node_width(node) += lsDelta;
+ }
+ }
+ }
}
CFRelease(line);
CFRelease(typesetter);
}
-void getGlyphBBoxFromCTFont(CTFontRef font, UInt16 gid, GlyphBBox* bbox)
+static void
+getGlyphBBoxFromCTFont(CTFontRef font, UInt16 gid, GlyphBBox* bbox)
{
CGRect rect;
@@ -206,27 +230,31 @@ void getGlyphBBoxFromCTFont(CTFontRef font, UInt16 gid, GlyphBBox* bbox)
}
}
-void GetGlyphBBox_AAT(CFDictionaryRef attributes, UInt16 gid, GlyphBBox* bbox)
+void
+GetGlyphBBox_AAT(CFDictionaryRef attributes, UInt16 gid, GlyphBBox* bbox)
/* returns glyph bounding box in TeX points */
{
CTFontRef font = fontFromAttributes(attributes);
return getGlyphBBoxFromCTFont(font, gid, bbox);
}
-double getGlyphWidthFromCTFont(CTFontRef font, UInt16 gid)
+static double
+getGlyphWidthFromCTFont(CTFontRef font, UInt16 gid)
{
CGSize advances[1] = { CGSizeMake(0, 0) };
return PStoTeXPoints(CTFontGetAdvancesForGlyphs(font, 0, &gid, advances, 1));
}
-double GetGlyphWidth_AAT(CFDictionaryRef attributes, UInt16 gid)
+double
+GetGlyphWidth_AAT(CFDictionaryRef attributes, UInt16 gid)
/* returns TeX points */
{
CTFontRef font = fontFromAttributes(attributes);
return getGlyphWidthFromCTFont(font, gid);
}
-void GetGlyphHeightDepth_AAT(CFDictionaryRef attributes, UInt16 gid, float* ht, float* dp)
+void
+GetGlyphHeightDepth_AAT(CFDictionaryRef attributes, UInt16 gid, float* ht, float* dp)
/* returns TeX points */
{
GlyphBBox bbox;
@@ -237,7 +265,8 @@ void GetGlyphHeightDepth_AAT(CFDictionaryRef attributes, UInt16 gid, float* ht,
*dp = -bbox.yMin;
}
-void GetGlyphSidebearings_AAT(CFDictionaryRef attributes, UInt16 gid, float* lsb, float* rsb)
+void
+GetGlyphSidebearings_AAT(CFDictionaryRef attributes, UInt16 gid, float* lsb, float* rsb)
/* returns TeX points */
{
CTFontRef font = fontFromAttributes(attributes);
@@ -249,7 +278,8 @@ void GetGlyphSidebearings_AAT(CFDictionaryRef attributes, UInt16 gid, float* lsb
*rsb = PStoTeXPoints(advance) - bbox.xMax;
}
-double GetGlyphItalCorr_AAT(CFDictionaryRef attributes, UInt16 gid)
+double
+GetGlyphItalCorr_AAT(CFDictionaryRef attributes, UInt16 gid)
{
CTFontRef font = fontFromAttributes(attributes);
CGSize advances[1] = { CGSizeMake(0, 0) };
@@ -263,10 +293,11 @@ double GetGlyphItalCorr_AAT(CFDictionaryRef attributes, UInt16 gid)
return 0;
}
-int mapCharToGlyphFromCTFont(CTFontRef font, UInt32 ch, UInt32 vs)
+static int
+mapCharToGlyphFromCTFont(CTFontRef font, UInt32 ch)
{
CGGlyph glyphs[2] = { 0 };
- UniChar txt[4];
+ UniChar txt[2];
int len = 1;
if (ch > 0xffff) {
@@ -274,20 +305,8 @@ int mapCharToGlyphFromCTFont(CTFontRef font, UInt32 ch, UInt32 vs)
txt[0] = 0xd800 + ch / 1024;
txt[1] = 0xdc00 + ch % 1024;
len = 2;
- }
- else
+ } else {
txt[0] = ch;
-
- if (vs) {
- if (vs > 0xffff) {
- vs -= 0x10000;
- txt[len] = 0xd800 + vs / 1024;
- txt[len + 1] = 0xdc00 + vs % 1024;
- len += 2;
- } else {
- txt[len] = vs;
- len += 1;
- }
}
if (CTFontGetGlyphsForCharacters(font, txt, glyphs, len))
@@ -296,19 +315,15 @@ int mapCharToGlyphFromCTFont(CTFontRef font, UInt32 ch, UInt32 vs)
return 0;
}
-int MapCharToGlyph_AAT(CFDictionaryRef attributes, UInt32 ch)
-{
- CTFontRef font = fontFromAttributes(attributes);
- return mapCharToGlyphFromCTFont(font, ch, 0);
-}
-
-int MapGlyphToIndex_AAT(CFDictionaryRef attributes, const char* glyphName)
+int
+MapCharToGlyph_AAT(CFDictionaryRef attributes, UInt32 ch)
{
CTFontRef font = fontFromAttributes(attributes);
- return GetGlyphIDFromCTFont(font, glyphName);
+ return mapCharToGlyphFromCTFont(font, ch);
}
-int GetGlyphIDFromCTFont(CTFontRef ctFontRef, const char* glyphName)
+static int
+GetGlyphIDFromCTFont(CTFontRef ctFontRef, const char* glyphName)
{
CFStringRef glyphname = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
glyphName,
@@ -319,6 +334,13 @@ int GetGlyphIDFromCTFont(CTFontRef ctFontRef, const char* glyphName)
return rval;
}
+int
+MapGlyphToIndex_AAT(CFDictionaryRef attributes, const char* glyphName)
+{
+ CTFontRef font = fontFromAttributes(attributes);
+ return GetGlyphIDFromCTFont(font, glyphName);
+}
+
char*
GetGlyphNameFromCTFont(CTFontRef ctFontRef, UInt16 gid, int* len)
{
@@ -350,8 +372,7 @@ GetFontCharRange_AAT(CFDictionaryRef attributes, int reqFirst)
while (MapCharToGlyph_AAT(attributes, ch) == 0 && ch < 0x10ffff)
++ch;
return ch;
- }
- else {
+ } else {
int ch = 0x10ffff;
while (MapCharToGlyph_AAT(attributes, ch) == 0 && ch > 0)
--ch;
@@ -359,7 +380,8 @@ GetFontCharRange_AAT(CFDictionaryRef attributes, int reqFirst)
}
}
-char* getNameFromCTFont(CTFontRef ctFontRef, CFStringRef nameKey)
+char*
+getNameFromCTFont(CTFontRef ctFontRef, CFStringRef nameKey)
{
char *buf;
CFStringRef name = CTFontCopyName(ctFontRef, nameKey);
@@ -372,7 +394,8 @@ char* getNameFromCTFont(CTFontRef ctFontRef, CFStringRef nameKey)
return 0;
}
-char* getFileNameFromCTFont(CTFontRef ctFontRef)
+char*
+getFileNameFromCTFont(CTFontRef ctFontRef, int *index)
{
char *ret = NULL;
CFURLRef url = NULL;
@@ -392,42 +415,43 @@ char* getFileNameFromCTFont(CTFontRef ctFontRef)
if (url) {
UInt8 pathname[PATH_MAX];
if (CFURLGetFileSystemRepresentation(url, true, pathname, PATH_MAX)) {
- int index = 0;
- char buf[20];
-
- /* finding face index by searching for preceding font ids with the same FSRef */
- /* logic copied from FreeType but without using ATS/FS APIs */
- ATSFontRef id1 = CTFontGetPlatformFont(ctFontRef, NULL);
- ATSFontRef id2 = id1 - 1;
- while (id2 > 0) {
- FSRef dummy;
- CTFontRef ctFontRef2;
- CFURLRef url2;
- if (noErr != ATSFontGetFileReference(id2, &dummy)) /* check if id2 is valid, any better way? */
- break;
- ctFontRef2 = CTFontCreateWithPlatformFont(id2, 0.0, NULL, NULL);
-#if !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
- status = ATSFontGetFileReference(id2, &fsref);
- if (status == noErr)
- url2 = CFURLCreateFromFSRef(NULL, &fsref);
-#else
- url2 = (CFURLRef) CTFontCopyAttribute(ctFontRef2, kCTFontURLAttribute);
-#endif
- if (!url2)
- break;
- if (!CFEqual(url, url2))
- break;
- id2--;
+ FT_Error error;
+ FT_Face face;
+
+ *index = 0;
+
+ if (!gFreeTypeLibrary) {
+ error = FT_Init_FreeType(&gFreeTypeLibrary);
+ if (error) {
+ fprintf(stderr, "FreeType initialization failed! (%d)\n", error);
+ exit(1);
+ }
}
- index = id1 - (id2 + 1);
- if (index > 0)
- sprintf(buf, ":%d", index);
- else
- buf[0] = '\0';
+ error = FT_New_Face(gFreeTypeLibrary, pathname, 0, &face);
+ if (!error) {
+ if (face->num_faces > 1) {
+ int num_faces = face->num_faces;
+ char *ps_name1 = getNameFromCTFont(ctFontRef, kCTFontPostScriptNameKey);
+ int i;
+ *index = -1;
+ FT_Done_Face (face);
+ for (i = 0; i < num_faces; i++) {
+ error = FT_New_Face (gFreeTypeLibrary, pathname, i, &face);
+ if (!error) {
+ const char *ps_name2 = FT_Get_Postscript_Name(face);
+ if (strcmp(ps_name1, ps_name2) == 0) {
+ *index = i;
+ break;
+ }
+ FT_Done_Face (face);
+ }
+ }
+ }
+ }
- ret = xmalloc(strlen((char*) pathname) + 2 + strlen(buf) + 1);
- sprintf(ret, "[%s%s]", pathname, buf);
+ if (*index != -1)
+ ret = strdup(pathname);
}
CFRelease(url);
}
@@ -435,9 +459,8 @@ char* getFileNameFromCTFont(CTFontRef ctFontRef)
return ret;
}
-CFDictionaryRef findDictionaryInArrayWithIdentifier(CFArrayRef array,
- const void* identifierKey,
- int identifier)
+CFDictionaryRef
+findDictionaryInArrayWithIdentifier(CFArrayRef array, const void* identifierKey, int identifier)
{
CFDictionaryRef dict = NULL;
@@ -459,8 +482,8 @@ CFDictionaryRef findDictionaryInArrayWithIdentifier(CFArrayRef array,
return dict;
}
-CFDictionaryRef findDictionaryInArray(CFArrayRef array, const void* nameKey,
- const char* name, int nameLength)
+CFDictionaryRef
+findDictionaryInArray(CFArrayRef array, const void* nameKey, const char* name, int nameLength)
{
CFDictionaryRef dict = NULL;
@@ -482,18 +505,21 @@ CFDictionaryRef findDictionaryInArray(CFArrayRef array, const void* nameKey,
return dict;
}
-CFNumberRef findSelectorByName(CFDictionaryRef feature, const char* name, int nameLength)
+CFNumberRef
+findSelectorByName(CFDictionaryRef feature, const char* name, int nameLength)
{
- CFArrayRef selectors = CFDictionaryGetValue(feature, kCTFontFeatureTypeSelectorsKey);
- CFDictionaryRef s = findDictionaryInArray(selectors, kCTFontFeatureSelectorNameKey, name, nameLength);
CFNumberRef selector = NULL;
- if (s)
- selector = CFDictionaryGetValue(s, kCTFontFeatureSelectorIdentifierKey);
+ CFArrayRef selectors = CFDictionaryGetValue(feature, kCTFontFeatureTypeSelectorsKey);
+ if (selectors) {
+ CFDictionaryRef s = findDictionaryInArray(selectors, kCTFontFeatureSelectorNameKey, name, nameLength);
+ if (s)
+ selector = CFDictionaryGetValue(s, kCTFontFeatureSelectorIdentifierKey);
+ }
return selector;
}
-static CFDictionaryRef createFeatureSettingDictionary(CFNumberRef featureTypeIdentifier,
- CFNumberRef featureSelectorIdentifier)
+static CFDictionaryRef
+createFeatureSettingDictionary(CFNumberRef featureTypeIdentifier, CFNumberRef featureSelectorIdentifier)
{
const void* settingKeys[] = { kCTFontFeatureTypeIdentifierKey, kCTFontFeatureSelectorIdentifierKey };
const void* settingValues[] = { featureTypeIdentifier, featureSelectorIdentifier };
@@ -632,17 +658,16 @@ loadAATfont(CTFontDescriptorRef descriptor, integer scaled_size, const char* cp1
if (decimal != 1.0) {
value += v / decimal;
decimal *= 10.0;
- }
- else
+ } else {
value = value * 10.0 + v;
- }
- else if (*cp3 == '.') {
+ }
+ } else if (*cp3 == '.') {
if (decimal != 1.0)
break;
decimal = 10.0;
- }
- else
+ } else {
break;
+ }
++cp3;
}
if (negate)
@@ -729,6 +754,7 @@ loadAATfont(CTFontDescriptorRef descriptor, integer scaled_size, const char* cp1
}
matrix = CGAffineTransformIdentity;
+ // XXX this breaks y glyph positioning
if (extend != 1.0 || slant != 0.0)
matrix = CGAffineTransformMake(extend, slant, 0, 1.0, 0, 0);
@@ -743,6 +769,16 @@ loadAATfont(CTFontDescriptorRef descriptor, integer scaled_size, const char* cp1
if (letterspace != 0.0)
loadedfontletterspace = (letterspace / 100.0) * scaled_size;
+ // Disable Core Text font fallback (cascading) with only the last resort font
+ // in the cascade list.
+ CFMutableArrayRef cascadeList = CFArrayCreateMutable(NULL, 1, &kCFTypeArrayCallBacks);
+ cascadeList = CFArrayCreateMutable(NULL, 1, &kCFTypeArrayCallBacks);
+ CTFontDescriptorRef lastResort = CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0);
+ CFArrayAppendValue(cascadeList, lastResort);
+ CFRelease(lastResort);
+ CFDictionaryAddValue(attributes, kCTFontCascadeListAttribute, cascadeList);
+ CFRelease(cascadeList);
+
descriptor = CTFontDescriptorCreateWithAttributes(attributes);
CFRelease(attributes);
actualFont = CTFontCreateCopyWithAttributes(font, ctSize, &matrix, descriptor);
@@ -836,8 +872,7 @@ find_pic_file(char** path, realrect* bounds, int pdfBoxType, int page)
CGPDFDocumentRelease(document);
result = noErr;
}
- }
- else {
+ } else {
CGImageSourceRef picFileSource = CGImageSourceCreateWithURL(picFileURL, NULL);
if (picFileSource) {
CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(picFileSource, 0, NULL);
diff --git a/Build/source/texk/web2c/xetexdir/am/xetex.am b/Build/source/texk/web2c/xetexdir/am/xetex.am
index 821625540d7..9fca6871091 100644
--- a/Build/source/texk/web2c/xetexdir/am/xetex.am
+++ b/Build/source/texk/web2c/xetexdir/am/xetex.am
@@ -122,12 +122,8 @@ libxetex_a_OBJCXXFLAGS = # $(WARNING_OBJCXXFLAGS)
libxetex_a_SOURCES = \
xetexdir/MathTable.h \
- xetexdir/FontTableCache.cpp \
- xetexdir/FontTableCache.h \
xetexdir/XeTeXFontInst.cpp \
xetexdir/XeTeXFontInst.h \
- xetexdir/XeTeXFontInst_FT2.cpp \
- xetexdir/XeTeXFontInst_FT2.h \
xetexdir/XeTeXFontMgr.cpp \
xetexdir/XeTeXFontMgr.h \
xetexdir/XeTeXLayoutInterface.cpp \
@@ -137,15 +133,11 @@ libxetex_a_SOURCES = \
xetexdir/XeTeX_ext.c \
xetexdir/XeTeX_ext.h \
xetexdir/XeTeXswap.h \
- xetexdir/sfnt.h \
xetexdir/trans.c \
xetexdir/trans.h \
xetexdir/hz.cpp \
xetexdir/xetex.h
-## included by xetexdir/XeTeXLayoutInterface.cpp
-EXTRA_DIST += xetexdir/appleGlyphNames.c
-
if XETEX_MACOSX
libxetex_a_SOURCES += \
diff --git a/Build/source/texk/web2c/xetexdir/appleGlyphNames.c b/Build/source/texk/web2c/xetexdir/appleGlyphNames.c
deleted file mode 100644
index 59a38fdff61..00000000000
--- a/Build/source/texk/web2c/xetexdir/appleGlyphNames.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/****************************************************************************\
- Part of the XeTeX typesetting system
- Copyright (c) 1994-2008 by SIL International
- Copyright (c) 2009 by Jonathan Kew
-
- SIL Author(s): 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 THE COPYRIGHT HOLDERS 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 the copyright holders
-shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written
-authorization from the copyright holders.
-\****************************************************************************/
-
-const char* appleGlyphNames[] = {
- ".notdef",
- ".null",
- "nonmarkingreturn",
- "space",
- "exclam",
- "quotedbl",
- "numbersign",
- "dollar",
- "percent",
- "ampersand",
- "quotesingle",
- "parenleft",
- "parenright",
- "asterisk",
- "plus",
- "comma",
- "hyphen",
- "period",
- "slash",
- "zero",
- "one",
- "two",
- "three",
- "four",
- "five",
- "six",
- "seven",
- "eight",
- "nine",
- "colon",
- "semicolon",
- "less",
- "equal",
- "greater",
- "question",
- "at",
- "A",
- "B",
- "C",
- "D",
- "E",
- "F",
- "G",
- "H",
- "I",
- "J",
- "K",
- "L",
- "M",
- "N",
- "O",
- "P",
- "Q",
- "R",
- "S",
- "T",
- "U",
- "V",
- "W",
- "X",
- "Y",
- "Z",
- "bracketleft",
- "backslash",
- "bracketright",
- "asciicircum",
- "underscore",
- "grave",
- "a",
- "b",
- "c",
- "d",
- "e",
- "f",
- "g",
- "h",
- "i",
- "j",
- "k",
- "l",
- "m",
- "n",
- "o",
- "p",
- "q",
- "r",
- "s",
- "t",
- "u",
- "v",
- "w",
- "x",
- "y",
- "z",
- "braceleft",
- "bar",
- "braceright",
- "asciitilde",
- "Adieresis",
- "Aring",
- "Ccedilla",
- "Eacute",
- "Ntilde",
- "Odieresis",
- "Udieresis",
- "aacute",
- "agrave",
- "acircumflex",
- "adieresis",
- "atilde",
- "aring",
- "ccedilla",
- "eacute",
- "egrave",
- "ecircumflex",
- "edieresis",
- "iacute",
- "igrave",
- "icircumflex",
- "idieresis",
- "ntilde",
- "oacute",
- "ograve",
- "ocircumflex",
- "odieresis",
- "otilde",
- "uacute",
- "ugrave",
- "ucircumflex",
- "udieresis",
- "dagger",
- "degree",
- "cent",
- "sterling",
- "section",
- "bullet",
- "paragraph",
- "germandbls",
- "registered",
- "copyright",
- "trademark",
- "acute",
- "dieresis",
- "notequal",
- "AE",
- "Oslash",
- "infinity",
- "plusminus",
- "lessequal",
- "greaterequal",
- "yen",
- "mu",
- "partialdiff",
- "summation",
- "product",
- "pi",
- "integral",
- "ordfeminine",
- "ordmasculine",
- "Omega",
- "ae",
- "oslash",
- "questiondown",
- "exclamdown",
- "logicalnot",
- "radical",
- "florin",
- "approxequal",
- "Delta",
- "guillemotleft",
- "guillemotright",
- "ellipsis",
- "nonbreakingspace",
- "Agrave",
- "Atilde",
- "Otilde",
- "OE",
- "oe",
- "endash",
- "emdash",
- "quotedblleft",
- "quotedblright",
- "quoteleft",
- "quoteright",
- "divide",
- "lozenge",
- "ydieresis",
- "Ydieresis",
- "fraction",
- "currency",
- "guilsinglleft",
- "guilsinglright",
- "fi",
- "fl",
- "daggerdbl",
- "periodcentered",
- "quotesinglbase",
- "quotedblbase",
- "perthousand",
- "Acircumflex",
- "Ecircumflex",
- "Aacute",
- "Edieresis",
- "Egrave",
- "Iacute",
- "Icircumflex",
- "Idieresis",
- "Igrave",
- "Oacute",
- "Ocircumflex",
- "apple",
- "Ograve",
- "Uacute",
- "Ucircumflex",
- "Ugrave",
- "dotlessi",
- "circumflex",
- "tilde",
- "macron",
- "breve",
- "dotaccent",
- "ring",
- "cedilla",
- "hungarumlaut",
- "ogonek",
- "caron",
- "Lslash",
- "lslash",
- "Scaron",
- "scaron",
- "Zcaron",
- "zcaron",
- "brokenbar",
- "Eth",
- "eth",
- "Yacute",
- "yacute",
- "Thorn",
- "thorn",
- "minus",
- "multiply",
- "onesuperior",
- "twosuperior",
- "threesuperior",
- "onehalf",
- "onequarter",
- "threequarters",
- "franc",
- "Gbreve",
- "gbreve",
- "Idotaccent",
- "Scedilla",
- "scedilla",
- "Cacute",
- "cacute",
- "Ccaron",
- "ccaron",
- "dcroat",
- 0
-};
diff --git a/Build/source/texk/web2c/xetexdir/sfnt.h b/Build/source/texk/web2c/xetexdir/sfnt.h
deleted file mode 100644
index 6844154c34e..00000000000
--- a/Build/source/texk/web2c/xetexdir/sfnt.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************\
- Part of the XeTeX typesetting system
- Copyright (c) 1994-2008 by SIL International
- Copyright (c) 2009 by Jonathan Kew
-
- SIL Author(s): 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 THE COPYRIGHT HOLDERS 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 the copyright holders
-shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written
-authorization from the copyright holders.
-\****************************************************************************/
-
-/* from ICU sample code, extended by JK for XeTeX */
-
-/***************************************************************************
-*
-* Copyright (C) 1998-2002, International Business Machines
-* Corporation and others. All Rights Reserved.
-*
-************************************************************************/
-
-#ifndef __SFNT_H
-#define __SFNT_H
-
-#ifndef ANY_NUMBER
-#define ANY_NUMBER 1
-#endif
-
-typedef int32_t fixed;
-
-typedef struct
-{
- uint32_t bc;
- uint32_t ad;
-} BigDate;
-
-struct HEADTable
-{
- fixed version;
- fixed fontRevision;
- uint32_t checksumAdjustment;
- uint32_t magicNumber;
- uint16_t flags;
- uint16_t unitsPerEm;
- BigDate created;
- BigDate modified;
- int16_t xMin;
- int16_t yMin;
- int16_t xMax;
- int16_t yMax;
- uint16_t macStyle;
- uint16_t lowestRecPPEM;
- int16_t fontDirectionHint;
- int16_t indexToLocFormat;
- int16_t glyphDataFormat;
-};
-
-struct MAXPTable
-{
- fixed version;
- uint16_t numGlyphs;
- uint16_t maxPoints;
- uint16_t maxContours;
- uint16_t maxComponentPoints;
- uint16_t maxComponentContours;
- uint16_t maxZones;
- uint16_t maxTwilightPoints;
- uint16_t maxStorage;
- uint16_t maxFunctionDefs;
- uint16_t maxInstructionDefs;
- uint16_t maxStackElements;
- uint16_t maxSizeOfInstructions;
- uint16_t maxComponentElements;
- uint16_t maxComponentDepth;
-};
-
-struct HHEATable
-{
- fixed version;
- int16_t ascent;
- int16_t descent;
- int16_t lineGap;
- uint16_t advanceWidthMax;
- int16_t minLeftSideBearing;
- int16_t minRightSideBearing;
- int16_t xMaxExtent;
- int16_t caretSlopeRise;
- int16_t caretSlopeRun;
- int16_t caretOffset;
- int16_t reserved1;
- int16_t reserved2;
- int16_t reserved3;
- int16_t reserved4;
- int16_t metricDataFormat;
- uint16_t numOfLongHorMetrics;
-};
-
-typedef struct
-{
- uint16_t advanceWidth;
- int16_t leftSideBearing;
-} LongHorMetric;
-
-struct HMTXTable
-{
- LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table
-// int16_t leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics
-};
-
-struct POSTTable
-{
- fixed version;
- fixed italicAngle;
- int16_t underlinePosition;
- uint16_t underlineThickness;
- uint32_t isFixedPitch;
- uint32_t minMemType42;
- uint32_t maxMemType42;
- uint32_t minMemType1;
- uint32_t maxMemType1;
-};
-
-struct OS2TableHeader {
- uint16_t version;
- int16_t xAvgCharWidth;
- uint16_t usWeightClass;
- uint16_t usWidthClass;
- int16_t fsType;
- int16_t ySubscriptXSize;
- int16_t ySubscriptYSize;
- int16_t ySubscriptXOffset;
- int16_t ySubscriptYOffset;
- int16_t ySuperscriptXSize;
- int16_t ySuperscriptYSize;
- int16_t ySuperscriptXOffset;
- int16_t ySuperscriptYOffset;
- int16_t yStrikeoutSize;
- int16_t yStrikeoutPosition;
- int16_t sFamilyClass;
- uint8_t panose[10];
- uint8_t ulCharRange[16]; // spec'd as 4 longs, but do this to keep structure packed
- int8_t achVendID[4];
- uint16_t fsSelection;
- uint16_t fsFirstCharIndex;
- uint16_t fsLastCharIndex;
-};
-
-#endif
-
diff --git a/Build/source/texk/web2c/xetexdir/xetex.web b/Build/source/texk/web2c/xetexdir/xetex.web
index dbf73b47b3c..dd255884bcd 100644
--- a/Build/source/texk/web2c/xetexdir/xetex.web
+++ b/Build/source/texk/web2c/xetexdir/xetex.web
@@ -210,7 +210,7 @@
\def\gglob{20, 26} % this should be the next two sections of "<Global...>"
@* \[1] Introduction.
-This is \eTeX, a program derived from and extending the capabilities of
+This is \XeTeX, a program derived from and extending the capabilities of
\TeX, a document compiler intended to produce typesetting of high
quality.
The \PASCAL\ program that follows is the definition of \TeX82, a standard
@@ -301,7 +301,7 @@ undergoes any modifications, so that it will be clear which version of
@^system dependencies@>
This program contains code for various features extending \TeX,
-therefore this program is called `\eTeX' and not
+therefore this program is called `\XeTeX' and not
`\TeX'; the official name `\TeX' by itself is reserved
for software systems that are fully compatible with each other.
A special test suite called the ``\.{TRIP} test'' is available for
@@ -317,8 +317,8 @@ known as `\eTeX'.
@d eTeX_revision==".5" { \.{\\eTeXrevision} }
@d eTeX_version_string=='-2.5' {current \eTeX\ version}
@#
-@d XeTeX_version=0
-@d XeTeX_revision==".9999"
+@d XeTeX_version=0 { \.{\\XeTeXversion} }
+@d XeTeX_revision==".9999" { \.{\\XeTeXrevision} }
@d XeTeX_version_string=='-0.9999' {current \XeTeX\ version}
@#
@d XeTeX_banner=='This is XeTeX, Version 3.1415926',eTeX_version_string,XeTeX_version_string
@@ -330,25 +330,25 @@ known as `\eTeX'.
@#
@d TeXXeT_code=0 {the \TeXXeT\ feature is optional}
@#
-@d XeTeX_dash_break_code = 1 {non-zero to enable breaks after en- and em-dashes}
+@d XeTeX_dash_break_code=1 {non-zero to enable breaks after en- and em-dashes}
@#
-@d XeTeX_upwards_code = 2 {non-zero if the main vertical list is being built upwards}
-@d XeTeX_use_glyph_metrics_code = 3 {non-zero to use exact glyph height/depth}
-@d XeTeX_inter_char_tokens_code = 4 {non-zero to enable \\XeTeXinterchartokens insertion}
+@d XeTeX_upwards_code=2 {non-zero if the main vertical list is being built upwards}
+@d XeTeX_use_glyph_metrics_code=3 {non-zero to use exact glyph height/depth}
+@d XeTeX_inter_char_tokens_code=4 {non-zero to enable \.{\\XeTeXinterchartokens} insertion}
@#
-@d XeTeX_input_normalization_code = 5 {normalization mode: 1 = NFC, 2 = NFD, else none}
+@d XeTeX_input_normalization_code=5 {normalization mode:, 1 for NFC, 2 for NFD, else none}
@#
-@d XeTeX_default_input_mode_code = 6 {input mode for newly opened files}
-@d XeTeX_input_mode_auto = 0
-@d XeTeX_input_mode_utf8 = 1
-@d XeTeX_input_mode_utf16be = 2
-@d XeTeX_input_mode_utf16le = 3
-@d XeTeX_input_mode_raw = 4
-@d XeTeX_input_mode_icu_mapping = 5
+@d XeTeX_default_input_mode_code=6 {input mode for newly opened files}
+@d XeTeX_input_mode_auto=0
+@d XeTeX_input_mode_utf8=1
+@d XeTeX_input_mode_utf16be=2
+@d XeTeX_input_mode_utf16le=3
+@d XeTeX_input_mode_raw=4
+@d XeTeX_input_mode_icu_mapping=5
@#
-@d XeTeX_default_input_encoding_code = 7 {|str_number| of encoding name if mode = ICU}
+@d XeTeX_default_input_encoding_code=7 {|str_number| of encoding name if |mode =| ICU}
@#
-@d XeTeX_tracing_fonts_code = 8 {non-zero to log native fonts used}
+@d XeTeX_tracing_fonts_code=8 {non-zero to log native fonts used}
@d eTeX_states=9 {number of \eTeX\ state variables in |eqtb|}
@ Different \PASCAL s have slightly different conventions, and the present
@@ -13047,29 +13047,27 @@ file. Parameters |i|, |num|, |den|, |mag|, |k|, and |x| are explained below.
\yskip\hang|post_post| 249. Ending of the postamble, see below.
-\yskip\hang|set_glyph_string| 254 w[4] k[2] x[4k] g[2k].
+\yskip\hang|pic_file| 251 |flags[1]| |t[4][6]| |p[2]| |len[2]| |path[l]|.
+ |flags=0| for raster image, and |1| for \.{PDF}.
+ |t| is transform matrix.
+ |p| is page number from the graphic file (0-based).
+ |len| is length of pathname.
+ |path| is pathname of graphic file.
-\yskip\hang|set_glyph_array| 253 w[4] k[2] xy[8k] g[2k]
+\yskip\hang\vbox{\halign{#&#\hfil\cr
+|define_native_font| 252 & |k[4]| |s[4]| |flags[2]| |lenps[1]| |lenfam[1]| |lensty[1]| |ps[lenps]| |fam[lenfam]| |sty[lensty]|\cr
+& |if (flags and COLORED) then| |rgba[4]|\cr
+& |if (flags and VARIATIONS) then| |numvars[2]| |axes[4nv]| |values[4nv]|\cr
+& |if (flags and MATRIX) then| |ta[4]| |tb[4]| |tc[4]| |td[4]| |tx[4]| |ty[4]|\cr
+}}
-\yskip\hang|define_native_font| 252 k[4] s[4] flags[2]
- lenps[1] lenfam[1] lensty[1] ps[lenps] fam[lenfam] sty[lensty]
- if (flags AND COLORED):
- rgba[4]
- if (flags AND VARIATIONS):
- numvars[2]
- axes[4nv]
- values[4nv]
- if (flags AND MATRIX):
- ta[4] tb[4] tc[4] td[4] tx[4] ty[4]
+\yskip\hang|set_glyph_array| 253 |w[4]| |k[2]| |xy[8k]| |g[2k]|.
-\yskip\hang|pic_file| 251 flags[1] t[4][6] p[2] len[2] path[l]
- flags = 0 for raster image, 1 for PDF
- t is transform matrix
- p is page \# from the graphic file (0-based)
- len is length of pathname
- path is pathname of graphic file
+\yskip\hang|set_glyph_string| 254 |w[4]| |k[2]| |x[4k]| |g[2k]|.
-\yskip\noindent Commands 250 and 255 are undefined at the present time (but 255 is used by pTeX).
+\yskip\noindent Commands 250--255 are undefined in normal \.{DVI} files,
+but 251--254 are permitted in the extended `\.{XDV}' files
+produced by \XeTeX. p\TeX\ uses 255.
@ @d set_char_0=0 {typeset character 0 and move right}
@d set1=128 {typeset a character and move right}
@@ -13099,10 +13097,10 @@ file. Parameters |i|, |num|, |den|, |mag|, |k|, and |x| are explained below.
@d post=248 {postamble beginning}
@d post_post=249 {postamble ending}
-@d set_glyph_string=254 {sequence of glyphs, all at the current y-position}
-@d set_glyph_array=253 {sequence of glyphs with individual x-y coordinates}
-@d define_native_font=252 {define native font}
@d pic_file=251 {embed picture or PDF}
+@d define_native_font=252 {define native font}
+@d set_glyph_array=253 {sequence of glyphs with individual x-y coordinates}
+@d set_glyph_string=254 {sequence of glyphs, all at the current y-position}
@ The preamble contains basic information about the file as a whole. As
stated above, there are six parameters:
@@ -13949,7 +13947,7 @@ done:
link(p) := null;
flush_node_list(r);
width(q) := k;
- set_justified_native_glyphs(q);
+ set_justified_native_glyphs(q);
p := q;
pool_ptr := str_start_macro(str_ptr); {flush the temporary string data}
end
@@ -15891,7 +15889,7 @@ begin
font_engine := find_native_font(name_of_file + 1, s);
if font_engine = 0 then goto done;
-
+
if s>=0 then
actual_size := s
else begin
@@ -29786,7 +29784,7 @@ XeTeX_count_features_code:
scan_font_ident; n:=cur_val;
if is_atsu_font(n) then
cur_val:=atsu_font_get(m - XeTeX_int, font_layout_engine[n])
- else if is_gr_font(n) then
+ else if is_gr_font(n) then
cur_val:=ot_font_get(m - XeTeX_int, font_layout_engine[n])
else
cur_val:=0;