backout changesets 9a9382595fce and ff34f480df07 (bug 910506) on a CLOSED TREE for failure in reftest variation-selector-unsupported-1.html

This commit is contained in:
Jonathan Kew 2013-09-27 14:58:28 +01:00
parent 772ea83a2c
commit bcb64cdef3
76 changed files with 1242 additions and 5377 deletions

View File

@ -28,8 +28,6 @@ HBSOURCES = \
hb-cache-private.hh \
hb-common.cc \
hb-fallback-shape.cc \
hb-face-private.hh \
hb-face.cc \
hb-font-private.hh \
hb-font.cc \
hb-mutex-private.hh \
@ -63,8 +61,6 @@ HBHEADERS = \
hb-blob.h \
hb-buffer.h \
hb-common.h \
hb-deprecated.h \
hb-face.h \
hb-font.h \
hb-set.h \
hb-shape.h \
@ -83,7 +79,6 @@ HBSOURCES += \
hb-ot-layout-gpos-table.hh \
hb-ot-layout-gsubgpos-private.hh \
hb-ot-layout-gsub-table.hh \
hb-ot-layout-jstf-table.hh \
hb-ot-layout-private.hh \
hb-ot-map.cc \
hb-ot-map-private.hh \
@ -127,6 +122,28 @@ HBSOURCES += hb-glib.cc
HBHEADERS += hb-glib.h
endif
if HAVE_GOBJECT
HBCFLAGS += $(GOBJECT_CFLAGS)
HBLIBS += $(GOBJECT_LIBS)
HBSOURCES += hb-gobject-structs.cc
nodist_HBSOURCES = hb-gobject-enums.cc
HBHEADERS += hb-gobject.h
BUILT_SOURCES += hb-gobject-enums.cc
EXTRA_DIST += hb-gobject-enums.cc.tmpl
DISTCLEANFILES += hb-gobject-enums.cc
hb-gobject-enums.cc: hb-gobject-enums.cc.tmpl $(HBHEADERS)
$(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > "$@.tmp" && \
mv "$@.tmp" "$@" || ( $(RM) "@.tmp" && false )
endif
if HAVE_ICU
HBCFLAGS += $(ICU_CFLAGS)
HBLIBS += $(ICU_LIBS)
HBSOURCES += hb-icu.cc
HBHEADERS += hb-icu.h
endif
if HAVE_FREETYPE
HBCFLAGS += $(FREETYPE_CFLAGS)
HBLIBS += $(FREETYPE_LIBS)
@ -155,6 +172,22 @@ HBSOURCES += hb-coretext.cc
HBHEADERS += hb-coretext.h
endif
if HAVE_HB_OLD
SUBDIRS += hb-old
HBCFLAGS += -I$(srcdir)/hb-old
HBLIBS += hb-old/libhb-old.la
HBSOURCES += hb-old.cc
endif
DIST_SUBDIRS += hb-old
if HAVE_ICU_LE
SUBDIRS += hb-icu-le
HBCFLAGS += -I$(srcdir)/hb-icu-le
HBLIBS += hb-icu-le/libhb-icu-le.la
HBSOURCES += hb-icu-le.cc
endif
DIST_SUBDIRS += hb-icu-le
if HAVE_UCDN
SUBDIRS += hb-ucdn
HBCFLAGS += -I$(srcdir)/hb-ucdn
@ -171,6 +204,9 @@ export_symbols = -export-symbols harfbuzz.def
harfbuzz_def_dependency = harfbuzz.def
libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS)
else
if HAVE_ICU
libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS)
else
# Use a C linker for GCC, not C++; Don't link to libstdc++
if HAVE_GCC
libharfbuzz_la_LINK = $(LINK) $(libharfbuzz_la_LDFLAGS)
@ -178,74 +214,16 @@ else
libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS)
endif
endif
endif
libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS) $(HBNODISTHEADERS)
nodist_libharfbuzz_la_SOURCES = $(nodist_HBSOURCES)
libharfbuzz_la_CPPFLAGS = $(HBCFLAGS)
libharfbuzz_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) $(export_symbols) -no-undefined
libharfbuzz_la_LIBADD = $(HBLIBS)
EXTRA_libharfbuzz_la_DEPENDENCIES = $(harfbuzz_def_dependency)
pkginclude_HEADERS = $(HBHEADERS)
nodist_pkginclude_HEADERS = $(HBNODISTHEADERS)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = harfbuzz.pc
EXTRA_DIST += harfbuzz.pc.in
if HAVE_ICU
lib_LTLIBRARIES += libharfbuzz-icu.la
libharfbuzz_icu_la_SOURCES = hb-icu.cc
libharfbuzz_icu_la_CPPFLAGS = $(ICU_CFLAGS)
libharfbuzz_icu_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) -no-undefined
libharfbuzz_icu_la_LIBADD = $(ICU_LIBS) libharfbuzz.la
pkginclude_HEADERS += hb-icu.h
pkgconfig_DATA += harfbuzz-icu.pc
endif
EXTRA_DIST += harfbuzz-icu.pc.in
if HAVE_GOBJECT
lib_LTLIBRARIES += libharfbuzz-gobject.la
libharfbuzz_gobject_la_SOURCES = hb-gobject-structs.cc
nodist_libharfbuzz_gobject_la_SOURCES = hb-gobject-enums.cc
libharfbuzz_gobject_la_CPPFLAGS = $(GOBJECT_CFLAGS)
libharfbuzz_gobject_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) -no-undefined
libharfbuzz_gobject_la_LIBADD = $(GOBJECT_LIBS) libharfbuzz.la
pkginclude_HEADERS += hb-gobject.h hb-gobject-structs.h
nodist_pkginclude_HEADERS += hb-gobject-enums.h
pkgconfig_DATA += harfbuzz-gobject.pc
BUILT_SOURCES += \
hb-gobject-enums.cc \
hb-gobject-enums.h \
$(NULL)
DISTCLEANFILES += \
hb-gobject-enums.cc \
hb-gobject-enums.h \
$(NULL)
hb-gobject-enums.%: hb-gobject-enums.%.tmpl $(HBHEADERS)
$(AM_V_GEN) $(GLIB_MKENUMS) \
--identifier-prefix hb_ --symbol-prefix hb_gobject \
--template $^ | \
sed 's/_t_get_type/_get_type/g; s/_T (/ (/g' > "$@.tmp" && \
mv "$@.tmp" "$@" || ( $(RM) "@.tmp" && false )
endif
EXTRA_DIST += \
harfbuzz-gobject.pc.in \
hb-gobject-enums.cc.tmpl \
hb-gobject-enums.h.tmpl \
$(NULL)
%.pc: %.pc.in $(top_builddir)/config.status
$(AM_V_GEN) \
$(SED) -e 's@%prefix%@$(prefix)@g' \
-e 's@%exec_prefix%@$(exec_prefix)@g' \
-e 's@%libdir%@$(libdir)@g' \
-e 's@%includedir%@$(includedir)@g' \
-e 's@%VERSION%@$(VERSION)@g' \
"$<" \
> "$@.tmp" && mv "$@.tmp" "$@" || ( $(RM) "$@.tmp"; false )
CLEANFILES += $(pkgconfig_DATA)
CLEANFILES += harfbuzz.def
harfbuzz.def: $(HBHEADERS) $(HBNODISTHEADERS)
@ -263,6 +241,7 @@ GENERATORS = \
gen-arabic-table.py \
gen-indic-table.py \
$(NULL)
EXTRA_DIST += $(GENERATORS)
unicode-tables: arabic-table indic-table
@ -294,7 +273,7 @@ EXTRA_DIST += \
hb-ot-shape-complex-myanmar-machine.rl \
hb-ot-shape-complex-sea-machine.rl \
$(NULL)
.rl.hh:
%.hh: %.rl
$(AM_V_GEN)$(top_srcdir)/missing --run ragel -e -F1 -o "$@.tmp" "$<" && \
mv "$@.tmp" "$@" || ( $(RM) "$@.tmp" && false )
@ -329,14 +308,21 @@ test_buffer_serialize_LDADD = libharfbuzz.la $(HBLIBS)
dist_check_SCRIPTS = \
check-c-linkage-decls.sh \
check-defs.sh \
check-header-guards.sh \
check-includes.sh \
check-libstdc++.sh \
check-static-inits.sh \
check-symbols.sh \
$(NULL)
if HAVE_ICU
else
dist_check_SCRIPTS += check-libstdc++.sh
endif
if HAVE_ICU_LE
else
dist_check_SCRIPTS += check-static-inits.sh
endif
TESTS = $(dist_check_SCRIPTS)
TESTS_ENVIRONMENT = \
srcdir="$(srcdir)" \
@ -345,47 +331,26 @@ TESTS_ENVIRONMENT = \
HBHEADERS="$(HBHEADERS) $(HBNODISTHEADERS)" \
$(NULL)
if HAVE_INTROSPECTION
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS = HarfBuzz-$(HB_VERSION_MAJOR).0.gir # What does the 0 mean anyway?!
INTROSPECTION_SCANNER_ARGS = -I$(srcdir) -n hb --identifier-prefix=hb_ --warn-all
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
HarfBuzz-0.0.gir: libharfbuzz.la libharfbuzz-gobject.la
HarfBuzz_0_0_gir_INCLUDES = GObject-2.0
HarfBuzz_0_0_gir_CFLAGS = \
$(INCLUDES) \
$(HBCFLAGS) \
-DHB_H \
-DHB_H_IN \
-DHB_OT_H \
-DHB_OT_H_IN \
-DHB_GOBJECT_H \
-DHB_GOBJECT_H_IN \
$(NULL)
HarfBuzz_0_0_gir_LIBS = \
libharfbuzz.la \
libharfbuzz-gobject.la \
$(NULL)
HarfBuzz_0_0_gir_FILES = \
$(HBHEADERS) \
$(HBNODISTHEADERS) \
$(HBSOURCES) \
hb-gobject-enums.cc \
hb-gobject-enums.h \
hb-gobject-structs.cc \
hb-gobject-structs.h \
$(NULL)
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)
typelibdir = $(libdir)/girepository-1.0
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
#-include $(INTROSPECTION_MAKEFILE)
#INTROSPECTION_GIRS = hb-1.0.gir
#INTROSPECTION_SCANNER_ARGS = -I$(srcdir) -n hb --identifier-prefix=hb_
#INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
#
#if HAVE_INTROSPECTION
#
#hb-1.0.gir: libharfbuzz.la
#hb_1_0_gir_INCLUDES = GObject-2.0
#hb_1_0_gir_CFLAGS = $(INCLUDES) $(HBCFLAGS) -DHB_H -DHB_H_IN -DHB_OT_H -DHB_OT_H_IN
#hb_1_0_gir_LIBS = libharfbuzz.la
#hb_1_0_gir_FILES = $(HBHEADERS) $(HBNODISTHEADERS)
#
#girdir = $(datadir)/gir-1.0
#gir_DATA = $(INTROSPECTION_GIRS)
#
#typelibdir = $(libdir)/girepository-1.0
#typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
#
#CLEANFILES += $(gir_DATA) $(typelib_DATA)
#endif
-include $(top_srcdir)/git.mk

View File

@ -6,8 +6,8 @@ export LC_ALL
test -z "$srcdir" && srcdir=.
stat=0
test "x$HBHEADERS" = x && HBHEADERS=`cd "$srcdir"; find . -maxdepth 1 -name 'hb*.h'`
test "x$HBSOURCES" = x && HBSOURCES=`cd "$srcdir"; find . -maxdepth 1 -name 'hb*.h'`
test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'`
test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb*.h'`
for x in $HBHEADERS; do

View File

@ -6,8 +6,8 @@ export LC_ALL
test -z "$srcdir" && srcdir=.
stat=0
test "x$HBHEADERS" = x && HBHEADERS=`cd "$srcdir"; find . -maxdepth 1 -name 'hb*.h'`
test "x$HBSOURCES" = x && HBSOURCES=`cd "$srcdir"; find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'`
test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'`
test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'`
for x in $HBHEADERS $HBSOURCES; do

View File

@ -6,14 +6,16 @@ export LC_ALL
test -z "$srcdir" && srcdir=.
stat=0
test "x$HBHEADERS" = x && HBHEADERS=`cd "$srcdir"; find . -maxdepth 1 -name 'hb*.h'`
test "x$HBSOURCES" = x && HBSOURCES=`cd "$srcdir"; find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'`
test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'`
test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'`
cd "$srcdir"
echo 'Checking that public header files #include "hb-common.h" or "hb.h" first (or none)'
for x in $HBHEADERS; do
test -f "$srcdir/$x" && x="$srcdir/$x"
grep '#.*\<include\>' "$x" /dev/null | head -n 1
done |
grep -v '"hb-common[.]h"' |
@ -26,7 +28,6 @@ grep . >&2 && stat=1
echo 'Checking that source files #include "hb-*private.hh" first (or none)'
for x in $HBSOURCES; do
test -f "$srcdir/$x" && x="$srcdir/$x"
grep '#.*\<include\>' "$x" /dev/null | head -n 1
done |
grep -v '"hb-.*private[.]hh"' |
@ -35,10 +36,7 @@ grep . >&2 && stat=1
echo 'Checking that there is no #include <hb.*.h>'
for x in $HBHEADERS $HBSOURCES; do
test -f "$srcdir/$x" && x="$srcdir/$x"
grep '#.*\<include\>.*<.*hb' "$x" /dev/null >&2 && stat=1
done
grep '#.*\<include\>.*<.*hb' $HBHEADERS $HBSOURCES >&2 && stat=1
exit $stat

View File

@ -4,9 +4,9 @@ LC_ALL=C
export LC_ALL
test -z "$srcdir" && srcdir=.
test -z "$MAKE" && MAKE=make
stat=0
if which nm 2>/dev/null >/dev/null; then
:
else
@ -14,23 +14,36 @@ else
exit 77
fi
echo "Checking that we are not exposing internal symbols"
defs="harfbuzz.def"
$MAKE $defs > /dev/null
tested=false
for so in `ls .libs/lib*.so .libs/lib*.dylib 2>/dev/null` ; do
for def in $defs; do
lib=`echo "$def" | sed 's/[.]def$//;s@.*/@@'`
so=.libs/lib${lib}.so
EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] ' | grep -v ' _fini\>\| _init\>\| _fdata\>\| _ftext\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>' | cut -d' ' -f3`"
prefix=`basename "$so" | sed 's/libharfbuzz/hb/; s/-/_/g; s/[.].*//'`
echo "Processing $so"
if echo "$EXPORTED_SYMBOLS" | grep -v "^${prefix}_"; then
echo "Ouch, internal symbols exposed"
stat=1
if test -f "$so"; then
echo "Checking that $so has the same symbol list as $def"
{
echo EXPORTS
echo "$EXPORTED_SYMBOLS"
# cheat: copy the last line from the def file!
tail -n1 "$def"
} | diff "$def" - >&2 || stat=1
echo "Checking that we are not exposing internal symbols"
if echo "$EXPORTED_SYMBOLS" | grep -v 'hb_'; then
echo "Ouch, internal symbols exposed"
stat=1
fi
tested=true
fi
tested=true
done
if ! $tested; then
echo "check-symbols.sh: no shared library found; skipping test"
echo "check-exported-symbols.sh: libharfbuzz shared library not found; skipping test"
exit 77
fi

View File

@ -1,12 +0,0 @@
prefix=%prefix%
exec_prefix=%exec_prefix%
libdir=%libdir%
includedir=%includedir%
Name: harfbuzz
Description: HarfBuzz text shaping library GObject integration
Version: %VERSION%
Requires: harfbuzz gobject-2.0 glib-2.0
Libs: -L${libdir} -lharfbuzz-gobject
Cflags: -I${includedir}/harfbuzz

View File

@ -1,13 +0,0 @@
prefix=%prefix%
exec_prefix=%exec_prefix%
libdir=%libdir%
includedir=%includedir%
Name: harfbuzz
Description: HarfBuzz text shaping library ICU integration
Version: %VERSION%
Requires: harfbuzz
Requires.private: icu-uc
Libs: -L${libdir} -lharfbuzz-icu
Cflags: -I${includedir}/harfbuzz

View File

@ -1,11 +0,0 @@
prefix=%prefix%
exec_prefix=%exec_prefix%
libdir=%libdir%
includedir=%includedir%
Name: harfbuzz
Description: HarfBuzz text shaping library
Version: %VERSION%
Libs: -L${libdir} -lharfbuzz
Cflags: -I${includedir}/harfbuzz

View File

