summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in21
-rw-r--r--docs/tmpl/atsui-fonts.sgml26
-rw-r--r--docs/tmpl/fonts.sgml18
-rw-r--r--docs/tmpl/glyphs.sgml23
-rw-r--r--docs/tmpl/layout.sgml16
-rw-r--r--docs/tmpl/main.sgml5
-rw-r--r--docs/tmpl/tab-stops.sgml2
-rw-r--r--docs/tmpl/text-attributes.sgml6
-rw-r--r--modules/Makefile.am1
-rw-r--r--modules/arabic/Makefile.am22
-rw-r--r--modules/arabic/arabic-fc.c226
-rw-r--r--modules/arabic/arabic-ot.c461
-rw-r--r--modules/arabic/arabic-ot.h80
-rw-r--r--modules/basic/Makefile.am2
-rw-r--r--modules/basic/basic-fc.c368
-rw-r--r--modules/syriac/Makefile.am25
-rw-r--r--modules/syriac/syriac-fc.c212
-rw-r--r--modules/syriac/syriac-ot.c361
-rw-r--r--modules/syriac/syriac-ot.h69
-rw-r--r--pango/Makefile.am14
-rw-r--r--pango/mini-fribidi/fribidi.c2
-rw-r--r--pango/opentype/COPYING17
-rw-r--r--pango/opentype/Makefile.am68
-rw-r--r--pango/opentype/README9
-rw-r--r--pango/opentype/TODO6
-rw-r--r--pango/opentype/hb-blob.c378
-rw-r--r--pango/opentype/hb-blob.h87
-rw-r--r--pango/opentype/hb-buffer-private.h136
-rw-r--r--pango/opentype/hb-buffer.c528
-rw-r--r--pango/opentype/hb-buffer.h152
-rw-r--r--pango/opentype/hb-common.h61
-rw-r--r--pango/opentype/hb-font-private.h96
-rw-r--r--pango/opentype/hb-font.cc323
-rw-r--r--pango/opentype/hb-font.h186
-rw-r--r--pango/opentype/hb-glib.c56
-rw-r--r--pango/opentype/hb-glib.h41
-rw-r--r--pango/opentype/hb-object-private.h105
-rw-r--r--pango/opentype/hb-open-file-private.hh223
-rw-r--r--pango/opentype/hb-open-type-private.hh640
-rw-r--r--pango/opentype/hb-ot-layout-common-private.hh614
-rw-r--r--pango/opentype/hb-ot-layout-gdef-private.hh373
-rw-r--r--pango/opentype/hb-ot-layout-gpos-private.hh1614
-rw-r--r--pango/opentype/hb-ot-layout-gsub-private.hh909
-rw-r--r--pango/opentype/hb-ot-layout-gsubgpos-private.hh956
-rw-r--r--pango/opentype/hb-ot-layout-private.h121
-rw-r--r--pango/opentype/hb-ot-layout.cc559
-rw-r--r--pango/opentype/hb-ot-layout.h201
-rw-r--r--pango/opentype/hb-ot.h34
-rw-r--r--pango/opentype/hb-private.h214
-rw-r--r--pango/opentype/hb-shape.c40
-rw-r--r--pango/opentype/hb-shape.h53
-rw-r--r--pango/opentype/hb-unicode-private.h57
-rw-r--r--pango/opentype/hb-unicode.c161
-rw-r--r--pango/opentype/hb-unicode.h219
-rw-r--r--pango/opentype/hb.h35
-rw-r--r--pango/opentype/main.cc170
-rw-r--r--pango/pango-ot-buffer.c252
-rw-r--r--pango/pango-ot-info.c266
-rw-r--r--pango/pango-ot-private.h7
-rw-r--r--pango/pangofc-private.h3
60 files changed, 347 insertions, 11583 deletions
diff --git a/configure.in b/configure.in
index c0928f5f..4d9b1575 100644
--- a/configure.in
+++ b/configure.in
@@ -369,7 +369,7 @@ have_cairo_atsui=false
cairo_required=1.7.6
PKG_CHECK_MODULES(CAIRO, cairo >= $cairo_required, have_cairo=true, AC_MSG_RESULT([no]))
-
+
if $have_cairo ; then
pango_save_libs=$LIBS
LIBS="$LIBS $CAIRO_LIBS"
@@ -451,6 +451,12 @@ AM_CONDITIONAL(HAVE_CAIRO_WIN32, $have_cairo_win32)
AM_CONDITIONAL(HAVE_CAIRO_FREETYPE, $have_cairo_freetype)
AM_CONDITIONAL(HAVE_CAIRO_ATSUI, $have_cairo_atsui)
+
+harfbuzz_required=0.5
+have_harfbuzz=false
+PKG_CHECK_MODULES(HARFBUZZ, harfbuzz >= $harfbuzz_required, have_harfbuzz=true)
+AM_CONDITIONAL(HAVE_HARFBUZZ, $have_harfbuzz)
+
#
# We must have some backend defined, in order for the pango-querymodules
# rule in pango/Makefile.am to work correctly. If you are up to writing
@@ -505,13 +511,12 @@ GOBJECT_INTROSPECTION_CHECK([0.9.5])
#
# Modules to build
#
-arabic_modules="arabic-fc,arabic-lang"
+arabic_modules="arabic-lang"
basic_modules="basic-fc,basic-win32,basic-x,basic-atsui,basic-coretext"
hangul_modules="hangul-fc"
hebrew_modules="hebrew-fc"
indic_modules="indic-fc,indic-lang"
khmer_modules="khmer-fc"
-syriac_modules="syriac-fc"
thai_modules="thai-fc"
tibetan_modules="tibetan-fc"
@@ -519,7 +524,7 @@ if $have_libthai ; then
thai_modules="$thai_modules,thai-lang"
fi
-all_modules="$arabic_modules,$basic_modules,$hangul_modules,$hebrew_modules,$indic_modules,$khmer_modules,$syriac_modules,$thai_modules,$tibetan_modules"
+all_modules="$arabic_modules,$basic_modules,$hangul_modules,$hebrew_modules,$indic_modules,$khmer_modules,$thai_modules,$tibetan_modules"
#
# Allow building some or all modules included
@@ -592,7 +597,6 @@ for module in $included_modules; do
done
IFS="$pango_save_ifs"
-AM_CONDITIONAL(INCLUDE_ARABIC_FC, echo $included_modules | egrep '(^|,)arabic-fc($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_ARABIC_LANG, echo $included_modules | egrep '(^|,)arabic-lang($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_BASIC_FC, echo $included_modules | egrep '(^|,)basic-fc($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_BASIC_WIN32, echo $included_modules | egrep '(^|,)basic-win32($|,)' > /dev/null)
@@ -604,12 +608,10 @@ AM_CONDITIONAL(INCLUDE_HEBREW_FC, echo $included_modules | egrep '(^|,)hebrew-fc
AM_CONDITIONAL(INCLUDE_INDIC_FC, echo $included_modules | egrep '(^|,)indic-fc($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_INDIC_LANG, echo $included_modules | egrep '(^|,)indic-lang($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_KHMER_FC, echo $included_modules | egrep '(^|,)khmer-fc($|,)' > /dev/null)
-AM_CONDITIONAL(INCLUDE_SYRIAC_FC, echo $included_modules | egrep '(^|,)syriac-fc($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_THAI_FC, echo $included_modules | egrep '(^|,)thai-fc($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_THAI_LANG, echo $included_modules | egrep '(^|,)thai-lang($|,)' > /dev/null)
AM_CONDITIONAL(INCLUDE_TIBETAN_FC, echo $included_modules | egrep '(^|,)tibetan-fc($|,)' > /dev/null)
-AM_CONDITIONAL(DYNAMIC_ARABIC_FC, echo $dynamic_modules | egrep '(^|,)arabic-fc($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_ARABIC_LANG, echo $dynamic_modules | egrep '(^|,)arabic-lang($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_BASIC_FC, echo $dynamic_modules | egrep '(^|,)basic-fc($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_BASIC_WIN32, echo $dynamic_modules | egrep '(^|,)basic-win32($|,)' > /dev/null)
@@ -621,7 +623,6 @@ AM_CONDITIONAL(DYNAMIC_HEBREW_FC, echo $dynamic_modules | egrep '(^|,)hebrew-fc(
AM_CONDITIONAL(DYNAMIC_INDIC_FC, echo $dynamic_modules | egrep '(^|,)indic-fc($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_INDIC_LANG, echo $dynamic_modules | egrep '(^|,)indic-lang($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_KHMER_FC, echo $dynamic_modules | egrep '(^|,)khmer-fc($|,)' > /dev/null)
-AM_CONDITIONAL(DYNAMIC_SYRIAC_FC, echo $dynamic_modules | egrep '(^|,)syriac-fc($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_THAI_FC, echo $dynamic_modules | egrep '(^|,)thai-fc($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_THAI_LANG, echo $dynamic_modules | egrep '(^|,)thai-lang($|,)' > /dev/null)
AM_CONDITIONAL(DYNAMIC_TIBETAN_FC, echo $dynamic_modules | egrep '(^|,)tibetan-fc($|,)' > /dev/null)
@@ -690,7 +691,7 @@ dnl * Options to pass to libtool
dnl ********************************************************
# Note that -module isn't included here since automake needs to see it to know
-# that something like pango-arabic-fc.la is a valid libtool archive
+# that something like pango-basic-fc.la is a valid libtool archive
#
LIBRARY_LIBTOOL_OPTIONS="-version-info $VERSION_INFO"
MODULE_LIBTOOL_OPTIONS="-export-dynamic -avoid-version"
@@ -1012,7 +1013,6 @@ AC_CONFIG_FILES([
Makefile
pango/Makefile
pango/mini-fribidi/Makefile
-pango/opentype/Makefile
pango/pango.rc
pango/pangoft2.rc
pango/pangowin32.rc
@@ -1027,7 +1027,6 @@ modules/hangul/Makefile
modules/hebrew/Makefile
modules/indic/Makefile
modules/khmer/Makefile
-modules/syriac/Makefile
modules/thai/Makefile
modules/tibetan/Makefile
examples/Makefile
diff --git a/docs/tmpl/atsui-fonts.sgml b/docs/tmpl/atsui-fonts.sgml
index c8b6aa06..7f3c9dd3 100644
--- a/docs/tmpl/atsui-fonts.sgml
+++ b/docs/tmpl/atsui-fonts.sgml
@@ -21,29 +21,3 @@ MacOS systems using the ATSUI text rendering subsystem.
<!-- ##### SECTION Image ##### -->
-<!-- ##### MACRO PANGO_RENDER_TYPE_ATSUI ##### -->
-<para>
-A string constant identifying the ATSUI renderer. The associated quark (see
-g_quark_from_string()) is used to identify the renderer in pango_find_map().
-</para>
-
-
-
-<!-- ##### FUNCTION pango_atsui_font_get_cgfont ##### -->
-<para>
-
-</para>
-
-@font:
-@Returns:
-
-
-<!-- ##### FUNCTION pango_atsui_font_get_atsfont ##### -->
-<para>
-
-</para>
-
-@font:
-@Returns:
-
-
diff --git a/docs/tmpl/fonts.sgml b/docs/tmpl/fonts.sgml
index 7b55dea7..16ca84f1 100644
--- a/docs/tmpl/fonts.sgml
+++ b/docs/tmpl/fonts.sgml
@@ -442,24 +442,6 @@ the documentation of the corresponding getters for documentation
of their meaning.
</para>
-@ref_count: reference count. Used internally. See pango_font_metrics_ref()
- and pango_font_metrics_unref().
-@ascent: the distance from the baseline to the highest point of the glyphs of
- the font. This is positive in practically all fonts.
-@descent: the distance from the baseline to the lowest point of the glyphs of
- the font. This is positive in practically all fonts.
-@approximate_char_width: approximate average width of the regular glyphs of
- the font. Note that for this calculation, East Asian characters
- (those passing g_unichar_iswide()) are counted as double-width.
- This produces a more uniform value for this measure across languages
- and results in more uniform and more expected UI sizes.
-@approximate_digit_width: approximate average width of the glyphs for digits
- of the font.
-@underline_position: position of the underline. This is normally negative.
-@underline_thickness: thickness of the underline.
-@strikethrough_position: position of the strikethrough line. This is
- normally positive.
-@strikethrough_thickness: thickness of the strikethrough line.
<!-- ##### MACRO PANGO_TYPE_FONT_METRICS ##### -->
<para>
diff --git a/docs/tmpl/glyphs.sgml b/docs/tmpl/glyphs.sgml
index 399319eb..926bf539 100644
--- a/docs/tmpl/glyphs.sgml
+++ b/docs/tmpl/glyphs.sgml
@@ -168,12 +168,6 @@ horizontal origin.
</para>
-@xx:
-@xy:
-@yx:
-@yy:
-@x0:
-@y0:
<!-- ##### MACRO PANGO_TYPE_MATRIX ##### -->
<para>
@@ -395,11 +389,6 @@ The storage for the glyph information is owned
by the structure which simplifies memory management.
</para>
-@num_glyphs: the number of glyphs in the string.
-@glyphs: an array of #PangoGlyphInfo structures of length <structfield>num_glyphs</structfield>.
-@log_clusters: for each glyph, byte index of the starting character for the
-cluster. The indices are relative to the start of the text
-corresponding to the PangoGlyphString.
<!-- ##### STRUCT PangoGlyphItem ##### -->
<para>
@@ -410,10 +399,6 @@ of shaping text with #PangoLayout is a list of #PangoLayoutLine,
each of which contains a list of #PangoGlyphItem.
</para>
-@item: a #PangoItem structure that provides information
- about a segment of text.
-@glyphs: the glyphs obtained by shaping the text
- corresponding to @item.
<!-- ##### STRUCT PangoGlyphItemIter ##### -->
<para>
@@ -457,14 +442,6 @@ None of the members of a #PangoGlyphItemIter should be modified manually.
</para>
-@glyph_item: the #PangoGlyphItem this iterator iterates over
-@text: the UTF-8 text that @glyph_item refers to
-@start_glyph: starting glyph of the cluster
-@start_index: starting text index of the cluster
-@start_char: starting number of characters of the cluster
-@end_glyph: ending glyph of the cluster
-@end_index: ending text index of the cluster
-@end_char: ending number of characters of the cluster
@Since: 1.22
<!-- ##### MACRO PANGO_TYPE_GLYPH_STRING ##### -->
diff --git a/docs/tmpl/layout.sgml b/docs/tmpl/layout.sgml
index 4be6a59a..997507df 100644
--- a/docs/tmpl/layout.sgml
+++ b/docs/tmpl/layout.sgml
@@ -124,8 +124,8 @@ has no user-visible fields.
</para>
-@layout:
-@Returns:
+@layout:
+@Returns:
<!-- ##### FUNCTION pango_layout_set_markup ##### -->
@@ -478,9 +478,9 @@ The #GObject type for #PangoAlignment.
</para>
-@layout:
-@n_attrs:
-@Returns:
+@layout:
+@n_attrs:
+@Returns:
<!-- ##### FUNCTION pango_layout_index_to_pos ##### -->
@@ -845,12 +845,6 @@ Routines for rendering PangoLayout objects are provided in
code specific to each rendering system.
</para>
-@layout: the parent layout for this line
-@start_index: the start of the line as byte index into @layout->text
-@length: the length of the line in bytes
-@runs: a list containing the runs of the line in visual order
-@is_paragraph_start: %TRUE if this is the first line of the paragraph
-@resolved_dir: the resolved #PangoDirection of the line
<!-- ##### TYPEDEF PangoLayoutRun ##### -->
<para>
diff --git a/docs/tmpl/main.sgml b/docs/tmpl/main.sgml
index 8373b123..112baaaf 100644
--- a/docs/tmpl/main.sgml
+++ b/docs/tmpl/main.sgml
@@ -36,11 +36,6 @@ The #PangoItem structure stores information about
a segment of text. It contains the following fields:
</para>
-@offset: the offset of the segment from the beginning of the
- string in bytes.
-@length: the length of the segment in bytes.
-@num_chars: the length of the segment in characters.
-@analysis: the properties of the segment.
<!-- ##### STRUCT PangoAnalysis ##### -->
<para>
diff --git a/docs/tmpl/tab-stops.sgml b/docs/tmpl/tab-stops.sgml
index 62b02020..0e28a72e 100644
--- a/docs/tmpl/tab-stops.sgml
+++ b/docs/tmpl/tab-stops.sgml
@@ -68,7 +68,7 @@ The #GObject type for #PangoTabAlign.
@positions_in_pixels:
@first_alignment:
@first_position:
-@Varargs:
+@...:
@Returns:
diff --git a/docs/tmpl/text-attributes.sgml b/docs/tmpl/text-attributes.sgml
index 98158f80..d7b5cb51 100644
--- a/docs/tmpl/text-attributes.sgml
+++ b/docs/tmpl/text-attributes.sgml
@@ -578,12 +578,6 @@ The #PangoColor structure is used to
represent a color in an uncalibrated RGB color-space.
</para>
-@red: The red component of the color. This is a value between 0 and 65535,
- with 65535 indicating full intensity.
-@green: The green component of the color. This is a value between 0 and 65535,
- with 65535 indicating full intensity.
-@blue: The blue component of the color. This is a value between 0 and 65535,
- with 65535 indicating full intensity.
<!-- ##### MACRO PANGO_TYPE_COLOR ##### -->
<para>
diff --git a/modules/Makefile.am b/modules/Makefile.am
index dc8a2c85..802c8b54 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -7,7 +7,6 @@ SUBDIRS = \
hebrew \
indic \
khmer \
- syriac \
thai \
tibetan
diff --git a/modules/arabic/Makefile.am b/modules/arabic/Makefile.am
index 935eb039..2a20532b 100644
--- a/modules/arabic/Makefile.am
+++ b/modules/arabic/Makefile.am
@@ -1,27 +1,5 @@
include $(top_srcdir)/modules/Module.mk
-if HAVE_FREETYPE
-INCLUDES += $(FREETYPE_CFLAGS)
-if INCLUDE_ARABIC_FC
-noinst_LTLIBRARIES += libpango-arabic-fc.la
-else
-if DYNAMIC_ARABIC_FC
-module_LTLIBRARIES += pango-arabic-fc.la
-endif
-endif
-endif
-
-fc_sources = \
- arabic-fc.c \
- arabic-ot.c \
- arabic-ot.h
-
-pango_arabic_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS)
-pango_arabic_fc_la_LIBADD = $(pangoft2libs)
-pango_arabic_fc_la_SOURCES = $(fc_sources)
-libpango_arabic_fc_la_SOURCES = $(fc_sources)
-libpango_arabic_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_arabic_fc
-
if INCLUDE_ARABIC_LANG
noinst_LTLIBRARIES += libpango-arabic-lang.la
diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c
deleted file mode 100644
index 4b024e14..00000000
--- a/modules/arabic/arabic-fc.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/* Pango
- * arabic-fc.c: Arabic shaper for FreeType-based backends
- *
- * Copyright (C) 2000, 2003, 2007 Red Hat Software
- * Authors:
- * Owen Taylor <otaylor@redhat.com>
- * Behdad Esfahbod <behdad@behdad.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-#include <string.h>
-
-#include "arabic-ot.h"
-
-#include "pango-engine.h"
-#include "pango-utils.h"
-#include "pangofc-font.h"
-
-/* No extra fields needed */
-typedef PangoEngineShape ArabicEngineFc;
-typedef PangoEngineShapeClass ArabicEngineFcClass ;
-
-#define SCRIPT_ENGINE_NAME "ArabicScriptEngineFc"
-#define RENDER_TYPE PANGO_RENDER_TYPE_FC
-
-static PangoEngineScriptInfo arabic_scripts[] = {
- { PANGO_SCRIPT_ARABIC, "*" },
- { PANGO_SCRIPT_NKO, "*" }
-};
-
-static PangoEngineInfo script_engines[] = {
- {
- SCRIPT_ENGINE_NAME,
- PANGO_ENGINE_TYPE_SHAPE,
- RENDER_TYPE,
- arabic_scripts, G_N_ELEMENTS(arabic_scripts)
- }
-};
-
-static const PangoOTFeatureMap gsub_features[] =
-{
- {"ccmp", PANGO_OT_ALL_GLYPHS},
- {"locl", PANGO_OT_ALL_GLYPHS},
- {"isol", isolated},
- {"fina", final},
- {"medi", medial},
- {"init", initial},
- {"rlig", PANGO_OT_ALL_GLYPHS},
- {"calt", PANGO_OT_ALL_GLYPHS},
- {"liga", PANGO_OT_ALL_GLYPHS},
- /* 'dlig' should be turned-on/off-able. lets turn off for now. */
- /* {"dlig", PANGO_OT_ALL_GLYPHS}, */
- {"cswh", PANGO_OT_ALL_GLYPHS},
- {"mset", PANGO_OT_ALL_GLYPHS}
-};
-
-static const PangoOTFeatureMap gpos_features[] =
-{
- {"curs", PANGO_OT_ALL_GLYPHS},
- {"kern", PANGO_OT_ALL_GLYPHS},
- {"mark", PANGO_OT_ALL_GLYPHS},
- {"mkmk", PANGO_OT_ALL_GLYPHS}
-};
-
-static void
-arabic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
- PangoFont *font,
- const char *text,
- gint length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
-{
- PangoFcFont *fc_font;
- FT_Face face;
- PangoOTRulesetDescription desc;
- const PangoOTRuleset *ruleset;
- PangoOTBuffer *buffer;
- gulong *properties = NULL;
- glong n_chars;
- gunichar *wcs;
- const char *p;
- int cluster = 0;
- gboolean rtl = analysis->level % 2 != 0;
- gboolean reverse;
- int i;
-
- g_return_if_fail (font != NULL);
- g_return_if_fail (text != NULL);
- g_return_if_fail (length >= 0);
- g_return_if_fail (analysis != NULL);
-
- fc_font = PANGO_FC_FONT (font);
- face = pango_fc_font_lock_face (fc_font);
- if (!face)
- return;
-
- buffer = pango_ot_buffer_new (fc_font);
- pango_ot_buffer_set_rtl (buffer, rtl);
- pango_ot_buffer_set_zero_width_marks (buffer, TRUE);
-
- wcs = g_utf8_to_ucs4_fast (text, length, &n_chars);
- properties = g_new0 (gulong, n_chars);
-
- reverse = !rtl ^ (analysis->gravity == PANGO_GRAVITY_NORTH || analysis->gravity == PANGO_GRAVITY_WEST);
- Arabic_Assign_Properties (wcs, properties, n_chars, reverse);
-
- g_free (wcs);
-
- p = text;
- for (i=0; i < n_chars; i++)
- {
- gunichar wc;
- PangoGlyph glyph;
-
- wc = g_utf8_get_char (p);
-
- if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK)
- cluster = p - text;
-
- if (pango_is_zero_width (wc))
- glyph = PANGO_GLYPH_EMPTY;
- else
- {
- gunichar c = wc;
-
- if (analysis->level % 2)
- g_unichar_get_mirror_char (c, &c);
-
- /* Hack - Microsoft fonts are strange and don't contain the
- * correct rules to shape ARABIC LETTER FARSI YEH in
- * medial/initial position. It looks identical to ARABIC LETTER
- * YEH in these positions, so we substitute if the font contains
- * ARABIC LETTER YEH
- */
- if (c == 0x6cc &&
- ((properties[i] & (initial | medial)) != (initial | medial)) &&
- pango_fc_font_has_char (fc_font, 0x64a))
- c = 0x64a;
-
- glyph = pango_fc_font_get_glyph (fc_font, c);
- }
-
- if (!glyph)
- glyph = PANGO_GET_UNKNOWN_GLYPH (wc);
-
- pango_ot_buffer_add_glyph (buffer, glyph, properties[i], cluster);
-
- p = g_utf8_next_char (p);
- }
-
- g_free (properties);
-
- desc.script = analysis->script;
- desc.language = analysis->language;
-
- desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features);
- desc.static_gsub_features = gsub_features;
- desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features);
- desc.static_gpos_features = gpos_features;
-
- /* TODO populate other_features from analysis->extra_attrs */
- desc.n_other_features = 0;
- desc.other_features = NULL;
-
- ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc);
-
- pango_ot_ruleset_substitute (ruleset, buffer);
- pango_ot_ruleset_position (ruleset, buffer);
- pango_ot_buffer_output (buffer, glyphs);
-
- pango_ot_buffer_destroy (buffer);
-
- pango_fc_font_unlock_face (fc_font);
-}
-
-static void
-arabic_engine_fc_class_init (PangoEngineShapeClass *class)
-{
- class->script_shape = arabic_engine_shape;
-}
-
-PANGO_ENGINE_SHAPE_DEFINE_TYPE (ArabicEngineFc, arabic_engine_fc,
- arabic_engine_fc_class_init, NULL)
-
-void
-PANGO_MODULE_ENTRY(init) (GTypeModule *module)
-{
- arabic_engine_fc_register_type (module);
-}
-
-void
-PANGO_MODULE_ENTRY(exit) (void)
-{
-}
-
-void
-PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
- int *n_engines)
-{
- *engines = script_engines;
- *n_engines = G_N_ELEMENTS (script_engines);
-}
-
-PangoEngine *
-PANGO_MODULE_ENTRY(create) (const char *id)
-{
- if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return g_object_new (arabic_engine_fc_type, NULL);
- else
- return NULL;
-}
diff --git a/modules/arabic/arabic-ot.c b/modules/arabic/arabic-ot.c
deleted file mode 100644
index ca8e7005..00000000
--- a/modules/arabic/arabic-ot.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/* This file is taken from the FreeType (1) tree. It's been reindented
- * to roughly match Pango guidelines (in anticipation of future changes),
- * but not otherwise much altered.
- */
-
-/****************************************************************************/
-/* */
-/* The FreeType project -- a free and portable quality TrueType renderer. */
-/* */
-/* Copyright 1996-2000 by */
-/* D. Turner, R.Wilhelm, and W. Lemberg */
-/* */
-/* arabic -- An implementation of the contextual algorithm given in the */
-/* Unicode 2.0 book to assign the `isolated', `initial', `medial', and */
-/* `final' properties to an input string of character codes for the Arabic */
-/* script. */
-/* */
-/* This file is part of the FreeType project, and may only be used */
-/* modified and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/* The code, like the FreeType code it is derived from is dual-licensed */
-/* under the GNU General Public License and the FreeType license. See */
-/* pango/opentype/COPYING for full details of this licensing scheme. */
-/****************************************************************************/
-
-#include "config.h"
-
-#include "arabic-ot.h"
-
-
-/*
- *
- * Here a table of the joining classes for characters in the range
- * U+0620 - U+06FF and U+0750 - U+077F.
- *
- * The following character also has a joining class:
- *
- * U+200D ZERO WIDTH JOINER -> causing
- *
- * All other characters are given the joining class `none'.
- *
- */
-
-static const joining_class arabic[] =
-{
- /* U+0620 */
- none, none, right, right,
- right, right, dual, right,
- dual, right, dual, dual,
- dual, dual, dual, right,
-
- /* U+0630 */
- right, right, right, dual,
- dual, dual, dual, dual,
- dual, dual, dual, none,
- none, none, none, none,
-
- /* U+0640 */
- causing, dual, dual, dual,
- dual, dual, dual, dual,
- right, dual, dual, transparent,
- transparent, transparent, transparent, transparent,
-
- /* U+0650 */
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, none,
-
- /* U+0660 */
- none, none, none, none,
- none, none, none, none,
- none, none, none, none,
- none, none, dual, dual,
-
- /* U+0670 */
- transparent, right, right, right,
- none, right, right, right,
- dual, dual, dual, dual,
- dual, dual, dual, dual,
-
- /* U+0680 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- right, right, right, right,
- right, right, right, right,
-
- /* U+0690 */
- right, right, right, right,
- right, right, right, right,
- right, right, dual, dual,
- dual, dual, dual, dual,
-
- /* U+06A0 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, dual,
-
- /* U+06B0 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, dual,
-
- /* U+06C0 */
- right, dual, right, right,
- right, right, right, right,
- right, right, right, right,
- dual, right, dual, right,
-
- /* U+06D0 */
- dual, dual, right, right,
- none, right, none, transparent,
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, transparent,
-
- /* U+06E0 */
- transparent, transparent, transparent, transparent,
- transparent, none, none, transparent,
- transparent, none, transparent, transparent,
- transparent, transparent, right, right,
-
- /* U+06F0 */
- none, none, none, none,
- none, none, none, none,
- none, none, dual, dual,
- dual, none, none, dual
-};
-
-static const joining_class arabic_supplement[] =
-{
- /* U+0750 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, right, right, right,
- dual, dual, dual, dual,
-
- /* U+0760 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, right,
- right, dual, none, none,
-
- /* U+0770 */
- none, none, none, none,
- none, none, none, none,
- none, none, none, none,
- none, none, none, none
-};
-
-/* Here a table of the joining classes for characters in the range
- * U+07C0 - U+07FF.
- *
- * The following character also has a joining class:
- *
- * U+200C ZERO WIDTH NON-JOINER -> causing
- *
- * All other characters are given the joining class `none'.
- */
-static const joining_class nko[] =
-{
- /* U+07C0 */
- none, none, none, none,
- none, none, none, none,
- none, none, dual, dual,
- dual, dual, dual, dual,
-
- /* U+07D0 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, dual,
-
- /* U+07E0 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- dual, dual, dual, transparent,
- transparent, transparent, transparent, transparent,
-
- /* U+07F0 */
- transparent, transparent, transparent, transparent,
- none, none, none, none,
- none, none, causing, none,
- none, none, none, none,
-};
-
-#if 0
-struct cgc_
-{
- FT_UShort char_code;
- FT_UShort glyph_index;
- FT_UShort class;
-};
-
-typedef struct cgc_ cgc;
-
-int compare_cgc (const void* a,
- const void* b)
-{
- return (((cgc*)a)->glyph_index > ((cgc*)b)->glyph_index) ?
- 1 : ((((cgc*)a)->glyph_index == ((cgc*)b)->glyph_index) ?
- 0 : -1);
-}
-
-
-TT_Error Build_Arabic_Glyph_Properties (TT_CharMap char_map,
- TT_UShort max_glyphs,
- TTO_GDEFHeader** gdef)
-{
- TT_UShort i, j, num_glyphs;
-
- cgc Arabic[0x0700 - 0x0620];
-
- TT_UShort glyph_indices[0x700 - 0x0620];
- TT_UShort classes[0x700 - 0x0620];
-
- if (!gdef)
- return TT_Err_Invalid_Argument;
-
- j = 0;
-
- for (i = 0x0620; i < 0x0700; i++)
- {
- Arabic[j].char_code = i;
- Arabic[j].class = (arabic[i - 0x0620] == transparent) ?
- MARK_GLYPH : SIMPLE_GLYPH;
- Arabic[j].glyph_index = TT_Char_Index (char_map, i);
- if (Arabic[j].glyph_index)
- j++;
- }
- num_glyphs = j;
-
- if (!num_glyphs)
- {
- /* no Arabic font */
- *gdef = NULL;
- return TT_Err_Ok;
- }
-
- /* sort it */
-
- qsort (Arabic, num_glyphs, sizeof (cgc), compare_cgc);
-
- /* write it to the arrays, removing duplicates */
-
- glyph_indices[0] = Arabic[0].glyph_index;
- classes[0] = Arabic[0].class;
-
- j = 1;
-
- for (i = 1; i < num_glyphs; i++)
- {
- glyph_indices[j] = Arabic[i].glyph_index;
- classes[j] = Arabic[i].class;
-
- if (glyph_indices[j - 1] != glyph_indices[j])
- j++;
- }
- num_glyphs = j;
-
- TT_GDEF_Build_ClassDefinition (*gdef, max_glyphs, num_glyphs,
- glyph_indices, classes);
-
- return TT_Err_Ok;
-}
-#endif
-
-/* The joining rules as given in the Unicode 2.0 book (characters are
- * here specified as appearing in the byte stream, i.e. *not* in
- * visual order). Joining classes are given in angle brackets, glyph
- * forms in square brackets. Glyphs affected by a specific rule are
- * enclosed with vertical bars.
- *
- * Note: The description of the joining algorithm in the book is
- * severely broken. You can get a corrected version from
- * www.unicode.org (as of 29-Jun-1999, this hasn't appeared).
- *
- * R1: <anything1> <transparent> <anything2>
- *
- * apply joining rules for
- * <anything1> <anything2> -> [shape1] [shape2]
- *
- * -> [shape1] [isolated] [shape2]
- *
- * R2: <causing|left|dual> |<right>|
- *
- * -> [final]
- *
- * R3: |<left>| <causing|right|dual>
- *
- * -> [initial]
- *
- * R4: <causing|left|dual> |<dual>| <causing|right|dual>
- *
- * -> [medial]
- *
- * R5: <causing|left|dual> |<dual>| <!(causing|right|dual)>
- *
- * -> [final]
- *
- * R6: <!(causing|left|dual)> |<dual>| <causing|right|dual>
- *
- * -> [initial]
- *
- * R7: If R1-R6 fail:
- *
- * <anything> -> [isolated]
- */
-
-/* `direction' can be -1, 0, or 1 to indicate the last non-transparent
- * glyph, the current glyph, and the next non-transparent glyph,
- * respectively.
- */
-
-static joining_class Get_Joining_Class (gunichar* string,
- int pos,
- int length,
- int direction,
- gboolean reverse)
-{
- joining_class j;
-
-
- while (1)
- {
- if (pos == 0 && direction < 0)
- return none;
-
- pos += direction;
-
- if (pos >= length)
- return none;
-
- if (string[pos] >= 0x0620 &&
- string[pos] < 0x0700)
- j = arabic[string[pos] - 0x0620];
- else if (string[pos] >= 0x0750 &&
- string[pos] < 0x0780)
- j = arabic_supplement[string[pos] - 0x0750];
- else if (string[pos] >= 0x07C0 &&
- string[pos] < 0x0800)
- j = nko[string[pos] - 0x07C0];
- else if (string[pos] == 0x200D)
- return causing;
- else
- return none;
-
- if (!direction || j != transparent)
- {
- if (G_UNLIKELY (reverse))
- return j == right ? left : j == left ? right : j;
- else
- return j;
- }
- }
-}
-
-
-FT_Error Arabic_Assign_Properties (gunichar *string,
- gulong *properties,
- int length,
- gboolean reverse)
-{
- joining_class previous, current, next;
- int i;
-
- if (!string || !properties || length == 0)
- return FT_Err_Invalid_Argument;
-
- for (i = 0; i < length; i++)
- {
- previous = Get_Joining_Class (string, i, length, -1, reverse);
- current = Get_Joining_Class (string, i, length, 0, reverse);
- next = Get_Joining_Class (string, i, length, 1, reverse);
-
- /* R1 */
-
- if (current == transparent)
- {
- properties[i] |= isolated_p;
- continue;
- }
-
- /* R2 */
-
- if (previous == causing ||
- previous == left ||
- previous == dual )
- if (current == right)
- {
- properties[i] |= reverse ? initial_p : final_p;
- continue;
- }
-
- /* R3 */
-
- if (current == left)
- if (next == causing ||
- next == right ||
- next == dual )
- {
- properties[i] |= reverse ? final_p : initial_p;
- continue;
- }
-
- /* R4 */
-
- if (previous == causing ||
- previous == left ||
- previous == dual )
- if (current == dual)
- if (next == causing ||
- next == right ||
- next == dual )
- {
- properties[i] |= medial_p;
- continue;
- }
-
- /* R5 */
-
- if (previous == causing ||
- previous == left ||
- previous == dual )
- if (current == dual)
- if (!(next == causing ||
- next == right ||
- next == dual ))
- {
- properties[i] |= reverse ? initial_p : final_p;
- continue;
- }
-
- /* R6 */
-
- if (!(previous == causing ||
- previous == left ||
- previous == dual ))
- if (current == dual)
- if (next == causing ||
- next == right ||
- next == dual )
- {
- properties[i] |= reverse ? final_p : initial_p;
- continue;
- }
-
- /* R7 */
-
- properties[i] |= isolated_p;
- }
-
- return FT_Err_Ok;
-}
-
-
-/* End */
diff --git a/modules/arabic/arabic-ot.h b/modules/arabic/arabic-ot.h
deleted file mode 100644
index db9a9aa9..00000000
--- a/modules/arabic/arabic-ot.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* This file is taken from the FreeType (1) tree. It's been reindented
- * to roughly match Pango guidelines (in anticipation of future changes),
- * but not otherwise much altered.
- */
-
-/****************************************************************************/
-/* */
-/* The FreeType project -- a free and portable quality TrueType renderer. */
-/* */
-/* Copyright 1996-2000 by */
-/* D. Turner, R.Wilhelm, and W. Lemberg */
-/* */
-/* arabic -- An implementation of the contextual algorithm given in the */
-/* Unicode 2.0 book to assign the `isolated', `initial', `medial', and */
-/* `final' properties to an input string of character codes for the Arabic */
-/* script. */
-/* */
-/* This file is part of the FreeType project, and may only be used */
-/* modified and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/* The file LICENSE.TXT can be found in the Pango distribution as */
-/* pango/opentype/FT-license.txt */
-/****************************************************************************/
-
-#include <pango/pango-ot.h>
-
-
-enum joining_type_
-{
- isolated = 1, /* nominal */
- final = 2, /* right_joining */
- initial = 4, /* left_joining */
- medial = 8 /* double_joining */
-};
-
-typedef enum joining_type_ joining_type;
-
-
- /* A glyph's property value as needed by e.g. TT_GSUB_Apply_String()
- specifies which features should *not* be applied */
-
-enum arabic_glyph_property_
-{
- isolated_p = final | initial | medial,
- final_p = isolated | initial | medial,
- initial_p = isolated | final | medial,
- medial_p = isolated | final | initial
-};
-
-typedef enum arabic_glyph_property_ arabic_glyph_property;
-
-
-enum joining_class_
-{
- right,
- left, /* not used */
- dual,
- causing,
- none,
- transparent
-};
-
-typedef enum joining_class_ joining_class;
-
-
-FT_Error Arabic_Assign_Properties (gunichar *string,
- gulong *properties,
- int length,
- gboolean reverse);
-#if 0
-TT_Error Build_Arabic_Glyph_Properties (TT_CharMap char_map,
- TT_UShort max_glyphs,
- TTO_GDEFHeader** gdef );
-#endif
-
-
-/* End */
diff --git a/modules/basic/Makefile.am b/modules/basic/Makefile.am
index a264d704..70e4b6b1 100644
--- a/modules/basic/Makefile.am
+++ b/modules/basic/Makefile.am
@@ -19,7 +19,7 @@ libpango_basic_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_basic_x
if HAVE_FREETYPE
-INCLUDES += $(FREETYPE_CFLAGS)
+INCLUDES += $(FREETYPE_CFLAGS) $(HARFBUZZ_CFLAGS)
if INCLUDE_BASIC_FC
noinst_LTLIBRARIES += libpango-basic-fc.la
else
diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c
index e3852c39..42832470 100644
--- a/modules/basic/basic-fc.c
+++ b/modules/basic/basic-fc.c
@@ -1,7 +1,7 @@
/* Pango
* basic-fc.c: Basic shaper for FreeType-based backends
*
- * Copyright (C) 2000, 2007 Red Hat Software
+ * Copyright (C) 2000, 2007, 2009 Red Hat Software
* Authors:
* Owen Taylor <otaylor@redhat.com>
* Behdad Esfahbod <behdad@behdad.org>
@@ -25,12 +25,17 @@
#include "config.h"
#include <string.h>
+#define PANGO_ENABLE_BACKEND 1 /* XXX */
#include <glib/gprintf.h>
#include "pango-engine.h"
#include "pango-utils.h"
#include "pangofc-font.h"
-#include "pango-ot.h"
+#include <hb-ft.h>
+#include <hb-glib.h>
+
+#define PANGO_UNITS_26_6(d) ((d) << 4)
+
/* No extra fields needed */
typedef PangoEngineShape BasicEngineFc;
@@ -40,47 +45,6 @@ typedef PangoEngineShapeClass BasicEngineFcClass;
#define RENDER_TYPE PANGO_RENDER_TYPE_FC
static PangoEngineScriptInfo basic_scripts[] = {
- /* Listed in OpenType "Standard scripts" standard */
- { PANGO_SCRIPT_LATIN, "*" },
- { PANGO_SCRIPT_CYRILLIC, "*" },
- { PANGO_SCRIPT_GREEK, "*" },
- { PANGO_SCRIPT_ARMENIAN, "*" },
- { PANGO_SCRIPT_GEORGIAN, "*" },
- { PANGO_SCRIPT_RUNIC, "*" },
- { PANGO_SCRIPT_OGHAM, "*" },
-
- /* The following are simple and can be shaped easily too */
-
- { PANGO_SCRIPT_BOPOMOFO, "*" },
- { PANGO_SCRIPT_CHEROKEE, "*" },
- { PANGO_SCRIPT_COPTIC, "*" },
- { PANGO_SCRIPT_DESERET, "*" },
- { PANGO_SCRIPT_ETHIOPIC, "*" },
- { PANGO_SCRIPT_GOTHIC, "*" },
- { PANGO_SCRIPT_HAN, "*" },
- { PANGO_SCRIPT_HIRAGANA, "*" },
- { PANGO_SCRIPT_KATAKANA, "*" },
- { PANGO_SCRIPT_OLD_ITALIC, "*" },
- { PANGO_SCRIPT_CANADIAN_ABORIGINAL, "*" },
- { PANGO_SCRIPT_YI, "*" },
-
- /* Unicode-4.0 additions */
- { PANGO_SCRIPT_BRAILLE, "*" },
- { PANGO_SCRIPT_CYPRIOT, "*" },
- { PANGO_SCRIPT_LIMBU, "*" },
- { PANGO_SCRIPT_OSMANYA, "*" },
- { PANGO_SCRIPT_SHAVIAN, "*" },
- { PANGO_SCRIPT_LINEAR_B, "*" },
- { PANGO_SCRIPT_UGARITIC, "*" },
-
- /* Unicode-4.1 additions */
- { PANGO_SCRIPT_GLAGOLITIC, "*" },
-
- /* Unicode-5.0 additions */
- { PANGO_SCRIPT_CUNEIFORM, "*" },
- { PANGO_SCRIPT_PHOENICIAN, "*" },
-
- /* In fact any script we don't know how to shape can go here */
{ PANGO_SCRIPT_COMMON, "" }
};
@@ -93,128 +57,260 @@ static PangoEngineInfo script_engines[] = {
}
};
-static const PangoOTFeatureMap gsub_features[] =
-{
- {"ccmp", PANGO_OT_ALL_GLYPHS},
- {"locl", PANGO_OT_ALL_GLYPHS},
- {"liga", PANGO_OT_ALL_GLYPHS},
- {"clig", PANGO_OT_ALL_GLYPHS}
-};
-static const PangoOTFeatureMap gpos_features[] =
-{
- {"kern", PANGO_OT_ALL_GLYPHS},
- {"mark", PANGO_OT_ALL_GLYPHS},
- {"mkmk", PANGO_OT_ALL_GLYPHS}
-};
+/* cache a single hb_buffer_t */
+static hb_buffer_t *cached_buffer = NULL;
+G_LOCK_DEFINE_STATIC (cached_buffer);
-static const PangoOTFeatureMap vertical_gsub_features[] =
+static hb_buffer_t *
+create_buffer (void)
{
- {"ccmp", PANGO_OT_ALL_GLYPHS},
- {"locl", PANGO_OT_ALL_GLYPHS},
- {"vert", PANGO_OT_ALL_GLYPHS}
-};
+ hb_buffer_t *buffer;
+
+ buffer = hb_buffer_create (32);
+ hb_buffer_set_unicode_funcs (buffer, hb_glib_get_unicode_funcs ());
-static const PangoOTFeatureMap vertical_gpos_features[] =
+ return buffer;
+}
+
+static hb_buffer_t *
+acquire_buffer (gboolean *free_buffer)
{
- {"vkrn", PANGO_OT_ALL_GLYPHS}
-};
+ hb_buffer_t *buffer;
+
+ if (G_LIKELY (G_TRYLOCK (cached_buffer)))
+ {
+ if (G_UNLIKELY (!cached_buffer))
+ cached_buffer = create_buffer ();
+
+ buffer = cached_buffer;
+ *free_buffer = FALSE;
+ }
+ else
+ {
+ buffer = create_buffer ();
+ *free_buffer = TRUE;
+ }
+
+ return buffer;
+}
static void
-basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
- PangoFont *font,
- const char *text,
- gint length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+release_buffer (hb_buffer_t *buffer, gboolean free_buffer)
{
+ if (G_LIKELY (!free_buffer))
+ {
+ hb_buffer_reset (buffer);
+ G_UNLOCK (cached_buffer);
+ }
+ else
+ hb_buffer_destroy (buffer);
+}
+
+typedef struct _PangoFcHbContext {
+ FT_Face ft_face;
PangoFcFont *fc_font;
- FT_Face face;
- PangoOTRulesetDescription desc;
- const PangoOTRuleset *ruleset;
- PangoOTBuffer *buffer;
- glong n_chars;
- const char *p;
- int cluster = 0;
- int i;
+} PangoFcHbContext;
- g_return_if_fail (font != NULL);
- g_return_if_fail (text != NULL);
- g_return_if_fail (length >= 0);
- g_return_if_fail (analysis != NULL);
+static hb_bool_t
+pango_fc_hb_font_get_glyph (hb_font_t *font, void *font_data,
+ hb_codepoint_t unicode, hb_codepoint_t variation_selector,
+ hb_codepoint_t *glyph,
+ void *user_data G_GNUC_UNUSED)
+{
+ PangoFcHbContext *context = (PangoFcHbContext *) font_data;
+ PangoFcFont *fc_font = context->fc_font;
- fc_font = PANGO_FC_FONT (font);
- face = pango_fc_font_lock_face (fc_font);
- if (!face)
- return;
+ *glyph = pango_fc_font_get_glyph (fc_font, unicode);
+ if (G_LIKELY (*glyph))
+ return TRUE;
- buffer = pango_ot_buffer_new (fc_font);
- pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0);
+ *glyph = PANGO_GET_UNKNOWN_GLYPH (unicode);
+ return FALSE;
+}
- n_chars = g_utf8_strlen (text, length);
- pango_glyph_string_set_size (glyphs, n_chars);
+static hb_bool_t
+pango_fc_hb_font_get_glyph_contour_point (hb_font_t *font, void *font_data,
+ hb_codepoint_t glyph, unsigned int point_index,
+ hb_position_t *x, hb_position_t *y,
+ void *user_data G_GNUC_UNUSED)
+{
+ return FALSE;
+#if 0
+ FT_Face ft_face = (FT_Face) font_data;
+ int load_flags = FT_LOAD_DEFAULT;
- p = text;
- for (i=0; i < n_chars; i++)
- {
- gunichar wc;
- PangoGlyph glyph;
+ /* TODO: load_flags, embolden, etc */
+
+ if (HB_UNLIKELY (FT_Load_Glyph (ft_face, glyph, load_flags)))
+ return FALSE;
- wc = g_utf8_get_char (p);
+ if (HB_UNLIKELY (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE))
+ return FALSE;
- if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK)
- cluster = p - text;
+ if (HB_UNLIKELY (point_index >= (unsigned int) ft_face->glyph->outline.n_points))
+ return FALSE;
- if (pango_is_zero_width (wc))
- glyph = PANGO_GLYPH_EMPTY;
- else
- {
- gunichar c = wc;
+ *x = ft_face->glyph->outline.points[point_index].x;
+ *y = ft_face->glyph->outline.points[point_index].y;
- if (analysis->level % 2)
- g_unichar_get_mirror_char (c, &c);
+ return TRUE;
+#endif
+}
- glyph = pango_fc_font_get_glyph (fc_font, c);
- }
+static hb_position_t
+pango_fc_hb_font_get_glyph_h_advance (hb_font_t *font, void *font_data,
+ hb_codepoint_t glyph,
+ void *user_data G_GNUC_UNUSED)
+{
+ PangoFcHbContext *context = (PangoFcHbContext *) font_data;
+ PangoFcFont *fc_font = context->fc_font;
+ PangoRectangle logical;
- if (!glyph)
- glyph = PANGO_GET_UNKNOWN_GLYPH (wc);
+ pango_font_get_glyph_extents ((PangoFont *) fc_font, glyph, NULL, &logical);
- pango_ot_buffer_add_glyph (buffer, glyph, 0, cluster);
+ return logical.width;
+}
- p = g_utf8_next_char (p);
- }
+static hb_bool_t
+pango_fc_hb_font_get_glyph_extents (hb_font_t *font, void *font_data,
+ hb_codepoint_t glyph,
+ hb_glyph_extents_t *extents,
+ void *user_data G_GNUC_UNUSED)
+{
+ PangoFcHbContext *context = (PangoFcHbContext *) font_data;
+ PangoFcFont *fc_font = context->fc_font;
+ PangoRectangle ink;
- desc.script = analysis->script;
- desc.language = analysis->language;
+ pango_font_get_glyph_extents ((PangoFont *) fc_font, glyph, &ink, NULL);
+
+ extents->x_bearing = ink.x;
+ extents->y_bearing = ink.y;
+ extents->width = ink.width;
+ extents->height = ink.height;
+
+ return TRUE;
+}
+
+static hb_position_t
+pango_fc_hb_font_get_h_kerning (hb_font_t *font, void *font_data,
+ hb_codepoint_t left_glyph, hb_codepoint_t right_glyph,
+ void *user_data G_GNUC_UNUSED)
+{
+ PangoFcHbContext *context = (PangoFcHbContext *) font_data;
+ FT_Face ft_face = context->ft_face;
+ FT_Vector kerning;
+
+ if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerning))
+ return 0;
+
+ return PANGO_UNITS_26_6 (kerning.x);
+}
+
+static hb_font_funcs_t *
+pango_fc_get_hb_font_funcs (void)
+{
+ static hb_font_funcs_t *funcs;
+
+ if (G_UNLIKELY (!funcs)) {
+ funcs = hb_font_funcs_create ();
+ hb_font_funcs_set_glyph_func (funcs, pango_fc_hb_font_get_glyph, NULL, NULL);
+ /* XXX vertical */
+ hb_font_funcs_set_glyph_h_advance_func (funcs, pango_fc_hb_font_get_glyph_h_advance, NULL, NULL);
+ hb_font_funcs_set_glyph_extents_func (funcs, pango_fc_hb_font_get_glyph_extents, NULL, NULL);
+ hb_font_funcs_set_glyph_contour_point_func (funcs, pango_fc_hb_font_get_glyph_contour_point, NULL, NULL);
+ hb_font_funcs_set_glyph_h_kerning_func (funcs, pango_fc_hb_font_get_h_kerning, NULL, NULL);
+ }
+
+ return funcs;
+}
- if (PANGO_GRAVITY_IS_VERTICAL (analysis->gravity))
- {
- desc.n_static_gsub_features = G_N_ELEMENTS (vertical_gsub_features);
- desc.static_gsub_features = vertical_gsub_features;
- desc.n_static_gpos_features = G_N_ELEMENTS (vertical_gpos_features);
- desc.static_gpos_features = vertical_gpos_features;
- }
- else
- {
- desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features);
- desc.static_gsub_features = gsub_features;
- desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features);
- desc.static_gpos_features = gpos_features;
- }
- /* TODO populate other_features from analysis->extra_attrs */
- desc.n_other_features = 0;
- desc.other_features = NULL;
- ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc);
- pango_ot_ruleset_substitute (ruleset, buffer);
- pango_ot_ruleset_position (ruleset, buffer);
- pango_ot_buffer_output (buffer, glyphs);
+static void
+basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
+ PangoFont *font,
+ const char *text,
+ gint length,
+ const PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
+{
+ PangoFcHbContext context;
+ PangoFcFont *fc_font;
+ FT_Face ft_face;
+ hb_font_t *hb_font;
+ hb_buffer_t *hb_buffer;
+ gboolean free_buffer;
+ gboolean is_hinted;
+ hb_glyph_info_t *hb_glyph;
+ hb_glyph_position_t *hb_position;
+ int last_cluster;
+ guint i, num_glyphs;
- pango_ot_buffer_destroy (buffer);
+ g_return_if_fail (font != NULL);
+ g_return_if_fail (text != NULL);
+ g_return_if_fail (length >= 0);
+ g_return_if_fail (analysis != NULL);
+
+ fc_font = PANGO_FC_FONT (font);
+ ft_face = pango_fc_font_lock_face (fc_font);
+ if (!ft_face)
+ return;
+
+ /* TODO: Cache hb_font? */
+ context.ft_face = ft_face;
+ context.fc_font = fc_font;
+ hb_font = hb_font_create (hb_ft_face_create_cached (ft_face));
+ hb_font_set_funcs (hb_font,
+ pango_fc_get_hb_font_funcs (),
+ &context,
+ NULL);
+ hb_font_set_scale (hb_font,
+ /* XXX CTM */
+ (((guint64) ft_face->size->metrics.x_scale * ft_face->units_per_EM) >> 12),
+ -(((guint64) ft_face->size->metrics.y_scale * ft_face->units_per_EM) >> 12));
+ is_hinted = fc_font->is_hinted;
+ hb_font_set_ppem (hb_font,
+ is_hinted ? ft_face->size->metrics.x_ppem : 0,
+ is_hinted ? ft_face->size->metrics.y_ppem : 0);
+
+ hb_buffer = acquire_buffer (&free_buffer);
+ /* setup buffer */
+ hb_buffer_set_direction (hb_buffer, analysis->level % 2 != 0 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
+ hb_buffer_set_script (hb_buffer, hb_glib_script_to_script (analysis->script));
+ hb_buffer_set_language (hb_buffer, hb_language_from_string (pango_language_to_string (analysis->language)));
+ hb_buffer_add_utf8 (hb_buffer, text, length, 0, length);
+
+ hb_shape (hb_font, hb_buffer, NULL, 0);
+
+ /* buffer output */
+ num_glyphs = hb_buffer_get_length (hb_buffer);
+ hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, NULL);
+ hb_position = hb_buffer_get_glyph_positions (hb_buffer, NULL);
+ pango_glyph_string_set_size (glyphs, num_glyphs);
+ last_cluster = -1;
+ for (i = 0; i < num_glyphs; i++)
+ {
+ glyphs->glyphs[i].glyph = hb_glyph->codepoint;
+ glyphs->log_clusters[i] = hb_glyph->cluster;
+ glyphs->glyphs[i].attr.is_cluster_start = glyphs->log_clusters[i] != last_cluster;
+ last_cluster = glyphs->log_clusters[i];
+
+ /* XXX
+ if (is_hinted)
+ advance = PANGO_UNITS_ROUND (advance);
+ */
+ glyphs->glyphs[i].geometry.width = hb_position->x_advance;
+ glyphs->glyphs[i].geometry.x_offset = hb_position->x_offset;
+ glyphs->glyphs[i].geometry.y_offset = hb_position->y_offset;
+
+ hb_glyph++;
+ hb_position++;
+ }
+ release_buffer (hb_buffer, free_buffer);
+ hb_font_destroy (hb_font);
pango_fc_font_unlock_face (fc_font);
}
diff --git a/modules/syriac/Makefile.am b/modules/syriac/Makefile.am
deleted file mode 100644
index 68a4441e..00000000
--- a/modules/syriac/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-include $(top_srcdir)/modules/Module.mk
-
-if HAVE_FREETYPE
-INCLUDES += $(FREETYPE_CFLAGS)
-if INCLUDE_SYRIAC_FC
-noinst_LTLIBRARIES += libpango-syriac-fc.la
-else
-if DYNAMIC_SYRIAC_FC
-module_LTLIBRARIES += pango-syriac-fc.la
-endif
-endif
-endif
-
-fc_sources = \
- syriac-fc.c \
- syriac-ot.c \
- syriac-ot.h
-
-pango_syriac_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS)
-pango_syriac_fc_la_LIBADD = $(pangoft2libs)
-pango_syriac_fc_la_SOURCES = $(fc_sources)
-libpango_syriac_fc_la_SOURCES = $(fc_sources)
-libpango_syriac_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_syriac_fc
-
--include $(top_srcdir)/git.mk
diff --git a/modules/syriac/syriac-fc.c b/modules/syriac/syriac-fc.c
deleted file mode 100644
index 7ba05fb4..00000000
--- a/modules/syriac/syriac-fc.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* Pango
- * syriac-fc.h:
- *
- * Copyright (C) 2000, 2003, 2007 Red Hat Software
- * Copyright (C) 2004 Emil Soleyman-Zomalan
- * Authors:
- * Owen Taylor <otaylor@redhat.com>
- * Emil Soleyman-Zomalan <emil@soleyman.com>
- * Behdad Esfahbod <behdad@behdad.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#include "config.h"
-#include <string.h>
-
-#include "syriac-ot.h"
-
-#include "pango-engine.h"
-#include "pango-utils.h"
-#include "pangofc-font.h"
-
-/* No extra fields needed */
-typedef PangoEngineShape SyriacEngineFc;
-typedef PangoEngineShapeClass SyriacEngineFcClass ;
-
-#define SCRIPT_ENGINE_NAME "SyriacScriptEngineFc"
-#define RENDER_TYPE PANGO_RENDER_TYPE_FC
-
-static PangoEngineScriptInfo syriac_scripts[] = {
- { PANGO_SCRIPT_SYRIAC, "*" },
-};
-
-static PangoEngineInfo script_engines[] = {
- {
- SCRIPT_ENGINE_NAME,
- PANGO_ENGINE_TYPE_SHAPE,
- RENDER_TYPE,
- syriac_scripts, G_N_ELEMENTS(syriac_scripts)
- }
-};
-
-static const PangoOTFeatureMap gsub_features[] =
-{
- {"ccmp", PANGO_OT_ALL_GLYPHS},
- {"locl", PANGO_OT_ALL_GLYPHS},
- {"isol", isolated},
- {"fina", final},
- {"fin2", final2},
- {"fin3", final3},
- {"medi", medial},
- {"med2", medial2},
- {"init", initial},
- {"rlig", PANGO_OT_ALL_GLYPHS},
- {"calt", PANGO_OT_ALL_GLYPHS},
- {"liga", PANGO_OT_ALL_GLYPHS},
- /* 'dlig' should be turned-on/off-able. lets turn off for now. */
- /* {"dlig", PANGO_OT_ALL_GLYPHS}, */
-};
-
-static const PangoOTFeatureMap gpos_features[] =
-{
- {"kern", PANGO_OT_ALL_GLYPHS},
- {"mark", PANGO_OT_ALL_GLYPHS},
- {"mkmk", PANGO_OT_ALL_GLYPHS}
-};
-
-static void
-syriac_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
- PangoFont *font,
- const char *text,
- gint length,
- const PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
-{
- PangoFcFont *fc_font;
- FT_Face face;
- PangoOTRulesetDescription desc;
- const PangoOTRuleset *ruleset;
- PangoOTBuffer *buffer;
- gulong *properties = NULL;
- glong n_chars;
- gunichar *wcs;
- const char *p;
- int cluster = 0;
- int i;
-
- g_return_if_fail (font != NULL);
- g_return_if_fail (text != NULL);
- g_return_if_fail (length >= 0);
- g_return_if_fail (analysis != NULL);
-
- fc_font = PANGO_FC_FONT (font);
- face = pango_fc_font_lock_face (fc_font);
- if (!face)
- return;
-
- buffer = pango_ot_buffer_new (fc_font);
- pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0);
- pango_ot_buffer_set_zero_width_marks (buffer, TRUE);
-
- wcs = g_utf8_to_ucs4_fast (text, length, &n_chars);
- properties = g_new0 (gulong, n_chars);
-
- syriac_assign_properties (wcs, properties, n_chars);
-
- g_free (wcs);
-
- p = text;
- for (i=0; i < n_chars; i++)
- {
- gunichar wc;
- PangoGlyph glyph;
-
- wc = g_utf8_get_char (p);
-
- if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK)
- cluster = p - text;
-
- if (pango_is_zero_width (wc))
- glyph = PANGO_GLYPH_EMPTY;
- else
- {
- gunichar c = wc;
-
- if (analysis->level % 2)
- g_unichar_get_mirror_char (c, &c);
-
- glyph = pango_fc_font_get_glyph (fc_font, c);
- }
-
- if (!glyph)
- glyph = PANGO_GET_UNKNOWN_GLYPH (wc);
-
- pango_ot_buffer_add_glyph (buffer, glyph, properties[i], cluster);
-
- p = g_utf8_next_char (p);
- }
-
- g_free (properties);
-
- desc.script = analysis->script;
- desc.language = analysis->language;
-
- desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features);
- desc.static_gsub_features = gsub_features;
- desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features);
- desc.static_gpos_features = gpos_features;
-
- /* TODO populate other_features from analysis->extra_attrs */
- desc.n_other_features = 0;
- desc.other_features = NULL;
-
- ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc);
-
- pango_ot_ruleset_substitute (ruleset, buffer);
- pango_ot_ruleset_position (ruleset, buffer);
- pango_ot_buffer_output (buffer, glyphs);
-
- pango_ot_buffer_destroy (buffer);
-
- pango_fc_font_unlock_face (fc_font);
-}
-
-static void
-syriac_engine_fc_class_init (PangoEngineShapeClass *class)
-{
- class->script_shape = syriac_engine_shape;
-}
-
-PANGO_ENGINE_SHAPE_DEFINE_TYPE (SyriacEngineFc, syriac_engine_fc,
- syriac_engine_fc_class_init, NULL)
-
-void
-PANGO_MODULE_ENTRY(init) (GTypeModule *module)
-{
- syriac_engine_fc_register_type (module);
-}
-
-void
-PANGO_MODULE_ENTRY(exit) (void)
-{
-}
-
-void
-PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
- int *n_engines)
-{
- *engines = script_engines;
- *n_engines = G_N_ELEMENTS (script_engines);
-}
-
-PangoEngine *
-PANGO_MODULE_ENTRY(create) (const char *id)
-{
- if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return g_object_new (syriac_engine_fc_type, NULL);
- else
- return NULL;
-}
diff --git a/modules/syriac/syriac-ot.c b/modules/syriac/syriac-ot.c
deleted file mode 100644
index 0fbb64e0..00000000
--- a/modules/syriac/syriac-ot.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* Pango
- * syriac-ot.h: Determine what OpenType features to apply to characters based
- * on the rules for Syriac from the OpenType standard.
- *
- * Copyright (C) 2004 Emil Soleyman-Zomalan
- * Author: Emil Soleyman-Zomalan <emil@soleyman.com>
- *
- * This file is based on the Arabic shaping code from FreeType 1 tree; original
- * copyright notice:
- *
- * The FreeType project -- a free and portable quality TrueType renderer.
- *
- * Copyright 1996-2000 by
- * D. Turner, R.Wilhelm, and W. Lemberg
- *
- * The code, like the FreeType code it is derived from is dual-licensed
- * under the GNU General Public License and the FreeType license. See
- * pango/opentype/COPYING for full details of this licensing scheme.
- */
-#include "config.h"
-#include "syriac-ot.h"
-
-/* Here a table of the joining classes for characters in the range
- * U+0700 - U+074F.
- *
- * The following character also has a joining class:
- *
- * U+200C ZERO WIDTH NON-JOINER -> causing
- *
- * All other characters are given the joining class `none'.
- */
-static const JoiningClass syriac[] =
-{
- /* U+0700 */
- none, none, none, none,
- none, none, none, none,
- none, none, none, none,
- none, none, none, transparent,
-
- /* U+0710 */
- right, none, dual, dual,
- dual, right, right, right,
- right, right, dual, dual,
- dual, dual, right, dual,
-
- /* U+0720 */
- dual, dual, dual, dual,
- dual, dual, dual, dual,
- right, dual, right, dual,
- right, none, none, none,
-
- /* U+0730 */
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, transparent,
-
- /* U+0740 */
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, transparent,
- transparent, transparent, transparent, none,
- none, right, dual, dual
-};
-
-/* `direction' can be -1, 0, or 1 to indicate the last non-transparent
- * glyph, the current glyph, and the next non-transparent glyph,
- * respectively.
- */
-static JoiningClass
-Get_Joining_Class (gunichar* string,
- int pos,
- int length,
- int direction)
-{
- JoiningClass j;
-
- while (1)
- {
- if (pos == 0 && direction < 0)
- return none;
-
- pos += direction;
-
- if (pos >= length)
- return none;
-
- if (string[pos] < 0x0700 ||
- string[pos] >= 0x074F)
- {
- if (string[pos] == 0x200C)
- return causing;
- else
- return none;
- }
- else
- j = syriac[string[pos] - 0x0700];
-
- if (!direction || j != transparent)
- return j;
- }
-}
-
-
-/* The rules here are roughly based on the Arabic rules from the Unicode
- * 2.0 standard (which differ from the Unicode-4.0 rules), augmented
- * with the Syriac rules from the Unicode-4.0 standard. The numbers
- * R1...R11 below do not correspond to either the Arabic or the Syriac
- * rule numbering from the Unicode standard.
- *
- * Characters are here specified as appearing in the byte stream, i.e.
- * *not* in visual order. Joining classes are given in angle brackets,
- * glyph forms in square brackets. Glyphs affected by a specific rule are
- * enclosed with vertical bars.
- *
- *
- * Glyphs: 0x0715 (Dalath), 0x0716 (Dalath Rish), 0x072A (Rish),
- * 0x0722 (Nun), 0x071F (Kaph)
- *
- *
- * R1: <anything1> <transparent> <anything2>
- *
- * apply joining rules for
- * <anything1> <anything2> -> [shape1] [shape2]
- * -> [shape1] [isolated] [shape2]
- *
- *
- * R2: <causing|right> <0x0722|0x071F> <!(causing|right|dual)>
- * -> [isolated]
- *
- * The Nun and Kaph characters each have 3 different glyphs
- * with two of those glyphs coming at the final position.
- * However, one of those final glyphs should really be of the
- * isolated glyph form where the preceding character cannot be
- * joined to and there is no next character.
- *
- * This rule exists to combine similar exception for both
- * characters without increasing the complexity in the other
- * rules.
- *
- *
- * R3: <causing|right|dual> && <!(0x0715|0x0716|0x072A)> |<alaph>|
- *
- * -> [final2]
- *
- * If the preceding glyph cannot be joined to the current
- * glyph and the preceding character is not a Dalath, Rish,
- * or Dotless Dalath Rish, then the Alaph takes this contextual
- * position.
- *
- * The [final2] joining rule is placed ahead of the [final] to
- * give it greater precedence when choosing the correct glyph.
- * If it comes after the [final] rule, the incorrect glyph is
- * inserted into position.
- *
- *
- * R4: <0x0715|0x0715|0x072A> |<alaph>|
- *
- * -> [final3]
- *
- * If the previous glyph is a Dalath, Rish, or Dotless Dalath
- * Rish, then the Alaph takes this contextual position.
- *
- * The [final3] joining rule is placed ahead of the [final] to
- * give it greater precedence when choosing the correct glyph.
- * If it comes after the [final] rule, the incorrect glyph is
- * inserted into position.
- *
- *
- * R5: <causing|right|dual> |<right>|
- *
- * -> [final]
- *
- *
- * R6: <causing|right|dual> |<dual>| <!(causing|right|dual)>
- *
- * -> [final]
- *
- *
- * R7: <causing|left|dual> |<dual>| <causing|right|dual>
- *
- * -> [medial]
- *
- *
- * R8: <causing|right> |<alaph>| <causing|right|dual>
- *
- * -> [medial2]
- *
- * If the Alaph glyph falls in the middle of a Syriac word and
- * the preceding character cannot be joined to, then the Alaph
- * takes this contextual position.
- *
- *
- * R9: |<left>| <causing|right|dual>
- *
- * -> [initial]
- *
- *
- * R10: <!(causing|left|dual)> |<dual>| <causing|right|dual>
- *
- * -> [initial]
- *
- *
- * R11: <anything> -> [isolated]
- *
- * This joining rule is placed at the end of these features
- * because when it is placed at the beginning of all of them
- * it tends to break the cursive nature of Syriac writing --
- * it inserts the isolated glyph of each character into that
- * position with no joining occurring all throughout a text
- * document.
- */
-
-FT_Error
-syriac_assign_properties (gunichar *string,
- gulong *properties,
- int length)
-{
- JoiningClass previous, current, next;
- int i;
-
- if (!string || !properties || length == 0)
- return FT_Err_Invalid_Argument;
-
- for (i = 0; i < length; i++)
- {
- previous = Get_Joining_Class (string, i, length, -1);
- current = Get_Joining_Class (string, i, length, 0);
- next = Get_Joining_Class (string, i, length, 1);
-
- /* R1 */
-
- if (current == transparent)
- {
- properties[i] |= isolated_p;
- continue;
- }
-
- /* R2 */
-
- if (string[i] == 0x0722 ||
- string[i] == 0x071F)
- if (previous == causing ||
- previous == right)
- if (!(next == causing ||
- next == right ||
- next == dual))
- {
- properties[i] |= isolated_p;
- continue;
- }
-
- /* R3 */
-
- if (string[i] == 0x0710)
- if (previous == causing ||
- previous == right)
- if (!(string[i - 1] == 0x0715 ||
- string[i - 1] == 0x0716 ||
- string[i - 1] == 0x072A))
- {
- properties[i] |= final2_p;
- continue;
- }
-
- /* R4 */
-
- if (string[i] == 0x0710)
- if (previous == causing ||
- previous == right)
- if (string[i - 1] == 0x0715 ||
- string[i - 1] == 0x0716 ||
- string[i - 1] == 0x072A)
- {
- properties[i] |= final3_p;
- continue;
- }
-
- /* R5 */
-
- if (previous == causing ||
- previous == right ||
- previous == dual)
- if (current == right)
- {
- properties[i] |= final_p;
- continue;
- }
-
- /* R6 */
-
- if (previous == causing ||
- previous == right ||
- previous == dual)
- if (current == dual)
- if (!(next == causing ||
- next == right ||
- next == dual ))
- {
- properties[i] |= final_p;
- continue;
- }
-
- /* R7 */
-
- if (previous == causing ||
- previous == left ||
- previous == dual)
- if (current == dual)
- if (next == causing ||
- next == right ||
- next == dual )
- {
- properties[i] |= medial_p;
- continue;
- }
-
- /* R8 */
-
- if (string[i] == 0x0710)
- if (previous == causing ||
- previous == right)
- if (next == causing ||
- next == right ||
- next == dual)
- {
- properties[i] |= medial2_p;
- continue;
- }
-
- /* R9 */
-
- if (current == left)
- if (next == causing ||
- next == right ||
- next == dual)
- {
- properties[i] |= initial_p;
- continue;
- }
-
- /* R10 */
-
- if (!(previous == causing ||
- previous == left ||
- previous == dual ))
- if (current == dual)
- if (next == causing ||
- next == right ||
- next == dual)
- {
- properties[i] |= initial_p;
- continue;
- }
-
- /* R11 */
-
- properties[i] |= isolated_p;
- }
-
- return FT_Err_Ok;
-}
diff --git a/modules/syriac/syriac-ot.h b/modules/syriac/syriac-ot.h
deleted file mode 100644
index e9aea543..00000000
--- a/modules/syriac/syriac-ot.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Pango
- * syriac-ot.h: Determine what OpenType features to apply to characters based
- * on the rules for Syriac from the OpenType standard.
- *
- * Copyright (C) 2004 Emil Soleyman-Zomalan
- * Author: Emil Soleyman-Zomalan <emil@soleyman.com>
- *
- * This file is based on the Arabic shaping code from FreeType 1 tree; original
- * copyright notice:
- *
- * The FreeType project -- a free and portable quality TrueType renderer.
- *
- * Copyright 1996-2000 by
- * D. Turner, R.Wilhelm, and W. Lemberg
- *
- * The code, like the FreeType code it is derived from is dual-licensed
- * under the GNU Public License and the FreeType license. See see
- * pango/opentype/FT-license.txt for full details of the FreeType
- * license.
- */
-
-#ifndef __SYRIAC_OT_H__
-#define __SYRIAC_OT_H__
-
-#include <pango/pango-ot.h>
-
-G_BEGIN_DECLS
-
-typedef enum
-{
- isolated = 1 << 0, /* nominal */
- final = 1 << 1, /* right_joining */
- initial = 1 << 2, /* left_joining */
- medial = 1 << 3, /* double_joining */
- medial2 = 1 << 4, /* double_joining, applies to Alaph only */
- final2 = 1 << 5, /* right_joining, applies to Alaph only */
- final3 = 1 << 6 /* right_joining, applies to Alaph only */
-} JoiningType;
-
-/* A glyph's property value as needed by e.g. TT_GSUB_Apply_String()
- specifies which features should *not* be applied */
-typedef enum
-{
- isolated_p = final | initial | medial | medial2 | final2 | final3,
- final_p = isolated | initial | medial | medial2 | final2 | final3,
- initial_p = isolated | final | medial | medial2 | final2 | final3,
- medial_p = isolated | final | initial | medial2 | final2 | final3,
- medial2_p = isolated | final | initial | medial | final2 | final3,
- final2_p = isolated | final | initial | medial | medial2 | final3,
- final3_p = isolated | final | initial | medial | medial2 | final2
-} SyriacGlyphForm;
-
-typedef enum
-{
- right,
- left, /* not used */
- dual,
- causing,
- none,
- transparent
-} JoiningClass;
-
-FT_Error syriac_assign_properties (gunichar *string,
- gulong *properties,
- int length);
-
-G_END_DECLS
-
-#endif /* __SYRIAC_OT_H__ */
diff --git a/pango/Makefile.am b/pango/Makefile.am
index 87189502..98835348 100644
--- a/pango/Makefile.am
+++ b/pango/Makefile.am
@@ -10,15 +10,7 @@ INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --warn-all --add-include-path=$(srcdir) --add-include-path=.
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --includedir=.
-if HAVE_FREETYPE
-OPENTYPE_SUBDIR=opentype
-endif
-
-FRIBIDI_SUBDIR=mini-fribidi
-
-SUBDIRS = $(OPENTYPE_SUBDIR) $(FRIBIDI_SUBDIR)
-
-DIST_SUBDIRS = mini-fribidi opentype
+SUBDIRS = mini-fribidi
INCLUDES = \
-DG_LOG_DOMAIN=\"Pango\" \
@@ -31,6 +23,7 @@ INCLUDES = \
$(GLIB_CFLAGS) \
$(XFT_CFLAGS) \
$(CAIRO_CFLAGS) \
+ $(HARFBUZZ_CFLAGS) \
$(FREETYPE_CFLAGS) \
$(X_CFLAGS)
@@ -235,14 +228,13 @@ pangoft2_public_sources = \
libpangoft2_1_0_la_LDFLAGS = $(LIBRARY_LIBTOOL_OPTIONS)
libpangoft2_1_0_la_LIBADD = \
- opentype/libharfbuzz.la \
libpango-$(PANGO_API_VERSION).la \
$(INCLUDED_FC_MODULES) \
$(GLIB_LIBS) \
+ $(HARFBUZZ_LIBS) \
$(FREETYPE_LIBS) \
$(libm)
libpangoft2_1_0_la_DEPENDENCIES = \
- opentype/libharfbuzz.la \
libpango-$(PANGO_API_VERSION).la \
$(INCLUDED_FC_MODULES)
libpangoft2_1_0_la_SOURCES = \
diff --git a/pango/mini-fribidi/fribidi.c b/pango/mini-fribidi/fribidi.c
index 1da1c1f9..08aebe31 100644
--- a/pango/mini-fribidi/fribidi.c
+++ b/pango/mini-fribidi/fribidi.c
@@ -49,8 +49,8 @@ struct _TypeLink
TypeLink *prev;
TypeLink *next;
- FriBidiCharType type;
FriBidiStrIndex pos, len;
+ FriBidiCharType type;
FriBidiLevel level;
};
diff --git a/pango/opentype/COPYING b/pango/opentype/COPYING
deleted file mode 100644
index d5075a3c..00000000
--- a/pango/opentype/COPYING
+++ /dev/null
@@ -1,17 +0,0 @@
-Permission is hereby granted, without written agreement and without
-license or royalty fees, to use, copy, modify, and distribute this
-software and its documentation for any purpose, provided that the
-above copyright notice and the following two paragraphs appear in
-all copies of this software.
-
-IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
-DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
-IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
-ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
-PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
diff --git a/pango/opentype/Makefile.am b/pango/opentype/Makefile.am
deleted file mode 100644
index 23bb55b3..00000000
--- a/pango/opentype/Makefile.am
+++ /dev/null
@@ -1,68 +0,0 @@
-# Process this file with automake to produce Makefile.in
-
-NULL =
-
-# The following warning options are useful for debugging: -Wpadded -Wcast-align
-#AM_CXXFLAGS =
-
-noinst_LTLIBRARIES = libharfbuzz.la
-
-HBSOURCES = \
- hb-blob.c \
- hb-buffer.c \
- hb-buffer-private.h \
- hb-font.cc \
- hb-font-private.h \
- hb-glib.h \
- hb-glib.c \
- hb-private.h \
- hb-shape.h \
- hb-shape.c \
- hb-unicode.c \
- hb-unicode.h \
- hb-unicode-private.h \
- hb-open-file-private.hh \
- hb-open-type-private.hh \
- hb-ot-layout.cc \
- hb-ot-layout-common-private.hh \
- hb-ot-layout-gdef-private.hh \
- hb-ot-layout-gpos-private.hh \
- hb-ot-layout-gsubgpos-private.hh \
- hb-ot-layout-gsub-private.hh \
- hb-ot-layout-private.h \
- hb-object-private.h \
- $(NULL)
-
-HBHEADERS = \
- hb.h \
- hb-blob.h \
- hb-buffer.h \
- hb-common.h \
- hb-font.h \
- hb-ot.h \
- hb-ot-layout.h \
- $(NULL)
-
-libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS)
-libharfbuzz_la_CPPFLAGS = -DHAVE_GLIB $(GLIB_CFLAGS)
-libharfbuzz_la_LIBADD = $(GLIB_LIBS)
-
-noinst_PROGRAMS = main
-
-main_SOURCES = main.cc
-main_CPPFLAGS = -DHAVE_GLIB $(GLIB_CFLAGS)
-main_LDADD = libharfbuzz.la $(GLIB_LIBS)
-
-EXTRA_DIST = README COPYING
-
-dist-hook: libharfbuzz.sourcefiles
-
-libharfbuzz.sourcefiles: Makefile
- for F in $(libharfbuzz_la_SOURCES); do \
- case $$F in \
- *.c|*.cc) echo ' <File RelativePath="..\..\..\pango\opentype\'$$F'" />' \
- ;; \
- esac; \
- done >libharfbuzz.sourcefiles
-
--include $(top_srcdir)/git.mk
diff --git a/pango/opentype/README b/pango/opentype/README
deleted file mode 100644
index 42d01046..00000000
--- a/pango/opentype/README
+++ /dev/null
@@ -1,9 +0,0 @@
-This is HarfBuzz, an OpenType Layout engine.
-
-Bug reports on these files should be sent to the HarfBuzz mailing list as
-listed on http://freedesktop.org/wiki/Software/harfbuzz
-
-For license information, see the file COPYING.
-
-Behdad Esfahbod
-May 24, 2009
diff --git a/pango/opentype/TODO b/pango/opentype/TODO
deleted file mode 100644
index 8524279f..00000000
--- a/pango/opentype/TODO
+++ /dev/null
@@ -1,6 +0,0 @@
-- HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH vs LookupType::... mess
-- Rename LookupFlag::MarkAttachmentType to LookupFlag:IgnoreSpecialMarks
-- cmap14 support in get_glyph callback
-- size_t?
-- Figure out compiler selection (add test for link to libstdc++)
-- Rename MEMORY_MODE to ACCESS_MODE
diff --git a/pango/opentype/hb-blob.c b/pango/opentype/hb-blob.c
deleted file mode 100644
index 3e787fcb..00000000
--- a/pango/opentype/hb-blob.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#include "hb-private.h"
-
-#include "hb-blob.h"
-
-#ifdef HAVE_SYS_MMAN_H
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-#include <sys/mman.h>
-#endif /* HAVE_SYS_MMAN_H */
-
-#ifndef HB_DEBUG_BLOB
-#define HB_DEBUG_BLOB HB_DEBUG
-#endif
-
-struct _hb_blob_t {
- hb_reference_count_t ref_count;
-
- unsigned int length;
-
- hb_mutex_t lock;
- /* the rest are protected by lock */
-
- unsigned int lock_count;
- hb_memory_mode_t mode;
-
- const char *data;
-
- hb_destroy_func_t destroy;
- void *user_data;
-};
-static hb_blob_t _hb_blob_nil = {
- HB_REFERENCE_COUNT_INVALID, /* ref_count */
-
- 0, /* length */
-
- HB_MUTEX_INIT, /* lock */
-
- 0, /* lock_count */
- HB_MEMORY_MODE_READONLY, /* mode */
-
- NULL, /* data */
-
- NULL, /* destroy */
- NULL /* user_data */
-};
-
-static void
-_hb_blob_destroy_user_data (hb_blob_t *blob)
-{
- if (blob->destroy) {
- blob->destroy (blob->user_data);
- blob->destroy = NULL;
- blob->user_data = NULL;
- }
-}
-
-static void
-_hb_blob_unlock_and_destroy (hb_blob_t *blob)
-{
- hb_blob_unlock (blob);
- hb_blob_destroy (blob);
-}
-
-hb_blob_t *
-hb_blob_create (const char *data,
- unsigned int length,
- hb_memory_mode_t mode,
- hb_destroy_func_t destroy,
- void *user_data)
-{
- hb_blob_t *blob;
-
- if (!length || !HB_OBJECT_DO_CREATE (hb_blob_t, blob)) {
- if (destroy)
- destroy (user_data);
- return &_hb_blob_nil;
- }
-
- hb_mutex_init (blob->lock);
- blob->lock_count = 0;
-
- blob->data = data;
- blob->length = length;
- blob->mode = mode;
-
- blob->destroy = destroy;
- blob->user_data = user_data;
-
- if (blob->mode == HB_MEMORY_MODE_DUPLICATE) {
- blob->mode = HB_MEMORY_MODE_READONLY;
- if (!hb_blob_try_writable (blob)) {
- hb_blob_destroy (blob);
- return &_hb_blob_nil;
- }
- }
-
- return blob;
-}
-
-hb_blob_t *
-hb_blob_create_sub_blob (hb_blob_t *parent,
- unsigned int offset,
- unsigned int length)
-{
- hb_blob_t *blob;
- const char *pdata;
-
- if (!length || offset >= parent->length || !HB_OBJECT_DO_CREATE (hb_blob_t, blob))
- return &_hb_blob_nil;
-
- pdata = hb_blob_lock (parent);
-
- blob->data = pdata + offset;
- blob->length = MIN (length, parent->length - offset);
-
- hb_mutex_lock (parent->lock);
- blob->mode = parent->mode;
- hb_mutex_unlock (parent->lock);
-
- blob->destroy = (hb_destroy_func_t) _hb_blob_unlock_and_destroy;
- blob->user_data = hb_blob_reference (parent);
-
- return blob;
-}
-
-hb_blob_t *
-hb_blob_create_empty (void)
-{
- return &_hb_blob_nil;
-}
-
-hb_blob_t *
-hb_blob_reference (hb_blob_t *blob)
-{
- HB_OBJECT_DO_REFERENCE (blob);
-}
-
-unsigned int
-hb_blob_get_reference_count (hb_blob_t *blob)
-{
- HB_OBJECT_DO_GET_REFERENCE_COUNT (blob);
-}
-
-void
-hb_blob_destroy (hb_blob_t *blob)
-{
- HB_OBJECT_DO_DESTROY (blob);
-
- _hb_blob_destroy_user_data (blob);
-
- free (blob);
-}
-
-unsigned int
-hb_blob_get_length (hb_blob_t *blob)
-{
- return blob->length;
-}
-
-const char *
-hb_blob_lock (hb_blob_t *blob)
-{
- if (HB_OBJECT_IS_INERT (blob))
- return NULL;
-
- hb_mutex_lock (blob->lock);
-
- blob->lock_count++;
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
- blob->lock_count, blob->data);
-#endif
-
- hb_mutex_unlock (blob->lock);
-
- return blob->data;
-}
-
-void
-hb_blob_unlock (hb_blob_t *blob)
-{
- if (HB_OBJECT_IS_INERT (blob))
- return;
-
- hb_mutex_lock (blob->lock);
-
- assert (blob->lock_count > 0);
- blob->lock_count--;
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
- hb_atomic_int_get (blob->lock_count), blob->data);
-#endif
-
- hb_mutex_unlock (blob->lock);
-}
-
-hb_bool_t
-hb_blob_is_writable (hb_blob_t *blob)
-{
- hb_memory_mode_t mode;
-
- if (HB_OBJECT_IS_INERT (blob))
- return FALSE;
-
- hb_mutex_lock (blob->lock);
-
- mode = blob->mode;
-
- hb_mutex_unlock (blob->lock);
-
- return mode == HB_MEMORY_MODE_WRITABLE;
-}
-
-
-static hb_bool_t
-_try_make_writable_inplace_unix_locked (hb_blob_t *blob)
-{
-#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT)
- uintptr_t pagesize = -1, mask, length;
- const char *addr;
-
-#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
- pagesize = (uintptr_t) sysconf (_SC_PAGE_SIZE);
-#elif defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
- pagesize = (uintptr_t) sysconf (_SC_PAGESIZE);
-#elif defined(HAVE_GETPAGESIZE)
- pagesize = (uintptr_t) getpagesize ();
-#endif
-
- if ((uintptr_t) -1L == pagesize) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: failed to get pagesize: %s\n", blob, __FUNCTION__, strerror (errno));
-#endif
- return FALSE;
- }
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: pagesize is %u\n", blob, __FUNCTION__, pagesize);
-#endif
-
- mask = ~(pagesize-1);
- addr = (const char *) (((uintptr_t) blob->data) & mask);
- length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr;
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: calling mprotect on [%p..%p] (%d bytes)\n",
- blob, __FUNCTION__,
- addr, addr+length, length);
-#endif
- if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: %s\n", blob, __FUNCTION__, strerror (errno));
-#endif
- return FALSE;
- }
-
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: successfully made [%p..%p] (%d bytes) writable\n",
- blob, __FUNCTION__,
- addr, addr+length, length);
-#endif
- return TRUE;
-#else
- return FALSE;
-#endif
-}
-
-static void
-_try_writable_inplace_locked (hb_blob_t *blob)
-{
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: making writable\n", blob, __FUNCTION__);
-#endif
-
- if (_try_make_writable_inplace_unix_locked (blob)) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: making writable -> succeeded\n", blob, __FUNCTION__);
-#endif
- blob->mode = HB_MEMORY_MODE_WRITABLE;
- } else {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, __FUNCTION__);
-#endif
- /* Failed to make writable inplace, mark that */
- blob->mode = HB_MEMORY_MODE_READONLY;
- }
-}
-
-hb_bool_t
-hb_blob_try_writable_inplace (hb_blob_t *blob)
-{
- hb_memory_mode_t mode;
-
- if (HB_OBJECT_IS_INERT (blob))
- return FALSE;
-
- hb_mutex_lock (blob->lock);
-
- if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
- _try_writable_inplace_locked (blob);
-
- mode = blob->mode;
-
- hb_mutex_unlock (blob->lock);
-
- return mode == HB_MEMORY_MODE_WRITABLE;
-}
-
-hb_bool_t
-hb_blob_try_writable (hb_blob_t *blob)
-{
- hb_memory_mode_t mode;
-
- if (HB_OBJECT_IS_INERT (blob))
- return FALSE;
-
- hb_mutex_lock (blob->lock);
-
- if (blob->mode == HB_MEMORY_MODE_READONLY)
- {
- char *new_data;
-
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
- blob->lock_count, blob->data);
-#endif
-
- if (blob->lock_count)
- goto done;
-
- new_data = malloc (blob->length);
- if (new_data) {
-#if HB_DEBUG_BLOB
- fprintf (stderr, "%p %s: dupped successfully -> %p\n", blob, __FUNCTION__, blob->data);
-#endif
- memcpy (new_data, blob->data, blob->length);
- _hb_blob_destroy_user_data (blob);
- blob->mode = HB_MEMORY_MODE_WRITABLE;
- blob->data = new_data;
- blob->destroy = free;
- blob->user_data = new_data;
- }
- }
- else if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
- _try_writable_inplace_locked (blob);
-
-done:
- mode = blob->mode;
-
- hb_mutex_unlock (blob->lock);
-
- return mode == HB_MEMORY_MODE_WRITABLE;
-}
diff --git a/pango/opentype/hb-blob.h b/pango/opentype/hb-blob.h
deleted file mode 100644
index 131a282b..00000000
--- a/pango/opentype/hb-blob.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_BLOB_H
-#define HB_BLOB_H
-
-#include "hb-common.h"
-
-HB_BEGIN_DECLS
-
-typedef enum {
- HB_MEMORY_MODE_DUPLICATE,
- HB_MEMORY_MODE_READONLY,
- HB_MEMORY_MODE_WRITABLE,
- HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE
-} hb_memory_mode_t;
-
-typedef struct _hb_blob_t hb_blob_t;
-
-hb_blob_t *
-hb_blob_create (const char *data,
- unsigned int length,
- hb_memory_mode_t mode,
- hb_destroy_func_t destroy,
- void *user_data);
-
-hb_blob_t *
-hb_blob_create_sub_blob (hb_blob_t *parent,
- unsigned int offset,
- unsigned int length);
-
-hb_blob_t *
-hb_blob_create_empty (void);
-
-hb_blob_t *
-hb_blob_reference (hb_blob_t *blob);
-
-unsigned int
-hb_blob_get_reference_count (hb_blob_t *blob);
-
-void
-hb_blob_destroy (hb_blob_t *blob);
-
-unsigned int
-hb_blob_get_length (hb_blob_t *blob);
-
-const char *
-hb_blob_lock (hb_blob_t *blob);
-
-void
-hb_blob_unlock (hb_blob_t *blob);
-
-hb_bool_t
-hb_blob_is_writable (hb_blob_t *blob);
-
-hb_bool_t
-hb_blob_try_writable_inplace (hb_blob_t *blob);
-
-hb_bool_t
-hb_blob_try_writable (hb_blob_t *blob);
-
-HB_END_DECLS
-
-#endif /* HB_BLOB_H */
diff --git a/pango/opentype/hb-buffer-private.h b/pango/opentype/hb-buffer-private.h
deleted file mode 100644
index f1947860..00000000
--- a/pango/opentype/hb-buffer-private.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 1998-2004 David Turner and Werner Lemberg
- * Copyright (C) 2004,2007,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
- */
-
-#ifndef HB_BUFFER_PRIVATE_H
-#define HB_BUFFER_PRIVATE_H
-
-#include "hb-private.h"
-#include "hb-buffer.h"
-
-HB_BEGIN_DECLS
-
-#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
-
-
-typedef struct _hb_internal_glyph_info_t {
- hb_codepoint_t codepoint;
- hb_mask_t mask;
- uint32_t cluster;
- uint16_t component;
- uint16_t lig_id;
- uint32_t gproperty;
-} hb_internal_glyph_info_t;
-
-typedef struct _hb_internal_glyph_position_t {
- hb_position_t x_pos;
- hb_position_t y_pos;
- hb_position_t x_advance;
- hb_position_t y_advance;
- uint32_t new_advance :1; /* if set, the advance width values are
- absolute, i.e., they won't be
- added to the original glyph's value
- but rather replace them */
- uint32_t back : 15; /* number of glyphs to go back
- for drawing current glyph */
- int32_t cursive_chain : 16; /* character to which this connects,
- may be positive or negative; used
- only internally */
-} hb_internal_glyph_position_t;
-
-ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
-ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
-ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
-
-
-struct _hb_buffer_t {
- hb_reference_count_t ref_count;
-
- unsigned int allocated;
-
- hb_bool_t have_output; /* weather we have an output buffer going on */
- hb_bool_t in_error; /* Allocation failed */
- unsigned int in_length;
- unsigned int out_length;
- unsigned int in_pos;
- unsigned int out_pos; /* out_length and out_pos are actually always the same */
-
- hb_internal_glyph_info_t *in_string;
- hb_internal_glyph_info_t *out_string;
- hb_internal_glyph_position_t *positions;
-
- hb_direction_t direction;
- unsigned int max_lig_id;
-};
-
-
-HB_INTERNAL void
-_hb_buffer_swap (hb_buffer_t *buffer);
-
-HB_INTERNAL void
-_hb_buffer_clear_output (hb_buffer_t *buffer);
-
-HB_INTERNAL void
-_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
- unsigned int num_in,
- unsigned int num_out,
- const uint16_t *glyph_data_be,
- unsigned short component,
- unsigned short ligID);
-
-HB_INTERNAL void
-_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
- hb_codepoint_t glyph_index,
- unsigned short component,
- unsigned short ligID);
-
-HB_INTERNAL void
-_hb_buffer_next_glyph (hb_buffer_t *buffer);
-
-HB_INTERNAL void
-_hb_buffer_replace_glyph (hb_buffer_t *buffer,
- hb_codepoint_t glyph_index);
-
-HB_INTERNAL unsigned short
-_hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
-
-
-/* convenience macros */
-#define IN_GLYPH(pos) (buffer->in_string[(pos)].codepoint)
-#define IN_INFO(pos) (&buffer->in_string[(pos)])
-#define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].codepoint)
-#define IN_CURINFO() (&buffer->in_string[buffer->in_pos])
-#define IN_MASK(pos) (buffer->in_string[(pos)].mask)
-#define IN_LIGID(pos) (buffer->in_string[(pos)].lig_id)
-#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
-#define POSITION(pos) (&buffer->positions[(pos)])
-#define CURPOSITION() (&buffer->positions[buffer->in_pos])
-#define OUT_GLYPH(pos) (buffer->out_string[(pos)].codepoint)
-#define OUT_INFO(pos) (&buffer->out_string[(pos)])
-
-HB_END_DECLS
-
-#endif /* HB_BUFFER_PRIVATE_H */
diff --git a/pango/opentype/hb-buffer.c b/pango/opentype/hb-buffer.c
deleted file mode 100644
index e9788ad2..00000000
--- a/pango/opentype/hb-buffer.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * Copyright (C) 1998-2004 David Turner and Werner Lemberg
- * Copyright (C) 2004,2007 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
- */
-
-#include "hb-buffer-private.h"
-
-#include <string.h>
-
-
-static hb_buffer_t _hb_buffer_nil = {
- HB_REFERENCE_COUNT_INVALID /* ref_count */
-};
-
-/* Here is how the buffer works internally:
- *
- * There are two string pointers: in_string and out_string. They
- * always have same allocated size, but different length and positions.
- *
- * As an optimization, both in_string and out_string may point to the
- * same piece of memory, which is owned by in_string. This remains the
- * case as long as out_length doesn't exceed in_length at any time.
- * In that case, swap() is no-op and the glyph operations operate mostly
- * in-place.
- *
- * As soon as out_string gets longer than in_string, out_string is moved over
- * to an alternate buffer (which we reuse the positions buffer for!), and its
- * current contents (out_length entries) are copied to the alt buffer.
- * This should all remain transparent to the user. swap() then switches
- * in_string and out_string.
- */
-
-/* Internal API */
-
-static hb_bool_t
-hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
-{
- if (HB_UNLIKELY (!hb_buffer_ensure (buffer, size))) return FALSE;
- if (buffer->out_string == buffer->in_string)
- {
- assert (buffer->have_output);
-
- buffer->out_string = (hb_internal_glyph_info_t *) buffer->positions;
- memcpy (buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]));
- }
-
- return TRUE;
-}
-
-/* Public API */
-
-hb_buffer_t *
-hb_buffer_create (unsigned int pre_alloc_size)
-{
- hb_buffer_t *buffer;
-
- if (!HB_OBJECT_DO_CREATE (hb_buffer_t, buffer))
- return &_hb_buffer_nil;
-
- if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
-
- return buffer;
-}
-
-hb_buffer_t *
-hb_buffer_reference (hb_buffer_t *buffer)
-{
- HB_OBJECT_DO_REFERENCE (buffer);
-}
-
-unsigned int
-hb_buffer_get_reference_count (hb_buffer_t *buffer)
-{
- HB_OBJECT_DO_GET_REFERENCE_COUNT (buffer);
-}
-
-void
-hb_buffer_destroy (hb_buffer_t *buffer)
-{
- HB_OBJECT_DO_DESTROY (buffer);
-
- free (buffer->in_string);
- free (buffer->positions);
-
- free (buffer);
-}
-
-void
-hb_buffer_clear (hb_buffer_t *buffer)
-{
- buffer->have_output = FALSE;
- buffer->in_error = FALSE;
- buffer->in_length = 0;
- buffer->out_length = 0;
- buffer->in_pos = 0;
- buffer->out_pos = 0;
- buffer->out_string = buffer->in_string;
- buffer->max_lig_id = 0;
-}
-
-hb_bool_t
-hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
-{
- if (HB_UNLIKELY (size > buffer->allocated))
- {
- unsigned int new_allocated = buffer->allocated;
- hb_internal_glyph_position_t *new_pos;
- hb_internal_glyph_info_t *new_info;
- hb_bool_t separate_out;
-
- if (HB_UNLIKELY (buffer->in_error))
- return FALSE;
-
- separate_out = buffer->out_string != buffer->in_string;
-
- while (size > new_allocated)
- new_allocated += (new_allocated >> 1) + 8;
-
- new_pos = (hb_internal_glyph_position_t *) realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0]));
- new_info = (hb_internal_glyph_info_t *) realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
-
- if (HB_UNLIKELY (!new_pos || !new_info))
- buffer->in_error = TRUE;
-
- if (HB_LIKELY (new_pos))
- buffer->positions = new_pos;
-
- if (HB_LIKELY (new_info))
- buffer->in_string = new_info;
-
- buffer->out_string = separate_out ? (hb_internal_glyph_info_t *) buffer->positions : buffer->in_string;
- if (HB_LIKELY (!buffer->in_error))
- buffer->allocated = new_allocated;
- }
-
- return HB_LIKELY (!buffer->in_error);
-}
-
-void
-hb_buffer_add_glyph (hb_buffer_t *buffer,
- hb_codepoint_t codepoint,
- hb_mask_t mask,
- unsigned int cluster)
-{
- hb_internal_glyph_info_t *glyph;
-
- if (HB_UNLIKELY (!hb_buffer_ensure (buffer, buffer->in_length + 1))) return;
-
- glyph = &buffer->in_string[buffer->in_length];
- glyph->codepoint = codepoint;
- glyph->mask = mask;
- glyph->cluster = cluster;
- glyph->component = 0;
- glyph->lig_id = 0;
- glyph->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
-
- buffer->in_length++;
-}
-
-void
-hb_buffer_set_direction (hb_buffer_t *buffer,
- hb_direction_t direction)
-
-{
- buffer->direction = direction;
-}
-
-
-/* HarfBuzz-Internal API */
-
-void
-_hb_buffer_clear_output (hb_buffer_t *buffer)
-{
- buffer->have_output = TRUE;
- buffer->out_length = 0;
- buffer->out_pos = 0;
- buffer->out_string = buffer->in_string;
-}
-
-void
-hb_buffer_clear_positions (hb_buffer_t *buffer)
-{
- _hb_buffer_clear_output (buffer);
- buffer->have_output = FALSE;
-
- if (HB_UNLIKELY (!buffer->positions))
- {
- buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0]));
- return;
- }
-
- memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length);
-}
-
-void
-_hb_buffer_swap (hb_buffer_t *buffer)
-{
- unsigned int tmp;
-
- assert (buffer->have_output);
-
- if (HB_UNLIKELY (buffer->in_error)) return;
-
- if (buffer->out_string != buffer->in_string)
- {
- hb_internal_glyph_info_t *tmp_string;
- tmp_string = buffer->in_string;
- buffer->in_string = buffer->out_string;
- buffer->out_string = tmp_string;
- buffer->positions = (hb_internal_glyph_position_t *) buffer->out_string;
- }
-
- tmp = buffer->in_length;
- buffer->in_length = buffer->out_length;
- buffer->out_length = tmp;
-
- tmp = buffer->in_pos;
- buffer->in_pos = buffer->out_pos;
- buffer->out_pos = tmp;
-}
-
-/* The following function copies `num_out' elements from `glyph_data'
- to `buffer->out_string', advancing the in array pointer in the structure
- by `num_in' elements, and the out array pointer by `num_out' elements.
- Finally, it sets the `length' field of `out' equal to
- `pos' of the `out' structure.
-
- If `component' is 0xFFFF, the component value from buffer->in_pos
- will copied `num_out' times, otherwise `component' itself will
- be used to fill the `component' fields.
-
- If `lig_id' is 0xFFFF, the lig_id value from buffer->in_pos
- will copied `num_out' times, otherwise `lig_id' itself will
- be used to fill the `lig_id' fields.
-
- The mask for all replacement glyphs are taken
- from the glyph at position `buffer->in_pos'.
-
- The cluster value for the glyph at position buffer->in_pos is used
- for all replacement glyphs */
-void
-_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
- unsigned int num_in,
- unsigned int num_out,
- const uint16_t *glyph_data_be,
- unsigned short component,
- unsigned short lig_id)
-{
- unsigned int i;
- unsigned int mask;
- unsigned int cluster;
-
- if (buffer->out_string != buffer->in_string ||
- buffer->out_pos + num_out > buffer->in_pos + num_in)
- {
- if (HB_UNLIKELY (!hb_buffer_ensure_separate (buffer, buffer->out_pos + num_out)))
- return;
- }
-
- mask = buffer->in_string[buffer->in_pos].mask;
- cluster = buffer->in_string[buffer->in_pos].cluster;
- if (component == 0xFFFF)
- component = buffer->in_string[buffer->in_pos].component;
- if (lig_id == 0xFFFF)
- lig_id = buffer->in_string[buffer->in_pos].lig_id;
-
- for (i = 0; i < num_out; i++)
- {
- hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i];
- info->codepoint = hb_be_uint16 (glyph_data_be[i]);
- info->mask = mask;
- info->cluster = cluster;
- info->component = component;
- info->lig_id = lig_id;
- info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
- }
-
- buffer->in_pos += num_in;
- buffer->out_pos += num_out;
- buffer->out_length = buffer->out_pos;
-}
-
-
-void
-_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
- hb_codepoint_t glyph_index,
- unsigned short component,
- unsigned short lig_id)
-{
- hb_internal_glyph_info_t *info;
-
- if (buffer->out_string != buffer->in_string)
- {
- if (HB_UNLIKELY (!hb_buffer_ensure (buffer, buffer->out_pos + 1))) return;
- buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
- }
- else if (buffer->out_pos != buffer->in_pos)
- buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
-
- info = &buffer->out_string[buffer->out_pos];
- info->codepoint = glyph_index;
- if (component != 0xFFFF)
- info->component = component;
- if (lig_id != 0xFFFF)
- info->lig_id = lig_id;
- info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
-
- buffer->in_pos++;
- buffer->out_pos++;
- buffer->out_length = buffer->out_pos;
-}
-
-void
-_hb_buffer_next_glyph (hb_buffer_t *buffer)
-{
- if (!buffer->have_output)
- {
- buffer->in_pos++;
- return;
- }
-
- if (buffer->out_string != buffer->in_string)
- {
- if (HB_UNLIKELY (!hb_buffer_ensure (buffer, buffer->out_pos + 1))) return;
- buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
- }
- else if (buffer->out_pos != buffer->in_pos)
- buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
-
- buffer->in_pos++;
- buffer->out_pos++;
- buffer->out_length = buffer->out_pos;
-}
-
-void
-_hb_buffer_replace_glyph (hb_buffer_t *buffer,
- hb_codepoint_t glyph_index)
-{
- _hb_buffer_add_output_glyph (buffer, glyph_index, 0xFFFF, 0xFFFF);
-}
-
-unsigned short
-_hb_buffer_allocate_lig_id (hb_buffer_t *buffer)
-{
- return ++buffer->max_lig_id;
-}
-
-
-unsigned int
-hb_buffer_get_len (hb_buffer_t *buffer)
-{
- return buffer->in_length;
-}
-
-/* Return value valid as long as buffer not modified */
-hb_glyph_info_t *
-hb_buffer_get_glyph_infos (hb_buffer_t *buffer)
-{
- return (hb_glyph_info_t *) buffer->in_string;
-}
-
-/* Return value valid as long as buffer not modified */
-hb_glyph_position_t *
-hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
-{
- if (buffer->have_output || (buffer->in_length && !buffer->positions))
- hb_buffer_clear_positions (buffer);
-
- return (hb_glyph_position_t *) buffer->positions;
-}
-
-
-void
-hb_buffer_reverse (hb_buffer_t *buffer)
-{
- unsigned int i, j;
-
- for (i = 0, j = buffer->in_length - 1; i < buffer->in_length / 2; i++, j--) {
- hb_internal_glyph_info_t t;
-
- t = buffer->in_string[i];
- buffer->in_string[i] = buffer->in_string[j];
- buffer->in_string[j] = t;
- }
-
- if (buffer->positions) {
- for (i = 0, j = buffer->in_length - 1; i < buffer->in_length / 2; i++, j--) {
- hb_internal_glyph_position_t t;
-
- t = buffer->positions[i];
- buffer->positions[i] = buffer->positions[j];
- buffer->positions[j] = t;
- }
- }
-}
-
-
-#define ADD_UTF(T) \
- HB_STMT_START { \
- const T *next = (const T *) text + item_offset; \
- const T *end = next + item_length; \
- while (next < end) { \
- hb_codepoint_t u; \
- const T *old_next = next; \
- next = UTF_NEXT (next, end, u); \
- hb_buffer_add_glyph (buffer, u, 0, old_next - (const T *) text); \
- } \
- } HB_STMT_END
-
-
-#define UTF8_COMPUTE(Char, Mask, Len) \
- if (Char < 128) { Len = 1; Mask = 0x7f; } \
- else if ((Char & 0xe0) == 0xc0) { Len = 2; Mask = 0x1f; } \
- else if ((Char & 0xf0) == 0xe0) { Len = 3; Mask = 0x0f; } \
- else if ((Char & 0xf8) == 0xf0) { Len = 4; Mask = 0x07; } \
- else Len = 0;
-
-static inline const uint8_t *
-hb_utf8_next (const uint8_t *text,
- const uint8_t *end,
- hb_codepoint_t *unicode)
-{
- uint8_t c = *text;
- unsigned int mask, len;
-
- UTF8_COMPUTE (c, mask, len);
- if (HB_UNLIKELY (!len || (unsigned int) (end - text) < len)) {
- *unicode = -1;
- return text + 1;
- } else {
- hb_codepoint_t result;
- unsigned int i;
- result = c & mask;
- for (i = 1; i < len; i++)
- {
- if (HB_UNLIKELY ((text[i] & 0xc0) != 0x80))
- {
- *unicode = -1;
- return text + 1;
- }
- result <<= 6;
- result |= (text[i] & 0x3f);
- }
- *unicode = result;
- return text + len;
- }
-}
-
-void
-hb_buffer_add_utf8 (hb_buffer_t *buffer,
- const char *text,
- unsigned int text_length,
- unsigned int item_offset,
- unsigned int item_length)
-{
-#define UTF_NEXT(S, E, U) hb_utf8_next (S, E, &(U))
- ADD_UTF (uint8_t);
-#undef UTF_NEXT
-}
-
-static inline const uint16_t *
-hb_utf16_next (const uint16_t *text,
- const uint16_t *end,
- hb_codepoint_t *unicode)
-{
- uint16_t c = *text++;
-
- if (HB_UNLIKELY (c >= 0xd800 && c < 0xdc00)) {
- /* high surrogate */
- uint16_t l;
- if (text < end && ((l = *text), HB_UNLIKELY (l >= 0xdc00 && l < 0xe000))) {
- /* low surrogate */
- *unicode = ((hb_codepoint_t) ((c) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000);
- text++;
- } else
- *unicode = -1;
- } else
- *unicode = c;
-
- return text;
-}
-
-void
-hb_buffer_add_utf16 (hb_buffer_t *buffer,
- const uint16_t *text,
- unsigned int text_length,
- unsigned int item_offset,
- unsigned int item_length)
-{
-#define UTF_NEXT(S, E, U) hb_utf16_next (S, E, &(U))
- ADD_UTF (uint16_t);
-#undef UTF_NEXT
-}
-
-void
-hb_buffer_add_utf32 (hb_buffer_t *buffer,
- const uint32_t *text,
- unsigned int text_length,
- unsigned int item_offset,
- unsigned int item_length)
-{
-#define UTF_NEXT(S, E, U) ((U) = *(S), (S)+1)
- ADD_UTF (uint32_t);
-#undef UTF_NEXT
-}
diff --git a/pango/opentype/hb-buffer.h b/pango/opentype/hb-buffer.h
deleted file mode 100644
index aaf6694e..00000000
--- a/pango/opentype/hb-buffer.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 1998-2004 David Turner and Werner Lemberg
- * Copyright (C) 2004,2007,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
- */
-
-#ifndef HB_BUFFER_H
-#define HB_BUFFER_H
-
-#include "hb-common.h"
-
-HB_BEGIN_DECLS
-
-typedef struct _hb_buffer_t hb_buffer_t;
-
-typedef enum _hb_direction_t {
- HB_DIRECTION_LTR,
- HB_DIRECTION_RTL,
- HB_DIRECTION_TTB,
- HB_DIRECTION_BTT
-} hb_direction_t;
-
-typedef struct _hb_glyph_info_t {
- hb_codepoint_t codepoint;
- hb_mask_t mask;
- uint32_t cluster;
- uint32_t internal1;
- uint32_t internal2;
-} hb_glyph_info_t;
-
-typedef struct _hb_glyph_position_t {
- hb_position_t x_pos;
- hb_position_t y_pos;
- hb_position_t x_advance;
- hb_position_t y_advance;
- /* XXX these should all be replaced by "uint32_t internal" */
- uint32_t new_advance :1; /* if set, the advance width values are
- absolute, i.e., they won't be
- added to the original glyph's value
- but rather replace them */
- uint32_t back : 15; /* number of glyphs to go back
- for drawing current glyph */
- int32_t cursive_chain : 16; /* character to which this connects,
- may be positive or negative; used
- only internally */
-} hb_glyph_position_t;
-
-
-hb_buffer_t *
-hb_buffer_create (unsigned int pre_alloc_size);
-
-hb_buffer_t *
-hb_buffer_reference (hb_buffer_t *buffer);
-
-unsigned int
-hb_buffer_get_reference_count (hb_buffer_t *buffer);
-
-void
-hb_buffer_destroy (hb_buffer_t *buffer);
-
-
-void
-hb_buffer_set_direction (hb_buffer_t *buffer,
- hb_direction_t direction);
-
-hb_direction_t
-hb_buffer_get_direction (hb_buffer_t *buffer);
-
-
-void
-hb_buffer_clear (hb_buffer_t *buffer);
-
-void
-hb_buffer_clear_positions (hb_buffer_t *buffer);
-
-hb_bool_t
-hb_buffer_ensure (hb_buffer_t *buffer,
- unsigned int size);
-
-void
-hb_buffer_reverse (hb_buffer_t *buffer);
-
-
-/* Filling the buffer in */
-
-void
-hb_buffer_add_glyph (hb_buffer_t *buffer,
- hb_codepoint_t codepoint,
- hb_mask_t mask,
- unsigned int cluster);
-
-void
-hb_buffer_add_utf8 (hb_buffer_t *buffer,
- const char *text,
- unsigned int text_length,
- unsigned int item_offset,
- unsigned int item_length);
-
-void
-hb_buffer_add_utf16 (hb_buffer_t *buffer,
- const uint16_t *text,
- unsigned int text_length,
- unsigned int item_offset,
- unsigned int item_length);
-
-void
-hb_buffer_add_utf32 (hb_buffer_t *buffer,
- const uint32_t *text,
- unsigned int text_length,
- unsigned int item_offset,
- unsigned int item_length);
-
-
-/* Getting glyphs out of the buffer */
-
-/* Return value valid as long as buffer not modified */
-unsigned int
-hb_buffer_get_len (hb_buffer_t *buffer);
-
-/* Return value valid as long as buffer not modified */
-hb_glyph_info_t *
-hb_buffer_get_glyph_infos (hb_buffer_t *buffer);
-
-/* Return value valid as long as buffer not modified */
-hb_glyph_position_t *
-hb_buffer_get_glyph_positions (hb_buffer_t *buffer);
-
-
-HB_END_DECLS
-
-#endif /* HB_BUFFER_H */
diff --git a/pango/opentype/hb-common.h b/pango/opentype/hb-common.h
deleted file mode 100644
index a6be6ba5..00000000
--- a/pango/opentype/hb-common.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_COMMON_H
-#define HB_COMMON_H
-
-# ifdef HAVE_STDINT_H
-# include <stdint.h>
-# else ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-# endif
-
-# ifdef __cplusplus
-# define HB_BEGIN_DECLS extern "C" {
-# define HB_END_DECLS }
-# else /* !__cplusplus */
-# define HB_BEGIN_DECLS
-# define HB_END_DECLS
-# endif /* !__cplusplus */
-
-typedef int hb_bool_t;
-
-typedef uint32_t hb_tag_t;
-#define HB_TAG(a,b,c,d) ((hb_tag_t)(((uint8_t)a<<24)|((uint8_t)b<<16)|((uint8_t)c<<8)|(uint8_t)d))
-#define HB_TAG_STR(s) (HB_TAG(((const char *) s)[0], \
- ((const char *) s)[1], \
- ((const char *) s)[2], \
- ((const char *) s)[3]))
-#define HB_TAG_NONE HB_TAG(0,0,0,0)
-
-typedef uint32_t hb_codepoint_t;
-typedef int32_t hb_position_t;
-typedef int32_t hb_16dot16_t;
-typedef uint32_t hb_mask_t;
-
-typedef void (*hb_destroy_func_t) (void *user_data);
-
-#endif /* HB_COMMON_H */
diff --git a/pango/opentype/hb-font-private.h b/pango/opentype/hb-font-private.h
deleted file mode 100644
index 8d921c71..00000000
--- a/pango/opentype/hb-font-private.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_FONT_PRIVATE_H
-#define HB_FONT_PRIVATE_H
-
-#include "hb-private.h"
-
-#include "hb-font.h"
-
-#include "hb-unicode-private.h"
-#include "hb-ot-layout-private.h"
-
-HB_BEGIN_DECLS
-
-/*
- * hb_font_funcs_t
- */
-
-struct _hb_font_funcs_t {
- hb_reference_count_t ref_count;
-
- hb_bool_t immutable;
-
- hb_font_get_glyph_func_t glyph_func;
- hb_font_get_contour_point_func_t contour_point_func;
- hb_font_get_glyph_metrics_func_t glyph_metrics_func;
- hb_font_get_kerning_func_t kerning_func;
-};
-
-HB_INTERNAL hb_font_funcs_t
-_hb_font_funcs_nil;
-
-/*
- * hb_face_t
- */
-
-struct _hb_face_t {
- hb_reference_count_t ref_count;
-
- hb_blob_t *blob;
- unsigned int index;
-
- hb_get_table_func_t get_table;
- hb_destroy_func_t destroy;
- void *user_data;
-
- hb_unicode_funcs_t *unicode;
-
- hb_ot_layout_t ot_layout;
-};
-
-
-/*
- * hb_font_t
- */
-
-struct _hb_font_t {
- hb_reference_count_t ref_count;
-
- hb_16dot16_t x_scale;
- hb_16dot16_t y_scale;
-
- unsigned int x_ppem;
- unsigned int y_ppem;
-
- hb_font_funcs_t *klass;
-};
-
-
-HB_END_DECLS
-
-#endif /* HB_FONT_PRIVATE_H */
diff --git a/pango/opentype/hb-font.cc b/pango/opentype/hb-font.cc
deleted file mode 100644
index df3d80b9..00000000
--- a/pango/opentype/hb-font.cc
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#include "hb-private.h"
-
-#include "hb-font-private.h"
-#include "hb-unicode-private.h"
-#include "hb-open-file-private.hh"
-#include "hb-blob.h"
-
-#include "hb-ot-layout-private.h"
-
-/*
- * hb_font_funcs_t
- */
-
-hb_font_funcs_t _hb_font_funcs_nil = {
- HB_REFERENCE_COUNT_INVALID, /* ref_count */
-
- TRUE, /* immutable */
-
- NULL, /* glyph_func */
- NULL, /* contour_point_func */
- NULL, /* glyph_metrics_func */
- NULL /* kerning_func */
-};
-
-hb_font_funcs_t *
-hb_font_funcs_create (void)
-{
- hb_font_funcs_t *ffuncs;
-
- if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs))
- return &_hb_font_funcs_nil;
-
- return ffuncs;
-}
-
-hb_font_funcs_t *
-hb_font_funcs_reference (hb_font_funcs_t *ffuncs)
-{
- HB_OBJECT_DO_REFERENCE (ffuncs);
-}
-
-unsigned int
-hb_font_funcs_get_reference_count (hb_font_funcs_t *ffuncs)
-{
- HB_OBJECT_DO_GET_REFERENCE_COUNT (ffuncs);
-}
-
-void
-hb_font_funcs_destroy (hb_font_funcs_t *ffuncs)
-{
- HB_OBJECT_DO_DESTROY (ffuncs);
-
- free (ffuncs);
-}
-
-hb_font_funcs_t *
-hb_font_funcs_copy (hb_font_funcs_t *other_ffuncs)
-{
- hb_font_funcs_t *ffuncs;
-
- if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs))
- return &_hb_font_funcs_nil;
-
- *ffuncs = *other_ffuncs;
-
- /* re-init refcount */
- HB_OBJECT_DO_INIT (ffuncs);
- ffuncs->immutable = FALSE;
-
- return ffuncs;
-}
-
-void
-hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs)
-{
- if (HB_OBJECT_IS_INERT (ffuncs))
- return;
-
- ffuncs->immutable = TRUE;
-}
-
-
-
-/*
- * hb_face_t
- */
-
-static hb_blob_t *
-_hb_face_get_table_from_blob (hb_tag_t tag, void *user_data)
-{
- hb_face_t *face = (hb_face_t *) user_data;
-
- const OpenTypeFontFile &ot_file = Sanitizer<OpenTypeFontFile>::lock_instance (face->blob);
- const OpenTypeFontFace &ot_face = ot_file.get_face (face->index);
-
- const OpenTypeTable &table = ot_face.get_table_by_tag (tag);
-
- hb_blob_t *blob = hb_blob_create_sub_blob (face->blob, table.offset, table.length);
-
- hb_blob_unlock (face->blob);
-
- return blob;
-}
-
-static hb_face_t _hb_face_nil = {
- HB_REFERENCE_COUNT_INVALID, /* ref_count */
-
- NULL, /* blob */
- 0, /* index */
-
- NULL, /* get_table */
- NULL, /* destroy */
- NULL, /* user_data */
-
- &_hb_unicode_funcs_nil, /* unicode */
-
- {} /* ot_layout */
-};
-
-hb_face_t *
-hb_face_create_for_tables (hb_get_table_func_t get_table,
- hb_destroy_func_t destroy,
- void *user_data)
-{
- hb_face_t *face;
-
- if (!HB_OBJECT_DO_CREATE (hb_face_t, face)) {
- if (destroy)
- destroy (user_data);
- return &_hb_face_nil;
- }
-
- face->get_table = get_table;
- face->destroy = destroy;
- face->user_data = user_data;
-
- _hb_ot_layout_init (face);
-
- return face;
-}
-
-hb_face_t *
-hb_face_create_for_data (hb_blob_t *blob,
- unsigned int index)
-{
- hb_face_t *face;
-
- if (!HB_OBJECT_DO_CREATE (hb_face_t, face))
- return &_hb_face_nil;
-
- face->blob = Sanitizer<OpenTypeFontFile>::sanitize (hb_blob_reference (blob));
- face->index = index;
- face->get_table = _hb_face_get_table_from_blob;
- face->user_data = face;
-
- _hb_ot_layout_init (face);
-
- return face;
-}
-
-hb_face_t *
-hb_face_reference (hb_face_t *face)
-{
- HB_OBJECT_DO_REFERENCE (face);
-}
-
-unsigned int
-hb_face_get_reference_count (hb_face_t *face)
-{
- HB_OBJECT_DO_GET_REFERENCE_COUNT (face);
-}
-
-void
-hb_face_destroy (hb_face_t *face)
-{
- HB_OBJECT_DO_DESTROY (face);
-
- _hb_ot_layout_fini (face);
-
- hb_blob_destroy (face->blob);
-
- if (face->destroy)
- face->destroy (face->user_data);
-
- hb_unicode_funcs_destroy (face->unicode);
-
- free (face);
-}
-
-void
-hb_face_set_unicode_funcs (hb_face_t *face,
- hb_unicode_funcs_t *unicode)
-{
- if (HB_OBJECT_IS_INERT (face))
- return;
-
- hb_unicode_funcs_reference (unicode);
- hb_unicode_funcs_destroy (face->unicode);
- face->unicode = unicode;
-}
-
-hb_blob_t *
-hb_face_get_table (hb_face_t *face,
- hb_tag_t tag)
-{
- if (HB_UNLIKELY (!face || !face->get_table))
- return hb_blob_create_empty ();
-
- return face->get_table (tag, face->user_data);
-}
-
-
-/*
- * hb_font_t
- */
-
-static hb_font_t _hb_font_nil = {
- HB_REFERENCE_COUNT_INVALID, /* ref_count */
-
- 0, /* x_scale */
- 0, /* y_scale */
-
- 0, /* x_ppem */
- 0, /* y_ppem */
-
- NULL /* klass */
-};
-
-hb_font_t *
-hb_font_create (void)
-{
- hb_font_t *font;
-
- if (!HB_OBJECT_DO_CREATE (hb_font_t, font))
- return &_hb_font_nil;
-
- return font;
-}
-
-hb_font_t *
-hb_font_reference (hb_font_t *font)
-{
- HB_OBJECT_DO_REFERENCE (font);
-}
-
-unsigned int
-hb_font_get_reference_count (hb_font_t *font)
-{
- HB_OBJECT_DO_GET_REFERENCE_COUNT (font);
-}
-
-void
-hb_font_destroy (hb_font_t *font)
-{
- HB_OBJECT_DO_DESTROY (font);
-
- hb_font_funcs_destroy (font->klass);
-
- free (font);
-}
-
-void
-hb_font_set_funcs (hb_font_t *font,
- hb_font_funcs_t *klass)
-{
- if (HB_OBJECT_IS_INERT (font))
- return;
-
- hb_font_funcs_reference (klass);
- hb_font_funcs_destroy (font->klass);
- font->klass = klass;
-}
-
-void
-hb_font_set_scale (hb_font_t *font,
- hb_16dot16_t x_scale,
- hb_16dot16_t y_scale)
-{
- if (HB_OBJECT_IS_INERT (font))
- return;
-
- font->x_scale = x_scale;
- font->y_scale = y_scale;
-}
-
-void
-hb_font_set_ppem (hb_font_t *font,
- unsigned int x_ppem,
- unsigned int y_ppem)
-{
- if (HB_OBJECT_IS_INERT (font))
- return;
-
- font->x_ppem = x_ppem;
- font->y_ppem = y_ppem;
-}
-
diff --git a/pango/opentype/hb-font.h b/pango/opentype/hb-font.h
deleted file mode 100644
index e020bd83..00000000
--- a/pango/opentype/hb-font.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_FONT_H
-#define HB_FONT_H
-
-#include "hb-common.h"
-#include "hb-blob.h"
-#include "hb-unicode.h"
-
-HB_BEGIN_DECLS
-
-typedef struct _hb_face_t hb_face_t;
-typedef struct _hb_font_t hb_font_t;
-
-/*
- * hb_face_t
- */
-
-hb_face_t *
-hb_face_create_for_data (hb_blob_t *blob,
- unsigned int index);
-
-typedef hb_blob_t * (*hb_get_table_func_t) (hb_tag_t tag, void *user_data);
-
-/* calls destroy() when not needing user_data anymore */
-hb_face_t *
-hb_face_create_for_tables (hb_get_table_func_t get_table,
- hb_destroy_func_t destroy,
- void *user_data);
-
-hb_face_t *
-hb_face_reference (hb_face_t *face);
-
-unsigned int
-hb_face_get_reference_count (hb_face_t *face);
-
-void
-hb_face_destroy (hb_face_t *face);
-
-void
-hb_face_set_unicode_funcs (hb_face_t *face,
- hb_unicode_funcs_t *unicode_funcs);
-
-hb_blob_t *
-hb_face_get_table (hb_face_t *face,
- hb_tag_t tag);
-
-
-/*
- * hb_font_funcs_t
- */
-
-typedef struct _hb_font_funcs_t hb_font_funcs_t;
-
-hb_font_funcs_t *
-hb_font_funcs_create (void);
-
-hb_font_funcs_t *
-hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
-
-unsigned int
-hb_font_funcs_get_reference_count (hb_font_funcs_t *ffuncs);
-
-void
-hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
-
-hb_font_funcs_t *
-hb_font_funcs_copy (hb_font_funcs_t *ffuncs);
-
-void
-hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
-
-
-/* funcs */
-
-typedef struct _hb_glyph_metrics_t hb_glyph_metrics_t;
-struct _hb_glyph_metrics_t
-{
- hb_position_t x_advance;
- hb_position_t y_advance;
- hb_position_t x_offset;
- hb_position_t y_offset;
- hb_position_t width;
- hb_position_t height;
-};
-
-typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
- hb_codepoint_t unicode, hb_codepoint_t variant_selector);
-typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
- unsigned int point_index,
- hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y);
-typedef void (*hb_font_get_glyph_metrics_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
- hb_codepoint_t glyph, hb_glyph_metrics_t *metrics);
-typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
-
-
-void
-hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_func_t glyph_func);
-
-void
-hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
- hb_font_get_contour_point_func_t contour_point_func);
-
-void
-hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_metrics_func_t glyph_metrics_func);
-
-void
-hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
- hb_font_get_kerning_func_t kerning_func);
-
-
-/*
- * hb_font_t
- */
-
-/* Fonts are very light-weight objects */
-
-hb_font_t *
-hb_font_create (void);
-
-hb_font_t *
-hb_font_reference (hb_font_t *font);
-
-unsigned int
-hb_font_get_reference_count (hb_font_t *font);
-
-void
-hb_font_destroy (hb_font_t *font);
-
-void
-hb_font_set_funcs (hb_font_t *font,
- hb_font_funcs_t *klass);
-
-/*
- * XXX
- * should we decompose this to units_per_EM and font-size?
- * units_per_EM setting then can go into the face, or better,
- * read from the 'head' table.
- *
- * Then we either need size+shape like freetype does, or a full
- * matrix.
- */
-void
-hb_font_set_scale (hb_font_t *font,
- hb_16dot16_t x_scale,
- hb_16dot16_t y_scale);
-
-/*
- * A zero value means "no hinting in that direction"
- */
-void
-hb_font_set_ppem (hb_font_t *font,
- unsigned int x_ppem,
- unsigned int y_ppem);
-
-
-HB_END_DECLS
-
-#endif /* HB_FONT_H */
diff --git a/pango/opentype/hb-glib.c b/pango/opentype/hb-glib.c
deleted file mode 100644
index 9fb3d914..00000000
--- a/pango/opentype/hb-glib.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#include "hb-private.h"
-
-#include "hb-glib.h"
-
-#include "hb-unicode-private.h"
-
-static hb_codepoint_t hb_glib_get_mirroring (hb_codepoint_t unicode) { g_unichar_get_mirror_char (unicode, &unicode); return unicode; }
-static hb_category_t hb_glib_get_general_category (hb_codepoint_t unicode) { return g_unichar_type (unicode); }
-static hb_script_t hb_glib_get_script (hb_codepoint_t unicode) { return g_unichar_get_script (unicode); }
-static unsigned int hb_glib_get_combining_class (hb_codepoint_t unicode) { return g_unichar_combining_class (unicode); }
-static unsigned int hb_glib_get_eastasian_width (hb_codepoint_t unicode) { return g_unichar_iswide (unicode); }
-
-
-static hb_unicode_funcs_t glib_ufuncs = {
- HB_REFERENCE_COUNT_INVALID, /* ref_count */
-
- TRUE, /* immutable */
-
- hb_glib_get_general_category,
- hb_glib_get_combining_class,
- hb_glib_get_mirroring,
- hb_glib_get_script,
- hb_glib_get_eastasian_width
-};
-
-hb_unicode_funcs_t *
-hb_glib_get_unicode_funcs (void)
-{
- return &glib_ufuncs;
-}
diff --git a/pango/opentype/hb-glib.h b/pango/opentype/hb-glib.h
deleted file mode 100644
index 6c949932..00000000
--- a/pango/opentype/hb-glib.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_GLIB_H
-#define HB_GLIB_H
-
-#include "hb.h"
-
-#include "hb-unicode.h"
-
-HB_BEGIN_DECLS
-
-hb_unicode_funcs_t *
-hb_glib_get_unicode_funcs (void);
-
-HB_END_DECLS
-
-#endif /* HB_GLIB_H */
diff --git a/pango/opentype/hb-object-private.h b/pango/opentype/hb-object-private.h
deleted file mode 100644
index 2186e58e..00000000
--- a/pango/opentype/hb-object-private.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2007 Chris Wilson
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_REFCOUNT_PRIVATE_H
-#define HB_REFCOUNT_PRIVATE_H
-
-
-/* Encapsulate operations on the object's reference count */
-typedef struct {
- hb_atomic_int_t ref_count;
-} hb_reference_count_t;
-
-#define hb_reference_count_inc(RC) hb_atomic_int_fetch_and_add ((RC).ref_count, 1)
-#define hb_reference_count_dec(RC) hb_atomic_int_fetch_and_add ((RC).ref_count, -1)
-
-#define HB_REFERENCE_COUNT_INIT(RC, VALUE) ((RC).ref_count = (VALUE))
-
-#define HB_REFERENCE_COUNT_GET_VALUE(RC) hb_atomic_int_get ((RC).ref_count)
-#define HB_REFERENCE_COUNT_SET_VALUE(RC, VALUE) hb_atomic_int_set ((RC).ref_count, (VALUE))
-
-#define HB_REFERENCE_COUNT_INVALID_VALUE ((hb_atomic_int_t) -1)
-#define HB_REFERENCE_COUNT_INVALID {HB_REFERENCE_COUNT_INVALID_VALUE}
-
-#define HB_REFERENCE_COUNT_IS_INVALID(RC) (HB_REFERENCE_COUNT_GET_VALUE (RC) == HB_REFERENCE_COUNT_INVALID_VALUE)
-
-#define HB_REFERENCE_COUNT_HAS_REFERENCE(RC) (HB_REFERENCE_COUNT_GET_VALUE (RC) > 0)
-
-
-
-/* Helper macros */
-
-#define HB_OBJECT_IS_INERT(obj) \
- (HB_UNLIKELY (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count)))
-
-#define HB_OBJECT_DO_INIT_EXPR(obj) \
- HB_REFERENCE_COUNT_INIT (obj->ref_count, 1)
-
-#define HB_OBJECT_DO_INIT(obj) \
- HB_STMT_START { \
- HB_OBJECT_DO_INIT_EXPR (obj); \
- } HB_STMT_END
-
-#define HB_OBJECT_DO_CREATE(Type, obj) \
- HB_LIKELY (( \
- (obj) = (Type *) calloc (1, sizeof (Type)), \
- HB_OBJECT_DO_INIT_EXPR (obj), \
- (obj) \
- ))
-
-#define HB_OBJECT_DO_REFERENCE(obj) \
- HB_STMT_START { \
- int old_count; \
- if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
- return obj; \
- old_count = hb_reference_count_inc (obj->ref_count); \
- assert (old_count > 0); \
- return obj; \
- } HB_STMT_END
-
-#define HB_OBJECT_DO_GET_REFERENCE_COUNT(obj) \
- HB_STMT_START { \
- if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
- return 0; \
- return HB_REFERENCE_COUNT_GET_VALUE (obj->ref_count); \
- } HB_STMT_END
-
-#define HB_OBJECT_DO_DESTROY(obj) \
- HB_STMT_START { \
- int old_count; \
- if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
- return; \
- old_count = hb_reference_count_dec (obj->ref_count); \
- assert (old_count > 0); \
- if (old_count != 1) \
- return; \
- } HB_STMT_END
-
-
-#endif /* HB_REFCOUNT_PRIVATE_H */
diff --git a/pango/opentype/hb-open-file-private.hh b/pango/opentype/hb-open-file-private.hh
deleted file mode 100644
index 080975b7..00000000
--- a/pango/opentype/hb-open-file-private.hh
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OPEN_FILE_PRIVATE_HH
-#define HB_OPEN_FILE_PRIVATE_HH
-
-#include "hb-open-type-private.hh"
-
-
-/*
- *
- * The OpenType Font File
- *
- */
-
-
-/*
- * Organization of an OpenType Font
- */
-
-struct OpenTypeFontFile;
-struct OffsetTable;
-struct TTCHeader;
-
-typedef struct TableDirectory
-{
- static inline unsigned int get_size () { return sizeof (TableDirectory); }
-
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE (tag) &&
- SANITIZE_MEM (CONST_CHARP(base) + (unsigned long) offset, length);
- }
-
- Tag tag; /* 4-byte identifier. */
- CheckSum checkSum; /* CheckSum for this table. */
- ULONG offset; /* Offset from beginning of TrueType font
- * file. */
- ULONG length; /* Length of this table. */
-} OpenTypeTable;
-ASSERT_SIZE (TableDirectory, 16);
-
-typedef struct OffsetTable
-{
- friend struct OpenTypeFontFile;
- friend struct TTCHeader;
-
- STATIC_DEFINE_GET_FOR_DATA (OffsetTable);
-
- inline unsigned int get_table_count (void) const
- { return numTables; }
- inline const Tag& get_table_tag (unsigned int i) const
- {
- if (HB_UNLIKELY (i >= numTables)) return Null(Tag);
- return tableDir[i].tag;
- }
- inline const TableDirectory& get_table (unsigned int i) const
- {
- if (HB_UNLIKELY (i >= numTables)) return Null(TableDirectory);
- return tableDir[i];
- }
- inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const
- {
- Tag t;
- t.set (tag);
- // TODO bsearch
- unsigned int count = numTables;
- for (unsigned int i = 0; i < count; i++)
- {
- if (t == tableDir[i].tag)
- {
- if (table_index) *table_index = i;
- return true;
- }
- }
- if (table_index) *table_index = NO_INDEX;
- return false;
- }
- inline const TableDirectory& get_table_by_tag (hb_tag_t tag) const
- {
- unsigned int table_index;
- find_table_index (tag, &table_index);
- return get_table (table_index);
- }
-
- inline unsigned int get_face_count (void) const { return 1; }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
- TRACE_SANITIZE ();
- if (!(SANITIZE_SELF () && SANITIZE_MEM (tableDir, tableDir[0].get_size () * numTables))) return false;
- unsigned int count = numTables;
- for (unsigned int i = 0; i < count; i++)
- if (!SANITIZE_BASE (tableDir[i], base))
- return false;
- return true;
- }
-
- private:
- Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */
- USHORT numTables; /* Number of tables. */
- USHORT searchRange; /* (Maximum power of 2 <= numTables) x 16 */
- USHORT entrySelector; /* Log2(maximum power of 2 <= numTables). */
- USHORT rangeShift; /* NumTables x 16-searchRange. */
- TableDirectory tableDir[VAR]; /* TableDirectory entries. numTables items */
-} OpenTypeFontFace;
-ASSERT_SIZE_VAR (OffsetTable, 12, TableDirectory);
-
-/*
- * TrueType Collections
- */
-
-struct TTCHeader
-{
- friend struct OpenTypeFontFile;
-
- STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (TTCHeader, 1, 2);
-
- inline unsigned int get_face_count (void) const { return table.len; }
-
- inline const OpenTypeFontFace& get_face (unsigned int i) const
- {
- return this+table[i];
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (version)) return false;
- if (version.major < 1 || version.major > 2) return true;
- /* TODO Maybe we shouldn't NEUTER these offsets, they may cause a full copy
- * of the whole font right now. */
- return table.sanitize (SANITIZE_ARG, CONST_CHARP(this), CONST_CHARP(this));
- }
-
- private:
- Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */
- FixedVersion version; /* Version of the TTC Header (1.0 or 2.0),
- * 0x00010000 or 0x00020000 */
- LongOffsetLongArrayOf<OffsetTable>
- table; /* Array of offsets to the OffsetTable for each font
- * from the beginning of the file */
-};
-ASSERT_SIZE (TTCHeader, 12);
-
-
-/*
- * OpenType Font File
- */
-
-struct OpenTypeFontFile
-{
- static const hb_tag_t TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 );
- static const hb_tag_t CFFTag = HB_TAG ('O','T','T','O');
- static const hb_tag_t TTCTag = HB_TAG ('t','t','c','f');
-
- STATIC_DEFINE_GET_FOR_DATA (OpenTypeFontFile);
-
- inline unsigned int get_face_count (void) const
- {
- switch (tag) {
- default: return 0;
- case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CONST_CHARP(this)).get_face_count ();
- case TTCTag: return TTCHeader::get_for_data (CONST_CHARP(this)).get_face_count ();
- }
- }
- inline const OpenTypeFontFace& get_face (unsigned int i) const
- {
- switch (tag) {
- default: return Null(OpenTypeFontFace);
- /* Note: for non-collection SFNT data we ignore index. This is because
- * Apple dfont container is a container of SFNT's. So each SFNT is a
- * non-TTC, but the index is more than zero. */
- case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CONST_CHARP(this));
- case TTCTag: return TTCHeader::get_for_data (CONST_CHARP(this)).get_face (i);
- }
- }
-
- /* This is how you get a table */
- inline const char* get_table_data (const OpenTypeTable& table) const
- {
- if (HB_UNLIKELY (table.offset == 0)) return NULL;
- return ((const char*) this) + table.offset;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
- switch (tag) {
- default: return true;
- case TrueTypeTag: case CFFTag: return SANITIZE_THIS (CAST (OffsetTable, *this, 0));
- case TTCTag: return SANITIZE (CAST (TTCHeader, *this, 0));
- }
- }
-
- Tag tag; /* 4-byte identifier. */
-};
-ASSERT_SIZE (OpenTypeFontFile, 4);
-
-
-#endif /* HB_OPEN_FILE_PRIVATE_HH */
diff --git a/pango/opentype/hb-open-type-private.hh b/pango/opentype/hb-open-type-private.hh
deleted file mode 100644
index d93b8e7a..00000000
--- a/pango/opentype/hb-open-type-private.hh
+++ /dev/null
@@ -1,640 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OPEN_TYPES_PRIVATE_HH
-#define HB_OPEN_TYPES_PRIVATE_HH
-
-#include "hb-private.h"
-
-#include "hb-blob.h"
-
-
-#define NO_INDEX ((unsigned int) 0xFFFF)
-
-
-/*
- * Casts
- */
-
-#define CONST_CHARP(X) (reinterpret_cast<const char *>(X))
-#define DECONST_CHARP(X) ((char *)reinterpret_cast<const char *>(X))
-#define CHARP(X) (reinterpret_cast<char *>(X))
-
-#define CONST_CAST(T,X,Ofs) (*(reinterpret_cast<const T *>(CONST_CHARP(&(X)) + Ofs)))
-#define DECONST_CAST(T,X,Ofs) (*(reinterpret_cast<T *>((char *)CONST_CHARP(&(X)) + Ofs)))
-#define CAST(T,X,Ofs) (*(reinterpret_cast<T *>(CHARP(&(X)) + Ofs)))
-
-#define CONST_NEXT(T,X) (*(reinterpret_cast<const T *>(CONST_CHARP(&(X)) + (X).get_size ())))
-#define NEXT(T,X) (*(reinterpret_cast<T *>(CHARP(&(X)) + (X).get_size ())))
-
-#define CONST_ARRAY_AFTER(T,X) ((reinterpret_cast<const T *>(CONST_CHARP(&(X)) + X.get_size ())))
-#define ARRAY_AFTER(T,X) ((reinterpret_cast<T *>(CHARP(&(X)) + X.get_size ())))
-
-/*
- * Class features
- */
-
-
-/* Null objects */
-
-/* Global nul-content Null pool. Enlarge as necessary. */
-static const void *_NullPool[32 / sizeof (void *)];
-
-/* Generic template for nul-content sizeof-sized Null objects. */
-template <typename Type>
-static inline const Type& Null () {
- ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool));
- return CONST_CAST (Type, *_NullPool, 0);
-}
-
-/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
-#define DEFINE_NULL_DATA(Type, size, data) \
-static const char _Null##Type[size + 1] = data; \
-template <> \
-inline const Type& Null<Type> () { \
- return CONST_CAST (Type, *_Null##Type, 0); \
-}
-
-/* Accessor macro. */
-#define Null(Type) Null<Type>()
-
-
-/* get_for_data() is a static class method returning a reference to an
- * instance of Type located at the input data location. It's just a
- * fancy, NULL-safe, cast! */
-#define STATIC_DEFINE_GET_FOR_DATA(Type) \
- static inline const Type& get_for_data (const char *data) \
- { \
- if (HB_UNLIKELY (data == NULL)) return Null(Type); \
- return CONST_CAST (Type, *data, 0); \
- }
-/* Like get_for_data(), but checks major version first. */
-#define STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION(Type, MajorMin, MajorMax) \
- static inline const Type& get_for_data (const char *data) \
- { \
- if (HB_UNLIKELY (data == NULL)) return Null(Type); \
- const Type& t = CONST_CAST (Type, *data, 0); \
- if (HB_UNLIKELY (t.version.major < MajorMin || t.version.major > MajorMax)) return Null(Type); \
- return t; \
- }
-
-
-/*
- * Sanitize
- */
-
-#ifndef HB_DEBUG_SANITIZE
-#define HB_DEBUG_SANITIZE HB_DEBUG
-#endif
-
-#if HB_DEBUG_SANITIZE
-#define TRACE_SANITIZE_ARG_DEF , unsigned int sanitize_depth HB_GNUC_UNUSED
-#define TRACE_SANITIZE_ARG , sanitize_depth + 1
-#define TRACE_SANITIZE_ARG_INIT , 1
-#define TRACE_SANITIZE() \
- HB_STMT_START { \
- if (sanitize_depth < HB_DEBUG_SANITIZE) \
- fprintf (stderr, "SANITIZE(%p) %-*d-> %s\n", \
- (CONST_CHARP (this) == CONST_CHARP (&NullPool)) ? 0 : this, \
- sanitize_depth, sanitize_depth, \
- __PRETTY_FUNCTION__); \
- } HB_STMT_END
-#else
-#define TRACE_SANITIZE_ARG_DEF
-#define TRACE_SANITIZE_ARG
-#define TRACE_SANITIZE_ARG_INIT
-#define TRACE_SANITIZE() HB_STMT_START {} HB_STMT_END
-#endif
-
-#define SANITIZE_ARG_DEF \
- hb_sanitize_context_t *context TRACE_SANITIZE_ARG_DEF
-#define SANITIZE_ARG \
- context TRACE_SANITIZE_ARG
-#define SANITIZE_ARG_INIT \
- &context TRACE_SANITIZE_ARG_INIT
-
-typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
-struct _hb_sanitize_context_t
-{
- const char *start, *end;
- int edit_count;
- hb_blob_t *blob;
-};
-
-static HB_GNUC_UNUSED void
-_hb_sanitize_init (hb_sanitize_context_t *context,
- hb_blob_t *blob)
-{
- context->blob = blob;
- context->start = hb_blob_lock (blob);
- context->end = context->start + hb_blob_get_length (blob);
- context->edit_count = 0;
-
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "sanitize %p init [%p..%p] (%u bytes)\n",
- context->blob, context->start, context->end, context->end - context->start);
-#endif
-}
-
-static HB_GNUC_UNUSED void
-_hb_sanitize_fini (hb_sanitize_context_t *context,
- bool unlock)
-{
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n",
- context->blob, context->start, context->end, context->edit_count);
-#endif
-
- if (unlock)
- hb_blob_unlock (context->blob);
-}
-
-static HB_GNUC_UNUSED inline bool
-_hb_sanitize_check (SANITIZE_ARG_DEF,
- const char *base,
- unsigned int len)
-{
- bool ret = context->start <= base &&
- base <= context->end &&
- (unsigned int) (context->end - base) >= len;
-
-#if HB_DEBUG_SANITIZE
- if (sanitize_depth < HB_DEBUG_SANITIZE) \
- fprintf (stderr, "SANITIZE(%p) %-*d-> check [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
- base,
- sanitize_depth, sanitize_depth,
- base, base+len, len,
- context->start, context->end,
- ret ? "pass" : "FAIL");
-#endif
- return ret;
-}
-
-static HB_GNUC_UNUSED inline bool
-_hb_sanitize_array (SANITIZE_ARG_DEF,
- const char *base,
- unsigned int record_size,
- unsigned int len)
-{
- bool overflows = record_size > 0 && len >= ((unsigned int) -1) / record_size;
-
-#if HB_DEBUG_SANITIZE
- if (sanitize_depth < HB_DEBUG_SANITIZE) \
- fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
- base,
- sanitize_depth, sanitize_depth,
- base, base + (record_size * len), record_size, len, (unsigned long) record_size * len,
- context->start, context->end,
- !overflows ? "does not overflow" : "OVERFLOWS FAIL");
-#endif
- return HB_LIKELY (!overflows) && _hb_sanitize_check (SANITIZE_ARG, base, record_size * len);
-}
-
-static HB_GNUC_UNUSED inline bool
-_hb_sanitize_edit (SANITIZE_ARG_DEF,
- const char *base HB_GNUC_UNUSED,
- unsigned int len HB_GNUC_UNUSED)
-{
- bool perm = hb_blob_try_writable_inplace (context->blob);
- context->edit_count++;
-
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
- base,
- sanitize_depth, sanitize_depth,
- context->edit_count,
- base, base+len, len,
- context->start, context->end,
- perm ? "granted" : "REJECTED");
-#endif
- return perm;
-}
-
-#define SANITIZE(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG))
-#define SANITIZE2(X,Y) (SANITIZE (X) && SANITIZE (Y))
-
-#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, CONST_CHARP(this)))
-#define SANITIZE_THIS2(X,Y) (SANITIZE_THIS (X) && SANITIZE_THIS (Y))
-#define SANITIZE_THIS3(X,Y,Z) (SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z))
-
-#define SANITIZE_BASE(X,B) HB_LIKELY ((X).sanitize (SANITIZE_ARG, B))
-#define SANITIZE_BASE2(X,Y,B) (SANITIZE_BASE (X,B) && SANITIZE_BASE (Y,B))
-
-#define SANITIZE_SELF() SANITIZE_OBJ (*this)
-#define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X))
-#define SANITIZE_GET_SIZE() SANITIZE_SELF() && SANITIZE_MEM (this, this->get_size ())
-
-#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, CONST_CHARP(B), (L)))
-
-#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, CONST_CHARP(A), S, L))
-
-#define NEUTER(Var, Val) \
- (SANITIZE_OBJ (Var) && \
- _hb_sanitize_edit (SANITIZE_ARG, CONST_CHARP(&(Var)), sizeof (Var)) && \
- ((Var).set (Val), true))
-
-
-/* Template to sanitize an object. */
-template <typename Type>
-struct Sanitizer
-{
- static hb_blob_t *sanitize (hb_blob_t *blob) {
- hb_sanitize_context_t context;
- bool sane;
-
- /* TODO is_sane() stuff */
-
- retry:
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "Sanitizer %p start %s\n", blob, __PRETTY_FUNCTION__);
-#endif
-
- _hb_sanitize_init (&context, blob);
-
- Type *t = &CAST (Type, *DECONST_CHARP(context.start), 0);
-
- sane = t->sanitize (SANITIZE_ARG_INIT);
- if (sane) {
- if (context.edit_count) {
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "Sanitizer %p passed first round with %d edits; going a second round %s\n",
- blob, context.edit_count, __PRETTY_FUNCTION__);
-#endif
- /* sanitize again to ensure no toe-stepping */
- context.edit_count = 0;
- sane = t->sanitize (SANITIZE_ARG_INIT);
- if (context.edit_count) {
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
- blob, context.edit_count, __PRETTY_FUNCTION__);
-#endif
- sane = false;
- }
- }
- _hb_sanitize_fini (&context, true);
- } else {
- unsigned int edit_count = context.edit_count;
- _hb_sanitize_fini (&context, true);
- if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) {
- /* ok, we made it writable by relocating. try again */
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "Sanitizer %p retry %s\n", blob, __PRETTY_FUNCTION__);
-#endif
- goto retry;
- }
- }
-
-#if HB_DEBUG_SANITIZE
- fprintf (stderr, "Sanitizer %p %s %s\n", blob, sane ? "passed" : "FAILED", __PRETTY_FUNCTION__);
-#endif
- if (sane)
- return blob;
- else {
- hb_blob_destroy (blob);
- return hb_blob_create_empty ();
- }
- }
-
- static const Type& lock_instance (hb_blob_t *blob) {
- return Type::get_for_data (hb_blob_lock (blob));
- }
-};
-
-
-/*
- *
- * The OpenType Font File: Data Types
- */
-
-
-/* "The following data types are used in the OpenType font file.
- * All OpenType fonts use Motorola-style byte ordering (Big Endian):" */
-
-/*
- * Int types
- */
-
-/* TODO On machines that allow unaligned access, use this version. */
-#define _DEFINE_INT_TYPE1_UNALIGNED(NAME, TYPE, BIG_ENDIAN, BYTES) \
- struct NAME \
- { \
- inline NAME& set (TYPE i) { (TYPE&) v = BIG_ENDIAN (i); return *this; } \
- inline operator TYPE(void) const { return BIG_ENDIAN ((TYPE&) v); } \
- inline bool operator == (const NAME &o) const { return (TYPE&) v == (TYPE&) o.v; } \
- inline bool sanitize (SANITIZE_ARG_DEF) { \
- TRACE_SANITIZE (); \
- return SANITIZE_SELF (); \
- } \
- private: unsigned char v[BYTES]; \
- }; \
- ASSERT_SIZE (NAME, BYTES)
-
-#define DEFINE_INT_TYPE1(NAME, TYPE, BIG_ENDIAN, BYTES) \
- struct NAME \
- { \
- static inline unsigned int get_size () { return BYTES; } \
- inline void set (TYPE i) { BIG_ENDIAN##_put_unaligned(v, i); } \
- inline operator TYPE(void) const { return BIG_ENDIAN##_get_unaligned (v); } \
- inline bool operator == (const NAME &o) const { return BIG_ENDIAN##_cmp_unaligned (v, o.v); } \
- inline bool sanitize (SANITIZE_ARG_DEF) { \
- TRACE_SANITIZE (); \
- return SANITIZE_SELF (); \
- } \
- private: unsigned char v[BYTES]; \
- }; \
- ASSERT_SIZE (NAME, BYTES)
-#define DEFINE_INT_TYPE0(NAME, type, b) DEFINE_INT_TYPE1 (NAME, type##_t, hb_be_##type, b)
-#define DEFINE_INT_TYPE(NAME, u, w) DEFINE_INT_TYPE0 (NAME, u##int##w, (w / 8))
-
-
-DEFINE_INT_TYPE (USHORT, u, 16); /* 16-bit unsigned integer. */
-DEFINE_INT_TYPE (SHORT, , 16); /* 16-bit signed integer. */
-DEFINE_INT_TYPE (ULONG, u, 32); /* 32-bit unsigned integer. */
-DEFINE_INT_TYPE (LONG, , 32); /* 32-bit signed integer. */
-
-
-/* Array of four uint8s (length = 32 bits) used to identify a script, language
- * system, feature, or baseline */
-struct Tag : ULONG
-{
- /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */
- inline operator const char* (void) const { return CONST_CHARP(this); }
- inline operator char* (void) { return CHARP(this); }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- /* Note: Only accept ASCII-visible tags (mind DEL)
- * This is one of the few times (only time?) we check
- * for data integrity, as opposed o just boundary checks
- */
- return SANITIZE_SELF () && (((uint32_t) *this) & 0x80808080) == 0;
- }
-};
-ASSERT_SIZE (Tag, 4);
-DEFINE_NULL_DATA (Tag, 4, " ");
-
-/* Glyph index number, same as uint16 (length = 16 bits) */
-typedef USHORT GlyphID;
-
-/* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */
-typedef USHORT Offset;
-
-/* LongOffset to a table, same as uint32 (length = 32 bits), Null offset = 0x00000000 */
-typedef ULONG LongOffset;
-
-
-/* CheckSum */
-struct CheckSum : ULONG
-{
- static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length)
- {
- uint32_t Sum = 0L;
- ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::get_size ();
-
- while (Table < EndPtr)
- Sum += *Table++;
- return Sum;
- }
-};
-ASSERT_SIZE (CheckSum, 4);
-
-
-/*
- * Version Numbers
- */
-
-struct FixedVersion
-{
- inline operator uint32_t (void) const { return (major << 16) + minor; }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- USHORT major;
- USHORT minor;
-};
-ASSERT_SIZE (FixedVersion, 4);
-
-
-
-/*
- * Template subclasses of Offset and LongOffset that do the dereferencing.
- * Use: (this+memberName)
- */
-
-template <typename OffsetType, typename Type>
-struct GenericOffsetTo : OffsetType
-{
- inline const Type& operator () (const void *base) const
- {
- unsigned int offset = *this;
- if (HB_UNLIKELY (!offset)) return Null(Type);
- return CONST_CAST(Type, *CONST_CHARP(base), offset);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
- TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
- unsigned int offset = *this;
- if (HB_UNLIKELY (!offset)) return true;
- return SANITIZE (CAST(Type, *DECONST_CHARP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
- }
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) {
- TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
- unsigned int offset = *this;
- if (HB_UNLIKELY (!offset)) return true;
- return SANITIZE_BASE (CAST(Type, *DECONST_CHARP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
- }
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) {
- TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
- unsigned int offset = *this;
- if (HB_UNLIKELY (!offset)) return true;
- return SANITIZE_BASE (CAST(Type, *DECONST_CHARP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0);
- }
-};
-template <typename Base, typename OffsetType, typename Type>
-inline const Type& operator + (const Base &base, GenericOffsetTo<OffsetType, Type> offset) { return offset (base); }
-
-template <typename Type>
-struct OffsetTo : GenericOffsetTo<Offset, Type> {};
-
-template <typename Type>
-struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
-
-
-/*
- * Array Types
- */
-
-template <typename LenType, typename Type>
-struct GenericArrayOf
-{
- const Type *const_array(void) const { return CONST_ARRAY_AFTER (Type, len); }
- Type *array(void) { return ARRAY_AFTER (Type, len); }
-
- inline const Type& operator [] (unsigned int i) const
- {
- if (HB_UNLIKELY (i >= len)) return Null(Type);
- return const_array()[i];
- }
- inline unsigned int get_size () const
- { return len.get_size () + len * Type::get_size (); }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE_GET_SIZE()) return false;
- /* Note: for structs that do not reference other structs,
- * we do not need to call their sanitize() as we already did
- * a bound check on the aggregate array size, hence the return.
- */
- return true;
- /* We do keep this code though to make sure the structs pointed
- * to do have a simple sanitize(), ie. they do not reference
- * other structs. */
- unsigned int count = len;
- for (unsigned int i = 0; i < count; i++)
- if (!SANITIZE (array()[i]))
- return false;
- return true;
- }
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
- TRACE_SANITIZE ();
- if (!SANITIZE_GET_SIZE()) return false;
- unsigned int count = len;
- for (unsigned int i = 0; i < count; i++)
- if (!array()[i].sanitize (SANITIZE_ARG, base))
- return false;
- return true;
- }
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) {
- TRACE_SANITIZE ();
- if (!SANITIZE_GET_SIZE()) return false;
- unsigned int count = len;
- for (unsigned int i = 0; i < count; i++)
- if (!array()[i].sanitize (SANITIZE_ARG, base, base2))
- return false;
- return true;
- }
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) {
- TRACE_SANITIZE ();
- if (!SANITIZE_GET_SIZE()) return false;
- unsigned int count = len;
- for (unsigned int i = 0; i < count; i++)
- if (!array()[i].sanitize (SANITIZE_ARG, base, user_data))
- return false;
- return true;
- }
-
- LenType len;
-/*Type array[VAR];*/
-};
-
-/* An array with a USHORT number of elements. */
-template <typename Type>
-struct ArrayOf : GenericArrayOf<USHORT, Type> {};
-
-/* An array with a ULONG number of elements. */
-template <typename Type>
-struct LongArrayOf : GenericArrayOf<ULONG, Type> {};
-
-/* Array of Offset's */
-template <typename Type>
-struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {};
-
-/* Array of LongOffset's */
-template <typename Type>
-struct LongOffsetArrayOf : ArrayOf<LongOffsetTo<Type> > {};
-
-/* LongArray of LongOffset's */
-template <typename Type>
-struct LongOffsetLongArrayOf : LongArrayOf<LongOffsetTo<Type> > {};
-
-/* Array of offsets relative to the beginning of the array itself. */
-template <typename Type>
-struct OffsetListOf : OffsetArrayOf<Type>
-{
- inline const Type& operator [] (unsigned int i) const
- {
- if (HB_UNLIKELY (i >= this->len)) return Null(Type);
- return this+this->const_array()[i];
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this));
- }
- inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) {
- TRACE_SANITIZE ();
- return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this), user_data);
- }
-};
-
-
-/* An array with a USHORT number of elements,
- * starting at second element. */
-template <typename Type>
-struct HeadlessArrayOf
-{
- const Type *const_array(void) const { return CONST_ARRAY_AFTER (Type, len); }
- Type *array(void) { return ARRAY_AFTER (Type, len); }
-
- inline const Type& operator [] (unsigned int i) const
- {
- if (HB_UNLIKELY (i >= len || !i)) return Null(Type);
- return const_array()[i-1];
- }
- inline unsigned int get_size () const
- { return len.get_size () + (len ? len - 1 : 0) * Type::get_size (); }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE_GET_SIZE()) return false;
- /* Note: for structs that do not reference other structs,
- * we do not need to call their sanitize() as we already did
- * a bound check on the aggregate array size, hence the return.
- */
- return true;
- /* We do keep this code though to make sure the structs pointed
- * to do have a simple sanitize(), ie. they do not reference
- * other structs. */
- unsigned int count = len ? len - 1 : 0;
- Type *a = array();
- for (unsigned int i = 0; i < count; i++)
- if (!SANITIZE (a[i]))
- return false;
- return true;
- }
-
- USHORT len;
-/*Type array[VAR];*/
-};
-
-
-#endif /* HB_OPEN_TYPES_PRIVATE_HH */
diff --git a/pango/opentype/hb-ot-layout-common-private.hh b/pango/opentype/hb-ot-layout-common-private.hh
deleted file mode 100644
index 1f6cf4a2..00000000
--- a/pango/opentype/hb-ot-layout-common-private.hh
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH
-#define HB_OT_LAYOUT_COMMON_PRIVATE_HH
-
-#include "hb-ot-layout-private.h"
-
-#include "hb-open-type-private.hh"
-
-
-#define NO_CONTEXT ((unsigned int) 0x110000)
-#define NOT_COVERED ((unsigned int) 0x110000)
-#define MAX_NESTING_LEVEL 8
-
-
-/*
- *
- * OpenType Layout Common Table Formats
- *
- */
-
-
-/*
- * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList
- */
-
-template <typename Type>
-struct Record
-{
- static inline unsigned int get_size () { return sizeof (Record<Type>); }
-
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
- TRACE_SANITIZE ();
- return SANITIZE (tag) && SANITIZE_BASE (offset, base);
- }
-
- Tag tag; /* 4-byte Tag identifier */
- OffsetTo<Type>
- offset; /* Offset from beginning of object holding
- * the Record */
-};
-
-template <typename Type>
-struct RecordArrayOf : ArrayOf<Record<Type> > {
- inline const Tag& get_tag (unsigned int i) const
- {
- if (HB_UNLIKELY (i >= this->len)) return Null(Tag);
- return (*this)[i].tag;
- }
- inline bool get_tags (unsigned int *record_count /* IN/OUT */,
- hb_tag_t *record_tags /* OUT */) const
- {
- const Record<Type> *a = this->const_array();
- unsigned int count = MIN (this->len, *record_count);
- for (unsigned int i = 0; i < count; i++)
- record_tags[i] = a[i].tag;
-
- *record_count = this->len;
- return !!this->len;
- }
- inline bool find_index (hb_tag_t tag, unsigned int *index) const
- {
- Tag t;
- t.set (tag);
- // TODO bsearch
- const Record<Type> *a = this->const_array();
- unsigned int count = this->len;
- for (unsigned int i = 0; i < count; i++)
- {
- if (t == a[i].tag)
- {
- if (index) *index = i;
- return true;
- }
- }
- if (index) *index = NO_INDEX;
- return false;
- }
-};
-
-template <typename Type>
-struct RecordListOf : RecordArrayOf<Type>
-{
- inline const Type& operator [] (unsigned int i) const
- { return this+RecordArrayOf<Type>::operator[](i).offset; }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return RecordArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this));
- }
-};
-
-
-struct IndexArray : ArrayOf<USHORT>
-{
- inline unsigned int operator [] (unsigned int i) const
- {
- if (HB_UNLIKELY (i >= this->len))
- return NO_INDEX;
- return this->const_array()[i];
- }
- inline bool get_indexes (unsigned int *_count /* IN/OUT */,
- unsigned int *_indexes /* OUT */) const
- {
- unsigned int count = MIN (this->len, *_count);
- const USHORT *a = this->const_array();
- for (unsigned int i = 0; i < count; i++)
- _indexes[i] = a[i];
-
- *_count = this->len;
- return !!this->len;
- }
-};
-
-
-struct Script;
-struct LangSys;
-struct Feature;
-
-
-struct LangSys
-{
- inline unsigned int get_feature_count (void) const
- { return featureIndex.len; }
- inline hb_tag_t get_feature_index (unsigned int i) const
- { return featureIndex[i]; }
- inline bool get_feature_indexes (unsigned int *feature_count /* IN/OUT */,
- unsigned int *feature_indexes /* OUT */) const
- { return featureIndex.get_indexes (feature_count, feature_indexes); }
-
- inline bool has_required_feature (void) const { return reqFeatureIndex != 0xffff; }
- inline int get_required_feature_index (void) const
- {
- if (reqFeatureIndex == 0xffff)
- return NO_INDEX;
- return reqFeatureIndex;;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE (featureIndex);
- }
-
- Offset lookupOrder; /* = Null (reserved for an offset to a
- * reordering table) */
- USHORT reqFeatureIndex;/* Index of a feature required for this
- * language system--if no required features
- * = 0xFFFF */
- IndexArray featureIndex; /* Array of indices into the FeatureList */
-};
-ASSERT_SIZE (LangSys, 6);
-DEFINE_NULL_DATA (LangSys, 6, "\0\0\xFF\xFF");
-
-
-struct Script
-{
- inline unsigned int get_lang_sys_count (void) const
- { return langSys.len; }
- inline const Tag& get_lang_sys_tag (unsigned int i) const
- { return langSys.get_tag (i); }
- inline bool get_lang_sys_tags (unsigned int *lang_sys_count /* IN/OUT */,
- hb_tag_t *lang_sys_tags /* OUT */) const
- { return langSys.get_tags (lang_sys_count, lang_sys_tags); }
- inline const LangSys& get_lang_sys (unsigned int i) const
- {
- if (i == NO_INDEX) return get_default_lang_sys ();
- return this+langSys[i].offset;
- }
- inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const
- { return langSys.find_index (tag, index); }
-
- inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; }
- inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (defaultLangSys) && SANITIZE_THIS (langSys);
- }
-
- private:
- OffsetTo<LangSys>
- defaultLangSys; /* Offset to DefaultLangSys table--from
- * beginning of Script table--may be Null */
- RecordArrayOf<LangSys>
- langSys; /* Array of LangSysRecords--listed
- * alphabetically by LangSysTag */
-};
-ASSERT_SIZE (Script, 4);
-
-typedef RecordListOf<Script> ScriptList;
-ASSERT_SIZE (ScriptList, 2);
-
-
-struct Feature
-{
- inline unsigned int get_lookup_count (void) const
- { return lookupIndex.len; }
- inline hb_tag_t get_lookup_index (unsigned int i) const
- { return lookupIndex[i]; }
- inline bool get_lookup_indexes (unsigned int *lookup_count /* IN/OUT */,
- unsigned int *lookup_tags /* OUT */) const
- { return lookupIndex.get_indexes (lookup_count, lookup_tags); }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE (lookupIndex);
- }
-
- /* TODO: implement get_feature_parameters() */
- /* TODO: implement FeatureSize and other special features? */
- Offset featureParams; /* Offset to Feature Parameters table (if one
- * has been defined for the feature), relative
- * to the beginning of the Feature Table; = Null
- * if not required */
- IndexArray lookupIndex; /* Array of LookupList indices */
-};
-ASSERT_SIZE (Feature, 4);
-
-typedef RecordListOf<Feature> FeatureList;
-ASSERT_SIZE (FeatureList, 2);
-
-
-struct LookupFlag : USHORT
-{
- enum {
- RightToLeft = 0x0001u,
- IgnoreBaseGlyphs = 0x0002u,
- IgnoreLigatures = 0x0004u,
- IgnoreMarks = 0x0008u,
- IgnoreFlags = 0x000Eu,
- UseMarkFilteringSet = 0x0010u,
- Reserved = 0x00E0u,
- MarkAttachmentType = 0xFF00u
- };
-};
-ASSERT_SIZE (LookupFlag, 2);
-
-struct LookupSubTable
-{
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- USHORT format; /* Subtable format. Different for GSUB and GPOS */
-};
-ASSERT_SIZE (LookupSubTable, 2);
-
-struct Lookup
-{
- inline const LookupSubTable& get_subtable (unsigned int i) const { return this+subTable[i]; }
- inline unsigned int get_subtable_count (void) const { return subTable.len; }
-
- inline unsigned int get_type (void) const { return lookupType; }
- inline unsigned int get_flag (void) const
- {
- unsigned int flag = lookupFlag;
- if (HB_UNLIKELY (flag & LookupFlag::UseMarkFilteringSet))
- {
- const USHORT &markFilteringSet = CONST_NEXT (USHORT, subTable);
- flag += (markFilteringSet << 16);
- }
- return flag;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!(SANITIZE (lookupType) && SANITIZE (lookupFlag) && SANITIZE_THIS (subTable))) return false;
- if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
- {
- USHORT &markFilteringSet = NEXT (USHORT, subTable);
- if (!SANITIZE (markFilteringSet)) return false;
- }
- return true;
- }
-
- USHORT lookupType; /* Different enumerations for GSUB and GPOS */
- USHORT lookupFlag; /* Lookup qualifiers */
- OffsetArrayOf<LookupSubTable>
- subTable; /* Array of SubTables */
- USHORT markFilteringSetX[VAR]; /* Index (base 0) into GDEF mark glyph sets
- * structure. This field is only present if bit
- * UseMarkFilteringSet of lookup flags is set. */
-};
-ASSERT_SIZE_VAR (Lookup, 6, USHORT);
-
-typedef OffsetListOf<Lookup> LookupList;
-ASSERT_SIZE (LookupList, 2);
-
-
-/*
- * Coverage Table
- */
-
-struct CoverageFormat1
-{
- friend struct Coverage;
-
- private:
- inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
- {
- if (HB_UNLIKELY (glyph_id > 0xFFFF))
- return NOT_COVERED;
- GlyphID gid;
- gid.set (glyph_id);
- // TODO: bsearch
- unsigned int num_glyphs = glyphArray.len;
- for (unsigned int i = 0; i < num_glyphs; i++)
- if (gid == glyphArray[i])
- return i;
- return NOT_COVERED;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE (glyphArray);
- }
-
- private:
- USHORT coverageFormat; /* Format identifier--format = 1 */
- ArrayOf<GlyphID>
- glyphArray; /* Array of GlyphIDs--in numerical order */
-};
-ASSERT_SIZE (CoverageFormat1, 4);
-
-struct CoverageRangeRecord
-{
- friend struct CoverageFormat2;
-
- static inline unsigned int get_size () { return sizeof (CoverageRangeRecord); }
-
- private:
- inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
- {
- if (glyph_id >= start && glyph_id <= end)
- return (unsigned int) startCoverageIndex + (glyph_id - start);
- return NOT_COVERED;
- }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- GlyphID start; /* First GlyphID in the range */
- GlyphID end; /* Last GlyphID in the range */
- USHORT startCoverageIndex; /* Coverage Index of first GlyphID in
- * range */
-};
-ASSERT_SIZE (CoverageRangeRecord, 6);
-DEFINE_NULL_DATA (CoverageRangeRecord, 6, "\000\001");
-
-struct CoverageFormat2
-{
- friend struct Coverage;
-
- private:
- inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
- {
- // TODO: bsearch
- unsigned int count = rangeRecord.len;
- for (unsigned int i = 0; i < count; i++)
- {
- unsigned int coverage = rangeRecord[i].get_coverage (glyph_id);
- if (coverage != NOT_COVERED)
- return coverage;
- }
- return NOT_COVERED;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE (rangeRecord);
- }
-
- private:
- USHORT coverageFormat; /* Format identifier--format = 2 */
- ArrayOf<CoverageRangeRecord>
- rangeRecord; /* Array of glyph ranges--ordered by
- * Start GlyphID. rangeCount entries
- * long */
-};
-ASSERT_SIZE (CoverageFormat2, 4);
-
-struct Coverage
-{
- inline unsigned int operator () (hb_codepoint_t glyph_id) const { return get_coverage (glyph_id); }
-
- inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
- {
- switch (u.format) {
- case 1: return u.format1->get_coverage(glyph_id);
- case 2: return u.format2->get_coverage(glyph_id);
- default:return NOT_COVERED;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- CoverageFormat1 format1[VAR];
- CoverageFormat2 format2[VAR];
- } u;
-};
-
-
-/*
- * Class Definition Table
- */
-
-struct ClassDefFormat1
-{
- friend struct ClassDef;
-
- private:
- inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
- {
- if ((unsigned int) (glyph_id - startGlyph) < classValue.len)
- return classValue[glyph_id - startGlyph];
- return 0;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE (classValue);
- }
-
- USHORT classFormat; /* Format identifier--format = 1 */
- GlyphID startGlyph; /* First GlyphID of the classValueArray */
- ArrayOf<USHORT>
- classValue; /* Array of Class Values--one per GlyphID */
-};
-ASSERT_SIZE (ClassDefFormat1, 6);
-
-struct ClassRangeRecord
-{
- friend struct ClassDefFormat2;
-
- static inline unsigned int get_size () { return sizeof (ClassRangeRecord); }
-
- private:
- inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
- {
- if (glyph_id >= start && glyph_id <= end)
- return classValue;
- return 0;
- }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- GlyphID start; /* First GlyphID in the range */
- GlyphID end; /* Last GlyphID in the range */
- USHORT classValue; /* Applied to all glyphs in the range */
-};
-ASSERT_SIZE (ClassRangeRecord, 6);
-DEFINE_NULL_DATA (ClassRangeRecord, 6, "\000\001");
-
-struct ClassDefFormat2
-{
- friend struct ClassDef;
-
- private:
- inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
- {
- // TODO: bsearch
- unsigned int count = rangeRecord.len;
- for (unsigned int i = 0; i < count; i++)
- {
- int classValue = rangeRecord[i].get_class (glyph_id);
- if (classValue > 0)
- return classValue;
- }
- return 0;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE (rangeRecord);
- }
-
- USHORT classFormat; /* Format identifier--format = 2 */
- ArrayOf<ClassRangeRecord>
- rangeRecord; /* Array of glyph ranges--ordered by
- * Start GlyphID */
-};
-ASSERT_SIZE (ClassDefFormat2, 4);
-
-struct ClassDef
-{
- inline hb_ot_layout_class_t operator () (hb_codepoint_t glyph_id) const { return get_class (glyph_id); }
-
- inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
- {
- switch (u.format) {
- case 1: return u.format1->get_class(glyph_id);
- case 2: return u.format2->get_class(glyph_id);
- default:return 0;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- ClassDefFormat1 format1[VAR];
- ClassDefFormat2 format2[VAR];
- } u;
-};
-
-
-/*
- * Device Tables
- */
-
-struct Device
-{
- inline int operator () (unsigned int ppem_size) const { return get_delta (ppem_size); }
-
- inline int get_delta (unsigned int ppem_size) const
- {
- unsigned int f = deltaFormat;
- if (HB_UNLIKELY (f < 1 || f > 3))
- return 0;
-
- if (ppem_size < startSize || ppem_size > endSize)
- return 0;
-
- unsigned int s = ppem_size - startSize;
-
- unsigned int byte = deltaValue[s >> (4 - f)];
- unsigned int bits = (byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f)));
- unsigned int mask = (0xFFFF >> (16 - (1 << f)));
-
- int delta = bits & mask;
-
- if ((unsigned int) delta >= ((mask + 1) >> 1))
- delta -= mask + 1;
-
- return delta;
- }
-
- inline unsigned int get_size () const
- {
- unsigned int f = deltaFormat;
- if (HB_UNLIKELY (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::get_size ();
- return 3 * USHORT::get_size () + ((endSize - startSize + (1 << (4 - f)) - 1) >> (4 - f));
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_GET_SIZE ();
- }
-
- private:
- USHORT startSize; /* Smallest size to correct--in ppem */
- USHORT endSize; /* Largest size to correct--in ppem */
- USHORT deltaFormat; /* Format of DeltaValue array data: 1, 2, or 3 */
- USHORT deltaValue[VAR]; /* Array of compressed data */
-};
-ASSERT_SIZE_VAR (Device, 6, USHORT);
-
-
-#endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */
diff --git a/pango/opentype/hb-ot-layout-gdef-private.hh b/pango/opentype/hb-ot-layout-gdef-private.hh
deleted file mode 100644
index f6480542..00000000
--- a/pango/opentype/hb-ot-layout-gdef-private.hh
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_LAYOUT_GDEF_PRIVATE_HH
-#define HB_OT_LAYOUT_GDEF_PRIVATE_HH
-
-#include "hb-ot-layout-common-private.hh"
-
-#include "hb-font-private.h"
-
-
-/*
- * Attachment List Table
- */
-
-typedef ArrayOf<USHORT> AttachPoint; /* Array of contour point indices--in
- * increasing numerical order */
-ASSERT_SIZE (AttachPoint, 2);
-
-struct AttachList
-{
- inline bool get_attach_points (hb_codepoint_t glyph_id,
- unsigned int *point_count /* IN/OUT */,
- unsigned int *point_array /* OUT */) const
- {
- unsigned int index = (this+coverage) (glyph_id);
- if (index == NOT_COVERED)
- {
- *point_count = 0;
- return false;
- }
- const AttachPoint &points = this+attachPoint[index];
-
- unsigned int count = MIN (points.len, *point_count);
- for (unsigned int i = 0; i < count; i++)
- point_array[i] = points[i];
-
- *point_count = points.len;
-
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, attachPoint);
- }
-
- private:
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table -- from
- * beginning of AttachList table */
- OffsetArrayOf<AttachPoint>
- attachPoint; /* Array of AttachPoint tables
- * in Coverage Index order */
-};
-ASSERT_SIZE (AttachList, 4);
-
-/*
- * Ligature Caret Table
- */
-
-struct CaretValueFormat1
-{
- friend struct CaretValue;
-
- private:
- inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED) const
- {
- /* TODO vertical */
- return context->font->x_scale * coordinate / 0x10000;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- USHORT caretValueFormat; /* Format identifier--format = 1 */
- SHORT coordinate; /* X or Y value, in design units */
-};
-ASSERT_SIZE (CaretValueFormat1, 4);
-
-struct CaretValueFormat2
-{
- friend struct CaretValue;
-
- private:
- inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
- {
- return /* TODO contour point */ 0;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- USHORT caretValueFormat; /* Format identifier--format = 2 */
- USHORT caretValuePoint; /* Contour point index on glyph */
-};
-ASSERT_SIZE (CaretValueFormat2, 4);
-
-struct CaretValueFormat3
-{
- friend struct CaretValue;
-
- inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED) const
- {
- /* TODO vertical */
- return context->font->x_scale * coordinate / 0x10000 +
- ((this+deviceTable).get_delta (context->font->x_ppem) << 6);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_THIS (deviceTable);
- }
-
- private:
- USHORT caretValueFormat; /* Format identifier--format = 3 */
- SHORT coordinate; /* X or Y value, in design units */
- OffsetTo<Device>
- deviceTable; /* Offset to Device table for X or Y
- * value--from beginning of CaretValue
- * table */
-};
-ASSERT_SIZE (CaretValueFormat3, 6);
-
-struct CaretValue
-{
- inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
- {
- switch (u.format) {
- case 1: return u.format1->get_caret_value (context, glyph_id);
- case 2: return u.format2->get_caret_value (context, glyph_id);
- case 3: return u.format3->get_caret_value (context, glyph_id);
- default:return 0;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- case 3: return u.format3->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- CaretValueFormat1 format1[VAR];
- CaretValueFormat2 format2[VAR];
- CaretValueFormat3 format3[VAR];
- } u;
-};
-
-struct LigGlyph
-{
- inline void get_lig_carets (hb_ot_layout_context_t *context,
- hb_codepoint_t glyph_id,
- unsigned int *caret_count /* IN/OUT */,
- int *caret_array /* OUT */) const
- {
-
- unsigned int count = MIN (carets.len, *caret_count);
- for (unsigned int i = 0; i < count; i++)
- caret_array[i] = (this+carets[i]).get_caret_value (context, glyph_id);
-
- *caret_count = carets.len;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (carets);
- }
-
- private:
- OffsetArrayOf<CaretValue>
- carets; /* Offset array of CaretValue tables
- * --from beginning of LigGlyph table
- * --in increasing coordinate order */
-};
-ASSERT_SIZE (LigGlyph, 2);
-
-struct LigCaretList
-{
- inline bool get_lig_carets (hb_ot_layout_context_t *context,
- hb_codepoint_t glyph_id,
- unsigned int *caret_count /* IN/OUT */,
- int *caret_array /* OUT */) const
- {
- unsigned int index = (this+coverage) (glyph_id);
- if (index == NOT_COVERED)
- {
- *caret_count = 0;
- return false;
- }
- const LigGlyph &lig_glyph = this+ligGlyph[index];
- lig_glyph.get_lig_carets (context, glyph_id, caret_count, caret_array);
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, ligGlyph);
- }
-
- private:
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of LigCaretList table */
- OffsetArrayOf<LigGlyph>
- ligGlyph; /* Array of LigGlyph tables
- * in Coverage Index order */
-};
-ASSERT_SIZE (LigCaretList, 4);
-
-
-struct MarkGlyphSetsFormat1
-{
- inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
- { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (coverage);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- LongOffsetArrayOf<Coverage>
- coverage; /* Array of long offsets to mark set
- * coverage tables */
-};
-ASSERT_SIZE (MarkGlyphSetsFormat1, 4);
-
-struct MarkGlyphSets
-{
- inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
- {
- switch (u.format) {
- case 1: return u.format1->covers (set_index, glyph_id);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- MarkGlyphSetsFormat1 format1[VAR];
- } u;
-};
-
-
-/*
- * GDEF
- */
-
-struct GDEF
-{
- static const hb_tag_t Tag = HB_OT_TAG_GDEF;
-
- enum {
- UnclassifiedGlyph = 0,
- BaseGlyph = 1,
- LigatureGlyph = 2,
- MarkGlyph = 3,
- ComponentGlyph = 4
- };
-
- STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1, 1);
-
- inline bool has_glyph_classes () const { return glyphClassDef != 0; }
- inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const
- { return (this+glyphClassDef).get_class (glyph); }
-
- inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; }
- inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const
- { return (this+markAttachClassDef).get_class (glyph); }
-
- inline bool has_attach_points () const { return attachList != 0; }
- inline bool get_attach_points (hb_codepoint_t glyph_id,
- unsigned int *point_count /* IN/OUT */,
- unsigned int *point_array /* OUT */) const
- { return (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
-
- inline bool has_lig_carets () const { return ligCaretList != 0; }
- inline bool get_lig_carets (hb_ot_layout_context_t *context,
- hb_codepoint_t glyph_id,
- unsigned int *caret_count /* IN/OUT */,
- int *caret_array /* OUT */) const
- { return (this+ligCaretList).get_lig_carets (context, glyph_id, caret_count, caret_array); }
-
- inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
- inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
- { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (version)) return false;
- if (version.major != 1) return true;
- return SANITIZE_THIS2 (glyphClassDef, attachList) &&
- SANITIZE_THIS2 (ligCaretList, markAttachClassDef) &&
- (version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0]));
- }
-
- private:
- FixedVersion version; /* Version of the GDEF table--currently
- * 0x00010002 */
- OffsetTo<ClassDef>
- glyphClassDef; /* Offset to class definition table
- * for glyph type--from beginning of
- * GDEF header (may be Null) */
- OffsetTo<AttachList>
- attachList; /* Offset to list of glyphs with
- * attachment points--from beginning
- * of GDEF header (may be Null) */
- OffsetTo<LigCaretList>
- ligCaretList; /* Offset to list of positioning points
- * for ligature carets--from beginning
- * of GDEF header (may be Null) */
- OffsetTo<ClassDef>
- markAttachClassDef; /* Offset to class definition table for
- * mark attachment type--from beginning
- * of GDEF header (may be Null) */
- OffsetTo<MarkGlyphSets>
- markGlyphSetsDef[VAR]; /* Offset to the table of mark set
- * definitions--from beginning of GDEF
- * header (may be NULL). Introduced
- * in version 00010002. */
-};
-ASSERT_SIZE_VAR (GDEF, 12, OffsetTo<MarkGlyphSets>);
-
-
-#endif /* HB_OT_LAYOUT_GDEF_PRIVATE_HH */
diff --git a/pango/opentype/hb-ot-layout-gpos-private.hh b/pango/opentype/hb-ot-layout-gpos-private.hh
deleted file mode 100644
index cdd28d2c..00000000
--- a/pango/opentype/hb-ot-layout-gpos-private.hh
+++ /dev/null
@@ -1,1614 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_LAYOUT_GPOS_PRIVATE_HH
-#define HB_OT_LAYOUT_GPOS_PRIVATE_HH
-
-#include "hb-ot-layout-gsubgpos-private.hh"
-
-#define HB_OT_LAYOUT_GPOS_NO_LAST ((unsigned int) -1)
-
-/* Shared Tables: ValueRecord, Anchor Table, and MarkArray */
-
-typedef SHORT Value;
-
-typedef Value ValueRecord[VAR];
-ASSERT_SIZE_VAR (ValueRecord, 0, Value);
-
-struct ValueFormat : USHORT
-{
- enum
- {
- xPlacement = 0x0001, /* Includes horizontal adjustment for placement */
- yPlacement = 0x0002, /* Includes vertical adjustment for placement */
- xAdvance = 0x0004, /* Includes horizontal adjustment for advance */
- yAdvance = 0x0008, /* Includes vertical adjustment for advance */
- xPlaDevice = 0x0010, /* Includes horizontal Device table for placement */
- yPlaDevice = 0x0020, /* Includes vertical Device table for placement */
- xAdvDevice = 0x0040, /* Includes horizontal Device table for advance */
- yAdvDevice = 0x0080, /* Includes vertical Device table for advance */
- ignored = 0x0F00, /* Was used in TrueType Open for MM fonts */
- reserved = 0xF000, /* For future use */
-
- devices = 0x00F0 /* Mask for having any Device table */
- };
-
-/* All fields are options. Only those available advance the value pointer. */
-#if 0
- SHORT xPlacement; /* Horizontal adjustment for
- * placement--in design units */
- SHORT yPlacement; /* Vertical adjustment for
- * placement--in design units */
- SHORT xAdvance; /* Horizontal adjustment for
- * advance--in design units (only used
- * for horizontal writing) */
- SHORT yAdvance; /* Vertical adjustment for advance--in
- * design units (only used for vertical
- * writing) */
- Offset xPlaDevice; /* Offset to Device table for
- * horizontal placement--measured from
- * beginning of PosTable (may be NULL) */
- Offset yPlaDevice; /* Offset to Device table for vertical
- * placement--measured from beginning
- * of PosTable (may be NULL) */
- Offset xAdvDevice; /* Offset to Device table for
- * horizontal advance--measured from
- * beginning of PosTable (may be NULL) */
- Offset yAdvDevice; /* Offset to Device table for vertical
- * advance--measured from beginning of
- * PosTable (may be NULL) */
-#endif
-
- inline unsigned int get_len () const
- { return _hb_popcount32 ((unsigned int) *this); }
- inline unsigned int get_size () const
- { return get_len () * Value::get_size (); }
-
- void apply_value (hb_ot_layout_context_t *context,
- const char *base,
- const Value *values,
- hb_internal_glyph_position_t *glyph_pos) const
- {
- unsigned int x_ppem, y_ppem;
- hb_16dot16_t x_scale, y_scale;
- unsigned int format = *this;
-
- if (!format) return;
-
- x_scale = context->font->x_scale;
- y_scale = context->font->y_scale;
- /* design units -> fractional pixel */
- if (format & xPlacement)
- glyph_pos->x_pos += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
- if (format & yPlacement)
- glyph_pos->y_pos += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
- if (format & xAdvance)
- glyph_pos->x_advance += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
- if (format & yAdvance)
- glyph_pos->y_advance += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
-
- x_ppem = context->font->x_ppem;
- y_ppem = context->font->y_ppem;
- /* pixel -> fractional pixel */
- if (format & xPlaDevice) {
- if (x_ppem)
- glyph_pos->x_pos += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 16;
- else
- values++;
- }
- if (format & yPlaDevice) {
- if (y_ppem)
- glyph_pos->y_pos += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 16;
- else
- values++;
- }
- if (format & xAdvDevice) {
- if (x_ppem)
- glyph_pos->x_advance += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 16;
- else
- values++;
- }
- if (format & yAdvDevice) {
- if (y_ppem)
- glyph_pos->y_advance += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 16;
- else
- values++;
- }
- }
-
- private:
- inline bool sanitize_value_devices (SANITIZE_ARG_DEF, void *base, const Value *values) {
- unsigned int format = *this;
-
- if (format & xPlacement) values++;
- if (format & yPlacement) values++;
- if (format & xAdvance) values++;
- if (format & yAdvance) values++;
-
- if ((format & xPlaDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
- if ((format & yPlaDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
- if ((format & xAdvDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
- if ((format & yAdvDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
-
- return true;
- }
-
- public:
-
- inline bool has_device () {
- unsigned int format = *this;
- return (format & devices) != 0;
- }
-
- inline bool sanitize_value (SANITIZE_ARG_DEF, void *base, const Value *values) {
- TRACE_SANITIZE ();
-
- return SANITIZE_MEM (values, get_size ()) &&
- (!has_device () || sanitize_value_devices (SANITIZE_ARG, base, values));
- }
-
- inline bool sanitize_values (SANITIZE_ARG_DEF, void *base, const Value *values, unsigned int count) {
- TRACE_SANITIZE ();
- unsigned int len = get_len ();
-
- if (!SANITIZE_ARRAY (values, get_size (), count)) return false;
-
- if (!has_device ()) return true;
-
- for (unsigned int i = 0; i < count; i++) {
- if (!sanitize_value_devices (SANITIZE_ARG, base, values))
- return false;
- values += len;
- }
-
- return true;
- }
-
- inline bool sanitize_values_stride_unsafe (SANITIZE_ARG_DEF, void *base, const Value *values, unsigned int count, unsigned int stride) {
- TRACE_SANITIZE ();
-
- if (!has_device ()) return true;
-
- for (unsigned int i = 0; i < count; i++) {
- if (!sanitize_value_devices (SANITIZE_ARG, base, values))
- return false;
- values += stride;
- }
-
- return true;
- }
-};
-ASSERT_SIZE (ValueFormat, 2);
-
-
-struct AnchorFormat1
-{
- friend struct Anchor;
-
- private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
- hb_position_t *x, hb_position_t *y) const
- {
- *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- SHORT xCoordinate; /* Horizontal value--in design units */
- SHORT yCoordinate; /* Vertical value--in design units */
-};
-ASSERT_SIZE (AnchorFormat1, 6);
-
-struct AnchorFormat2
-{
- friend struct Anchor;
-
- private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
- hb_position_t *x, hb_position_t *y) const
- {
- /* TODO Contour */
- *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- USHORT format; /* Format identifier--format = 2 */
- SHORT xCoordinate; /* Horizontal value--in design units */
- SHORT yCoordinate; /* Vertical value--in design units */
- USHORT anchorPoint; /* Index to glyph contour point */
-};
-ASSERT_SIZE (AnchorFormat2, 8);
-
-struct AnchorFormat3
-{
- friend struct Anchor;
-
- private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
- hb_position_t *x, hb_position_t *y) const
- {
- *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
-
- /* pixel -> fractional pixel */
- if (context->font->x_ppem)
- *x += (this+xDeviceTable).get_delta (context->font->x_ppem) << 16;
- if (context->font->y_ppem)
- *y += (this+yDeviceTable).get_delta (context->font->y_ppem) << 16;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_THIS2 (xDeviceTable, yDeviceTable);
- }
-
- private:
- USHORT format; /* Format identifier--format = 3 */
- SHORT xCoordinate; /* Horizontal value--in design units */
- SHORT yCoordinate; /* Vertical value--in design units */
- OffsetTo<Device>
- xDeviceTable; /* Offset to Device table for X
- * coordinate-- from beginning of
- * Anchor table (may be NULL) */
- OffsetTo<Device>
- yDeviceTable; /* Offset to Device table for Y
- * coordinate-- from beginning of
- * Anchor table (may be NULL) */
-};
-ASSERT_SIZE (AnchorFormat3, 10);
-
-struct Anchor
-{
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
- hb_position_t *x, hb_position_t *y) const
- {
- *x = *y = 0;
- switch (u.format) {
- case 1: u.format1->get_anchor (context, glyph_id, x, y); return;
- case 2: u.format2->get_anchor (context, glyph_id, x, y); return;
- case 3: u.format3->get_anchor (context, glyph_id, x, y); return;
- default: return;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- case 3: return u.format3->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- AnchorFormat1 format1[VAR];
- AnchorFormat2 format2[VAR];
- AnchorFormat3 format3[VAR];
- } u;
-};
-
-
-struct AnchorMatrix
-{
- inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols) const {
- if (HB_UNLIKELY (row >= rows || col >= cols)) return Null(Anchor);
- return this+matrix[row * cols + col];
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF, unsigned int cols) {
- TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
- if (rows > 0 && cols >= ((unsigned int) -1) / rows) return false;
- unsigned int count = rows * cols;
- if (!SANITIZE_ARRAY (matrix, matrix[0].get_size (), count)) return false;
- for (unsigned int i = 0; i < count; i++)
- if (!SANITIZE_THIS (matrix[i])) return false;
- return true;
- }
-
- USHORT rows; /* Number of rows */
- private:
- OffsetTo<Anchor>
- matrix[VAR]; /* Matrix of offsets to Anchor tables--
- * from beginning of AnchorMatrix table */
-};
-ASSERT_SIZE_VAR (AnchorMatrix, 2, OffsetTo<Anchor>);
-
-
-struct MarkRecord
-{
- friend struct MarkArray;
-
- static inline unsigned int get_size () { return sizeof (MarkRecord); }
-
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_BASE (markAnchor, base);
- }
-
- private:
- USHORT klass; /* Class defined for this mark */
- OffsetTo<Anchor>
- markAnchor; /* Offset to Anchor table--from
- * beginning of MarkArray table */
-};
-ASSERT_SIZE (MarkRecord, 4);
-
-struct MarkArray
-{
- inline bool apply (APPLY_ARG_DEF,
- unsigned int mark_index, unsigned int glyph_index,
- const AnchorMatrix &anchors, unsigned int class_count,
- unsigned int glyph_pos) const
- {
- TRACE_APPLY ();
- const MarkRecord &record = markRecord[mark_index];
- unsigned int mark_class = record.klass;
-
- const Anchor& mark_anchor = this + record.markAnchor;
- const Anchor& glyph_anchor = anchors.get_anchor (glyph_index, mark_class, class_count);
-
- hb_position_t mark_x, mark_y, base_x, base_y;
-
- mark_anchor.get_anchor (context, IN_CURGLYPH (), &mark_x, &mark_y);
- glyph_anchor.get_anchor (context, IN_GLYPH (glyph_pos), &base_x, &base_y);
-
- hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
- o->x_pos = base_x - mark_x;
- o->y_pos = base_y - mark_y;
- o->x_advance = 0;
- o->y_advance = 0;
- o->back = buffer->in_pos - glyph_pos;
-
- buffer->in_pos++;
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (markRecord);
- }
-
- private:
- ArrayOf<MarkRecord>
- markRecord; /* Array of MarkRecords--in Coverage order */
-};
-ASSERT_SIZE (MarkArray, 2);
-
-
-/* Lookups */
-
-struct SinglePosFormat1
-{
- friend struct SinglePos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- valueFormat.apply_value (context, CONST_CHARP(this), values, CURPOSITION ());
-
- buffer->in_pos++;
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
- valueFormat.sanitize_value (SANITIZE_ARG, CHARP(this), values);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of subtable */
- ValueFormat valueFormat; /* Defines the types of data in the
- * ValueRecord */
- ValueRecord values; /* Defines positioning
- * value(s)--applied to all glyphs in
- * the Coverage table */
-};
-ASSERT_SIZE_VAR (SinglePosFormat1, 6, ValueRecord);
-
-struct SinglePosFormat2
-{
- friend struct SinglePos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- if (HB_LIKELY (index >= valueCount))
- return false;
-
- valueFormat.apply_value (context, CONST_CHARP(this),
- &values[index * valueFormat.get_len ()],
- CURPOSITION ());
-
- buffer->in_pos++;
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
- valueFormat.sanitize_values (SANITIZE_ARG, CHARP(this), values, valueCount);
- }
-
- private:
- USHORT format; /* Format identifier--format = 2 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of subtable */
- ValueFormat valueFormat; /* Defines the types of data in the
- * ValueRecord */
- USHORT valueCount; /* Number of ValueRecords */
- ValueRecord values; /* Array of ValueRecords--positioning
- * values applied to glyphs */
-};
-ASSERT_SIZE_VAR (SinglePosFormat2, 8, ValueRecord);
-
-struct SinglePos
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- case 2: return u.format2->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- SinglePosFormat1 format1[VAR];
- SinglePosFormat2 format2[VAR];
- } u;
-};
-
-
-struct PairValueRecord
-{
- friend struct PairPosFormat1;
-
- private:
- GlyphID secondGlyph; /* GlyphID of second glyph in the
- * pair--first glyph is listed in the
- * Coverage table */
- ValueRecord values; /* Positioning data for the first glyph
- * followed by for second glyph */
-};
-ASSERT_SIZE_VAR (PairValueRecord, 2, ValueRecord);
-
-struct PairSet
-{
- friend struct PairPosFormat1;
-
- /* Note: Doesn't sanitize the Device entries in the ValueRecord */
- inline bool sanitize (SANITIZE_ARG_DEF, unsigned int format_len) {
- TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
- unsigned int count = (1 + format_len) * len;
- return SANITIZE_MEM (array, USHORT::get_size () * count);
- }
-
- private:
- USHORT len; /* Number of PairValueRecords */
- PairValueRecord
- array[VAR]; /* Array of PairValueRecords--ordered
- * by GlyphID of the second glyph */
-};
-ASSERT_SIZE_VAR (PairSet, 2, PairValueRecord);
-
-struct PairPosFormat1
-{
- friend struct PairPos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
- if (HB_UNLIKELY (buffer->in_pos + 2 > end))
- return false;
-
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
- {
- if (HB_UNLIKELY (j == end))
- return false;
- j++;
- }
-
- unsigned int len1 = valueFormat1.get_len ();
- unsigned int len2 = valueFormat2.get_len ();
- unsigned int record_size = USHORT::get_size () * (1 + len1 + len2);
-
- const PairSet &pair_set = this+pairSet[index];
- unsigned int count = pair_set.len;
- const PairValueRecord *record = pair_set.array;
- for (unsigned int i = 0; i < count; i++)
- {
- if (IN_GLYPH (j) == record->secondGlyph)
- {
- valueFormat1.apply_value (context, CONST_CHARP(this), &record->values[0], CURPOSITION ());
- valueFormat2.apply_value (context, CONST_CHARP(this), &record->values[len1], POSITION (j));
- if (len2)
- j++;
- buffer->in_pos = j;
- return true;
- }
- record = &CONST_CAST (PairValueRecord, *record, record_size);
- }
-
- return false;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
-
- unsigned int len1 = valueFormat1.get_len ();
- unsigned int len2 = valueFormat2.get_len ();
-
- if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
- pairSet.sanitize (SANITIZE_ARG, CONST_CHARP(this), len1 + len2))) return false;
-
- if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
-
- unsigned int stride = 1 + len1 + len2;
- unsigned int count1 = pairSet.len;
- for (unsigned int i = 0; i < count1; i++)
- {
- const PairSet &pair_set = this+pairSet[i];
-
- unsigned int count2 = pair_set.len;
- const PairValueRecord *record = pair_set.array;
- if (!(valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &record->values[0], count2, stride) &&
- valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &record->values[len1], count2, stride)))
- return false;
- }
-
- return true;
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of subtable */
- ValueFormat valueFormat1; /* Defines the types of data in
- * ValueRecord1--for the first glyph
- * in the pair--may be zero (0) */
- ValueFormat valueFormat2; /* Defines the types of data in
- * ValueRecord2--for the second glyph
- * in the pair--may be zero (0) */
- OffsetArrayOf<PairSet>
- pairSet; /* Array of PairSet tables
- * ordered by Coverage Index */
-};
-ASSERT_SIZE (PairPosFormat1, 10);
-
-struct PairPosFormat2
-{
- friend struct PairPos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
- if (HB_UNLIKELY (buffer->in_pos + 2 > end))
- return false;
-
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
- {
- if (HB_UNLIKELY (j == end))
- return false;
- j++;
- }
-
- unsigned int len1 = valueFormat1.get_len ();
- unsigned int len2 = valueFormat2.get_len ();
- unsigned int record_len = len1 + len2;
-
- unsigned int klass1 = (this+classDef1) (IN_CURGLYPH ());
- unsigned int klass2 = (this+classDef2) (IN_GLYPH (j));
- if (HB_UNLIKELY (klass1 >= class1Count || klass2 >= class2Count))
- return false;
-
- const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
- valueFormat1.apply_value (context, CONST_CHARP(this), v, CURPOSITION ());
- valueFormat2.apply_value (context, CONST_CHARP(this), v + len1, POSITION (j));
-
- if (len2)
- j++;
- buffer->in_pos = j;
-
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
- SANITIZE_THIS2 (classDef1, classDef2))) return false;
-
- unsigned int len1 = valueFormat1.get_len ();
- unsigned int len2 = valueFormat2.get_len ();
- unsigned int stride = len1 + len2;
- unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
- unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
- return SANITIZE_ARRAY (values, record_size, count) &&
- valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &values[0], count, stride) &&
- valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &values[len1], count, stride);
- }
-
- private:
- USHORT format; /* Format identifier--format = 2 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of subtable */
- ValueFormat valueFormat1; /* ValueRecord definition--for the
- * first glyph of the pair--may be zero
- * (0) */
- ValueFormat valueFormat2; /* ValueRecord definition--for the
- * second glyph of the pair--may be
- * zero (0) */
- OffsetTo<ClassDef>
- classDef1; /* Offset to ClassDef table--from
- * beginning of PairPos subtable--for
- * the first glyph of the pair */
- OffsetTo<ClassDef>
- classDef2; /* Offset to ClassDef table--from
- * beginning of PairPos subtable--for
- * the second glyph of the pair */
- USHORT class1Count; /* Number of classes in ClassDef1
- * table--includes Class0 */
- USHORT class2Count; /* Number of classes in ClassDef2
- * table--includes Class0 */
- ValueRecord values; /* Matrix of value pairs:
- * class1-major, class2-minor,
- * Each entry has value1 and value2 */
-};
-ASSERT_SIZE_VAR (PairPosFormat2, 16, ValueRecord);
-
-struct PairPos
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- case 2: return u.format2->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- PairPosFormat1 format1[VAR];
- PairPosFormat2 format2[VAR];
- } u;
-};
-
-
-struct EntryExitRecord
-{
- static inline unsigned int get_size () { return sizeof (EntryExitRecord); }
-
- inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
- TRACE_SANITIZE ();
- return SANITIZE_BASE2 (entryAnchor, exitAnchor, base);
- }
-
- OffsetTo<Anchor>
- entryAnchor; /* Offset to EntryAnchor table--from
- * beginning of CursivePos
- * subtable--may be NULL */
- OffsetTo<Anchor>
- exitAnchor; /* Offset to ExitAnchor table--from
- * beginning of CursivePos
- * subtable--may be NULL */
-};
-ASSERT_SIZE (EntryExitRecord, 4);
-
-struct CursivePosFormat1
-{
- friend struct CursivePos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- /* Now comes the messiest part of the whole OpenType
- specification. At first glance, cursive connections seem easy
- to understand, but there are pitfalls! The reason is that
- the specs don't mention how to compute the advance values
- resp. glyph offsets. I was told it would be an omission, to
- be fixed in the next OpenType version... Again many thanks to
- Andrei Burago <andreib@microsoft.com> for clarifications.
-
- Consider the following example:
-
- | xadv1 |
- +---------+
- | |
- +-----+--+ 1 |
- | | .| |
- | 0+--+------+
- | 2 |
- | |
- 0+--------+
- | xadv2 |
-
- glyph1: advance width = 12
- anchor point = (3,1)
-
- glyph2: advance width = 11
- anchor point = (9,4)
-
- LSB is 1 for both glyphs (so the boxes drawn above are glyph
- bboxes). Writing direction is R2L; `0' denotes the glyph's
- coordinate origin.
-
- Now the surprising part: The advance width of the *left* glyph
- (resp. of the *bottom* glyph) will be modified, no matter
- whether the writing direction is L2R or R2L (resp. T2B or
- B2T)! This assymetry is caused by the fact that the glyph's
- coordinate origin is always the lower left corner for all
- writing directions.
-
- Continuing the above example, we can compute the new
- (horizontal) advance width of glyph2 as
-
- 9 - 3 = 6 ,
-
- and the new vertical offset of glyph2 as
-
- 1 - 4 = -3 .
-
-
- Vertical writing direction is far more complicated:
-
- a) Assuming that we recompute the advance height of the lower glyph:
-
- --
- +---------+
- -- | |
- +-----+--+ 1 | yadv1
- | | .| |
- yadv2 | 0+--+------+ -- BSB1 --
- | 2 | -- -- y_offset
- | |
- BSB2 -- 0+--------+ --
- -- --
-
- glyph1: advance height = 6
- anchor point = (3,1)
-
- glyph2: advance height = 7
- anchor point = (9,4)
-
- TSB is 1 for both glyphs; writing direction is T2B.
-
-
- BSB1 = yadv1 - (TSB1 + ymax1)
- BSB2 = yadv2 - (TSB2 + ymax2)
- y_offset = y2 - y1
-
- vertical advance width of glyph2
- = y_offset + BSB2 - BSB1
- = (y2 - y1) + (yadv2 - (TSB2 + ymax2)) - (yadv1 - (TSB1 + ymax1))
- = y2 - y1 + yadv2 - TSB2 - ymax2 - (yadv1 - TSB1 - ymax1)
- = y2 - y1 + yadv2 - TSB2 - ymax2 - yadv1 + TSB1 + ymax1
-
-
- b) Assuming that we recompute the advance height of the upper glyph:
-
- -- --
- +---------+ -- TSB1
- -- -- | |
- TSB2 -- +-----+--+ 1 | yadv1 ymax1
- | | .| |
- yadv2 | 0+--+------+ -- --
- ymax2 | 2 | -- y_offset
- | |
- -- 0+--------+ --
- --
-
- glyph1: advance height = 6
- anchor point = (3,1)
-
- glyph2: advance height = 7
- anchor point = (9,4)
-
- TSB is 1 for both glyphs; writing direction is T2B.
-
- y_offset = y2 - y1
-
- vertical advance width of glyph2
- = TSB1 + ymax1 + y_offset - (TSB2 + ymax2)
- = TSB1 + ymax1 + y2 - y1 - TSB2 - ymax2
-
-
- Comparing a) with b) shows that b) is easier to compute. I'll wait
- for a reply from Andrei to see what should really be implemented...
-
- Since horizontal advance widths or vertical advance heights
- can be used alone but not together, no ambiguity occurs. */
-
- struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &context->info.gpos;
- hb_codepoint_t last_pos = gpi->last;
- gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
-
- /* We don't handle mark glyphs here. */
- if (property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
- return false;
-
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const EntryExitRecord &record = entryExitRecord[index];
-
- if (last_pos == HB_OT_LAYOUT_GPOS_NO_LAST || !record.entryAnchor)
- goto end;
-
- hb_position_t entry_x, entry_y;
- (this+record.entryAnchor).get_anchor (context, IN_CURGLYPH (), &entry_x, &entry_y);
-
- /* TODO vertical */
-
- if (buffer->direction == HB_DIRECTION_RTL)
- {
- POSITION (buffer->in_pos)->x_advance = entry_x - gpi->anchor_x;
- POSITION (buffer->in_pos)->new_advance = TRUE;
- }
- else
- {
- POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x;
- POSITION (last_pos)->new_advance = TRUE;
- }
-
- if (lookup_flag & LookupFlag::RightToLeft)
- {
- POSITION (last_pos)->cursive_chain = last_pos - buffer->in_pos;
- POSITION (last_pos)->y_pos = entry_y - gpi->anchor_y;
- }
- else
- {
- POSITION (buffer->in_pos)->cursive_chain = buffer->in_pos - last_pos;
- POSITION (buffer->in_pos)->y_pos = gpi->anchor_y - entry_y;
- }
-
- end:
- if (record.exitAnchor)
- {
- gpi->last = buffer->in_pos;
- (this+record.exitAnchor).get_anchor (context, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
- }
-
- buffer->in_pos++;
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, entryExitRecord);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of subtable */
- ArrayOf<EntryExitRecord>
- entryExitRecord; /* Array of EntryExit records--in
- * Coverage Index order */
-};
-ASSERT_SIZE (CursivePosFormat1, 6);
-
-struct CursivePos
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- CursivePosFormat1 format1[VAR];
- } u;
-};
-
-
-typedef AnchorMatrix BaseArray; /* base-major--
- * in order of BaseCoverage Index--,
- * mark-minor--
- * ordered by class--zero-based. */
-
-struct MarkBasePosFormat1
-{
- friend struct MarkBasePos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ());
- if (HB_LIKELY (mark_index == NOT_COVERED))
- return false;
-
- /* now we search backwards for a non-mark glyph */
- unsigned int j = buffer->in_pos;
- do
- {
- if (HB_UNLIKELY (!j))
- return false;
- j--;
- } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
-
-#if 0
- /* The following assertion is too strong. */
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH))
- return false;
-#endif
-
- unsigned int base_index = (this+baseCoverage) (IN_GLYPH (j));
- if (base_index == NOT_COVERED)
- return false;
-
- return (this+markArray).apply (APPLY_ARG, mark_index, base_index, this+baseArray, classCount, j);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_THIS2 (markCoverage, baseCoverage) &&
- SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- markCoverage; /* Offset to MarkCoverage table--from
- * beginning of MarkBasePos subtable */
- OffsetTo<Coverage>
- baseCoverage; /* Offset to BaseCoverage table--from
- * beginning of MarkBasePos subtable */
- USHORT classCount; /* Number of classes defined for marks */
- OffsetTo<MarkArray>
- markArray; /* Offset to MarkArray table--from
- * beginning of MarkBasePos subtable */
- OffsetTo<BaseArray>
- baseArray; /* Offset to BaseArray table--from
- * beginning of MarkBasePos subtable */
-};
-ASSERT_SIZE (MarkBasePosFormat1, 12);
-
-struct MarkBasePos
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- MarkBasePosFormat1 format1[VAR];
- } u;
-};
-
-
-typedef AnchorMatrix LigatureAttach; /* component-major--
- * in order of writing direction--,
- * mark-minor--
- * ordered by class--zero-based. */
-
-typedef OffsetListOf<LigatureAttach> LigatureArray;
- /* Array of LigatureAttach
- * tables ordered by
- * LigatureCoverage Index */
-
-struct MarkLigPosFormat1
-{
- friend struct MarkLigPos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ());
- if (HB_LIKELY (mark_index == NOT_COVERED))
- return false;
-
- /* now we search backwards for a non-mark glyph */
- unsigned int j = buffer->in_pos;
- do
- {
- if (HB_UNLIKELY (!j))
- return false;
- j--;
- } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property));
-
-#if 0
- /* The following assertion is too strong. */
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE))
- return false;
-#endif
-
- unsigned int lig_index = (this+ligatureCoverage) (IN_GLYPH (j));
- if (lig_index == NOT_COVERED)
- return false;
-
- const LigatureArray& lig_array = this+ligatureArray;
- const LigatureAttach& lig_attach = lig_array[lig_index];
-
- /* Find component to attach to */
- unsigned int comp_count = lig_attach.rows;
- if (HB_UNLIKELY (!comp_count))
- return false;
- unsigned int comp_index;
- /* We must now check whether the ligature ID of the current mark glyph
- * is identical to the ligature ID of the found ligature. If yes, we
- * can directly use the component index. If not, we attach the mark
- * glyph to the last component of the ligature. */
- if (IN_LIGID (j) && IN_LIGID (j) == IN_LIGID (buffer->in_pos) && IN_COMPONENT (buffer->in_pos))
- {
- comp_index = IN_COMPONENT (buffer->in_pos) - 1;
- if (comp_index >= comp_count)
- comp_index = comp_count - 1;
- }
- else
- comp_index = comp_count - 1;
-
- return (this+markArray).apply (APPLY_ARG, mark_index, comp_index, lig_attach, classCount, j);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () &&
- SANITIZE_THIS2 (markCoverage, ligatureCoverage) &&
- SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- markCoverage; /* Offset to Mark Coverage table--from
- * beginning of MarkLigPos subtable */
- OffsetTo<Coverage>
- ligatureCoverage; /* Offset to Ligature Coverage
- * table--from beginning of MarkLigPos
- * subtable */
- USHORT classCount; /* Number of defined mark classes */
- OffsetTo<MarkArray>
- markArray; /* Offset to MarkArray table--from
- * beginning of MarkLigPos subtable */
- OffsetTo<LigatureArray>
- ligatureArray; /* Offset to LigatureArray table--from
- * beginning of MarkLigPos subtable */
-};
-ASSERT_SIZE (MarkLigPosFormat1, 12);
-
-struct MarkLigPos
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- MarkLigPosFormat1 format1[VAR];
- } u;
-};
-
-
-typedef AnchorMatrix Mark2Array; /* mark2-major--
- * in order of Mark2Coverage Index--,
- * mark1-minor--
- * ordered by class--zero-based. */
-
-struct MarkMarkPosFormat1
-{
- friend struct MarkMarkPos;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- unsigned int mark1_index = (this+mark1Coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (mark1_index == NOT_COVERED))
- return false;
-
- /* now we search backwards for a suitable mark glyph until a non-mark glyph */
- unsigned int j = buffer->in_pos;
- do
- {
- if (HB_UNLIKELY (!j))
- return false;
- j--;
- } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, &property));
-
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
- return false;
-
- /* Two marks match only if they belong to the same base, or same component
- * of the same ligature. That is, the component numbers must match, and
- * if those are non-zero, the ligid number should also match. */
- if ((IN_COMPONENT (j) != IN_COMPONENT (buffer->in_pos)) ||
- (IN_COMPONENT (j) && IN_LIGID (j) != IN_LIGID (buffer->in_pos)))
- return false;
-
- unsigned int mark2_index = (this+mark2Coverage) (IN_GLYPH (j));
- if (mark2_index == NOT_COVERED)
- return false;
-
- return (this+mark1Array).apply (APPLY_ARG, mark1_index, mark2_index, this+mark2Array, classCount, j);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_THIS2 (mark1Coverage, mark2Coverage) &&
- SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- mark1Coverage; /* Offset to Combining Mark1 Coverage
- * table--from beginning of MarkMarkPos
- * subtable */
- OffsetTo<Coverage>
- mark2Coverage; /* Offset to Combining Mark2 Coverage
- * table--from beginning of MarkMarkPos
- * subtable */
- USHORT classCount; /* Number of defined mark classes */
- OffsetTo<MarkArray>
- mark1Array; /* Offset to Mark1Array table--from
- * beginning of MarkMarkPos subtable */
- OffsetTo<Mark2Array>
- mark2Array; /* Offset to Mark2Array table--from
- * beginning of MarkMarkPos subtable */
-};
-ASSERT_SIZE (MarkMarkPosFormat1, 12);
-
-struct MarkMarkPos
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- MarkMarkPosFormat1 format1[VAR];
- } u;
-};
-
-
-static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index);
-
-struct ContextPos : Context
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- return Context::apply (APPLY_ARG, position_lookup);
- }
-};
-
-struct ChainContextPos : ChainContext
-{
- friend struct PosLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- return ChainContext::apply (APPLY_ARG, position_lookup);
- }
-};
-
-
-struct ExtensionPos : Extension
-{
- friend struct PosLookupSubTable;
-
- private:
- inline const struct PosLookupSubTable& get_subtable (void) const
- { return CONST_CAST (PosLookupSubTable, Extension::get_subtable (), 0); }
-
- inline bool apply (APPLY_ARG_DEF) const;
-
- inline bool sanitize (SANITIZE_ARG_DEF);
-};
-
-
-
-/*
- * PosLookup
- */
-
-
-struct PosLookupSubTable
-{
- friend struct PosLookup;
-
- enum {
- Single = 1,
- Pair = 2,
- Cursive = 3,
- MarkBase = 4,
- MarkLig = 5,
- MarkMark = 6,
- Context = 7,
- ChainContext = 8,
- Extension = 9
- };
-
- inline bool apply (APPLY_ARG_DEF, unsigned int lookup_type) const
- {
- TRACE_APPLY ();
- switch (lookup_type) {
- case Single: return u.single->apply (APPLY_ARG);
- case Pair: return u.pair->apply (APPLY_ARG);
- case Cursive: return u.cursive->apply (APPLY_ARG);
- case MarkBase: return u.markBase->apply (APPLY_ARG);
- case MarkLig: return u.markLig->apply (APPLY_ARG);
- case MarkMark: return u.markMark->apply (APPLY_ARG);
- case Context: return u.context->apply (APPLY_ARG);
- case ChainContext: return u.chainContext->apply (APPLY_ARG);
- case Extension: return u.extension->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF, unsigned int lookup_type) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.sub_format)) return false;
- switch (lookup_type) {
- case Single: return u.single->sanitize (SANITIZE_ARG);
- case Pair: return u.pair->sanitize (SANITIZE_ARG);
- case Cursive: return u.cursive->sanitize (SANITIZE_ARG);
- case MarkBase: return u.markBase->sanitize (SANITIZE_ARG);
- case MarkLig: return u.markLig->sanitize (SANITIZE_ARG);
- case MarkMark: return u.markMark->sanitize (SANITIZE_ARG);
- case Context: return u.context->sanitize (SANITIZE_ARG);
- case ChainContext: return u.chainContext->sanitize (SANITIZE_ARG);
- case Extension: return u.extension->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT sub_format;
- SinglePos single[VAR];
- PairPos pair[VAR];
- CursivePos cursive[VAR];
- MarkBasePos markBase[VAR];
- MarkLigPos markLig[VAR];
- MarkMarkPos markMark[VAR];
- ContextPos context[VAR];
- ChainContextPos chainContext[VAR];
- ExtensionPos extension[VAR];
- } u;
-};
-
-
-struct PosLookup : Lookup
-{
- inline const PosLookupSubTable& get_subtable (unsigned int i) const
- { return (const PosLookupSubTable&) Lookup::get_subtable (i); }
-
- /* Like get_type(), but looks through extension lookups.
- * Never returns Extension */
- inline unsigned int get_effective_type (void) const
- {
- unsigned int type = get_type ();
-
- if (HB_UNLIKELY (type == PosLookupSubTable::Extension))
- {
- unsigned int count = get_subtable_count ();
- type = get_subtable(0).u.extension->get_type ();
- /* The spec says all subtables should have the same type.
- * This is specially important if one has a reverse type! */
- for (unsigned int i = 1; i < count; i++)
- if (get_subtable(i).u.extension->get_type () != type)
- return 0;
- }
-
- return type;
- }
-
- inline bool apply_once (hb_ot_layout_context_t *context,
- hb_buffer_t *buffer,
- unsigned int context_length,
- unsigned int nesting_level_left) const
- {
- unsigned int lookup_type = get_type ();
- unsigned int lookup_flag = get_flag ();
- unsigned int property;
-
- if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), lookup_flag, &property))
- return false;
-
- for (unsigned int i = 0; i < get_subtable_count (); i++)
- if (get_subtable (i).apply (APPLY_ARG_INIT, lookup_type))
- return true;
-
- return false;
- }
-
- inline bool apply_string (hb_ot_layout_context_t *context,
- hb_buffer_t *buffer,
- hb_mask_t mask) const
- {
- bool ret = false;
-
- if (HB_UNLIKELY (!buffer->in_length))
- return false;
-
- context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
-
- buffer->in_pos = 0;
- while (buffer->in_pos < buffer->in_length)
- {
- bool done;
- if (~IN_MASK (buffer->in_pos) & mask)
- {
- done = apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL);
- ret |= done;
- }
- else
- {
- done = false;
- /* Contrary to properties defined in GDEF, user-defined properties
- will always stop a possible cursive positioning. */
- context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST;
- }
-
- if (!done)
- buffer->in_pos++;
- }
-
- return ret;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!Lookup::sanitize (SANITIZE_ARG)) return false;
- OffsetArrayOf<PosLookupSubTable> &list = (OffsetArrayOf<PosLookupSubTable> &) subTable;
- return list.sanitize (SANITIZE_ARG, this, get_type ());
- }
-};
-
-typedef OffsetListOf<PosLookup> PosLookupList;
-ASSERT_SIZE (PosLookupList, 2);
-
-/*
- * GPOS
- */
-
-struct GPOS : GSUBGPOS
-{
- static const hb_tag_t Tag = HB_OT_TAG_GPOS;
-
- static inline const GPOS& get_for_data (const char *data)
- { return (const GPOS&) GSUBGPOS::get_for_data (data); }
-
- inline const PosLookup& get_lookup (unsigned int i) const
- { return (const PosLookup&) GSUBGPOS::get_lookup (i); }
-
- inline bool position_lookup (hb_ot_layout_context_t *context,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
- OffsetTo<PosLookupList> &list = CAST(OffsetTo<PosLookupList>, lookupList, 0);
- return SANITIZE_THIS (list);
- }
-};
-ASSERT_SIZE (GPOS, 10);
-
-
-/* Out-of-class implementation for methods recursing */
-
-inline bool ExtensionPos::apply (APPLY_ARG_DEF) const
-{
- TRACE_APPLY ();
- unsigned int lookup_type = get_type ();
-
- if (HB_UNLIKELY (lookup_type == PosLookupSubTable::Extension))
- return false;
-
- return get_subtable ().apply (APPLY_ARG, lookup_type);
-}
-
-inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
-{
- TRACE_SANITIZE ();
- return Extension::sanitize (SANITIZE_ARG) &&
- (&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
- get_type () == PosLookupSubTable::Extension ||
- DECONST_CAST (PosLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG, get_type ()));
-}
-
-static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
-{
- const GPOS &gpos = *(context->face->ot_layout.gpos);
- const PosLookup &l = gpos.get_lookup (lookup_index);
-
- if (HB_UNLIKELY (nesting_level_left == 0))
- return false;
- nesting_level_left--;
-
- if (HB_UNLIKELY (context_length < 1))
- return false;
-
- return l.apply_once (context, buffer, context_length, nesting_level_left);
-}
-
-
-#endif /* HB_OT_LAYOUT_GPOS_PRIVATE_HH */
diff --git a/pango/opentype/hb-ot-layout-gsub-private.hh b/pango/opentype/hb-ot-layout-gsub-private.hh
deleted file mode 100644
index a9f78c24..00000000
--- a/pango/opentype/hb-ot-layout-gsub-private.hh
+++ /dev/null
@@ -1,909 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_LAYOUT_GSUB_PRIVATE_HH
-#define HB_OT_LAYOUT_GSUB_PRIVATE_HH
-
-#include "hb-ot-layout-gsubgpos-private.hh"
-
-
-struct SingleSubstFormat1
-{
- friend struct SingleSubst;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
- unsigned int index = (this+coverage) (glyph_id);
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- glyph_id += deltaGlyphID;
- _hb_buffer_replace_glyph (buffer, glyph_id);
-
- /* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, property);
-
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (coverage) && SANITIZE (deltaGlyphID);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of Substitution table */
- SHORT deltaGlyphID; /* Add to original GlyphID to get
- * substitute GlyphID */
-};
-ASSERT_SIZE (SingleSubstFormat1, 6);
-
-struct SingleSubstFormat2
-{
- friend struct SingleSubst;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
- unsigned int index = (this+coverage) (glyph_id);
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- if (HB_UNLIKELY (index >= substitute.len))
- return false;
-
- glyph_id = substitute[index];
- _hb_buffer_replace_glyph (buffer, glyph_id);
-
- /* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, property);
-
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (coverage) && SANITIZE (substitute);
- }
-
- private:
- USHORT format; /* Format identifier--format = 2 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of Substitution table */
- ArrayOf<GlyphID>
- substitute; /* Array of substitute
- * GlyphIDs--ordered by Coverage Index */
-};
-ASSERT_SIZE (SingleSubstFormat2, 6);
-
-struct SingleSubst
-{
- friend struct SubstLookupSubTable;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- case 2: return u.format2->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- SingleSubstFormat1 format1[VAR];
- SingleSubstFormat2 format2[VAR];
- } u;
-};
-
-
-struct Sequence
-{
- friend struct MultipleSubstFormat1;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- if (HB_UNLIKELY (!substitute.len))
- return false;
-
- _hb_buffer_add_output_glyphs (buffer, 1,
- substitute.len, (const uint16_t *) substitute.const_array(),
- 0xFFFF, 0xFFFF);
-
- /* This is a guess only ... */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- {
- if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
- property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
-
- unsigned int count = substitute.len;
- for (unsigned int n = 0; n < count; n++)
- _hb_ot_layout_set_glyph_property (context->face, substitute[n], property);
- }
-
- return true;
- }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE (substitute);
- }
-
- private:
- ArrayOf<GlyphID>
- substitute; /* String of GlyphIDs to substitute */
-};
-ASSERT_SIZE (Sequence, 2);
-
-struct MultipleSubstFormat1
-{
- friend struct MultipleSubst;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
-
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- return (this+sequence[index]).apply (APPLY_ARG);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, sequence);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of Substitution table */
- OffsetArrayOf<Sequence>
- sequence; /* Array of Sequence tables
- * ordered by Coverage Index */
-};
-ASSERT_SIZE (MultipleSubstFormat1, 6);
-
-struct MultipleSubst
-{
- friend struct SubstLookupSubTable;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- MultipleSubstFormat1 format1[VAR];
- } u;
-};
-
-
-typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in
- * arbitrary order */
-ASSERT_SIZE (AlternateSet, 2);
-
-struct AlternateSubstFormat1
-{
- friend struct AlternateSubst;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
-
- unsigned int index = (this+coverage) (glyph_id);
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const AlternateSet &alt_set = this+alternateSet[index];
-
- if (HB_UNLIKELY (!alt_set.len))
- return false;
-
- unsigned int alt_index = 0;
-
- /* XXX callback to user to choose alternate
- if (context->face->altfunc)
- alt_index = (context->face->altfunc)(context->layout, buffer,
- buffer->out_pos, glyph_id,
- alt_set.len, alt_set.array);
- */
-
- if (HB_UNLIKELY (alt_index >= alt_set.len))
- return false;
-
- glyph_id = alt_set[alt_index];
-
- _hb_buffer_replace_glyph (buffer, glyph_id);
-
- /* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_property (context->face, glyph_id, property);
-
- return true;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, alternateSet);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of Substitution table */
- OffsetArrayOf<AlternateSet>
- alternateSet; /* Array of AlternateSet tables
- * ordered by Coverage Index */
-};
-ASSERT_SIZE (AlternateSubstFormat1, 6);
-
-struct AlternateSubst
-{
- friend struct SubstLookupSubTable;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- AlternateSubstFormat1 format1[VAR];
- } u;
-};
-
-
-struct Ligature
-{
- friend struct LigatureSet;
-
- private:
- inline bool apply (APPLY_ARG_DEF, bool is_mark) const
- {
- TRACE_APPLY ();
- unsigned int i, j;
- unsigned int count = component.len;
- unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
- if (HB_UNLIKELY (buffer->in_pos + count > end))
- return false;
-
- for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
- {
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, &property))
- {
- if (HB_UNLIKELY (j + count - i == end))
- return false;
- j++;
- }
-
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
- is_mark = FALSE;
-
- if (HB_LIKELY (IN_GLYPH (j) != component[i]))
- return false;
- }
- /* This is just a guess ... */
- if (_hb_ot_layout_has_new_glyph_classes (context->face))
- _hb_ot_layout_set_glyph_class (context->face, ligGlyph,
- is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
- : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
-
- if (j == buffer->in_pos + i) /* No input glyphs skipped */
- /* We don't use a new ligature ID if there are no skipped
- glyphs and the ligature already has an ID. */
- _hb_buffer_add_output_glyphs (buffer, i,
- 1, (const uint16_t *) &ligGlyph,
- 0,
- IN_LIGID (buffer->in_pos) && !IN_COMPONENT (buffer->in_pos) ?
- 0xFFFF : _hb_buffer_allocate_lig_id (buffer));
- else
- {
- unsigned int lig_id = _hb_buffer_allocate_lig_id (buffer);
- _hb_buffer_add_output_glyph (buffer, ligGlyph, 0xFFFF, lig_id);
-
- /* Now we must do a second loop to copy the skipped glyphs to
- `out' and assign component values to it. We start with the
- glyph after the first component. Glyphs between component
- i and i+1 belong to component i. Together with the lig_id
- value it is later possible to check whether a specific
- component value really belongs to a given ligature. */
-
- for ( i = 1; i < count; i++ )
- {
- while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL))
- _hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i, lig_id);
-
- (buffer->in_pos)++;
- }
- }
-
- return true;
- }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE2 (ligGlyph, component);
- }
-
- private:
- GlyphID ligGlyph; /* GlyphID of ligature to substitute */
- HeadlessArrayOf<GlyphID>
- component; /* Array of component GlyphIDs--start
- * with the second component--ordered
- * in writing direction */
-};
-ASSERT_SIZE (Ligature, 4);
-
-struct LigatureSet
-{
- friend struct LigatureSubstFormat1;
-
- private:
- inline bool apply (APPLY_ARG_DEF, bool is_mark) const
- {
- TRACE_APPLY ();
- unsigned int num_ligs = ligature.len;
- for (unsigned int i = 0; i < num_ligs; i++)
- {
- const Ligature &lig = this+ligature[i];
- if (lig.apply (APPLY_ARG, is_mark))
- return true;
- }
-
- return false;
- }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (ligature);
- }
-
- private:
- OffsetArrayOf<Ligature>
- ligature; /* Array LigatureSet tables
- * ordered by preference */
-};
-ASSERT_SIZE (LigatureSet, 2);
-
-struct LigatureSubstFormat1
-{
- friend struct LigatureSubst;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
-
- bool first_is_mark = !!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
-
- unsigned int index = (this+coverage) (glyph_id);
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const LigatureSet &lig_set = this+ligatureSet[index];
- return lig_set.apply (APPLY_ARG, first_is_mark);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, ligatureSet);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of Substitution table */
- OffsetArrayOf<LigatureSet>
- ligatureSet; /* Array LigatureSet tables
- * ordered by Coverage Index */
-};
-ASSERT_SIZE (LigatureSubstFormat1, 6);
-
-struct LigatureSubst
-{
- friend struct SubstLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- LigatureSubstFormat1 format1[VAR];
- } u;
-};
-
-
-
-static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index);
-
-struct ContextSubst : Context
-{
- friend struct SubstLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- return Context::apply (APPLY_ARG, substitute_lookup);
- }
-};
-
-struct ChainContextSubst : ChainContext
-{
- friend struct SubstLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- return ChainContext::apply (APPLY_ARG, substitute_lookup);
- }
-};
-
-
-struct ExtensionSubst : Extension
-{
- friend struct SubstLookupSubTable;
-
- private:
- inline const struct SubstLookupSubTable& get_subtable (void) const
- { return CONST_CAST (SubstLookupSubTable, Extension::get_subtable (), 0); }
-
- inline bool apply (APPLY_ARG_DEF) const;
-
- inline bool sanitize (SANITIZE_ARG_DEF);
-};
-
-
-struct ReverseChainSingleSubstFormat1
-{
- friend struct ReverseChainSingleSubst;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- if (HB_UNLIKELY (context_length != NO_CONTEXT))
- return false; /* No chaining to this type */
-
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
- const ArrayOf<GlyphID> &substitute = CONST_NEXT (ArrayOf<GlyphID>, lookahead);
-
- if (match_backtrack (APPLY_ARG,
- backtrack.len, (USHORT *) backtrack.const_array(),
- match_coverage, DECONST_CHARP(this)) &&
- match_lookahead (APPLY_ARG,
- lookahead.len, (USHORT *) lookahead.const_array(),
- match_coverage, DECONST_CHARP(this),
- 1))
- {
- IN_CURGLYPH () = substitute[index];
- buffer->in_pos--; /* Reverse! */
- return true;
- }
-
- return false;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE_THIS2 (coverage, backtrack))
- return false;
- OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, backtrack);
- if (!SANITIZE_THIS (lookahead))
- return false;
- ArrayOf<GlyphID> &substitute = NEXT (ArrayOf<GlyphID>, lookahead);
- return SANITIZE (substitute);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of table */
- OffsetArrayOf<Coverage>
- backtrack; /* Array of coverage tables
- * in backtracking sequence, in glyph
- * sequence order */
- OffsetArrayOf<Coverage>
- lookaheadX; /* Array of coverage tables
- * in lookahead sequence, in glyph
- * sequence order */
- ArrayOf<GlyphID>
- substituteX; /* Array of substitute
- * GlyphIDs--ordered by Coverage Index */
-};
-ASSERT_SIZE (ReverseChainSingleSubstFormat1, 10);
-
-struct ReverseChainSingleSubst
-{
- friend struct SubstLookupSubTable;
-
- private:
- inline bool apply (APPLY_ARG_DEF) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- ReverseChainSingleSubstFormat1 format1[VAR];
- } u;
-};
-
-
-
-/*
- * SubstLookup
- */
-
-struct SubstLookupSubTable
-{
- friend struct SubstLookup;
-
- enum {
- Single = 1,
- Multiple = 2,
- Alternate = 3,
- Ligature = 4,
- Context = 5,
- ChainContext = 6,
- Extension = 7,
- ReverseChainSingle = 8
- };
-
- inline bool apply (APPLY_ARG_DEF, unsigned int lookup_type) const
- {
- TRACE_APPLY ();
- switch (lookup_type) {
- case Single: return u.single->apply (APPLY_ARG);
- case Multiple: return u.multiple->apply (APPLY_ARG);
- case Alternate: return u.alternate->apply (APPLY_ARG);
- case Ligature: return u.ligature->apply (APPLY_ARG);
- case Context: return u.context->apply (APPLY_ARG);
- case ChainContext: return u.chainContext->apply (APPLY_ARG);
- case Extension: return u.extension->apply (APPLY_ARG);
- case ReverseChainSingle: return u.reverseChainContextSingle->apply (APPLY_ARG);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF, unsigned int lookup_type) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.sub_format)) return false;
- switch (lookup_type) {
- case Single: return u.single->sanitize (SANITIZE_ARG);
- case Multiple: return u.multiple->sanitize (SANITIZE_ARG);
- case Alternate: return u.alternate->sanitize (SANITIZE_ARG);
- case Ligature: return u.ligature->sanitize (SANITIZE_ARG);
- case Context: return u.context->sanitize (SANITIZE_ARG);
- case ChainContext: return u.chainContext->sanitize (SANITIZE_ARG);
- case Extension: return u.extension->sanitize (SANITIZE_ARG);
- case ReverseChainSingle: return u.reverseChainContextSingle->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT sub_format;
- SingleSubst single[VAR];
- MultipleSubst multiple[VAR];
- AlternateSubst alternate[VAR];
- LigatureSubst ligature[VAR];
- ContextSubst context[VAR];
- ChainContextSubst chainContext[VAR];
- ExtensionSubst extension[VAR];
- ReverseChainSingleSubst reverseChainContextSingle[VAR];
- } u;
-};
-
-
-struct SubstLookup : Lookup
-{
- inline const SubstLookupSubTable& get_subtable (unsigned int i) const
- { return CONST_CAST (SubstLookupSubTable, Lookup::get_subtable (i), 0); }
-
- /* Like get_type(), but looks through extension lookups.
- * Never returns Extension */
- inline unsigned int get_effective_type (void) const
- {
- unsigned int type = get_type ();
-
- if (HB_UNLIKELY (type == SubstLookupSubTable::Extension))
- {
- unsigned int count = get_subtable_count ();
- type = get_subtable(0).u.extension->get_type ();
- /* The spec says all subtables should have the same type.
- * This is specially important if one has a reverse type! */
- for (unsigned int i = 1; i < count; i++)
- if (get_subtable(i).u.extension->get_type () != type)
- return 0;
- }
-
- return type;
- }
-
- inline bool is_reverse (void) const
- { return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle); }
-
- inline bool apply_once (hb_ot_layout_context_t *context,
- hb_buffer_t *buffer,
- unsigned int context_length,
- unsigned int nesting_level_left) const
- {
- unsigned int lookup_type = get_type ();
- unsigned int lookup_flag = get_flag ();
- unsigned int property;
-
- if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), lookup_flag, &property))
- return false;
-
- unsigned int count = get_subtable_count ();
- for (unsigned int i = 0; i < count; i++)
- if (get_subtable (i).apply (APPLY_ARG_INIT, lookup_type))
- return true;
-
- return false;
- }
-
- inline bool apply_string (hb_ot_layout_context_t *context,
- hb_buffer_t *buffer,
- hb_mask_t mask) const
- {
- bool ret = false;
-
- if (HB_UNLIKELY (!buffer->in_length))
- return false;
-
- if (HB_LIKELY (!is_reverse ()))
- {
- /* in/out forward substitution */
- _hb_buffer_clear_output (buffer);
- buffer->in_pos = 0;
- while (buffer->in_pos < buffer->in_length)
- {
- if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
- ret = true;
- else
- _hb_buffer_next_glyph (buffer);
-
- }
- if (ret)
- _hb_buffer_swap (buffer);
- }
- else
- {
- /* in-place backward substitution */
- buffer->in_pos = buffer->in_length - 1;
- do
- {
- if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
- ret = true;
- else
- buffer->in_pos--;
-
- }
- while ((int) buffer->in_pos >= 0);
- }
-
- return ret;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!Lookup::sanitize (SANITIZE_ARG)) return false;
- OffsetArrayOf<SubstLookupSubTable> &list = (OffsetArrayOf<SubstLookupSubTable> &) subTable;
- return list.sanitize (SANITIZE_ARG, this, get_type ());
- }
-};
-
-typedef OffsetListOf<SubstLookup> SubstLookupList;
-ASSERT_SIZE (SubstLookupList, 2);
-
-/*
- * GSUB
- */
-
-struct GSUB : GSUBGPOS
-{
- static const hb_tag_t Tag = HB_OT_TAG_GSUB;
-
- static inline const GSUB& get_for_data (const char *data)
- { return (const GSUB&) GSUBGPOS::get_for_data (data); }
-
- inline const SubstLookup& get_lookup (unsigned int i) const
- { return (const SubstLookup&) GSUBGPOS::get_lookup (i); }
-
- inline bool substitute_lookup (hb_ot_layout_context_t *context,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
-
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
- OffsetTo<SubstLookupList> &list = CAST(OffsetTo<SubstLookupList>, lookupList, 0);
- return SANITIZE_THIS (list);
- }
-};
-ASSERT_SIZE (GSUB, 10);
-
-
-/* Out-of-class implementation for methods recursing */
-
-inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const
-{
- TRACE_APPLY ();
- unsigned int lookup_type = get_type ();
-
- if (HB_UNLIKELY (lookup_type == SubstLookupSubTable::Extension))
- return false;
-
- return get_subtable ().apply (APPLY_ARG, lookup_type);
-}
-
-inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF)
-{
- TRACE_SANITIZE ();
- return Extension::sanitize (SANITIZE_ARG) &&
- (&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
- get_type () == SubstLookupSubTable::Extension ||
- DECONST_CAST (SubstLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG, get_type ()));
-}
-
-static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
-{
- const GSUB &gsub = *(context->face->ot_layout.gsub);
- const SubstLookup &l = gsub.get_lookup (lookup_index);
-
- if (HB_UNLIKELY (nesting_level_left == 0))
- return false;
- nesting_level_left--;
-
- if (HB_UNLIKELY (context_length < 1))
- return false;
-
- return l.apply_once (context, buffer, context_length, nesting_level_left);
-}
-
-
-#endif /* HB_OT_LAYOUT_GSUB_PRIVATE_HH */
diff --git a/pango/opentype/hb-ot-layout-gsubgpos-private.hh b/pango/opentype/hb-ot-layout-gsubgpos-private.hh
deleted file mode 100644
index 0bb96a41..00000000
--- a/pango/opentype/hb-ot-layout-gsubgpos-private.hh
+++ /dev/null
@@ -1,956 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
-#define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
-
-#include "hb-buffer-private.h"
-#include "hb-ot-layout-gdef-private.hh"
-
-
-#ifndef HB_DEBUG_APPLY
-#define HB_DEBUG_APPLY HB_DEBUG
-#endif
-
-#if HB_DEBUG_APPLY
-#define TRACE_APPLY_ARG_DEF , unsigned int apply_depth HB_GNUC_UNUSED
-#define TRACE_APPLY_ARG , apply_depth + 1
-#define TRACE_APPLY_ARG_INIT , 1
-#define TRACE_APPLY() \
- HB_STMT_START { \
- if (apply_depth < HB_DEBUG_APPLY) \
- fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \
- (CONST_CHARP (this) == CONST_CHARP (&NullPool)) ? 0 : this, \
- apply_depth, apply_depth, \
- __PRETTY_FUNCTION__); \
- } HB_STMT_END
-#else
-#define TRACE_APPLY_ARG_DEF
-#define TRACE_APPLY_ARG
-#define TRACE_APPLY_ARG_INIT
-#define TRACE_APPLY() HB_STMT_START {} HB_STMT_END
-#endif
-
-#define APPLY_ARG_DEF \
- hb_ot_layout_context_t *context, \
- hb_buffer_t *buffer, \
- unsigned int context_length HB_GNUC_UNUSED, \
- unsigned int nesting_level_left HB_GNUC_UNUSED, \
- unsigned int lookup_flag HB_GNUC_UNUSED, \
- unsigned int property HB_GNUC_UNUSED /* propety of first glyph */ \
- TRACE_APPLY_ARG_DEF
-#define APPLY_ARG \
- context, \
- buffer, \
- context_length, \
- nesting_level_left, \
- lookup_flag, \
- property \
- TRACE_APPLY_ARG
-#define APPLY_ARG_INIT \
- context, \
- buffer, \
- context_length, \
- nesting_level_left, \
- lookup_flag, \
- property \
- TRACE_APPLY_ARG_INIT
-
-
-typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, char *data);
-typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index);
-
-struct ContextFuncs
-{
- match_func_t match;
- apply_lookup_func_t apply;
-};
-
-
-static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, char *data HB_GNUC_UNUSED)
-{
- return glyph_id == value;
-}
-
-static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, char *data)
-{
- const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data);
- return class_def.get_class (glyph_id) == value;
-}
-
-static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, char *data)
-{
- const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value;
- return (data+coverage) (glyph_id) != NOT_COVERED;
-}
-
-
-static inline bool match_input (APPLY_ARG_DEF,
- unsigned int count, /* Including the first glyph (not matched) */
- const USHORT input[], /* Array of input values--start with second glyph */
- match_func_t match_func,
- char *match_data,
- unsigned int *context_length_out)
-{
- unsigned int i, j;
- unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
- if (HB_UNLIKELY (buffer->in_pos + count > end))
- return false;
-
- for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
- {
- while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL))
- {
- if (HB_UNLIKELY (j + count - i == end))
- return false;
- j++;
- }
-
- if (HB_LIKELY (!match_func (IN_GLYPH (j), input[i - 1], match_data)))
- return false;
- }
-
- *context_length_out = j - buffer->in_pos;
-
- return true;
-}
-
-static inline bool match_backtrack (APPLY_ARG_DEF,
- unsigned int count,
- const USHORT backtrack[],
- match_func_t match_func,
- char *match_data)
-{
- if (HB_UNLIKELY (buffer->out_pos < count))
- return false;
-
- for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
- {
- while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
- {
- if (HB_UNLIKELY (j + 1 == count - i))
- return false;
- j--;
- }
-
- if (HB_LIKELY (!match_func (OUT_GLYPH (j), backtrack[i], match_data)))
- return false;
- }
-
- return true;
-}
-
-static inline bool match_lookahead (APPLY_ARG_DEF,
- unsigned int count,
- const USHORT lookahead[],
- match_func_t match_func,
- char *match_data,
- unsigned int offset)
-{
- unsigned int i, j;
- unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
- if (HB_UNLIKELY (buffer->in_pos + offset + count > end))
- return false;
-
- for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
- {
- while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL))
- {
- if (HB_UNLIKELY (j + count - i == end))
- return false;
- j++;
- }
-
- if (HB_LIKELY (!match_func (IN_GLYPH (j), lookahead[i], match_data)))
- return false;
- }
-
- return true;
-}
-
-
-struct LookupRecord
-{
- static inline unsigned int get_size () { return sizeof (LookupRecord); }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- USHORT sequenceIndex; /* Index into current glyph
- * sequence--first glyph = 0 */
- USHORT lookupListIndex; /* Lookup to apply to that
- * position--zero--based */
-};
-ASSERT_SIZE (LookupRecord, 4);
-
-static inline bool apply_lookup (APPLY_ARG_DEF,
- unsigned int count, /* Including the first glyph */
- unsigned int lookupCount,
- const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
- apply_lookup_func_t apply_func)
-{
- unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length);
- if (HB_UNLIKELY (buffer->in_pos + count > end))
- return false;
-
- /* TODO We don't support lookupRecord arrays that are not increasing:
- * Should be easy for in_place ones at least. */
-
- /* Note: If sublookup is reverse, i will underflow after the first loop
- * and we jump out of it. Not entirely disastrous. So we don't check
- * for reverse lookup here.
- */
- for (unsigned int i = 0; i < count; /* NOP */)
- {
- while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL))
- {
- if (HB_UNLIKELY (buffer->in_pos == end))
- return true;
- /* No lookup applied for this index */
- _hb_buffer_next_glyph (buffer);
- }
-
- if (lookupCount && i == lookupRecord->sequenceIndex)
- {
- unsigned int old_pos = buffer->in_pos;
-
- /* Apply a lookup */
- bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex);
-
- lookupRecord++;
- lookupCount--;
- /* Err, this is wrong if the lookup jumped over some glyphs */
- i += buffer->in_pos - old_pos;
- if (HB_UNLIKELY (buffer->in_pos == end))
- return true;
-
- if (!done)
- goto not_applied;
- }
- else
- {
- not_applied:
- /* No lookup applied for this index */
- _hb_buffer_next_glyph (buffer);
- i++;
- }
- }
-
- return true;
-}
-
-
-/* Contextual lookups */
-
-struct ContextLookupContext
-{
- ContextFuncs funcs;
- char *match_data;
-};
-
-static inline bool context_lookup (APPLY_ARG_DEF,
- unsigned int inputCount, /* Including the first glyph (not matched) */
- const USHORT input[], /* Array of input values--start with second glyph */
- unsigned int lookupCount,
- const LookupRecord lookupRecord[],
- ContextLookupContext &lookup_context)
-{
- return match_input (APPLY_ARG,
- inputCount, input,
- lookup_context.funcs.match, lookup_context.match_data,
- &context_length) &&
- apply_lookup (APPLY_ARG,
- inputCount,
- lookupCount, lookupRecord,
- lookup_context.funcs.apply);
-}
-
-struct Rule
-{
- friend struct RuleSet;
-
- private:
- inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
- {
- TRACE_APPLY ();
- const LookupRecord *lookupRecord = &CONST_CAST (LookupRecord, input, input[0].get_size () * (inputCount ? inputCount - 1 : 0));
- return context_lookup (APPLY_ARG,
- inputCount, input,
- lookupCount, lookupRecord,
- lookup_context);
- }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!(SANITIZE (inputCount) && SANITIZE (lookupCount))) return false;
- return SANITIZE_MEM (input,
- input[0].get_size () * inputCount +
- lookupRecordX[0].get_size () * lookupCount);
- }
-
- private:
- USHORT inputCount; /* Total number of glyphs in input
- * glyph sequence--includes the first
- * glyph */
- USHORT lookupCount; /* Number of LookupRecords */
- USHORT input[VAR]; /* Array of match inputs--start with
- * second glyph */
- LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
- * design order */
-};
-ASSERT_SIZE_VAR2 (Rule, 4, USHORT, LookupRecord);
-
-struct RuleSet
-{
- inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
- {
- TRACE_APPLY ();
- unsigned int num_rules = rule.len;
- for (unsigned int i = 0; i < num_rules; i++)
- {
- if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
- return true;
- }
-
- return false;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (rule);
- }
-
- private:
- OffsetArrayOf<Rule>
- rule; /* Array of Rule tables
- * ordered by preference */
-};
-
-
-struct ContextFormat1
-{
- friend struct Context;
-
- private:
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const RuleSet &rule_set = this+ruleSet[index];
- struct ContextLookupContext lookup_context = {
- {match_glyph, apply_func},
- NULL
- };
- return rule_set.apply (APPLY_ARG, lookup_context);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, ruleSet);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of table */
- OffsetArrayOf<RuleSet>
- ruleSet; /* Array of RuleSet tables
- * ordered by Coverage Index */
-};
-ASSERT_SIZE (ContextFormat1, 6);
-
-
-struct ContextFormat2
-{
- friend struct Context;
-
- private:
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const ClassDef &class_def = this+classDef;
- index = class_def (IN_CURGLYPH ());
- const RuleSet &rule_set = this+ruleSet[index];
- /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
- * them across subrule lookups. Not sure it's worth it.
- */
- struct ContextLookupContext lookup_context = {
- {match_class, apply_func},
- DECONST_CHARP(&class_def)
- };
- return rule_set.apply (APPLY_ARG, lookup_context);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS3 (coverage, classDef, ruleSet);
- }
-
- private:
- USHORT format; /* Format identifier--format = 2 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of table */
- OffsetTo<ClassDef>
- classDef; /* Offset to glyph ClassDef table--from
- * beginning of table */
- OffsetArrayOf<RuleSet>
- ruleSet; /* Array of RuleSet tables
- * ordered by class */
-};
-ASSERT_SIZE (ContextFormat2, 8);
-
-
-struct ContextFormat3
-{
- friend struct Context;
-
- private:
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const LookupRecord *lookupRecord = &CONST_CAST(LookupRecord, coverage, coverage[0].get_size () * glyphCount);
- struct ContextLookupContext lookup_context = {
- {match_coverage, apply_func},
- DECONST_CHARP(this)
- };
- return context_lookup (APPLY_ARG,
- glyphCount, (const USHORT *) (coverage + 1),
- lookupCount, lookupRecord,
- lookup_context);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE_SELF ()) return false;
- unsigned int count = glyphCount;
- for (unsigned int i = 0; i < count; i++)
- if (!SANITIZE_THIS (coverage[i])) return false;
- LookupRecord *lookupRecord = &CAST(LookupRecord, coverage, coverage[0].get_size () * glyphCount);
- return SANITIZE_MEM (lookupRecord, lookupRecord[0].get_size () * lookupCount);
- }
-
- private:
- USHORT format; /* Format identifier--format = 3 */
- USHORT glyphCount; /* Number of glyphs in the input glyph
- * sequence */
- USHORT lookupCount; /* Number of LookupRecords */
- OffsetTo<Coverage>
- coverage[VAR]; /* Array of offsets to Coverage
- * table in glyph sequence order */
- LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in
- * design order */
-};
-ASSERT_SIZE_VAR2 (ContextFormat3, 6, OffsetTo<Coverage>, LookupRecord);
-
-struct Context
-{
- protected:
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG, apply_func);
- case 2: return u.format2->apply (APPLY_ARG, apply_func);
- case 3: return u.format3->apply (APPLY_ARG, apply_func);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- case 3: return u.format3->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- ContextFormat1 format1[VAR];
- ContextFormat2 format2[VAR];
- ContextFormat3 format3[VAR];
- } u;
-};
-
-
-/* Chaining Contextual lookups */
-
-struct ChainContextLookupContext
-{
- ContextFuncs funcs;
- char *match_data[3];
-};
-
-static inline bool chain_context_lookup (APPLY_ARG_DEF,
- unsigned int backtrackCount,
- const USHORT backtrack[],
- unsigned int inputCount, /* Including the first glyph (not matched) */
- const USHORT input[], /* Array of input values--start with second glyph */
- unsigned int lookaheadCount,
- const USHORT lookahead[],
- unsigned int lookupCount,
- const LookupRecord lookupRecord[],
- ChainContextLookupContext &lookup_context)
-{
- /* First guess */
- if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
- buffer->in_pos + inputCount + lookaheadCount > buffer->in_length ||
- inputCount + lookaheadCount > context_length))
- return false;
-
- unsigned int offset;
- return match_backtrack (APPLY_ARG,
- backtrackCount, backtrack,
- lookup_context.funcs.match, lookup_context.match_data[0]) &&
- match_input (APPLY_ARG,
- inputCount, input,
- lookup_context.funcs.match, lookup_context.match_data[1],
- &offset) &&
- match_lookahead (APPLY_ARG,
- lookaheadCount, lookahead,
- lookup_context.funcs.match, lookup_context.match_data[2],
- offset) &&
- (context_length = offset, true) &&
- apply_lookup (APPLY_ARG,
- inputCount,
- lookupCount, lookupRecord,
- lookup_context.funcs.apply);
-}
-
-struct ChainRule
-{
- friend struct ChainRuleSet;
-
- private:
- inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
- {
- TRACE_APPLY ();
- const HeadlessArrayOf<USHORT> &input = CONST_NEXT (HeadlessArrayOf<USHORT>, backtrack);
- const ArrayOf<USHORT> &lookahead = CONST_NEXT (ArrayOf<USHORT>, input);
- const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
- return chain_context_lookup (APPLY_ARG,
- backtrack.len, backtrack.const_array(),
- input.len, input.const_array(),
- lookahead.len, lookahead.const_array(),
- lookup.len, lookup.const_array(),
- lookup_context);
- return false;
- }
-
- public:
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (backtrack)) return false;
- HeadlessArrayOf<USHORT> &input = NEXT (HeadlessArrayOf<USHORT>, backtrack);
- if (!SANITIZE (input)) return false;
- ArrayOf<USHORT> &lookahead = NEXT (ArrayOf<USHORT>, input);
- if (!SANITIZE (lookahead)) return false;
- ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
- return SANITIZE (lookup);
- }
-
- private:
- ArrayOf<USHORT>
- backtrack; /* Array of backtracking values
- * (to be matched before the input
- * sequence) */
- HeadlessArrayOf<USHORT>
- inputX; /* Array of input values (start with
- * second glyph) */
- ArrayOf<USHORT>
- lookaheadX; /* Array of lookahead values's (to be
- * matched after the input sequence) */
- ArrayOf<LookupRecord>
- lookupX; /* Array of LookupRecords--in
- * design order) */
-};
-ASSERT_SIZE (ChainRule, 8);
-
-struct ChainRuleSet
-{
- inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
- {
- TRACE_APPLY ();
- unsigned int num_rules = rule.len;
- for (unsigned int i = 0; i < num_rules; i++)
- {
- if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
- return true;
- }
-
- return false;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS (rule);
- }
-
- private:
- OffsetArrayOf<ChainRule>
- rule; /* Array of ChainRule tables
- * ordered by preference */
-};
-ASSERT_SIZE (ChainRuleSet, 2);
-
-struct ChainContextFormat1
-{
- friend struct ChainContext;
-
- private:
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const ChainRuleSet &rule_set = this+ruleSet[index];
- struct ChainContextLookupContext lookup_context = {
- {match_glyph, apply_func},
- {NULL, NULL, NULL}
- };
- return rule_set.apply (APPLY_ARG, lookup_context);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, ruleSet);
- }
-
- private:
- USHORT format; /* Format identifier--format = 1 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of table */
- OffsetArrayOf<ChainRuleSet>
- ruleSet; /* Array of ChainRuleSet tables
- * ordered by Coverage Index */
-};
-ASSERT_SIZE (ChainContextFormat1, 6);
-
-struct ChainContextFormat2
-{
- friend struct ChainContext;
-
- private:
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const ClassDef &backtrack_class_def = this+backtrackClassDef;
- const ClassDef &input_class_def = this+inputClassDef;
- const ClassDef &lookahead_class_def = this+lookaheadClassDef;
-
- index = input_class_def (IN_CURGLYPH ());
- const ChainRuleSet &rule_set = this+ruleSet[index];
- /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
- * them across subrule lookups. Not sure it's worth it.
- */
- struct ChainContextLookupContext lookup_context = {
- {match_class, apply_func},
- {DECONST_CHARP(&backtrack_class_def),
- DECONST_CHARP(&input_class_def),
- DECONST_CHARP(&lookahead_class_def)}
- };
- return rule_set.apply (APPLY_ARG, lookup_context);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_THIS2 (coverage, backtrackClassDef) &&
- SANITIZE_THIS2 (inputClassDef, lookaheadClassDef) &&
- SANITIZE_THIS (ruleSet);
- }
-
- private:
- USHORT format; /* Format identifier--format = 2 */
- OffsetTo<Coverage>
- coverage; /* Offset to Coverage table--from
- * beginning of table */
- OffsetTo<ClassDef>
- backtrackClassDef; /* Offset to glyph ClassDef table
- * containing backtrack sequence
- * data--from beginning of table */
- OffsetTo<ClassDef>
- inputClassDef; /* Offset to glyph ClassDef
- * table containing input sequence
- * data--from beginning of table */
- OffsetTo<ClassDef>
- lookaheadClassDef; /* Offset to glyph ClassDef table
- * containing lookahead sequence
- * data--from beginning of table */
- OffsetArrayOf<ChainRuleSet>
- ruleSet; /* Array of ChainRuleSet tables
- * ordered by class */
-};
-ASSERT_SIZE (ChainContextFormat2, 12);
-
-struct ChainContextFormat3
-{
- friend struct ChainContext;
-
- private:
-
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- const OffsetArrayOf<Coverage> &input = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack);
-
- unsigned int index = (this+input[0]) (IN_CURGLYPH ());
- if (HB_LIKELY (index == NOT_COVERED))
- return false;
-
- const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, input);
- const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead);
- struct ChainContextLookupContext lookup_context = {
- {match_coverage, apply_func},
- {DECONST_CHARP(this), DECONST_CHARP(this), DECONST_CHARP(this)}
- };
- return chain_context_lookup (APPLY_ARG,
- backtrack.len, (const USHORT *) backtrack.const_array(),
- input.len, (const USHORT *) input.const_array() + 1,
- lookahead.len, (const USHORT *) lookahead.const_array(),
- lookup.len, lookup.const_array(),
- lookup_context);
- return false;
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE_THIS (backtrack)) return false;
- OffsetArrayOf<Coverage> &input = NEXT (OffsetArrayOf<Coverage>, backtrack);
- if (!SANITIZE_THIS (input)) return false;
- OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, input);
- if (!SANITIZE_THIS (lookahead)) return false;
- ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead);
- return SANITIZE (lookup);
- }
-
- private:
- USHORT format; /* Format identifier--format = 3 */
- OffsetArrayOf<Coverage>
- backtrack; /* Array of coverage tables
- * in backtracking sequence, in glyph
- * sequence order */
- OffsetArrayOf<Coverage>
- inputX ; /* Array of coverage
- * tables in input sequence, in glyph
- * sequence order */
- OffsetArrayOf<Coverage>
- lookaheadX; /* Array of coverage tables
- * in lookahead sequence, in glyph
- * sequence order */
- ArrayOf<LookupRecord>
- lookupX; /* Array of LookupRecords--in
- * design order) */
-};
-ASSERT_SIZE (ChainContextFormat3, 10);
-
-struct ChainContext
-{
- protected:
- inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const
- {
- TRACE_APPLY ();
- switch (u.format) {
- case 1: return u.format1->apply (APPLY_ARG, apply_func);
- case 2: return u.format2->apply (APPLY_ARG, apply_func);
- case 3: return u.format3->apply (APPLY_ARG, apply_func);
- default:return false;
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- case 2: return u.format2->sanitize (SANITIZE_ARG);
- case 3: return u.format3->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- ChainContextFormat1 format1[VAR];
- ChainContextFormat2 format2[VAR];
- ChainContextFormat3 format3[VAR];
- } u;
-};
-
-
-struct ExtensionFormat1
-{
- friend struct Extension;
-
- protected:
- inline unsigned int get_type (void) const { return extensionLookupType; }
- inline unsigned int get_offset (void) const { return (extensionOffset[0] << 16) + extensionOffset[1]; }
- inline const LookupSubTable& get_subtable (void) const
- {
- unsigned int offset = get_offset ();
- if (HB_UNLIKELY (!offset)) return Null(LookupSubTable);
- return CONST_CAST (LookupSubTable, *this, offset);
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- return SANITIZE_SELF ();
- }
-
- private:
- USHORT format; /* Format identifier. Set to 1. */
- USHORT extensionLookupType; /* Lookup type of subtable referenced
- * by ExtensionOffset (i.e. the
- * extension subtable). */
- USHORT extensionOffset[2]; /* Offset to the extension subtable,
- * of lookup type subtable.
- * Defined as two shorts to avoid
- * alignment requirements. */
-};
-ASSERT_SIZE (ExtensionFormat1, 8);
-
-struct Extension
-{
- inline unsigned int get_type (void) const
- {
- switch (u.format) {
- case 1: return u.format1->get_type ();
- default:return 0;
- }
- }
- inline const LookupSubTable& get_subtable (void) const
- {
- switch (u.format) {
- case 1: return u.format1->get_subtable ();
- default:return Null(LookupSubTable);
- }
- }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
- case 1: return u.format1->sanitize (SANITIZE_ARG);
- default:return true;
- }
- }
-
- private:
- union {
- USHORT format; /* Format identifier */
- ExtensionFormat1 format1[VAR];
- } u;
-};
-
-
-/*
- * GSUB/GPOS Common
- */
-
-struct GSUBGPOS
-{
- static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB;
- static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS;
-
- STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1, 1);
-
- inline unsigned int get_script_count (void) const
- { return (this+scriptList).len; }
- inline const Tag& get_script_tag (unsigned int i) const
- { return (this+scriptList).get_tag (i); }
- inline bool get_script_tags (unsigned int *script_count /* IN/OUT */,
- hb_tag_t *script_tags /* OUT */) const
- { return (this+scriptList).get_tags (script_count, script_tags); }
- inline const Script& get_script (unsigned int i) const
- { return (this+scriptList)[i]; }
- inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
- { return (this+scriptList).find_index (tag, index); }
-
- inline unsigned int get_feature_count (void) const
- { return (this+featureList).len; }
- inline const Tag& get_feature_tag (unsigned int i) const
- { return (this+featureList).get_tag (i); }
- inline bool get_feature_tags (unsigned int *feature_count /* IN/OUT */,
- hb_tag_t *feature_tags /* OUT */) const
- { return (this+featureList).get_tags (feature_count, feature_tags); }
- inline const Feature& get_feature (unsigned int i) const
- { return (this+featureList)[i]; }
- inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
- { return (this+featureList).find_index (tag, index); }
-
- inline unsigned int get_lookup_count (void) const
- { return (this+lookupList).len; }
- inline const Lookup& get_lookup (unsigned int i) const
- { return (this+lookupList)[i]; }
-
- inline bool sanitize (SANITIZE_ARG_DEF) {
- TRACE_SANITIZE ();
- if (!SANITIZE (version)) return false;
- if (version.major != 1) return true;
- return SANITIZE_THIS3 (scriptList, featureList, lookupList);
- }
-
- protected:
- FixedVersion version; /* Version of the GSUB/GPOS table--initially set
- * to 0x00010000 */
- OffsetTo<ScriptList>
- scriptList; /* ScriptList table */
- OffsetTo<FeatureList>
- featureList; /* FeatureList table */
- OffsetTo<LookupList>
- lookupList; /* LookupList table */
-};
-ASSERT_SIZE (GSUBGPOS, 10);
-
-
-#endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */
diff --git a/pango/opentype/hb-ot-layout-private.h b/pango/opentype/hb-ot-layout-private.h
deleted file mode 100644
index fb7bfe49..00000000
--- a/pango/opentype/hb-ot-layout-private.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_LAYOUT_PRIVATE_H
-#define HB_OT_LAYOUT_PRIVATE_H
-
-#include "hb-private.h"
-
-#include "hb-ot-layout.h"
-
-#include "hb-font.h"
-#include "hb-buffer-private.h"
-
-
-HB_BEGIN_DECLS
-
-typedef unsigned int hb_ot_layout_class_t;
-
-/*
- * hb_ot_layout_t
- */
-
-typedef struct _hb_ot_layout_t hb_ot_layout_t;
-
-struct _hb_ot_layout_t
-{
- hb_blob_t *gdef_blob;
- hb_blob_t *gsub_blob;
- hb_blob_t *gpos_blob;
-
- const struct GDEF *gdef;
- const struct GSUB *gsub;
- const struct GPOS *gpos;
-
- struct
- {
- unsigned char *klasses;
- unsigned int len;
- } new_gdef;
-};
-
-typedef struct _hb_ot_layout_context_t hb_ot_layout_context_t;
-struct _hb_ot_layout_context_t
-{
- hb_face_t *face;
- hb_font_t *font;
-
- union info_t
- {
- struct gpos_t
- {
- unsigned int last; /* the last valid glyph--used with cursive positioning */
- hb_position_t anchor_x; /* the coordinates of the anchor point */
- hb_position_t anchor_y; /* of the last valid glyph */
- } gpos;
- } info;
-};
-
-
-void
-_hb_ot_layout_init (hb_face_t *face);
-
-void
-_hb_ot_layout_fini (hb_face_t *face);
-
-
-/*
- * GDEF
- */
-
-HB_INTERNAL hb_bool_t
-_hb_ot_layout_has_new_glyph_classes (hb_face_t *face);
-
-HB_INTERNAL void
-_hb_ot_layout_set_glyph_property (hb_face_t *face,
- hb_codepoint_t glyph,
- unsigned int property);
-
-HB_INTERNAL void
-_hb_ot_layout_set_glyph_class (hb_face_t *face,
- hb_codepoint_t glyph,
- hb_ot_layout_glyph_class_t klass);
-
-HB_INTERNAL hb_bool_t
-_hb_ot_layout_check_glyph_property (hb_face_t *face,
- hb_internal_glyph_info_t *ginfo,
- unsigned int lookup_flags,
- unsigned int *property);
-
-HB_INTERNAL hb_bool_t
-_hb_ot_layout_skip_mark (hb_face_t *face,
- hb_internal_glyph_info_t *ginfo,
- unsigned int lookup_flags,
- unsigned int *property);
-
-HB_END_DECLS
-
-#endif /* HB_OT_LAYOUT_PRIVATE_H */
diff --git a/pango/opentype/hb-ot-layout.cc b/pango/opentype/hb-ot-layout.cc
deleted file mode 100644
index 8099fc5f..00000000
--- a/pango/opentype/hb-ot-layout.cc
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * Copyright (C) 1998-2004 David Turner and Werner Lemberg
- * Copyright (C) 2006 Behdad Esfahbod
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#define HB_OT_LAYOUT_CC
-
-#include "hb-ot-layout-private.h"
-
-#include "hb-ot-layout-gdef-private.hh"
-#include "hb-ot-layout-gsub-private.hh"
-#include "hb-ot-layout-gpos-private.hh"
-
-
-#include <stdlib.h>
-#include <string.h>
-
-
-void
-_hb_ot_layout_init (hb_face_t *face)
-{
- hb_ot_layout_t *layout = &face->ot_layout;
-
- memset (layout, 0, sizeof (*layout));
-
- layout->gdef_blob = Sanitizer<GDEF>::sanitize (hb_face_get_table (face, HB_OT_TAG_GDEF));
- layout->gdef = &Sanitizer<GDEF>::lock_instance (layout->gdef_blob);
-
- layout->gsub_blob = Sanitizer<GSUB>::sanitize (hb_face_get_table (face, HB_OT_TAG_GSUB));
- layout->gsub = &Sanitizer<GSUB>::lock_instance (layout->gsub_blob);
-
- layout->gpos_blob = Sanitizer<GPOS>::sanitize (hb_face_get_table (face, HB_OT_TAG_GPOS));
- layout->gpos = &Sanitizer<GPOS>::lock_instance (layout->gpos_blob);
-}
-
-void
-_hb_ot_layout_fini (hb_face_t *face)
-{
- hb_ot_layout_t *layout = &face->ot_layout;
-
- hb_blob_unlock (layout->gdef_blob);
- hb_blob_unlock (layout->gsub_blob);
- hb_blob_unlock (layout->gpos_blob);
-
- hb_blob_destroy (layout->gdef_blob);
- hb_blob_destroy (layout->gsub_blob);
- hb_blob_destroy (layout->gpos_blob);
-
- free (layout->new_gdef.klasses);
-}
-
-static const GDEF&
-_get_gdef (hb_face_t *face)
-{
- return HB_LIKELY (face->ot_layout.gdef) ? *face->ot_layout.gdef : Null(GDEF);
-}
-
-static const GSUB&
-_get_gsub (hb_face_t *face)
-{
- return HB_LIKELY (face->ot_layout.gsub) ? *face->ot_layout.gsub : Null(GSUB);
-}
-
-static const GPOS&
-_get_gpos (hb_face_t *face)
-{
- return HB_LIKELY (face->ot_layout.gpos) ? *face->ot_layout.gpos : Null(GPOS);
-}
-
-
-/*
- * GDEF
- */
-
-/* TODO the public class_t is a mess */
-
-hb_bool_t
-hb_ot_layout_has_font_glyph_classes (hb_face_t *face)
-{
- return _get_gdef (face).has_glyph_classes ();
-}
-
-hb_bool_t
-_hb_ot_layout_has_new_glyph_classes (hb_face_t *face)
-{
- return face->ot_layout.new_gdef.len > 0;
-}
-
-static unsigned int
-_hb_ot_layout_get_glyph_property (hb_face_t *face,
- hb_codepoint_t glyph)
-{
- hb_ot_layout_class_t klass;
- const GDEF &gdef = _get_gdef (face);
-
- klass = gdef.get_glyph_class (glyph);
-
- if (!klass && glyph < face->ot_layout.new_gdef.len)
- klass = face->ot_layout.new_gdef.klasses[glyph];
-
- switch (klass) {
- default:
- case GDEF::UnclassifiedGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED;
- case GDEF::BaseGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
- case GDEF::LigatureGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE;
- case GDEF::ComponentGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT;
- case GDEF::MarkGlyph:
- klass = gdef.get_mark_attachment_type (glyph);
- return HB_OT_LAYOUT_GLYPH_CLASS_MARK + (klass << 8);
- }
-}
-
-hb_bool_t
-_hb_ot_layout_check_glyph_property (hb_face_t *face,
- hb_internal_glyph_info_t *ginfo,
- unsigned int lookup_flags,
- unsigned int *property_out)
-{
- unsigned int property;
-
- if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
- ginfo->gproperty = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint);
- property = ginfo->gproperty;
- if (property_out)
- *property_out = property;
-
- /* Not covered, if, for example, glyph class is ligature and
- * lookup_flags includes LookupFlags::IgnoreLigatures
- */
- if (property & lookup_flags & LookupFlag::IgnoreFlags)
- return false;
-
- if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
- {
- /* If using mark filtering sets, the high short of
- * lookup_flags has the set index.
- */
- if (lookup_flags & LookupFlag::UseMarkFilteringSet)
- return _get_gdef (face).mark_set_covers (lookup_flags >> 16, ginfo->codepoint);
-
- /* The second byte of lookup_flags has the meaning
- * "ignore marks of attachment type different than
- * the attachment type specified."
- */
- if (lookup_flags & LookupFlag::MarkAttachmentType && property & LookupFlag::MarkAttachmentType)
- return (lookup_flags & LookupFlag::MarkAttachmentType) == (property & LookupFlag::MarkAttachmentType);
- }
-
- return true;
-}
-
-hb_bool_t
-_hb_ot_layout_skip_mark (hb_face_t *face,
- hb_internal_glyph_info_t *ginfo,
- unsigned int lookup_flags,
- unsigned int *property_out)
-{
- unsigned int property;
-
- if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
- ginfo->gproperty = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint);
- property = ginfo->gproperty;
- if (property_out)
- *property_out = property;
-
- if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
- {
- /* Skip mark if lookup_flags includes LookupFlags::IgnoreMarks */
- if (lookup_flags & LookupFlag::IgnoreMarks)
- return true;
-
- /* If using mark filtering sets, the high short of lookup_flags has the set index. */
- if (lookup_flags & LookupFlag::UseMarkFilteringSet)
- return !_get_gdef (face).mark_set_covers (lookup_flags >> 16, ginfo->codepoint);
-
- /* The second byte of lookup_flags has the meaning "ignore marks of attachment type
- * different than the attachment type specified." */
- if (lookup_flags & LookupFlag::MarkAttachmentType && property & LookupFlag::MarkAttachmentType)
- return (lookup_flags & LookupFlag::MarkAttachmentType) != (property & LookupFlag::MarkAttachmentType);
- }
-
- return false;
-}
-
-void
-_hb_ot_layout_set_glyph_class (hb_face_t *face,
- hb_codepoint_t glyph,
- hb_ot_layout_glyph_class_t klass)
-{
- if (HB_OBJECT_IS_INERT (face))
- return;
-
- /* TODO optimize this? similar to old harfbuzz code for example */
-
- hb_ot_layout_t *layout = &face->ot_layout;
- hb_ot_layout_class_t gdef_klass;
- unsigned int len = layout->new_gdef.len;
-
- if (HB_UNLIKELY (glyph > 65535))
- return;
-
- /* XXX this is not threadsafe */
- if (glyph >= len) {
- unsigned int new_len;
- unsigned char *new_klasses;
-
- new_len = len == 0 ? 120 : 2 * len;
- while (new_len <= glyph)
- new_len *= 2;
-
- if (new_len > 65536)
- new_len = 65536;
- new_klasses = (unsigned char *) realloc (layout->new_gdef.klasses, new_len * sizeof (unsigned char));
-
- if (HB_UNLIKELY (!new_klasses))
- return;
-
- memset (new_klasses + len, 0, new_len - len);
-
- layout->new_gdef.klasses = new_klasses;
- layout->new_gdef.len = new_len;
- }
-
- switch (klass) {
- default:
- case HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED: gdef_klass = GDEF::UnclassifiedGlyph; break;
- case HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH: gdef_klass = GDEF::BaseGlyph; break;
- case HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE: gdef_klass = GDEF::LigatureGlyph; break;
- case HB_OT_LAYOUT_GLYPH_CLASS_MARK: gdef_klass = GDEF::MarkGlyph; break;
- case HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT: gdef_klass = GDEF::ComponentGlyph; break;
- }
-
- layout->new_gdef.klasses[glyph] = gdef_klass;
- return;
-}
-
-void
-_hb_ot_layout_set_glyph_property (hb_face_t *face,
- hb_codepoint_t glyph,
- unsigned int property)
-{ _hb_ot_layout_set_glyph_class (face, glyph, (hb_ot_layout_glyph_class_t) (property & 0xff)); }
-
-
-hb_ot_layout_glyph_class_t
-hb_ot_layout_get_glyph_class (hb_face_t *face,
- hb_codepoint_t glyph)
-{
- return (hb_ot_layout_glyph_class_t) (_hb_ot_layout_get_glyph_property (face, glyph) & 0xff);
-}
-
-void
-hb_ot_layout_set_glyph_class (hb_face_t *face,
- hb_codepoint_t glyph,
- hb_ot_layout_glyph_class_t klass)
-{
- _hb_ot_layout_set_glyph_class (face, glyph, klass);
-}
-
-void
-hb_ot_layout_build_glyph_classes (hb_face_t *face,
- hb_codepoint_t *glyphs,
- unsigned char *klasses,
- uint16_t count)
-{
- if (HB_OBJECT_IS_INERT (face))
- return;
-
- hb_ot_layout_t *layout = &face->ot_layout;
-
- if (HB_UNLIKELY (!count || !glyphs || !klasses))
- return;
-
- if (layout->new_gdef.len == 0) {
- layout->new_gdef.klasses = (unsigned char *) calloc (count, sizeof (unsigned char));
- layout->new_gdef.len = count;
- }
-
- for (unsigned int i = 0; i < count; i++)
- _hb_ot_layout_set_glyph_class (face, glyphs[i], (hb_ot_layout_glyph_class_t) klasses[i]);
-}
-
-hb_bool_t
-hb_ot_layout_get_attach_points (hb_face_t *face,
- hb_codepoint_t glyph,
- unsigned int *point_count /* IN/OUT */,
- unsigned int *point_array /* OUT */)
-{
- return _get_gdef (face).get_attach_points (glyph, point_count, point_array);
-}
-
-hb_bool_t
-hb_ot_layout_get_lig_carets (hb_face_t *face,
- hb_font_t *font,
- hb_codepoint_t glyph,
- unsigned int *caret_count /* IN/OUT */,
- int *caret_array /* OUT */)
-{
- hb_ot_layout_context_t context;
- context.font = font;
- context.face = face;
- return _get_gdef (face).get_lig_carets (&context, glyph, caret_count, caret_array);
-}
-
-/*
- * GSUB/GPOS
- */
-
-static const GSUBGPOS&
-get_gsubgpos_table (hb_face_t *face,
- hb_tag_t table_tag)
-{
- switch (table_tag) {
- case HB_OT_TAG_GSUB: return _get_gsub (face);
- case HB_OT_TAG_GPOS: return _get_gpos (face);
- default: return Null(GSUBGPOS);
- }
-}
-
-
-hb_bool_t
-hb_ot_layout_table_get_script_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int *script_count /* IN/OUT */,
- hb_tag_t *script_tags /* OUT */)
-{
- const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
-
- return g.get_script_tags (script_count, script_tags);
-}
-
-hb_bool_t
-hb_ot_layout_table_find_script (hb_face_t *face,
- hb_tag_t table_tag,
- hb_tag_t script_tag,
- unsigned int *script_index)
-{
- ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX);
- const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
-
- if (g.find_script_index (script_tag, script_index))
- return TRUE;
-
- /* try finding 'DFLT' */
- if (g.find_script_index (HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT, script_index))
- return FALSE;
-
- /* try with 'dflt'; MS site has had typos and many fonts use it now :( */
- if (g.find_script_index (HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE, script_index))
- return FALSE;
-
- if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX;
- return FALSE;
-}
-
-hb_bool_t
-hb_ot_layout_table_get_feature_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int *feature_count /* IN/OUT */,
- hb_tag_t *feature_tags /* OUT */)
-{
- const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
-
- return g.get_feature_tags (feature_count, feature_tags);
-}
-
-
-hb_bool_t
-hb_ot_layout_script_get_language_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int *language_count /* IN/OUT */,
- hb_tag_t *language_tags /* OUT */)
-{
- const Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
-
- return s.get_lang_sys_tags (language_count, language_tags);
-}
-
-hb_bool_t
-hb_ot_layout_script_find_language (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- hb_tag_t language_tag,
- unsigned int *language_index)
-{
- ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX);
- const Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
-
- if (s.find_lang_sys_index (language_tag, language_index))
- return TRUE;
-
- /* try with 'dflt'; MS site has had typos and many fonts use it now :( */
- if (s.find_lang_sys_index (HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE, language_index))
- return FALSE;
-
- if (language_index) *language_index = HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX;
- return FALSE;
-}
-
-hb_bool_t
-hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- unsigned int *feature_index)
-{
- const LangSys &l = get_gsubgpos_table (face, table_tag).get_script (script_index).get_lang_sys (language_index);
-
- if (feature_index) *feature_index = l.get_required_feature_index ();
-
- return l.has_required_feature ();
-}
-
-hb_bool_t
-hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- unsigned int *feature_count /* IN/OUT */,
- unsigned int *feature_indexes /* OUT */)
-{
- const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
- const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
-
- return l.get_feature_indexes (feature_count, feature_indexes);
-}
-
-hb_bool_t
-hb_ot_layout_language_get_feature_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- unsigned int *feature_count /* IN/OUT */,
- hb_tag_t *feature_tags /* OUT */)
-{
- const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
- const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
-
- ASSERT_STATIC (sizeof (unsigned int) == sizeof (hb_tag_t));
- hb_bool_t ret = l.get_feature_indexes (feature_count, (unsigned int *) feature_tags);
-
- if (feature_tags) {
- unsigned int count = *feature_count;
- for (unsigned int i = 0; i < count; i++)
- feature_tags[i] = g.get_feature_tag ((unsigned int) feature_tags[i]);
- }
-
- return ret;
-}
-
-
-hb_bool_t
-hb_ot_layout_language_find_feature (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- hb_tag_t feature_tag,
- unsigned int *feature_index)
-{
- ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX);
- const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
- const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
-
- unsigned int num_features = l.get_feature_count ();
- for (unsigned int i = 0; i < num_features; i++) {
- unsigned int f_index = l.get_feature_index (i);
-
- if (feature_tag == g.get_feature_tag (f_index)) {
- if (feature_index) *feature_index = f_index;
- return TRUE;
- }
- }
-
- if (feature_index) *feature_index = HB_OT_LAYOUT_NO_FEATURE_INDEX;
- return FALSE;
-}
-
-hb_bool_t
-hb_ot_layout_feature_get_lookup_indexes (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int feature_index,
- unsigned int *lookup_count /* IN/OUT */,
- unsigned int *lookup_indexes /* OUT */)
-{
- const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
- const Feature &f = g.get_feature (feature_index);
-
- return f.get_lookup_indexes (lookup_count, lookup_indexes);
-}
-
-
-/*
- * GSUB
- */
-
-hb_bool_t
-hb_ot_layout_has_substitution (hb_face_t *face)
-{
- return &_get_gsub (face) != &Null(GSUB);
-}
-
-hb_bool_t
-hb_ot_layout_substitute_lookup (hb_face_t *face,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask)
-{
- hb_ot_layout_context_t context;
- context.font = NULL;
- context.face = face;
- return _get_gsub (face).substitute_lookup (&context, buffer, lookup_index, mask);
-}
-
-
-/*
- * GPOS
- */
-
-hb_bool_t
-hb_ot_layout_has_positioning (hb_face_t *face)
-{
- return &_get_gpos (face) != &Null(GPOS);
-}
-
-hb_bool_t
-hb_ot_layout_position_lookup (hb_face_t *face,
- hb_font_t *font,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask)
-{
- hb_ot_layout_context_t context;
- context.font = font;
- context.face = face;
- return _get_gpos (face).position_lookup (&context, buffer, lookup_index, mask);
-}
diff --git a/pango/opentype/hb-ot-layout.h b/pango/opentype/hb-ot-layout.h
deleted file mode 100644
index ee615ca9..00000000
--- a/pango/opentype/hb-ot-layout.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_LAYOUT_H
-#define HB_OT_LAYOUT_H
-
-#include "hb-common.h"
-#include "hb-buffer.h"
-#include "hb-font.h"
-
-HB_BEGIN_DECLS
-
-#define HB_OT_TAG_GDEF HB_TAG('G','D','E','F')
-#define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
-#define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')
-
-/*
- * GDEF
- */
-
-typedef enum {
- HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0000,
- HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 0x0002,
- HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 0x0004,
- HB_OT_LAYOUT_GLYPH_CLASS_MARK = 0x0008,
- HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 0x0010
-} hb_ot_layout_glyph_class_t;
-
-/* XXX These should eventually be removed as we move synthesized glyph
- * classes in harfbuzz. */
-
-hb_bool_t
-hb_ot_layout_has_font_glyph_classes (hb_face_t *face);
-
-hb_ot_layout_glyph_class_t
-hb_ot_layout_get_glyph_class (hb_face_t *face,
- hb_codepoint_t glyph);
-
-void
-hb_ot_layout_set_glyph_class (hb_face_t *face,
- hb_codepoint_t glyph,
- hb_ot_layout_glyph_class_t klass);
-
-void
-hb_ot_layout_build_glyph_classes (hb_face_t *face,
- hb_codepoint_t *glyphs,
- unsigned char *klasses,
- uint16_t count);
-
-/* Not that useful. Provides list of attach points for a glyph that a
- * client may want to cache */
-hb_bool_t
-hb_ot_layout_get_attach_points (hb_face_t *face,
- hb_codepoint_t glyph,
- unsigned int *point_count /* IN/OUT */,
- unsigned int *point_array /* OUT */);
-
-/* Ligature caret positions */
-hb_bool_t
-hb_ot_layout_get_lig_carets (hb_face_t *face,
- hb_font_t *font,
- hb_codepoint_t glyph,
- unsigned int *caret_count /* IN/OUT */,
- int *caret_array /* OUT */);
-
-
-/*
- * GSUB/GPOS feature query and enumeration interface
- */
-
-#define HB_OT_LAYOUT_NO_SCRIPT_INDEX ((unsigned int) 0xFFFF)
-#define HB_OT_LAYOUT_NO_FEATURE_INDEX ((unsigned int) 0xFFFF)
-#define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX ((unsigned int) 0xFFFF)
-#define HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
-#define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
-
-hb_bool_t
-hb_ot_layout_table_get_script_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int *script_count /* IN/OUT */,
- hb_tag_t *script_tags /* OUT */);
-
-hb_bool_t
-hb_ot_layout_table_find_script (hb_face_t *face,
- hb_tag_t table_tag,
- hb_tag_t script_tag,
- unsigned int *script_index);
-
-hb_bool_t
-hb_ot_layout_table_get_feature_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int *feature_count /* IN/OUT */,
- hb_tag_t *feature_tags /* OUT */);
-
-hb_bool_t
-hb_ot_layout_script_get_language_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int *language_count /* IN/OUT */,
- hb_tag_t *language_tags /* OUT */);
-
-hb_bool_t
-hb_ot_layout_script_find_language (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- hb_tag_t language_tag,
- unsigned int *language_index);
-
-hb_bool_t
-hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- unsigned int *feature_index);
-
-hb_bool_t
-hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- unsigned int *feature_count /* IN/OUT */,
- unsigned int *feature_indexes /* OUT */);
-
-hb_bool_t
-hb_ot_layout_language_get_feature_tags (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- unsigned int *feature_count /* IN/OUT */,
- hb_tag_t *feature_tags /* OUT */);
-
-hb_bool_t
-hb_ot_layout_language_find_feature (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int script_index,
- unsigned int language_index,
- hb_tag_t feature_tag,
- unsigned int *feature_index);
-
-hb_bool_t
-hb_ot_layout_feature_get_lookup_indexes (hb_face_t *face,
- hb_tag_t table_tag,
- unsigned int feature_index,
- unsigned int *lookup_count /* IN/OUT */,
- unsigned int *lookup_indexes /* OUT */);
-
-
-/*
- * GSUB
- */
-
-hb_bool_t
-hb_ot_layout_has_substitution (hb_face_t *face);
-
-hb_bool_t
-hb_ot_layout_substitute_lookup (hb_face_t *face,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask);
-
-/*
- * GPOS
- */
-
-hb_bool_t
-hb_ot_layout_has_positioning (hb_face_t *face);
-
-hb_bool_t
-hb_ot_layout_position_lookup (hb_face_t *face,
- hb_font_t *font,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask);
-
-
-HB_END_DECLS
-
-#endif /* HB_OT_LAYOUT_H */
diff --git a/pango/opentype/hb-ot.h b/pango/opentype/hb-ot.h
deleted file mode 100644
index c04216b8..00000000
--- a/pango/opentype/hb-ot.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_OT_H
-#define HB_OT_H
-
-#include "hb.h"
-
-#include "hb-ot-layout.h"
-
-#endif /* HB_OT_H */
diff --git a/pango/opentype/hb-private.h b/pango/opentype/hb-private.h
deleted file mode 100644
index 92e514f7..00000000
--- a/pango/opentype/hb-private.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_PRIVATE_H
-#define HB_PRIVATE_H
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* #define HB_DEBUG 1 */
-#ifndef HB_DEBUG
-#define HB_DEBUG 0
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#if HB_DEBUG
-#include <stdio.h>
-#include <errno.h>
-#endif
-
-#include "hb-common.h"
-
-#define hb_be_uint8
-#define hb_be_int8
-#define hb_be_uint16(v) ((uint16_t) hb_be_int16 ((uint16_t) v))
-#define hb_be_uint32(v) ((uint32_t) hb_be_int32 ((uint32_t) v))
-
-/* We need external help for these */
-
-#if HAVE_GLIB
-
-#include <glib.h>
-
-/* Macros to convert to/from BigEndian */
-#define hb_be_int16(v) GINT16_FROM_BE (v)
-#define hb_be_int32(v) GINT32_FROM_BE (v)
-
-typedef int hb_atomic_int_t;
-#define hb_atomic_int_fetch_and_add(AI, V) g_atomic_int_exchange_and_add (&(AI), V)
-#define hb_atomic_int_get(AI) g_atomic_int_get (&(AI))
-#define hb_atomic_int_set(AI, V) g_atomic_int_set (&(AI), V)
-
-typedef GStaticMutex hb_mutex_t;
-#define HB_MUTEX_INIT G_STATIC_MUTEX_INIT
-#define hb_mutex_init(M) g_static_mutex_init (&M)
-#define hb_mutex_lock(M) g_static_mutex_lock (&M)
-#define hb_mutex_trylock(M) g_static_mutex_trylock (&M)
-#define hb_mutex_unlock(M) g_static_mutex_unlock (&M)
-
-#else
-#error "Could not find any system to define platform macros, see hb-private.h"
-#endif
-
-
-#define hb_be_uint8_put_unaligned(v,V) (v[0] = (V), 0)
-#define hb_be_uint8_get_unaligned(v) (uint8_t) (v[0])
-#define hb_be_uint8_cmp_unaligned(a,b) (a[0] == b[0])
-#define hb_be_int8_put_unaligned hb_be_uint8_put_unaligned
-#define hb_be_int8_get_unaligned (int8_t) hb_be_uint8_get_unaligned
-#define hb_be_int8_cmp_unaligned hb_be_uint8_cmp_unaligned
-
-#define hb_be_uint16_put_unaligned(v,V) (v[0] = (V>>8), v[1] = (V), 0)
-#define hb_be_uint16_get_unaligned(v) (uint16_t) ((v[0] << 8) + v[1])
-#define hb_be_uint16_cmp_unaligned(a,b) (a[0] == b[0] && a[1] == b[1])
-#define hb_be_int16_put_unaligned hb_be_uint16_put_unaligned
-#define hb_be_int16_get_unaligned (int16_t) hb_be_uint16_get_unaligned
-#define hb_be_int16_cmp_unaligned hb_be_uint16_cmp_unaligned
-
-#define hb_be_uint32_put_unaligned(v,V) (v[0] = (V>>24), v[1] = (V>>16), v[2] = (V>>8), v[3] = (V), 0)
-#define hb_be_uint32_get_unaligned(v) (uint32_t) ((v[0] << 24) + (v[1] << 16) + (v[2] << 8) + v[3])
-#define hb_be_uint32_cmp_unaligned(a,b) (a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3])
-#define hb_be_int32_put_unaligned hb_be_uint32_put_unaligned
-#define hb_be_int32_get_unaligned (int32_t) hb_be_uint32_get_unaligned
-#define hb_be_int32_cmp_unaligned hb_be_uint32_cmp_unaligned
-
-
-/* Basics */
-
-#undef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-
-#ifndef HB_INTERNAL
-# define HB_INTERNAL extern
-#endif
-
-#ifndef NULL
-# define NULL ((void *)0)
-#endif
-
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-
-#define HB_STMT_START do
-#define HB_STMT_END while (0)
-
-#define _ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
-#define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond))
-#define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
-
-#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size))
-
-#define VAR 1 /* Size signifying variable-sized array */
-#define ASSERT_SIZE_VAR(_type, _size, _var_type) \
- ASSERT_STATIC (sizeof (_type) == (_size) + VAR * sizeof (_var_type))
-#define ASSERT_SIZE_VAR2(_type, _size, _var_type1, _var_type2) \
- ASSERT_STATIC (sizeof (_type) == (_size) + VAR * sizeof (_var_type1) + VAR * sizeof (_var_type2))
-
-#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
-#define _HB_BOOLEAN_EXPR(expr) \
- __extension__ ({ \
- int _cairo_boolean_var_; \
- if (expr) \
- _cairo_boolean_var_ = 1; \
- else \
- _cairo_boolean_var_ = 0; \
- _cairo_boolean_var_; \
-})
-#define HB_LIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1))
-#define HB_UNLIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))
-#else
-#define HB_LIKELY(expr) (expr)
-#define HB_UNLIKELY(expr) (expr)
-#endif
-
-#ifndef __GNUC__
-#undef __attribute__
-#define __attribute__(x)
-#endif
-
-#if __GNUC__ >= 4
-#define HB_GNUC_UNUSED __attribute__((unused))
-#define HB_GNUC_PURE __attribute__((pure))
-#define HB_GNUC_CONST __attribute__((const))
-#else
-#define HB_GNUC_UNUSED
-#define HB_GNUC_PURE
-#define HB_GNUC_CONST
-#endif
-
-
-#if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER)
-#define snprintf _snprintf
-#endif
-
-#ifdef _MSC_VER
-#undef inline
-#define inline __inline
-#endif
-
-#ifdef __STRICT_ANSI__
-#undef inline
-#define inline __inline__
-#endif
-
-
-/* Return the number of 1 bits in mask.
- *
- * GCC 3.4 supports a "population count" builtin, which on many targets is
- * implemented with a single instruction. There is a fallback definition
- * in libgcc in case a target does not have one, which should be just as
- * good as the open-coded solution below, (which is "HACKMEM 169").
- */
-static HB_GNUC_UNUSED inline unsigned int
-_hb_popcount32 (uint32_t mask)
-{
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
- return __builtin_popcount (mask);
-#else
- register uint32_t y;
-
- y = (mask >> 1) &033333333333;
- y = mask - y - ((y >>1) & 033333333333);
- return (((y + (y >> 3)) & 030707070707) % 077);
-#endif
-}
-
-
-/* Multiplies a 16dot16 value by another value, then truncates the result */
-#define _hb_16dot16_mul_round(A,B) (((int64_t) (A) * (B) + 0x8000) / 0x10000)
-
-#include "hb-object-private.h"
-
-#endif /* HB_PRIVATE_H */
diff --git a/pango/opentype/hb-shape.c b/pango/opentype/hb-shape.c
deleted file mode 100644
index 55e21507..00000000
--- a/pango/opentype/hb-shape.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#include "hb-private.h"
-
-#include "hb-shape.h"
-
-
-void
-hb_shape (hb_face_t *face,
- hb_font_t *font,
- hb_buffer_t *buffer,
- hb_feature_t *features,
- unsigned int num_features)
-{
-}
-
diff --git a/pango/opentype/hb-shape.h b/pango/opentype/hb-shape.h
deleted file mode 100644
index be205929..00000000
--- a/pango/opentype/hb-shape.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_SHAPE_H
-#define HB_SHAPE_H
-
-#include "hb-common.h"
-#include "hb-buffer.h"
-#include "hb-font.h"
-
-HB_BEGIN_DECLS
-
-typedef struct _hb_feature_t {
- const char *name;
- const char *value;
- unsigned int start;
- unsigned int end;
-} hb_feature_t;
-
-void
-hb_shape (hb_face_t *face,
- hb_font_t *font,
- hb_buffer_t *buffer,
- hb_feature_t *features,
- unsigned int num_features);
-
-
-HB_END_DECLS
-
-#endif /* HB_SHAPE_H */
diff --git a/pango/opentype/hb-unicode-private.h b/pango/opentype/hb-unicode-private.h
deleted file mode 100644
index 88802455..00000000
--- a/pango/opentype/hb-unicode-private.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_UNICODE_PRIVATE_H
-#define HB_UNICODE_PRIVATE_H
-
-#include "hb-private.h"
-
-#include "hb-unicode.h"
-
-HB_BEGIN_DECLS
-
-/*
- * hb_unicode_funcs_t
- */
-
-struct _hb_unicode_funcs_t {
- hb_reference_count_t ref_count;
-
- hb_bool_t immutable;
-
- hb_unicode_get_general_category_func_t get_general_category;
- hb_unicode_get_combining_class_func_t get_combining_class;
- hb_unicode_get_mirroring_func_t get_mirroring;
- hb_unicode_get_script_func_t get_script;
- hb_unicode_get_eastasian_width_func_t get_eastasian_width;
-};
-
-HB_INTERNAL hb_unicode_funcs_t
-_hb_unicode_funcs_nil;
-
-HB_END_DECLS
-
-#endif /* HB_UNICODE_PRIVATE_H */
diff --git a/pango/opentype/hb-unicode.c b/pango/opentype/hb-unicode.c
deleted file mode 100644
index 01b54f58..00000000
--- a/pango/opentype/hb-unicode.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#include "hb-private.h"
-
-#include "hb-unicode-private.h"
-
-/*
- * hb_unicode_funcs_t
- */
-
-static hb_codepoint_t hb_unicode_get_mirroring_nil (hb_codepoint_t unicode) { return unicode; }
-static hb_category_t hb_unicode_get_general_category_nil (hb_codepoint_t unicode) { return HB_CATEGORY_OTHER_LETTER; }
-static hb_script_t hb_unicode_get_script_nil (hb_codepoint_t unicode) { return HB_SCRIPT_UNKNOWN; }
-static unsigned int hb_unicode_get_combining_class_nil (hb_codepoint_t unicode) { return 0; }
-static unsigned int hb_unicode_get_eastasian_width_nil (hb_codepoint_t unicode) { return 1; }
-
-hb_unicode_funcs_t _hb_unicode_funcs_nil = {
- HB_REFERENCE_COUNT_INVALID, /* ref_count */
-
- TRUE, /* immutable */
-
- hb_unicode_get_general_category_nil,
- hb_unicode_get_combining_class_nil,
- hb_unicode_get_mirroring_nil,
- hb_unicode_get_script_nil,
- hb_unicode_get_eastasian_width_nil
-};
-
-hb_unicode_funcs_t *
-hb_unicode_funcs_create (void)
-{
- hb_unicode_funcs_t *ufuncs;
-
- if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
- return &_hb_unicode_funcs_nil;
-
- *ufuncs = _hb_unicode_funcs_nil;
- HB_OBJECT_DO_INIT (ufuncs);
-
- return ufuncs;
-}
-
-hb_unicode_funcs_t *
-hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs)
-{
- HB_OBJECT_DO_REFERENCE (ufuncs);
-}
-
-unsigned int
-hb_unicode_funcs_get_reference_count (hb_unicode_funcs_t *ufuncs)
-{
- HB_OBJECT_DO_GET_REFERENCE_COUNT (ufuncs);
-}
-
-void
-hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
-{
- HB_OBJECT_DO_DESTROY (ufuncs);
-
- free (ufuncs);
-}
-
-hb_unicode_funcs_t *
-hb_unicode_funcs_copy (hb_unicode_funcs_t *other_ufuncs)
-{
- hb_unicode_funcs_t *ufuncs;
-
- if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
- return &_hb_unicode_funcs_nil;
-
- *ufuncs = *other_ufuncs;
- HB_OBJECT_DO_INIT (ufuncs);
- ufuncs->immutable = FALSE;
-
- return ufuncs;
-}
-
-void
-hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
-{
- if (HB_OBJECT_IS_INERT (ufuncs))
- return;
-
- ufuncs->immutable = TRUE;
-}
-
-
-void
-hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_mirroring_func_t mirroring_func)
-{
- if (ufuncs->immutable)
- return;
-
- ufuncs->get_mirroring = mirroring_func ? mirroring_func : hb_unicode_get_mirroring_nil;
-}
-
-void
-hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_general_category_func_t general_category_func)
-{
- if (ufuncs->immutable)
- return;
-
- ufuncs->get_general_category = general_category_func ? general_category_func : hb_unicode_get_general_category_nil;
-}
-
-void
-hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_script_func_t script_func)
-{
- if (ufuncs->immutable)
- return;
-
- ufuncs->get_script = script_func ? script_func : hb_unicode_get_script_nil;
-}
-
-void
-hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_combining_class_func_t combining_class_func)
-{
- if (ufuncs->immutable)
- return;
-
- ufuncs->get_combining_class = combining_class_func ? combining_class_func : hb_unicode_get_combining_class_nil;
-}
-
-void
-hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_eastasian_width_func_t eastasian_width_func)
-{
- if (ufuncs->immutable)
- return;
-
- ufuncs->get_eastasian_width = eastasian_width_func ? eastasian_width_func : hb_unicode_get_eastasian_width_nil;
-}
-
diff --git a/pango/opentype/hb-unicode.h b/pango/opentype/hb-unicode.h
deleted file mode 100644
index 59f198db..00000000
--- a/pango/opentype/hb-unicode.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_UNICODE_H
-#define HB_UNICODE_H
-
-#include "hb-common.h"
-
-HB_BEGIN_DECLS
-
-/* Unicode General Category property */
-typedef enum
-{
- HB_CATEGORY_CONTROL,
- HB_CATEGORY_FORMAT,
- HB_CATEGORY_UNASSIGNED,
- HB_CATEGORY_PRIVATE_USE,
- HB_CATEGORY_SURROGATE,
- HB_CATEGORY_LOWERCASE_LETTER,
- HB_CATEGORY_MODIFIER_LETTER,
- HB_CATEGORY_OTHER_LETTER,
- HB_CATEGORY_TITLECASE_LETTER,
- HB_CATEGORY_UPPERCASE_LETTER,
- HB_CATEGORY_COMBINING_MARK,
- HB_CATEGORY_ENCLOSING_MARK,
- HB_CATEGORY_NON_SPACING_MARK,
- HB_CATEGORY_DECIMAL_NUMBER,
- HB_CATEGORY_LETTER_NUMBER,
- HB_CATEGORY_OTHER_NUMBER,
- HB_CATEGORY_CONNECT_PUNCTUATION,
- HB_CATEGORY_DASH_PUNCTUATION,
- HB_CATEGORY_CLOSE_PUNCTUATION,
- HB_CATEGORY_FINAL_PUNCTUATION,
- HB_CATEGORY_INITIAL_PUNCTUATION,
- HB_CATEGORY_OTHER_PUNCTUATION,
- HB_CATEGORY_OPEN_PUNCTUATION,
- HB_CATEGORY_CURRENCY_SYMBOL,
- HB_CATEGORY_MODIFIER_SYMBOL,
- HB_CATEGORY_MATH_SYMBOL,
- HB_CATEGORY_OTHER_SYMBOL,
- HB_CATEGORY_LINE_SEPARATOR,
- HB_CATEGORY_PARAGRAPH_SEPARATOR,
- HB_CATEGORY_SPACE_SEPARATOR
-} hb_category_t;
-
-/* Unicode Script property */
-typedef enum
-{ /* ISO 15924 code */
- HB_SCRIPT_INVALID_CODE = -1,
- HB_SCRIPT_COMMON = 0, /* Zyyy */
- HB_SCRIPT_INHERITED, /* Qaai */
- HB_SCRIPT_ARABIC, /* Arab */
- HB_SCRIPT_ARMENIAN, /* Armn */
- HB_SCRIPT_BENGALI, /* Beng */
- HB_SCRIPT_BOPOMOFO, /* Bopo */
- HB_SCRIPT_CHEROKEE, /* Cher */
- HB_SCRIPT_COPTIC, /* Qaac */
- HB_SCRIPT_CYRILLIC, /* Cyrl (Cyrs) */
- HB_SCRIPT_DESERET, /* Dsrt */
- HB_SCRIPT_DEVANAGARI, /* Deva */
- HB_SCRIPT_ETHIOPIC, /* Ethi */
- HB_SCRIPT_GEORGIAN, /* Geor (Geon, Geoa) */
- HB_SCRIPT_GOTHIC, /* Goth */
- HB_SCRIPT_GREEK, /* Grek */
- HB_SCRIPT_GUJARATI, /* Gujr */
- HB_SCRIPT_GURMUKHI, /* Guru */
- HB_SCRIPT_HAN, /* Hani */
- HB_SCRIPT_HANGUL, /* Hang */
- HB_SCRIPT_HEBREW, /* Hebr */
- HB_SCRIPT_HIRAGANA, /* Hira */
- HB_SCRIPT_KANNADA, /* Knda */
- HB_SCRIPT_KATAKANA, /* Kana */
- HB_SCRIPT_KHMER, /* Khmr */
- HB_SCRIPT_LAO, /* Laoo */
- HB_SCRIPT_LATIN, /* Latn (Latf, Latg) */
- HB_SCRIPT_MALAYALAM, /* Mlym */
- HB_SCRIPT_MONGOLIAN, /* Mong */
- HB_SCRIPT_MYANMAR, /* Mymr */
- HB_SCRIPT_OGHAM, /* Ogam */
- HB_SCRIPT_OLD_ITALIC, /* Ital */
- HB_SCRIPT_ORIYA, /* Orya */
- HB_SCRIPT_RUNIC, /* Runr */
- HB_SCRIPT_SINHALA, /* Sinh */
- HB_SCRIPT_SYRIAC, /* Syrc (Syrj, Syrn, Syre) */
- HB_SCRIPT_TAMIL, /* Taml */
- HB_SCRIPT_TELUGU, /* Telu */
- HB_SCRIPT_THAANA, /* Thaa */
- HB_SCRIPT_THAI, /* Thai */
- HB_SCRIPT_TIBETAN, /* Tibt */
- HB_SCRIPT_CANADIAN_ABORIGINAL, /* Cans */
- HB_SCRIPT_YI, /* Yiii */
- HB_SCRIPT_TAGALOG, /* Tglg */
- HB_SCRIPT_HANUNOO, /* Hano */
- HB_SCRIPT_BUHID, /* Buhd */
- HB_SCRIPT_TAGBANWA, /* Tagb */
-
- /* Unicode-4.0 additions */
- HB_SCRIPT_BRAILLE, /* Brai */
- HB_SCRIPT_CYPRIOT, /* Cprt */
- HB_SCRIPT_LIMBU, /* Limb */
- HB_SCRIPT_OSMANYA, /* Osma */
- HB_SCRIPT_SHAVIAN, /* Shaw */
- HB_SCRIPT_LINEAR_B, /* Linb */
- HB_SCRIPT_TAI_LE, /* Tale */
- HB_SCRIPT_UGARITIC, /* Ugar */
-
- /* Unicode-4.1 additions */
- HB_SCRIPT_NEW_TAI_LUE, /* Talu */
- HB_SCRIPT_BUGINESE, /* Bugi */
- HB_SCRIPT_GLAGOLITIC, /* Glag */
- HB_SCRIPT_TIFINAGH, /* Tfng */
- HB_SCRIPT_SYLOTI_NAGRI, /* Sylo */
- HB_SCRIPT_OLD_PERSIAN, /* Xpeo */
- HB_SCRIPT_KHAROSHTHI, /* Khar */
-
- /* Unicode-5.0 additions */
- HB_SCRIPT_UNKNOWN, /* Zzzz */
- HB_SCRIPT_BALINESE, /* Bali */
- HB_SCRIPT_CUNEIFORM, /* Xsux */
- HB_SCRIPT_PHOENICIAN, /* Phnx */
- HB_SCRIPT_PHAGS_PA, /* Phag */
- HB_SCRIPT_NKO, /* Nkoo */
-
- /* Unicode-5.1 additions */
- HB_SCRIPT_KAYAH_LI, /* Kali */
- HB_SCRIPT_LEPCHA, /* Lepc */
- HB_SCRIPT_REJANG, /* Rjng */
- HB_SCRIPT_SUNDANESE, /* Sund */
- HB_SCRIPT_SAURASHTRA, /* Saur */
- HB_SCRIPT_CHAM, /* Cham */
- HB_SCRIPT_OL_CHIKI, /* Olck */
- HB_SCRIPT_VAI, /* Vaii */
- HB_SCRIPT_CARIAN, /* Cari */
- HB_SCRIPT_LYCIAN, /* Lyci */
- HB_SCRIPT_LYDIAN /* Lydi */
-} hb_script_t;
-
-
-/*
- * hb_unicode_funcs_t
- */
-
-typedef struct _hb_unicode_funcs_t hb_unicode_funcs_t;
-
-hb_unicode_funcs_t *
-hb_unicode_funcs_create (void);
-
-hb_unicode_funcs_t *
-hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs);
-
-unsigned int
-hb_unicode_funcs_get_reference_count (hb_unicode_funcs_t *ufuncs);
-
-void
-hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs);
-
-hb_unicode_funcs_t *
-hb_unicode_funcs_copy (hb_unicode_funcs_t *ufuncs);
-
-void
-hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs);
-
-
-/* funcs */
-
-typedef hb_codepoint_t (*hb_unicode_get_mirroring_func_t) (hb_codepoint_t unicode);
-typedef hb_category_t (*hb_unicode_get_general_category_func_t) (hb_codepoint_t unicode);
-typedef hb_script_t (*hb_unicode_get_script_func_t) (hb_codepoint_t unicode);
-typedef unsigned int (*hb_unicode_get_combining_class_func_t) (hb_codepoint_t unicode);
-typedef unsigned int (*hb_unicode_get_eastasian_width_func_t) (hb_codepoint_t unicode);
-
-
-void
-hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_mirroring_func_t mirroring_func);
-
-void
-hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_general_category_func_t general_category_func);
-
-void
-hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_script_func_t script_func);
-
-void
-hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_combining_class_func_t combining_class_func);
-
-void
-hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_eastasian_width_func_t eastasian_width_func);
-
-
-HB_END_DECLS
-
-#endif /* HB_FONT_H */
diff --git a/pango/opentype/hb.h b/pango/opentype/hb.h
deleted file mode 100644
index a948e134..00000000
--- a/pango/opentype/hb.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#ifndef HB_H
-#define HB_H
-
-#include "hb-common.h"
-#include "hb-blob.h"
-#include "hb-buffer.h"
-#include "hb-font.h"
-
-#endif /* HB_H */
diff --git a/pango/opentype/main.cc b/pango/opentype/main.cc
deleted file mode 100644
index 31264a47..00000000
--- a/pango/opentype/main.cc
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
- *
- * This is part of HarfBuzz, an OpenType Layout engine library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Red Hat Author(s): Behdad Esfahbod
- */
-
-#define HB_OT_LAYOUT_CC
-#include "hb-open-file-private.hh"
-#include "hb-ot-layout-gdef-private.hh"
-#include "hb-ot-layout-gsubgpos-private.hh"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-int
-main (int argc, char **argv)
-{
- if (argc != 2) {
- fprintf (stderr, "usage: %s font-file.ttf\n", argv[0]);
- exit (1);
- }
-
- GMappedFile *mf = g_mapped_file_new (argv[1], FALSE, NULL);
- const char *font_data = g_mapped_file_get_contents (mf);
- int len = g_mapped_file_get_length (mf);
-
- printf ("Opened font file %s: %d bytes long\n", argv[1], len);
-
- const OpenTypeFontFile &ot = OpenTypeFontFile::get_for_data (font_data);
-
- switch (ot.tag) {
- case OpenTypeFontFile::TrueTypeTag:
- printf ("OpenType font with TrueType outlines\n");
- break;
- case OpenTypeFontFile::CFFTag:
- printf ("OpenType font with CFF (Type1) outlines\n");
- break;
- case OpenTypeFontFile::TTCTag:
- printf ("TrueType Collection of OpenType fonts\n");
- break;
- default:
- printf ("Unknown font format\n");
- break;
- }
-
- int num_fonts = ot.get_face_count ();
- printf ("%d font(s) found in file\n", num_fonts);
- for (int n_font = 0; n_font < num_fonts; n_font++) {
- const OpenTypeFontFace &font = ot.get_face (n_font);
- printf ("Font %d of %d:\n", n_font, num_fonts);
-
- int num_tables = font.get_table_count ();
- printf (" %d table(s) found in font\n", num_tables);
- for (int n_table = 0; n_table < num_tables; n_table++) {
- const OpenTypeTable &table = font.get_table (n_table);
- printf (" Table %2d of %2d: %.4s (0x%08x+0x%08x)\n", n_table, num_tables,
- (const char *)table.tag,
- (unsigned int) table.offset,
- (unsigned int) table.length);
-
- switch (table.tag) {
-
- case GSUBGPOS::GSUBTag:
- case GSUBGPOS::GPOSTag:
- {
-
- const GSUBGPOS &g = GSUBGPOS::get_for_data (ot.get_table_data (table));
-
- int num_scripts = g.get_script_count ();
- printf (" %d script(s) found in table\n", num_scripts);
- for (int n_script = 0; n_script < num_scripts; n_script++) {
- const Script &script = g.get_script (n_script);
- printf (" Script %2d of %2d: %.4s\n", n_script, num_scripts,
- (const char *)g.get_script_tag(n_script));
-
- if (!script.has_default_lang_sys())
- printf (" No default language system\n");
- int num_langsys = script.get_lang_sys_count ();
- printf (" %d language system(s) found in script\n", num_langsys);
- for (int n_langsys = script.has_default_lang_sys() ? -1 : 0; n_langsys < num_langsys; n_langsys++) {
- const LangSys &langsys = n_langsys == -1
- ? script.get_default_lang_sys ()
- : script.get_lang_sys (n_langsys);
- printf (n_langsys == -1
- ? " Default Language System\n"
- : " Language System %2d of %2d: %.4s\n", n_langsys, num_langsys,
- (const char *)script.get_lang_sys_tag (n_langsys));
- if (langsys.get_required_feature_index () == NO_INDEX)
- printf (" No required feature\n");
-
- int num_features = langsys.get_feature_count ();
- printf (" %d feature(s) found in language system\n", num_features);
- for (int n_feature = 0; n_feature < num_features; n_feature++) {
- printf (" Feature index %2d of %2d: %d\n", n_feature, num_features,
- langsys.get_feature_index (n_feature));
- }
- }
- }
-
- int num_features = g.get_feature_count ();
- printf (" %d feature(s) found in table\n", num_features);
- for (int n_feature = 0; n_feature < num_features; n_feature++) {
- const Feature &feature = g.get_feature (n_feature);
- printf (" Feature %2d of %2d: %.4s; %d lookup(s)\n", n_feature, num_features,
- (const char *)g.get_feature_tag(n_feature),
- feature.get_lookup_count());
-
- int num_lookups = feature.get_lookup_count ();
- printf (" %d lookup(s) found in feature\n", num_lookups);
- for (int n_lookup = 0; n_lookup < num_lookups; n_lookup++) {
- printf (" Lookup index %2d of %2d: %d\n", n_lookup, num_lookups,
- feature.get_lookup_index (n_lookup));
- }
- }
-
- int num_lookups = g.get_lookup_count ();
- printf (" %d lookup(s) found in table\n", num_lookups);
- for (int n_lookup = 0; n_lookup < num_lookups; n_lookup++) {
- const Lookup &lookup = g.get_lookup (n_lookup);
- printf (" Lookup %2d of %2d: type %d, flags 0x%04X\n", n_lookup, num_lookups,
- lookup.get_type(), lookup.get_flag());
- }
-
- }
- break;
-
- case GDEF::Tag:
- {
-
- const GDEF &gdef = GDEF::get_for_data (ot.get_table_data (table));
-
- printf (" Has %sglyph classes\n",
- gdef.has_glyph_classes () ? "" : "no ");
- printf (" Has %smark attachment types\n",
- gdef.has_mark_attachment_types () ? "" : "no ");
- printf (" Has %sattach points\n",
- gdef.has_attach_points () ? "" : "no ");
- printf (" Has %slig carets\n",
- gdef.has_lig_carets () ? "" : "no ");
- printf (" Has %smark sets\n",
- gdef.has_mark_sets () ? "" : "no ");
- break;
- }
- }
- }
- }
-
- return 0;
-}
diff --git a/pango/pango-ot-buffer.c b/pango/pango-ot-buffer.c
index f5a68512..100e6465 100644
--- a/pango/pango-ot-buffer.c
+++ b/pango/pango-ot-buffer.c
@@ -30,6 +30,17 @@ static hb_buffer_t *cached_buffer = NULL;
G_LOCK_DEFINE_STATIC (cached_buffer);
static hb_buffer_t *
+create_buffer (void)
+{
+ hb_buffer_t *buffer;
+
+ buffer = hb_buffer_create (32);
+ hb_buffer_set_unicode_funcs (buffer, hb_glib_get_unicode_funcs ());
+
+ return buffer;
+}
+
+static hb_buffer_t *
acquire_buffer (gboolean *free_buffer)
{
hb_buffer_t *buffer;
@@ -37,14 +48,14 @@ acquire_buffer (gboolean *free_buffer)
if (G_LIKELY (G_TRYLOCK (cached_buffer)))
{
if (G_UNLIKELY (!cached_buffer))
- cached_buffer = hb_buffer_create (64);
+ cached_buffer = create_buffer ();
buffer = cached_buffer;
*free_buffer = FALSE;
}
else
{
- buffer = hb_buffer_create (32);
+ buffer = create_buffer ();
*free_buffer = TRUE;
}
@@ -54,9 +65,9 @@ acquire_buffer (gboolean *free_buffer)
static void
release_buffer (hb_buffer_t *buffer, gboolean free_buffer)
{
- if (G_LIKELY (!free_buffer) && hb_buffer_get_reference_count (buffer) == 1)
+ if (G_LIKELY (!free_buffer))
{
- hb_buffer_clear (buffer);
+ hb_buffer_reset (buffer);
G_UNLOCK (cached_buffer);
}
else
@@ -115,7 +126,7 @@ pango_ot_buffer_destroy (PangoOTBuffer *buffer)
void
pango_ot_buffer_clear (PangoOTBuffer *buffer)
{
- hb_buffer_clear (buffer->buffer);
+ hb_buffer_reset (buffer->buffer);
buffer->applied_gpos = FALSE;
}
@@ -137,8 +148,7 @@ pango_ot_buffer_add_glyph (PangoOTBuffer *buffer,
guint properties,
guint cluster)
{
- hb_buffer_add_glyph (buffer->buffer,
- glyph, properties, cluster);
+ hb_buffer_add (buffer->buffer, glyph, ~properties, cluster);
}
/**
@@ -198,124 +208,10 @@ pango_ot_buffer_get_glyphs (const PangoOTBuffer *buffer,
int *n_glyphs)
{
if (glyphs)
- *glyphs = (PangoOTGlyph *) hb_buffer_get_glyph_infos (buffer->buffer);
+ *glyphs = (PangoOTGlyph *) hb_buffer_get_glyph_infos (buffer->buffer, NULL);
if (n_glyphs)
- *n_glyphs = hb_buffer_get_len (buffer->buffer);
-}
-
-static void
-apply_gpos_ltr (PangoGlyphString *glyphs,
- hb_glyph_position_t *positions,
- gboolean scale,
- double xscale,
- double yscale,
- gboolean is_hinted)
-{
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- {
- FT_Pos x_pos = positions[i].x_pos;
- FT_Pos y_pos = positions[i].y_pos;
- int back = i;
- int j;
- int adjustment;
-
-
- adjustment = PANGO_UNITS_26_6(positions[i].x_advance);
-
- if (is_hinted)
- adjustment = PANGO_UNITS_ROUND (adjustment);
- if (G_UNLIKELY (scale))
- adjustment *= xscale;
-
- if (positions[i].new_advance)
- glyphs->glyphs[i].geometry.width = adjustment;
- else
- glyphs->glyphs[i].geometry.width += adjustment;
-
-
- while (positions[back].back != 0)
- {
- back -= positions[back].back;
- x_pos += positions[back].x_pos;
- y_pos += positions[back].y_pos;
- }
-
- for (j = back; j < i; j++)
- glyphs->glyphs[i].geometry.x_offset -= glyphs->glyphs[j].geometry.width;
-
- if (G_UNLIKELY (scale))
- {
- glyphs->glyphs[i].geometry.x_offset += xscale * PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= yscale * PANGO_UNITS_26_6(y_pos);
- }
- else
- {
- glyphs->glyphs[i].geometry.x_offset += PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= PANGO_UNITS_26_6(y_pos);
- }
- }
-}
-
-static void
-apply_gpos_rtl (PangoGlyphString *glyphs,
- hb_glyph_position_t *positions,
- gboolean scale,
- double xscale,
- double yscale,
- gboolean is_hinted)
-{
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- {
- int i_rev = glyphs->num_glyphs - i - 1;
- int back_rev = i_rev;
- int back;
- FT_Pos x_pos = positions[i_rev].x_pos;
- FT_Pos y_pos = positions[i_rev].y_pos;
- int j;
- int adjustment;
-
-
- adjustment = PANGO_UNITS_26_6(positions[i_rev].x_advance);
-
- if (is_hinted)
- adjustment = PANGO_UNITS_ROUND (adjustment);
- if (G_UNLIKELY (scale))
- adjustment *= xscale;
-
- if (positions[i_rev].new_advance)
- glyphs->glyphs[i].geometry.width = adjustment;
- else
- glyphs->glyphs[i].geometry.width += adjustment;
-
-
- while (positions[back_rev].back != 0)
- {
- back_rev -= positions[back_rev].back;
- x_pos += positions[back_rev].x_pos;
- y_pos += positions[back_rev].y_pos;
- }
-
- back = glyphs->num_glyphs - back_rev - 1;
-
- for (j = i; j < back; j++)
- glyphs->glyphs[i].geometry.x_offset += glyphs->glyphs[j].geometry.width;
-
- if (G_UNLIKELY (scale))
- {
- glyphs->glyphs[i].geometry.x_offset += xscale * PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= yscale * PANGO_UNITS_26_6(y_pos);
- }
- else
- {
- glyphs->glyphs[i].geometry.x_offset += PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= PANGO_UNITS_26_6(y_pos);
- }
- }
+ *n_glyphs = hb_buffer_get_length (buffer->buffer);
}
/**
@@ -333,103 +229,43 @@ void
pango_ot_buffer_output (const PangoOTBuffer *buffer,
PangoGlyphString *glyphs)
{
- FT_Face face;
- hb_face_t *hb_face;
unsigned int i;
int last_cluster;
- unsigned int len;
- PangoOTGlyph *otglyphs;
- hb_glyph_position_t *positions;
-
- face = pango_fc_font_lock_face (buffer->font);
- g_assert (face);
-
- pango_ot_buffer_get_glyphs (buffer, &otglyphs, (int *) &len);
+ unsigned int num_glyphs;
+ hb_buffer_t *hb_buffer = buffer->buffer;
+ gboolean is_hinted = buffer->font->is_hinted;
+ hb_glyph_info_t *hb_glyph;
+ hb_glyph_position_t *hb_position;
/* Copy glyphs into output glyph string */
- pango_glyph_string_set_size (glyphs, len);
-
+ num_glyphs = hb_buffer_get_length (hb_buffer);
+ hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, NULL);
+ hb_position = hb_buffer_get_glyph_positions (hb_buffer, NULL);
+ pango_glyph_string_set_size (glyphs, num_glyphs);
last_cluster = -1;
- for (i = 0; i < len; i++)
+ for (i = 0; i < num_glyphs; i++)
{
- PangoOTGlyph *otglyph = &otglyphs[i];
-
- glyphs->glyphs[i].glyph = otglyph->glyph;
-
- glyphs->log_clusters[i] = otglyph->cluster;
- if (glyphs->log_clusters[i] != last_cluster)
- glyphs->glyphs[i].attr.is_cluster_start = 1;
- else
- glyphs->glyphs[i].attr.is_cluster_start = 0;
+ int advance;
+ glyphs->glyphs[i].glyph = hb_glyph->codepoint;
+ glyphs->log_clusters[i] = hb_glyph->cluster;
+ glyphs->glyphs[i].attr.is_cluster_start = glyphs->log_clusters[i] != last_cluster;
last_cluster = glyphs->log_clusters[i];
- }
- hb_face = _pango_ot_info_get_hb_face (pango_ot_info_get (face));
-
- /* Apply default positioning */
- for (i = 0; i < (unsigned int)glyphs->num_glyphs; i++)
- {
- if (glyphs->glyphs[i].glyph)
- {
- PangoRectangle logical_rect;
-
- if (buffer->zero_width_marks &&
- hb_ot_layout_get_glyph_class (hb_face, glyphs->glyphs[i].glyph) == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
- {
- glyphs->glyphs[i].geometry.width = 0;
- }
- else
- {
- pango_font_get_glyph_extents ((PangoFont *)buffer->font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
- glyphs->glyphs[i].geometry.width = logical_rect.width;
- }
- }
- else
- glyphs->glyphs[i].geometry.width = 0;
+ advance = hb_position->x_advance;
+ if (is_hinted)
+ advance = PANGO_UNITS_ROUND (advance);
+ glyphs->glyphs[i].geometry.width = advance;
+ glyphs->glyphs[i].geometry.x_offset = hb_position->x_offset;
+ glyphs->glyphs[i].geometry.y_offset = hb_position->y_offset;
- glyphs->glyphs[i].geometry.x_offset = 0;
- glyphs->glyphs[i].geometry.y_offset = 0;
+ hb_glyph++;
+ hb_position++;
}
if (buffer->rtl)
- {
- /* Swap all glyphs */
- pango_glyph_string_reverse_range (glyphs, 0, glyphs->num_glyphs);
- }
-
- positions = hb_buffer_get_glyph_positions (buffer->buffer);
- if (buffer->applied_gpos)
- {
- gboolean scale = FALSE;
- double xscale = 1, yscale = 1;
- PangoFcFontKey *key = _pango_fc_font_get_font_key (buffer->font);
-
- /* This is a kludge, and dupped in pango_fc_font_kern_glyphs().
- * Should move the scale factor to PangoFcFont layer. */
- if (key) {
- const PangoMatrix *matrix = pango_fc_font_key_get_matrix (key);
- PangoMatrix identity = PANGO_MATRIX_INIT;
- if (G_UNLIKELY (matrix && 0 != memcmp (&identity, matrix, 4 * sizeof (double))))
- {
- scale = TRUE;
- pango_matrix_get_font_scale_factors (matrix, &xscale, &yscale);
- if (xscale) xscale = 1 / xscale;
- if (yscale) yscale = 1 / yscale;
- }
- }
-
- if (buffer->rtl)
- apply_gpos_rtl (glyphs, positions, scale, xscale, yscale, buffer->font->is_hinted);
- else
- apply_gpos_ltr (glyphs, positions, scale, xscale, yscale, buffer->font->is_hinted);
- }
- else
- {
- /* FIXME we should only do this if the 'kern' feature was requested */
- pango_fc_font_kern_glyphs (buffer->font, glyphs);
- }
-
- pango_fc_font_unlock_face (buffer->font);
+ pango_glyph_string_reverse_range (glyphs, 0, glyphs->num_glyphs);
+ if (!buffer->applied_gpos)
+ pango_fc_font_kern_glyphs (buffer->font, glyphs);
}
diff --git a/pango/pango-ot-info.c b/pango/pango-ot-info.c
index be7d53a3..56d28bfe 100644
--- a/pango/pango-ot-info.c
+++ b/pango/pango-ot-info.c
@@ -27,8 +27,6 @@
static void pango_ot_info_finalize (GObject *object);
-static void synthesize_class_def (PangoOTInfo *info);
-
G_DEFINE_TYPE (PangoOTInfo, pango_ot_info, G_TYPE_OBJECT);
static void
@@ -65,31 +63,6 @@ pango_ot_info_finalizer (void *object)
g_object_unref (info);
}
-static hb_blob_t *
-_get_table (hb_tag_t tag, void *user_data)
-{
- PangoOTInfo *info = (PangoOTInfo *) user_data;
- FT_Byte *buffer;
- FT_ULong length = 0;
- FT_Error error;
-
- error = FT_Load_Sfnt_Table (info->face, tag, 0, NULL, &length);
- if (error)
- return hb_blob_create_empty ();
-
- buffer = g_malloc (length);
- if (buffer == NULL)
- return hb_blob_create_empty ();
-
- error = FT_Load_Sfnt_Table (info->face, tag, 0, buffer, &length);
- if (error)
- return hb_blob_create_empty ();
-
- return hb_blob_create ((const char *) buffer, length,
- HB_MEMORY_MODE_WRITABLE,
- g_free, buffer);
-}
-
/**
* pango_ot_info_get:
@@ -118,26 +91,7 @@ pango_ot_info_get (FT_Face face)
face->generic.finalizer = pango_ot_info_finalizer;
info->face = face;
-
- if (face->stream->read == NULL) {
- hb_blob_t *blob;
-
- blob = hb_blob_create ((const char *) face->stream->base,
- (unsigned int) face->stream->size,
- HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE,
- NULL, NULL);
- info->hb_face = hb_face_create_for_data (blob, face->face_index);
- hb_blob_destroy (blob);
- } else {
- info->hb_face = hb_face_create_for_tables (_get_table, NULL, info);
- }
-
-
- hb_face_set_unicode_funcs (info->hb_face, hb_glib_get_unicode_funcs ());
-
- /* XXX this is such a waste if not SFNT */
- if (!hb_ot_layout_has_font_glyph_classes (info->hb_face))
- synthesize_class_def (info);
+ info->hb_face = hb_ft_face_create (face, NULL);
}
return info;
@@ -149,142 +103,6 @@ _pango_ot_info_get_hb_face (PangoOTInfo *info)
return info->hb_face;
}
-typedef struct _GlyphInfo GlyphInfo;
-
-struct _GlyphInfo {
- unsigned short glyph;
- unsigned short class;
-};
-
-static int
-compare_glyph_info (gconstpointer a,
- gconstpointer b)
-{
- const GlyphInfo *info_a = a;
- const GlyphInfo *info_b = b;
-
- return (info_a->glyph < info_b->glyph) ? -1 :
- (info_a->glyph == info_b->glyph) ? 0 : 1;
-}
-
-/* Make a guess at the appropriate class for a glyph given
- * a character code that maps to the glyph
- */
-static gboolean
-get_glyph_class (gunichar charcode,
- unsigned short *class)
-{
- /* For characters mapped into the Arabic Presentation forms, using properties
- * derived as we apply GSUB substitutions will be more reliable
- */
- if ((charcode >= 0xFB50 && charcode <= 0xFDFF) || /* Arabic Presentation Forms-A */
- (charcode >= 0xFE70 && charcode <= 0XFEFF)) /* Arabic Presentation Forms-B */
- return FALSE;
-
- switch ((int) g_unichar_type (charcode))
- {
- case G_UNICODE_COMBINING_MARK:
- case G_UNICODE_ENCLOSING_MARK:
- case G_UNICODE_NON_SPACING_MARK:
- *class = HB_OT_LAYOUT_GLYPH_CLASS_MARK; /* Mark glyph (non-spacing combining glyph) */
- return TRUE;
- case G_UNICODE_UNASSIGNED:
- case G_UNICODE_PRIVATE_USE:
- return FALSE; /* Unknown, don't assign a class; classes get
- * propagated during GSUB application */
- default:
- *class = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH; /* Base glyph (single character, spacing glyph) */
- return TRUE;
- }
-}
-
-static gboolean
-set_unicode_charmap (FT_Face face)
-{
- int charmap;
-
- for (charmap = 0; charmap < face->num_charmaps; charmap++)
- if (face->charmaps[charmap]->encoding == ft_encoding_unicode)
- {
- FT_Error error = FT_Set_Charmap(face, face->charmaps[charmap]);
- return error == FT_Err_Ok;
- }
-
- return FALSE;
-}
-
-/* Synthesize a GDEF table using the font's charmap and the
- * Unicode property database. We'll fill in class definitions
- * for glyphs not in the charmap as we walk through the tables.
- */
-static void
-synthesize_class_def (PangoOTInfo *info)
-{
- GArray *glyph_infos;
- hb_codepoint_t *glyph_indices;
- unsigned char *classes;
- gunichar charcode;
- FT_UInt glyph;
- unsigned int i, j;
- FT_CharMap old_charmap;
-
- old_charmap = info->face->charmap;
-
- if (!old_charmap || old_charmap->encoding != ft_encoding_unicode)
- if (!set_unicode_charmap (info->face))
- return;
-
- glyph_infos = g_array_new (FALSE, FALSE, sizeof (GlyphInfo));
-
- /* Collect all the glyphs in the charmap, and guess
- * the appropriate classes for them
- */
- charcode = FT_Get_First_Char (info->face, &glyph);
- while (glyph != 0)
- {
- GlyphInfo glyph_info;
-
- if (glyph <= 65535)
- {
- glyph_info.glyph = glyph;
- if (get_glyph_class (charcode, &glyph_info.class))
- g_array_append_val (glyph_infos, glyph_info);
- }
-
- charcode = FT_Get_Next_Char (info->face, charcode, &glyph);
- }
-
- /* Sort and remove duplicates
- */
- g_array_sort (glyph_infos, compare_glyph_info);
-
- glyph_indices = g_new (hb_codepoint_t, glyph_infos->len);
- classes = g_new (unsigned char, glyph_infos->len);
-
- for (i = 0, j = 0; i < glyph_infos->len; i++)
- {
- GlyphInfo *info = &g_array_index (glyph_infos, GlyphInfo, i);
-
- if (j == 0 || info->glyph != glyph_indices[j - 1])
- {
- glyph_indices[j] = info->glyph;
- classes[j] = info->class;
-
- j++;
- }
- }
-
- g_array_free (glyph_infos, TRUE);
-
- hb_ot_layout_build_glyph_classes (info->hb_face, glyph_indices, classes, j);
-
- g_free (glyph_indices);
- g_free (classes);
-
- if (old_charmap && info->face->charmap != old_charmap)
- FT_Set_Charmap (info->face, old_charmap);
-}
-
static hb_tag_t
get_hb_table_type (PangoOTTableType table_type)
{
@@ -429,11 +247,11 @@ pango_ot_info_list_scripts (PangoOTInfo *info,
{
hb_tag_t tt = get_hb_table_type (table_type);
PangoOTTag *result;
- unsigned int count = 0;
+ unsigned int count;
- hb_ot_layout_table_get_script_tags (info->hb_face, tt, &count, NULL);
+ count = hb_ot_layout_table_get_script_tags (info->hb_face, tt, 0, NULL, NULL);
result = g_new (PangoOTTag, count + 1);
- hb_ot_layout_table_get_script_tags (info->hb_face, tt, &count, result);
+ hb_ot_layout_table_get_script_tags (info->hb_face, tt, 0, &count, result);
result[count] = 0;
return result;
@@ -459,11 +277,11 @@ pango_ot_info_list_languages (PangoOTInfo *info,
{
hb_tag_t tt = get_hb_table_type (table_type);
PangoOTTag *result;
- unsigned int count = 0;
+ unsigned int count;
- hb_ot_layout_script_get_language_tags (info->hb_face, tt, script_index, &count, NULL);
+ count = hb_ot_layout_script_get_language_tags (info->hb_face, tt, script_index, 0, NULL, NULL);
result = g_new (PangoOTTag, count + 1);
- hb_ot_layout_script_get_language_tags (info->hb_face, tt, script_index, &count, result);
+ hb_ot_layout_script_get_language_tags (info->hb_face, tt, script_index, 0, &count, result);
result[count] = 0;
return result;
@@ -493,11 +311,11 @@ pango_ot_info_list_features (PangoOTInfo *info,
{
hb_tag_t tt = get_hb_table_type (table_type);
PangoOTTag *result;
- unsigned int count = 0;
+ unsigned int count;
- hb_ot_layout_language_get_feature_tags (info->hb_face, tt, script_index, language_index, &count, NULL);
+ count = hb_ot_layout_language_get_feature_tags (info->hb_face, tt, script_index, language_index, 0, NULL, NULL);
result = g_new (PangoOTTag, count + 1);
- hb_ot_layout_language_get_feature_tags (info->hb_face, tt, script_index, language_index, &count, result);
+ hb_ot_layout_language_get_feature_tags (info->hb_face, tt, script_index, language_index, 0, &count, result);
result[count] = 0;
return result;
@@ -510,6 +328,8 @@ _pango_ot_info_substitute (const PangoOTInfo *info,
{
unsigned int i;
+ hb_ot_layout_substitute_start (buffer->buffer);
+
for (i = 0; i < ruleset->rules->len; i++)
{
PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
@@ -525,16 +345,18 @@ _pango_ot_info_substitute (const PangoOTInfo *info,
hb_ot_layout_feature_get_lookup_indexes (info->hb_face,
HB_OT_TAG_GSUB,
rule->feature_index,
+ 0,
&lookup_count,
lookup_indexes);
- lookup_count = MIN (G_N_ELEMENTS (lookup_indexes), lookup_count);
for (j = 0; j < lookup_count; j++)
hb_ot_layout_substitute_lookup (info->hb_face,
buffer->buffer,
lookup_indexes[j],
rule->property_bit);
}
+
+ hb_ot_layout_substitute_finish (buffer->buffer);
}
void
@@ -542,22 +364,41 @@ _pango_ot_info_position (const PangoOTInfo *info,
const PangoOTRuleset *ruleset,
PangoOTBuffer *buffer)
{
- unsigned int i;
+ unsigned int i, num_glyphs;
gboolean is_hinted;
hb_font_t *hb_font;
-
- hb_buffer_clear_positions (buffer->buffer);
+ hb_glyph_info_t *hb_glyph;
+ hb_glyph_position_t *hb_position;
/* XXX reuse hb_font */
- hb_font = hb_font_create ();
+ hb_font = hb_font_create (info->hb_face);
hb_font_set_scale (hb_font,
- info->face->size->metrics.x_scale,
- info->face->size->metrics.y_scale);
+ (((guint64) info->face->size->metrics.x_scale * info->face->units_per_EM) >> 12),
+ -(((guint64) info->face->size->metrics.y_scale * info->face->units_per_EM) >> 12));
is_hinted = buffer->font->is_hinted;
hb_font_set_ppem (hb_font,
is_hinted ? info->face->size->metrics.x_ppem : 0,
is_hinted ? info->face->size->metrics.y_ppem : 0);
+
+ /* Apply default positioning */
+ num_glyphs = hb_buffer_get_length (buffer->buffer);
+ hb_glyph = hb_buffer_get_glyph_infos (buffer->buffer, NULL);
+ hb_position = hb_buffer_get_glyph_positions (buffer->buffer, NULL);
+
+ hb_ot_layout_position_start (buffer->buffer);
+
+ for (i = 0; i < num_glyphs; i++)
+ {
+ PangoRectangle logical_rect;
+ pango_font_get_glyph_extents ((PangoFont *) buffer->font, hb_glyph->codepoint, NULL, &logical_rect);
+ hb_position->x_advance = logical_rect.width;
+
+ hb_glyph++;
+ hb_position++;
+ }
+
+
for (i = 0; i < ruleset->rules->len; i++)
{
PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
@@ -573,12 +414,12 @@ _pango_ot_info_position (const PangoOTInfo *info,
hb_ot_layout_feature_get_lookup_indexes (info->hb_face,
HB_OT_TAG_GPOS,
rule->feature_index,
+ 0,
&lookup_count,
lookup_indexes);
- lookup_count = MIN (G_N_ELEMENTS (lookup_indexes), lookup_count);
for (j = 0; j < lookup_count; j++)
- hb_ot_layout_position_lookup (info->hb_face, hb_font,
+ hb_ot_layout_position_lookup (hb_font,
buffer->buffer,
lookup_indexes[j],
rule->property_bit);
@@ -586,28 +427,7 @@ _pango_ot_info_position (const PangoOTInfo *info,
buffer->applied_gpos = TRUE;
}
- if (buffer->applied_gpos)
- {
- unsigned int i, j;
- unsigned int len = hb_buffer_get_len (buffer->buffer);
- hb_glyph_position_t *positions = hb_buffer_get_glyph_positions (buffer->buffer);
-
- /* First handle all left-to-right connections */
- for (j = 0; j < len; j++)
- {
- if (positions[j].cursive_chain > 0)
- positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos;
- }
-
- /* Then handle all right-to-left connections */
- for (i = len; i > 0; i--)
- {
- j = i - 1;
-
- if (positions[j].cursive_chain < 0)
- positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos;
- }
- }
+ hb_ot_layout_position_finish (buffer->buffer);
hb_font_destroy (hb_font);
}
diff --git a/pango/pango-ot-private.h b/pango/pango-ot-private.h
index a011b74d..1911512e 100644
--- a/pango/pango-ot-private.h
+++ b/pango/pango-ot-private.h
@@ -25,8 +25,11 @@
#include <glib-object.h>
#include <pango/pango-ot.h>
-#include "opentype/hb-ot.h"
-#include "opentype/hb-glib.h"
+#include <hb-ot.h>
+#include <hb-ft.h>
+#include <hb-glib.h>
+
+#include "pangofc-private.h"
G_BEGIN_DECLS
diff --git a/pango/pangofc-private.h b/pango/pangofc-private.h
index f200c8c0..7945962e 100644
--- a/pango/pangofc-private.h
+++ b/pango/pangofc-private.h
@@ -61,7 +61,8 @@ struct _PangoFcCmapCache
(((d) >= 0) ? \
((d) + PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6 : \
((d) - PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6)
-#define PANGO_UNITS_26_6(d) (PANGO_SCALE_26_6 * (d))
+#define PANGO_UNITS_26_6(d) ((d) * PANGO_SCALE_26_6)
+#define PANGO_UNITS_TO_26_6(d) ((d) / PANGO_SCALE_26_6)
void _pango_fc_font_shutdown (PangoFcFont *fcfont);