@ -76,22 +76,6 @@ _hb_blob_destroy_user_data (hb_blob_t *blob)
}
}
/**
* hb_blob_create: (Xconstructor)
* @data: (array length=length) (closure user_data) (destroy destroy) (scope notified) (transfer none): Pointer to blob data.
* @length: Length of @data in bytes.
* @mode: Memory mode for @data.
* @user_data: Data parameter to pass to @destroy.
* @destroy: Callback to call when @data is not needed anymore.
*
* Creates a new "blob" object wrapping @data. The @mode parameter is used
* to negotiate ownership and lifecycle of @data.
*
* Return value: New blob, or the empty blob if something failed or if @length is
* zero. Destroy with hb_blob_destroy().
*
* Since: 1.0
**/
hb_blob_t *
hb_blob_create (const char *data,
unsigned int length,
@ -125,26 +109,6 @@ hb_blob_create (const char *data,
return blob;
}
/**
* hb_blob_create_sub_blob:
* @parent: Parent blob.
* @offset: Start offset of sub-blob within @parent, in bytes.
* @length: Length of sub-blob.
*
* Returns a blob that represents a range of bytes in @parent. The new
* blob is always created with %HB_MEMORY_MODE_READONLY, meaning that it
* will never modify data in the parent blob. The parent data is not
* expected to be modified, and will result in undefined behavior if it
* is.
*
* Makes @parent immutable.
*
* Return value: New blob, or the empty blob if something failed or if
* @length is zero or @offset is beyond the end of @parent's data. Destroy
* with hb_blob_destroy().
*
* Since: 1.0
**/
hb_blob_t *
hb_blob_create_sub_blob (hb_blob_t *parent,
unsigned int offset,
@ -166,17 +130,6 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
return blob;
}
/**
* hb_blob_get_empty:
*
* Returns the singleton empty blob.
*
* See TODO:link object types for more information.
*
* Return value: (transfer full): the empty blob.
*
* Since: 1.0
**/
hb_blob_t *
hb_blob_get_empty (void)
{
@ -196,36 +149,12 @@ hb_blob_get_empty (void)
return const_cast<hb_blob_t *> (&_hb_blob_nil);
}
/**
* hb_blob_reference: (skip)
* @blob: a blob.
*
* Increases the reference count on @blob.
*
* See TODO:link object types for more information.
*
* Return value: @blob.
*
* Since: 1.0
**/
hb_blob_t *
hb_blob_reference (hb_blob_t *blob)
{
return hb_object_reference (blob);
}
/**
* hb_blob_destroy: (skip)
* @blob: a blob.
*
* Descreases the reference count on @blob, and if it reaches zero, destroys
* @blob, freeing all memory, possibly calling the destroy-callback the blob
* was created for if it has not been called already.
*
* See TODO:link object types for more information.
*
* Since: 1.0
**/
void
hb_blob_destroy (hb_blob_t *blob)
{
@ -236,18 +165,6 @@ hb_blob_destroy (hb_blob_t *blob)
free (blob);
}
/**
* hb_blob_set_user_data: (skip)
* @blob: a blob.
* @key: key for data to set.
* @data: data to set.
* @destroy: callback to call when @data is not needed anymore.
* @replace: whether to replace an existing data with the same key.
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_blob_set_user_data (hb_blob_t *blob,
hb_user_data_key_t *key,
@ -258,17 +175,6 @@ hb_blob_set_user_data (hb_blob_t *blob,
return hb_object_set_user_data (blob, key, data, destroy, replace);
}
/**
* hb_blob_get_user_data: (skip)
* @blob: a blob.
* @key: key for data to get.
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
void *
hb_blob_get_user_data (hb_blob_t *blob,
hb_user_data_key_t *key)
@ -277,14 +183,6 @@ hb_blob_get_user_data (hb_blob_t *blob,
}
/**
* hb_blob_make_immutable:
* @blob: a blob.
*
*
*
* Since: 1.0
**/
void
hb_blob_make_immutable (hb_blob_t *blob)
{
@ -294,16 +192,6 @@ hb_blob_make_immutable (hb_blob_t *blob)
blob->immutable = true;
}
/**
* hb_blob_is_immutable:
* @blob: a blob.
*
*
*
* Return value: TODO
*
* Since: 1.0
**/
hb_bool_t
hb_blob_is_immutable (hb_blob_t *blob)
{
@ -311,33 +199,12 @@ hb_blob_is_immutable (hb_blob_t *blob)
}
/**
* hb_blob_get_length:
* @blob: a blob.
*
*
*
* Return value: the length of blob data in bytes.
*
* Since: 1.0
**/
unsigned int
hb_blob_get_length (hb_blob_t *blob)
{
return blob->length;
}
/**
* hb_blob_get_data:
* @blob: a blob.
* @length: (out):
*
*
*
* Returns: (transfer none) (array length=length):
*
* Since: 1.0
**/
const char *
hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
{
@ -347,22 +214,6 @@ hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
return blob->data;
}
/**
* hb_blob_get_data_writable:
* @blob: a blob.
* @length: (out): output length of the writable data.
*
* Tries to make blob data writable (possibly copying it) and
* return pointer to data.
*
* Fails if blob has been made immutable, or if memory allocation
* fails.
*
* Returns: (transfer none) (array length=length): Writable blob data,
* or %NULL if failed.
*
* Since: 1.0
**/
char *
hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
{
@ -473,3 +324,5 @@ _try_writable (hb_blob_t *blob)
return true;
}

View File

@ -80,8 +80,6 @@ struct hb_buffer_t {
inline hb_glyph_info_t &prev (void) { return out_info[out_len - 1]; }
inline hb_glyph_info_t prev (void) const { return info[out_len - 1]; }
inline bool has_separate_output (void) const { return info != out_info; }
unsigned int serial;
/* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */

View File

@ -33,32 +33,12 @@ static const char *serialize_formats[] = {
NULL
};
/**
* hb_buffer_serialize_list_formats:
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
const char **
hb_buffer_serialize_list_formats (void)
{
return serialize_formats;
}
/**
* hb_buffer_serialize_format_from_string:
* @str:
* @len:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_buffer_serialize_format_t
hb_buffer_serialize_format_from_string (const char *str, int len)
{
@ -66,16 +46,6 @@ hb_buffer_serialize_format_from_string (const char *str, int len)
return (hb_buffer_serialize_format_t) (hb_tag_from_string (str, len) & ~0x20202020);
}
/**
* hb_buffer_serialize_format_to_string:
* @format:
*
*
*
* Return value:
*
* Since: 1.0
**/
const char *
hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format)
{
@ -130,10 +100,10 @@ _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
*p++ = '"';
}
else
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint);
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster));
p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster);
}
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS))
@ -191,21 +161,21 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
p += strlen (p);
}
else
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint);
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster));
p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster);
}
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS))
{
if (pos[i].x_offset || pos[i].y_offset)
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", pos[i].x_offset, pos[i].y_offset));
p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", pos[i].x_offset, pos[i].y_offset);
*p++ = '+';
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance));
p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance);
if (pos->y_advance)
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance));
p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance);
}
if (buf_size > (p - b))
@ -224,24 +194,6 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
}
/* Returns number of items, starting at start, that were serialized. */
/**
* hb_buffer_serialize_glyphs:
* @buffer: a buffer.
* @start:
* @end:
* @buf: (array length=buf_size):
* @buf_size:
* @buf_consumed: (out):
* @font:
* @format:
* @flags:
*
*
*
* Return value:
*
* Since: 1.0
**/
unsigned int
hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
unsigned int start,
@ -334,21 +286,6 @@ parse_int (const char *pp, const char *end, int32_t *pv)
#include "hb-buffer-deserialize-json.hh"
#include "hb-buffer-deserialize-text.hh"
/**
* hb_buffer_deserialize_glyphs:
* @buffer: a buffer.
* @buf: (array length=buf_len):
* @buf_len:
* @end_ptr: (out):
* @font:
* @format:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
const char *buf,

View File

@ -176,7 +176,7 @@ hb_buffer_t::clear (void)
hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT;
props = default_props;
flags = HB_BUFFER_FLAG_DEFAULT;
flags = HB_BUFFER_FLAGS_DEFAULT;
content_type = HB_BUFFER_CONTENT_TYPE_INVALID;
in_error = false;
@ -549,7 +549,7 @@ void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const c
{
assert (byte_i < 8 && byte_i + count <= 8);
if (DEBUG_ENABLED (BUFFER))
if (DEBUG (BUFFER))
dump_var_allocation (this);
DEBUG_MSG (BUFFER, this,
"Allocating var bytes %d..%d for %s",
@ -564,7 +564,7 @@ void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const c
void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner)
{
if (DEBUG_ENABLED (BUFFER))
if (DEBUG (BUFFER))
dump_var_allocation (this);
DEBUG_MSG (BUFFER, this,
@ -581,7 +581,7 @@ void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const
void hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner)
{
if (DEBUG_ENABLED (BUFFER))
if (DEBUG (BUFFER))
dump_var_allocation (this);
DEBUG_MSG (BUFFER, this,
@ -603,15 +603,6 @@ void hb_buffer_t::deallocate_var_all (void)
/* Public API */
/**
* hb_buffer_create: (Xconstructor)
*
*
*
* Return value: (transfer full)
*
* Since: 1.0
**/
hb_buffer_t *
hb_buffer_create (void)
{
@ -625,15 +616,6 @@ hb_buffer_create (void)
return buffer;
}
/**
* hb_buffer_get_empty:
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_buffer_t *
hb_buffer_get_empty (void)
{
@ -642,7 +624,7 @@ hb_buffer_get_empty (void)
const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil),
HB_SEGMENT_PROPERTIES_DEFAULT,
HB_BUFFER_FLAG_DEFAULT,
HB_BUFFER_FLAGS_DEFAULT,
HB_BUFFER_CONTENT_TYPE_INVALID,
true, /* in_error */
@ -655,30 +637,12 @@ hb_buffer_get_empty (void)
return const_cast<hb_buffer_t *> (&_hb_buffer_nil);
}
/**
* hb_buffer_reference: (skip)
* @buffer: a buffer.
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_buffer_t *
hb_buffer_reference (hb_buffer_t *buffer)
{
return hb_object_reference (buffer);
}
/**
* hb_buffer_destroy: (skip)
* @buffer: a buffer.
*
*
*
* Since: 1.0
**/
void
hb_buffer_destroy (hb_buffer_t *buffer)
{
@ -692,20 +656,6 @@ hb_buffer_destroy (hb_buffer_t *buffer)
free (buffer);
}
/**
* hb_buffer_set_user_data: (skip)
* @buffer: a buffer.
* @key:
* @data:
* @destroy:
* @replace:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_buffer_set_user_data (hb_buffer_t *buffer,
hb_user_data_key_t *key,
@ -716,17 +666,6 @@ hb_buffer_set_user_data (hb_buffer_t *buffer,
return hb_object_set_user_data (buffer, key, data, destroy, replace);
}
/**
* hb_buffer_get_user_data: (skip)
* @buffer: a buffer.
* @key:
*
*
*
* Return value:
*
* Since: 1.0
**/
void *
hb_buffer_get_user_data (hb_buffer_t *buffer,
hb_user_data_key_t *key)
@ -735,15 +674,6 @@ hb_buffer_get_user_data (hb_buffer_t *buffer,
}
/**
* hb_buffer_set_content_type:
* @buffer: a buffer.
* @content_type:
*
*
*
* Since: 1.0
**/
void
hb_buffer_set_content_type (hb_buffer_t *buffer,
hb_buffer_content_type_t content_type)
@ -751,16 +681,6 @@ hb_buffer_set_content_type (hb_buffer_t *buffer,
buffer->content_type = content_type;
}
/**
* hb_buffer_get_content_type:
* @buffer: a buffer.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_buffer_content_type_t
hb_buffer_get_content_type (hb_buffer_t *buffer)
{
@ -768,56 +688,28 @@ hb_buffer_get_content_type (hb_buffer_t *buffer)
}
/**
* hb_buffer_set_unicode_funcs:
* @buffer: a buffer.
* @unicode_funcs:
*
*
*
* Since: 1.0
**/
void
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
hb_unicode_funcs_t *unicode_funcs)
hb_unicode_funcs_t *unicode)
{
if (unlikely (hb_object_is_inert (buffer)))
return;
if (!unicode_funcs)
unicode_funcs = hb_unicode_funcs_get_default ();
if (!unicode)
unicode = hb_unicode_funcs_get_default ();
hb_unicode_funcs_reference (unicode_funcs);
hb_unicode_funcs_reference (unicode);
hb_unicode_funcs_destroy (buffer->unicode);
buffer->unicode = unicode_funcs;
buffer->unicode = unicode;
}
/**
* hb_buffer_get_unicode_funcs:
* @buffer: a buffer.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_unicode_funcs_t *
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer)
{
return buffer->unicode;
}
/**
* hb_buffer_set_direction:
* @buffer: a buffer.
* @direction:
*
*
*
* Since: 1.0
**/
void
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction)
@ -829,31 +721,12 @@ hb_buffer_set_direction (hb_buffer_t *buffer,
buffer->props.direction = direction;
}
/**
* hb_buffer_get_direction:
* @buffer: a buffer.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_direction_t
hb_buffer_get_direction (hb_buffer_t *buffer)
{
return buffer->props.direction;
}
/**
* hb_buffer_set_script:
* @buffer: a buffer.
* @script:
*
*
*
* Since: 1.0
**/
void
hb_buffer_set_script (hb_buffer_t *buffer,
hb_script_t script)
@ -864,31 +737,12 @@ hb_buffer_set_script (hb_buffer_t *buffer,
buffer->props.script = script;
}
/**
* hb_buffer_get_script:
* @buffer: a buffer.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_script_t
hb_buffer_get_script (hb_buffer_t *buffer)
{
return buffer->props.script;
}
/**
* hb_buffer_set_language:
* @buffer: a buffer.
* @language:
*
*
*
* Since: 1.0
**/
void
hb_buffer_set_language (hb_buffer_t *buffer,
hb_language_t language)
@ -899,31 +753,12 @@ hb_buffer_set_language (hb_buffer_t *buffer,
buffer->props.language = language;
}
/**
* hb_buffer_get_language:
* @buffer: a buffer.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_language_t
hb_buffer_get_language (hb_buffer_t *buffer)
{
return buffer->props.language;
}
/**
* hb_buffer_set_segment_properties:
* @buffer: a buffer.
* @props:
*
*
*
* Since: 1.0
**/
void
hb_buffer_set_segment_properties (hb_buffer_t *buffer,
const hb_segment_properties_t *props)
@ -934,15 +769,6 @@ hb_buffer_set_segment_properties (hb_buffer_t *buffer,
buffer->props = *props;
}
/**
* hb_buffer_get_segment_properties:
* @buffer: a buffer.
* @props:
*
*
*
* Since: 1.0
**/
void
hb_buffer_get_segment_properties (hb_buffer_t *buffer,
hb_segment_properties_t *props)
@ -951,15 +777,6 @@ hb_buffer_get_segment_properties (hb_buffer_t *buffer,
}
/**
* hb_buffer_set_flags:
* @buffer: a buffer.
* @flags:
*
*
*
* Since: 1.0
**/
void
hb_buffer_set_flags (hb_buffer_t *buffer,
hb_buffer_flags_t flags)
@ -970,16 +787,6 @@ hb_buffer_set_flags (hb_buffer_t *buffer,
buffer->flags = flags;
}
/**
* hb_buffer_get_flags:
* @buffer: a buffer.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_buffer_flags_t
hb_buffer_get_flags (hb_buffer_t *buffer)
{
@ -987,77 +794,30 @@ hb_buffer_get_flags (hb_buffer_t *buffer)
}
/**
* hb_buffer_reset:
* @buffer: a buffer.
*
*
*
* Since: 1.0
**/
void
hb_buffer_reset (hb_buffer_t *buffer)
{
buffer->reset ();
}
/**
* hb_buffer_clear_contents:
* @buffer: a buffer.
*
*
*
* Since: 1.0
**/
void
hb_buffer_clear_contents (hb_buffer_t *buffer)
{
buffer->clear ();
}
/**
* hb_buffer_pre_allocate:
* @buffer: a buffer.
* @size:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size)
{
return buffer->ensure (size);
}
/**
* hb_buffer_allocation_successful:
* @buffer: a buffer.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_buffer_allocation_successful (hb_buffer_t *buffer)
{
return !buffer->in_error;
}
/**
* hb_buffer_add:
* @buffer: a buffer.
* @codepoint:
* @cluster:
*
*
*
* Since: 1.0
**/
void
hb_buffer_add (hb_buffer_t *buffer,
hb_codepoint_t codepoint,
@ -1067,17 +827,6 @@ hb_buffer_add (hb_buffer_t *buffer,
buffer->clear_context (1);
}
/**
* hb_buffer_set_length:
* @buffer: a buffer.
* @length:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_buffer_set_length (hb_buffer_t *buffer,
unsigned int length)
@ -1104,34 +853,13 @@ hb_buffer_set_length (hb_buffer_t *buffer,
return true;
}
/**
* hb_buffer_get_length:
* @buffer: a buffer.
*
* Returns the number of items in the buffer.
*
* Return value: buffer length.
*
* Since: 1.0
**/
unsigned int
hb_buffer_get_length (hb_buffer_t *buffer)
{
return buffer->len;
}
/**
* hb_buffer_get_glyph_infos:
* @buffer: a buffer.
* @length: (out): output array length.
*
* Returns buffer glyph information array. Returned pointer
* is valid as long as buffer contents are not modified.
*
* Return value: (transfer none) (array length=length): buffer glyph information array.
*
* Since: 1.0
**/
/* Return value valid as long as buffer not modified */
hb_glyph_info_t *
hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
unsigned int *length)
@ -1142,18 +870,7 @@ hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
return (hb_glyph_info_t *) buffer->info;
}
/**
* hb_buffer_get_glyph_positions:
* @buffer: a buffer.
* @length: (out): output length.
*
* Returns buffer glyph position array. Returned pointer
* is valid as long as buffer contents are not modified.
*
* Return value: (transfer none) (array length=length): buffer glyph position array.
*
* Since: 1.0
**/
/* Return value valid as long as buffer not modified */
hb_glyph_position_t *
hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
unsigned int *length)
@ -1167,60 +884,18 @@ hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
return (hb_glyph_position_t *) buffer->pos;
}
/**
* hb_buffer_reverse:
* @buffer: a buffer.
*
* Reverses buffer contents.
*
* Since: 1.0
**/
void
hb_buffer_reverse (hb_buffer_t *buffer)
{
buffer->reverse ();
}
/**
* hb_buffer_reverse_clusters:
* @buffer: a buffer.
*
* Reverses buffer clusters. That is, the buffer contents are
* reversed, then each cluster (consecutive items having the
* same cluster number) are reversed again.
*
* Since: 1.0
**/
void
hb_buffer_reverse_clusters (hb_buffer_t *buffer)
{
buffer->reverse_clusters ();
}
/**
* hb_buffer_guess_segment_properties:
* @buffer: a buffer.
*
* Sets unset buffer segment properties based on buffer Unicode
* contents. If buffer is not empty, it must have content type
* %HB_BUFFER_CONTENT_TYPE_UNICODE.
*
* If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it
* will be set to the Unicode script of the first character in
* the buffer that has a script other than %HB_SCRIPT_COMMON,
* %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN.
*
* Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID),
* it will be set to the natural horizontal direction of the
* buffer script as returned by hb_script_get_horizontal_direction().
*
* Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID),
* it will be set to the process's default language as returned by
* hb_language_get_default(). This may change in the future by
* taking buffer script into consideration when choosing a language.
*
* Since: 1.0
**/
void
hb_buffer_guess_segment_properties (hb_buffer_t *buffer)
{
@ -1293,18 +968,6 @@ hb_buffer_add_utf (hb_buffer_t *buffer,
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
}
/**
* hb_buffer_add_utf8:
* @buffer: a buffer.
* @text: (array length=text_length):
* @text_length:
* @item_offset:
* @item_length:
*
*
*
* Since: 1.0
**/
void
hb_buffer_add_utf8 (hb_buffer_t *buffer,
const char *text,
@ -1315,40 +978,16 @@ hb_buffer_add_utf8 (hb_buffer_t *buffer,
hb_buffer_add_utf (buffer, (const uint8_t *) text, text_length, item_offset, item_length);
}
/**
* hb_buffer_add_utf16:
* @buffer: a buffer.
* @text: (array length=text_length):
* @text_length:
* @item_offset:
* @item_length:
*
*
*
* Since: 1.0
**/
void
hb_buffer_add_utf16 (hb_buffer_t *buffer,
const uint16_t *text,
int text_length,
unsigned int item_offset,
int item_length)
int item_length)
{
hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length);
}
/**
* hb_buffer_add_utf32:
* @buffer: a buffer.
* @text: (array length=text_length):
* @text_length:
* @item_offset:
* @item_length:
*
*
*
* Since: 1.0
**/
void
hb_buffer_add_utf32 (hb_buffer_t *buffer,
const uint32_t *text,
@ -1415,14 +1054,6 @@ normalize_glyphs_cluster (hb_buffer_t *buffer,
}
}
/**
* hb_buffer_normalize_glyphs:
* @buffer: a buffer.
*
*
*
* Since: 1.0
**/
void
hb_buffer_normalize_glyphs (hb_buffer_t *buffer)
{

View File

@ -171,8 +171,8 @@ void
hb_buffer_guess_segment_properties (hb_buffer_t *buffer);
typedef enum { /*< flags >*/
HB_BUFFER_FLAG_DEFAULT = 0x00000000,
typedef enum {
HB_BUFFER_FLAGS_DEFAULT = 0x00000000,
HB_BUFFER_FLAG_BOT = 0x00000001, /* Beginning-of-text */
HB_BUFFER_FLAG_EOT = 0x00000002, /* End-of-text */
HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004
@ -274,8 +274,8 @@ hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
* Serialize
*/
typedef enum { /*< flags >*/
HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000,
typedef enum {
HB_BUFFER_SERIALIZE_FLAGS_DEFAULT = 0x00000000,
HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001,
HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002,
HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004

View File

@ -57,45 +57,25 @@ _hb_options_init (void)
/* hb_tag_t */
/**
* hb_tag_from_string:
* @str: (array length=len):
* @len:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_tag_t
hb_tag_from_string (const char *str, int len)
hb_tag_from_string (const char *s, int len)
{
char tag[4];
unsigned int i;
if (!str || !len || !*str)
if (!s || !len || !*s)
return HB_TAG_NONE;
if (len < 0 || len > 4)
len = 4;
for (i = 0; i < (unsigned) len && str[i]; i++)
tag[i] = str[i];
for (i = 0; i < (unsigned) len && s[i]; i++)
tag[i] = s[i];
for (; i < 4; i++)
tag[i] = ' ';
return HB_TAG_CHAR4 (tag);
}
/**
* hb_tag_to_string:
* @tag:
* @buf: (array fixed-size=4):
*
*
*
* Since: 1.0
**/
void
hb_tag_to_string (hb_tag_t tag, char *buf)
{
@ -115,17 +95,6 @@ const char direction_strings[][4] = {
"btt"
};
/**
* hb_direction_from_string:
* @str: (array length=len):
* @len:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_direction_t
hb_direction_from_string (const char *str, int len)
{
@ -143,16 +112,6 @@ hb_direction_from_string (const char *str, int len)
return HB_DIRECTION_INVALID;
}
/**
* hb_direction_to_string:
* @direction:
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
const char *
hb_direction_to_string (hb_direction_t direction)
{
@ -228,7 +187,7 @@ struct hb_language_item_t {
return *this;
}
void finish (void) { free ((void *) lang); }
void finish (void) { free (lang); }
};
@ -278,27 +237,14 @@ retry:
}
/**
* hb_language_from_string:
* @str: (array length=len):
* @len:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_language_t
hb_language_from_string (const char *str, int len)
{
char strbuf[64];
if (!str || !len || !*str)
return HB_LANGUAGE_INVALID;
if (len >= 0)
{
char strbuf[32];
if (len >= 0) {
len = MIN (len, (int) sizeof (strbuf) - 1);
str = (char *) memcpy (strbuf, str, len);
strbuf[len] = '\0';
@ -309,16 +255,6 @@ hb_language_from_string (const char *str, int len)
return likely (item) ? item->lang : HB_LANGUAGE_INVALID;
}
/**
* hb_language_to_string:
* @language:
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
const char *
hb_language_to_string (hb_language_t language)
{
@ -326,15 +262,6 @@ hb_language_to_string (hb_language_t language)
return language->s;
}
/**
* hb_language_get_default:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_language_t
hb_language_get_default (void)
{
@ -352,16 +279,6 @@ hb_language_get_default (void)
/* hb_script_t */
/**
* hb_script_from_iso15924_tag:
* @tag:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_script_t
hb_script_from_iso15924_tag (hb_tag_t tag)
{
@ -396,49 +313,18 @@ hb_script_from_iso15924_tag (hb_tag_t tag)
return HB_SCRIPT_UNKNOWN;
}
/**
* hb_script_from_string:
* @s: (array length=len):
* @len:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_script_t
hb_script_from_string (const char *s, int len)
{
return hb_script_from_iso15924_tag (hb_tag_from_string (s, len));
}
/**
* hb_script_to_iso15924_tag:
* @script:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_tag_t
hb_script_to_iso15924_tag (hb_script_t script)
{
return (hb_tag_t) script;
}
/**
* hb_script_get_horizontal_direction:
* @script:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_direction_t
hb_script_get_horizontal_direction (hb_script_t script)
{
@ -523,16 +409,6 @@ hb_user_data_array_t::get (hb_user_data_key_t *key)
/* hb_version */
/**
* hb_version:
* @major: (out): Library major version component.
* @minor: (out): Library minor version component.
* @micro: (out): Library micro version component.
*
* Returns library version as three integer components.
*
* Since: 1.0
**/
void
hb_version (unsigned int *major,
unsigned int *minor,
@ -543,33 +419,12 @@ hb_version (unsigned int *major,
*micro = HB_VERSION_MICRO;
}
/**
* hb_version_string:
*
* Returns library version as a string with three components.
*
* Return value: library version string.
*
* Since: 1.0
**/
const char *
hb_version_string (void)
{
return HB_VERSION_STRING;
}
/**
* hb_version_check:
* @major:
* @minor:
* @micro:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_version_check (unsigned int major,
unsigned int minor,

View File

@ -131,7 +131,7 @@ hb_direction_to_string (hb_direction_t direction);
/* hb_language_t */
typedef const struct hb_language_impl_t *hb_language_t;
typedef struct hb_language_impl_t *hb_language_t;
/* len=-1 means str is NUL-terminated */
hb_language_t
@ -153,153 +153,137 @@ hb_language_get_default (void);
/* Unicode Character Database property: Script (sc) */
typedef enum
{
/*1.1*/ HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'),
/*1.1*/ HB_SCRIPT_INHERITED = HB_TAG ('Z','i','n','h'),
/*5.0*/ HB_SCRIPT_UNKNOWN = HB_TAG ('Z','z','z','z'),
/* Unicode-1.1 additions */
HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'),
HB_SCRIPT_ARABIC = HB_TAG ('A','r','a','b'),
HB_SCRIPT_ARMENIAN = HB_TAG ('A','r','m','n'),
HB_SCRIPT_BENGALI = HB_TAG ('B','e','n','g'),
HB_SCRIPT_BOPOMOFO = HB_TAG ('B','o','p','o'),
HB_SCRIPT_CANADIAN_ABORIGINAL = HB_TAG ('C','a','n','s'),
HB_SCRIPT_CHEROKEE = HB_TAG ('C','h','e','r'),
HB_SCRIPT_COPTIC = HB_TAG ('C','o','p','t'),
HB_SCRIPT_CYRILLIC = HB_TAG ('C','y','r','l'),
HB_SCRIPT_DEVANAGARI = HB_TAG ('D','e','v','a'),
HB_SCRIPT_GEORGIAN = HB_TAG ('G','e','o','r'),
HB_SCRIPT_GREEK = HB_TAG ('G','r','e','k'),
HB_SCRIPT_GUJARATI = HB_TAG ('G','u','j','r'),
HB_SCRIPT_GURMUKHI = HB_TAG ('G','u','r','u'),
HB_SCRIPT_HANGUL = HB_TAG ('H','a','n','g'),
HB_SCRIPT_HAN = HB_TAG ('H','a','n','i'),
HB_SCRIPT_HEBREW = HB_TAG ('H','e','b','r'),
HB_SCRIPT_HIRAGANA = HB_TAG ('H','i','r','a'),
HB_SCRIPT_INHERITED = HB_TAG ('Z','i','n','h'),
HB_SCRIPT_KANNADA = HB_TAG ('K','n','d','a'),
HB_SCRIPT_KATAKANA = HB_TAG ('K','a','n','a'),
HB_SCRIPT_LAO = HB_TAG ('L','a','o','o'),
HB_SCRIPT_LATIN = HB_TAG ('L','a','t','n'),
HB_SCRIPT_MALAYALAM = HB_TAG ('M','l','y','m'),
HB_SCRIPT_MONGOLIAN = HB_TAG ('M','o','n','g'),
HB_SCRIPT_OGHAM = HB_TAG ('O','g','a','m'),
HB_SCRIPT_ORIYA = HB_TAG ('O','r','y','a'),
HB_SCRIPT_RUNIC = HB_TAG ('R','u','n','r'),
HB_SCRIPT_SYRIAC = HB_TAG ('S','y','r','c'),
HB_SCRIPT_TAMIL = HB_TAG ('T','a','m','l'),
HB_SCRIPT_TELUGU = HB_TAG ('T','e','l','u'),
HB_SCRIPT_THAI = HB_TAG ('T','h','a','i'),
HB_SCRIPT_YI = HB_TAG ('Y','i','i','i'),
/*1.1*/ HB_SCRIPT_ARABIC = HB_TAG ('A','r','a','b'),
/*1.1*/ HB_SCRIPT_ARMENIAN = HB_TAG ('A','r','m','n'),
/*1.1*/ HB_SCRIPT_BENGALI = HB_TAG ('B','e','n','g'),
/*1.1*/ HB_SCRIPT_CYRILLIC = HB_TAG ('C','y','r','l'),
/*1.1*/ HB_SCRIPT_DEVANAGARI = HB_TAG ('D','e','v','a'),
/*1.1*/ HB_SCRIPT_GEORGIAN = HB_TAG ('G','e','o','r'),
/*1.1*/ HB_SCRIPT_GREEK = HB_TAG ('G','r','e','k'),
/*1.1*/ HB_SCRIPT_GUJARATI = HB_TAG ('G','u','j','r'),
/*1.1*/ HB_SCRIPT_GURMUKHI = HB_TAG ('G','u','r','u'),
/*1.1*/ HB_SCRIPT_HANGUL = HB_TAG ('H','a','n','g'),
/*1.1*/ HB_SCRIPT_HAN = HB_TAG ('H','a','n','i'),
/*1.1*/ HB_SCRIPT_HEBREW = HB_TAG ('H','e','b','r'),
/*1.1*/ HB_SCRIPT_HIRAGANA = HB_TAG ('H','i','r','a'),
/*1.1*/ HB_SCRIPT_KANNADA = HB_TAG ('K','n','d','a'),
/*1.1*/ HB_SCRIPT_KATAKANA = HB_TAG ('K','a','n','a'),
/*1.1*/ HB_SCRIPT_LAO = HB_TAG ('L','a','o','o'),
/*1.1*/ HB_SCRIPT_LATIN = HB_TAG ('L','a','t','n'),
/*1.1*/ HB_SCRIPT_MALAYALAM = HB_TAG ('M','l','y','m'),
/*1.1*/ HB_SCRIPT_ORIYA = HB_TAG ('O','r','y','a'),
/*1.1*/ HB_SCRIPT_TAMIL = HB_TAG ('T','a','m','l'),
/*1.1*/ HB_SCRIPT_TELUGU = HB_TAG ('T','e','l','u'),
/*1.1*/ HB_SCRIPT_THAI = HB_TAG ('T','h','a','i'),
/* Unicode-2.0 additions */
HB_SCRIPT_TIBETAN = HB_TAG ('T','i','b','t'),
/*2.0*/ HB_SCRIPT_TIBETAN = HB_TAG ('T','i','b','t'),
/* Unicode-3.0 additions */
HB_SCRIPT_ETHIOPIC = HB_TAG ('E','t','h','i'),
HB_SCRIPT_KHMER = HB_TAG ('K','h','m','r'),
HB_SCRIPT_MYANMAR = HB_TAG ('M','y','m','r'),
HB_SCRIPT_SINHALA = HB_TAG ('S','i','n','h'),
HB_SCRIPT_THAANA = HB_TAG ('T','h','a','a'),
/*3.0*/ HB_SCRIPT_BOPOMOFO = HB_TAG ('B','o','p','o'),
/*3.0*/ HB_SCRIPT_BRAILLE = HB_TAG ('B','r','a','i'),
/*3.0*/ HB_SCRIPT_CANADIAN_SYLLABICS = HB_TAG ('C','a','n','s'),
/*3.0*/ HB_SCRIPT_CHEROKEE = HB_TAG ('C','h','e','r'),
/*3.0*/ HB_SCRIPT_ETHIOPIC = HB_TAG ('E','t','h','i'),
/*3.0*/ HB_SCRIPT_KHMER = HB_TAG ('K','h','m','r'),
/*3.0*/ HB_SCRIPT_MONGOLIAN = HB_TAG ('M','o','n','g'),
/*3.0*/ HB_SCRIPT_MYANMAR = HB_TAG ('M','y','m','r'),
/*3.0*/ HB_SCRIPT_OGHAM = HB_TAG ('O','g','a','m'),
/*3.0*/ HB_SCRIPT_RUNIC = HB_TAG ('R','u','n','r'),
/*3.0*/ HB_SCRIPT_SINHALA = HB_TAG ('S','i','n','h'),
/*3.0*/ HB_SCRIPT_SYRIAC = HB_TAG ('S','y','r','c'),
/*3.0*/ HB_SCRIPT_THAANA = HB_TAG ('T','h','a','a'),
/*3.0*/ HB_SCRIPT_YI = HB_TAG ('Y','i','i','i'),
/* Unicode-3.1 additions */
HB_SCRIPT_DESERET = HB_TAG ('D','s','r','t'),
HB_SCRIPT_GOTHIC = HB_TAG ('G','o','t','h'),
HB_SCRIPT_OLD_ITALIC = HB_TAG ('I','t','a','l'),
/*3.1*/ HB_SCRIPT_DESERET = HB_TAG ('D','s','r','t'),
/*3.1*/ HB_SCRIPT_GOTHIC = HB_TAG ('G','o','t','h'),
/*3.1*/ HB_SCRIPT_OLD_ITALIC = HB_TAG ('I','t','a','l'),
/* Unicode-3.2 additions */
HB_SCRIPT_BUHID = HB_TAG ('B','u','h','d'),
HB_SCRIPT_HANUNOO = HB_TAG ('H','a','n','o'),
HB_SCRIPT_TAGALOG = HB_TAG ('T','g','l','g'),
HB_SCRIPT_TAGBANWA = HB_TAG ('T','a','g','b'),
/*3.2*/ HB_SCRIPT_BUHID = HB_TAG ('B','u','h','d'),
/*3.2*/ HB_SCRIPT_HANUNOO = HB_TAG ('H','a','n','o'),
/*3.2*/ HB_SCRIPT_TAGALOG = HB_TAG ('T','g','l','g'),
/*3.2*/ HB_SCRIPT_TAGBANWA = HB_TAG ('T','a','g','b'),
/* Unicode-4.0 additions */
HB_SCRIPT_BRAILLE = HB_TAG ('B','r','a','i'),
HB_SCRIPT_CYPRIOT = HB_TAG ('C','p','r','t'),
HB_SCRIPT_LIMBU = HB_TAG ('L','i','m','b'),
HB_SCRIPT_LINEAR_B = HB_TAG ('L','i','n','b'),
HB_SCRIPT_OSMANYA = HB_TAG ('O','s','m','a'),
HB_SCRIPT_SHAVIAN = HB_TAG ('S','h','a','w'),
HB_SCRIPT_TAI_LE = HB_TAG ('T','a','l','e'),
HB_SCRIPT_UGARITIC = HB_TAG ('U','g','a','r'),
/*4.0*/ HB_SCRIPT_CYPRIOT = HB_TAG ('C','p','r','t'),
/*4.0*/ HB_SCRIPT_LIMBU = HB_TAG ('L','i','m','b'),
/*4.0*/ HB_SCRIPT_LINEAR_B = HB_TAG ('L','i','n','b'),
/*4.0*/ HB_SCRIPT_OSMANYA = HB_TAG ('O','s','m','a'),
/*4.0*/ HB_SCRIPT_SHAVIAN = HB_TAG ('S','h','a','w'),
/*4.0*/ HB_SCRIPT_TAI_LE = HB_TAG ('T','a','l','e'),
/*4.0*/ HB_SCRIPT_UGARITIC = HB_TAG ('U','g','a','r'),
/* Unicode-4.1 additions */
HB_SCRIPT_BUGINESE = HB_TAG ('B','u','g','i'),
HB_SCRIPT_GLAGOLITIC = HB_TAG ('G','l','a','g'),
HB_SCRIPT_KHAROSHTHI = HB_TAG ('K','h','a','r'),
HB_SCRIPT_NEW_TAI_LUE = HB_TAG ('T','a','l','u'),
HB_SCRIPT_OLD_PERSIAN = HB_TAG ('X','p','e','o'),
HB_SCRIPT_SYLOTI_NAGRI = HB_TAG ('S','y','l','o'),
HB_SCRIPT_TIFINAGH = HB_TAG ('T','f','n','g'),
/*4.1*/ HB_SCRIPT_BUGINESE = HB_TAG ('B','u','g','i'),
/*4.1*/ HB_SCRIPT_COPTIC = HB_TAG ('C','o','p','t'),
/*4.1*/ HB_SCRIPT_GLAGOLITIC = HB_TAG ('G','l','a','g'),
/*4.1*/ HB_SCRIPT_KHAROSHTHI = HB_TAG ('K','h','a','r'),
/*4.1*/ HB_SCRIPT_NEW_TAI_LUE = HB_TAG ('T','a','l','u'),
/*4.1*/ HB_SCRIPT_OLD_PERSIAN = HB_TAG ('X','p','e','o'),
/*4.1*/ HB_SCRIPT_SYLOTI_NAGRI = HB_TAG ('S','y','l','o'),
/*4.1*/ HB_SCRIPT_TIFINAGH = HB_TAG ('T','f','n','g'),
/* Unicode-5.0 additions */
HB_SCRIPT_BALINESE = HB_TAG ('B','a','l','i'),
HB_SCRIPT_CUNEIFORM = HB_TAG ('X','s','u','x'),
HB_SCRIPT_NKO = HB_TAG ('N','k','o','o'),
HB_SCRIPT_PHAGS_PA = HB_TAG ('P','h','a','g'),
HB_SCRIPT_PHOENICIAN = HB_TAG ('P','h','n','x'),
HB_SCRIPT_UNKNOWN = HB_TAG ('Z','z','z','z'),
/*5.0*/ HB_SCRIPT_BALINESE = HB_TAG ('B','a','l','i'),
/*5.0*/ HB_SCRIPT_CUNEIFORM = HB_TAG ('X','s','u','x'),
/*5.0*/ HB_SCRIPT_NKO = HB_TAG ('N','k','o','o'),
/*5.0*/ HB_SCRIPT_PHAGS_PA = HB_TAG ('P','h','a','g'),
/*5.0*/ HB_SCRIPT_PHOENICIAN = HB_TAG ('P','h','n','x'),
/* Unicode-5.1 additions */
HB_SCRIPT_CARIAN = HB_TAG ('C','a','r','i'),
HB_SCRIPT_CHAM = HB_TAG ('C','h','a','m'),
HB_SCRIPT_KAYAH_LI = HB_TAG ('K','a','l','i'),
HB_SCRIPT_LEPCHA = HB_TAG ('L','e','p','c'),
HB_SCRIPT_LYCIAN = HB_TAG ('L','y','c','i'),
HB_SCRIPT_LYDIAN = HB_TAG ('L','y','d','i'),
HB_SCRIPT_OL_CHIKI = HB_TAG ('O','l','c','k'),
HB_SCRIPT_REJANG = HB_TAG ('R','j','n','g'),
HB_SCRIPT_SAURASHTRA = HB_TAG ('S','a','u','r'),
HB_SCRIPT_SUNDANESE = HB_TAG ('S','u','n','d'),
HB_SCRIPT_VAI = HB_TAG ('V','a','i','i'),
/*5.1*/ HB_SCRIPT_CARIAN = HB_TAG ('C','a','r','i'),
/*5.1*/ HB_SCRIPT_CHAM = HB_TAG ('C','h','a','m'),
/*5.1*/ HB_SCRIPT_KAYAH_LI = HB_TAG ('K','a','l','i'),
/*5.1*/ HB_SCRIPT_LEPCHA = HB_TAG ('L','e','p','c'),
/*5.1*/ HB_SCRIPT_LYCIAN = HB_TAG ('L','y','c','i'),
/*5.1*/ HB_SCRIPT_LYDIAN = HB_TAG ('L','y','d','i'),
/*5.1*/ HB_SCRIPT_OL_CHIKI = HB_TAG ('O','l','c','k'),
/*5.1*/ HB_SCRIPT_REJANG = HB_TAG ('R','j','n','g'),
/*5.1*/ HB_SCRIPT_SAURASHTRA = HB_TAG ('S','a','u','r'),
/*5.1*/ HB_SCRIPT_SUNDANESE = HB_TAG ('S','u','n','d'),
/*5.1*/ HB_SCRIPT_VAI = HB_TAG ('V','a','i','i'),
/* Unicode-5.2 additions */
HB_SCRIPT_AVESTAN = HB_TAG ('A','v','s','t'),
HB_SCRIPT_BAMUM = HB_TAG ('B','a','m','u'),
HB_SCRIPT_EGYPTIAN_HIEROGLYPHS = HB_TAG ('E','g','y','p'),
HB_SCRIPT_IMPERIAL_ARAMAIC = HB_TAG ('A','r','m','i'),
HB_SCRIPT_INSCRIPTIONAL_PAHLAVI = HB_TAG ('P','h','l','i'),
HB_SCRIPT_INSCRIPTIONAL_PARTHIAN = HB_TAG ('P','r','t','i'),
HB_SCRIPT_JAVANESE = HB_TAG ('J','a','v','a'),
HB_SCRIPT_KAITHI = HB_TAG ('K','t','h','i'),
HB_SCRIPT_LISU = HB_TAG ('L','i','s','u'),
HB_SCRIPT_MEETEI_MAYEK = HB_TAG ('M','t','e','i'),
HB_SCRIPT_OLD_SOUTH_ARABIAN = HB_TAG ('S','a','r','b'),
HB_SCRIPT_OLD_TURKIC = HB_TAG ('O','r','k','h'),
HB_SCRIPT_SAMARITAN = HB_TAG ('S','a','m','r'),
HB_SCRIPT_TAI_THAM = HB_TAG ('L','a','n','a'),
HB_SCRIPT_TAI_VIET = HB_TAG ('T','a','v','t'),
/*5.2*/ HB_SCRIPT_AVESTAN = HB_TAG ('A','v','s','t'),
/*5.2*/ HB_SCRIPT_BAMUM = HB_TAG ('B','a','m','u'),
/*5.2*/ HB_SCRIPT_EGYPTIAN_HIEROGLYPHS = HB_TAG ('E','g','y','p'),
/*5.2*/ HB_SCRIPT_IMPERIAL_ARAMAIC = HB_TAG ('A','r','m','i'),
/*5.2*/ HB_SCRIPT_INSCRIPTIONAL_PAHLAVI = HB_TAG ('P','h','l','i'),
/*5.2*/ HB_SCRIPT_INSCRIPTIONAL_PARTHIAN = HB_TAG ('P','r','t','i'),
/*5.2*/ HB_SCRIPT_JAVANESE = HB_TAG ('J','a','v','a'),
/*5.2*/ HB_SCRIPT_KAITHI = HB_TAG ('K','t','h','i'),
/*5.2*/ HB_SCRIPT_LISU = HB_TAG ('L','i','s','u'),
/*5.2*/ HB_SCRIPT_MEETEI_MAYEK = HB_TAG ('M','t','e','i'),
/*5.2*/ HB_SCRIPT_OLD_SOUTH_ARABIAN = HB_TAG ('S','a','r','b'),
/*5.2*/ HB_SCRIPT_OLD_TURKIC = HB_TAG ('O','r','k','h'),
/*5.2*/ HB_SCRIPT_SAMARITAN = HB_TAG ('S','a','m','r'),
/*5.2*/ HB_SCRIPT_TAI_THAM = HB_TAG ('L','a','n','a'),
/*5.2*/ HB_SCRIPT_TAI_VIET = HB_TAG ('T','a','v','t'),
/* Unicode-6.0 additions */
HB_SCRIPT_BATAK = HB_TAG ('B','a','t','k'),
HB_SCRIPT_BRAHMI = HB_TAG ('B','r','a','h'),
HB_SCRIPT_MANDAIC = HB_TAG ('M','a','n','d'),
/*6.0*/ HB_SCRIPT_BATAK = HB_TAG ('B','a','t','k'),
/*6.0*/ HB_SCRIPT_BRAHMI = HB_TAG ('B','r','a','h'),
/*6.0*/ HB_SCRIPT_MANDAIC = HB_TAG ('M','a','n','d'),
/* Unicode-6.1 additions */
HB_SCRIPT_CHAKMA = HB_TAG ('C','a','k','m'),
HB_SCRIPT_MEROITIC_CURSIVE = HB_TAG ('M','e','r','c'),
HB_SCRIPT_MEROITIC_HIEROGLYPHS = HB_TAG ('M','e','r','o'),
HB_SCRIPT_MIAO = HB_TAG ('P','l','r','d'),
HB_SCRIPT_SHARADA = HB_TAG ('S','h','r','d'),
HB_SCRIPT_SORA_SOMPENG = HB_TAG ('S','o','r','a'),
HB_SCRIPT_TAKRI = HB_TAG ('T','a','k','r'),
/*6.1*/ HB_SCRIPT_CHAKMA = HB_TAG ('C','a','k','m'),
/*6.1*/ HB_SCRIPT_MEROITIC_CURSIVE = HB_TAG ('M','e','r','c'),
/*6.1*/ HB_SCRIPT_MEROITIC_HIEROGLYPHS = HB_TAG ('M','e','r','o'),
/*6.1*/ HB_SCRIPT_MIAO = HB_TAG ('P','l','r','d'),
/*6.1*/ HB_SCRIPT_SHARADA = HB_TAG ('S','h','r','d'),
/*6.1*/ HB_SCRIPT_SORA_SOMPENG = HB_TAG ('S','o','r','a'),
/*6.1*/ HB_SCRIPT_TAKRI = HB_TAG ('T','a','k','r'),
/* No script set. */
/*---*/ HB_SCRIPT_INVALID = HB_TAG_NONE
/* No script set */
HB_SCRIPT_INVALID = HB_TAG_NONE
} hb_script_t;
/* These are moved out of hb_script_t because glib-mkenums chokes otherwise. */
#if 0
/*7.0*/ HB_SCRIPT_BASSA_VAH = HB_TAG ('B','a','s','s'),
/*7.0*/ HB_SCRIPT_CAUCASIAN_ALBANIAN = HB_TAG ('A','g','h','b'),
/*7.0*/ HB_SCRIPT_DUPLOYAN = HB_TAG ('D','u','p','l'),
/*7.0*/ HB_SCRIPT_ELBASAN = HB_TAG ('E','l','b','a'),
/*7.0*/ HB_SCRIPT_GRANTHA = HB_TAG ('G','r','a','n'),
/*7.0*/ HB_SCRIPT_KHOJKI = HB_TAG ('K','h','o','j'),
/*7.0*/ HB_SCRIPT_KHUDAWADI = HB_TAG ('S','i','n','d'),
/*7.0*/ HB_SCRIPT_LINEAR_A = HB_TAG ('L','i','n','a'),
/*7.0*/ HB_SCRIPT_MAHAJANI = HB_TAG ('M','a','h','j'),
/*7.0*/ HB_SCRIPT_MANICHAEAN = HB_TAG ('M','a','n','i'),
/*7.0*/ HB_SCRIPT_MENDE_KIKAKUI = HB_TAG ('M','e','n','d'),
/*7.0*/ HB_SCRIPT_MODI = ???
/*7.0*/ HB_SCRIPT_MRO = HB_TAG ('M','r','o','o'),
/*7.0*/ HB_SCRIPT_NABATAEAN = HB_TAG ('N','b','a','t'),
/*7.0*/ HB_SCRIPT_OLD_NORTH_ARABIAN = HB_TAG ('N','a','r','b'),
/*7.0*/ HB_SCRIPT_OLD_PERMIC = HB_TAG ('P','e','r','m'),
/*7.0*/ HB_SCRIPT_PAHAWH_HMONG = HB_TAG ('H','m','n','g'),
/*7.0*/ HB_SCRIPT_PALMYRENE = HB_TAG ('P','a','l','m'),
/*7.0*/ HB_SCRIPT_PAU_CIN_HAU = ???
/*7.0*/ HB_SCRIPT_PSALTER_PAHLAVI = HB_TAG ('P','h','l','p'),
/*7.0*/ HB_SCRIPT_SIDDHAM = ???
/*7.0*/ HB_SCRIPT_TIRHUTA = HB_TAG ('T','i','r','h'),
/*7.0*/ HB_SCRIPT_WARANG_CITI = HB_TAG ('W','a','r','a'),
#endif
/* Script functions */

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2012,2013 Mozilla Foundation.
* Copyright © 2012,2013 Google, Inc.
* Copyright © 2012 Mozilla Foundation.
* Copyright © 2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@ -170,222 +170,6 @@ hb_coretext_font_get_ct_font (hb_font_t *font)
* shaper
*/
struct feature_record_t {
unsigned int feature;
unsigned int setting;
};
struct active_feature_t {
feature_record_t rec;
unsigned int order;
static int cmp (const active_feature_t *a, const active_feature_t *b) {
return a->rec.feature < b->rec.feature ? -1 : a->rec.feature > b->rec.feature ? 1 :
a->order < b->order ? -1 : a->order > b->order ? 1 :
a->rec.setting < b->rec.setting ? -1 : a->rec.setting > b->rec.setting ? 1 :
0;
}
bool operator== (const active_feature_t *f) {
return cmp (this, f) == 0;
}
};
struct feature_event_t {
unsigned int index;
bool start;
active_feature_t feature;
static int cmp (const feature_event_t *a, const feature_event_t *b) {
return a->index < b->index ? -1 : a->index > b->index ? 1 :
a->start < b->start ? -1 : a->start > b->start ? 1 :
active_feature_t::cmp (&a->feature, &b->feature);
}
};
struct range_record_t {
CTFontRef font;
unsigned int index_first; /* == start */
unsigned int index_last; /* == end - 1 */
};
/* The following enum members are added in OS X 10.8. */
#define kAltHalfWidthTextSelector 6
#define kAltProportionalTextSelector 5
#define kAlternateHorizKanaOffSelector 1
#define kAlternateHorizKanaOnSelector 0
#define kAlternateKanaType 34
#define kAlternateVertKanaOffSelector 3
#define kAlternateVertKanaOnSelector 2
#define kCaseSensitiveLayoutOffSelector 1
#define kCaseSensitiveLayoutOnSelector 0
#define kCaseSensitiveLayoutType 33
#define kCaseSensitiveSpacingOffSelector 3
#define kCaseSensitiveSpacingOnSelector 2
#define kContextualAlternatesOffSelector 1
#define kContextualAlternatesOnSelector 0
#define kContextualAlternatesType 36
#define kContextualLigaturesOffSelector 19
#define kContextualLigaturesOnSelector 18
#define kContextualSwashAlternatesOffSelector 5
#define kContextualSwashAlternatesOnSelector 4
#define kDefaultLowerCaseSelector 0
#define kDefaultUpperCaseSelector 0
#define kHistoricalLigaturesOffSelector 21
#define kHistoricalLigaturesOnSelector 20
#define kHojoCharactersSelector 12
#define kJIS2004CharactersSelector 11
#define kLowerCasePetiteCapsSelector 2
#define kLowerCaseSmallCapsSelector 1
#define kLowerCaseType 37
#define kMathematicalGreekOffSelector 11
#define kMathematicalGreekOnSelector 10
#define kNLCCharactersSelector 13
#define kQuarterWidthTextSelector 4
#define kScientificInferiorsSelector 4
#define kStylisticAltEightOffSelector 17
#define kStylisticAltEightOnSelector 16
#define kStylisticAltEighteenOffSelector 37
#define kStylisticAltEighteenOnSelector 36
#define kStylisticAltElevenOffSelector 23
#define kStylisticAltElevenOnSelector 22
#define kStylisticAltFifteenOffSelector 31
#define kStylisticAltFifteenOnSelector 30
#define kStylisticAltFiveOffSelector 11
#define kStylisticAltFiveOnSelector 10
#define kStylisticAltFourOffSelector 9
#define kStylisticAltFourOnSelector 8
#define kStylisticAltFourteenOffSelector 29
#define kStylisticAltFourteenOnSelector 28
#define kStylisticAltNineOffSelector 19
#define kStylisticAltNineOnSelector 18
#define kStylisticAltNineteenOffSelector 39
#define kStylisticAltNineteenOnSelector 38
#define kStylisticAltOneOffSelector 3
#define kStylisticAltOneOnSelector 2
#define kStylisticAltSevenOffSelector 15
#define kStylisticAltSevenOnSelector 14
#define kStylisticAltSeventeenOffSelector 35
#define kStylisticAltSeventeenOnSelector 34
#define kStylisticAltSixOffSelector 13
#define kStylisticAltSixOnSelector 12
#define kStylisticAltSixteenOffSelector 33
#define kStylisticAltSixteenOnSelector 32
#define kStylisticAltTenOffSelector 21
#define kStylisticAltTenOnSelector 20
#define kStylisticAltThirteenOffSelector 27
#define kStylisticAltThirteenOnSelector 26
#define kStylisticAltThreeOffSelector 7
#define kStylisticAltThreeOnSelector 6
#define kStylisticAltTwelveOffSelector 25
#define kStylisticAltTwelveOnSelector 24
#define kStylisticAltTwentyOffSelector 41
#define kStylisticAltTwentyOnSelector 40
#define kStylisticAltTwoOffSelector 5
#define kStylisticAltTwoOnSelector 4
#define kStylisticAlternativesType 35
#define kSwashAlternatesOffSelector 3
#define kSwashAlternatesOnSelector 2
#define kThirdWidthTextSelector 3
#define kTraditionalNamesCharactersSelector 14
#define kUpperCasePetiteCapsSelector 2
#define kUpperCaseSmallCapsSelector 1
#define kUpperCaseType 38
/* Table data courtesy of Apple. */
struct feature_mapping_t {
FourCharCode otFeatureTag;
uint16_t aatFeatureType;
uint16_t selectorToEnable;
uint16_t selectorToDisable;
} feature_mappings[] = {
{ 'c2pc', kUpperCaseType, kUpperCasePetiteCapsSelector, kDefaultUpperCaseSelector },
{ 'c2sc', kUpperCaseType, kUpperCaseSmallCapsSelector, kDefaultUpperCaseSelector },
{ 'calt', kContextualAlternatesType, kContextualAlternatesOnSelector, kContextualAlternatesOffSelector },
{ 'case', kCaseSensitiveLayoutType, kCaseSensitiveLayoutOnSelector, kCaseSensitiveLayoutOffSelector },
{ 'clig', kLigaturesType, kContextualLigaturesOnSelector, kContextualLigaturesOffSelector },
{ 'cpsp', kCaseSensitiveLayoutType, kCaseSensitiveSpacingOnSelector, kCaseSensitiveSpacingOffSelector },
{ 'cswh', kContextualAlternatesType, kContextualSwashAlternatesOnSelector, kContextualSwashAlternatesOffSelector },
{ 'dlig', kLigaturesType, kRareLigaturesOnSelector, kRareLigaturesOffSelector },
{ 'expt', kCharacterShapeType, kExpertCharactersSelector, 16 },
{ 'frac', kFractionsType, kDiagonalFractionsSelector, kNoFractionsSelector },
{ 'fwid', kTextSpacingType, kMonospacedTextSelector, 7 },
{ 'halt', kTextSpacingType, kAltHalfWidthTextSelector, 7 },
{ 'hist', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector },
{ 'hkna', kAlternateKanaType, kAlternateHorizKanaOnSelector, kAlternateHorizKanaOffSelector, },
{ 'hlig', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector },
{ 'hngl', kTransliterationType, kHanjaToHangulSelector, kNoTransliterationSelector },
{ 'hojo', kCharacterShapeType, kHojoCharactersSelector, 16 },
{ 'hwid', kTextSpacingType, kHalfWidthTextSelector, 7 },
{ 'ital', kItalicCJKRomanType, kCJKItalicRomanOnSelector, kCJKItalicRomanOffSelector },
{ 'jp04', kCharacterShapeType, kJIS2004CharactersSelector, 16 },
{ 'jp78', kCharacterShapeType, kJIS1978CharactersSelector, 16 },
{ 'jp83', kCharacterShapeType, kJIS1983CharactersSelector, 16 },
{ 'jp90', kCharacterShapeType, kJIS1990CharactersSelector, 16 },
{ 'liga', kLigaturesType, kCommonLigaturesOnSelector, kCommonLigaturesOffSelector },
{ 'lnum', kNumberCaseType, kUpperCaseNumbersSelector, 2 },
{ 'mgrk', kMathematicalExtrasType, kMathematicalGreekOnSelector, kMathematicalGreekOffSelector },
{ 'nlck', kCharacterShapeType, kNLCCharactersSelector, 16 },
{ 'onum', kNumberCaseType, kLowerCaseNumbersSelector, 2 },
{ 'ordn', kVerticalPositionType, kOrdinalsSelector, kNormalPositionSelector },
{ 'palt', kTextSpacingType, kAltProportionalTextSelector, 7 },
{ 'pcap', kLowerCaseType, kLowerCasePetiteCapsSelector, kDefaultLowerCaseSelector },
{ 'pkna', kTextSpacingType, kProportionalTextSelector, 7 },
{ 'pnum', kNumberSpacingType, kProportionalNumbersSelector, 4 },
{ 'pwid', kTextSpacingType, kProportionalTextSelector, 7 },
{ 'qwid', kTextSpacingType, kQuarterWidthTextSelector, 7 },
{ 'ruby', kRubyKanaType, kRubyKanaOnSelector, kRubyKanaOffSelector },
{ 'sinf', kVerticalPositionType, kScientificInferiorsSelector, kNormalPositionSelector },
{ 'smcp', kLowerCaseType, kLowerCaseSmallCapsSelector, kDefaultLowerCaseSelector },
{ 'smpl', kCharacterShapeType, kSimplifiedCharactersSelector, 16 },
{ 'ss01', kStylisticAlternativesType, kStylisticAltOneOnSelector, kStylisticAltOneOffSelector },
{ 'ss02', kStylisticAlternativesType, kStylisticAltTwoOnSelector, kStylisticAltTwoOffSelector },
{ 'ss03', kStylisticAlternativesType, kStylisticAltThreeOnSelector, kStylisticAltThreeOffSelector },
{ 'ss04', kStylisticAlternativesType, kStylisticAltFourOnSelector, kStylisticAltFourOffSelector },
{ 'ss05', kStylisticAlternativesType, kStylisticAltFiveOnSelector, kStylisticAltFiveOffSelector },
{ 'ss06', kStylisticAlternativesType, kStylisticAltSixOnSelector, kStylisticAltSixOffSelector },
{ 'ss07', kStylisticAlternativesType, kStylisticAltSevenOnSelector, kStylisticAltSevenOffSelector },
{ 'ss08', kStylisticAlternativesType, kStylisticAltEightOnSelector, kStylisticAltEightOffSelector },
{ 'ss09', kStylisticAlternativesType, kStylisticAltNineOnSelector, kStylisticAltNineOffSelector },
{ 'ss10', kStylisticAlternativesType, kStylisticAltTenOnSelector, kStylisticAltTenOffSelector },
{ 'ss11', kStylisticAlternativesType, kStylisticAltElevenOnSelector, kStylisticAltElevenOffSelector },
{ 'ss12', kStylisticAlternativesType, kStylisticAltTwelveOnSelector, kStylisticAltTwelveOffSelector },
{ 'ss13', kStylisticAlternativesType, kStylisticAltThirteenOnSelector, kStylisticAltThirteenOffSelector },
{ 'ss14', kStylisticAlternativesType, kStylisticAltFourteenOnSelector, kStylisticAltFourteenOffSelector },
{ 'ss15', kStylisticAlternativesType, kStylisticAltFifteenOnSelector, kStylisticAltFifteenOffSelector },
{ 'ss16', kStylisticAlternativesType, kStylisticAltSixteenOnSelector, kStylisticAltSixteenOffSelector },
{ 'ss17', kStylisticAlternativesType, kStylisticAltSeventeenOnSelector, kStylisticAltSeventeenOffSelector },
{ 'ss18', kStylisticAlternativesType, kStylisticAltEighteenOnSelector, kStylisticAltEighteenOffSelector },
{ 'ss19', kStylisticAlternativesType, kStylisticAltNineteenOnSelector, kStylisticAltNineteenOffSelector },
{ 'ss20', kStylisticAlternativesType, kStylisticAltTwentyOnSelector, kStylisticAltTwentyOffSelector },
{ 'subs', kVerticalPositionType, kInferiorsSelector, kNormalPositionSelector },
{ 'sups', kVerticalPositionType, kSuperiorsSelector, kNormalPositionSelector },
{ 'swsh', kContextualAlternatesType, kSwashAlternatesOnSelector, kSwashAlternatesOffSelector },
{ 'titl', kStyleOptionsType, kTitlingCapsSelector, kNoStyleOptionsSelector },
{ 'tnam', kCharacterShapeType, kTraditionalNamesCharactersSelector, 16 },
{ 'tnum', kNumberSpacingType, kMonospacedNumbersSelector, 4 },
{ 'trad', kCharacterShapeType, kTraditionalCharactersSelector, 16 },
{ 'twid', kTextSpacingType, kThirdWidthTextSelector, 7 },
{ 'unic', kLetterCaseType, 14, 15 },
{ 'valt', kTextSpacingType, kAltProportionalTextSelector, 7 },
{ 'vert', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector },
{ 'vhal', kTextSpacingType, kAltHalfWidthTextSelector, 7 },
{ 'vkna', kAlternateKanaType, kAlternateVertKanaOnSelector, kAlternateVertKanaOffSelector },
{ 'vpal', kTextSpacingType, kAltProportionalTextSelector, 7 },
{ 'vrt2', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector },
{ 'zero', kTypographicExtrasType, kSlashedZeroOnSelector, kSlashedZeroOffSelector },
};
static int
_hb_feature_mapping_cmp (const void *key_, const void *entry_)
{
unsigned int key = * (unsigned int *) key_;
const feature_mapping_t * entry = (const feature_mapping_t *) entry_;
return key < entry->otFeatureTag ? -1 :
key > entry->otFeatureTag ? 1 :
0;
}
hb_bool_t
_hb_coretext_shape (hb_shape_plan_t *shape_plan,
hb_font_t *font,
@ -394,158 +178,9 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
unsigned int num_features)
{
hb_face_t *face = font->face;
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
/*
* Set up features.
* (copied + modified from code from hb-uniscribe.cc)
*/
hb_auto_array_t<feature_record_t> feature_records;
hb_auto_array_t<range_record_t> range_records;
if (num_features)
{
/* Sort features by start/end events. */
hb_auto_array_t<feature_event_t> feature_events;
for (unsigned int i = 0; i < num_features; i++)
{
const feature_mapping_t * mapping = (const feature_mapping_t *) bsearch (&features[i].tag,
feature_mappings,
ARRAY_LENGTH (feature_mappings),
sizeof (feature_mappings[0]),
_hb_feature_mapping_cmp);
if (!mapping)
continue;
active_feature_t feature;
feature.rec.feature = mapping->aatFeatureType;
feature.rec.setting = features[i].value ? mapping->selectorToEnable : mapping->selectorToDisable;
feature.order = i;
feature_event_t *event;
event = feature_events.push ();
if (unlikely (!event))
goto fail_features;
event->index = features[i].start;
event->start = true;
event->feature = feature;
event = feature_events.push ();
if (unlikely (!event))
goto fail_features;
event->index = features[i].end;
event->start = false;
event->feature = feature;
}
feature_events.sort ();
/* Add a strategic final event. */
{
active_feature_t feature;
feature.rec.feature = HB_TAG_NONE;
feature.rec.setting = 0;
feature.order = num_features + 1;
feature_event_t *event = feature_events.push ();
if (unlikely (!event))
goto fail_features;
event->index = 0; /* This value does magic. */
event->start = false;
event->feature = feature;
}
/* Scan events and save features for each range. */
hb_auto_array_t<active_feature_t> active_features;
unsigned int last_index = 0;
for (unsigned int i = 0; i < feature_events.len; i++)
{
feature_event_t *event = &feature_events[i];
if (event->index != last_index)
{
/* Save a snapshot of active features and the range. */
range_record_t *range = range_records.push ();
if (unlikely (!range))
goto fail_features;
unsigned int offset = feature_records.len;
if (active_features.len)
{
CFMutableArrayRef features_array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
/* TODO sort and resolve conflicting features? */
/* active_features.sort (); */
for (unsigned int j = 0; j < active_features.len; j++)
{
CFStringRef keys[2] = {
kCTFontFeatureTypeIdentifierKey,
kCTFontFeatureSelectorIdentifierKey
};
CFNumberRef values[2] = {
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.feature),
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting)
};
CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault,
(const void **) keys,
(const void **) values,
2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease (values[0]);
CFRelease (values[1]);
CFArrayAppendValue (features_array, dict);
CFRelease (dict);
}
CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault,
(const void **) &kCTFontFeatureSettingsAttribute,
(const void **) &features_array,
1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease (features_array);
CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes (attributes);
CFRelease (attributes);
range->font = CTFontCreateCopyWithAttributes (font_data->ct_font, 0.0, NULL, font_desc);
CFRelease (font_desc);
}
else
{
range->font = NULL;
}
range->index_first = last_index;
range->index_last = event->index - 1;
last_index = event->index;
}
if (event->start) {
active_feature_t *feature = active_features.push ();
if (unlikely (!feature))
goto fail_features;
*feature = event->feature;
} else {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
active_features.remove (feature - active_features.array);
}
}
if (!range_records.len) /* No active feature found. */
goto fail_features;
}
else
{
fail_features:
num_features = 0;
}
#define FAIL(...) \
HB_STMT_START { \
DEBUG_MSG (CORETEXT, NULL, __VA_ARGS__); \
@ -574,59 +209,22 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
#undef utf16_index
CFStringRef string_ref = CFStringCreateWithCharactersNoCopy (NULL,
CFStringRef string_ref = CFStringCreateWithCharactersNoCopy (kCFAllocatorDefault,
pchars, chars_len,
kCFAllocatorNull);
CFMutableAttributedStringRef attr_string = CFAttributedStringCreateMutable (NULL, chars_len);
CFAttributedStringReplaceString (attr_string, CFRangeMake (0, 0), string_ref);
CFDictionaryRef attrs = CFDictionaryCreate (kCFAllocatorDefault,
(const void**) &kCTFontAttributeName,
(const void**) &font_data->ct_font,
1, /* count of attributes */
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
/* TODO: support features */
CFAttributedStringRef attr_string = CFAttributedStringCreate (kCFAllocatorDefault, string_ref, attrs);
CFRelease (string_ref);
CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
kCTFontAttributeName, font_data->ct_font);
if (num_features)
{
unsigned int *log_clusters = (unsigned int *) (pchars + chars_len);
/* Need log_clusters to assign features. */
chars_len = 0;
for (unsigned int i = 0; i < buffer->len; i++)
{
hb_codepoint_t c = buffer->info[i].codepoint;
unsigned int cluster = buffer->info[i].cluster;
log_clusters[chars_len++] = cluster;
if (c >= 0x10000 && c < 0x110000)
log_clusters[chars_len++] = cluster; /* Surrogates. */
}
unsigned int start = 0;
range_record_t *last_range = &range_records[0];
for (unsigned int k = 0; k < chars_len; k++)
{
range_record_t *range = last_range;
while (log_clusters[k] < range->index_first)
range--;
while (log_clusters[k] > range->index_last)
range++;
if (range != last_range)
{
if (last_range->font)
CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, k - start),
kCTFontAttributeName, last_range->font);
start = k;
}
last_range = range;
}
if (start != chars_len && last_range->font)
CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, chars_len - start - 1),
kCTFontAttributeName, last_range->font);
for (unsigned int i = 0; i < range_records.len; i++)
if (range_records[i].font)
CFRelease (range_records[i].font);
}
CFRelease (attrs);
CTLineRef line = CTLineCreateWithAttributedString (attr_string);
CFRelease (attr_string);
@ -634,6 +232,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
CFArrayRef glyph_runs = CTLineGetGlyphRuns (line);
unsigned int num_runs = CFArrayGetCount (glyph_runs);
bool success = true;
buffer->len = 0;
const CFRange range_all = CFRangeMake (0, 0);
@ -688,6 +287,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
double advance = (j + 1 < num_glyphs ? positions[j + 1].x : positions[0].x + run_width) - positions[j].x;
hb_glyph_info_t *info = &buffer->info[buffer->len];
hb_glyph_position_t *pos = &buffer->pos[buffer->len];
info->codepoint = glyphs[j];
info->cluster = string_indices[j];
@ -751,7 +351,5 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
}
}
CFRelease (line);
return true;
}

View File

@ -1,51 +0,0 @@
/*
* Copyright © 2013 Google, Inc.
*
* This is part of HarfBuzz, a text shaping 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.
*
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_H_IN
#error "Include <hb.h> instead."
#endif
#ifndef HB_DEPRECATED_H
#define HB_DEPRECATED_H
#include "hb-common.h"
#include "hb-unicode.h"
#include "hb-font.h"
HB_BEGIN_DECLS
#ifndef HB_DISABLE_DEPRECATED
#define HB_SCRIPT_CANADIAN_ABORIGINAL HB_SCRIPT_CANADIAN_SYLLABICS
#define HB_BUFFER_FLAGS_DEFAULT HB_BUFFER_FLAG_DEFAULT
#define HB_BUFFER_SERIALIZE_FLAGS_DEFAULT HB_BUFFER_SERIALIZE_FLAG_DEFAULT
#endif
HB_END_DECLS
#endif /* HB_DEPRECATED_H */

View File

@ -1,108 +0,0 @@
/*
* Copyright © 2009 Red Hat, Inc.
* Copyright © 2011 Google, Inc.
*
* This is part of HarfBuzz, a text shaping 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
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_FACE_PRIVATE_HH
#define HB_FACE_PRIVATE_HH
#include "hb-private.hh"
#include "hb-font.h"
#include "hb-object-private.hh"
#include "hb-shaper-private.hh"
#include "hb-shape-plan-private.hh"
/*
* hb_face_t
*/
struct hb_face_t {
hb_object_header_t header;
ASSERT_POD ();
hb_bool_t immutable;
hb_reference_table_func_t reference_table_func;
void *user_data;
hb_destroy_func_t destroy;
unsigned int index;
mutable unsigned int upem;
mutable unsigned int num_glyphs;
struct hb_shaper_data_t shaper_data;
struct plan_node_t {
hb_shape_plan_t *shape_plan;
plan_node_t *next;
} *shape_plans;
inline hb_blob_t *reference_table (hb_tag_t tag) const
{
hb_blob_t *blob;
if (unlikely (!this || !reference_table_func))
return hb_blob_get_empty ();
blob = reference_table_func (/*XXX*/const_cast<hb_face_t *> (this), tag, user_data);
if (unlikely (!blob))
return hb_blob_get_empty ();
return blob;
}
inline HB_PURE_FUNC unsigned int get_upem (void) const
{
if (unlikely (!upem))
load_upem ();
return upem;
}
inline unsigned int get_num_glyphs (void) const
{
if (unlikely (num_glyphs == (unsigned int) -1))
load_num_glyphs ();
return num_glyphs;
}
private:
HB_INTERNAL void load_upem (void) const;
HB_INTERNAL void load_num_glyphs (void) const;
};
extern HB_INTERNAL const hb_face_t _hb_face_nil;
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face);
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
#endif /* HB_FACE_PRIVATE_HH */

View File

@ -1,482 +0,0 @@
/*
* Copyright © 2009 Red Hat, Inc.
* Copyright © 2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping 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
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
#include "hb-ot-layout-private.hh"
#include "hb-font-private.hh"
#include "hb-blob.h"
#include "hb-open-file-private.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-maxp-table.hh"
#include "hb-cache-private.hh"
#include <string.h>
/*
* hb_face_t
*/
const hb_face_t _hb_face_nil = {
HB_OBJECT_HEADER_STATIC,
true, /* immutable */
NULL, /* reference_table_func */
NULL, /* user_data */
NULL, /* destroy */
0, /* index */
1000, /* upem */
0, /* num_glyphs */
{
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
},
NULL, /* shape_plans */
};
/**
* hb_face_create_for_tables:
* @reference_table_func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Return value: (transfer full)
*
* Since: 1.0
**/
hb_face_t *
hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
void *user_data,
hb_destroy_func_t destroy)
{
hb_face_t *face;
if (!reference_table_func || !(face = hb_object_create<hb_face_t> ())) {
if (destroy)
destroy (user_data);
return hb_face_get_empty ();
}
face->reference_table_func = reference_table_func;
face->user_data = user_data;
face->destroy = destroy;
face->upem = 0;
face->num_glyphs = (unsigned int) -1;
return face;
}
typedef struct hb_face_for_data_closure_t {
hb_blob_t *blob;
unsigned int index;
} hb_face_for_data_closure_t;
static hb_face_for_data_closure_t *
_hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
{
hb_face_for_data_closure_t *closure;
closure = (hb_face_for_data_closure_t *) malloc (sizeof (hb_face_for_data_closure_t));
if (unlikely (!closure))
return NULL;
closure->blob = blob;
closure->index = index;
return closure;
}
static void
_hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure)
{
hb_blob_destroy (closure->blob);
free (closure);
}
static hb_blob_t *
_hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
{
hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) user_data;
if (tag == HB_TAG_NONE)
return hb_blob_reference (data->blob);
const OT::OpenTypeFontFile &ot_file = *OT::Sanitizer<OT::OpenTypeFontFile>::lock_instance (data->blob);
const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index);
const OT::OpenTypeTable &table = ot_face.get_table_by_tag (tag);
hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, table.offset, table.length);
return blob;
}
/**
* hb_face_create: (Xconstructor)
* @blob:
* @index:
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_face_t *
hb_face_create (hb_blob_t *blob,
unsigned int index)
{
hb_face_t *face;
if (unlikely (!blob || !hb_blob_get_length (blob)))
return hb_face_get_empty ();
hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::Sanitizer<OT::OpenTypeFontFile>::sanitize (hb_blob_reference (blob)), index);
if (unlikely (!closure))
return hb_face_get_empty ();
face = hb_face_create_for_tables (_hb_face_for_data_reference_table,
closure,
(hb_destroy_func_t) _hb_face_for_data_closure_destroy);
hb_face_set_index (face, index);
return face;
}
/**
* hb_face_get_empty:
*
*
*
* Return value: (transfer full)
*
* Since: 1.0
**/
hb_face_t *
hb_face_get_empty (void)
{
return const_cast<hb_face_t *> (&_hb_face_nil);
}
/**
* hb_face_reference: (skip)
* @face: a face.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_face_t *
hb_face_reference (hb_face_t *face)
{
return hb_object_reference (face);
}
/**
* hb_face_destroy: (skip)
* @face: a face.
*
*
*
* Since: 1.0
**/
void
hb_face_destroy (hb_face_t *face)
{
if (!hb_object_destroy (face)) return;
for (hb_face_t::plan_node_t *node = face->shape_plans; node; )
{
hb_face_t::plan_node_t *next = node->next;
hb_shape_plan_destroy (node->shape_plan);
free (node);
node = next;
}
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face);
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
if (face->destroy)
face->destroy (face->user_data);
free (face);
}
/**
* hb_face_set_user_data: (skip)
* @face: a face.
* @key:
* @data:
* @destroy:
* @replace:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_face_set_user_data (hb_face_t *face,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace)
{
return hb_object_set_user_data (face, key, data, destroy, replace);
}
/**
* hb_face_get_user_data: (skip)
* @face: a face.
* @key:
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
void *
hb_face_get_user_data (hb_face_t *face,
hb_user_data_key_t *key)
{
return hb_object_get_user_data (face, key);
}
/**
* hb_face_make_immutable:
* @face: a face.
*
*
*
* Since: 1.0
**/
void
hb_face_make_immutable (hb_face_t *face)
{
if (hb_object_is_inert (face))
return;
face->immutable = true;
}
/**
* hb_face_is_immutable:
* @face: a face.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_face_is_immutable (hb_face_t *face)
{
return face->immutable;
}
/**
* hb_face_reference_table:
* @face: a face.
* @tag:
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_blob_t *
hb_face_reference_table (hb_face_t *face,
hb_tag_t tag)
{
return face->reference_table (tag);
}
/**
* hb_face_reference_blob:
* @face: a face.
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_blob_t *
hb_face_reference_blob (hb_face_t *face)
{
return face->reference_table (HB_TAG_NONE);
}
/**
* hb_face_set_index:
* @face: a face.
* @index:
*
*
*
* Since: 1.0
**/
void
hb_face_set_index (hb_face_t *face,
unsigned int index)
{
if (hb_object_is_inert (face))
return;
face->index = index;
}
/**
* hb_face_get_index:
* @face: a face.
*
*
*
* Return value:
*
* Since: 1.0
**/
unsigned int
hb_face_get_index (hb_face_t *face)
{
return face->index;
}
/**
* hb_face_set_upem:
* @face: a face.
* @upem:
*
*
*
* Since: 1.0
**/
void
hb_face_set_upem (hb_face_t *face,
unsigned int upem)
{
if (hb_object_is_inert (face))
return;
face->upem = upem;
}
/**
* hb_face_get_upem:
* @face: a face.
*
*
*
* Return value:
*
* Since: 1.0
**/
unsigned int
hb_face_get_upem (hb_face_t *face)
{
return face->get_upem ();
}
void
hb_face_t::load_upem (void) const
{
hb_blob_t *head_blob = OT::Sanitizer<OT::head>::sanitize (reference_table (HB_OT_TAG_head));
const OT::head *head_table = OT::Sanitizer<OT::head>::lock_instance (head_blob);
upem = head_table->get_upem ();
hb_blob_destroy (head_blob);
}
/**
* hb_face_set_glyph_count:
* @face: a face.
* @glyph_count:
*
*
*
* Since: 1.0
**/
void
hb_face_set_glyph_count (hb_face_t *face,
unsigned int glyph_count)
{
if (hb_object_is_inert (face))
return;
face->num_glyphs = glyph_count;
}
/**
* hb_face_get_glyph_count:
* @face: a face.
*
*
*
* Return value:
*
* Since: 1.0
**/
unsigned int
hb_face_get_glyph_count (hb_face_t *face)
{
return face->get_num_glyphs ();
}
void
hb_face_t::load_num_glyphs (void) const
{
hb_blob_t *maxp_blob = OT::Sanitizer<OT::maxp>::sanitize (reference_table (HB_OT_TAG_maxp));
const OT::maxp *maxp_table = OT::Sanitizer<OT::maxp>::lock_instance (maxp_blob);
num_glyphs = maxp_table->get_num_glyphs ();
hb_blob_destroy (maxp_blob);
}

View File

@ -1,117 +0,0 @@
/*
* Copyright © 2009 Red Hat, Inc.
*
* This is part of HarfBuzz, a text shaping 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_IN
#error "Include <hb.h> instead."
#endif
#ifndef HB_FACE_H
#define HB_FACE_H
#include "hb-common.h"
#include "hb-blob.h"
HB_BEGIN_DECLS
/*
* hb_face_t
*/
typedef struct hb_face_t hb_face_t;
hb_face_t *
hb_face_create (hb_blob_t *blob,
unsigned int index);
typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data);
/* calls destroy() when not needing user_data anymore */
hb_face_t *
hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
void *user_data,
hb_destroy_func_t destroy);
hb_face_t *
hb_face_get_empty (void);
hb_face_t *
hb_face_reference (hb_face_t *face);
void
hb_face_destroy (hb_face_t *face);
hb_bool_t
hb_face_set_user_data (hb_face_t *face,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace);
void *
hb_face_get_user_data (hb_face_t *face,
hb_user_data_key_t *key);
void
hb_face_make_immutable (hb_face_t *face);
hb_bool_t
hb_face_is_immutable (hb_face_t *face);
hb_blob_t *
hb_face_reference_table (hb_face_t *face,
hb_tag_t tag);
hb_blob_t *
hb_face_reference_blob (hb_face_t *face);
void
hb_face_set_index (hb_face_t *face,
unsigned int index);
unsigned int
hb_face_get_index (hb_face_t *face);
void
hb_face_set_upem (hb_face_t *face,
unsigned int upem);
unsigned int
hb_face_get_upem (hb_face_t *face);
void
hb_face_set_glyph_count (hb_face_t *face,
unsigned int glyph_count);
unsigned int
hb_face_get_glyph_count (hb_face_t *face);
HB_END_DECLS
#endif /* HB_FACE_H */

View File

@ -33,8 +33,8 @@
#include "hb-font.h"
#include "hb-object-private.hh"
#include "hb-face-private.hh"
#include "hb-shaper-private.hh"
#include "hb-shape-plan-private.hh"
@ -84,6 +84,71 @@ struct hb_font_funcs_t {
};
/*
* hb_face_t
*/
struct hb_face_t {
hb_object_header_t header;
ASSERT_POD ();
hb_bool_t immutable;
hb_reference_table_func_t reference_table_func;
void *user_data;
hb_destroy_func_t destroy;
unsigned int index;
mutable unsigned int upem;
mutable unsigned int num_glyphs;
struct hb_shaper_data_t shaper_data;
struct plan_node_t {
hb_shape_plan_t *shape_plan;
plan_node_t *next;
} *shape_plans;
inline hb_blob_t *reference_table (hb_tag_t tag) const
{
hb_blob_t *blob;
if (unlikely (!this || !reference_table_func))
return hb_blob_get_empty ();
blob = reference_table_func (/*XXX*/const_cast<hb_face_t *> (this), tag, user_data);
if (unlikely (!blob))
return hb_blob_get_empty ();
return blob;
}
inline unsigned int get_upem (void) const
{
if (unlikely (!upem))
load_upem ();
return upem;
}
inline unsigned int get_num_glyphs (void) const
{
if (unlikely (num_glyphs == (unsigned int) -1))
load_num_glyphs ();
return num_glyphs;
}
private:
HB_INTERNAL void load_upem (void) const;
HB_INTERNAL void load_num_glyphs (void) const;
};
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face);
#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
/*
* hb_font_t
@ -193,10 +258,10 @@ struct hb_font_t {
klass->user_data.glyph_h_kerning);
}
inline hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph)
inline hb_position_t get_glyph_v_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
{
return klass->get.glyph_v_kerning (this, user_data,
top_glyph, bottom_glyph,
left_glyph, right_glyph,
klass->user_data.glyph_v_kerning);
}
@ -271,21 +336,16 @@ struct hb_font_t {
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
{
if (!get_glyph_h_origin (glyph, x, y) &&
get_glyph_v_origin (glyph, x, y))
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
hb_bool_t ret = get_glyph_h_origin (glyph, x, y);
if (!ret && (ret = get_glyph_v_origin (glyph, x, y))) {
hb_position_t dx, dy;
guess_v_origin_minus_h_origin (glyph, &dx, &dy);
*x -= dx; *y -= dy;
}
}
else
{
if (!get_glyph_v_origin (glyph, x, y) &&
get_glyph_h_origin (glyph, x, y))
{
} else {
hb_bool_t ret = get_glyph_v_origin (glyph, x, y);
if (!ret && (ret = get_glyph_h_origin (glyph, x, y))) {
hb_position_t dx, dy;
guess_v_origin_minus_h_origin (glyph, &dx, &dy);
*x += dx; *y += dy;
@ -361,8 +421,7 @@ struct hb_font_t {
{
if (get_glyph_name (glyph, s, size)) return;
if (size && snprintf (s, size, "gid%u", glyph) < 0)
*s = '\0';
snprintf (s, size, "gid%u", glyph);
}
/* Parses gidDDD and uniUUUU strings automatically. */
@ -397,7 +456,7 @@ struct hb_font_t {
}
private:
inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / face->get_upem (); }
inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / hb_face_get_upem (this->face); }
};
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS

File diff suppressed because it is too large Load Diff

View File

@ -32,13 +32,86 @@
#define HB_FONT_H
#include "hb-common.h"
#include "hb-face.h"
#include "hb-blob.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 (hb_blob_t *blob,
unsigned int index);
typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data);
/* calls destroy() when not needing user_data anymore */
hb_face_t *
hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
void *user_data,
hb_destroy_func_t destroy);
hb_face_t *
hb_face_get_empty (void);
hb_face_t *
hb_face_reference (hb_face_t *face);
void
hb_face_destroy (hb_face_t *face);
hb_bool_t
hb_face_set_user_data (hb_face_t *face,
hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
hb_bool_t replace);
void *
hb_face_get_user_data (hb_face_t *face,
hb_user_data_key_t *key);
void
hb_face_make_immutable (hb_face_t *face);
hb_bool_t
hb_face_is_immutable (hb_face_t *face);
hb_blob_t *
hb_face_reference_table (hb_face_t *face,
hb_tag_t tag);
hb_blob_t *
hb_face_reference_blob (hb_face_t *face);
void
hb_face_set_index (hb_face_t *face,
unsigned int index);
unsigned int
hb_face_get_index (hb_face_t *face);
void
hb_face_set_upem (hb_face_t *face,
unsigned int upem);
unsigned int
hb_face_get_upem (hb_face_t *face);
void
hb_face_set_glyph_count (hb_face_t *face,
unsigned int glyph_count);
unsigned int
hb_face_get_glyph_count (hb_face_t *face);
/*
* hb_font_funcs_t
@ -139,180 +212,54 @@ typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *
/* func setters */
/**
* hb_font_funcs_set_glyph_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_func_t func,
hb_font_get_glyph_func_t glyph_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_h_advance_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_advance_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_v_advance_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_advance_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_h_origin_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_origin_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_v_origin_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_origin_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_h_kerning_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_v_kerning_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_extents_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_extents_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_contour_point_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_contour_point_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_name_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_name_func_t func,
hb_font_get_glyph_name_func_t glyph_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_from_name_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_from_name_func_t func,
hb_font_get_glyph_from_name_func_t glyph_func,
void *user_data, hb_destroy_func_t destroy);

View File

@ -73,7 +73,8 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
#ifdef HAVE_FT_FACE_GETCHARVARIANTINDEX
if (unlikely (variation_selector)) {
*glyph = FT_Face_GetCharVariantIndex (ft_face, unicode, variation_selector);
return *glyph != 0;
if (*glyph)
return true;
}
#endif
@ -260,15 +261,6 @@ hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED,
*glyph = FT_Get_Name_Index (ft_face, buf);
}
if (*glyph == 0)
{
/* Check whether the given name was actually the name of glyph 0. */
char buf[128];
if (!FT_Get_Glyph_Name(ft_face, 0, buf, sizeof (buf)) &&
len < 0 ? !strcmp (buf, name) : !strncmp (buf, name, len))
return true;
}
return *glyph != 0;
}
@ -319,16 +311,7 @@ reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
buffer, free);
}
/**
* hb_ft_face_create:
* @ft_face: (destroy destroy) (scope notified):
* @destroy:
*
*
*
* Return value: (transfer full):
* Since: 1.0
**/
hb_face_t *
hb_ft_face_create (FT_Face ft_face,
hb_destroy_func_t destroy)
@ -364,15 +347,6 @@ hb_ft_face_finalize (FT_Face ft_face)
hb_face_destroy ((hb_face_t *) ft_face->generic.data);
}
/**
* hb_ft_face_create_cached:
* @ft_face:
*
*
*
* Return value: (transfer full):
* Since: 1.0
**/
hb_face_t *
hb_ft_face_create_cached (FT_Face ft_face)
{
@ -394,16 +368,6 @@ _do_nothing (void)
}
/**
* hb_ft_font_create:
* @ft_face: (destroy destroy) (scope notified):
* @destroy:
*
*
*
* Return value: (transfer full):
* Since: 1.0
**/
hb_font_t *
hb_ft_font_create (FT_Face ft_face,
hb_destroy_func_t destroy)

View File

@ -77,7 +77,7 @@ glib_script_to_script[] =
HB_SCRIPT_THAANA,
HB_SCRIPT_THAI,
HB_SCRIPT_TIBETAN,
HB_SCRIPT_CANADIAN_SYLLABICS,
HB_SCRIPT_CANADIAN_ABORIGINAL,
HB_SCRIPT_YI,
HB_SCRIPT_TAGALOG,
HB_SCRIPT_HANUNOO,

View File

@ -45,12 +45,13 @@
/*** END file-production ***/
/*** BEGIN value-header ***/
inline static /* TODO(behdad) disable these for now until we fix them... */
GType
@enum_name@_get_type (void)
{
static gsize type_id = 0;
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter (&type_id))
if (g_once_init_enter (&g_define_type_id__volatile))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
@ -62,12 +63,12 @@ GType
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType id =
GType g_define_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&type_id, id);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return type_id;
return g_define_type_id__volatile;
}
/*** END value-tail ***/

View File

@ -1,55 +0,0 @@
/*** BEGIN file-header ***/
/*
* Copyright © 2013 Google, Inc.
*
* This is part of HarfBuzz, a text shaping 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.
*
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_GOBJECT_H_IN
#error "Include <hb-gobject.h> instead."
#endif
#ifndef HB_GOBJECT_ENUMS_H
#define HB_GOBJECT_ENUMS_H
#include "hb.h"
#include <glib-object.h>
HB_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
/*** END value-header ***/
/*** BEGIN file-tail ***/
HB_END_DECLS
#endif /* HB_GOBJECT_ENUMS_H */
/*** END file-tail ***/

View File

@ -37,84 +37,27 @@
#include "hb-gobject.h"
#define HB_DEFINE_BOXED_TYPE(name,copy_func,free_func) \
#define _HB_DEFINE_BOXED_TYPE(Name,underscore_name,copy_func,free_func) \
GType \
hb_gobject_##name##_get_type (void) \
underscore_name##_get_type (void) \
{ \
static gsize type_id = 0; \
if (g_once_init_enter (&type_id)) { \
GType id = g_boxed_type_register_static (g_intern_static_string ("hb_" #name "_t"), \
(GBoxedCopyFunc) copy_func, \
(GBoxedFreeFunc) free_func); \
g_once_init_leave (&type_id, id); \
static volatile gsize type = 0; \
if (g_once_init_enter (&type)) { \
GType t = g_boxed_type_register_static (g_intern_static_string (#Name), \
(GBoxedCopyFunc) copy_func, \
(GBoxedFreeFunc) free_func); \
g_once_init_leave (&type, t); \
} \
return type_id; \
return type; \
}
#define HB_DEFINE_OBJECT_TYPE(name) \
HB_DEFINE_BOXED_TYPE (name, hb_##name##_reference, hb_##name##_destroy);
#define HB_DEFINE_BOXED_TYPE(name) \
_HB_DEFINE_BOXED_TYPE (hb_##name, hb_gobject_##name, hb_##name##_reference, hb_##name##_destroy);
HB_DEFINE_OBJECT_TYPE (buffer)
HB_DEFINE_OBJECT_TYPE (blob)
HB_DEFINE_OBJECT_TYPE (face)
HB_DEFINE_OBJECT_TYPE (font)
HB_DEFINE_OBJECT_TYPE (font_funcs)
HB_DEFINE_OBJECT_TYPE (set)
HB_DEFINE_OBJECT_TYPE (shape_plan)
HB_DEFINE_OBJECT_TYPE (unicode_funcs)
HB_DEFINE_BOXED_TYPE (buffer)
HB_DEFINE_BOXED_TYPE (blob)
HB_DEFINE_BOXED_TYPE (face)
HB_DEFINE_BOXED_TYPE (font)
HB_DEFINE_BOXED_TYPE (font_funcs)
HB_DEFINE_BOXED_TYPE (unicode_funcs)
static hb_feature_t *feature_reference (hb_feature_t *g)
{
hb_feature_t *c = (hb_feature_t *) calloc (1, sizeof (hb_feature_t));
if (unlikely (!c)) return NULL;
*c = *g;
return c;
}
static void feature_destroy (hb_feature_t *g) { free (g); }
HB_DEFINE_BOXED_TYPE (feature, feature_reference, feature_destroy)
static hb_glyph_info_t *glyph_info_reference (hb_glyph_info_t *g)
{
hb_glyph_info_t *c = (hb_glyph_info_t *) calloc (1, sizeof (hb_glyph_info_t));
if (unlikely (!c)) return NULL;
*c = *g;
return c;
}
static void glyph_info_destroy (hb_glyph_info_t *g) { free (g); }
HB_DEFINE_BOXED_TYPE (glyph_info, glyph_info_reference, glyph_info_destroy)
static hb_glyph_position_t *glyph_position_reference (hb_glyph_position_t *g)
{
hb_glyph_position_t *c = (hb_glyph_position_t *) calloc (1, sizeof (hb_glyph_position_t));
if (unlikely (!c)) return NULL;
*c = *g;
return c;
}
static void glyph_position_destroy (hb_glyph_position_t *g) { free (g); }
HB_DEFINE_BOXED_TYPE (glyph_position, glyph_position_reference, glyph_position_destroy)
static hb_segment_properties_t *segment_properties_reference (hb_segment_properties_t *g)
{
hb_segment_properties_t *c = (hb_segment_properties_t *) calloc (1, sizeof (hb_segment_properties_t));
if (unlikely (!c)) return NULL;
*c = *g;
return c;
}
static void segment_properties_destroy (hb_segment_properties_t *g) { free (g); }
HB_DEFINE_BOXED_TYPE (segment_properties, segment_properties_reference, segment_properties_destroy)
static hb_user_data_key_t user_data_key_reference (hb_user_data_key_t l) { return l; }
static void user_data_key_destroy (hb_user_data_key_t l) { }
HB_DEFINE_BOXED_TYPE (user_data_key, user_data_key_reference, user_data_key_destroy)
static hb_language_t *language_reference (hb_language_t *l)
{
hb_language_t *c = (hb_language_t *) calloc (1, sizeof (hb_language_t));
if (unlikely (!c)) return NULL;
*c = *l;
return c;
}
static void language_destroy (hb_language_t *l) { free (l); }
HB_DEFINE_BOXED_TYPE (language, language_reference, language_destroy)

View File

@ -1,95 +0,0 @@
/*
* Copyright © 2011 Google, Inc.
*
* This is part of HarfBuzz, a text shaping 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.
*
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_GOBJECT_H_IN
#error "Include <hb-gobject.h> instead."
#endif
#ifndef HB_GOBJECT_STRUCTS_H
#define HB_GOBJECT_STRUCTS_H
#include "hb.h"
#include <glib-object.h>
HB_BEGIN_DECLS
/* Object types */
GType hb_gobject_blob_get_type (void);
#define HB_GOBJECT_TYPE_BLOB (hb_gobject_blob_get_type ())
GType hb_gobject_buffer_get_type (void);
#define HB_GOBJECT_TYPE_BUFFER (hb_gobject_buffer_get_type ())
GType hb_gobject_face_get_type (void);
#define HB_GOBJECT_TYPE_FACE (hb_gobject_face_get_type ())
GType hb_gobject_font_get_type (void);
#define HB_GOBJECT_TYPE_FONT (hb_gobject_font_get_type ())
GType hb_gobject_font_funcs_get_type (void);
#define HB_GOBJECT_TYPE_FONT_FUNCS (hb_gobject_font_funcs_get_type ())
GType hb_gobject_set_get_type (void);
#define HB_GOBJECT_TYPE_SET (hb_gobject_set_get_type ())
GType hb_gobject_shape_plan_get_type (void);
#define HB_GOBJECT_TYPE_SHAPE_PLAN (hb_gobject_shape_plan_get_type ())
GType hb_gobject_unicode_funcs_get_type (void);
#define HB_GOBJECT_TYPE_UNICODE_FUNCS (hb_gobject_unicode_funcs_get_type ())
/* Value types */
GType hb_gobject_feature_get_type (void);
#define HB_GOBJECT_TYPE_FEATURE (hb_gobject_feature_get_type ())
GType hb_gobject_glyph_info_get_type (void);
#define HB_GOBJECT_TYPE_GLYPH_INFO (hb_gobject_glyph_info_get_type ())
GType hb_gobject_glyph_position_get_type (void);
#define HB_GOBJECT_TYPE_GLYPH_POSITION (hb_gobject_glyph_position_get_type ())
GType hb_gobject_segment_properties_get_type (void);
#define HB_GOBJECT_TYPE_SEGMENT_PROPERTIES (hb_gobject_segment_properties_get_type ())
GType hb_gobject_user_data_key_get_type (void);
#define HB_GOBJECT_TYPE_USER_DATA_KEY (hb_gobject_user_data_key_get_type ())
/* Currently gobject-introspection doesn't understand that hb_language_t
* can be passed by-value. As such we box it up. May remove in the
* future.
*
* https://bugzilla.gnome.org/show_bug.cgi?id=707656
*/
GType hb_gobject_language_get_type (void);
#define HB_GOBJECT_TYPE_LANGUAGE (hb_gobject_language_get_type ())
HB_END_DECLS
#endif /* HB_GOBJECT_H */

View File

@ -26,15 +26,44 @@
#ifndef HB_GOBJECT_H
#define HB_GOBJECT_H
#define HB_GOBJECT_H_IN
#include "hb.h"
#include "hb-gobject-enums.h"
#include "hb-gobject-structs.h"
#include <glib-object.h>
HB_BEGIN_DECLS
/* Objects */
#define HB_GOBJECT_TYPE_BLOB hb_gobject_blob_get_type ()
GType
hb_gobject_blob_get_type (void);
#define HB_GOBJECT_TYPE_BUFFER hb_gobject_buffer_get_type ()
GType
hb_gobject_buffer_get_type (void);
#define HB_GOBJECT_TYPE_FACE hb_gobject_face_get_type ()
GType
hb_gobject_face_get_type (void);
#define HB_GOBJECT_TYPE_FONT hb_gobject_font_get_type ()
GType
hb_gobject_font_get_type (void);
#define HB_GOBJECT_TYPE_FONT_FUNCS hb_gobject_font_funcs_get_type ()
GType
hb_gobject_font_funcs_get_type (void);
#define HB_GOBJECT_TYPE_UNICODE_FUNCS hb_gobject_unicode_funcs_get_type ()
GType
hb_gobject_unicode_funcs_get_type (void);
/* Enums */
HB_END_DECLS
#undef HB_GOBJECT_H_IN
#endif /* HB_GOBJECT_H */

View File

@ -30,10 +30,11 @@
#define hb_graphite2_shaper_font_data_t gr_font
#include "hb-shaper-impl-private.hh"
#include "hb-graphite2.h"
#include <graphite2/Font.h>
#include <graphite2/Segment.h>
#include "hb-graphite2.h"
#include "hb-ot-tag.h"

View File

@ -28,8 +28,6 @@
#include "hb.h"
#include <graphite2/Font.h>
HB_BEGIN_DECLS

View File

@ -642,21 +642,15 @@ struct LongOffset : ULONG
/* CheckSum */
struct CheckSum : ULONG
{
/* This is reference implementation from the spec. */
static inline uint32_t CalcTableChecksum (const ULONG *Table, uint32_t Length)
static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length)
{
uint32_t Sum = 0L;
const ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size;
ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size;
while (Table < EndPtr)
Sum += *Table++;
return Sum;
}
/* Note: data should be 4byte aligned and have 4byte padding at the end. */
inline void set_for_data (const void *data, unsigned int length)
{ set (CalcTableChecksum ((const ULONG *) data, length)); }
public:
DEFINE_SIZE_STATIC (4);
};

View File

@ -43,7 +43,7 @@ namespace OT {
struct head
{
static const hb_tag_t tableTag = HB_OT_TAG_head;
static const hb_tag_t Tag = HB_OT_TAG_head;
inline unsigned int get_upem (void) const {
unsigned int upem = unitsPerEm;

View File

@ -42,7 +42,7 @@ namespace OT {
struct hhea
{
static const hb_tag_t tableTag = HB_OT_TAG_hhea;
static const hb_tag_t Tag = HB_OT_TAG_hhea;
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this);

View File

@ -50,7 +50,7 @@ struct LongHorMetric
struct hmtx
{
static const hb_tag_t tableTag = HB_OT_TAG_hmtx;
static const hb_tag_t Tag = HB_OT_TAG_hmtx;
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this);

View File

@ -871,9 +871,9 @@ struct Coverage
inline void init (const Coverage &c_) {
format = c_.u.format;
switch (format) {
case 1: u.format1.init (c_.u.format1); return;
case 2: u.format2.init (c_.u.format2); return;
default: return;
case 1: return u.format1.init (c_.u.format1);
case 2: return u.format2.init (c_.u.format2);
default:return;
}
}
inline bool more (void) {
@ -894,14 +894,14 @@ struct Coverage
switch (format) {
case 1: return u.format1.get_glyph ();
case 2: return u.format2.get_glyph ();
default:return 0;
default:return true;
}
}
inline uint16_t get_coverage (void) {
switch (format) {
case 1: return u.format1.get_coverage ();
case 2: return u.format2.get_coverage ();
default:return -1;
default:return true;
}
}
@ -955,19 +955,6 @@ struct ClassDefFormat1
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const {
unsigned int count = classValue.len;
if (klass == 0)
{
/* Match if there's any glyph that is not listed! */
hb_codepoint_t g = -1;
if (!hb_set_next (glyphs, &g))
return false;
if (g < startGlyph)
return true;
g = startGlyph + count - 1;
if (hb_set_next (glyphs, &g))
return true;
/* Fall through. */
}
for (unsigned int i = 0; i < count; i++)
if (classValue[i] == klass && glyphs->has (startGlyph + i))
return true;
@ -1011,22 +998,6 @@ struct ClassDefFormat2
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const {
unsigned int count = rangeRecord.len;
if (klass == 0)
{
/* Match if there's any glyph that is not listed! */
hb_codepoint_t g = (hb_codepoint_t) -1;
for (unsigned int i = 0; i < count; i++)
{
if (!hb_set_next (glyphs, &g))
break;
if (g < rangeRecord[i].start)
return true;
g = rangeRecord[i].end;
}
if (g != (hb_codepoint_t) -1 && hb_set_next (glyphs, &g))
return true;
/* Fall through. */
}
for (unsigned int i = 0; i < count; i++)
if (rangeRecord[i].value == klass && rangeRecord[i].intersects (glyphs))
return true;

View File

@ -324,7 +324,7 @@ struct MarkGlyphSets
struct GDEF
{
static const hb_tag_t tableTag = HB_OT_TAG_GDEF;
static const hb_tag_t Tag = HB_OT_TAG_GDEF;
enum GlyphClasses {
UnclassifiedGlyph = 0,

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2007,2008,2009,2010 Red Hat, Inc.
* Copyright © 2010,2012,2013 Google, Inc.
* Copyright © 2010,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@ -710,6 +710,8 @@ struct PairPosFormat2
TRACE_COLLECT_GLYPHS (this);
/* (this+coverage).add_coverage (c->input); // Don't need this. */
/* TODO only add values for pairs that have nonzero adjustments. */
unsigned int count1 = class1Count;
const ClassDef &klass1 = this+classDef1;
for (unsigned int i = 0; i < count1; i++)
@ -1012,6 +1014,7 @@ struct MarkBasePosFormat1
TRACE_COLLECT_GLYPHS (this);
(this+markCoverage).add_coverage (c->input);
(this+baseCoverage).add_coverage (c->input);
/* TODO only add combinations that have nonzero adjustment. */
}
inline const Coverage &get_coverage (void) const
@ -1115,6 +1118,7 @@ struct MarkLigPosFormat1
TRACE_COLLECT_GLYPHS (this);
(this+markCoverage).add_coverage (c->input);
(this+ligatureCoverage).add_coverage (c->input);
/* TODO only add combinations that have nonzero adjustment. */
}
inline const Coverage &get_coverage (void) const
@ -1230,6 +1234,7 @@ struct MarkMarkPosFormat1
TRACE_COLLECT_GLYPHS (this);
(this+mark1Coverage).add_coverage (c->input);
(this+mark2Coverage).add_coverage (c->input);
/* TODO only add combinations that have nonzero adjustment. */
}
inline const Coverage &get_coverage (void) const
@ -1429,18 +1434,7 @@ struct PosLookup : Lookup
inline const PosLookupSubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
inline bool is_reverse (void) const
{
return false;
}
inline hb_is_inplace_context_t::return_t is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
return TRACE_RETURN (true);
}
inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const
inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
c->set_recurse_func (NULL);
@ -1472,6 +1466,31 @@ struct PosLookup : Lookup
static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const
{
bool ret = false;
if (unlikely (!c->buffer->len || !c->lookup_mask))
return false;
c->set_recurse_func (apply_recurse_func);
c->set_lookup (*this);
c->buffer->idx = 0;
while (c->buffer->idx < c->buffer->len)
{
if (digest->may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) &&
apply_once (c))
ret = true;
else
c->buffer->idx++;
}
return ret;
}
template <typename context_t>
static inline typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index);
@ -1505,7 +1524,7 @@ typedef OffsetListOf<PosLookup> PosLookupList;
struct GPOS : GSUBGPOS
{
static const hb_tag_t tableTag = HB_OT_TAG_GPOS;
static const hb_tag_t Tag = HB_OT_TAG_GPOS;
inline const PosLookup& get_lookup (unsigned int i) const
{ return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2007,2008,2009,2010 Red Hat, Inc.
* Copyright © 2010,2012,2013 Google, Inc.
* Copyright © 2010,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@ -37,12 +37,6 @@ namespace OT {
struct SingleSubstFormat1
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -121,12 +115,6 @@ struct SingleSubstFormat1
struct SingleSubstFormat2
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -263,13 +251,6 @@ struct SingleSubst
struct Sequence
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
/* For len==0 we don't do anything, so it's harmless. */
return TRACE_RETURN (substitute.len <= 1);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -294,18 +275,11 @@ struct Sequence
unsigned int klass = c->buffer->cur().glyph_props() &
HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0;
unsigned int count = substitute.len;
if (count == 1) /* Special-case to make it in-place. */
{
c->replace_glyph (substitute.array[0]);
}
else
{
for (unsigned int i = 0; i < count; i++) {
set_lig_props_for_component (c->buffer->cur(), i);
c->output_glyph (substitute.array[i], klass);
}
c->buffer->skip_glyph ();
for (unsigned int i = 0; i < count; i++) {
set_lig_props_for_component (c->buffer->cur(), i);
c->output_glyph (substitute.array[i], klass);
}
c->buffer->skip_glyph ();
return TRACE_RETURN (true);
}
@ -334,18 +308,6 @@ struct Sequence
struct MultipleSubstFormat1
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
/* Some tools generate MultipleSubst with each substitute having length 1!
* So, check them. */
unsigned int count = sequence.len;
for (unsigned int i = 0; i < count; i++)
if (!(this+sequence[i]).is_inplace (c))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -471,12 +433,6 @@ typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in
struct AlternateSubstFormat1
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -797,12 +753,6 @@ struct LigatureSet
struct LigatureSubstFormat1
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
return TRACE_RETURN (false);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -951,12 +901,6 @@ struct ExtensionSubst : Extension<ExtensionSubst>
struct ReverseChainSingleSubstFormat1
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -1194,13 +1138,6 @@ struct SubstLookup : Lookup
return lookup_type_is_reverse (type);
}
inline hb_is_inplace_context_t::return_t is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
c->set_recurse_func (dispatch_recurse_func<hb_is_inplace_context_t>);
return TRACE_RETURN (dispatch (c));
}
inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -1208,7 +1145,7 @@ struct SubstLookup : Lookup
return TRACE_RETURN (dispatch (c));
}
inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const
inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>);
@ -1247,6 +1184,54 @@ struct SubstLookup : Lookup
}
static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest) const
{
bool ret = false;
if (unlikely (!c->buffer->len || !c->lookup_mask))
return false;
c->set_recurse_func (apply_recurse_func);
c->set_lookup (*this);
if (likely (!is_reverse ()))
{
/* in/out forward substitution */
c->buffer->clear_output ();
c->buffer->idx = 0;
while (c->buffer->idx < c->buffer->len)
{
if (digest->may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) &&
apply_once (c))
ret = true;
else
c->buffer->next_glyph ();
}
if (ret)
c->buffer->swap_buffers ();
}
else
{
/* in-place backward substitution */
c->buffer->remove_output ();
c->buffer->idx = c->buffer->len - 1;
do
{
if (digest->may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) &&
apply_once (c))
ret = true;
else
c->buffer->idx--;
}
while ((int) c->buffer->idx >= 0);
}
return ret;
}
inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c,
unsigned int i)
@ -1351,7 +1336,7 @@ typedef OffsetListOf<SubstLookup> SubstLookupList;
struct GSUB : GSUBGPOS
{
static const hb_tag_t tableTag = HB_OT_TAG_GSUB;
static const hb_tag_t Tag = HB_OT_TAG_GSUB;
inline const SubstLookup& get_lookup (unsigned int i) const
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }

View File

@ -44,55 +44,6 @@ namespace OT {
"");
#ifndef HB_DEBUG_IS_INPLACE
#define HB_DEBUG_IS_INPLACE (HB_DEBUG+0)
#endif
#define TRACE_IS_INPLACE(this) \
hb_auto_trace_t<HB_DEBUG_IS_INPLACE, bool> trace \
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
"");
struct hb_is_inplace_context_t
{
inline const char *get_name (void) { return "IS_INPLACE"; }
static const unsigned int max_debug_depth = HB_DEBUG_IS_INPLACE;
typedef bool return_t;
typedef return_t (*recurse_func_t) (hb_is_inplace_context_t *c, unsigned int lookup_index);
template <typename T>
inline return_t dispatch (const T &obj) { return obj.is_inplace (this); }
static return_t default_return_value (void) { return true; }
bool stop_sublookup_iteration (return_t r) const { return !r; }
return_t recurse (unsigned int lookup_index)
{
if (unlikely (nesting_level_left == 0 || !recurse_func))
return default_return_value ();
nesting_level_left--;
bool ret = recurse_func (this, lookup_index);
nesting_level_left++;
return ret;
}
hb_face_t *face;
recurse_func_t recurse_func;
unsigned int nesting_level_left;
unsigned int debug_depth;
hb_is_inplace_context_t (hb_face_t *face_,
unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
face (face_),
recurse_func (NULL),
nesting_level_left (nesting_level_left_),
debug_depth (0) {}
void set_recurse_func (recurse_func_t func) { recurse_func = func; }
};
#ifndef HB_DEBUG_CLOSURE
#define HB_DEBUG_CLOSURE (HB_DEBUG+0)
#endif
@ -207,13 +158,7 @@ struct hb_collect_glyphs_context_t
/* Note that GPOS sets recurse_func to NULL already, so it doesn't get
* past the previous check. For GSUB, we only want to collect the output
* glyphs in the recursion. If output is not requested, we can go home now.
*
* Note further, that the above is not exactly correct. A recursed lookup
* is allowed to match input that is not matched in the context, but that's
* not how most fonts are built. It's possible to relax that and recurse
* with all sets here if it proves to be an issue.
*/
* glyphs in the recursion. If output is not requested, we can go home now. */
if (output == hb_set_get_empty ())
return HB_VOID;
@ -327,12 +272,14 @@ struct hb_apply_context_t
hb_apply_context_t (unsigned int table_index_,
hb_font_t *font_,
hb_buffer_t *buffer_) :
hb_buffer_t *buffer_,
hb_mask_t lookup_mask_,
bool auto_zwj_) :
table_index (table_index_),
font (font_), face (font->face), buffer (buffer_),
direction (buffer_->props.direction),
lookup_mask (1),
auto_zwj (true),
lookup_mask (lookup_mask_),
auto_zwj (auto_zwj_),
recurse_func (NULL),
nesting_level_left (MAX_NESTING_LEVEL),
lookup_props (0),
@ -340,8 +287,6 @@ struct hb_apply_context_t
has_glyph_classes (gdef.has_glyph_classes ()),
debug_depth (0) {}
inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; }
inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; }
inline void set_recurse_func (recurse_func_t func) { recurse_func = func; }
inline void set_lookup_props (unsigned int lookup_props_) { lookup_props = lookup_props_; }
inline void set_lookup (const Lookup &l) { lookup_props = l.get_props (); }
@ -872,11 +817,7 @@ static inline void ligate_input (hb_apply_context_t *c,
unsigned int components_so_far = last_num_components;
if (!is_mark_ligature)
{
set_lig_props_for_ligature (c->buffer->cur(), lig_id, total_component_count);
if (_hb_glyph_info_get_general_category (&c->buffer->cur()) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
_hb_glyph_info_set_general_category (&c->buffer->cur(), HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER);
}
c->replace_glyph (lig_glyph, klass);
for (unsigned int i = 1; i < count; i++)
@ -977,7 +918,7 @@ static inline void recurse_lookups (context_t *c,
const LookupRecord lookupRecord[] /* Array of LookupRecords--in design order */)
{
for (unsigned int i = 0; i < lookupCount; i++)
c->recurse (lookupRecord[i].lookupListIndex);
c->recurse (lookupRecord->lookupListIndex);
}
static inline bool apply_lookup (hb_apply_context_t *c,
@ -1016,14 +957,13 @@ static inline bool apply_lookup (hb_apply_context_t *c,
lookupRecord++;
lookupCount--;
i++;
/* Err, this is wrong if the lookup jumped over some glyphs */
i += c->buffer->idx - old_pos;
if (!done)
goto not_applied;
else
{
if (c->table_index == 1)
c->buffer->idx = old_pos + 1;
/* Reinitialize iterator. */
hb_apply_context_t::skipping_forward_iterator_t tmp (c, c->buffer->idx - 1, count - i);
tmp.set_syllable (syllable);
@ -1052,14 +992,13 @@ static inline bool apply_lookup (hb_apply_context_t *c,
lookupRecord++;
lookupCount--;
i++;
/* Err, this is wrong if the lookup jumped over some glyphs */
i += c->buffer->idx - old_pos;
if (!done)
goto not_applied2;
else
{
if (c->table_index == 1)
c->buffer->idx = old_pos + 1;
/* Reinitialize iterator. */
hb_apply_context_t::skipping_forward_iterator_t tmp (c, c->buffer->idx - 1, count - i);
tmp.set_syllable (syllable);
@ -1157,17 +1096,6 @@ static inline bool context_apply_lookup (hb_apply_context_t *c,
struct Rule
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0));
unsigned int count = lookupCount;
for (unsigned int i = 0; i < count; i++)
if (!c->recurse (lookupRecord[i].lookupListIndex))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{
TRACE_CLOSURE (this);
@ -1227,16 +1155,6 @@ struct Rule
struct RuleSet
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if (!(this+rule[i]).is_inplace (c))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{
TRACE_CLOSURE (this);
@ -1293,16 +1211,6 @@ struct RuleSet
struct ContextFormat1
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
unsigned int count = ruleSet.len;
for (unsigned int i = 0; i < count; i++)
if (!(this+ruleSet[i]).is_inplace (c))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -1389,16 +1297,6 @@ struct ContextFormat1
struct ContextFormat2
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
unsigned int count = ruleSet.len;
for (unsigned int i = 0; i < count; i++)
if (!(this+ruleSet[i]).is_inplace (c))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -1494,17 +1392,6 @@ struct ContextFormat2
struct ContextFormat3
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
unsigned int count = lookupCount;
for (unsigned int i = 0; i < count; i++)
if (!c->recurse (lookupRecord[i].lookupListIndex))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -1667,7 +1554,7 @@ static inline void chain_context_closure_lookup (hb_closure_context_t *c,
&& intersects_array (c,
inputCount ? inputCount - 1 : 0, input,
lookup_context.funcs.intersects, lookup_context.intersects_data[1])
&& intersects_array (c,
&& intersects_array (c,
lookaheadCount, lookahead,
lookup_context.funcs.intersects, lookup_context.intersects_data[2]))
recurse_lookups (c,
@ -1746,19 +1633,6 @@ static inline bool chain_context_apply_lookup (hb_apply_context_t *c,
struct ChainRule
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
const HeadlessArrayOf<USHORT> &input = StructAfter<HeadlessArrayOf<USHORT> > (backtrack);
const ArrayOf<USHORT> &lookahead = StructAfter<ArrayOf<USHORT> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
unsigned int count = lookup.len;
for (unsigned int i = 0; i < count; i++)
if (!c->recurse (lookup.array[i].lookupListIndex))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const
{
TRACE_CLOSURE (this);
@ -1844,16 +1718,6 @@ struct ChainRule
struct ChainRuleSet
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
if (!(this+rule[i]).is_inplace (c))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c, ChainContextClosureLookupContext &lookup_context) const
{
TRACE_CLOSURE (this);
@ -1907,16 +1771,6 @@ struct ChainRuleSet
struct ChainContextFormat1
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
unsigned int count = ruleSet.len;
for (unsigned int i = 0; i < count; i++)
if (!(this+ruleSet[i]).is_inplace (c))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -2000,16 +1854,6 @@ struct ChainContextFormat1
struct ChainContextFormat2
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
unsigned int count = ruleSet.len;
for (unsigned int i = 0; i < count; i++)
if (!(this+ruleSet[i]).is_inplace (c))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);
@ -2134,20 +1978,6 @@ struct ChainContextFormat2
struct ChainContextFormat3
{
inline bool is_inplace (hb_is_inplace_context_t *c) const
{
TRACE_IS_INPLACE (this);
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
unsigned int count = lookup.len;
for (unsigned int i = 0; i < count; i++)
if (!c->recurse (lookup.array[i].lookupListIndex))
return TRACE_RETURN (false);
return TRACE_RETURN (true);
}
inline void closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE (this);

View File

@ -1,229 +0,0 @@
/*
* Copyright © 2013 Google, Inc.
*
* This is part of HarfBuzz, a text shaping 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.
*
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_LAYOUT_JSTF_TABLE_HH
#define HB_OT_LAYOUT_JSTF_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-ot-layout-gpos-table.hh"
namespace OT {
/*
* JstfModList -- Justification Modification List Tables
*/
typedef IndexArray JstfModList;
/*
* JstfMax -- Justification Maximum Table
*/
typedef OffsetListOf<PosLookup> JstfMax;
/*
* JstfPriority -- Justification Priority Table
*/
struct JstfPriority
{
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this);
return TRACE_RETURN (c->check_struct (this) &&
shrinkageEnableGSUB.sanitize (c, this) &&
shrinkageDisableGSUB.sanitize (c, this) &&
shrinkageEnableGPOS.sanitize (c, this) &&
shrinkageDisableGPOS.sanitize (c, this) &&
shrinkageJstfMax.sanitize (c, this) &&
extensionEnableGSUB.sanitize (c, this) &&
extensionDisableGSUB.sanitize (c, this) &&
extensionEnableGPOS.sanitize (c, this) &&
extensionDisableGPOS.sanitize (c, this) &&
extensionJstfMax.sanitize (c, this));
}
protected:
OffsetTo<JstfModList>
shrinkageEnableGSUB; /* Offset to Shrinkage Enable GSUB
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfModList>
shrinkageDisableGSUB; /* Offset to Shrinkage Disable GSUB
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfModList>
shrinkageEnableGPOS; /* Offset to Shrinkage Enable GPOS
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfModList>
shrinkageDisableGPOS; /* Offset to Shrinkage Disable GPOS
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfMax>
shrinkageJstfMax; /* Offset to Shrinkage JstfMax table--
* from beginning of JstfPriority table
* --may be NULL */
OffsetTo<JstfModList>
extensionEnableGSUB; /* Offset to Extension Enable GSUB
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfModList>
extensionDisableGSUB; /* Offset to Extension Disable GSUB
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfModList>
extensionEnableGPOS; /* Offset to Extension Enable GPOS
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfModList>
extensionDisableGPOS; /* Offset to Extension Disable GPOS
* JstfModList table--from beginning of
* JstfPriority table--may be NULL */
OffsetTo<JstfMax>
extensionJstfMax; /* Offset to Extension JstfMax table--
* from beginning of JstfPriority table
* --may be NULL */
public:
DEFINE_SIZE_STATIC (20);
};
/*
* JstfLangSys -- Justification Language System Table
*/
struct JstfLangSys : OffsetListOf<JstfPriority>
{
inline bool sanitize (hb_sanitize_context_t *c,
const Record<JstfLangSys>::sanitize_closure_t * = NULL) {
TRACE_SANITIZE (this);
return TRACE_RETURN (OffsetListOf<JstfPriority>::sanitize (c));
}
};
/*
* ExtenderGlyphs -- Extender Glyph Table
*/
typedef SortedArrayOf<GlyphID> ExtenderGlyphs;
/*
* JstfScript -- The Justification Table
*/
struct JstfScript
{
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 unsigned int get_lang_sys_tags (unsigned int start_offset,
unsigned int *lang_sys_count /* IN/OUT */,
hb_tag_t *lang_sys_tags /* OUT */) const
{ return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); }
inline const JstfLangSys& get_lang_sys (unsigned int i) const
{
if (i == Index::NOT_FOUND_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 JstfLangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
inline bool sanitize (hb_sanitize_context_t *c,
const Record<JstfScript>::sanitize_closure_t * = NULL) {
TRACE_SANITIZE (this);
return TRACE_RETURN (extenderGlyphs.sanitize (c, this) &&
defaultLangSys.sanitize (c, this) &&
langSys.sanitize (c, this));
}
protected:
OffsetTo<ExtenderGlyphs>
extenderGlyphs; /* Offset to ExtenderGlyph table--from beginning
* of JstfScript table-may be NULL */
OffsetTo<JstfLangSys>
defaultLangSys; /* Offset to DefaultJstfLangSys table--from
* beginning of JstfScript table--may be Null */
RecordArrayOf<JstfLangSys>
langSys; /* Array of JstfLangSysRecords--listed
* alphabetically by LangSysTag */
public:
DEFINE_SIZE_ARRAY (6, langSys);
};
/*
* JSTF -- The Justification Table
*/
struct JSTF
{
static const hb_tag_t tableTag = HB_OT_TAG_JSTF;
inline unsigned int get_script_count (void) const
{ return scriptList.len; }
inline const Tag& get_script_tag (unsigned int i) const
{ return scriptList.get_tag (i); }
inline unsigned int get_script_tags (unsigned int start_offset,
unsigned int *script_count /* IN/OUT */,
hb_tag_t *script_tags /* OUT */) const
{ return scriptList.get_tags (start_offset, script_count, script_tags); }
inline const JstfScript& get_script (unsigned int i) const
{ return this+scriptList[i].offset; }
inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
{ return scriptList.find_index (tag, index); }
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this);
return TRACE_RETURN (version.sanitize (c) && likely (version.major == 1) &&
scriptList.sanitize (c, this));
}
protected:
FixedVersion version; /* Version of the JSTF table--initially set
* to 0x00010000 */
RecordArrayOf<JstfScript>
scriptList; /* Array of JstfScripts--listed
* alphabetically by ScriptTag */
public:
DEFINE_SIZE_ARRAY (6, scriptList);
};
} /* namespace OT */
#endif /* HB_OT_LAYOUT_JSTF_TABLE_HH */

View File

@ -58,12 +58,6 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *uni
info->unicode_props1() = unicode->modified_combining_class (info->codepoint);
}
inline void
_hb_glyph_info_set_general_category (hb_glyph_info_t *info, hb_unicode_general_category_t gen_cat)
{
info->unicode_props0() = (unsigned int) gen_cat | ((info->unicode_props0()) & ~0x1F);
}
inline hb_unicode_general_category_t
_hb_glyph_info_get_general_category (const hb_glyph_info_t *info)
{
@ -208,19 +202,12 @@ HB_INTERNAL void
hb_ot_layout_substitute_start (hb_font_t *font,
hb_buffer_t *buffer);
struct hb_ot_layout_lookup_accelerator_t;
namespace OT {
struct hb_apply_context_t;
struct SubstLookup;
}
HB_INTERNAL void
hb_ot_layout_substitute_lookup (OT::hb_apply_context_t *c,
const OT::SubstLookup &lookup,
const hb_ot_layout_lookup_accelerator_t &accel);
HB_INTERNAL hb_bool_t
hb_ot_layout_substitute_lookup (hb_font_t *font,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask,
hb_bool_t auto_zwj);
/* Should be called after all the substitute_lookup's are done */
HB_INTERNAL void
@ -233,6 +220,13 @@ HB_INTERNAL void
hb_ot_layout_position_start (hb_font_t *font,
hb_buffer_t *buffer);
HB_INTERNAL hb_bool_t
hb_ot_layout_position_lookup (hb_font_t *font,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask,
hb_bool_t auto_zwj);
/* Should be called after all the position_lookup's are done */
HB_INTERNAL void
hb_ot_layout_position_finish (hb_font_t *font,
@ -250,23 +244,6 @@ namespace OT {
struct GPOS;
}
struct hb_ot_layout_lookup_accelerator_t
{
template <typename TLookup>
inline void init (const TLookup &lookup)
{
digest.init ();
lookup.add_coverage (&digest);
}
template <typename TLookup>
inline void fini (const TLookup &lookup)
{
}
hb_set_digest_t digest;
};
struct hb_ot_layout_t
{
hb_blob_t *gdef_blob;
@ -280,8 +257,8 @@ struct hb_ot_layout_t
unsigned int gsub_lookup_count;
unsigned int gpos_lookup_count;
hb_ot_layout_lookup_accelerator_t *gsub_accels;
hb_ot_layout_lookup_accelerator_t *gpos_accels;
hb_set_digest_t *gsub_digests;
hb_set_digest_t *gpos_digests;
};

View File

@ -2,7 +2,7 @@
* Copyright © 1998-2004 David Turner and Werner Lemberg
* Copyright © 2006 Behdad Esfahbod
* Copyright © 2007,2008,2009 Red Hat, Inc.
* Copyright © 2012,2013 Google, Inc.
* Copyright © 2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@ -33,9 +33,6 @@
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
#include "hb-ot-layout-jstf-table.hh"
#include "hb-ot-map-private.hh"
#include <stdlib.h>
#include <string.h>
@ -62,20 +59,26 @@ _hb_ot_layout_create (hb_face_t *face)
layout->gsub_lookup_count = layout->gsub->get_lookup_count ();
layout->gpos_lookup_count = layout->gpos->get_lookup_count ();
layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t));
layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t));
layout->gsub_digests = (hb_set_digest_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_set_digest_t));
layout->gpos_digests = (hb_set_digest_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_set_digest_t));
if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) ||
(layout->gpos_lookup_count && !layout->gpos_accels)))
if (unlikely ((layout->gsub_lookup_count && !layout->gsub_digests) ||
(layout->gpos_lookup_count && !layout->gpos_digests)))
{
_hb_ot_layout_destroy (layout);
return NULL;
}
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
layout->gsub_accels[i].init (layout->gsub->get_lookup (i));
{
layout->gsub_digests[i].init ();
layout->gsub->get_lookup (i).add_coverage (&layout->gsub_digests[i]);
}
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
layout->gpos_accels[i].init (layout->gpos->get_lookup (i));
{
layout->gpos_digests[i].init ();
layout->gpos->get_lookup (i).add_coverage (&layout->gpos_digests[i]);
}
return layout;
}
@ -83,18 +86,13 @@ _hb_ot_layout_create (hb_face_t *face)
void
_hb_ot_layout_destroy (hb_ot_layout_t *layout)
{
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
layout->gsub_accels[i].fini (layout->gsub->get_lookup (i));
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
layout->gpos_accels[i].fini (layout->gpos->get_lookup (i));
free (layout->gsub_accels);
free (layout->gpos_accels);
hb_blob_destroy (layout->gdef_blob);
hb_blob_destroy (layout->gsub_blob);
hb_blob_destroy (layout->gpos_blob);
free (layout->gsub_digests);
free (layout->gpos_digests);
free (layout);
}
@ -447,19 +445,19 @@ _hb_ot_layout_collect_lookups_features (hb_face_t *face,
const hb_tag_t *features,
hb_set_t *lookup_indexes /* OUT */)
{
unsigned int required_feature_index;
if (hb_ot_layout_language_get_required_feature_index (face,
table_tag,
script_index,
language_index,
&required_feature_index))
_hb_ot_layout_collect_lookups_lookups (face,
table_tag,
required_feature_index,
lookup_indexes);
if (!features)
{
unsigned int required_feature_index;
if (hb_ot_layout_language_get_required_feature_index (face,
table_tag,
script_index,
language_index,
&required_feature_index))
_hb_ot_layout_collect_lookups_lookups (face,
table_tag,
required_feature_index,
lookup_indexes);
/* All features */
unsigned int feature_indices[32];
unsigned int offset, len;
@ -615,13 +613,13 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
case HB_OT_TAG_GSUB:
{
const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index);
l.collect_glyphs (&c);
l.collect_glyphs_lookup (&c);
return;
}
case HB_OT_TAG_GPOS:
{
const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index);
l.collect_glyphs (&c);
l.collect_glyphs_lookup (&c);
return;
}
}
@ -661,7 +659,7 @@ hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face,
const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index);
return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index].digest);
return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
}
void
@ -670,6 +668,22 @@ hb_ot_layout_substitute_start (hb_font_t *font, hb_buffer_t *buffer)
OT::GSUB::substitute_start (font, buffer);
}
hb_bool_t
hb_ot_layout_substitute_lookup (hb_font_t *font,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask,
hb_bool_t auto_zwj)
{
if (unlikely (lookup_index >= hb_ot_layout_from_face (font->face)->gsub_lookup_count)) return false;
OT::hb_apply_context_t c (0, font, buffer, mask, auto_zwj);
const OT::SubstLookup& l = hb_ot_layout_from_face (font->face)->gsub->get_lookup (lookup_index);
return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gsub_digests[lookup_index]);
}
void
hb_ot_layout_substitute_finish (hb_font_t *font, hb_buffer_t *buffer)
{
@ -704,6 +718,22 @@ hb_ot_layout_position_start (hb_font_t *font, hb_buffer_t *buffer)
OT::GPOS::position_start (font, buffer);
}
hb_bool_t
hb_ot_layout_position_lookup (hb_font_t *font,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask,
hb_bool_t auto_zwj)
{
if (unlikely (lookup_index >= hb_ot_layout_from_face (font->face)->gpos_lookup_count)) return false;
OT::hb_apply_context_t c (1, font, buffer, mask, auto_zwj);
const OT::PosLookup& l = hb_ot_layout_from_face (font->face)->gpos->get_lookup (lookup_index);
return l.apply_string (&c, &hb_ot_layout_from_face (font->face)->gpos_digests[lookup_index]);
}
void
hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer)
{
@ -754,158 +784,3 @@ hb_ot_layout_get_size_params (hb_face_t *face,
return false;
}
/*
* Parts of different types are implemented here such that they have direct
* access to GSUB/GPOS lookups.
*/
struct GSUBProxy
{
static const unsigned int table_index = 0;
typedef OT::SubstLookup Lookup;
GSUBProxy (hb_face_t *face) :
table (*hb_ot_layout_from_face (face)->gsub),
accels (hb_ot_layout_from_face (face)->gsub_accels) {}
const OT::GSUB &table;
const hb_ot_layout_lookup_accelerator_t *accels;
};
struct GPOSProxy
{
static const unsigned int table_index = 1;
typedef OT::PosLookup Lookup;
GPOSProxy (hb_face_t *face) :
table (*hb_ot_layout_from_face (face)->gpos),
accels (hb_ot_layout_from_face (face)->gpos_accels) {}
const OT::GPOS &table;
const hb_ot_layout_lookup_accelerator_t *accels;
};
template <typename Lookup>
static inline bool apply_once (OT::hb_apply_context_t *c,
const Lookup &lookup)
{
if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props))
return false;
return lookup.dispatch (c);
}
template <typename Proxy>
static inline bool
apply_string (OT::hb_apply_context_t *c,
const typename Proxy::Lookup &lookup,
const hb_ot_layout_lookup_accelerator_t &accel)
{
bool ret = false;
OT::hb_is_inplace_context_t inplace_c (c->face);
bool inplace = lookup.is_inplace (&inplace_c);
if (unlikely (!c->buffer->len || !c->lookup_mask))
return false;
c->set_lookup (lookup);
if (likely (!lookup.is_reverse ()))
{
/* in/out forward substitution/positioning */
if (Proxy::table_index == 0)
c->buffer->clear_output ();
c->buffer->idx = 0;
while (c->buffer->idx < c->buffer->len)
{
if (accel.digest.may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) &&
apply_once (c, lookup))
ret = true;
else
c->buffer->next_glyph ();
}
if (ret)
{
if (!inplace)
c->buffer->swap_buffers ();
else
assert (!c->buffer->has_separate_output ());
}
}
else
{
/* in-place backward substitution/positioning */
if (Proxy::table_index == 0)
c->buffer->remove_output ();
c->buffer->idx = c->buffer->len - 1;
do
{
if (accel.digest.may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) &&
apply_once (c, lookup))
ret = true;
else
c->buffer->idx--;
}
while ((int) c->buffer->idx >= 0);
}
return ret;
}
template <typename Proxy>
inline void hb_ot_map_t::apply (const Proxy &proxy,
const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer) const
{
const unsigned int table_index = proxy.table_index;
unsigned int i = 0;
OT::hb_apply_context_t c (table_index, font, buffer);
c.set_recurse_func (Proxy::Lookup::apply_recurse_func);
for (unsigned int stage_index = 0; stage_index < stages[table_index].len; stage_index++) {
const stage_map_t *stage = &stages[table_index][stage_index];
for (; i < stage->last_lookup; i++)
{
unsigned int lookup_index = lookups[table_index][i].index;
c.set_lookup_mask (lookups[table_index][i].mask);
c.set_auto_zwj (lookups[table_index][i].auto_zwj);
apply_string<Proxy> (&c,
proxy.table.get_lookup (lookup_index),
proxy.accels[lookup_index]);
}
if (stage->pause_func)
{
buffer->clear_output ();
stage->pause_func (plan, font, buffer);
}
}
}
void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
GSUBProxy proxy (font->face);
apply (proxy, plan, font, buffer);
}
void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
GPOSProxy proxy (font->face);
apply (proxy, plan, font, buffer);
}
HB_INTERNAL void
hb_ot_layout_substitute_lookup (OT::hb_apply_context_t *c,
const OT::SubstLookup &lookup,
const hb_ot_layout_lookup_accelerator_t &accel)
{
apply_string<GSUBProxy> (c, lookup, accel);
}

View File

@ -41,7 +41,6 @@ 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')
#define HB_OT_TAG_JSTF HB_TAG('J','S','T','F')
/*

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2009,2010 Red Hat, Inc.
* Copyright © 2010,2011,2012,2013 Google, Inc.
* Copyright © 2010,2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@ -31,8 +31,8 @@
#include "hb-buffer-private.hh"
#include "hb-ot-layout-private.hh"
struct hb_ot_shape_plan_t;
static const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS};
@ -67,9 +67,9 @@ struct hb_ot_map_t
typedef void (*pause_func_t) (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer);
struct stage_map_t {
unsigned int last_lookup; /* Cumulative */
pause_func_t pause_func;
struct pause_map_t {
unsigned int num_lookups; /* Cumulative */
pause_func_t callback;
};
@ -110,27 +110,23 @@ struct hb_ot_map_t
*lookup_count = 0;
return;
}
assert (stage <= stages[table_index].len);
unsigned int start = stage ? stages[table_index][stage - 1].last_lookup : 0;
unsigned int end = stage < stages[table_index].len ? stages[table_index][stage].last_lookup : lookups[table_index].len;
assert (stage <= pauses[table_index].len);
unsigned int start = stage ? pauses[table_index][stage - 1].num_lookups : 0;
unsigned int end = stage < pauses[table_index].len ? pauses[table_index][stage].num_lookups : lookups[table_index].len;
*plookups = &lookups[table_index][start];
*lookup_count = end - start;
}
HB_INTERNAL void collect_lookups (unsigned int table_index, hb_set_t *lookups) const;
template <typename Proxy>
HB_INTERNAL inline void apply (const Proxy &proxy,
const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const;
HB_INTERNAL void substitute (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const;
HB_INTERNAL void position (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const;
inline void finish (void) {
features.finish ();
for (unsigned int table_index = 0; table_index < 2; table_index++)
{
lookups[table_index].finish ();
stages[table_index].finish ();
}
lookups[0].finish ();
lookups[1].finish ();
pauses[0].finish ();
pauses[1].finish ();
}
public:
@ -149,7 +145,7 @@ struct hb_ot_map_t
hb_prealloced_array_t<feature_map_t, 8> features;
hb_prealloced_array_t<lookup_map_t, 32> lookups[2]; /* GSUB/GPOS */
hb_prealloced_array_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */
hb_prealloced_array_t<pause_map_t, 1> pauses[2]; /* GSUB/GPOS */
};
enum hb_ot_map_feature_flags_t {
@ -199,10 +195,8 @@ struct hb_ot_map_builder_t
inline void finish (void) {
feature_infos.finish ();
for (unsigned int table_index = 0; table_index < 2; table_index++)
{
stages[table_index].finish ();
}
pauses[0].finish ();
pauses[1].finish ();
}
private:
@ -219,9 +213,9 @@ struct hb_ot_map_builder_t
{ return (a->tag != b->tag) ? (a->tag < b->tag ? -1 : 1) : (a->seq < b->seq ? -1 : 1); }
};
struct stage_info_t {
unsigned int index;
hb_ot_map_t::pause_func_t pause_func;
struct pause_info_t {
unsigned int stage;
hb_ot_map_t::pause_func_t callback;
};
HB_INTERNAL void add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func);
@ -238,8 +232,8 @@ struct hb_ot_map_builder_t
private:
unsigned int current_stage[2]; /* GSUB/GPOS */
hb_prealloced_array_t<feature_info_t, 32> feature_infos;
hb_prealloced_array_t<stage_info_t, 8> stages[2]; /* GSUB/GPOS */
hb_prealloced_array_t<feature_info_t,16> feature_infos;
hb_prealloced_array_t<pause_info_t, 1> pauses[2]; /* GSUB/GPOS */
};

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2009,2010 Red Hat, Inc.
* Copyright © 2010,2011,2013 Google, Inc.
* Copyright © 2010,2011 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@ -28,8 +28,6 @@
#include "hb-ot-map-private.hh"
#include "hb-ot-layout-private.hh"
void
hb_ot_map_t::add_lookups (hb_face_t *face,
@ -102,6 +100,54 @@ void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value,
info->stage[1] = current_stage[1];
}
/* Keep the next two functions in sync. */
void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
const unsigned int table_index = 0;
unsigned int i = 0;
for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; pause_index++) {
const pause_map_t *pause = &pauses[table_index][pause_index];
for (; i < pause->num_lookups; i++)
hb_ot_layout_substitute_lookup (font, buffer,
lookups[table_index][i].index,
lookups[table_index][i].mask,
lookups[table_index][i].auto_zwj);
buffer->clear_output ();
if (pause->callback)
pause->callback (plan, font, buffer);
}
for (; i < lookups[table_index].len; i++)
hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index,
lookups[table_index][i].mask,
lookups[table_index][i].auto_zwj);
}
void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
const unsigned int table_index = 1;
unsigned int i = 0;
for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; pause_index++) {
const pause_map_t *pause = &pauses[table_index][pause_index];
for (; i < pause->num_lookups; i++)
hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index,
lookups[table_index][i].mask,
lookups[table_index][i].auto_zwj);
if (pause->callback)
pause->callback (plan, font, buffer);
}
for (; i < lookups[table_index].len; i++)
hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index,
lookups[table_index][i].mask,
lookups[table_index][i].auto_zwj);
}
void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const
{
@ -111,10 +157,10 @@ void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_o
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func)
{
stage_info_t *s = stages[table_index].push ();
if (likely (s)) {
s->index = current_stage[table_index];
s->pause_func = pause_func;
pause_info_t *p = pauses[table_index].push ();
if (likely (p)) {
p->stage = current_stage[table_index];
p->callback = pause_func;
}
current_stage[table_index]++;
@ -231,7 +277,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m)
&required_feature_index))
m.add_lookups (face, table_index, required_feature_index, 1, true);
unsigned int stage_index = 0;
unsigned int pause_index = 0;
unsigned int last_num_lookups = 0;
for (unsigned stage = 0; stage < current_stage[table_index]; stage++)
{
@ -261,14 +307,14 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m)
last_num_lookups = m.lookups[table_index].len;
if (stage_index < stages[table_index].len && stages[table_index][stage_index].index == stage) {
hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push ();
if (likely (stage_map)) {
stage_map->last_lookup = last_num_lookups;
stage_map->pause_func = stages[table_index][stage_index].pause_func;
if (pause_index < pauses[table_index].len && pauses[table_index][pause_index].stage == stage) {
hb_ot_map_t::pause_map_t *pause_map = m.pauses[table_index].push ();
if (likely (pause_map)) {
pause_map->num_lookups = last_num_lookups;
pause_map->callback = pauses[table_index][pause_index].callback;
}
stage_index++;
pause_index++;
}
}
}

View File

@ -41,7 +41,7 @@ namespace OT {
struct maxp
{
static const hb_tag_t tableTag = HB_OT_TAG_maxp;
static const hb_tag_t Tag = HB_OT_TAG_maxp;
inline unsigned int get_num_glyphs (void) const {
return numGlyphs;

View File

@ -74,7 +74,7 @@ struct NameRecord
struct name
{
static const hb_tag_t tableTag = HB_OT_TAG_name;
static const hb_tag_t Tag = HB_OT_TAG_name;
inline unsigned int get_name (unsigned int platform_id,
unsigned int encoding_id,
@ -98,9 +98,6 @@ struct name
return length;
}
inline unsigned int get_size (void) const
{ return min_size + count * nameRecord[0].min_size; }
inline bool sanitize_records (hb_sanitize_context_t *c) {
TRACE_SANITIZE (this);
char *string_pool = (char *) this + stringOffset;
@ -119,6 +116,7 @@ struct name
}
/* We only implement format 0 for now. */
protected:
USHORT format; /* Format selector (=0/1). */
USHORT count; /* Number of name records. */
Offset stringOffset; /* Offset to start of string storage (from start of table). */

View File

@ -199,7 +199,7 @@ struct arabic_fallback_plan_t
hb_mask_t mask_array[ARABIC_NUM_FALLBACK_FEATURES];
OT::SubstLookup *lookup_array[ARABIC_NUM_FALLBACK_FEATURES];
hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_NUM_FALLBACK_FEATURES];
hb_set_digest_t digest_array[ARABIC_NUM_FALLBACK_FEATURES];
};
static const arabic_fallback_plan_t arabic_fallback_plan_nil = {};
@ -214,11 +214,12 @@ arabic_fallback_plan_create (const hb_ot_shape_plan_t *plan,
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
{
fallback_plan->digest_array[i].init ();
fallback_plan->mask_array[i] = plan->map.get_1_mask (arabic_fallback_features[i]);
if (fallback_plan->mask_array[i]) {
fallback_plan->lookup_array[i] = arabic_fallback_synthesize_lookup (plan, font, i);
if (fallback_plan->lookup_array[i])
fallback_plan->accel_array[i].init (*fallback_plan->lookup_array[i]);
fallback_plan->lookup_array[i]->add_coverage (&fallback_plan->digest_array[i]);
}
}
@ -233,10 +234,7 @@ arabic_fallback_plan_destroy (arabic_fallback_plan_t *fallback_plan)
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
if (fallback_plan->lookup_array[i])
{
fallback_plan->accel_array[i].fini (fallback_plan->lookup_array[i]);
free (fallback_plan->lookup_array[i]);
}
free (fallback_plan);
}
@ -246,13 +244,10 @@ arabic_fallback_plan_shape (arabic_fallback_plan_t *fallback_plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
OT::hb_apply_context_t c (0, font, buffer);
for (unsigned int i = 0; i < ARABIC_NUM_FALLBACK_FEATURES; i++)
if (fallback_plan->lookup_array[i]) {
c.set_lookup_mask (fallback_plan->mask_array[i]);
hb_ot_layout_substitute_lookup (&c,
*fallback_plan->lookup_array[i],
fallback_plan->accel_array[i]);
OT::hb_apply_context_t c (0, font, buffer, fallback_plan->mask_array[i], true/*auto_zwj*/);
fallback_plan->lookup_array[i]->apply_string (&c, &fallback_plan->digest_array[i]);
}
}

View File

@ -193,6 +193,7 @@ collect_features_arabic (hb_ot_shape_planner_t *plan)
map->add_gsub_pause (NULL);
map->add_global_bool_feature (HB_TAG('c','s','w','h'));
map->add_global_bool_feature (HB_TAG('d','l','i','g'));
map->add_global_bool_feature (HB_TAG('m','s','e','t'));
}

View File

@ -32,7 +32,7 @@
#include "hb-private.hh"
#line 36 "hb-ot-shape-complex-indic-machine.hh.tmp"
#line 36 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
static const unsigned char _indic_syllable_machine_trans_keys[] = {
1u, 16u, 13u, 13u, 5u, 7u, 5u, 7u, 7u, 7u, 5u, 7u, 5u, 7u, 7u, 7u,
5u, 7u, 5u, 7u, 7u, 7u, 5u, 7u, 5u, 7u, 7u, 7u, 4u, 4u, 6u, 6u,
@ -1269,7 +1269,7 @@ find_syllables (hb_buffer_t *buffer)
int cs;
hb_glyph_info_t *info = buffer->info;
#line 1273 "hb-ot-shape-complex-indic-machine.hh.tmp"
#line 1273 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
{
cs = indic_syllable_machine_start;
ts = 0;
@ -1286,7 +1286,7 @@ find_syllables (hb_buffer_t *buffer)
unsigned int last = 0;
unsigned int syllable_serial = 1;
#line 1290 "hb-ot-shape-complex-indic-machine.hh.tmp"
#line 1290 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
{
int _slen;
int _trans;
@ -1300,7 +1300,7 @@ _resume:
#line 1 "NONE"
{ts = p;}
break;
#line 1304 "hb-ot-shape-complex-indic-machine.hh.tmp"
#line 1304 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
}
_keys = _indic_syllable_machine_trans_keys + (cs<<1);
@ -1411,7 +1411,7 @@ _eof_trans:
#line 87 "../../src/hb-ot-shape-complex-indic-machine.rl"
{act = 5;}
break;
#line 1415 "hb-ot-shape-complex-indic-machine.hh.tmp"
#line 1415 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
}
_again:
@ -1420,7 +1420,7 @@ _again:
#line 1 "NONE"
{ts = 0;}
break;
#line 1424 "hb-ot-shape-complex-indic-machine.hh.tmp"
#line 1424 "../../src/hb-ot-shape-complex-indic-machine.hh.tmp"
}
if ( ++p != pe )

View File

@ -319,7 +319,6 @@ static const indic_config_t indic_configs[] =
{HB_SCRIPT_MALAYALAM, true, 0x0D4D,BASE_POS_LAST, REPH_POS_AFTER_MAIN, REPH_MODE_LOG_REPHA},
{HB_SCRIPT_SINHALA, false,0x0DCA,BASE_POS_FIRST,REPH_POS_AFTER_MAIN, REPH_MODE_EXPLICIT},
{HB_SCRIPT_KHMER, false,0x17D2,BASE_POS_FIRST,REPH_POS_DEFAULT, REPH_MODE_VIS_REPHA},
{HB_SCRIPT_JAVANESE, false,0xA9C0,BASE_POS_LAST, REPH_POS_DEFAULT, REPH_MODE_IMPLICIT},
};
@ -445,10 +444,6 @@ override_features_indic (hb_ot_shape_planner_t *plan)
if (hb_options ().uniscribe_bug_compatible)
plan->map.add_feature (HB_TAG('k','e','r','n'), 0, F_GLOBAL);
/* 'calt' is enabled by default in hb-ot-shape.cc, but is a discretionary,
non-default feature for Indic scripts. */
plan->map.add_feature (HB_TAG('c','a','l','t'), 0, F_GLOBAL);
plan->map.add_feature (HB_TAG('l','i','g','a'), 0, F_GLOBAL);
}

View File

@ -104,6 +104,17 @@ static void
override_features_myanmar (hb_ot_shape_planner_t *plan)
{
plan->map.add_feature (HB_TAG('l','i','g','a'), 0, F_GLOBAL);
/*
* Note:
*
* Spec says 'mark' is used, and the mmrtext.ttf font from
* Windows 8 has lookups for it. But testing suggests that
* Windows 8 Uniscribe is NOT applying it. It *is* applying
* 'mkmk' however.
*/
if (hb_options ().uniscribe_bug_compatible)
plan->map.add_feature (HB_TAG('m','a','r','k'), 0, F_GLOBAL);
}

View File

@ -161,8 +161,6 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
/* Unicode-1.1 additions */
case HB_SCRIPT_ARABIC:
/* Unicode-3.0 additions */
case HB_SCRIPT_MONGOLIAN:
case HB_SCRIPT_SYRIAC:

View File

@ -420,8 +420,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
hb_mask_t kern_mask = plan->map.get_1_mask (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction) ?
HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n'));
OT::hb_apply_context_t c (1, font, buffer);
c.set_lookup_mask (kern_mask);
OT::hb_apply_context_t c (1, font, buffer, kern_mask, true/*auto_zwj*/);
c.set_lookup_props (OT::LookupFlag::IgnoreMarks);
for (buffer->idx = 0; buffer->idx < count;)

View File

@ -217,24 +217,8 @@ handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns
for (; buffer->idx < end - 1;) {
if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepoint))) {
/* The next two lines are some ugly lines... But work. */
if (c->font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &buffer->cur().glyph_index()))
{
buffer->replace_glyphs (2, 1, &buffer->cur().codepoint);
}
else
{
/* Just pass on the two characters separately, let GSUB do its magic. */
set_glyph (buffer->cur(), c->font);
buffer->next_glyph ();
set_glyph (buffer->cur(), c->font);
buffer->next_glyph ();
}
/* Skip any further variation selectors. */
while (buffer->idx < end && unlikely (buffer->unicode->is_variation_selector (buffer->cur().codepoint)))
{
set_glyph (buffer->cur(), c->font);
buffer->next_glyph ();
}
c->font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &buffer->cur().glyph_index());
buffer->replace_glyphs (2, 1, &buffer->cur().codepoint);
} else {
set_glyph (buffer->cur(), c->font);
buffer->next_glyph ();

View File

@ -30,7 +30,8 @@
#include "hb-private.hh"
#include "hb-ot-map-private.hh"
#include "hb-ot-layout-private.hh"

View File

@ -58,8 +58,17 @@ static hb_tag_t horizontal_features[] = {
HB_TAG('r','c','l','t'),
};
/* Note:
* Technically speaking, vrt2 and vert are mutually exclusive.
* According to the spec, valt and vpal are also mutually exclusive.
* But we apply them all for now.
*/
static hb_tag_t vertical_features[] = {
HB_TAG('v','a','l','t'),
HB_TAG('v','e','r','t'),
HB_TAG('v','k','r','n'),
HB_TAG('v','p','a','l'),
HB_TAG('v','r','t','2'),
};
@ -418,6 +427,8 @@ zero_mark_widths_by_gdef (hb_buffer_t *buffer)
static inline void
hb_ot_position_default (hb_ot_shape_context_t *c)
{
hb_ot_layout_position_start (c->font, c->buffer);
unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++)
{
@ -431,13 +442,6 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
&c->buffer->pos[i].y_offset);
}
}
static inline bool
hb_ot_position_complex (hb_ot_shape_context_t *c)
{
bool ret = false;
unsigned int count = c->buffer->len;
switch (c->plan->shaper->zero_width_marks)
{
@ -457,6 +461,13 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE:
break;
}
}
static inline bool
hb_ot_position_complex (hb_ot_shape_context_t *c)
{
bool ret = false;
unsigned int count = c->buffer->len;
if (hb_ot_layout_has_positioning (c->face))
{
@ -498,20 +509,18 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
break;
}
hb_ot_layout_position_finish (c->font, c->buffer);
return ret;
}
static inline void
hb_ot_position (hb_ot_shape_context_t *c)
{
hb_ot_layout_position_start (c->font, c->buffer);
hb_ot_position_default (c);
hb_bool_t fallback = !hb_ot_position_complex (c);
hb_ot_layout_position_finish (c->font, c->buffer);
if (fallback && c->plan->shaper->fallback_position)
_hb_ot_shape_fallback_position (c->plan, c->font, c->buffer);

View File

@ -321,22 +321,14 @@ struct hb_prealloced_array_t
inline void pop (void)
{
len--;
}
inline void remove (unsigned int i)
{
if (unlikely (i >= len))
return;
memmove (static_cast<void *> (&array[i]),
static_cast<void *> (&array[i + 1]),
(len - i - 1) * sizeof (Type));
len--;
/* TODO: shrink array if needed */
}
inline void shrink (unsigned int l)
{
if (l < len)
len = l;
/* TODO: shrink array if needed */
}
template <typename T>
@ -384,7 +376,7 @@ struct hb_prealloced_array_t
}
};
#define HB_AUTO_ARRAY_PREALLOCED 16
#define HB_AUTO_ARRAY_PREALLOCED 64
template <typename Type>
struct hb_auto_array_t : hb_prealloced_array_t <Type, HB_AUTO_ARRAY_PREALLOCED>
{
@ -571,8 +563,8 @@ _hb_debug (unsigned int level,
return level < max_level;
}
#define DEBUG_LEVEL_ENABLED(WHAT, LEVEL) (_hb_debug ((LEVEL), HB_DEBUG_##WHAT))
#define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0))
#define DEBUG_LEVEL(WHAT, LEVEL) (_hb_debug ((LEVEL), HB_DEBUG_##WHAT))
#define DEBUG(WHAT) (DEBUG_LEVEL (WHAT, 0))
template <int max_level> static inline void
_hb_debug_msg_va (const char *what,
@ -603,7 +595,7 @@ _hb_debug_msg_va (const char *what,
#define ULBAR "\342\225\257" /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */
#define LBAR "\342\225\264" /* U+2574 BOX DRAWINGS LIGHT LEFT */
static const char bars[] = VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR;
fprintf (stderr, "%2u %s" VRBAR "%s",
fprintf (stderr, "%2d %s" VRBAR "%s",
level,
bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars), (unsigned int) (sizeof (VBAR) - 1) * level),
level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR);

View File

@ -45,14 +45,12 @@ struct hb_set_digest_lowest_bits_t
{
ASSERT_POD ();
static const unsigned int mask_bytes = sizeof (mask_t);
static const unsigned int mask_bits = sizeof (mask_t) * 8;
static const unsigned int num_bits = 0
+ (mask_bytes >= 1 ? 3 : 0)
+ (mask_bytes >= 2 ? 1 : 0)
+ (mask_bytes >= 4 ? 1 : 0)
+ (mask_bytes >= 8 ? 1 : 0)
+ (mask_bytes >= 16? 1 : 0)
+ (sizeof (mask_t) >= 1 ? 3 : 0)
+ (sizeof (mask_t) >= 2 ? 1 : 0)
+ (sizeof (mask_t) >= 4 ? 1 : 0)
+ (sizeof (mask_t) >= 8 ? 1 : 0)
+ (sizeof (mask_t) >= 16? 1 : 0)
+ 0;
ASSERT_STATIC (shift < sizeof (hb_codepoint_t) * 8);
@ -67,7 +65,7 @@ struct hb_set_digest_lowest_bits_t
}
inline void add_range (hb_codepoint_t a, hb_codepoint_t b) {
if ((b >> shift) - (a >> shift) >= mask_bits - 1)
if ((b >> shift) - (a >> shift) >= sizeof (mask_t) * 8 - 1)
mask = (mask_t) -1;
else {
mask_t ma = mask_for (a);
@ -83,7 +81,7 @@ struct hb_set_digest_lowest_bits_t
private:
static inline mask_t mask_for (hb_codepoint_t g) {
return ((mask_t) 1) << ((g >> shift) & (mask_bits - 1));
return ((mask_t) 1) << ((g >> shift) & (sizeof (mask_t) * 8 - 1));
}
mask_t mask;
};
@ -171,7 +169,7 @@ struct hb_set_t
inline void add (hb_codepoint_t g)
{
if (unlikely (in_error)) return;
if (unlikely (g == INVALID)) return;
if (unlikely (g == SENTINEL)) return;
if (unlikely (g > MAX_G)) return;
elt (g) |= mask (g);
}
@ -256,22 +254,19 @@ struct hb_set_t
}
inline bool next (hb_codepoint_t *codepoint) const
{
if (unlikely (*codepoint == INVALID)) {
if (unlikely (*codepoint == SENTINEL)) {
hb_codepoint_t i = get_min ();
if (i != INVALID) {
if (i != SENTINEL) {
*codepoint = i;
return true;
} else {
*codepoint = INVALID;
} else
return false;
}
}
for (hb_codepoint_t i = *codepoint + 1; i < MAX_G + 1; i++)
if (has (i)) {
*codepoint = i;
return true;
}
*codepoint = INVALID;
return false;
}
inline bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const
@ -280,10 +275,7 @@ struct hb_set_t
i = *last;
if (!next (&i))
{
*last = *first = INVALID;
return false;
}
*last = *first = i;
while (next (&i) && i == *last + 1)
@ -306,7 +298,7 @@ struct hb_set_t
for (unsigned int j = 0; j < BITS; j++)
if (elts[i] & (1 << j))
return i * BITS + j;
return INVALID;
return SENTINEL;
}
inline hb_codepoint_t get_max (void) const
{
@ -315,7 +307,7 @@ struct hb_set_t
for (unsigned int j = BITS; j; j--)
if (elts[i - 1] & (1 << (j - 1)))
return (i - 1) * BITS + (j - 1);
return INVALID;
return SENTINEL;
}
typedef uint32_t elt_t;
@ -324,7 +316,7 @@ struct hb_set_t
static const unsigned int BITS = (1 << SHIFT);
static const unsigned int MASK = BITS - 1;
static const unsigned int ELTS = (MAX_G + 1 + (BITS - 1)) / BITS;
static const hb_codepoint_t INVALID = HB_SET_VALUE_INVALID;
static const hb_codepoint_t SENTINEL = (hb_codepoint_t) -1;
elt_t &elt (hb_codepoint_t g) { return elts[g >> SHIFT]; }
elt_t elt (hb_codepoint_t g) const { return elts[g >> SHIFT]; }

View File

@ -30,13 +30,6 @@
/* Public API */
/**
* hb_set_create: (Xconstructor)
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_set_t *
hb_set_create (void)
{
@ -50,13 +43,6 @@ hb_set_create (void)
return set;
}
/**
* hb_set_get_empty:
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_set_t *
hb_set_get_empty (void)
{
@ -70,26 +56,12 @@ hb_set_get_empty (void)
return const_cast<hb_set_t *> (&_hb_set_nil);
}
/**
* hb_set_reference: (skip)
* @set: a set.
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_set_t *
hb_set_reference (hb_set_t *set)
{
return hb_object_reference (set);
}
/**
* hb_set_destroy: (skip)
* @set: a set.
*
* Since: 1.0
**/
void
hb_set_destroy (hb_set_t *set)
{
@ -100,18 +72,6 @@ hb_set_destroy (hb_set_t *set)
free (set);
}
/**
* hb_set_set_user_data: (skip)
* @set: a set.
* @key:
* @data:
* @destroy (closure data):
* @replace:
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_set_set_user_data (hb_set_t *set,
hb_user_data_key_t *key,
@ -122,15 +82,6 @@ hb_set_set_user_data (hb_set_t *set,
return hb_object_set_user_data (set, key, data, destroy, replace);
}
/**
* hb_set_get_user_data: (skip)
* @set: a set.
* @key:
*
* Return value: (transfer none):
*
* Since: 1.0
**/
void *
hb_set_get_user_data (hb_set_t *set,
hb_user_data_key_t *key)
@ -139,63 +90,24 @@ hb_set_get_user_data (hb_set_t *set,
}
/**
* hb_set_allocation_successful:
* @set: a set.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_set_allocation_successful (const hb_set_t *set HB_UNUSED)
{
return !set->in_error;
}
/**
* hb_set_clear:
* @set: a set.
*
*
*
* Since: 1.0
**/
void
hb_set_clear (hb_set_t *set)
{
set->clear ();
}
/**
* hb_set_is_empty:
* @set: a set.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_set_is_empty (const hb_set_t *set)
{
return set->is_empty ();
}
/**
* hb_set_has:
* @set: a set.
* @codepoint:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_set_has (const hb_set_t *set,
hb_codepoint_t codepoint)
@ -203,15 +115,6 @@ hb_set_has (const hb_set_t *set,
return set->has (codepoint);
}
/**
* hb_set_add:
* @set: a set.
* @codepoint:
*
*
*
* Since: 1.0
**/
void
hb_set_add (hb_set_t *set,
hb_codepoint_t codepoint)
@ -219,16 +122,6 @@ hb_set_add (hb_set_t *set,
set->add (codepoint);
}
/**
* hb_set_add_range:
* @set: a set.
* @first:
* @last:
*
*
*
* Since: 1.0
**/
void
hb_set_add_range (hb_set_t *set,
hb_codepoint_t first,
@ -237,15 +130,6 @@ hb_set_add_range (hb_set_t *set,
set->add_range (first, last);
}
/**
* hb_set_del:
* @set: a set.
* @codepoint:
*
*
*
* Since: 1.0
**/
void
hb_set_del (hb_set_t *set,
hb_codepoint_t codepoint)
@ -253,16 +137,6 @@ hb_set_del (hb_set_t *set,
set->del (codepoint);
}
/**
* hb_set_del_range:
* @set: a set.
* @first:
* @last:
*
*
*
* Since: 1.0
**/
void
hb_set_del_range (hb_set_t *set,
hb_codepoint_t first,
@ -271,17 +145,6 @@ hb_set_del_range (hb_set_t *set,
set->del_range (first, last);
}
/**
* hb_set_is_equal:
* @set: a set.
* @other:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_set_is_equal (const hb_set_t *set,
const hb_set_t *other)
@ -289,15 +152,6 @@ hb_set_is_equal (const hb_set_t *set,
return set->is_equal (other);
}
/**
* hb_set_set:
* @set: a set.
* @other:
*
*
*
* Since: 1.0
**/
void
hb_set_set (hb_set_t *set,
const hb_set_t *other)
@ -305,15 +159,6 @@ hb_set_set (hb_set_t *set,
set->set (other);
}
/**
* hb_set_union:
* @set: a set.
* @other:
*
*
*
* Since: 1.0
**/
void
hb_set_union (hb_set_t *set,
const hb_set_t *other)
@ -321,15 +166,6 @@ hb_set_union (hb_set_t *set,
set->union_ (other);
}
/**
* hb_set_intersect:
* @set: a set.
* @other:
*
*
*
* Since: 1.0
**/
void
hb_set_intersect (hb_set_t *set,
const hb_set_t *other)
@ -337,15 +173,6 @@ hb_set_intersect (hb_set_t *set,
set->intersect (other);
}
/**
* hb_set_subtract:
* @set: a set.
* @other:
*
*
*
* Since: 1.0
**/
void
hb_set_subtract (hb_set_t *set,
const hb_set_t *other)
@ -353,15 +180,6 @@ hb_set_subtract (hb_set_t *set,
set->subtract (other);
}
/**
* hb_set_symmetric_difference:
* @set: a set.
* @other:
*
*
*
* Since: 1.0
**/
void
hb_set_symmetric_difference (hb_set_t *set,
const hb_set_t *other)
@ -369,79 +187,30 @@ hb_set_symmetric_difference (hb_set_t *set,
set->symmetric_difference (other);
}
/**
* hb_set_invert:
* @set: a set.
*
*
*
* Since: 1.0
**/
void
hb_set_invert (hb_set_t *set)
{
set->invert ();
}
/**
* hb_set_get_population:
* @set: a set.
*
* Returns the number of numbers in the set.
*
* Return value: set population.
*
* Since: 1.0
**/
unsigned int
hb_set_get_population (const hb_set_t *set)
{
return set->get_population ();
}
/**
* hb_set_get_min:
* @set: a set.
*
* Finds the minimum number in the set.
*
* Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
*
* Since: 1.0
**/
hb_codepoint_t
hb_set_get_min (const hb_set_t *set)
{
return set->get_min ();
}
/**
* hb_set_get_max:
* @set: a set.
*
* Finds the maximum number in the set.
*
* Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
*
* Since: 1.0
**/
hb_codepoint_t
hb_set_get_max (const hb_set_t *set)
{
return set->get_max ();
}
/**
* hb_set_next:
* @set: a set.
* @codepoint: (inout):
*
*
*
* Return value: whether there was a next value.
*
* Since: 1.0
**/
hb_bool_t
hb_set_next (const hb_set_t *set,
hb_codepoint_t *codepoint)
@ -449,19 +218,6 @@ hb_set_next (const hb_set_t *set,
return set->next (codepoint);
}
/**
* hb_set_next_range:
* @set: a set.
* @first: (out): output first codepoint in the range.
* @last: (inout): input current last and output last codepoint in the range.
*
* Gets the next consecutive range of numbers in @set that
* are greater than current value of @last.
*
* Return value: whether there was a next range.
*
* Since: 1.0
**/
hb_bool_t
hb_set_next_range (const hb_set_t *set,
hb_codepoint_t *first,

View File

@ -36,8 +36,6 @@
HB_BEGIN_DECLS
#define HB_SET_VALUE_INVALID ((hb_codepoint_t) -1)
typedef struct hb_set_t hb_set_t;

View File

@ -83,20 +83,6 @@ hb_shape_plan_plan (hb_shape_plan_t *shape_plan,
* hb_shape_plan_t
*/
/**
* hb_shape_plan_create: (Xconstructor)
* @face:
* @props:
* @user_features: (array length=num_user_features):
* @num_user_features:
* @shaper_list: (array zero-terminated=1):
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_shape_plan_t *
hb_shape_plan_create (hb_face_t *face,
const hb_segment_properties_t *props,
@ -125,15 +111,6 @@ hb_shape_plan_create (hb_face_t *face,
return shape_plan;
}
/**
* hb_shape_plan_get_empty:
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_shape_plan_t *
hb_shape_plan_get_empty (void)
{
@ -157,30 +134,12 @@ hb_shape_plan_get_empty (void)
return const_cast<hb_shape_plan_t *> (&_hb_shape_plan_nil);
}
/**
* hb_shape_plan_reference: (skip)
* @shape_plan: a shape plan.
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_shape_plan_t *
hb_shape_plan_reference (hb_shape_plan_t *shape_plan)
{
return hb_object_reference (shape_plan);
}
/**
* hb_shape_plan_destroy: (skip)
* @shape_plan: a shape plan.
*
*
*
* Since: 1.0
**/
void
hb_shape_plan_destroy (hb_shape_plan_t *shape_plan)
{
@ -195,20 +154,6 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan)
free (shape_plan);
}
/**
* hb_shape_plan_set_user_data: (skip)
* @shape_plan: a shape plan.
* @key:
* @data:
* @destroy:
* @replace:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_shape_plan_set_user_data (hb_shape_plan_t *shape_plan,
hb_user_data_key_t *key,
@ -219,17 +164,6 @@ hb_shape_plan_set_user_data (hb_shape_plan_t *shape_plan,
return hb_object_set_user_data (shape_plan, key, data, destroy, replace);
}
/**
* hb_shape_plan_get_user_data: (skip)
* @shape_plan: a shape plan.
* @key:
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
void *
hb_shape_plan_get_user_data (hb_shape_plan_t *shape_plan,
hb_user_data_key_t *key)
@ -238,20 +172,6 @@ hb_shape_plan_get_user_data (hb_shape_plan_t *shape_plan,
}
/**
* hb_shape_plan_execute:
* @shape_plan: a shape plan.
* @font: a font.
* @buffer: a buffer.
* @features: (array length=num_features):
* @num_features:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_shape_plan_execute (hb_shape_plan_t *shape_plan,
hb_font_t *font,
@ -318,20 +238,6 @@ hb_shape_plan_matches (const hb_shape_plan_t *shape_plan,
(shape_plan->shaper_func == proposal->shaper_func));
}
/**
* hb_shape_plan_create_cached:
* @face:
* @props:
* @user_features: (array length=num_user_features):
* @num_user_features:
* @shaper_list: (array zero-terminated=1):
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_shape_plan_t *
hb_shape_plan_create_cached (hb_face_t *face,
const hb_segment_properties_t *props,
@ -401,16 +307,6 @@ retry:
return hb_shape_plan_reference (shape_plan);
}
/**
* hb_shape_plan_get_shaper:
* @shape_plan: a shape plan.
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
const char *
hb_shape_plan_get_shaper (hb_shape_plan_t *shape_plan)
{

View File

@ -153,18 +153,6 @@ parse_one_feature (const char **pp, const char *end, hb_feature_t *feature)
*pp == end;
}
/**
* hb_feature_from_string:
* @str: (array length=len):
* @len:
* @feature: (out):
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_feature_from_string (const char *str, int len,
hb_feature_t *feature)
@ -175,16 +163,6 @@ hb_feature_from_string (const char *str, int len,
return parse_one_feature (&str, str + len, feature);
}
/**
* hb_feature_to_string:
* @feature:
* @buf: (array length=size):
* @size:
*
*
*
* Since: 1.0
**/
void
hb_feature_to_string (hb_feature_t *feature,
char *buf, unsigned int size)
@ -203,23 +181,23 @@ hb_feature_to_string (hb_feature_t *feature,
{
s[len++] = '[';
if (feature->start)
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->start));
len += snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->start);
if (feature->end != feature->start + 1) {
s[len++] = ':';
if (feature->end != (unsigned int) -1)
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->end));
len += snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->end);
}
s[len++] = ']';
}
if (feature->value > 1)
{
s[len++] = '=';
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->value));
len += snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->value);
}
assert (len < ARRAY_LENGTH (s));
len = MIN (len, size - 1);
memcpy (buf, s, len);
buf[len] = '\0';
s[len] = '\0';
}
@ -231,15 +209,6 @@ void free_static_shaper_list (void)
free (static_shaper_list);
}
/**
* hb_shape_list_shapers:
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
const char **
hb_shape_list_shapers (void)
{
@ -275,20 +244,6 @@ retry:
}
/**
* hb_shape_full:
* @font: a font.
* @buffer: a buffer.
* @features: (array length=num_features):
* @num_features:
* @shaper_list: (array zero-terminated=1):
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_shape_full (hb_font_t *font,
hb_buffer_t *buffer,
@ -310,17 +265,6 @@ hb_shape_full (hb_font_t *font,
return res;
}
/**
* hb_shape:
* @font: a font.
* @buffer: a buffer.
* @features: (array length=num_features):
* @num_features:
*
*
*
* Since: 1.0
**/
void
hb_shape (hb_font_t *font,
hb_buffer_t *buffer,

View File

@ -49,7 +49,7 @@ static const hb_script_t ucdn_script_translate[] =
HB_SCRIPT_HANGUL,
HB_SCRIPT_ETHIOPIC,
HB_SCRIPT_CHEROKEE,
HB_SCRIPT_CANADIAN_SYLLABICS,
HB_SCRIPT_CANADIAN_ABORIGINAL,
HB_SCRIPT_OGHAM,
HB_SCRIPT_RUNIC,
HB_SCRIPT_KHMER,

View File

@ -128,9 +128,6 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
* is NOT Default_Ignorable, but it really behaves in a way that it should
* be. That has been reported to the Unicode Technical Committee for
* consideration. As such, we include it here, since Uniscribe removes it.
* It *is* in Unicode 6.3 however. U+061C ARABIC LETTER MARK from Unicode
* 6.3 is also added manually. The new Unicode 6.3 bidi formatting
* characters are encoded in a block that was Default_Ignorable already.
*
* Note: While U+115F and U+1160 are Default_Ignorable, we do NOT want to
* hide them, as the way Uniscribe has implemented them is with regular
@ -176,7 +173,6 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
switch (page) {
case 0x00: return unlikely (ch == 0x00AD);
case 0x03: return unlikely (ch == 0x034F);
case 0x06: return unlikely (ch == 0x061C);
case 0x17: return hb_in_range<hb_codepoint_t> (ch, 0x17B4, 0x17B5);
case 0x18: return hb_in_range<hb_codepoint_t> (ch, 0x180B, 0x180E);
case 0x20: return hb_in_ranges<hb_codepoint_t> (ch, 0x200B, 0x200F,

View File

@ -133,7 +133,7 @@ hb_unicode_funcs_get_default (void)
#ifdef HAVE_GLIB
HB_UNICODE_FUNCS_IMPLEMENT(glib)
#elif 0 && defined(HAVE_ICU)
#elif defined(HAVE_ICU)
HB_UNICODE_FUNCS_IMPLEMENT(icu)
#elif defined(HAVE_UCDN)
HB_UNICODE_FUNCS_IMPLEMENT(ucdn)
@ -150,16 +150,6 @@ hb_unicode_funcs_get_default (void)
#pragma message("To suppress this warnings, define HB_NO_UNICODE_FUNCS.")
#endif
/**
* hb_unicode_funcs_create: (Xconstructor)
* @parent: (allow-none):
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_unicode_funcs_t *
hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
{
@ -197,45 +187,18 @@ const hb_unicode_funcs_t _hb_unicode_funcs_nil = {
}
};
/**
* hb_unicode_funcs_get_empty:
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_unicode_funcs_t *
hb_unicode_funcs_get_empty (void)
{
return const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil);
}
/**
* hb_unicode_funcs_reference: (skip)
* @ufuncs: Unicode functions.
*
*
*
* Return value: (transfer full):
*
* Since: 1.0
**/
hb_unicode_funcs_t *
hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs)
{
return hb_object_reference (ufuncs);
}
/**
* hb_unicode_funcs_destroy: (skip)
* @ufuncs: Unicode functions.
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
{
@ -251,20 +214,6 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
free (ufuncs);
}
/**
* hb_unicode_funcs_set_user_data: (skip)
* @ufuncs: Unicode functions.
* @key:
* @data:
* @destroy:
* @replace:
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs,
hb_user_data_key_t *key,
@ -275,17 +224,6 @@ hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs,
return hb_object_set_user_data (ufuncs, key, data, destroy, replace);
}
/**
* hb_unicode_funcs_get_user_data: (skip)
* @ufuncs: Unicode functions.
* @key:
*
*
*
* Return value: (transfer none):
*
* Since: 1.0
**/
void *
hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs,
hb_user_data_key_t *key)
@ -294,14 +232,6 @@ hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs,
}
/**
* hb_unicode_funcs_make_immutable:
* @ufuncs: Unicode functions.
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
{
@ -311,32 +241,12 @@ hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
ufuncs->immutable = true;
}
/**
* hb_unicode_funcs_is_immutable:
* @ufuncs: Unicode functions.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs)
{
return ufuncs->immutable;
}
/**
* hb_unicode_funcs_get_parent:
* @ufuncs: Unicode functions.
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_unicode_funcs_t *
hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs)
{
@ -384,19 +294,6 @@ hb_unicode_##name (hb_unicode_funcs_t *ufuncs, \
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
#undef HB_UNICODE_FUNC_IMPLEMENT
/**
* hb_unicode_compose:
* @ufuncs: Unicode functions.
* @a:
* @b:
* @ab: (out):
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_unicode_compose (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t a,
@ -406,19 +303,6 @@ hb_unicode_compose (hb_unicode_funcs_t *ufuncs,
return ufuncs->compose (a, b, ab);
}
/**
* hb_unicode_decompose:
* @ufuncs: Unicode functions.
* @ab:
* @a: (out):
* @b: (out):
*
*
*
* Return value:
*
* Since: 1.0
**/
hb_bool_t
hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t ab,
@ -428,18 +312,6 @@ hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
return ufuncs->decompose (ab, a, b);
}
/**
* hb_unicode_decompose_compatibility:
* @ufuncs: Unicode functions.
* @u:
* @decomposed: (out):
*
*
*
* Return value:
*
* Since: 1.0
**/
unsigned int
hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t u,

View File

@ -248,7 +248,7 @@ typedef hb_bool_t (*hb_unicode_decompose_func_t) (hb_unicode_funcs_t *ufuncs,
/**
* hb_unicode_decompose_compatibility_func_t:
* @ufuncs: a Unicode function structure
* @ufuncs: Unicode function structure
* @u: codepoint to decompose
* @decomposed: address of codepoint array (of length %HB_UNICODE_MAX_DECOMPOSITION_LEN) to write decomposition into
* @user_data: user data pointer as passed to hb_unicode_funcs_set_decompose_compatibility_func()
@ -274,132 +274,44 @@ typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_
/* setters */
/**
* hb_unicode_funcs_set_combining_class_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_combining_class_func_t func,
hb_unicode_combining_class_func_t combining_class_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_unicode_funcs_set_eastasian_width_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_eastasian_width_func_t func,
hb_unicode_eastasian_width_func_t eastasian_width_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_unicode_funcs_set_general_category_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_general_category_func_t func,
hb_unicode_general_category_func_t general_category_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_unicode_funcs_set_mirroring_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_mirroring_func_t func,
hb_unicode_mirroring_func_t mirroring_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_unicode_funcs_set_script_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_script_func_t func,
hb_unicode_script_func_t script_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_unicode_funcs_set_compose_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_compose_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_compose_func_t func,
hb_unicode_compose_func_t compose_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_unicode_funcs_set_decompose_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_decompose_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_decompose_func_t func,
hb_unicode_decompose_func_t decompose_func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_unicode_funcs_set_decompose_compatibility_func:
* @ufuncs: a Unicode function structure
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: 1.0
**/
void
hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_decompose_compatibility_func_t func,
hb_unicode_decompose_compatibility_func_t decompose_compatibility_func,
void *user_data, hb_destroy_func_t destroy);
/* accessors */

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2011,2012,2013 Google, Inc.
* Copyright © 2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@ -32,11 +32,9 @@
#include <windows.h>
#include <usp10.h>
#include <rpc.h>
#include "hb-uniscribe.h"
#include "hb-open-file-private.hh"
#include "hb-ot-name-table.hh"
#include "hb-ot-tag.h"
@ -46,249 +44,16 @@
#endif
typedef HRESULT (WINAPI *SIOT) /*ScriptItemizeOpenType*/(
const WCHAR *pwcInChars,
int cInChars,
int cMaxItems,
const SCRIPT_CONTROL *psControl,
const SCRIPT_STATE *psState,
SCRIPT_ITEM *pItems,
OPENTYPE_TAG *pScriptTags,
int *pcItems
/*
DWORD GetFontData(
__in HDC hdc,
__in DWORD dwTable,
__in DWORD dwOffset,
__out LPVOID lpvBuffer,
__in DWORD cbData
);
*/
typedef HRESULT (WINAPI *SSOT) /*ScriptShapeOpenType*/(
HDC hdc,
SCRIPT_CACHE *psc,
SCRIPT_ANALYSIS *psa,
OPENTYPE_TAG tagScript,
OPENTYPE_TAG tagLangSys,
int *rcRangeChars,
TEXTRANGE_PROPERTIES **rpRangeProperties,
int cRanges,
const WCHAR *pwcChars,
int cChars,
int cMaxGlyphs,
WORD *pwLogClust,
SCRIPT_CHARPROP *pCharProps,
WORD *pwOutGlyphs,
SCRIPT_GLYPHPROP *pOutGlyphProps,
int *pcGlyphs
);
typedef HRESULT (WINAPI *SPOT) /*ScriptPlaceOpenType*/(
HDC hdc,
SCRIPT_CACHE *psc,
SCRIPT_ANALYSIS *psa,
OPENTYPE_TAG tagScript,
OPENTYPE_TAG tagLangSys,
int *rcRangeChars,
TEXTRANGE_PROPERTIES **rpRangeProperties,
int cRanges,
const WCHAR *pwcChars,
WORD *pwLogClust,
SCRIPT_CHARPROP *pCharProps,
int cChars,
const WORD *pwGlyphs,
const SCRIPT_GLYPHPROP *pGlyphProps,
int cGlyphs,
int *piAdvance,
GOFFSET *pGoffset,
ABC *pABC
);
/* Fallback implementations. */
static HRESULT WINAPI
hb_ScriptItemizeOpenType(
const WCHAR *pwcInChars,
int cInChars,
int cMaxItems,
const SCRIPT_CONTROL *psControl,
const SCRIPT_STATE *psState,
SCRIPT_ITEM *pItems,
OPENTYPE_TAG *pScriptTags,
int *pcItems
)
{
{
return ScriptItemize (pwcInChars,
cInChars,
cMaxItems,
psControl,
psState,
pItems,
pcItems);
}
}
static HRESULT WINAPI
hb_ScriptShapeOpenType(
HDC hdc,
SCRIPT_CACHE *psc,
SCRIPT_ANALYSIS *psa,
OPENTYPE_TAG tagScript,
OPENTYPE_TAG tagLangSys,
int *rcRangeChars,
TEXTRANGE_PROPERTIES **rpRangeProperties,
int cRanges,
const WCHAR *pwcChars,
int cChars,
int cMaxGlyphs,
WORD *pwLogClust,
SCRIPT_CHARPROP *pCharProps,
WORD *pwOutGlyphs,
SCRIPT_GLYPHPROP *pOutGlyphProps,
int *pcGlyphs
)
{
SCRIPT_VISATTR *psva = (SCRIPT_VISATTR *) pOutGlyphProps;
return ScriptShape (hdc,
psc,
pwcChars,
cChars,
cMaxGlyphs,
psa,
pwOutGlyphs,
pwLogClust,
psva,
pcGlyphs);
}
static HRESULT WINAPI
hb_ScriptPlaceOpenType(
HDC hdc,
SCRIPT_CACHE *psc,
SCRIPT_ANALYSIS *psa,
OPENTYPE_TAG tagScript,
OPENTYPE_TAG tagLangSys,
int *rcRangeChars,
TEXTRANGE_PROPERTIES **rpRangeProperties,
int cRanges,
const WCHAR *pwcChars,
WORD *pwLogClust,
SCRIPT_CHARPROP *pCharProps,
int cChars,
const WORD *pwGlyphs,
const SCRIPT_GLYPHPROP *pGlyphProps,
int cGlyphs,
int *piAdvance,
GOFFSET *pGoffset,
ABC *pABC
)
{
SCRIPT_VISATTR *psva = (SCRIPT_VISATTR *) pGlyphProps;
return ScriptPlace (hdc,
psc,
pwGlyphs,
cGlyphs,
psva,
psa,
piAdvance,
pGoffset,
pABC);
}
struct hb_uniscribe_shaper_funcs_t {
SIOT ScriptItemizeOpenType;
SSOT ScriptShapeOpenType;
SPOT ScriptPlaceOpenType;
inline void init (void)
{
HMODULE hinstLib;
this->ScriptItemizeOpenType = NULL;
this->ScriptShapeOpenType = NULL;
this->ScriptPlaceOpenType = NULL;
hinstLib = GetModuleHandle (TEXT ("usp10.dll"));
if (hinstLib)
{
this->ScriptItemizeOpenType = (SIOT) GetProcAddress (hinstLib, "ScriptItemizeOpenType");
this->ScriptShapeOpenType = (SSOT) GetProcAddress (hinstLib, "ScriptShapeOpenType");
this->ScriptPlaceOpenType = (SPOT) GetProcAddress (hinstLib, "ScriptPlaceOpenType");
}
if (!this->ScriptItemizeOpenType ||
!this->ScriptShapeOpenType ||
!this->ScriptPlaceOpenType)
{
DEBUG_MSG (UNISCRIBE, NULL, "OpenType versions of functions not found; falling back.");
this->ScriptItemizeOpenType = hb_ScriptItemizeOpenType;
this->ScriptShapeOpenType = hb_ScriptShapeOpenType;
this->ScriptPlaceOpenType = hb_ScriptPlaceOpenType;
}
}
};
static hb_uniscribe_shaper_funcs_t *uniscribe_funcs;
static inline void
free_uniscribe_funcs (void)
{
free (uniscribe_funcs);
}
static hb_uniscribe_shaper_funcs_t *
hb_uniscribe_shaper_get_funcs (void)
{
retry:
hb_uniscribe_shaper_funcs_t *funcs = (hb_uniscribe_shaper_funcs_t *) hb_atomic_ptr_get (&uniscribe_funcs);
if (unlikely (!funcs))
{
funcs = (hb_uniscribe_shaper_funcs_t *) calloc (1, sizeof (hb_uniscribe_shaper_funcs_t));
if (unlikely (!funcs))
return NULL;
funcs->init ();
if (!hb_atomic_ptr_cmpexch (&uniscribe_funcs, NULL, funcs)) {
free (funcs);
goto retry;
}
#ifdef HAVE_ATEXIT
atexit (free_uniscribe_funcs); /* First person registers atexit() callback. */
#endif
}
return funcs;
}
struct active_feature_t {
OPENTYPE_FEATURE_RECORD rec;
unsigned int order;
static int cmp (const active_feature_t *a, const active_feature_t *b) {
return a->rec.tagFeature < b->rec.tagFeature ? -1 : a->rec.tagFeature > b->rec.tagFeature ? 1 :
a->order < b->order ? -1 : a->order > b->order ? 1 :
a->rec.lParameter < b->rec.lParameter ? -1 : a->rec.lParameter > b->rec.lParameter ? 1 :
0;
}
bool operator== (const active_feature_t *f) {
return cmp (this, f) == 0;
}
};
struct feature_event_t {
unsigned int index;
bool start;
active_feature_t feature;
static int cmp (const feature_event_t *a, const feature_event_t *b) {
return a->index < b->index ? -1 : a->index > b->index ? 1 :
a->start < b->start ? -1 : a->start > b->start ? 1 :
active_feature_t::cmp (&a->feature, &b->feature);
}
};
struct range_record_t {
TEXTRANGE_PROPERTIES props;
unsigned int index_first; /* == start */
unsigned int index_last; /* == end - 1 */
};
HB_SHAPER_DATA_ENSURE_DECLARE(uniscribe, face)
HB_SHAPER_DATA_ENSURE_DECLARE(uniscribe, font)
@ -300,132 +65,8 @@ HB_SHAPER_DATA_ENSURE_DECLARE(uniscribe, font)
struct hb_uniscribe_shaper_face_data_t {
HANDLE fh;
hb_uniscribe_shaper_funcs_t *funcs;
wchar_t face_name[LF_FACESIZE];
};
/* face_name should point to a wchar_t[LF_FACESIZE] object. */
static void
_hb_generate_unique_face_name (wchar_t *face_name, unsigned int *plen)
{
/* We'll create a private name for the font from a UUID using a simple,
* somewhat base64-like encoding scheme */
const char *enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
UUID id;
UuidCreate ((UUID*) &id);
unsigned int name_str_len = 0;
face_name[name_str_len++] = 'F';
face_name[name_str_len++] = '_';
unsigned char *p = (unsigned char *) &id;
for (unsigned int i = 0; i < 16; i += 2)
{
/* Spread the 16 bits from two bytes of the UUID across three chars of face_name,
* using the bits in groups of 5,5,6 to select chars from enc.
* This will generate 24 characters; with the 'F_' prefix we already provided,
* the name will be 26 chars (plus the NUL terminator), so will always fit within
* face_name (LF_FACESIZE = 32). */
face_name[name_str_len++] = enc[p[i] >> 3];
face_name[name_str_len++] = enc[((p[i] << 2) | (p[i + 1] >> 6)) & 0x1f];
face_name[name_str_len++] = enc[p[i + 1] & 0x3f];
}
face_name[name_str_len] = 0;
if (plen)
*plen = name_str_len;
}
/* Destroys blob. */
static hb_blob_t *
_hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
{
/* Create a copy of the font data, with the 'name' table replaced by a
* table that names the font with our private F_* name created above.
* For simplicity, we just append a new 'name' table and update the
* sfnt directory; the original table is left in place, but unused.
*
* The new table will contain just 5 name IDs: family, style, unique,
* full, PS. All of them point to the same name data with our unique name.
*/
blob = OT::Sanitizer<OT::OpenTypeFontFile>::sanitize (blob);
unsigned int length, new_length, name_str_len;
const char *orig_sfnt_data = hb_blob_get_data (blob, &length);
_hb_generate_unique_face_name (new_name, &name_str_len);
static const uint16_t name_IDs[] = { 1, 2, 3, 4, 6 };
unsigned int name_table_length = OT::name::min_size +
ARRAY_LENGTH (name_IDs) * OT::NameRecord::static_size +
name_str_len * 2; /* for name data in UTF16BE form */
unsigned int name_table_offset = (length + 3) & ~3;
new_length = name_table_offset + ((name_table_length + 3) & ~3);
void *new_sfnt_data = calloc (1, new_length);
if (!new_sfnt_data)
{
hb_blob_destroy (blob);
return NULL;
}
memcpy(new_sfnt_data, orig_sfnt_data, length);
OT::name &name = OT::StructAtOffset<OT::name> (new_sfnt_data, name_table_offset);
name.format.set (0);
name.count.set (ARRAY_LENGTH (name_IDs));
name.stringOffset.set (name.get_size ());
for (unsigned int i = 0; i < ARRAY_LENGTH (name_IDs); i++)
{
OT::NameRecord &record = name.nameRecord[i];
record.platformID.set (3);
record.encodingID.set (1);
record.languageID.set (0x0409); /* English */
record.nameID.set (name_IDs[i]);
record.length.set (name_str_len * 2);
record.offset.set (0);
}
/* Copy string data from new_name, converting wchar_t to UTF16BE. */
unsigned char *p = &OT::StructAfter<unsigned char> (name);
for (unsigned int i = 0; i < name_str_len; i++)
{
*p++ = new_name[i] >> 8;
*p++ = new_name[i] & 0xff;
}
/* Adjust name table entry to point to new name table */
const OT::OpenTypeFontFile &file = * (OT::OpenTypeFontFile *) (new_sfnt_data);
unsigned int face_count = file.get_face_count ();
for (unsigned int face_index = 0; face_index < face_count; face_index++)
{
/* Note: doing multiple edits (ie. TTC) can be unsafe. There may be
* toe-stepping. But we don't really care. */
const OT::OpenTypeFontFace &face = file.get_face (face_index);
unsigned int index;
if (face.find_table_index (HB_OT_TAG_name, &index))
{
OT::TableRecord &record = const_cast<OT::TableRecord &> (face.get_table (index));
record.checkSum.set_for_data (&name, name_table_length);
record.offset.set (name_table_offset);
record.length.set (name_table_length);
}
else if (face_index == 0) /* Fail if first face doesn't have 'name' table. */
{
free (new_sfnt_data);
hb_blob_destroy (blob);
return NULL;
}
}
/* The checkSumAdjustment field in the 'head' table is now wrong,
* but that doesn't actually seem to cause any problems so we don't
* bother. */
hb_blob_destroy (blob);
return hb_blob_create ((const char *) new_sfnt_data, new_length,
HB_MEMORY_MODE_WRITABLE, NULL, free);
}
hb_uniscribe_shaper_face_data_t *
_hb_uniscribe_shaper_face_data_create (hb_face_t *face)
{
@ -433,30 +74,16 @@ _hb_uniscribe_shaper_face_data_create (hb_face_t *face)
if (unlikely (!data))
return NULL;
data->funcs = hb_uniscribe_shaper_get_funcs ();
if (unlikely (!data->funcs))
{
free (data);
return NULL;
}
hb_blob_t *blob = hb_face_reference_blob (face);
if (unlikely (!hb_blob_get_length (blob)))
unsigned int blob_length;
const char *blob_data = hb_blob_get_data (blob, &blob_length);
if (unlikely (!blob_length))
DEBUG_MSG (UNISCRIBE, face, "Face has empty blob");
blob = _hb_rename_font (blob, data->face_name);
if (unlikely (!blob))
{
free (data);
return NULL;
}
DWORD num_fonts_installed;
data->fh = AddFontMemResourceEx ((void *) hb_blob_get_data (blob, NULL),
hb_blob_get_length (blob),
0, &num_fonts_installed);
if (unlikely (!data->fh))
{
data->fh = AddFontMemResourceEx ((void *) blob_data, blob_length, 0, &num_fonts_installed);
hb_blob_destroy (blob);
if (unlikely (!data->fh)) {
DEBUG_MSG (UNISCRIBE, face, "Face AddFontMemResourceEx() failed");
free (data);
return NULL;
@ -492,10 +119,26 @@ populate_log_font (LOGFONTW *lf,
lf->lfHeight = -font->y_scale;
lf->lfCharSet = DEFAULT_CHARSET;
hb_face_t *face = font->face;
hb_uniscribe_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
hb_blob_t *blob = OT::Sanitizer<OT::name>::sanitize (hb_face_reference_table (font->face, HB_TAG ('n','a','m','e')));
const OT::name *name_table = OT::Sanitizer<OT::name>::lock_instance (blob);
unsigned int len = name_table->get_name (3, 1, 0x409, 4,
lf->lfFaceName,
sizeof (lf->lfFaceName[0]) * LF_FACESIZE)
/ sizeof (lf->lfFaceName[0]);
hb_blob_destroy (blob);
memcpy (lf->lfFaceName, face_data->face_name, sizeof (lf->lfFaceName));
if (unlikely (!len)) {
DEBUG_MSG (UNISCRIBE, NULL, "Didn't find English name table entry");
return false;
}
if (unlikely (len >= LF_FACESIZE)) {
DEBUG_MSG (UNISCRIBE, NULL, "Font name too long");
return false;
}
for (unsigned int i = 0; i < len; i++)
lf->lfFaceName[i] = hb_be_uint16 (lf->lfFaceName[i]);
lf->lfFaceName[len] = 0;
return true;
}
@ -597,126 +240,6 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
hb_face_t *face = font->face;
hb_uniscribe_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font);
hb_uniscribe_shaper_funcs_t *funcs = face_data->funcs;
/*
* Set up features.
*/
hb_auto_array_t<OPENTYPE_FEATURE_RECORD> feature_records;
hb_auto_array_t<range_record_t> range_records;
if (num_features)
{
/* Sort features by start/end events. */
hb_auto_array_t<feature_event_t> feature_events;
for (unsigned int i = 0; i < num_features; i++)
{
active_feature_t feature;
feature.rec.tagFeature = hb_uint32_swap (features[i].tag);
feature.rec.lParameter = features[i].value;
feature.order = i;
feature_event_t *event;
event = feature_events.push ();
if (unlikely (!event))
goto fail_features;
event->index = features[i].start;
event->start = true;
event->feature = feature;
event = feature_events.push ();
if (unlikely (!event))
goto fail_features;
event->index = features[i].end;
event->start = false;
event->feature = feature;
}
feature_events.sort ();
/* Add a strategic final event. */
{
active_feature_t feature;
feature.rec.tagFeature = 0;
feature.rec.lParameter = 0;
feature.order = num_features + 1;
feature_event_t *event = feature_events.push ();
if (unlikely (!event))
goto fail_features;
event->index = 0; /* This value does magic. */
event->start = false;
event->feature = feature;
}
/* Scan events and save features for each range. */
hb_auto_array_t<active_feature_t> active_features;
unsigned int last_index = 0;
for (unsigned int i = 0; i < feature_events.len; i++)
{
feature_event_t *event = &feature_events[i];
if (event->index != last_index)
{
/* Save a snapshot of active features and the range. */
range_record_t *range = range_records.push ();
if (unlikely (!range))
goto fail_features;
unsigned int offset = feature_records.len;
active_features.sort ();
for (unsigned int j = 0; j < active_features.len; j++)
{
if (!j || active_features[j].rec.tagFeature != feature_records[feature_records.len - 1].tagFeature)
{
OPENTYPE_FEATURE_RECORD *feature = feature_records.push ();
if (unlikely (!feature))
goto fail_features;
*feature = active_features[j].rec;
}
else
{
/* Overrides value for existing feature. */
feature_records[feature_records.len - 1].lParameter = active_features[j].rec.lParameter;
}
}
/* Will convert to pointer after all is ready, since feature_records.array
* may move as we grow it. */
range->props.potfRecords = reinterpret_cast<OPENTYPE_FEATURE_RECORD *> (offset);
range->props.cotfRecords = feature_records.len - offset;
range->index_first = last_index;
range->index_last = event->index - 1;
last_index = event->index;
}
if (event->start) {
active_feature_t *feature = active_features.push ();
if (unlikely (!feature))
goto fail_features;
*feature = event->feature;
} else {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
active_features.remove (feature - active_features.array);
}
}
if (!range_records.len) /* No active feature found. */
goto fail_features;
/* Fixup the pointers. */
for (unsigned int i = 0; i < range_records.len; i++)
{
range_record_t *range = &range_records[i];
range->props.potfRecords = feature_records.array + reinterpret_cast<unsigned int> (range->props.potfRecords);
}
}
else
{
fail_features:
num_features = 0;
}
#define FAIL(...) \
HB_STMT_START { \
@ -742,8 +265,7 @@ retry:
WCHAR *pchars = (WCHAR *) scratch;
unsigned int chars_len = 0;
for (unsigned int i = 0; i < buffer->len; i++)
{
for (unsigned int i = 0; i < buffer->len; i++) {
hb_codepoint_t c = buffer->info[i].codepoint;
buffer->info[i].utf16_index() = chars_len;
if (likely (c < 0x10000))
@ -760,20 +282,6 @@ retry:
ALLOCATE_ARRAY (WORD, log_clusters, chars_len);
ALLOCATE_ARRAY (SCRIPT_CHARPROP, char_props, chars_len);
if (num_features)
{
/* Need log_clusters to assign features. */
chars_len = 0;
for (unsigned int i = 0; i < buffer->len; i++)
{
hb_codepoint_t c = buffer->info[i].codepoint;
unsigned int cluster = buffer->info[i].cluster;
log_clusters[chars_len++] = cluster;
if (c >= 0x10000 && c < 0x110000)
log_clusters[chars_len++] = cluster; /* Surrogates. */
}
}
/* On Windows, we don't care about alignment...*/
unsigned int glyphs_size = scratch_size / (sizeof (WORD) +
sizeof (SCRIPT_GLYPHPROP) +
@ -787,14 +295,6 @@ retry:
ALLOCATE_ARRAY (GOFFSET, offsets, glyphs_size);
ALLOCATE_ARRAY (uint32_t, vis_clusters, glyphs_size);
/* Note:
* We can't touch the contents of glyph_props. Our fallback
* implementations of Shape and Place functions use that buffer
* by casting it to a different type. It works because they
* both agree about it, but if we want to access it here we
* need address that issue first.
*/
#undef ALLOCATE_ARRAY
#define MAX_ITEMS 256
@ -812,90 +312,55 @@ retry:
bidi_state.uBidiLevel = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
bidi_state.fOverrideDirection = 1;
hr = funcs->ScriptItemizeOpenType (wchars,
chars_len,
MAX_ITEMS,
&bidi_control,
&bidi_state,
items,
script_tags,
&item_count);
hr = ScriptItemizeOpenType (wchars,
chars_len,
MAX_ITEMS,
&bidi_control,
&bidi_state,
items,
script_tags,
&item_count);
if (unlikely (FAILED (hr)))
FAIL ("ScriptItemizeOpenType() failed: 0x%08xL", hr);
#undef MAX_ITEMS
int *range_char_counts = NULL;
TEXTRANGE_PROPERTIES **range_properties = NULL;
int range_count = 0;
if (num_features) {
/* TODO setup ranges */
}
OPENTYPE_TAG language_tag = hb_uint32_swap (hb_ot_tag_from_language (buffer->props.language));
hb_auto_array_t<TEXTRANGE_PROPERTIES*> range_properties;
hb_auto_array_t<int> range_char_counts;
unsigned int glyphs_offset = 0;
unsigned int glyphs_len;
bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
for (unsigned int i = 0; i < item_count; i++)
for (unsigned int j = 0; j < item_count; j++)
{
unsigned int i = backward ? item_count - 1 - j : j;
unsigned int chars_offset = items[i].iCharPos;
unsigned int item_chars_len = items[i + 1].iCharPos - chars_offset;
if (num_features)
{
range_properties.shrink (0);
range_char_counts.shrink (0);
range_record_t *last_range = &range_records[0];
for (unsigned int k = chars_offset; k < chars_offset + item_chars_len; k++)
{
range_record_t *range = last_range;
while (log_clusters[k] < range->index_first)
range--;
while (log_clusters[k] > range->index_last)
range++;
if (!range_properties.len ||
&range->props != range_properties[range_properties.len - 1])
{
TEXTRANGE_PROPERTIES **props = range_properties.push ();
int *c = range_char_counts.push ();
if (unlikely (!props || !c))
{
range_properties.shrink (0);
range_char_counts.shrink (0);
break;
}
*props = &range->props;
*c = 1;
}
else
{
range_char_counts[range_char_counts.len - 1]++;
}
last_range = range;
}
}
/* Asking for glyphs in logical order circumvents at least
* one bug in Uniscribe. */
items[i].a.fLogicalOrder = true;
retry_shape:
hr = funcs->ScriptShapeOpenType (font_data->hdc,
&font_data->script_cache,
&items[i].a,
script_tags[i],
language_tag,
range_char_counts.array,
range_properties.array,
range_properties.len,
wchars + chars_offset,
item_chars_len,
glyphs_size - glyphs_offset,
/* out */
log_clusters + chars_offset,
char_props + chars_offset,
glyphs + glyphs_offset,
glyph_props + glyphs_offset,
(int *) &glyphs_len);
hr = ScriptShapeOpenType (font_data->hdc,
&font_data->script_cache,
&items[i].a,
script_tags[i],
language_tag,
range_char_counts,
range_properties,
range_count,
wchars + chars_offset,
item_chars_len,
glyphs_size - glyphs_offset,
/* out */
log_clusters + chars_offset,
char_props + chars_offset,
glyphs + glyphs_offset,
glyph_props + glyphs_offset,
(int *) &glyphs_len);
if (unlikely (items[i].a.fNoGlyphIndex))
FAIL ("ScriptShapeOpenType() set fNoGlyphIndex");
@ -921,36 +386,28 @@ retry:
for (unsigned int j = chars_offset; j < chars_offset + item_chars_len; j++)
log_clusters[j] += glyphs_offset;
hr = funcs->ScriptPlaceOpenType (font_data->hdc,
&font_data->script_cache,
&items[i].a,
script_tags[i],
language_tag,
range_char_counts.array,
range_properties.array,
range_properties.len,
wchars + chars_offset,
log_clusters + chars_offset,
char_props + chars_offset,
item_chars_len,
glyphs + glyphs_offset,
glyph_props + glyphs_offset,
glyphs_len,
/* out */
advances + glyphs_offset,
offsets + glyphs_offset,
NULL);
hr = ScriptPlaceOpenType (font_data->hdc,
&font_data->script_cache,
&items[i].a,
script_tags[i],
language_tag,
range_char_counts,
range_properties,
range_count,
wchars + chars_offset,
log_clusters + chars_offset,
char_props + chars_offset,
item_chars_len,
glyphs + glyphs_offset,
glyph_props + glyphs_offset,
glyphs_len,
/* out */
advances + glyphs_offset,
offsets + glyphs_offset,
NULL);
if (unlikely (FAILED (hr)))
FAIL ("ScriptPlaceOpenType() failed: 0x%08xL", hr);
if (DEBUG_ENABLED (UNISCRIBE))
fprintf (stderr, "Item %d RTL %d LayoutRTL %d LogicalOrder %d ScriptTag %c%c%c%c\n",
i,
items[i].a.fRTL,
items[i].a.fLayoutRTL,
items[i].a.fLogicalOrder,
HB_UNTAG (hb_uint32_swap (script_tags[i])));
glyphs_offset += glyphs_len;
}
glyphs_len = glyphs_offset;
@ -965,9 +422,15 @@ retry:
uint32_t *p = &vis_clusters[log_clusters[buffer->info[i].utf16_index()]];
*p = MIN (*p, buffer->info[i].cluster);
}
for (unsigned int i = 1; i < glyphs_len; i++)
if (vis_clusters[i] == -1)
vis_clusters[i] = vis_clusters[i - 1];
if (!backward) {
for (unsigned int i = 1; i < glyphs_len; i++)
if (vis_clusters[i] == -1)
vis_clusters[i] = vis_clusters[i - 1];
} else {
for (int i = glyphs_len - 2; i >= 0; i--)
if (vis_clusters[i] == -1)
vis_clusters[i] = vis_clusters[i + 1];
}
#undef utf16_index
@ -1001,13 +464,10 @@ retry:
/* TODO vertical */
pos->x_advance = info->mask;
pos->x_offset = backward ? -info->var1.u32 : info->var1.u32;
pos->x_offset = info->var1.u32;
pos->y_offset = info->var2.u32;
}
if (backward)
hb_buffer_reverse (buffer);
/* Wow, done! */
return true;
}

View File

@ -38,9 +38,9 @@ HB_BEGIN_DECLS
#define HB_VERSION_MAJOR 0
#define HB_VERSION_MINOR 9
#define HB_VERSION_MICRO 21
#define HB_VERSION_MICRO 16
#define HB_VERSION_STRING "0.9.21"
#define HB_VERSION_STRING "0.9.16"
#define HB_VERSION_CHECK(major,minor,micro) \
((major)*10000+(minor)*100+(micro) >= \

View File

@ -31,8 +31,6 @@
#include "hb-blob.h"
#include "hb-buffer.h"
#include "hb-common.h"
#include "hb-deprecated.h"
#include "hb-face.h"
#include "hb-font.h"
#include "hb-set.h"
#include "hb-shape.h"

View File

@ -170,7 +170,7 @@ main (int argc, char **argv)
}
break;
case GDEF::tableTag:
case GDEF::Tag:
{
const GDEF &gdef = *CastP<GDEF> (font_data + table.offset);

View File

@ -16,8 +16,6 @@ EXPORTS.harfbuzz += [
'hb-blob.h',
'hb-buffer.h',
'hb-common.h',
'hb-deprecated.h',
'hb-face.h',
'hb-font.h',
'hb-ot-layout.h',
'hb-ot-tag.h',
@ -35,7 +33,6 @@ CPP_SOURCES += [
'hb-buffer.cc',
'hb-common.cc',
'hb-fallback-shape.cc',
'hb-face.cc',
'hb-font.cc',
'hb-ot-layout.cc',
'hb-ot-map.cc',

View File

@ -114,7 +114,7 @@ main (int argc, char **argv)
hb_buffer_serialize_glyphs (buf, 0, hb_buffer_get_length (buf),
out, sizeof (out), NULL,
font, HB_BUFFER_SERIALIZE_FORMAT_JSON,
HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
HB_BUFFER_SERIALIZE_FLAGS_DEFAULT);
puts (out);
}

View File

@ -83,7 +83,7 @@ hb_codepoint_t
gfxHarfBuzzShaper::GetGlyph(hb_codepoint_t unicode,
hb_codepoint_t variation_selector) const
{
hb_codepoint_t gid = 0;
hb_codepoint_t gid;
if (mUseFontGetGlyph) {
gid = mFont->GetGlyph(unicode, variation_selector);
@ -98,18 +98,6 @@ gfxHarfBuzzShaper::GetGlyph(hb_codepoint_t unicode,
const uint8_t* data =
(const uint8_t*)hb_blob_get_data(mCmapTable, nullptr);
if (variation_selector) {
if (mUVSTableOffset) {
gid =
gfxFontUtils::MapUVSToGlyphFormat14(data + mUVSTableOffset,
unicode,
variation_selector);
}
// If the variation sequence was not supported, return zero here;
// harfbuzz will call us again for the base character alone
return gid;
}
switch (mCmapFormat) {
case 4:
gid = unicode < UNICODE_BMP_LIMIT ?
@ -122,8 +110,21 @@ gfxHarfBuzzShaper::GetGlyph(hb_codepoint_t unicode,
break;
default:
NS_WARNING("unsupported cmap format, glyphs will be missing");
gid = 0;
break;
}
if (gid && variation_selector && mUVSTableOffset) {
hb_codepoint_t varGID =
gfxFontUtils::MapUVSToGlyphFormat14(data + mUVSTableOffset,
unicode,
variation_selector);
if (varGID) {
gid = varGID;
}
// else the variation sequence was not supported, use default
// mapping of the character code alone
}
}
if (!gid) {