mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-05-26 15:02:46 +00:00
import from custom branch of UXP: update harfbuzz to 2.8.2 (58116e6c)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
gfx/harfbuzz status as of 2017-09-05:
|
||||
gfx/harfbuzz status as of 2021-07-09:
|
||||
|
||||
This directory contains the harfbuzz source from the 'master' branch of
|
||||
https://github.com/behdad/harfbuzz.
|
||||
https://github.com/harfbuzz/harfbuzz.
|
||||
|
||||
Current version: 1.5.1
|
||||
Current version: 2.8.2
|
||||
|
||||
UPDATING:
|
||||
|
||||
|
||||
+222
-126
@@ -1,5 +1,6 @@
|
||||
# Process this file with automake to produce Makefile.in
|
||||
|
||||
NULL =
|
||||
SUBDIRS =
|
||||
DIST_SUBDIRS =
|
||||
BUILT_SOURCES =
|
||||
@@ -8,13 +9,20 @@ CLEANFILES =
|
||||
DISTCLEANFILES =
|
||||
MAINTAINERCLEANFILES =
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
|
||||
TESTS =
|
||||
check_PROGRAMS =
|
||||
|
||||
# The following warning options are useful for debugging: -Wpadded
|
||||
#AM_CXXFLAGS =
|
||||
EXTRA_DIST += harfbuzz.cc
|
||||
EXTRA_DIST += meson.build
|
||||
EXTRA_DIST += fix_get_types.py
|
||||
|
||||
# Convenience targets:
|
||||
lib: $(BUILT_SOURCES) libharfbuzz.la
|
||||
fuzzing: $(BUILT_SOURCES) libharfbuzz-fuzzing.la
|
||||
libs: $(BUILT_SOURCES) $(lib_LTLIBRARIES)
|
||||
tiny:
|
||||
$(MAKE) $(AM_MAKEFLAGS) CPPFLAGS="-Os -DHB_TINY $(CPPFLAGS)" libs
|
||||
tinyz:
|
||||
$(MAKE) $(AM_MAKEFLAGS) CPPFLAGS="-Oz -DHB_TINY $(CPPFLAGS)" libs
|
||||
|
||||
lib_LTLIBRARIES = libharfbuzz.la
|
||||
|
||||
@@ -27,17 +35,6 @@ HBDEPS =
|
||||
HBSOURCES = $(HB_BASE_sources)
|
||||
HBSOURCES += $(HB_BASE_RAGEL_GENERATED_sources)
|
||||
HBHEADERS = $(HB_BASE_headers)
|
||||
HBNODISTHEADERS = $(HB_NODIST_headers)
|
||||
|
||||
if HAVE_OT
|
||||
HBSOURCES += $(HB_OT_sources)
|
||||
HBSOURCES += $(HB_OT_RAGEL_GENERATED_sources)
|
||||
HBHEADERS += $(HB_OT_headers)
|
||||
endif
|
||||
|
||||
if HAVE_FALLBACK
|
||||
HBSOURCES += $(HB_FALLBACK_sources)
|
||||
endif
|
||||
|
||||
if HAVE_PTHREAD
|
||||
HBCFLAGS += $(PTHREAD_CFLAGS)
|
||||
@@ -55,12 +52,7 @@ endif
|
||||
if HAVE_FREETYPE
|
||||
HBCFLAGS += $(FREETYPE_CFLAGS)
|
||||
HBLIBS += $(FREETYPE_LIBS)
|
||||
# XXX
|
||||
# The following creates a recursive dependency on FreeType if FreeType is
|
||||
# built with HarfBuzz support enabled. Newer pkg-config handles that just
|
||||
# fine but pkg-config 0.26 as shipped in Ubuntu 14.04 crashes. Remove
|
||||
# in a year or two, or otherwise work around it...
|
||||
#HBDEPS += $(FREETYPE_DEPS)
|
||||
HBDEPS += $(FREETYPE_DEPS)
|
||||
HBSOURCES += $(HB_FT_sources)
|
||||
HBHEADERS += $(HB_FT_headers)
|
||||
endif
|
||||
@@ -87,6 +79,13 @@ HBSOURCES += $(HB_DIRECTWRITE_sources)
|
||||
HBHEADERS += $(HB_DIRECTWRITE_headers)
|
||||
endif
|
||||
|
||||
if HAVE_GDI
|
||||
HBCFLAGS += $(GDI_CXXFLAGS)
|
||||
HBNONPCLIBS += $(GDI_LIBS)
|
||||
HBSOURCES += $(HB_GDI_sources)
|
||||
HBHEADERS += $(HB_GDI_headers)
|
||||
endif
|
||||
|
||||
if HAVE_CORETEXT
|
||||
HBCFLAGS += $(CORETEXT_CFLAGS)
|
||||
HBNONPCLIBS += $(CORETEXT_LIBS)
|
||||
@@ -94,14 +93,17 @@ HBSOURCES += $(HB_CORETEXT_sources)
|
||||
HBHEADERS += $(HB_CORETEXT_headers)
|
||||
endif
|
||||
|
||||
if HAVE_UCDN
|
||||
SUBDIRS += hb-ucdn
|
||||
HBCFLAGS += -I$(srcdir)/hb-ucdn
|
||||
HBLIBS += hb-ucdn/libhb-ucdn.la
|
||||
HBSOURCES += $(HB_UCDN_sources)
|
||||
endif
|
||||
DIST_SUBDIRS += hb-ucdn
|
||||
|
||||
BUILT_SOURCES += \
|
||||
hb-version.h
|
||||
|
||||
$(srcdir)/hb-version.h: hb-version.h.in $(top_srcdir)/configure.ac
|
||||
$(AM_V_GEN) $(SED) \
|
||||
-e 's/[@]HB_VERSION_MAJOR@/$(HB_VERSION_MAJOR)/' \
|
||||
-e 's/[@]HB_VERSION_MINOR@/$(HB_VERSION_MINOR)/' \
|
||||
-e 's/[@]HB_VERSION_MICRO@/$(HB_VERSION_MICRO)/' \
|
||||
-e 's/[@]HB_VERSION@/$(HB_VERSION)/' \
|
||||
"$<" > "$@" || ($(RM) "$@"; false)
|
||||
|
||||
# Put the library together
|
||||
|
||||
@@ -110,43 +112,53 @@ HBLIBS += $(HBNONPCLIBS)
|
||||
if OS_WIN32
|
||||
export_symbols = -export-symbols harfbuzz.def
|
||||
harfbuzz_def_dependency = harfbuzz.def
|
||||
libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS)
|
||||
export_symbols_subset = -export-symbols harfbuzz-subset.def
|
||||
harfbuzz_subset_def_dependency = harfbuzz-subset.def
|
||||
export_symbols_icu = -export-symbols harfbuzz-icu.def
|
||||
harfbuzz_icu_def_dependency = harfbuzz-icu.def
|
||||
export_symbols_gobject = -export-symbols harfbuzz-gobject.def
|
||||
harfbuzz_gobject_def_dependency = harfbuzz-gobject.def
|
||||
chosen_linker = $(CXXLINK)
|
||||
else
|
||||
if WITH_LIBSTDCXX
|
||||
chosen_linker = $(CXXLINK)
|
||||
else
|
||||
# Use a C linker for GCC, not C++; Don't link to libstdc++
|
||||
if HAVE_GCC
|
||||
libharfbuzz_la_LINK = $(LINK) $(libharfbuzz_la_LDFLAGS)
|
||||
# Use a C linker for GCC, not C++; Don't link to libstdc++
|
||||
chosen_linker = $(LINK)
|
||||
else
|
||||
libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS)
|
||||
chosen_linker = $(CXXLINK)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS) $(HBNODISTHEADERS)
|
||||
libharfbuzz_la_CPPFLAGS = $(HBCFLAGS)
|
||||
libharfbuzz_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) $(export_symbols) -no-undefined
|
||||
@CODE_COVERAGE_RULES@
|
||||
|
||||
base_link_flags = $(AM_LDFLAGS) -lm -version-info $(HB_LIBTOOL_VERSION_INFO) -no-undefined
|
||||
libharfbuzz_la_LINK = $(chosen_linker) $(libharfbuzz_la_LDFLAGS)
|
||||
libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS)
|
||||
libharfbuzz_la_CPPFLAGS = $(HBCFLAGS) $(CODE_COVERAGE_CFLAGS)
|
||||
libharfbuzz_la_LDFLAGS = $(base_link_flags) $(export_symbols) $(CODE_COVERAGE_LDFLAGS)
|
||||
libharfbuzz_la_LIBADD = $(HBLIBS)
|
||||
EXTRA_libharfbuzz_la_DEPENDENCIES = $(harfbuzz_def_dependency)
|
||||
pkginclude_HEADERS = $(HBHEADERS)
|
||||
nodist_pkginclude_HEADERS = $(HBNODISTHEADERS)
|
||||
nodist_pkginclude_HEADERS =
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = harfbuzz.pc
|
||||
EXTRA_DIST += harfbuzz.pc.in
|
||||
cmakedir = $(libdir)/cmake/harfbuzz
|
||||
cmake_DATA = harfbuzz-config.cmake
|
||||
EXTRA_DIST += hb-version.h.in harfbuzz.pc.in harfbuzz-config.cmake.in
|
||||
|
||||
FUZZING_CPPFLAGS= \
|
||||
-DHB_NDEBUG \
|
||||
-DHB_MAX_NESTING_LEVEL=3 \
|
||||
-DHB_SANITIZE_MAX_EDITS=3 \
|
||||
-DHB_BUFFER_MAX_EXPANSION_FACTOR=3 \
|
||||
-DHB_BUFFER_MAX_LEN_MIN=8 \
|
||||
-DHB_BUFFER_MAX_LEN_DEFAULT=128 \
|
||||
$(NULL)
|
||||
EXTRA_LTLIBRARIES = libharfbuzz-fuzzing.la
|
||||
libharfbuzz_fuzzing_la_LINK = $(libharfbuzz_la_LINK)
|
||||
libharfbuzz_fuzzing_la_SOURCES = $(libharfbuzz_la_SOURCES)
|
||||
libharfbuzz_fuzzing_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS) $(FUZZING_CPPFLAGS)
|
||||
libharfbuzz_fuzzing_la_LDFLAGS = $(libharfbuzz_la_LDFLAGS)
|
||||
libharfbuzz_fuzzing_la_LIBADD = $(libharfbuzz_la_LIBADD)
|
||||
EXTRA_libharfbuzz_fuzzing_la_DEPENDENCIES = $(EXTRA_libharfbuzz_la_DEPENDENCIES)
|
||||
CLEANFILES += libharfbuzz-fuzzing.la
|
||||
lib_LTLIBRARIES += libharfbuzz-subset.la
|
||||
libharfbuzz_subset_la_LINK = $(chosen_linker) $(libharfbuzz_subset_la_LDFLAGS)
|
||||
libharfbuzz_subset_la_SOURCES = $(HB_SUBSET_sources)
|
||||
libharfbuzz_subset_la_CPPFLAGS = $(HBCFLAGS) $(CODE_COVERAGE_CFLAGS)
|
||||
libharfbuzz_subset_la_LDFLAGS = $(base_link_flags) $(export_symbols_subset) $(CODE_COVERAGE_LDFLAGS)
|
||||
libharfbuzz_subset_la_LIBADD = libharfbuzz.la
|
||||
EXTRA_libharfbuzz_subset_la_DEPENDENCIES = $(harfbuzz_subset_def_dependency)
|
||||
pkginclude_HEADERS += $(HB_SUBSET_headers)
|
||||
pkgconfig_DATA += harfbuzz-subset.pc
|
||||
EXTRA_DIST += harfbuzz-subset.pc.in
|
||||
|
||||
if HAVE_ICU
|
||||
if HAVE_ICU_BUILTIN
|
||||
@@ -157,9 +169,10 @@ HBHEADERS += $(HB_ICU_headers)
|
||||
else
|
||||
lib_LTLIBRARIES += libharfbuzz-icu.la
|
||||
libharfbuzz_icu_la_SOURCES = $(HB_ICU_sources)
|
||||
libharfbuzz_icu_la_CPPFLAGS = $(ICU_CFLAGS)
|
||||
libharfbuzz_icu_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) -no-undefined
|
||||
libharfbuzz_icu_la_CPPFLAGS = $(HBCFLAGS) $(ICU_CFLAGS) $(CODE_COVERAGE_CFLAGS)
|
||||
libharfbuzz_icu_la_LDFLAGS = $(base_link_flags) $(export_symbols_icu) $(CODE_COVERAGE_LDFLAGS)
|
||||
libharfbuzz_icu_la_LIBADD = $(ICU_LIBS) libharfbuzz.la
|
||||
EXTRA_libharfbuzz_icu_la_DEPENDENCIES = $(harfbuzz_icu_def_dependency)
|
||||
pkginclude_HEADERS += $(HB_ICU_headers)
|
||||
pkgconfig_DATA += harfbuzz-icu.pc
|
||||
endif
|
||||
@@ -168,13 +181,15 @@ EXTRA_DIST += harfbuzz-icu.pc.in
|
||||
|
||||
if HAVE_GOBJECT
|
||||
lib_LTLIBRARIES += libharfbuzz-gobject.la
|
||||
libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_sources)
|
||||
nodist_libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_ENUM_sources)
|
||||
libharfbuzz_gobject_la_CPPFLAGS = $(GOBJECT_CFLAGS)
|
||||
libharfbuzz_gobject_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) -no-undefined
|
||||
libharfbuzz_gobject_la_LINK = $(chosen_linker) $(libharfbuzz_gobject_la_LDFLAGS)
|
||||
libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_DIST_sources)
|
||||
nodist_libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_NODIST_sources)
|
||||
libharfbuzz_gobject_la_CPPFLAGS = $(HBCFLAGS) $(GOBJECT_CFLAGS) $(CODE_COVERAGE_CFLAGS)
|
||||
libharfbuzz_gobject_la_LDFLAGS = $(base_link_flags) $(CODE_COVERAGE_LDFLAGS)
|
||||
libharfbuzz_gobject_la_LIBADD = $(GOBJECT_LIBS) libharfbuzz.la
|
||||
pkginclude_HEADERS += $(HB_GOBJECT_headers)
|
||||
nodist_pkginclude_HEADERS += $(HB_GOBJECT_ENUM_headers)
|
||||
EXTRA_libharfbuzz_gobject_la_DEPENDENCIES = $(harfbuzz_gobject_def_dependency)
|
||||
pkginclude_HEADERS += $(HB_GOBJECT_DIST_headers)
|
||||
nodist_pkginclude_HEADERS += $(HB_GOBJECT_NODIST_headers)
|
||||
pkgconfig_DATA += harfbuzz-gobject.pc
|
||||
|
||||
BUILT_SOURCES += \
|
||||
@@ -186,7 +201,7 @@ DISTCLEANFILES += \
|
||||
$(HB_GOBJECT_ENUM_headers) \
|
||||
$(NULL)
|
||||
hb-gobject-enums.%: hb-gobject-enums.%.tmpl $(HBHEADERS)
|
||||
$(AM_V_GEN) $(GLIB_MKENUMS) \
|
||||
$(AM_V_GEN) PYTHONIOENCODING=UTF-8 $(GLIB_MKENUMS) \
|
||||
--identifier-prefix hb_ --symbol-prefix hb_gobject \
|
||||
--template $^ | \
|
||||
sed 's/_t_get_type/_get_type/g; s/_T (/ (/g' > "$@" \
|
||||
@@ -214,64 +229,84 @@ EXTRA_DIST += \
|
||||
CLEANFILES += $(pkgconfig_DATA)
|
||||
|
||||
|
||||
CLEANFILES += harfbuzz.def
|
||||
harfbuzz.def: $(HBHEADERS) $(HBNODISTHEADERS)
|
||||
$(AM_V_GEN) (echo EXPORTS; \
|
||||
(cat $^ || echo 'hb_ERROR ()' ) | \
|
||||
$(EGREP) '^hb_.* \(' | \
|
||||
sed -e 's/ (.*//' | \
|
||||
LC_ALL=C sort; \
|
||||
echo LIBRARY libharfbuzz-0.dll; \
|
||||
) >"$@"
|
||||
@ ! grep -q hb_ERROR "$@" \
|
||||
|| ($(RM) "$@"; false)
|
||||
DEF_FILES = harfbuzz.def harfbuzz-subset.def harfbuzz-icu.def harfbuzz-deprecated-symbols.txt
|
||||
if HAVE_GOBJECT
|
||||
DEF_FILES += harfbuzz-gobject.def
|
||||
endif
|
||||
check: $(DEF_FILES) # For check-symbols.sh
|
||||
CLEANFILES += $(DEF_FILES)
|
||||
harfbuzz.def: $(top_builddir)/config.status
|
||||
harfbuzz.def: $(HBHEADERS)
|
||||
$(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
|
||||
harfbuzz-subset.def: $(HB_SUBSET_headers)
|
||||
$(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
|
||||
harfbuzz-icu.def: $(HB_ICU_headers)
|
||||
$(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
|
||||
harfbuzz-gobject.def: $(HB_GOBJECT_headers)
|
||||
$(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^
|
||||
harfbuzz-deprecated-symbols.txt: $(srcdir)/hb-deprecated.h
|
||||
$(AM_V_GEN) PLAIN_LIST=1 $(srcdir)/gen-def.py "$@" $^
|
||||
|
||||
|
||||
GENERATORS = \
|
||||
gen-arabic-joining-list.py \
|
||||
gen-arabic-table.py \
|
||||
gen-def.py \
|
||||
gen-emoji-table.py \
|
||||
gen-harfbuzzcc.py \
|
||||
gen-hb-version.py \
|
||||
gen-indic-table.py \
|
||||
gen-os2-unicode-ranges.py \
|
||||
gen-ragel-artifacts.py \
|
||||
gen-tag-table.py \
|
||||
gen-ucd-table.py \
|
||||
gen-use-table.py \
|
||||
gen-vowel-constraints.py \
|
||||
$(NULL)
|
||||
EXTRA_DIST += $(GENERATORS)
|
||||
|
||||
unicode-tables: arabic-table indic-table use-table
|
||||
|
||||
arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
|
||||
$(AM_V_GEN) $(builddir)/$^ > hb-ot-shape-complex-arabic-table.hh \
|
||||
|| ($(RM) hb-ot-shape-complex-arabic-table.hh; false)
|
||||
|
||||
indic-table: gen-indic-table.py IndicSyllabicCategory-7.0.0.txt IndicMatraCategory-7.0.0.txt Blocks.txt
|
||||
$(AM_V_GEN) $(builddir)/$^ > hb-ot-shape-complex-indic-table.cc \
|
||||
|| ($(RM) hb-ot-shape-complex-indic-table.cc; false)
|
||||
|
||||
use-table: gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt
|
||||
$(AM_V_GEN) $(builddir)/$^ > hb-ot-shape-complex-use-table.cc \
|
||||
|| ($(RM) hb-ot-shape-complex-use-table.cc; false)
|
||||
|
||||
built-sources: $(BUILT_SOURCES)
|
||||
|
||||
.PHONY: unicode-tables arabic-table indic-table use-table built-sources
|
||||
.PHONY: built-sources
|
||||
|
||||
RAGEL_GENERATED = \
|
||||
$(patsubst %,$(srcdir)/%,$(HB_BASE_RAGEL_GENERATED_sources)) \
|
||||
$(patsubst %,$(srcdir)/%,$(HB_OT_RAGEL_GENERATED_sources)) \
|
||||
$(NULL)
|
||||
BUILT_SOURCES += $(RAGEL_GENERATED)
|
||||
EXTRA_DIST += \
|
||||
$(HB_BASE_RAGEL_sources) \
|
||||
$(HB_OT_RAGEL_sources) \
|
||||
$(NULL)
|
||||
MAINTAINERCLEANFILES += $(RAGEL_GENERATED)
|
||||
# We decided to add ragel-generated files to git...
|
||||
#MAINTAINERCLEANFILES += $(RAGEL_GENERATED)
|
||||
$(srcdir)/%.hh: $(srcdir)/%.rl
|
||||
$(AM_V_GEN)(cd $(srcdir) && $(RAGEL) -e -F1 -o "$*.hh" "$*.rl") \
|
||||
|| ($(RM) "$@"; false)
|
||||
|
||||
harfbuzz.cc: Makefile.sources
|
||||
$(AM_V_GEN) \
|
||||
for f in \
|
||||
$(HB_BASE_sources) \
|
||||
$(HB_GLIB_sources) \
|
||||
$(HB_FT_sources) \
|
||||
$(HB_GRAPHITE2_sources) \
|
||||
$(HB_UNISCRIBE_sources) \
|
||||
$(HB_GDI_sources) \
|
||||
$(HB_DIRECTWRITE_sources) \
|
||||
$(HB_CORETEXT_sources) \
|
||||
; do echo '#include "'$$f'"'; done | \
|
||||
grep '[.]cc"' > $(srcdir)/harfbuzz.cc \
|
||||
|| ($(RM) $(srcdir)/harfbuzz.cc; false)
|
||||
BUILT_SOURCES += harfbuzz.cc
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
main \
|
||||
test \
|
||||
test-buffer-serialize \
|
||||
test-size-params \
|
||||
test-would-substitute \
|
||||
test-ot-meta \
|
||||
test-ot-name \
|
||||
test-ot-glyphname \
|
||||
test-gpos-size-params \
|
||||
test-gsub-would-substitute \
|
||||
$(NULL)
|
||||
bin_PROGRAMS =
|
||||
|
||||
@@ -283,50 +318,118 @@ test_SOURCES = test.cc
|
||||
test_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
|
||||
test_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
|
||||
|
||||
test_would_substitute_SOURCES = test-would-substitute.cc
|
||||
test_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
|
||||
test_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
|
||||
|
||||
test_size_params_SOURCES = test-size-params.cc
|
||||
test_size_params_CPPFLAGS = $(HBCFLAGS)
|
||||
test_size_params_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_buffer_serialize_SOURCES = test-buffer-serialize.cc
|
||||
test_buffer_serialize_CPPFLAGS = $(HBCFLAGS)
|
||||
test_buffer_serialize_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
check: harfbuzz.def # For check-defs.sh
|
||||
test_ot_meta_SOURCES = test-ot-meta.cc
|
||||
test_ot_meta_CPPFLAGS = $(HBCFLAGS)
|
||||
test_ot_meta_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_ot_name_SOURCES = test-ot-name.cc
|
||||
test_ot_name_CPPFLAGS = $(HBCFLAGS)
|
||||
test_ot_name_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_ot_glyphname_SOURCES = test-ot-glyphname.cc
|
||||
test_ot_glyphname_CPPFLAGS = $(HBCFLAGS)
|
||||
test_ot_glyphname_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_gpos_size_params_SOURCES = test-gpos-size-params.cc
|
||||
test_gpos_size_params_CPPFLAGS = $(HBCFLAGS)
|
||||
test_gpos_size_params_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_gsub_would_substitute_SOURCES = test-gsub-would-substitute.cc
|
||||
test_gsub_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
|
||||
test_gsub_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
|
||||
|
||||
COMPILED_TESTS = test-algs test-array test-iter test-meta test-number test-ot-tag test-priority-queue test-unicode-ranges test-bimap test-repacker
|
||||
COMPILED_TESTS_CPPFLAGS = $(HBCFLAGS) -DMAIN -UNDEBUG
|
||||
COMPILED_TESTS_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
check_PROGRAMS += $(COMPILED_TESTS)
|
||||
TESTS += $(COMPILED_TESTS)
|
||||
|
||||
test_algs_SOURCES = test-algs.cc hb-static.cc
|
||||
test_algs_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_algs_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
test_array_SOURCES = test-array.cc
|
||||
test_array_CPPFLAGS = $(HBCFLAGS)
|
||||
test_array_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_priority_queue_SOURCES = test-priority-queue.cc hb-static.cc
|
||||
test_priority_queue_CPPFLAGS = $(HBCFLAGS)
|
||||
test_priority_queue_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_repacker_SOURCES = test-repacker.cc hb-static.cc
|
||||
test_repacker_CPPFLAGS = $(HBCFLAGS)
|
||||
test_repacker_LDADD = libharfbuzz.la libharfbuzz-subset.la $(HBLIBS)
|
||||
|
||||
test_iter_SOURCES = test-iter.cc hb-static.cc
|
||||
test_iter_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_iter_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
test_meta_SOURCES = test-meta.cc hb-static.cc
|
||||
test_meta_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_meta_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
test_number_SOURCES = test-number.cc hb-number.cc
|
||||
test_number_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_number_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
test_ot_tag_SOURCES = hb-ot-tag.cc
|
||||
test_ot_tag_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_ot_tag_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
test_unicode_ranges_SOURCES = test-unicode-ranges.cc
|
||||
test_unicode_ranges_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_unicode_ranges_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
test_bimap_SOURCES = test-bimap.cc hb-static.cc
|
||||
test_bimap_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_bimap_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
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 \
|
||||
check-c-linkage-decls.py \
|
||||
check-externs.py \
|
||||
check-header-guards.py \
|
||||
check-includes.py \
|
||||
check-static-inits.py \
|
||||
check-symbols.py \
|
||||
$(NULL)
|
||||
TESTS += $(dist_check_SCRIPTS)
|
||||
|
||||
check_PROGRAMS = \
|
||||
test-ot-tag \
|
||||
if !WITH_LIBSTDCXX
|
||||
dist_check_SCRIPTS += \
|
||||
check-libstdc++.py \
|
||||
$(NULL)
|
||||
test_ot_tag_SOURCES = hb-ot-tag.cc
|
||||
test_ot_tag_CPPFLAGS = $(HBCFLAGS) -DMAIN
|
||||
test_ot_tag_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
endif
|
||||
|
||||
TESTS = $(dist_check_SCRIPTS) $(check_PROGRAMS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
srcdir="$(srcdir)" \
|
||||
builddir="$(builddir)" \
|
||||
MAKE="$(MAKE) $(AM_MAKEFLAGS)" \
|
||||
HBSOURCES="$(HBSOURCES)" \
|
||||
HBHEADERS="$(HBHEADERS) $(HBNODISTHEADERS)" \
|
||||
HBHEADERS="$(HBHEADERS)" \
|
||||
LDD="$(LDD)" \
|
||||
NM="$(NM)" \
|
||||
OBJDUMP="$(OBJDUMP)" \
|
||||
OTOOL="$(OTOOL)" \
|
||||
$(NULL)
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
|
||||
-include $(INTROSPECTION_MAKEFILE)
|
||||
INTROSPECTION_GIRS = HarfBuzz-0.0.gir # What does the 0 mean anyway?!
|
||||
INTROSPECTION_SCANNER_ARGS = -I$(srcdir) -n hb --identifier-prefix=hb_ --warn-all
|
||||
INTROSPECTION_SCANNER_ARGS = \
|
||||
-I$(srcdir) \
|
||||
--warn-all --verbose \
|
||||
--namespace=HarfBuzz \
|
||||
--nsversion=0.0 \
|
||||
--symbol-prefix=hb \
|
||||
--symbol-prefix=hb_gobject \
|
||||
--identifier-prefix=hb_ \
|
||||
--pkg-export=harfbuzz-gobject \
|
||||
--c-include=hb-gobject.h
|
||||
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
|
||||
INTROSPECTION_SCANNER_ENV = CC="$(CC)"
|
||||
|
||||
@@ -335,12 +438,8 @@ 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 \
|
||||
-DHB_NO_SINGLE_HEADER_ERROR \
|
||||
-DHAVE_GOBJECT \
|
||||
-DHB_EXTERN= \
|
||||
$(NULL)
|
||||
HarfBuzz_0_0_gir_LIBS = \
|
||||
@@ -349,12 +448,9 @@ HarfBuzz_0_0_gir_LIBS = \
|
||||
$(NULL)
|
||||
HarfBuzz_0_0_gir_FILES = \
|
||||
$(HBHEADERS) \
|
||||
$(HBNODISTHEADERS) \
|
||||
$(HBSOURCES) \
|
||||
$(HB_GOBJECT_ENUM_sources) \
|
||||
$(HB_GOBJECT_ENUM_headers) \
|
||||
$(HB_GOBJECT_sources) \
|
||||
$(HB_GOBJECT_STRUCTS_headers) \
|
||||
$(HB_GOBJECT_headers) \
|
||||
$(NULL)
|
||||
|
||||
girdir = $(datadir)/gir-1.0
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
# Base and default-included sources and headers
|
||||
|
||||
HB_BASE_sources = \
|
||||
hb-aat-layout-ankr-table.hh \
|
||||
hb-aat-layout-bsln-table.hh \
|
||||
hb-aat-layout-common.hh \
|
||||
hb-aat-layout-feat-table.hh \
|
||||
hb-aat-layout-just-table.hh \
|
||||
hb-aat-layout-kerx-table.hh \
|
||||
hb-aat-layout-morx-table.hh \
|
||||
hb-aat-layout-opbd-table.hh \
|
||||
hb-aat-layout-trak-table.hh \
|
||||
hb-aat-layout.cc \
|
||||
hb-aat-layout.hh \
|
||||
hb-aat-ltag-table.hh \
|
||||
hb-aat-map.cc \
|
||||
hb-aat-map.hh \
|
||||
hb-algs.hh \
|
||||
hb-array.hh \
|
||||
hb-atomic.hh \
|
||||
hb-bimap.hh \
|
||||
hb-blob.cc \
|
||||
hb-blob.hh \
|
||||
hb-buffer-serialize.cc \
|
||||
hb-buffer.cc \
|
||||
hb-buffer.hh \
|
||||
hb-cache.hh \
|
||||
hb-cff-interp-common.hh \
|
||||
hb-cff-interp-cs-common.hh \
|
||||
hb-cff-interp-dict-common.hh \
|
||||
hb-cff1-interp-cs.hh \
|
||||
hb-cff2-interp-cs.hh \
|
||||
hb-common.cc \
|
||||
hb-config.hh \
|
||||
hb-debug.hh \
|
||||
hb-dispatch.hh \
|
||||
hb-draw.cc \
|
||||
hb-draw.hh \
|
||||
hb-face.cc \
|
||||
hb-face.hh \
|
||||
hb-fallback-shape.cc \
|
||||
hb-font.cc \
|
||||
hb-font.hh \
|
||||
hb-iter.hh \
|
||||
hb-kern.hh \
|
||||
hb-machinery.hh \
|
||||
hb-map.cc \
|
||||
hb-map.hh \
|
||||
hb-meta.hh \
|
||||
hb-mutex.hh \
|
||||
hb-null.hh \
|
||||
hb-number.cc \
|
||||
hb-number.hh \
|
||||
hb-object.hh \
|
||||
hb-open-file.hh \
|
||||
hb-open-type.hh \
|
||||
hb-ot-cff-common.hh \
|
||||
hb-ot-cff1-std-str.hh \
|
||||
hb-ot-cff1-table.cc \
|
||||
hb-ot-cff1-table.hh \
|
||||
hb-ot-cff2-table.cc \
|
||||
hb-ot-cff2-table.hh \
|
||||
hb-ot-cmap-table.hh \
|
||||
hb-ot-color-cbdt-table.hh \
|
||||
hb-ot-color-colr-table.hh \
|
||||
hb-ot-color-cpal-table.hh \
|
||||
hb-ot-color-sbix-table.hh \
|
||||
hb-ot-color-svg-table.hh \
|
||||
hb-ot-color.cc \
|
||||
hb-ot-face-table-list.hh \
|
||||
hb-ot-face.cc \
|
||||
hb-ot-face.hh \
|
||||
hb-ot-font.cc \
|
||||
hb-ot-gasp-table.hh \
|
||||
hb-ot-glyf-table.hh \
|
||||
hb-ot-hdmx-table.hh \
|
||||
hb-ot-head-table.hh \
|
||||
hb-ot-hhea-table.hh \
|
||||
hb-ot-hmtx-table.hh \
|
||||
hb-ot-kern-table.hh \
|
||||
hb-ot-layout-base-table.hh \
|
||||
hb-ot-layout-common.hh \
|
||||
hb-ot-layout-gdef-table.hh \
|
||||
hb-ot-layout-gpos-table.hh \
|
||||
hb-ot-layout-gsub-table.hh \
|
||||
hb-ot-layout-gsubgpos.hh \
|
||||
hb-ot-layout-jstf-table.hh \
|
||||
hb-ot-layout.cc \
|
||||
hb-ot-layout.hh \
|
||||
hb-ot-map.cc \
|
||||
hb-ot-map.hh \
|
||||
hb-ot-math-table.hh \
|
||||
hb-ot-math.cc \
|
||||
hb-ot-maxp-table.hh \
|
||||
hb-ot-meta-table.hh \
|
||||
hb-ot-meta.cc \
|
||||
hb-ot-metrics.cc \
|
||||
hb-ot-metrics.hh \
|
||||
hb-ot-name-language-static.hh \
|
||||
hb-ot-name-language.hh \
|
||||
hb-ot-name-table.hh \
|
||||
hb-ot-name.cc \
|
||||
hb-ot-os2-table.hh \
|
||||
hb-ot-os2-unicode-ranges.hh \
|
||||
hb-ot-post-macroman.hh \
|
||||
hb-ot-post-table.hh \
|
||||
hb-ot-shape-complex-arabic-fallback.hh \
|
||||
hb-ot-shape-complex-arabic-joining-list.hh \
|
||||
hb-ot-shape-complex-arabic-table.hh \
|
||||
hb-ot-shape-complex-arabic-win1256.hh \
|
||||
hb-ot-shape-complex-arabic.cc \
|
||||
hb-ot-shape-complex-arabic.hh \
|
||||
hb-ot-shape-complex-default.cc \
|
||||
hb-ot-shape-complex-hangul.cc \
|
||||
hb-ot-shape-complex-hebrew.cc \
|
||||
hb-ot-shape-complex-indic-table.cc \
|
||||
hb-ot-shape-complex-indic.cc \
|
||||
hb-ot-shape-complex-indic.hh \
|
||||
hb-ot-shape-complex-khmer.cc \
|
||||
hb-ot-shape-complex-khmer.hh \
|
||||
hb-ot-shape-complex-myanmar.cc \
|
||||
hb-ot-shape-complex-myanmar.hh \
|
||||
hb-ot-shape-complex-syllabic.cc \
|
||||
hb-ot-shape-complex-syllabic.hh \
|
||||
hb-ot-shape-complex-thai.cc \
|
||||
hb-ot-shape-complex-use-table.hh \
|
||||
hb-ot-shape-complex-use.cc \
|
||||
hb-ot-shape-complex-vowel-constraints.cc \
|
||||
hb-ot-shape-complex-vowel-constraints.hh \
|
||||
hb-ot-shape-complex.hh \
|
||||
hb-ot-shape-fallback.cc \
|
||||
hb-ot-shape-fallback.hh \
|
||||
hb-ot-shape-normalize.cc \
|
||||
hb-ot-shape-normalize.hh \
|
||||
hb-ot-shape.cc \
|
||||
hb-ot-shape.hh \
|
||||
hb-ot-stat-table.hh \
|
||||
hb-ot-tag-table.hh \
|
||||
hb-ot-tag.cc \
|
||||
hb-ot-var-avar-table.hh \
|
||||
hb-ot-var-fvar-table.hh \
|
||||
hb-ot-var-gvar-table.hh \
|
||||
hb-ot-var-hvar-table.hh \
|
||||
hb-ot-var-mvar-table.hh \
|
||||
hb-ot-var.cc \
|
||||
hb-ot-vorg-table.hh \
|
||||
hb-pool.hh \
|
||||
hb-sanitize.hh \
|
||||
hb-serialize.hh \
|
||||
hb-set-digest.hh \
|
||||
hb-set.cc \
|
||||
hb-set.hh \
|
||||
hb-shape-plan.cc \
|
||||
hb-shape-plan.hh \
|
||||
hb-shape.cc \
|
||||
hb-shaper-impl.hh \
|
||||
hb-shaper-list.hh \
|
||||
hb-shaper.cc \
|
||||
hb-shaper.hh \
|
||||
hb-static.cc \
|
||||
hb-string-array.hh \
|
||||
hb-style.cc \
|
||||
hb-ucd-table.hh \
|
||||
hb-ucd.cc \
|
||||
hb-unicode-emoji-table.hh \
|
||||
hb-unicode.cc \
|
||||
hb-unicode.hh \
|
||||
hb-utf.hh \
|
||||
hb-vector.hh \
|
||||
hb-priority-queue.hh \
|
||||
hb.hh \
|
||||
$(NULL)
|
||||
|
||||
HB_BASE_RAGEL_GENERATED_sources = \
|
||||
hb-buffer-deserialize-json.hh \
|
||||
hb-buffer-deserialize-text.hh \
|
||||
hb-number-parser.hh \
|
||||
hb-ot-shape-complex-indic-machine.hh \
|
||||
hb-ot-shape-complex-khmer-machine.hh \
|
||||
hb-ot-shape-complex-myanmar-machine.hh \
|
||||
hb-ot-shape-complex-use-machine.hh \
|
||||
$(NULL)
|
||||
HB_BASE_RAGEL_sources = \
|
||||
hb-buffer-deserialize-json.rl \
|
||||
hb-buffer-deserialize-text.rl \
|
||||
hb-number-parser.rl \
|
||||
hb-ot-shape-complex-indic-machine.rl \
|
||||
hb-ot-shape-complex-khmer-machine.rl \
|
||||
hb-ot-shape-complex-myanmar-machine.rl \
|
||||
hb-ot-shape-complex-use-machine.rl \
|
||||
$(NULL)
|
||||
|
||||
HB_BASE_headers = \
|
||||
hb-aat-layout.h \
|
||||
hb-aat.h \
|
||||
hb-blob.h \
|
||||
hb-buffer.h \
|
||||
hb-common.h \
|
||||
hb-deprecated.h \
|
||||
hb-draw.h \
|
||||
hb-face.h \
|
||||
hb-font.h \
|
||||
hb-map.h \
|
||||
hb-ot-color.h \
|
||||
hb-ot-deprecated.h \
|
||||
hb-ot-font.h \
|
||||
hb-ot-layout.h \
|
||||
hb-ot-math.h \
|
||||
hb-ot-meta.h \
|
||||
hb-ot-metrics.h \
|
||||
hb-ot-name.h \
|
||||
hb-ot-shape.h \
|
||||
hb-ot-var.h \
|
||||
hb-ot.h \
|
||||
hb-set.h \
|
||||
hb-shape-plan.h \
|
||||
hb-shape.h \
|
||||
hb-style.h \
|
||||
hb-unicode.h \
|
||||
hb-version.h \
|
||||
hb.h \
|
||||
$(NULL)
|
||||
|
||||
# Optional Sources and Headers with external deps
|
||||
|
||||
HB_FT_sources = hb-ft.cc
|
||||
HB_FT_headers = hb-ft.h
|
||||
|
||||
HB_GLIB_sources = hb-glib.cc
|
||||
HB_GLIB_headers = hb-glib.h
|
||||
|
||||
HB_GRAPHITE2_sources = hb-graphite2.cc
|
||||
HB_GRAPHITE2_headers = hb-graphite2.h
|
||||
|
||||
# System-dependent sources and headers
|
||||
|
||||
HB_CORETEXT_sources = hb-coretext.cc
|
||||
HB_CORETEXT_headers = hb-coretext.h
|
||||
|
||||
HB_DIRECTWRITE_sources = hb-directwrite.cc
|
||||
HB_DIRECTWRITE_headers = hb-directwrite.h
|
||||
|
||||
HB_GDI_sources = hb-gdi.cc
|
||||
HB_GDI_headers = hb-gdi.h
|
||||
|
||||
HB_UNISCRIBE_sources = hb-uniscribe.cc
|
||||
HB_UNISCRIBE_headers = hb-uniscribe.h
|
||||
|
||||
# Sources for libharfbuzz-gobject and libharfbuzz-icu
|
||||
HB_ICU_sources = hb-icu.cc
|
||||
HB_ICU_headers = hb-icu.h
|
||||
|
||||
# Sources for libharfbuzz-subset
|
||||
HB_SUBSET_sources = \
|
||||
hb-number.cc \
|
||||
hb-number.hh \
|
||||
hb-ot-cff1-table.cc \
|
||||
hb-ot-cff2-table.cc \
|
||||
hb-ot-color-colrv1-closure.hh \
|
||||
hb-static.cc \
|
||||
hb-subset-cff-common.cc \
|
||||
hb-subset-cff-common.hh \
|
||||
hb-subset-cff1.cc \
|
||||
hb-subset-cff1.hh \
|
||||
hb-subset-cff2.cc \
|
||||
hb-subset-cff2.hh \
|
||||
hb-subset-input.cc \
|
||||
hb-subset-input.hh \
|
||||
hb-subset-plan.cc \
|
||||
hb-subset-plan.hh \
|
||||
hb-subset.cc \
|
||||
hb-subset.hh \
|
||||
hb-repacker.hh \
|
||||
$(NULL)
|
||||
|
||||
HB_SUBSET_headers = \
|
||||
hb-subset.h \
|
||||
$(NULL)
|
||||
|
||||
HB_GOBJECT_DIST_sources = hb-gobject-structs.cc
|
||||
HB_GOBJECT_DIST_headers = hb-gobject.h hb-gobject-structs.h
|
||||
HB_GOBJECT_ENUM_sources = hb-gobject-enums.cc
|
||||
HB_GOBJECT_ENUM_headers = hb-gobject-enums.h
|
||||
HB_GOBJECT_NODIST_sources = $(HB_GOBJECT_ENUM_sources)
|
||||
HB_GOBJECT_NODIST_headers = $(HB_GOBJECT_ENUM_headers)
|
||||
HB_GOBJECT_sources = $(HB_GOBJECT_DIST_sources) $(HB_GOBJECT_NODIST_sources)
|
||||
HB_GOBJECT_headers = $(HB_GOBJECT_DIST_headers) $(HB_GOBJECT_NODIST_headers)
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os
|
||||
|
||||
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
|
||||
|
||||
HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
|
||||
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
|
||||
HBSOURCES = [os.path.basename (x) for x in os.getenv ('HBSOURCES', '').split ()] or \
|
||||
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))]
|
||||
|
||||
stat = 0
|
||||
|
||||
for x in HBHEADERS:
|
||||
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
|
||||
if ('HB_BEGIN_DECLS' not in content) or ('HB_END_DECLS' not in content):
|
||||
print ('Ouch, file %s does not have HB_BEGIN_DECLS / HB_END_DECLS, but it should' % x)
|
||||
stat = 1
|
||||
|
||||
for x in HBSOURCES:
|
||||
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
|
||||
if ('HB_BEGIN_DECLS' in content) or ('HB_END_DECLS' in content):
|
||||
print ('Ouch, file %s has HB_BEGIN_DECLS / HB_END_DECLS, but it shouldn\'t' % x)
|
||||
stat = 1
|
||||
|
||||
sys.exit (stat)
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LC_ALL=C
|
||||
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'`
|
||||
|
||||
|
||||
for x in $HBHEADERS; do
|
||||
test -f $srcdir/$x && x=$srcdir/$x
|
||||
if ! grep -q HB_BEGIN_DECLS "$x" || ! grep -q HB_END_DECLS "$x"; then
|
||||
echo "Ouch, file $x does not have HB_BEGIN_DECLS / HB_END_DECLS, but it should"
|
||||
stat=1
|
||||
fi
|
||||
done
|
||||
for x in $HBSOURCES; do
|
||||
test -f $srcdir/$x && x=$srcdir/$x
|
||||
if grep -q HB_BEGIN_DECLS "$x" || grep -q HB_END_DECLS "$x"; then
|
||||
echo "Ouch, file $x has HB_BEGIN_DECLS / HB_END_DECLS, but it shouldn't"
|
||||
stat=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $stat
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
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
|
||||
echo "check-defs.sh: 'nm' not found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
defs="harfbuzz.def"
|
||||
$MAKE $defs > /dev/null
|
||||
tested=false
|
||||
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\>\| _fbss\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>\| __gcov_flush\>\| llvm_' | cut -d' ' -f3`"
|
||||
|
||||
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
|
||||
|
||||
tested=true
|
||||
fi
|
||||
done
|
||||
if ! $tested; then
|
||||
echo "check-defs.sh: libharfbuzz shared library not found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
exit $stat
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, re
|
||||
|
||||
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
|
||||
|
||||
HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
|
||||
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
|
||||
|
||||
stat = 0
|
||||
|
||||
print ('Checking that all public symbols are exported with HB_EXTERN')
|
||||
for x in HBHEADERS:
|
||||
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
|
||||
for s in re.findall (r'\n.+\nhb_.+\n', content):
|
||||
if not s.startswith ('\nHB_EXTERN '):
|
||||
print ('failure on:', s)
|
||||
stat = 1
|
||||
|
||||
sys.exit (stat)
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, re
|
||||
|
||||
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
|
||||
|
||||
HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
|
||||
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
|
||||
HBSOURCES = [os.path.basename (x) for x in os.getenv ('HBSOURCES', '').split ()] or \
|
||||
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))]
|
||||
|
||||
stat = 0
|
||||
|
||||
for x in HBHEADERS + HBSOURCES:
|
||||
if not x.endswith ('h') or x == 'hb-gobject-structs.h': continue
|
||||
tag = x.upper ().replace ('.', '_').replace ('-', '_')
|
||||
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
|
||||
if len (re.findall (tag + r'\b', content)) != 3:
|
||||
print ('Ouch, header file %s does not have correct preprocessor guards' % x)
|
||||
stat = 1
|
||||
|
||||
sys.exit (stat)
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LC_ALL=C
|
||||
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'`
|
||||
|
||||
for x in $HBHEADERS $HBSOURCES; do
|
||||
test -f "$srcdir/$x" && x="$srcdir/$x"
|
||||
echo "$x" | grep -q '[^h]$' && continue;
|
||||
xx=`echo "$x" | sed 's@.*/@@'`
|
||||
tag=`echo "$xx" | tr 'a-z.-' 'A-Z_'`
|
||||
lines=`grep -w "$tag" "$x" | wc -l | sed 's/[ ]*//g'`
|
||||
if test "x$lines" != x3; then
|
||||
echo "Ouch, header file $x does not have correct preprocessor guards"
|
||||
stat=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $stat
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, re
|
||||
|
||||
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
|
||||
|
||||
HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
|
||||
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
|
||||
HBSOURCES = [os.path.basename (x) for x in os.getenv ('HBSOURCES', '').split ()] or \
|
||||
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))]
|
||||
|
||||
stat = 0
|
||||
|
||||
print ('Checking that public header files #include "hb-common.h" or "hb.h" first (or none)')
|
||||
for x in HBHEADERS:
|
||||
if x == 'hb.h' or x == 'hb-common.h': continue
|
||||
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
|
||||
first = re.findall (r'#.*include.*', content)[0]
|
||||
if first not in ['#include "hb.h"', '#include "hb-common.h"']:
|
||||
print ('failure on %s' % x)
|
||||
stat = 1
|
||||
|
||||
print ('Checking that source files #include a private header first (or none)')
|
||||
for x in HBSOURCES:
|
||||
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
|
||||
includes = re.findall (r'#.*include.*', content)
|
||||
if includes:
|
||||
if not len (re.findall (r'"hb.*\.hh"', includes[0])):
|
||||
print ('failure on %s' % x)
|
||||
stat = 1
|
||||
|
||||
print ('Checking that there is no #include <hb-*.h>')
|
||||
for x in HBHEADERS + HBSOURCES:
|
||||
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
|
||||
if re.findall ('#.*include.*<.*hb', content):
|
||||
print ('failure on %s' % x)
|
||||
stat = 1
|
||||
|
||||
sys.exit (stat)
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LC_ALL=C
|
||||
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'`
|
||||
|
||||
|
||||
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"' |
|
||||
grep -v '"hb[.]h"' |
|
||||
grep -v 'hb-common[.]h:' |
|
||||
grep -v 'hb[.]h:' |
|
||||
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 | grep -v 'include _' | head -n 1
|
||||
done |
|
||||
grep -v '"hb-.*private[.]hh"' |
|
||||
grep -v 'hb-private[.]hh:' |
|
||||
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
|
||||
|
||||
|
||||
exit $stat
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, shutil, subprocess
|
||||
|
||||
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
|
||||
|
||||
libs = os.getenv ('libs', '.libs')
|
||||
|
||||
ldd = os.getenv ('LDD', shutil.which ('ldd'))
|
||||
if not ldd:
|
||||
otool = os.getenv ('OTOOL', shutil.which ('otool'))
|
||||
if otool:
|
||||
ldd = otool + ' -L'
|
||||
else:
|
||||
print ('check-libstdc++.py: \'ldd\' not found; skipping test')
|
||||
sys.exit (77)
|
||||
|
||||
stat = 0
|
||||
tested = False
|
||||
|
||||
# harfbuzz-icu links to libstdc++ because icu does.
|
||||
for soname in ['harfbuzz', 'harfbuzz-subset', 'harfbuzz-gobject']:
|
||||
for suffix in ['so', 'dylib']:
|
||||
so = os.path.join (libs, 'lib%s.%s' % (soname, suffix))
|
||||
if not os.path.exists (so): continue
|
||||
|
||||
print ('Checking that we are not linking to libstdc++ or libc++ in %s' % so)
|
||||
ldd_result = subprocess.check_output (ldd.split() + [so])
|
||||
if (b'libstdc++' in ldd_result) or (b'libc++' in ldd_result):
|
||||
print ('Ouch, %s is linked to libstdc++ or libc++' % so)
|
||||
stat = 1
|
||||
|
||||
tested = True
|
||||
|
||||
if not tested:
|
||||
print ('check-libstdc++.py: libharfbuzz shared library not found; skipping test')
|
||||
sys.exit (77)
|
||||
|
||||
sys.exit (stat)
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
test -z "$srcdir" && srcdir=.
|
||||
stat=0
|
||||
|
||||
|
||||
if which ldd 2>/dev/null >/dev/null; then
|
||||
:
|
||||
else
|
||||
echo "check-libstdc++.sh: 'ldd' not found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
tested=false
|
||||
for suffix in so dylib; do
|
||||
so=.libs/libharfbuzz.$suffix
|
||||
if ! test -f "$so"; then continue; fi
|
||||
|
||||
echo "Checking that we are not linking to libstdc++ or libc++"
|
||||
if ldd $so | grep 'libstdc[+][+]\|libc[+][+]'; then
|
||||
echo "Ouch, linked to libstdc++ or libc++"
|
||||
stat=1
|
||||
fi
|
||||
tested=true
|
||||
done
|
||||
if ! $tested; then
|
||||
echo "check-libstdc++.sh: libharfbuzz shared library not found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
exit $stat
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, shutil, subprocess, glob, re
|
||||
|
||||
builddir = os.getenv ('builddir', os.path.dirname (__file__))
|
||||
libs = os.getenv ('libs', '.libs')
|
||||
|
||||
objdump = os.getenv ('OBJDUMP', shutil.which ('objdump'))
|
||||
if not objdump:
|
||||
print ('check-static-inits.py: \'ldd\' not found; skipping test')
|
||||
sys.exit (77)
|
||||
|
||||
if sys.version_info < (3, 5):
|
||||
print ('check-static-inits.py: needs python 3.5 for recursive support in glob')
|
||||
sys.exit (77)
|
||||
|
||||
OBJS = glob.glob (os.path.join (builddir, libs, '**', '*.o'), recursive=True)
|
||||
if not OBJS:
|
||||
print ('check-static-inits.py: object files not found; skipping test')
|
||||
sys.exit (77)
|
||||
|
||||
stat = 0
|
||||
tested = 0
|
||||
|
||||
for obj in OBJS:
|
||||
result = subprocess.run(objdump.split () + ['-t', obj], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
if result.returncode:
|
||||
if result.stderr.find (b'not recognized') != -1:
|
||||
# https://github.com/harfbuzz/harfbuzz/issues/3019
|
||||
print ('objdump %s returned "not recognized", skipping' % obj)
|
||||
continue
|
||||
print ('objdump %s returned error:\n%s' % (obj, result.stderr.decode ('utf-8')))
|
||||
stat = 2
|
||||
|
||||
result = result.stdout.decode ('utf-8')
|
||||
|
||||
# Checking that no object file has static initializers
|
||||
for l in re.findall (r'^.*\.[cd]tors.*$', result, re.MULTILINE):
|
||||
if not re.match (r'.*\b0+\b', l):
|
||||
print ('Ouch, %s has static initializers/finalizers' % obj)
|
||||
stat = 1
|
||||
|
||||
# Checking that no object file has lazy static C++ constructors/destructors or other such stuff
|
||||
if ('__cxa_' in result) and ('__ubsan_handle' not in result):
|
||||
print ('Ouch, %s has lazy static C++ constructors/destructors or other such stuff' % obj)
|
||||
stat = 1
|
||||
|
||||
tested += 1
|
||||
|
||||
sys.exit (stat if tested else 77)
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
test -z "$srcdir" && srcdir=.
|
||||
stat=0
|
||||
|
||||
|
||||
if which objdump 2>/dev/null >/dev/null; then
|
||||
:
|
||||
else
|
||||
echo "check-static-inits.sh: 'objdump' not found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
OBJS=.libs/*.o
|
||||
if test "x`echo $OBJS`" = "x$OBJS" 2>/dev/null >/dev/null; then
|
||||
echo "check-static-inits.sh: object files not found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
echo "Checking that no object file has static initializers"
|
||||
for obj in $OBJS; do
|
||||
if objdump -t "$obj" | grep '[.][cd]tors' | grep -v '\<00*\>'; then
|
||||
echo "Ouch, $obj has static initializers/finalizers"
|
||||
stat=1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Checking that no object file has lazy static C++ constructors/destructors or other such stuff"
|
||||
for obj in $OBJS; do
|
||||
if objdump -t "$obj" | grep '__cxa_'; then
|
||||
echo "Ouch, $obj has lazy static C++ constructors/destructors or other such stuff"
|
||||
stat=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $stat
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, shutil, subprocess, re, difflib
|
||||
|
||||
os.environ['LC_ALL'] = 'C' # otherwise 'nm' prints in wrong order
|
||||
|
||||
builddir = os.getenv ('builddir', os.path.dirname (__file__))
|
||||
libs = os.getenv ('libs', '.libs')
|
||||
|
||||
IGNORED_SYMBOLS = '|'.join(['_fini', '_init', '_fdata', '_ftext', '_fbss',
|
||||
'__bss_start', '__bss_start__', '__bss_end__', '_edata', '_end', '_bss_end__',
|
||||
'__end__', '__gcov_.*', 'llvm_.*', 'flush_fn_list', 'writeout_fn_list', 'mangle_path'])
|
||||
|
||||
nm = os.getenv ('NM', shutil.which ('nm'))
|
||||
if not nm:
|
||||
print ('check-symbols.py: \'nm\' not found; skipping test')
|
||||
sys.exit (77)
|
||||
|
||||
cxxflit = shutil.which ('c++filt')
|
||||
|
||||
tested = False
|
||||
stat = 0
|
||||
|
||||
for soname in ['harfbuzz', 'harfbuzz-subset', 'harfbuzz-icu', 'harfbuzz-gobject']:
|
||||
for suffix in ['so', 'dylib']:
|
||||
so = os.path.join (builddir, libs, 'lib%s.%s' % (soname, suffix))
|
||||
if not os.path.exists (so): continue
|
||||
|
||||
# On macOS, C symbols are prefixed with _
|
||||
symprefix = '_' if suffix == 'dylib' else ''
|
||||
|
||||
EXPORTED_SYMBOLS = [s.split ()[2]
|
||||
for s in re.findall (r'^.+ [BCDGIRST] .+$', subprocess.check_output (nm.split() + [so]).decode ('utf-8'), re.MULTILINE)
|
||||
if not re.match (r'.* %s(%s)\b' % (symprefix, IGNORED_SYMBOLS), s)]
|
||||
|
||||
# run again c++flit also if is available
|
||||
if cxxflit:
|
||||
EXPORTED_SYMBOLS = subprocess.check_output (
|
||||
[cxxflit], input='\n'.join (EXPORTED_SYMBOLS).encode ()
|
||||
).decode ('utf-8').splitlines ()
|
||||
|
||||
prefix = (symprefix + os.path.basename (so)).replace ('libharfbuzz', 'hb').replace ('-', '_').split ('.')[0]
|
||||
|
||||
print ('Checking that %s does not expose internal symbols' % so)
|
||||
suspicious_symbols = [x for x in EXPORTED_SYMBOLS if not re.match (r'^%s(_|$)' % prefix, x)]
|
||||
if suspicious_symbols:
|
||||
print ('Ouch, internal symbols exposed:', suspicious_symbols)
|
||||
stat = 1
|
||||
|
||||
def_path = os.path.join (builddir, soname + '.def')
|
||||
if not os.path.exists (def_path):
|
||||
print ('\'%s\' not found; skipping' % def_path)
|
||||
else:
|
||||
print ('Checking that %s has the same symbol list as %s' % (so, def_path))
|
||||
with open (def_path, 'r', encoding='utf-8') as f: def_file = f.read ()
|
||||
diff_result = list (difflib.context_diff (
|
||||
def_file.splitlines (),
|
||||
['EXPORTS'] + [re.sub ('^%shb' % symprefix, 'hb', x) for x in EXPORTED_SYMBOLS] +
|
||||
# cheat: copy the last line from the def file!
|
||||
[def_file.splitlines ()[-1]]
|
||||
))
|
||||
|
||||
if diff_result:
|
||||
print ('\n'.join (diff_result))
|
||||
stat = 1
|
||||
|
||||
tested = True
|
||||
|
||||
if not tested:
|
||||
print ('check-symbols.sh: no shared libraries found; skipping test')
|
||||
sys.exit (77)
|
||||
|
||||
sys.exit (stat)
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
|
||||
test -z "$srcdir" && srcdir=.
|
||||
stat=0
|
||||
|
||||
|
||||
if which nm 2>/dev/null >/dev/null; then
|
||||
:
|
||||
else
|
||||
echo "check-symbols.sh: 'nm' not found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
echo "Checking that we are not exposing internal symbols"
|
||||
tested=false
|
||||
for suffix in so dylib; do
|
||||
so=.libs/libharfbuzz.$suffix
|
||||
if ! test -f "$so"; then continue; fi
|
||||
|
||||
EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v ' _fini\>\| _init\>\| _fdata\>\| _ftext\>\| _fbss\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>\| __gcov_flush\>\| ___gcov_flush\>\| llvm_\| _llvm_' | cut -d' ' -f3`"
|
||||
|
||||
prefix=`basename "$so" | sed 's/libharfbuzz/hb/; s/-/_/g; s/[.].*//'`
|
||||
|
||||
# On mac, C symbols are prefixed with _
|
||||
if test $suffix = dylib; then prefix="_$prefix"; fi
|
||||
|
||||
echo "Processing $so"
|
||||
if echo "$EXPORTED_SYMBOLS" | grep -v "^${prefix}_"; then
|
||||
echo "Ouch, internal symbols exposed"
|
||||
stat=1
|
||||
fi
|
||||
|
||||
tested=true
|
||||
done
|
||||
if ! $tested; then
|
||||
echo "check-symbols.sh: no shared library found; skipping test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
exit $stat
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser ()
|
||||
parser.add_argument ('input')
|
||||
parser.add_argument ('output')
|
||||
args = parser.parse_args ()
|
||||
|
||||
with open (args.input, 'r') as inp, open (args.output, 'w') as out:
|
||||
for l in inp.readlines ():
|
||||
l = re.sub ('_t_get_type', '_get_type', l)
|
||||
l = re.sub ('_T \(', ' (', l)
|
||||
out.write (l)
|
||||
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""usage: ./gen-arabic-joining-table.py ArabicShaping.txt Scripts.txt
|
||||
|
||||
Input files:
|
||||
* https://unicode.org/Public/UCD/latest/ucd/ArabicShaping.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/Scripts.txt
|
||||
"""
|
||||
|
||||
import os.path, sys
|
||||
|
||||
if len (sys.argv) != 3:
|
||||
sys.exit (__doc__)
|
||||
|
||||
files = [open (x, encoding='utf-8') for x in sys.argv[1:]]
|
||||
|
||||
headers = [[f.readline (), f.readline ()] for f in files]
|
||||
while files[0].readline ().find ('##################') < 0:
|
||||
pass
|
||||
|
||||
def read (f):
|
||||
mapping = {}
|
||||
for line in f:
|
||||
|
||||
j = line.find ('#')
|
||||
if j >= 0:
|
||||
line = line[:j]
|
||||
|
||||
fields = [x.strip () for x in line.split (';')]
|
||||
if len (fields) == 1:
|
||||
continue
|
||||
|
||||
uu = fields[0].split ('..')
|
||||
start = int (uu[0], 16)
|
||||
if len (uu) == 1:
|
||||
end = start
|
||||
else:
|
||||
end = int (uu[1], 16)
|
||||
|
||||
t = fields[1]
|
||||
|
||||
for u in range (start, end + 1):
|
||||
mapping[u] = t
|
||||
|
||||
return mapping
|
||||
|
||||
def read_joining_uu (f):
|
||||
values = set ()
|
||||
for line in f:
|
||||
|
||||
if line[0] == '#':
|
||||
continue
|
||||
|
||||
fields = [x.strip () for x in line.split (';')]
|
||||
if len (fields) == 1:
|
||||
continue
|
||||
if fields[2] in {'T', 'U'}:
|
||||
continue
|
||||
|
||||
values.add (int (fields[0], 16))
|
||||
|
||||
return sorted (values)
|
||||
|
||||
def print_has_arabic_joining (scripts, joining_uu):
|
||||
|
||||
print ("static bool")
|
||||
print ("has_arabic_joining (hb_script_t script)")
|
||||
print ("{")
|
||||
print (" /* List of scripts that have data in arabic-table. */")
|
||||
print (" switch ((int) script)")
|
||||
print (" {")
|
||||
|
||||
for script in sorted ({scripts[u] for u in joining_uu if scripts[u] not in {'Common', 'Inherited'}}):
|
||||
print (" case HB_SCRIPT_{}:".format (script.upper ()))
|
||||
|
||||
print (" return true;")
|
||||
print ()
|
||||
print (" default:")
|
||||
print (" return false;")
|
||||
print (" }")
|
||||
print ("}")
|
||||
print ()
|
||||
|
||||
print ("/* == Start of generated function == */")
|
||||
print ("/*")
|
||||
print (" * The following function is generated by running:")
|
||||
print (" *")
|
||||
print (" * ./gen-arabic-joining-list.py ArabicShaping.txt Scripts.txt")
|
||||
print (" *")
|
||||
print (" * on files with these headers:")
|
||||
print (" *")
|
||||
for h in headers:
|
||||
for l in h:
|
||||
print (" * %s" % (l.strip ()))
|
||||
print (" */")
|
||||
print ()
|
||||
print ("#ifndef HB_OT_SHAPE_COMPLEX_ARABIC_JOINING_LIST_HH")
|
||||
print ("#define HB_OT_SHAPE_COMPLEX_ARABIC_JOINING_LIST_HH")
|
||||
print ()
|
||||
|
||||
print_has_arabic_joining (read (files[1]), read_joining_uu (files[0]))
|
||||
|
||||
print ()
|
||||
print ("#endif /* HB_OT_SHAPE_COMPLEX_ARABIC_JOINING_LIST_HH */")
|
||||
print ()
|
||||
print ("/* == End of generated function == */")
|
||||
@@ -1,13 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
"""usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
|
||||
|
||||
Input files:
|
||||
* https://unicode.org/Public/UCD/latest/ucd/ArabicShaping.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt
|
||||
"""
|
||||
|
||||
import os.path, sys
|
||||
|
||||
if len (sys.argv) != 4:
|
||||
print >>sys.stderr, "usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt"
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
files = [file (x) for x in sys.argv[1:]]
|
||||
files = [open (x, encoding='utf-8') for x in sys.argv[1:]]
|
||||
|
||||
headers = [[files[0].readline (), files[0].readline ()], [files[2].readline (), files[2].readline ()]]
|
||||
headers.append (["UnicodeData.txt does not have a header."])
|
||||
@@ -60,14 +66,14 @@ def print_joining_table(f):
|
||||
values[u] = value
|
||||
|
||||
short_value = {}
|
||||
for value in set([v for v in values.values()] + ['JOINING_TYPE_X']):
|
||||
for value in sorted (set ([v for v in values.values ()] + ['JOINING_TYPE_X'])):
|
||||
short = ''.join(x[0] for x in value.split('_')[2:])
|
||||
assert short not in short_value.values()
|
||||
short_value[value] = short
|
||||
|
||||
print
|
||||
print ()
|
||||
for value,short in short_value.items():
|
||||
print "#define %s %s" % (short, value)
|
||||
print ("#define %s %s" % (short, value))
|
||||
|
||||
uu = sorted(values.keys())
|
||||
num = len(values)
|
||||
@@ -82,15 +88,15 @@ def print_joining_table(f):
|
||||
ranges.append([u,u])
|
||||
last = u
|
||||
|
||||
print
|
||||
print "static const uint8_t joining_table[] ="
|
||||
print "{"
|
||||
print ()
|
||||
print ("static const uint8_t joining_table[] =")
|
||||
print ("{")
|
||||
last_block = None
|
||||
offset = 0
|
||||
for start,end in ranges:
|
||||
|
||||
print
|
||||
print "#define joining_offset_0x%04xu %d" % (start, offset)
|
||||
print ()
|
||||
print ("#define joining_offset_0x%04xu %d" % (start, offset))
|
||||
|
||||
for u in range(start, end+1):
|
||||
|
||||
@@ -99,53 +105,53 @@ def print_joining_table(f):
|
||||
|
||||
if block != last_block or u == start:
|
||||
if u != start:
|
||||
print
|
||||
print ()
|
||||
if block in all_blocks:
|
||||
print "\n /* %s */" % block
|
||||
print ("\n /* %s */" % block)
|
||||
else:
|
||||
print "\n /* FILLER */"
|
||||
print ("\n /* FILLER */")
|
||||
last_block = block
|
||||
if u % 32 != 0:
|
||||
print
|
||||
print " /* %04X */" % (u//32*32), " " * (u % 32),
|
||||
print ()
|
||||
print (" /* %04X */" % (u//32*32), " " * (u % 32), end="")
|
||||
|
||||
if u % 32 == 0:
|
||||
print
|
||||
print " /* %04X */ " % u,
|
||||
sys.stdout.write("%s," % short_value[value])
|
||||
print
|
||||
print ()
|
||||
print (" /* %04X */ " % u, end="")
|
||||
print ("%s," % short_value[value], end="")
|
||||
print ()
|
||||
|
||||
offset += end - start + 1
|
||||
print
|
||||
print ()
|
||||
occupancy = num * 100. / offset
|
||||
print "}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)
|
||||
print
|
||||
print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy))
|
||||
print ()
|
||||
|
||||
page_bits = 12;
|
||||
print
|
||||
print "static unsigned int"
|
||||
print "joining_type (hb_codepoint_t u)"
|
||||
print "{"
|
||||
print " switch (u >> %d)" % page_bits
|
||||
print " {"
|
||||
page_bits = 12
|
||||
print ()
|
||||
print ("static unsigned int")
|
||||
print ("joining_type (hb_codepoint_t u)")
|
||||
print ("{")
|
||||
print (" switch (u >> %d)" % page_bits)
|
||||
print (" {")
|
||||
pages = set([u>>page_bits for u in [s for s,e in ranges]+[e for s,e in ranges]])
|
||||
for p in sorted(pages):
|
||||
print " case 0x%0Xu:" % p
|
||||
print (" case 0x%0Xu:" % p)
|
||||
for (start,end) in ranges:
|
||||
if p not in [start>>page_bits, end>>page_bits]: continue
|
||||
offset = "joining_offset_0x%04xu" % start
|
||||
print " if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return joining_table[u - 0x%04Xu + %s];" % (start, end, start, offset)
|
||||
print " break;"
|
||||
print ""
|
||||
print " default:"
|
||||
print " break;"
|
||||
print " }"
|
||||
print " return X;"
|
||||
print "}"
|
||||
print
|
||||
print (" if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return joining_table[u - 0x%04Xu + %s];" % (start, end, start, offset))
|
||||
print (" break;")
|
||||
print ("")
|
||||
print (" default:")
|
||||
print (" break;")
|
||||
print (" }")
|
||||
print (" return X;")
|
||||
print ("}")
|
||||
print ()
|
||||
for value,short in short_value.items():
|
||||
print "#undef %s" % (short)
|
||||
print
|
||||
print ("#undef %s" % (short))
|
||||
print ()
|
||||
|
||||
def print_shaping_table(f):
|
||||
|
||||
@@ -175,7 +181,6 @@ def print_shaping_table(f):
|
||||
if items not in ligatures:
|
||||
ligatures[items] = {}
|
||||
ligatures[items][shape] = c
|
||||
pass
|
||||
else:
|
||||
# Save shape
|
||||
if items[0] not in names:
|
||||
@@ -186,9 +191,9 @@ def print_shaping_table(f):
|
||||
shapes[items[0]] = {}
|
||||
shapes[items[0]][shape] = c
|
||||
|
||||
print
|
||||
print "static const uint16_t shaping_table[][4] ="
|
||||
print "{"
|
||||
print ()
|
||||
print ("static const uint16_t shaping_table[][4] =")
|
||||
print ("{")
|
||||
|
||||
keys = shapes.keys ()
|
||||
min_u, max_u = min (keys), max (keys)
|
||||
@@ -196,13 +201,13 @@ def print_shaping_table(f):
|
||||
s = [shapes[u][shape] if u in shapes and shape in shapes[u] else 0
|
||||
for shape in ['initial', 'medial', 'final', 'isolated']]
|
||||
value = ', '.join ("0x%04Xu" % c for c in s)
|
||||
print " {%s}, /* U+%04X %s */" % (value, u, names[u] if u in names else "")
|
||||
print (" {%s}, /* U+%04X %s */" % (value, u, names[u] if u in names else ""))
|
||||
|
||||
print "};"
|
||||
print
|
||||
print "#define SHAPING_TABLE_FIRST 0x%04Xu" % min_u
|
||||
print "#define SHAPING_TABLE_LAST 0x%04Xu" % max_u
|
||||
print
|
||||
print ("};")
|
||||
print ()
|
||||
print ("#define SHAPING_TABLE_FIRST 0x%04Xu" % min_u)
|
||||
print ("#define SHAPING_TABLE_LAST 0x%04Xu" % max_u)
|
||||
print ()
|
||||
|
||||
ligas = {}
|
||||
for pair in ligatures.keys ():
|
||||
@@ -218,52 +223,49 @@ def print_shaping_table(f):
|
||||
ligas[liga[0]] = []
|
||||
ligas[liga[0]].append ((liga[1], c))
|
||||
max_i = max (len (ligas[l]) for l in ligas)
|
||||
print
|
||||
print "static const struct ligature_set_t {"
|
||||
print " uint16_t first;"
|
||||
print " struct ligature_pairs_t {"
|
||||
print " uint16_t second;"
|
||||
print " uint16_t ligature;"
|
||||
print " } ligatures[%d];" % max_i
|
||||
print "} ligature_table[] ="
|
||||
print "{"
|
||||
keys = ligas.keys ()
|
||||
keys.sort ()
|
||||
for first in keys:
|
||||
print ()
|
||||
print ("static const struct ligature_set_t {")
|
||||
print (" uint16_t first;")
|
||||
print (" struct ligature_pairs_t {")
|
||||
print (" uint16_t second;")
|
||||
print (" uint16_t ligature;")
|
||||
print (" } ligatures[%d];" % max_i)
|
||||
print ("} ligature_table[] =")
|
||||
print ("{")
|
||||
for first in sorted (ligas.keys ()):
|
||||
|
||||
print " { 0x%04Xu, {" % (first)
|
||||
print (" { 0x%04Xu, {" % (first))
|
||||
for liga in ligas[first]:
|
||||
print " { 0x%04Xu, 0x%04Xu }, /* %s */" % (liga[0], liga[1], names[liga[1]])
|
||||
print " }},"
|
||||
print (" { 0x%04Xu, 0x%04Xu }, /* %s */" % (liga[0], liga[1], names[liga[1]]))
|
||||
print (" }},")
|
||||
|
||||
print "};"
|
||||
print
|
||||
print ("};")
|
||||
print ()
|
||||
|
||||
|
||||
|
||||
print "/* == Start of generated table == */"
|
||||
print "/*"
|
||||
print " * The following table is generated by running:"
|
||||
print " *"
|
||||
print " * ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt"
|
||||
print " *"
|
||||
print " * on files with these headers:"
|
||||
print " *"
|
||||
print ("/* == Start of generated table == */")
|
||||
print ("/*")
|
||||
print (" * The following table is generated by running:")
|
||||
print (" *")
|
||||
print (" * ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt")
|
||||
print (" *")
|
||||
print (" * on files with these headers:")
|
||||
print (" *")
|
||||
for h in headers:
|
||||
for l in h:
|
||||
print " * %s" % (l.strip())
|
||||
print " */"
|
||||
print
|
||||
print "#ifndef HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH"
|
||||
print "#define HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH"
|
||||
print
|
||||
print (" * %s" % (l.strip()))
|
||||
print (" */")
|
||||
print ()
|
||||
print ("#ifndef HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH")
|
||||
print ("#define HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH")
|
||||
print ()
|
||||
|
||||
read_blocks (files[2])
|
||||
print_joining_table (files[0])
|
||||
print_shaping_table (files[1])
|
||||
|
||||
print
|
||||
print "#endif /* HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH */"
|
||||
print
|
||||
print "/* == End of generated table == */"
|
||||
|
||||
print ()
|
||||
print ("#endif /* HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH */")
|
||||
print ()
|
||||
print ("/* == End of generated table == */")
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]"
|
||||
|
||||
import os, re, sys
|
||||
|
||||
if len (sys.argv) < 3:
|
||||
sys.exit(__doc__)
|
||||
|
||||
output_file = sys.argv[1]
|
||||
header_paths = sys.argv[2:]
|
||||
|
||||
headers_content = []
|
||||
for h in header_paths:
|
||||
if h.endswith (".h"):
|
||||
with open (h, encoding='utf-8') as f: headers_content.append (f.read ())
|
||||
|
||||
symbols = sorted (re.findall (r"^hb_\w+(?= \()", "\n".join (headers_content), re.M))
|
||||
if '--experimental-api' not in sys.argv:
|
||||
# Move these to harfbuzz-sections.txt when got stable
|
||||
experimental_symbols = \
|
||||
"""hb_font_draw_glyph
|
||||
hb_draw_funcs_t
|
||||
hb_draw_close_path_func_t
|
||||
hb_draw_cubic_to_func_t
|
||||
hb_draw_line_to_func_t
|
||||
hb_draw_move_to_func_t
|
||||
hb_draw_quadratic_to_func_t
|
||||
hb_draw_funcs_create
|
||||
hb_draw_funcs_destroy
|
||||
hb_draw_funcs_is_immutable
|
||||
hb_draw_funcs_make_immutable
|
||||
hb_draw_funcs_reference
|
||||
hb_draw_funcs_set_close_path_func
|
||||
hb_draw_funcs_set_cubic_to_func
|
||||
hb_draw_funcs_set_line_to_func
|
||||
hb_draw_funcs_set_move_to_func
|
||||
hb_draw_funcs_set_quadratic_to_func
|
||||
hb_style_get_value
|
||||
hb_font_get_var_coords_design""".splitlines ()
|
||||
symbols = [x for x in symbols if x not in experimental_symbols]
|
||||
symbols = "\n".join (symbols)
|
||||
|
||||
result = symbols if os.getenv ('PLAIN_LIST', '') else """EXPORTS
|
||||
%s
|
||||
LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('src/', '').replace ('.def', ''))
|
||||
|
||||
with open (output_file, "w") as f: f.write (result)
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""usage: ./gen-emoji-table.py emoji-data.txt
|
||||
|
||||
Input file:
|
||||
* https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
|
||||
"""
|
||||
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
import packTab
|
||||
|
||||
if len (sys.argv) != 2:
|
||||
sys.exit (__doc__)
|
||||
|
||||
f = open(sys.argv[1])
|
||||
header = [f.readline () for _ in range(10)]
|
||||
|
||||
ranges = OrderedDict()
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if not line or line[0] == '#':
|
||||
continue
|
||||
rang, typ = [s.strip() for s in line.split('#')[0].split(';')[:2]]
|
||||
|
||||
rang = [int(s, 16) for s in rang.split('..')]
|
||||
if len(rang) > 1:
|
||||
start, end = rang
|
||||
else:
|
||||
start = end = rang[0]
|
||||
|
||||
if typ not in ranges:
|
||||
ranges[typ] = []
|
||||
if ranges[typ] and ranges[typ][-1][1] == start - 1:
|
||||
ranges[typ][-1] = (ranges[typ][-1][0], end)
|
||||
else:
|
||||
ranges[typ].append((start, end))
|
||||
|
||||
|
||||
|
||||
print ("/* == Start of generated table == */")
|
||||
print ("/*")
|
||||
print (" * The following tables are generated by running:")
|
||||
print (" *")
|
||||
print (" * ./gen-emoji-table.py emoji-data.txt")
|
||||
print (" *")
|
||||
print (" * on file with this header:")
|
||||
print (" *")
|
||||
for l in header:
|
||||
print (" * %s" % (l.strip()))
|
||||
print (" */")
|
||||
print ()
|
||||
print ("#ifndef HB_UNICODE_EMOJI_TABLE_HH")
|
||||
print ("#define HB_UNICODE_EMOJI_TABLE_HH")
|
||||
print ()
|
||||
print ('#include "hb-unicode.hh"')
|
||||
print ()
|
||||
|
||||
for typ, s in ranges.items():
|
||||
if typ != "Extended_Pictographic": continue
|
||||
|
||||
arr = dict()
|
||||
for start,end in s:
|
||||
for i in range(start, end + 1):
|
||||
arr[i] = 1
|
||||
|
||||
sol = packTab.pack_table(arr, 0, compression=3)
|
||||
code = packTab.Code('_hb_emoji')
|
||||
sol.genCode(code, 'is_'+typ)
|
||||
code.print_c(linkage='static inline')
|
||||
print()
|
||||
|
||||
print ()
|
||||
print ("#endif /* HB_UNICODE_EMOJI_TABLE_HH */")
|
||||
print ()
|
||||
print ("/* == End of generated table == */")
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"This tool is intended to be used from meson"
|
||||
|
||||
import os, sys, shutil
|
||||
|
||||
if len (sys.argv) < 3:
|
||||
sys.exit (__doc__)
|
||||
|
||||
OUTPUT = sys.argv[1]
|
||||
CURRENT_SOURCE_DIR = sys.argv[2]
|
||||
sources = sys.argv[3:]
|
||||
|
||||
with open (OUTPUT, "wb") as f:
|
||||
f.write ("".join ('#include "{}"\n'.format (os.path.basename (x)) for x in sources if x.endswith (".cc")).encode ())
|
||||
|
||||
# copy it also to src/
|
||||
shutil.copyfile (OUTPUT, os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)))
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"This tool is intended to be used from meson"
|
||||
|
||||
import os, sys, shutil, re
|
||||
|
||||
if len (sys.argv) < 4:
|
||||
sys.exit(__doc__)
|
||||
|
||||
version = sys.argv[1]
|
||||
major, minor, micro = version.split (".")
|
||||
|
||||
OUTPUT = sys.argv[2]
|
||||
INPUT = sys.argv[3]
|
||||
CURRENT_SOURCE_DIR = os.path.dirname(INPUT)
|
||||
|
||||
try:
|
||||
with open (OUTPUT, "r") as old_output:
|
||||
for line in old_output:
|
||||
old_version = re.match (r"#define HB_VERSION_STRING \"(\d.\d.\d)\"", line)
|
||||
if old_version and old_version[1] == version:
|
||||
sys.exit ()
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
with open (INPUT, "r", encoding='utf-8') as template:
|
||||
with open (OUTPUT, "wb") as output:
|
||||
output.write (template.read ()
|
||||
.replace ("@HB_VERSION_MAJOR@", major)
|
||||
.replace ("@HB_VERSION_MINOR@", minor)
|
||||
.replace ("@HB_VERSION_MICRO@", micro)
|
||||
.replace ("@HB_VERSION@", version)
|
||||
.encode ())
|
||||
|
||||
# copy it also to src/
|
||||
shutil.copyfile (OUTPUT, os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)))
|
||||
@@ -1,10 +1,17 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""usage: ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt
|
||||
|
||||
Input files:
|
||||
* https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
if len (sys.argv) != 4:
|
||||
print >>sys.stderr, "usage: ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt"
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
ALLOWED_SINGLES = [0x00A0, 0x25CC]
|
||||
ALLOWED_BLOCKS = [
|
||||
@@ -30,12 +37,12 @@ ALLOWED_BLOCKS = [
|
||||
'Myanmar Extended-A',
|
||||
]
|
||||
|
||||
files = [file (x) for x in sys.argv[1:]]
|
||||
files = [open (x, encoding='utf-8') for x in sys.argv[1:]]
|
||||
|
||||
headers = [[f.readline () for i in range (2)] for f in files]
|
||||
|
||||
data = [{} for f in files]
|
||||
values = [{} for f in files]
|
||||
data = [{} for _ in files]
|
||||
values = [{} for _ in files]
|
||||
for i, f in enumerate (files):
|
||||
for line in f:
|
||||
|
||||
@@ -75,11 +82,6 @@ for i,d in enumerate (data):
|
||||
combined = {k:v for k,v in combined.items() if k in ALLOWED_SINGLES or v[2] in ALLOWED_BLOCKS}
|
||||
data = combined
|
||||
del combined
|
||||
num = len (data)
|
||||
|
||||
for u in [0x17CD, 0x17CE, 0x17CF, 0x17D0, 0x17D3]:
|
||||
if data[u][0] == 'Other':
|
||||
data[u][0] = "Vowel_Dependent"
|
||||
|
||||
# Move the outliers NO-BREAK SPACE and DOTTED CIRCLE out
|
||||
singles = {}
|
||||
@@ -87,21 +89,25 @@ for u in ALLOWED_SINGLES:
|
||||
singles[u] = data[u]
|
||||
del data[u]
|
||||
|
||||
print "/* == Start of generated table == */"
|
||||
print "/*"
|
||||
print " * The following table is generated by running:"
|
||||
print " *"
|
||||
print " * ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt"
|
||||
print " *"
|
||||
print " * on files with these headers:"
|
||||
print " *"
|
||||
print ("/* == Start of generated table == */")
|
||||
print ("/*")
|
||||
print (" * The following table is generated by running:")
|
||||
print (" *")
|
||||
print (" * ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt")
|
||||
print (" *")
|
||||
print (" * on files with these headers:")
|
||||
print (" *")
|
||||
for h in headers:
|
||||
for l in h:
|
||||
print " * %s" % (l.strip())
|
||||
print " */"
|
||||
print
|
||||
print '#include "hb-ot-shape-complex-indic-private.hh"'
|
||||
print
|
||||
print (" * %s" % (l.strip()))
|
||||
print (" */")
|
||||
print ()
|
||||
print ('#include "hb.hh"')
|
||||
print ()
|
||||
print ('#ifndef HB_NO_OT_SHAPE')
|
||||
print ()
|
||||
print ('#include "hb-ot-shape-complex-indic.hh"')
|
||||
print ()
|
||||
|
||||
# Shorten values
|
||||
short = [{
|
||||
@@ -129,10 +135,11 @@ for i in range (2):
|
||||
|
||||
what = ["INDIC_SYLLABIC_CATEGORY", "INDIC_MATRA_CATEGORY"]
|
||||
what_short = ["ISC", "IMC"]
|
||||
print ('#pragma GCC diagnostic push')
|
||||
print ('#pragma GCC diagnostic ignored "-Wunused-macros"')
|
||||
cat_defs = []
|
||||
for i in range (2):
|
||||
print
|
||||
vv = values[i].keys ()
|
||||
vv.sort ()
|
||||
vv = sorted (values[i].keys ())
|
||||
for v in vv:
|
||||
v_no_and = v.replace ('_And_', '_')
|
||||
if v in short[i]:
|
||||
@@ -143,14 +150,22 @@ for i in range (2):
|
||||
raise Exception ("Duplicate short value alias", v, all_shorts[i][s])
|
||||
all_shorts[i][s] = v
|
||||
short[i][v] = s
|
||||
print "#define %s_%s %s_%s %s/* %3d chars; %s */" % \
|
||||
(what_short[i], s, what[i], v.upper (), \
|
||||
' '* ((48-1 - len (what[i]) - 1 - len (v)) / 8), \
|
||||
values[i][v], v)
|
||||
print
|
||||
print "#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)"
|
||||
print
|
||||
print
|
||||
cat_defs.append ((what_short[i] + '_' + s, what[i] + '_' + v.upper (), str (values[i][v]), v))
|
||||
|
||||
maxlen_s = max ([len (c[0]) for c in cat_defs])
|
||||
maxlen_l = max ([len (c[1]) for c in cat_defs])
|
||||
maxlen_n = max ([len (c[2]) for c in cat_defs])
|
||||
for s in what_short:
|
||||
print ()
|
||||
for c in [c for c in cat_defs if s in c[0]]:
|
||||
print ("#define %s %s /* %s chars; %s */" %
|
||||
(c[0].ljust (maxlen_s), c[1].ljust (maxlen_l), c[2].rjust (maxlen_n), c[3]))
|
||||
print ()
|
||||
print ('#pragma GCC diagnostic pop')
|
||||
print ()
|
||||
print ("#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)")
|
||||
print ()
|
||||
print ()
|
||||
|
||||
total = 0
|
||||
used = 0
|
||||
@@ -158,35 +173,34 @@ last_block = None
|
||||
def print_block (block, start, end, data):
|
||||
global total, used, last_block
|
||||
if block and block != last_block:
|
||||
print
|
||||
print
|
||||
print " /* %s */" % block
|
||||
print ()
|
||||
print ()
|
||||
print (" /* %s */" % block)
|
||||
num = 0
|
||||
assert start % 8 == 0
|
||||
assert (end+1) % 8 == 0
|
||||
for u in range (start, end+1):
|
||||
if u % 8 == 0:
|
||||
print
|
||||
print " /* %04X */" % u,
|
||||
print ()
|
||||
print (" /* %04X */" % u, end="")
|
||||
if u in data:
|
||||
num += 1
|
||||
d = data.get (u, defaults)
|
||||
sys.stdout.write ("%9s" % ("_(%s,%s)," % (short[0][d[0]], short[1][d[1]])))
|
||||
print ("%9s" % ("_(%s,%s)," % (short[0][d[0]], short[1][d[1]])), end="")
|
||||
|
||||
total += end - start + 1
|
||||
used += num
|
||||
if block:
|
||||
last_block = block
|
||||
|
||||
uu = data.keys ()
|
||||
uu.sort ()
|
||||
uu = sorted (data.keys ())
|
||||
|
||||
last = -100000
|
||||
num = 0
|
||||
offset = 0
|
||||
starts = []
|
||||
ends = []
|
||||
print "static const INDIC_TABLE_ELEMENT_TYPE indic_table[] = {"
|
||||
print ("static const uint16_t indic_table[] = {")
|
||||
for u in uu:
|
||||
if u <= last:
|
||||
continue
|
||||
@@ -201,59 +215,59 @@ for u in uu:
|
||||
if start != last + 1:
|
||||
if start - last <= 1+16*3:
|
||||
print_block (None, last+1, start-1, data)
|
||||
last = start-1
|
||||
else:
|
||||
if last >= 0:
|
||||
ends.append (last + 1)
|
||||
offset += ends[-1] - starts[-1]
|
||||
print
|
||||
print
|
||||
print "#define indic_offset_0x%04xu %d" % (start, offset)
|
||||
print ()
|
||||
print ()
|
||||
print ("#define indic_offset_0x%04xu %d" % (start, offset))
|
||||
starts.append (start)
|
||||
|
||||
print_block (block, start, end, data)
|
||||
last = end
|
||||
ends.append (last + 1)
|
||||
offset += ends[-1] - starts[-1]
|
||||
print
|
||||
print
|
||||
print ()
|
||||
print ()
|
||||
occupancy = used * 100. / total
|
||||
page_bits = 12
|
||||
print "}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)
|
||||
print
|
||||
print "INDIC_TABLE_ELEMENT_TYPE"
|
||||
print "hb_indic_get_categories (hb_codepoint_t u)"
|
||||
print "{"
|
||||
print " switch (u >> %d)" % page_bits
|
||||
print " {"
|
||||
pages = set([u>>page_bits for u in starts+ends+singles.keys()])
|
||||
print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy))
|
||||
print ()
|
||||
print ("uint16_t")
|
||||
print ("hb_indic_get_categories (hb_codepoint_t u)")
|
||||
print ("{")
|
||||
print (" switch (u >> %d)" % page_bits)
|
||||
print (" {")
|
||||
pages = set ([u>>page_bits for u in starts+ends+list (singles.keys ())])
|
||||
for p in sorted(pages):
|
||||
print " case 0x%0Xu:" % p
|
||||
print (" case 0x%0Xu:" % p)
|
||||
for u,d in singles.items ():
|
||||
if p != u>>page_bits: continue
|
||||
print (" if (unlikely (u == 0x%04Xu)) return _(%s,%s);" % (u, short[0][d[0]], short[1][d[1]]))
|
||||
for (start,end) in zip (starts, ends):
|
||||
if p not in [start>>page_bits, end>>page_bits]: continue
|
||||
offset = "indic_offset_0x%04xu" % start
|
||||
print " if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return indic_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
|
||||
for u,d in singles.items ():
|
||||
if p != u>>page_bits: continue
|
||||
print " if (unlikely (u == 0x%04Xu)) return _(%s,%s);" % (u, short[0][d[0]], short[1][d[1]])
|
||||
print " break;"
|
||||
print ""
|
||||
print " default:"
|
||||
print " break;"
|
||||
print " }"
|
||||
print " return _(x,x);"
|
||||
print "}"
|
||||
print
|
||||
print "#undef _"
|
||||
print (" if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return indic_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset))
|
||||
print (" break;")
|
||||
print ("")
|
||||
print (" default:")
|
||||
print (" break;")
|
||||
print (" }")
|
||||
print (" return _(x,x);")
|
||||
print ("}")
|
||||
print ()
|
||||
print ("#undef _")
|
||||
for i in range (2):
|
||||
print
|
||||
vv = values[i].keys ()
|
||||
vv.sort ()
|
||||
print ()
|
||||
vv = sorted (values[i].keys ())
|
||||
for v in vv:
|
||||
print "#undef %s_%s" % \
|
||||
(what_short[i], short[i][v])
|
||||
print
|
||||
print "/* == End of generated table == */"
|
||||
print ("#undef %s_%s" %
|
||||
(what_short[i], short[i][v]))
|
||||
print ()
|
||||
print ('#endif')
|
||||
print ()
|
||||
print ("/* == End of generated table == */")
|
||||
|
||||
# Maintain at least 30% occupancy in the table */
|
||||
if occupancy < 30:
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Generates the code for a sorted unicode range array as used in hb-ot-os2-unicode-ranges.hh
|
||||
Input is a tab seperated list of unicode ranges from the otspec
|
||||
(https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur).
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
print ("""static OS2Range _hb_os2_unicode_ranges[] =
|
||||
{""")
|
||||
|
||||
args = sys.argv[1:]
|
||||
input_file = args[0]
|
||||
|
||||
with open (input_file, mode="r", encoding="utf-8") as f:
|
||||
|
||||
all_ranges = []
|
||||
current_bit = 0
|
||||
while True:
|
||||
line = f.readline().strip()
|
||||
if not line:
|
||||
break
|
||||
fields = re.split(r'\t+', line)
|
||||
if len(fields) == 3:
|
||||
current_bit = fields[0]
|
||||
fields = fields[1:]
|
||||
elif len(fields) > 3:
|
||||
raise Exception("bad input :(.")
|
||||
|
||||
name = fields[0]
|
||||
ranges = re.split("-", fields[1])
|
||||
if len(ranges) != 2:
|
||||
raise Exception("bad input :(.")
|
||||
|
||||
v = tuple((int(ranges[0], 16), int(ranges[1], 16), int(current_bit), name))
|
||||
all_ranges.append(v)
|
||||
|
||||
all_ranges = sorted(all_ranges, key=lambda t: t[0])
|
||||
|
||||
for ranges in all_ranges:
|
||||
start = ("0x%X" % ranges[0]).rjust(8)
|
||||
end = ("0x%X" % ranges[1]).rjust(8)
|
||||
bit = ("%s" % ranges[2]).rjust(3)
|
||||
|
||||
print (" {%s, %s, %s}, // %s" % (start, end, bit, ranges[3]))
|
||||
|
||||
print ("""};""")
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"This tool is intended to be used from meson"
|
||||
|
||||
import os, os.path, sys, subprocess, shutil
|
||||
|
||||
ragel = os.getenv ('RAGEL', shutil.which ('ragel'))
|
||||
if not ragel:
|
||||
sys.exit ('You have to install ragel if you are going to develop HarfBuzz itself')
|
||||
|
||||
if len (sys.argv) < 4:
|
||||
sys.exit (__doc__)
|
||||
|
||||
OUTPUT = sys.argv[1]
|
||||
CURRENT_SOURCE_DIR = sys.argv[2]
|
||||
INPUT = sys.argv[3]
|
||||
|
||||
outdir = os.path.dirname (OUTPUT)
|
||||
shutil.copy (INPUT, outdir)
|
||||
rl = os.path.basename (INPUT)
|
||||
hh = rl.replace ('.rl', '.hh')
|
||||
subprocess.Popen (ragel.split() + ['-e', '-F1', '-o', hh, rl], cwd=outdir).wait ()
|
||||
|
||||
# copy it also to src/
|
||||
shutil.copyfile (os.path.join (outdir, hh), os.path.join (CURRENT_SOURCE_DIR, hh))
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,167 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""usage: ./gen-ucd-table ucd.nounihan.grouped.xml [/path/to/hb-common.h]
|
||||
|
||||
Input file:
|
||||
* https://unicode.org/Public/UCD/latest/ucdxml/ucd.nounihan.grouped.zip
|
||||
"""
|
||||
|
||||
import sys, re
|
||||
import logging
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
|
||||
|
||||
if len (sys.argv) not in (2, 3):
|
||||
sys.exit (__doc__)
|
||||
|
||||
# https://github.com/harfbuzz/packtab
|
||||
import packTab
|
||||
import packTab.ucdxml
|
||||
|
||||
logging.info('Loading UCDXML...')
|
||||
ucdxml = packTab.ucdxml.load_ucdxml(sys.argv[1])
|
||||
ucd = packTab.ucdxml.ucdxml_get_repertoire(ucdxml)
|
||||
|
||||
hb_common_h = 'hb-common.h' if len (sys.argv) < 3 else sys.argv[2]
|
||||
|
||||
logging.info('Preparing data tables...')
|
||||
|
||||
gc = [u['gc'] for u in ucd]
|
||||
ccc = [int(u['ccc']) for u in ucd]
|
||||
bmg = [int(v, 16) - int(u) if v else 0 for u,v in enumerate(u['bmg'] for u in ucd)]
|
||||
#gc_ccc_non0 = set((cat,klass) for cat,klass in zip(gc,ccc) if klass)
|
||||
#gc_bmg_non0 = set((cat,mirr) for cat,mirr in zip(gc, bmg) if mirr)
|
||||
|
||||
sc = [u['sc'] for u in ucd]
|
||||
|
||||
dm = {i:tuple(int(v, 16) for v in u['dm'].split()) for i,u in enumerate(ucd)
|
||||
if u['dm'] != '#' and u['dt'] == 'can' and not (0xAC00 <= i < 0xAC00+11172)}
|
||||
ce = {i for i,u in enumerate(ucd) if u['Comp_Ex'] == 'Y'}
|
||||
|
||||
assert not any(v for v in dm.values() if len(v) not in (1,2))
|
||||
dm1 = sorted(set(v for v in dm.values() if len(v) == 1))
|
||||
assert all((v[0] >> 16) in (0,2) for v in dm1)
|
||||
dm1_p0_array = ['0x%04Xu' % (v[0] & 0xFFFF) for v in dm1 if (v[0] >> 16) == 0]
|
||||
dm1_p2_array = ['0x%04Xu' % (v[0] & 0xFFFF) for v in dm1 if (v[0] >> 16) == 2]
|
||||
dm1_order = {v:i+1 for i,v in enumerate(dm1)}
|
||||
|
||||
dm2 = sorted((v+(i if i not in ce and not ccc[i] else 0,), v)
|
||||
for i,v in dm.items() if len(v) == 2)
|
||||
|
||||
filt = lambda v: ((v[0] & 0xFFFFF800) == 0x0000 and
|
||||
(v[1] & 0xFFFFFF80) == 0x0300 and
|
||||
(v[2] & 0xFFF0C000) == 0x0000)
|
||||
dm2_u32_array = [v for v in dm2 if filt(v[0])]
|
||||
dm2_u64_array = [v for v in dm2 if not filt(v[0])]
|
||||
assert dm2_u32_array + dm2_u64_array == dm2
|
||||
dm2_u32_array = ["HB_CODEPOINT_ENCODE3_11_7_14 (0x%04Xu, 0x%04Xu, 0x%04Xu)" % v[0] for v in dm2_u32_array]
|
||||
dm2_u64_array = ["HB_CODEPOINT_ENCODE3 (0x%04Xu, 0x%04Xu, 0x%04Xu)" % v[0] for v in dm2_u64_array]
|
||||
|
||||
l = 1 + len(dm1_p0_array) + len(dm1_p2_array)
|
||||
dm2_order = {v[1]:i+l for i,v in enumerate(dm2)}
|
||||
|
||||
dm_order = {None: 0}
|
||||
dm_order.update(dm1_order)
|
||||
dm_order.update(dm2_order)
|
||||
|
||||
gc_order = dict()
|
||||
for i,v in enumerate(('Cc', 'Cf', 'Cn', 'Co', 'Cs', 'Ll', 'Lm', 'Lo', 'Lt', 'Lu',
|
||||
'Mc', 'Me', 'Mn', 'Nd', 'Nl', 'No', 'Pc', 'Pd', 'Pe', 'Pf',
|
||||
'Pi', 'Po', 'Ps', 'Sc', 'Sk', 'Sm', 'So', 'Zl', 'Zp', 'Zs',)):
|
||||
gc_order[i] = v
|
||||
gc_order[v] = i
|
||||
|
||||
sc_order = dict()
|
||||
sc_array = []
|
||||
sc_re = re.compile(r"\b(HB_SCRIPT_[_A-Z]*).*HB_TAG [(]'(.)','(.)','(.)','(.)'[)]")
|
||||
for line in open(hb_common_h):
|
||||
m = sc_re.search (line)
|
||||
if not m: continue
|
||||
name = m.group(1)
|
||||
tag = ''.join(m.group(i) for i in range(2, 6))
|
||||
i = len(sc_array)
|
||||
sc_order[tag] = i
|
||||
sc_order[i] = tag
|
||||
sc_array.append(name)
|
||||
|
||||
DEFAULT = 1
|
||||
COMPACT = 3
|
||||
SLOPPY = 5
|
||||
|
||||
|
||||
logging.info('Generating output...')
|
||||
print("/* == Start of generated table == */")
|
||||
print("/*")
|
||||
print(" * The following table is generated by running:")
|
||||
print(" *")
|
||||
print(" * ./gen-ucd-table.py ucd.nounihan.grouped.xml")
|
||||
print(" *")
|
||||
print(" * on file with this description:", ucdxml.description)
|
||||
print(" */")
|
||||
print()
|
||||
print("#ifndef HB_UCD_TABLE_HH")
|
||||
print("#define HB_UCD_TABLE_HH")
|
||||
print()
|
||||
print('#include "hb.hh"')
|
||||
print()
|
||||
|
||||
code = packTab.Code('_hb_ucd')
|
||||
sc_array, _ = code.addArray('hb_script_t', 'sc_map', sc_array)
|
||||
dm1_p0_array, _ = code.addArray('uint16_t', 'dm1_p0_map', dm1_p0_array)
|
||||
dm1_p2_array, _ = code.addArray('uint16_t', 'dm1_p2_map', dm1_p2_array)
|
||||
dm2_u32_array, _ = code.addArray('uint32_t', 'dm2_u32_map', dm2_u32_array)
|
||||
dm2_u64_array, _ = code.addArray('uint64_t', 'dm2_u64_map', dm2_u64_array)
|
||||
code.print_c(linkage='static inline')
|
||||
|
||||
datasets = [
|
||||
('gc', gc, 'Cn', gc_order),
|
||||
('ccc', ccc, 0, None),
|
||||
('bmg', bmg, 0, None),
|
||||
('sc', sc, 'Zzzz', sc_order),
|
||||
('dm', dm, None, dm_order),
|
||||
]
|
||||
|
||||
for compression in (DEFAULT, COMPACT, SLOPPY):
|
||||
logging.info(' Compression=%d:' % compression)
|
||||
print()
|
||||
if compression == DEFAULT:
|
||||
print('#ifndef HB_OPTIMIZE_SIZE')
|
||||
elif compression == COMPACT:
|
||||
print('#elif !defined(HB_NO_UCD_UNASSIGNED)')
|
||||
else:
|
||||
print('#else')
|
||||
print()
|
||||
|
||||
if compression == SLOPPY:
|
||||
for i in range(len(gc)):
|
||||
if (i % 128) and gc[i] == 'Cn':
|
||||
gc[i] = gc[i - 1]
|
||||
for i in range(len(gc) - 2, -1, -1):
|
||||
if ((i + 1) % 128) and gc[i] == 'Cn':
|
||||
gc[i] = gc[i + 1]
|
||||
for i in range(len(sc)):
|
||||
if (i % 128) and sc[i] == 'Zzzz':
|
||||
sc[i] = sc[i - 1]
|
||||
for i in range(len(sc) - 2, -1, -1):
|
||||
if ((i + 1) % 128) and sc[i] == 'Zzzz':
|
||||
sc[i] = sc[i + 1]
|
||||
|
||||
|
||||
code = packTab.Code('_hb_ucd')
|
||||
|
||||
for name,data,default,mapping in datasets:
|
||||
sol = packTab.pack_table(data, default, mapping=mapping, compression=compression)
|
||||
logging.info(' Dataset=%-8s FullCost=%d' % (name, sol.fullCost))
|
||||
sol.genCode(code, name)
|
||||
|
||||
code.print_c(linkage='static inline')
|
||||
|
||||
print()
|
||||
|
||||
print('#endif')
|
||||
print()
|
||||
|
||||
print()
|
||||
print("#endif /* HB_UCD_TABLE_HH */")
|
||||
print()
|
||||
print("/* == End of generated table == */")
|
||||
logging.info('Done.')
|
||||
+277
-170
@@ -1,23 +1,53 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# flake8: noqa: F821
|
||||
|
||||
"""usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt ArabicShaping.txt Blocks.txt IndicSyllabicCategory-Additional.txt IndicPositionalCategory-Additional.txt
|
||||
|
||||
Input files:
|
||||
* https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/ArabicShaping.txt
|
||||
* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt
|
||||
* ms-use/IndicSyllabicCategory-Additional.txt
|
||||
* ms-use/IndicPositionalCategory-Additional.txt
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
if len (sys.argv) != 5:
|
||||
print >>sys.stderr, "usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt"
|
||||
sys.exit (1)
|
||||
if len (sys.argv) != 8:
|
||||
sys.exit (__doc__)
|
||||
|
||||
BLACKLISTED_BLOCKS = ["Thai", "Lao", "Tibetan"]
|
||||
DISABLED_BLOCKS = [
|
||||
'Samaritan',
|
||||
'Thai',
|
||||
'Lao',
|
||||
]
|
||||
|
||||
files = [file (x) for x in sys.argv[1:]]
|
||||
files = [open (x, encoding='utf-8') for x in sys.argv[1:]]
|
||||
|
||||
headers = [[f.readline () for i in range (2)] for j,f in enumerate(files) if j != 2]
|
||||
for j in range(5, 7):
|
||||
for line in files[j]:
|
||||
line = line.rstrip()
|
||||
if not line:
|
||||
break
|
||||
headers[j - 1].append(line)
|
||||
headers.append (["UnicodeData.txt does not have a header."])
|
||||
|
||||
data = [{} for f in files]
|
||||
values = [{} for f in files]
|
||||
data = [{} for _ in files]
|
||||
values = [{} for _ in files]
|
||||
for i, f in enumerate (files):
|
||||
extended = False
|
||||
|
||||
for line in f:
|
||||
|
||||
# TODO: https://github.com/MicrosoftDocs/typography-issues/issues/522
|
||||
if extended and line.startswith ('# ') and line.find (';'):
|
||||
line = line[2:]
|
||||
elif 'USE_Syllabic_Category' in line:
|
||||
extended = True
|
||||
|
||||
j = line.find ('#')
|
||||
if j >= 0:
|
||||
line = line[:j]
|
||||
@@ -33,19 +63,68 @@ for i, f in enumerate (files):
|
||||
else:
|
||||
end = int (uu[1], 16)
|
||||
|
||||
t = fields[1 if i != 2 else 2]
|
||||
t = fields[1 if i not in [2, 3] else 2]
|
||||
|
||||
if i == 3:
|
||||
t = 'jt_' + t
|
||||
elif i == 5 and t == 'Consonant_Final_Modifier':
|
||||
# TODO: https://github.com/MicrosoftDocs/typography-issues/issues/336
|
||||
t = 'Syllable_Modifier'
|
||||
elif i == 6 and t == 'NA':
|
||||
t = 'Not_Applicable'
|
||||
|
||||
i0 = i if i < 5 else i - 5
|
||||
for u in range (start, end + 1):
|
||||
data[i][u] = t
|
||||
values[i][t] = values[i].get (t, 0) + end - start + 1
|
||||
data[i0][u] = t
|
||||
values[i0][t] = values[i0].get (t, 0) + end - start + 1
|
||||
|
||||
defaults = ('Other', 'Not_Applicable', 'Cn', 'No_Block')
|
||||
defaults = ('Other', 'Not_Applicable', 'Cn', 'jt_X', 'No_Block')
|
||||
|
||||
# TODO Characters that are not in Unicode Indic files, but used in USE
|
||||
data[0][0x034F] = defaults[0]
|
||||
data[0][0x0640] = defaults[0]
|
||||
data[0][0x1B61] = defaults[0]
|
||||
data[0][0x1B63] = defaults[0]
|
||||
data[0][0x1B64] = defaults[0]
|
||||
data[0][0x1B65] = defaults[0]
|
||||
data[0][0x1B66] = defaults[0]
|
||||
data[0][0x1B67] = defaults[0]
|
||||
data[0][0x1B69] = defaults[0]
|
||||
data[0][0x1B6A] = defaults[0]
|
||||
data[0][0x2060] = defaults[0]
|
||||
for u in range (0xFE00, 0xFE0F + 1):
|
||||
for u in range (0x07CA, 0x07EA + 1):
|
||||
data[0][u] = defaults[0]
|
||||
data[0][0x07FA] = defaults[0]
|
||||
for u in range (0x0840, 0x0858 + 1):
|
||||
data[0][u] = defaults[0]
|
||||
for u in range (0x1887, 0x18A8 + 1):
|
||||
data[0][u] = defaults[0]
|
||||
data[0][0x18AA] = defaults[0]
|
||||
for u in range (0xA840, 0xA872 + 1):
|
||||
data[0][u] = defaults[0]
|
||||
for u in range (0x10B80, 0x10B91 + 1):
|
||||
data[0][u] = defaults[0]
|
||||
for u in range (0x10BA9, 0x10BAE + 1):
|
||||
data[0][u] = defaults[0]
|
||||
data[0][0x10FB0] = defaults[0]
|
||||
for u in range (0x10FB2, 0x10FB6 + 1):
|
||||
data[0][u] = defaults[0]
|
||||
for u in range (0x10FB8, 0x10FBF + 1):
|
||||
data[0][u] = defaults[0]
|
||||
for u in range (0x10FC1, 0x10FC4 + 1):
|
||||
data[0][u] = defaults[0]
|
||||
for u in range (0x10FC9, 0x10FCB + 1):
|
||||
data[0][u] = defaults[0]
|
||||
# TODO https://github.com/harfbuzz/harfbuzz/pull/1685
|
||||
data[0][0x1B5B] = 'Consonant_Placeholder'
|
||||
data[0][0x1B5C] = 'Consonant_Placeholder'
|
||||
data[0][0x1B5F] = 'Consonant_Placeholder'
|
||||
data[0][0x1B62] = 'Consonant_Placeholder'
|
||||
data[0][0x1B68] = 'Consonant_Placeholder'
|
||||
# TODO https://github.com/harfbuzz/harfbuzz/issues/1035
|
||||
data[0][0x11C44] = 'Consonant_Placeholder'
|
||||
data[0][0x11C45] = 'Consonant_Placeholder'
|
||||
# TODO https://github.com/harfbuzz/harfbuzz/pull/1399
|
||||
data[0][0x111C8] = 'Consonant_Placeholder'
|
||||
|
||||
# Merge data into one dict:
|
||||
for i,v in enumerate (defaults):
|
||||
@@ -58,10 +137,9 @@ for i,d in enumerate (data):
|
||||
if not u in combined:
|
||||
combined[u] = list (defaults)
|
||||
combined[u][i] = v
|
||||
combined = {k:v for k,v in combined.items() if v[3] not in BLACKLISTED_BLOCKS}
|
||||
combined = {k:v for k,v in combined.items() if v[4] not in DISABLED_BLOCKS}
|
||||
data = combined
|
||||
del combined
|
||||
num = len (data)
|
||||
|
||||
|
||||
property_names = [
|
||||
@@ -92,6 +170,7 @@ property_names = [
|
||||
'Consonant_Medial',
|
||||
'Consonant_Final',
|
||||
'Consonant_Head_Letter',
|
||||
'Consonant_Initial_Postfixed',
|
||||
'Modifying_Letter',
|
||||
'Tone_Letter',
|
||||
'Tone_Mark',
|
||||
@@ -105,6 +184,10 @@ property_names = [
|
||||
'Number_Joiner',
|
||||
'Number',
|
||||
'Brahmi_Joining_Number',
|
||||
'Hieroglyph',
|
||||
'Hieroglyph_Joiner',
|
||||
'Hieroglyph_Segment_Begin',
|
||||
'Hieroglyph_Segment_End',
|
||||
# Indic_Positional_Category
|
||||
'Not_Applicable',
|
||||
'Right',
|
||||
@@ -114,12 +197,22 @@ property_names = [
|
||||
'Top',
|
||||
'Bottom',
|
||||
'Top_And_Bottom',
|
||||
'Top_And_Bottom_And_Left',
|
||||
'Top_And_Right',
|
||||
'Top_And_Left',
|
||||
'Top_And_Left_And_Right',
|
||||
'Bottom_And_Left',
|
||||
'Bottom_And_Right',
|
||||
'Top_And_Bottom_And_Right',
|
||||
'Overstruck',
|
||||
# Joining_Type
|
||||
'jt_C',
|
||||
'jt_D',
|
||||
'jt_L',
|
||||
'jt_R',
|
||||
'jt_T',
|
||||
'jt_U',
|
||||
'jt_X',
|
||||
]
|
||||
|
||||
class PropertyValue(object):
|
||||
@@ -128,9 +221,11 @@ class PropertyValue(object):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
def __eq__(self, other):
|
||||
return self.name == (other if isinstance(other, basestring) else other.name)
|
||||
return self.name == (other if isinstance(other, str) else other.name)
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
def __hash__(self):
|
||||
return hash(str(self))
|
||||
|
||||
property_values = {}
|
||||
|
||||
@@ -142,104 +237,105 @@ for name in property_names:
|
||||
globals().update(property_values)
|
||||
|
||||
|
||||
def is_BASE(U, UISC, UGC):
|
||||
def is_BASE(U, UISC, UGC, AJT):
|
||||
return (UISC in [Number, Consonant, Consonant_Head_Letter,
|
||||
#SPEC-DRAFT Consonant_Placeholder,
|
||||
Tone_Letter,
|
||||
Vowel_Independent #SPEC-DRAFT
|
||||
Vowel_Independent,
|
||||
] or
|
||||
# TODO: https://github.com/MicrosoftDocs/typography-issues/issues/484
|
||||
AJT in [jt_C, jt_D, jt_L, jt_R] and UISC != Joiner or
|
||||
(UGC == Lo and UISC in [Avagraha, Bindu, Consonant_Final, Consonant_Medial,
|
||||
Consonant_Subjoined, Vowel, Vowel_Dependent]))
|
||||
def is_BASE_IND(U, UISC, UGC):
|
||||
#SPEC-DRAFT return (UISC in [Consonant_Dead, Modifying_Letter] or UGC == Po)
|
||||
return (UISC in [Consonant_Dead, Modifying_Letter] or
|
||||
(UGC == Po and not U in [0x104E, 0x2022]) or
|
||||
False # SPEC-DRAFT-OUTDATED! U == 0x002D
|
||||
)
|
||||
def is_BASE_NUM(U, UISC, UGC):
|
||||
def is_BASE_NUM(U, UISC, UGC, AJT):
|
||||
return UISC == Brahmi_Joining_Number
|
||||
def is_BASE_OTHER(U, UISC, UGC):
|
||||
if UISC == Consonant_Placeholder: return True #SPEC-DRAFT
|
||||
#SPEC-DRAFT return U in [0x00A0, 0x00D7, 0x2015, 0x2022, 0x25CC, 0x25FB, 0x25FC, 0x25FD, 0x25FE]
|
||||
def is_BASE_OTHER(U, UISC, UGC, AJT):
|
||||
if UISC == Consonant_Placeholder: return True
|
||||
return U in [0x2015, 0x2022, 0x25FB, 0x25FC, 0x25FD, 0x25FE]
|
||||
def is_CGJ(U, UISC, UGC):
|
||||
return U == 0x034F
|
||||
def is_CONS_FINAL(U, UISC, UGC):
|
||||
def is_CONS_FINAL(U, UISC, UGC, AJT):
|
||||
return ((UISC == Consonant_Final and UGC != Lo) or
|
||||
UISC == Consonant_Succeeding_Repha)
|
||||
def is_CONS_FINAL_MOD(U, UISC, UGC):
|
||||
#SPEC-DRAFT return UISC in [Consonant_Final_Modifier, Syllable_Modifier]
|
||||
return UISC == Syllable_Modifier
|
||||
def is_CONS_MED(U, UISC, UGC):
|
||||
return UISC == Consonant_Medial and UGC != Lo
|
||||
def is_CONS_MOD(U, UISC, UGC):
|
||||
return UISC in [Nukta, Gemination_Mark, Consonant_Killer]
|
||||
def is_CONS_SUB(U, UISC, UGC):
|
||||
#SPEC-DRAFT return UISC == Consonant_Subjoined
|
||||
def is_CONS_FINAL_MOD(U, UISC, UGC, AJT):
|
||||
return UISC == Syllable_Modifier
|
||||
def is_CONS_MED(U, UISC, UGC, AJT):
|
||||
# Consonant_Initial_Postfixed is new in Unicode 11; not in the spec.
|
||||
return (UISC == Consonant_Medial and UGC != Lo or
|
||||
UISC == Consonant_Initial_Postfixed)
|
||||
def is_CONS_MOD(U, UISC, UGC, AJT):
|
||||
return (UISC in [Nukta, Gemination_Mark, Consonant_Killer] and
|
||||
not is_SYM_MOD(U, UISC, UGC, AJT))
|
||||
def is_CONS_SUB(U, UISC, UGC, AJT):
|
||||
return UISC == Consonant_Subjoined and UGC != Lo
|
||||
def is_HALANT(U, UISC, UGC):
|
||||
return UISC in [Virama, Invisible_Stacker]
|
||||
def is_HALANT_NUM(U, UISC, UGC):
|
||||
def is_CONS_WITH_STACKER(U, UISC, UGC, AJT):
|
||||
return UISC == Consonant_With_Stacker
|
||||
def is_HALANT(U, UISC, UGC, AJT):
|
||||
return (UISC in [Virama, Invisible_Stacker]
|
||||
and not is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UGC, AJT)
|
||||
and not is_SAKOT(U, UISC, UGC, AJT))
|
||||
def is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UGC, AJT):
|
||||
# https://github.com/harfbuzz/harfbuzz/issues/1102
|
||||
# https://github.com/harfbuzz/harfbuzz/issues/1379
|
||||
return U in [0x11046, 0x1134D]
|
||||
def is_HALANT_NUM(U, UISC, UGC, AJT):
|
||||
return UISC == Number_Joiner
|
||||
def is_ZWNJ(U, UISC, UGC):
|
||||
def is_HIEROGLYPH(U, UISC, UGC, AJT):
|
||||
return UISC == Hieroglyph
|
||||
def is_HIEROGLYPH_JOINER(U, UISC, UGC, AJT):
|
||||
return UISC == Hieroglyph_Joiner
|
||||
def is_HIEROGLYPH_SEGMENT_BEGIN(U, UISC, UGC, AJT):
|
||||
return UISC == Hieroglyph_Segment_Begin
|
||||
def is_HIEROGLYPH_SEGMENT_END(U, UISC, UGC, AJT):
|
||||
return UISC == Hieroglyph_Segment_End
|
||||
def is_ZWNJ(U, UISC, UGC, AJT):
|
||||
return UISC == Non_Joiner
|
||||
def is_ZWJ(U, UISC, UGC):
|
||||
return UISC == Joiner
|
||||
def is_Word_Joiner(U, UISC, UGC):
|
||||
return U == 0x2060
|
||||
def is_OTHER(U, UISC, UGC):
|
||||
#SPEC-OUTDATED return UGC == Zs # or any other SCRIPT_COMMON characters
|
||||
return (UISC == Other
|
||||
and not is_SYM_MOD(U, UISC, UGC)
|
||||
and not is_CGJ(U, UISC, UGC)
|
||||
and not is_Word_Joiner(U, UISC, UGC)
|
||||
and not is_VARIATION_SELECTOR(U, UISC, UGC)
|
||||
def is_OTHER(U, UISC, UGC, AJT):
|
||||
return ((UGC in [Cn, Po] or UISC in [Consonant_Dead, Joiner, Modifying_Letter, Other])
|
||||
and not is_BASE(U, UISC, UGC, AJT)
|
||||
and not is_BASE_OTHER(U, UISC, UGC, AJT)
|
||||
and not is_SYM(U, UISC, UGC, AJT)
|
||||
and not is_SYM_MOD(U, UISC, UGC, AJT)
|
||||
)
|
||||
def is_Reserved(U, UISC, UGC):
|
||||
return UGC == 'Cn'
|
||||
def is_REPHA(U, UISC, UGC):
|
||||
#return UISC == Consonant_Preceding_Repha
|
||||
#SPEC-OUTDATED hack to categorize Consonant_With_Stacker and Consonant_Prefixed
|
||||
return UISC in [Consonant_Preceding_Repha, Consonant_With_Stacker, Consonant_Prefixed]
|
||||
def is_SYM(U, UISC, UGC):
|
||||
if U == 0x25CC: return False #SPEC-DRAFT
|
||||
#SPEC-DRAFT return UGC in [So, Sc] or UISC == Symbol_Letter
|
||||
return UGC in [So, Sc]
|
||||
def is_SYM_MOD(U, UISC, UGC):
|
||||
def is_REPHA(U, UISC, UGC, AJT):
|
||||
return UISC in [Consonant_Preceding_Repha, Consonant_Prefixed]
|
||||
def is_SAKOT(U, UISC, UGC, AJT):
|
||||
return U == 0x1A60
|
||||
def is_SYM(U, UISC, UGC, AJT):
|
||||
if U in [0x25CC, 0x1E14F]: return False
|
||||
return UGC in [So, Sc] and U not in [0x0F01, 0x1B62, 0x1B68]
|
||||
def is_SYM_MOD(U, UISC, UGC, AJT):
|
||||
return U in [0x1B6B, 0x1B6C, 0x1B6D, 0x1B6E, 0x1B6F, 0x1B70, 0x1B71, 0x1B72, 0x1B73]
|
||||
def is_VARIATION_SELECTOR(U, UISC, UGC):
|
||||
return 0xFE00 <= U <= 0xFE0F
|
||||
def is_VOWEL(U, UISC, UGC):
|
||||
# https://github.com/roozbehp/unicode-data/issues/6
|
||||
def is_VOWEL(U, UISC, UGC, AJT):
|
||||
# https://github.com/harfbuzz/harfbuzz/issues/376
|
||||
return (UISC == Pure_Killer or
|
||||
(UGC != Lo and UISC in [Vowel, Vowel_Dependent] and U not in [0xAA29]))
|
||||
def is_VOWEL_MOD(U, UISC, UGC):
|
||||
# https://github.com/roozbehp/unicode-data/issues/6
|
||||
def is_VOWEL_MOD(U, UISC, UGC, AJT):
|
||||
# https://github.com/harfbuzz/harfbuzz/issues/376
|
||||
return (UISC in [Tone_Mark, Cantillation_Mark, Register_Shifter, Visarga] or
|
||||
(UGC != Lo and (UISC == Bindu or U in [0xAA29])))
|
||||
|
||||
# CGJ, VS, WJ, and ZWJ are handled in find_syllables
|
||||
use_mapping = {
|
||||
'B': is_BASE,
|
||||
'IND': is_BASE_IND,
|
||||
'N': is_BASE_NUM,
|
||||
'GB': is_BASE_OTHER,
|
||||
'CGJ': is_CGJ,
|
||||
'F': is_CONS_FINAL,
|
||||
'FM': is_CONS_FINAL_MOD,
|
||||
'M': is_CONS_MED,
|
||||
'CM': is_CONS_MOD,
|
||||
'SUB': is_CONS_SUB,
|
||||
'CS': is_CONS_WITH_STACKER,
|
||||
'H': is_HALANT,
|
||||
'HVM': is_HALANT_OR_VOWEL_MODIFIER,
|
||||
'HN': is_HALANT_NUM,
|
||||
'G': is_HIEROGLYPH,
|
||||
'J': is_HIEROGLYPH_JOINER,
|
||||
'SB': is_HIEROGLYPH_SEGMENT_BEGIN,
|
||||
'SE': is_HIEROGLYPH_SEGMENT_END,
|
||||
'ZWNJ': is_ZWNJ,
|
||||
'ZWJ': is_ZWJ,
|
||||
'WJ': is_Word_Joiner,
|
||||
'O': is_OTHER,
|
||||
'Rsv': is_Reserved,
|
||||
'R': is_REPHA,
|
||||
'S': is_SYM,
|
||||
'Sk': is_SAKOT,
|
||||
'SM': is_SYM_MOD,
|
||||
'VS': is_VARIATION_SELECTOR,
|
||||
'V': is_VOWEL,
|
||||
'VM': is_VOWEL_MOD,
|
||||
}
|
||||
@@ -252,13 +348,13 @@ use_positions = {
|
||||
},
|
||||
'M': {
|
||||
'Abv': [Top],
|
||||
'Blw': [Bottom],
|
||||
'Blw': [Bottom, Bottom_And_Left, Bottom_And_Right],
|
||||
'Pst': [Right],
|
||||
'Pre': [Left],
|
||||
'Pre': [Left, Top_And_Bottom_And_Left],
|
||||
},
|
||||
'CM': {
|
||||
'Abv': [Top],
|
||||
'Blw': [Bottom],
|
||||
'Blw': [Bottom, Overstruck],
|
||||
},
|
||||
'V': {
|
||||
'Abv': [Top, Top_And_Bottom, Top_And_Bottom_And_Right, Top_And_Right],
|
||||
@@ -277,59 +373,69 @@ use_positions = {
|
||||
'Blw': [Bottom],
|
||||
},
|
||||
'H': None,
|
||||
'HVM': None,
|
||||
'B': None,
|
||||
'FM': None,
|
||||
'FM': {
|
||||
'Abv': [Top],
|
||||
'Blw': [Bottom],
|
||||
'Pst': [Not_Applicable],
|
||||
},
|
||||
'R': None,
|
||||
'SUB': None,
|
||||
}
|
||||
|
||||
def map_to_use(data):
|
||||
out = {}
|
||||
items = use_mapping.items()
|
||||
for U,(UISC,UIPC,UGC,UBlock) in data.items():
|
||||
for U,(UISC,UIPC,UGC,AJT,UBlock) in data.items():
|
||||
|
||||
# Resolve Indic_Syllabic_Category
|
||||
|
||||
# TODO: These don't have UISC assigned in Unicode 8.0, but
|
||||
# have UIPC
|
||||
if U == 0x17DD: UISC = Vowel_Dependent
|
||||
# TODO: These don't have UISC assigned in Unicode 13.0.0, but have UIPC
|
||||
if 0x1CE2 <= U <= 0x1CE8: UISC = Cantillation_Mark
|
||||
|
||||
# Tibetan:
|
||||
# TODO: These don't have UISC assigned in Unicode 13.0.0, but have UIPC
|
||||
if 0x0F18 <= U <= 0x0F19 or 0x0F3E <= U <= 0x0F3F: UISC = Vowel_Dependent
|
||||
|
||||
# TODO: https://github.com/harfbuzz/harfbuzz/pull/627
|
||||
if 0x1BF2 <= U <= 0x1BF3: UISC = Nukta; UIPC = Bottom
|
||||
|
||||
# TODO: U+1CED should only be allowed after some of
|
||||
# the nasalization marks, maybe only for U+1CE9..U+1CF1.
|
||||
if U == 0x1CED: UISC = Tone_Mark
|
||||
|
||||
evals = [(k, v(U,UISC,UGC)) for k,v in items]
|
||||
values = [k for k,v in evals if v]
|
||||
assert len(values) == 1, "%s %s %s %s" % (hex(U), UISC, UGC, values)
|
||||
# TODO: https://github.com/microsoft/font-tools/issues/1
|
||||
if U == 0xA982: UISC = Consonant_Succeeding_Repha
|
||||
|
||||
values = [k for k,v in items if v(U,UISC,UGC,AJT)]
|
||||
assert len(values) == 1, "%s %s %s %s %s" % (hex(U), UISC, UGC, AJT, values)
|
||||
USE = values[0]
|
||||
|
||||
# Resolve Indic_Positional_Category
|
||||
|
||||
# TODO: Not in Unicode 8.0 yet, but in spec.
|
||||
if U == 0x1B6C: UIPC = Bottom
|
||||
|
||||
# TODO: These should die, but have UIPC in Unicode 8.0
|
||||
# TODO: These should die, but have UIPC in Unicode 13.0.0
|
||||
if U in [0x953, 0x954]: UIPC = Not_Applicable
|
||||
|
||||
# TODO: In USE's override list but not in Unicode 8.0
|
||||
if U == 0x103C: UIPC = Left
|
||||
|
||||
# TODO: These are not in USE's override list that we have, nor are they in Unicode 8.0
|
||||
# TODO: These are not in USE's override list that we have, nor are they in Unicode 13.0.0
|
||||
if 0xA926 <= U <= 0xA92A: UIPC = Top
|
||||
if U == 0x111CA: UIPC = Bottom
|
||||
if U == 0x11300: UIPC = Top
|
||||
if U == 0x1133C: UIPC = Bottom
|
||||
if U == 0x1171E: UIPC = Left # Correct?!
|
||||
if 0x1CF2 <= U <= 0x1CF3: UIPC = Right
|
||||
# TODO: https://github.com/harfbuzz/harfbuzz/pull/1037
|
||||
# and https://github.com/harfbuzz/harfbuzz/issues/1631
|
||||
if U in [0x11302, 0x11303, 0x114C1]: UIPC = Top
|
||||
if 0x1CF8 <= U <= 0x1CF9: UIPC = Top
|
||||
|
||||
assert (UIPC in [Not_Applicable, Visual_Order_Left] or
|
||||
USE in use_positions), "%s %s %s %s %s" % (hex(U), UIPC, USE, UISC, UGC)
|
||||
# TODO: https://github.com/harfbuzz/harfbuzz/pull/982
|
||||
# also https://github.com/harfbuzz/harfbuzz/issues/1012
|
||||
if 0x1112A <= U <= 0x1112B: UIPC = Top
|
||||
if 0x11131 <= U <= 0x11132: UIPC = Top
|
||||
|
||||
assert (UIPC in [Not_Applicable, Visual_Order_Left] or U == 0x0F7F or
|
||||
USE in use_positions), "%s %s %s %s %s %s" % (hex(U), UIPC, USE, UISC, UGC, AJT)
|
||||
|
||||
pos_mapping = use_positions.get(USE, None)
|
||||
if pos_mapping:
|
||||
values = [k for k,v in pos_mapping.items() if v and UIPC in v]
|
||||
assert len(values) == 1, "%s %s %s %s %s %s" % (hex(U), UIPC, USE, UISC, UGC, values)
|
||||
assert len(values) == 1, "%s %s %s %s %s %s %s" % (hex(U), UIPC, USE, UISC, UGC, AJT, values)
|
||||
USE = USE + values[0]
|
||||
|
||||
out[U] = (USE, UBlock)
|
||||
@@ -338,27 +444,26 @@ def map_to_use(data):
|
||||
defaults = ('O', 'No_Block')
|
||||
data = map_to_use(data)
|
||||
|
||||
# Remove the outliers
|
||||
singles = {}
|
||||
for u in [0x034F, 0x25CC, 0x1107F]:
|
||||
singles[u] = data[u]
|
||||
del data[u]
|
||||
|
||||
print "/* == Start of generated table == */"
|
||||
print "/*"
|
||||
print " * The following table is generated by running:"
|
||||
print " *"
|
||||
print " * ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt"
|
||||
print " *"
|
||||
print " * on files with these headers:"
|
||||
print " *"
|
||||
print ("/* == Start of generated table == */")
|
||||
print ("/*")
|
||||
print (" * The following table is generated by running:")
|
||||
print (" *")
|
||||
print (" * {} IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt ArabicShaping.txt Blocks.txt IndicSyllabicCategory-Additional.txt IndicPositionalCategory-Additional.txt".format (sys.argv[0]))
|
||||
print (" *")
|
||||
print (" * on files with these headers:")
|
||||
print (" *")
|
||||
for h in headers:
|
||||
for l in h:
|
||||
print " * %s" % (l.strip())
|
||||
print " */"
|
||||
print
|
||||
print '#include "hb-ot-shape-complex-use-private.hh"'
|
||||
print
|
||||
print (" * %s" % (l.strip()))
|
||||
print (" */")
|
||||
print ()
|
||||
print ("#ifndef HB_OT_SHAPE_COMPLEX_USE_TABLE_HH")
|
||||
print ("#define HB_OT_SHAPE_COMPLEX_USE_TABLE_HH")
|
||||
print ()
|
||||
print ('#include "hb.hh"')
|
||||
print ()
|
||||
print ('#include "hb-ot-shape-complex-use-machine.hh"')
|
||||
print ()
|
||||
|
||||
total = 0
|
||||
used = 0
|
||||
@@ -366,49 +471,53 @@ last_block = None
|
||||
def print_block (block, start, end, data):
|
||||
global total, used, last_block
|
||||
if block and block != last_block:
|
||||
print
|
||||
print
|
||||
print " /* %s */" % block
|
||||
print ()
|
||||
print ()
|
||||
print (" /* %s */" % block)
|
||||
if start % 16:
|
||||
print ' ' * (20 + (start % 16 * 6)),
|
||||
print (' ' * (20 + (start % 16 * 6)), end='')
|
||||
num = 0
|
||||
assert start % 8 == 0
|
||||
assert (end+1) % 8 == 0
|
||||
for u in range (start, end+1):
|
||||
if u % 16 == 0:
|
||||
print
|
||||
print " /* %04X */" % u,
|
||||
print ()
|
||||
print (" /* %04X */" % u, end='')
|
||||
if u in data:
|
||||
num += 1
|
||||
d = data.get (u, defaults)
|
||||
sys.stdout.write ("%6s," % d[0])
|
||||
print ("%6s," % d[0], end='')
|
||||
|
||||
total += end - start + 1
|
||||
used += num
|
||||
if block:
|
||||
last_block = block
|
||||
|
||||
uu = data.keys ()
|
||||
uu.sort ()
|
||||
uu = sorted (data.keys ())
|
||||
|
||||
last = -100000
|
||||
num = 0
|
||||
offset = 0
|
||||
starts = []
|
||||
ends = []
|
||||
print ('#pragma GCC diagnostic push')
|
||||
print ('#pragma GCC diagnostic ignored "-Wunused-macros"')
|
||||
for k,v in sorted(use_mapping.items()):
|
||||
if k in use_positions and use_positions[k]: continue
|
||||
print "#define %s USE_%s /* %s */" % (k, k, v.__name__[3:])
|
||||
print ("#define %s USE(%s) /* %s */" % (k, k, v.__name__[3:]))
|
||||
for k,v in sorted(use_positions.items()):
|
||||
if not v: continue
|
||||
for suf in v.keys():
|
||||
tag = k + suf
|
||||
print "#define %s USE_%s" % (tag, tag)
|
||||
print ""
|
||||
print "static const USE_TABLE_ELEMENT_TYPE use_table[] = {"
|
||||
print ("#define %s USE(%s)" % (tag, tag))
|
||||
print ('#pragma GCC diagnostic pop')
|
||||
print ("")
|
||||
print ("static const uint8_t use_table[] = {")
|
||||
for u in uu:
|
||||
if u <= last:
|
||||
continue
|
||||
if data[u][0] == 'O':
|
||||
continue
|
||||
block = data[u][1]
|
||||
|
||||
start = u//8*8
|
||||
@@ -420,59 +529,57 @@ for u in uu:
|
||||
if start != last + 1:
|
||||
if start - last <= 1+16*3:
|
||||
print_block (None, last+1, start-1, data)
|
||||
last = start-1
|
||||
else:
|
||||
if last >= 0:
|
||||
ends.append (last + 1)
|
||||
offset += ends[-1] - starts[-1]
|
||||
print
|
||||
print
|
||||
print "#define use_offset_0x%04xu %d" % (start, offset)
|
||||
print ()
|
||||
print ()
|
||||
print ("#define use_offset_0x%04xu %d" % (start, offset))
|
||||
starts.append (start)
|
||||
|
||||
print_block (block, start, end, data)
|
||||
last = end
|
||||
ends.append (last + 1)
|
||||
offset += ends[-1] - starts[-1]
|
||||
print
|
||||
print
|
||||
print ()
|
||||
print ()
|
||||
occupancy = used * 100. / total
|
||||
page_bits = 12
|
||||
print "}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)
|
||||
print
|
||||
print "USE_TABLE_ELEMENT_TYPE"
|
||||
print "hb_use_get_categories (hb_codepoint_t u)"
|
||||
print "{"
|
||||
print " switch (u >> %d)" % page_bits
|
||||
print " {"
|
||||
pages = set([u>>page_bits for u in starts+ends+singles.keys()])
|
||||
print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy))
|
||||
print ()
|
||||
print ("static inline uint8_t")
|
||||
print ("hb_use_get_category (hb_codepoint_t u)")
|
||||
print ("{")
|
||||
print (" switch (u >> %d)" % page_bits)
|
||||
print (" {")
|
||||
pages = set([u>>page_bits for u in starts+ends])
|
||||
for p in sorted(pages):
|
||||
print " case 0x%0Xu:" % p
|
||||
print (" case 0x%0Xu:" % p)
|
||||
for (start,end) in zip (starts, ends):
|
||||
if p not in [start>>page_bits, end>>page_bits]: continue
|
||||
offset = "use_offset_0x%04xu" % start
|
||||
print " if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return use_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
|
||||
for u,d in singles.items ():
|
||||
if p != u>>page_bits: continue
|
||||
print " if (unlikely (u == 0x%04Xu)) return %s;" % (u, d[0])
|
||||
print " break;"
|
||||
print ""
|
||||
print " default:"
|
||||
print " break;"
|
||||
print " }"
|
||||
print " return USE_O;"
|
||||
print "}"
|
||||
print
|
||||
print (" if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return use_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset))
|
||||
print (" break;")
|
||||
print ("")
|
||||
print (" default:")
|
||||
print (" break;")
|
||||
print (" }")
|
||||
print (" return USE(O);")
|
||||
print ("}")
|
||||
print ()
|
||||
for k in sorted(use_mapping.keys()):
|
||||
if k in use_positions and use_positions[k]: continue
|
||||
print "#undef %s" % k
|
||||
print ("#undef %s" % k)
|
||||
for k,v in sorted(use_positions.items()):
|
||||
if not v: continue
|
||||
for suf in v.keys():
|
||||
tag = k + suf
|
||||
print "#undef %s" % tag
|
||||
print
|
||||
print "/* == End of generated table == */"
|
||||
print ("#undef %s" % tag)
|
||||
print ()
|
||||
print ()
|
||||
print ("#endif /* HB_OT_SHAPE_COMPLEX_USE_TABLE_HH */")
|
||||
print ("/* == End of generated table == */")
|
||||
|
||||
# Maintain at least 50% occupancy in the table */
|
||||
if occupancy < 50:
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Generator of the function to prohibit certain vowel sequences.
|
||||
|
||||
It creates ``_hb_preprocess_text_vowel_constraints``, which inserts dotted
|
||||
circles into sequences prohibited by the USE script development spec.
|
||||
This function should be used as the ``preprocess_text`` of an
|
||||
``hb_ot_complex_shaper_t``.
|
||||
|
||||
usage: ./gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt
|
||||
|
||||
Input file:
|
||||
* https://unicode.org/Public/UCD/latest/ucd/Scripts.txt
|
||||
"""
|
||||
|
||||
import collections
|
||||
def write (s):
|
||||
sys.stdout.flush ()
|
||||
sys.stdout.buffer.write (s.encode ('utf-8'))
|
||||
import sys
|
||||
|
||||
if len (sys.argv) != 3:
|
||||
sys.exit (__doc__)
|
||||
|
||||
with open (sys.argv[2], encoding='utf-8') as f:
|
||||
scripts_header = [f.readline () for i in range (2)]
|
||||
scripts = {}
|
||||
script_order = {}
|
||||
for line in f:
|
||||
j = line.find ('#')
|
||||
if j >= 0:
|
||||
line = line[:j]
|
||||
fields = [x.strip () for x in line.split (';')]
|
||||
if len (fields) == 1:
|
||||
continue
|
||||
uu = fields[0].split ('..')
|
||||
start = int (uu[0], 16)
|
||||
if len (uu) == 1:
|
||||
end = start
|
||||
else:
|
||||
end = int (uu[1], 16)
|
||||
script = fields[1]
|
||||
for u in range (start, end + 1):
|
||||
scripts[u] = script
|
||||
if script not in script_order:
|
||||
script_order[script] = start
|
||||
|
||||
class ConstraintSet (object):
|
||||
"""A set of prohibited code point sequences.
|
||||
|
||||
Args:
|
||||
constraint (List[int]): A prohibited code point sequence.
|
||||
|
||||
"""
|
||||
def __init__ (self, constraint):
|
||||
# Either a list or a dictionary. As a list of code points, it
|
||||
# represents a prohibited code point sequence. As a dictionary,
|
||||
# it represents a set of prohibited sequences, where each item
|
||||
# represents the set of prohibited sequences starting with the
|
||||
# key (a code point) concatenated with any of the values
|
||||
# (ConstraintSets).
|
||||
self._c = constraint
|
||||
|
||||
def add (self, constraint):
|
||||
"""Add a constraint to this set."""
|
||||
if not constraint:
|
||||
return
|
||||
first = constraint[0]
|
||||
rest = constraint[1:]
|
||||
if isinstance (self._c, list):
|
||||
if constraint == self._c[:len (constraint)]:
|
||||
self._c = constraint
|
||||
elif self._c != constraint[:len (self._c)]:
|
||||
self._c = {self._c[0]: ConstraintSet (self._c[1:])}
|
||||
if isinstance (self._c, dict):
|
||||
if first in self._c:
|
||||
self._c[first].add (rest)
|
||||
else:
|
||||
self._c[first] = ConstraintSet (rest)
|
||||
|
||||
@staticmethod
|
||||
def _indent (depth):
|
||||
return (' ' * depth).replace (' ', '\t')
|
||||
|
||||
def __str__ (self, index=0, depth=4):
|
||||
s = []
|
||||
indent = self._indent (depth)
|
||||
if isinstance (self._c, list):
|
||||
if len (self._c) == 0:
|
||||
assert index == 2, 'Cannot use `matched` for this constraint; the general case has not been implemented'
|
||||
s.append ('{}matched = true;\n'.format (indent))
|
||||
elif len (self._c) == 1:
|
||||
assert index == 1, 'Cannot use `matched` for this constraint; the general case has not been implemented'
|
||||
s.append ('{}matched = 0x{:04X}u == buffer->cur ({}).codepoint;\n'.format (indent, next (iter (self._c)), index or ''))
|
||||
else:
|
||||
s.append ('{}if (0x{:04X}u == buffer->cur ({}).codepoint &&\n'.format (indent, self._c[0], index or ''))
|
||||
if index:
|
||||
s.append ('{}buffer->idx + {} < count &&\n'.format (self._indent (depth + 2), index + 1))
|
||||
for i, cp in enumerate (self._c[1:], start=1):
|
||||
s.append ('{}0x{:04X}u == buffer->cur ({}).codepoint{}\n'.format (
|
||||
self._indent (depth + 2), cp, index + i, ')' if i == len (self._c) - 1 else ' &&'))
|
||||
s.append ('{}{{\n'.format (indent))
|
||||
for i in range (index):
|
||||
s.append ('{}(void) buffer->next_glyph ();\n'.format (self._indent (depth + 1)))
|
||||
s.append ('{}matched = true;\n'.format (self._indent (depth + 1)))
|
||||
s.append ('{}}}\n'.format (indent))
|
||||
else:
|
||||
s.append ('{}switch (buffer->cur ({}).codepoint)\n'.format(indent, index or ''))
|
||||
s.append ('{}{{\n'.format (indent))
|
||||
cases = collections.defaultdict (set)
|
||||
for first, rest in sorted (self._c.items ()):
|
||||
cases[rest.__str__ (index + 1, depth + 2)].add (first)
|
||||
for body, labels in sorted (cases.items (), key=lambda b_ls: sorted (b_ls[1])[0]):
|
||||
for i, cp in enumerate (sorted (labels)):
|
||||
if i % 4 == 0:
|
||||
s.append (self._indent (depth + 1))
|
||||
else:
|
||||
s.append (' ')
|
||||
s.append ('case 0x{:04X}u:{}'.format (cp, '\n' if i % 4 == 3 else ''))
|
||||
if len (labels) % 4 != 0:
|
||||
s.append ('\n')
|
||||
s.append (body)
|
||||
s.append ('{}break;\n'.format (self._indent (depth + 2)))
|
||||
s.append ('{}}}\n'.format (indent))
|
||||
return ''.join (s)
|
||||
|
||||
constraints = {}
|
||||
with open (sys.argv[1], encoding='utf-8') as f:
|
||||
constraints_header = []
|
||||
while True:
|
||||
line = f.readline ().strip ()
|
||||
if line == '#':
|
||||
break
|
||||
constraints_header.append(line)
|
||||
for line in f:
|
||||
j = line.find ('#')
|
||||
if j >= 0:
|
||||
line = line[:j]
|
||||
constraint = [int (cp, 16) for cp in line.split (';')[0].split ()]
|
||||
if not constraint: continue
|
||||
assert 2 <= len (constraint), 'Prohibited sequence is too short: {}'.format (constraint)
|
||||
script = scripts[constraint[0]]
|
||||
if script in constraints:
|
||||
constraints[script].add (constraint)
|
||||
else:
|
||||
constraints[script] = ConstraintSet (constraint)
|
||||
assert constraints, 'No constraints found'
|
||||
|
||||
print ('/* == Start of generated functions == */')
|
||||
print ('/*')
|
||||
print (' * The following functions are generated by running:')
|
||||
print (' *')
|
||||
print (' * %s ms-use/IndicShapingInvalidCluster.txt Scripts.txt' % sys.argv[0])
|
||||
print (' *')
|
||||
print (' * on files with these headers:')
|
||||
print (' *')
|
||||
for line in constraints_header:
|
||||
print (' * %s' % line.strip ())
|
||||
print (' *')
|
||||
for line in scripts_header:
|
||||
print (' * %s' % line.strip ())
|
||||
print (' */')
|
||||
|
||||
print ()
|
||||
print ('#include "hb.hh"')
|
||||
print ()
|
||||
print ('#ifndef HB_NO_OT_SHAPE')
|
||||
print ()
|
||||
print ('#include "hb-ot-shape-complex-vowel-constraints.hh"')
|
||||
print ()
|
||||
print ('static void')
|
||||
print ('_output_dotted_circle (hb_buffer_t *buffer)')
|
||||
print ('{')
|
||||
print (' (void) buffer->output_glyph (0x25CCu);')
|
||||
print (' _hb_glyph_info_reset_continuation (&buffer->prev());')
|
||||
print ('}')
|
||||
print ()
|
||||
print ('static void')
|
||||
print ('_output_with_dotted_circle (hb_buffer_t *buffer)')
|
||||
print ('{')
|
||||
print (' _output_dotted_circle (buffer);')
|
||||
print (' (void) buffer->next_glyph ();')
|
||||
print ('}')
|
||||
print ()
|
||||
|
||||
print ('void')
|
||||
print ('_hb_preprocess_text_vowel_constraints (const hb_ot_shape_plan_t *plan HB_UNUSED,')
|
||||
print ('\t\t\t\t hb_buffer_t *buffer,')
|
||||
print ('\t\t\t\t hb_font_t *font HB_UNUSED)')
|
||||
print ('{')
|
||||
print ('#ifdef HB_NO_OT_SHAPE_COMPLEX_VOWEL_CONSTRAINTS')
|
||||
print (' return;')
|
||||
print ('#endif')
|
||||
print (' if (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE)')
|
||||
print (' return;')
|
||||
print ()
|
||||
print (' /* UGLY UGLY UGLY business of adding dotted-circle in the middle of')
|
||||
print (' * vowel-sequences that look like another vowel. Data for each script')
|
||||
print (' * collected from the USE script development spec.')
|
||||
print (' *')
|
||||
print (' * https://github.com/harfbuzz/harfbuzz/issues/1019')
|
||||
print (' */')
|
||||
print (' buffer->clear_output ();')
|
||||
print (' unsigned int count = buffer->len;')
|
||||
print (' switch ((unsigned) buffer->props.script)')
|
||||
print (' {')
|
||||
|
||||
for script, constraints in sorted (constraints.items (), key=lambda s_c: script_order[s_c[0]]):
|
||||
print (' case HB_SCRIPT_{}:'.format (script.upper ()))
|
||||
print (' for (buffer->idx = 0; buffer->idx + 1 < count && buffer->successful;)')
|
||||
print (' {')
|
||||
print ('\tbool matched = false;')
|
||||
write (str (constraints))
|
||||
print ('\t(void) buffer->next_glyph ();')
|
||||
print ('\tif (matched) _output_with_dotted_circle (buffer);')
|
||||
print (' }')
|
||||
print (' break;')
|
||||
print ()
|
||||
|
||||
print (' default:')
|
||||
print (' break;')
|
||||
print (' }')
|
||||
print (' buffer->swap_buffers ();')
|
||||
print ('}')
|
||||
|
||||
print ()
|
||||
print ()
|
||||
print ('#endif')
|
||||
print ('/* == End of generated functions == */')
|
||||
@@ -0,0 +1,86 @@
|
||||
# Set these variables so that the `${prefix}/lib` expands to something we can
|
||||
# remove.
|
||||
set(_harfbuzz_remove_string "REMOVE_ME")
|
||||
set(exec_prefix "${_harfbuzz_remove_string}")
|
||||
set(prefix "${_harfbuzz_remove_string}")
|
||||
|
||||
# Compute the installation prefix by stripping components from our current
|
||||
# location.
|
||||
get_filename_component(_harfbuzz_prefix "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
|
||||
get_filename_component(_harfbuzz_prefix "${_harfbuzz_prefix}" DIRECTORY)
|
||||
set(_harfbuzz_libdir "@libdir@")
|
||||
string(REPLACE "${_harfbuzz_remove_string}/" "" _harfbuzz_libdir "${_harfbuzz_libdir}")
|
||||
set(_harfbuzz_libdir_iter "${_harfbuzz_libdir}")
|
||||
while (_harfbuzz_libdir_iter)
|
||||
set(_harfbuzz_libdir_prev_iter "${_harfbuzz_libdir_iter}")
|
||||
get_filename_component(_harfbuzz_libdir_iter "${_harfbuzz_libdir_iter}" DIRECTORY)
|
||||
if (_harfbuzz_libdir_prev_iter STREQUAL _harfbuzz_libdir_iter)
|
||||
break()
|
||||
endif ()
|
||||
get_filename_component(_harfbuzz_prefix "${_harfbuzz_prefix}" DIRECTORY)
|
||||
endwhile ()
|
||||
unset(_harfbuzz_libdir_iter)
|
||||
|
||||
# Get the include subdir.
|
||||
set(_harfbuzz_includedir "@includedir@")
|
||||
string(REPLACE "${_harfbuzz_remove_string}/" "" _harfbuzz_includedir "${_harfbuzz_includedir}")
|
||||
|
||||
# Extract version information from libtool.
|
||||
set(_harfbuzz_version_info "@HB_LIBTOOL_VERSION_INFO@")
|
||||
string(REPLACE ":" ";" _harfbuzz_version_info "${_harfbuzz_version_info}")
|
||||
list(GET _harfbuzz_version_info 0
|
||||
_harfbuzz_current)
|
||||
list(GET _harfbuzz_version_info 1
|
||||
_harfbuzz_revision)
|
||||
list(GET _harfbuzz_version_info 2
|
||||
_harfbuzz_age)
|
||||
unset(_harfbuzz_version_info)
|
||||
|
||||
if (APPLE)
|
||||
set(_harfbuzz_lib_suffix ".0${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
elseif (UNIX)
|
||||
set(_harfbuzz_lib_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}.0.${_harfbuzz_current}.${_harfbuzz_revision}")
|
||||
else ()
|
||||
# Unsupported.
|
||||
set(harfbuzz_FOUND 0)
|
||||
endif ()
|
||||
|
||||
# Add the libraries.
|
||||
add_library(harfbuzz::harfbuzz SHARED IMPORTED)
|
||||
set_target_properties(harfbuzz::harfbuzz PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
|
||||
IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz${_harfbuzz_lib_suffix}")
|
||||
|
||||
add_library(harfbuzz::icu SHARED IMPORTED)
|
||||
set_target_properties(harfbuzz::icu PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
|
||||
INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
|
||||
IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-icu${_harfbuzz_lib_suffix}")
|
||||
|
||||
add_library(harfbuzz::subset SHARED IMPORTED)
|
||||
set_target_properties(harfbuzz::subset PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
|
||||
INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
|
||||
IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-subset${_harfbuzz_lib_suffix}")
|
||||
|
||||
# Only add the gobject library if it was built.
|
||||
set(_harfbuzz_have_gobject "@have_gobject@")
|
||||
if (_harfbuzz_have_gobject)
|
||||
add_library(harfbuzz::gobject SHARED IMPORTED)
|
||||
set_target_properties(harfbuzz::gobject PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_harfbuzz_prefix}/${_harfbuzz_includedir}/harfbuzz"
|
||||
INTERFACE_LINK_LIBRARIES "harfbuzz::harfbuzz"
|
||||
IMPORTED_LOCATION "${_harfbuzz_prefix}/${_harfbuzz_libdir}/libharfbuzz-gobject${_harfbuzz_lib_suffix}")
|
||||
endif ()
|
||||
|
||||
# Clean out variables we used in our scope.
|
||||
unset(_harfbuzz_lib_suffix)
|
||||
unset(_harfbuzz_current)
|
||||
unset(_harfbuzz_revision)
|
||||
unset(_harfbuzz_age)
|
||||
unset(_harfbuzz_includedir)
|
||||
unset(_harfbuzz_libdir)
|
||||
unset(_harfbuzz_prefix)
|
||||
unset(exec_prefix)
|
||||
unset(prefix)
|
||||
unset(_harfbuzz_remove_string)
|
||||
@@ -1,13 +0,0 @@
|
||||
prefix=/usr/local
|
||||
exec_prefix=/usr/local
|
||||
libdir=/usr/local/lib
|
||||
includedir=/usr/local/include
|
||||
|
||||
Name: harfbuzz
|
||||
Description: HarfBuzz text shaping library ICU integration
|
||||
Version: 1.5.1
|
||||
|
||||
Requires: harfbuzz
|
||||
Requires.private: icu-uc
|
||||
Libs: -L${libdir} -lharfbuzz-icu
|
||||
Cflags: -I${includedir}/harfbuzz
|
||||
@@ -0,0 +1,12 @@
|
||||
prefix=%prefix%
|
||||
exec_prefix=%exec_prefix%
|
||||
libdir=%libdir%
|
||||
includedir=%includedir%
|
||||
|
||||
Name: harfbuzz
|
||||
Description: HarfBuzz font subsetter
|
||||
Version: %VERSION%
|
||||
|
||||
Requires: harfbuzz
|
||||
Libs: -L${libdir} -lharfbuzz-subset
|
||||
Cflags: -I${includedir}/harfbuzz
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "hb-aat-layout.cc"
|
||||
#include "hb-aat-map.cc"
|
||||
#include "hb-blob.cc"
|
||||
#include "hb-buffer-serialize.cc"
|
||||
#include "hb-buffer.cc"
|
||||
#include "hb-common.cc"
|
||||
#include "hb-draw.cc"
|
||||
#include "hb-face.cc"
|
||||
#include "hb-fallback-shape.cc"
|
||||
#include "hb-font.cc"
|
||||
#include "hb-map.cc"
|
||||
#include "hb-number.cc"
|
||||
#include "hb-ot-cff1-table.cc"
|
||||
#include "hb-ot-cff2-table.cc"
|
||||
#include "hb-ot-color.cc"
|
||||
#include "hb-ot-face.cc"
|
||||
#include "hb-ot-font.cc"
|
||||
#include "hb-ot-layout.cc"
|
||||
#include "hb-ot-map.cc"
|
||||
#include "hb-ot-math.cc"
|
||||
#include "hb-ot-meta.cc"
|
||||
#include "hb-ot-metrics.cc"
|
||||
#include "hb-ot-name.cc"
|
||||
#include "hb-ot-shape-complex-arabic.cc"
|
||||
#include "hb-ot-shape-complex-default.cc"
|
||||
#include "hb-ot-shape-complex-hangul.cc"
|
||||
#include "hb-ot-shape-complex-hebrew.cc"
|
||||
#include "hb-ot-shape-complex-indic-table.cc"
|
||||
#include "hb-ot-shape-complex-indic.cc"
|
||||
#include "hb-ot-shape-complex-khmer.cc"
|
||||
#include "hb-ot-shape-complex-myanmar.cc"
|
||||
#include "hb-ot-shape-complex-syllabic.cc"
|
||||
#include "hb-ot-shape-complex-thai.cc"
|
||||
#include "hb-ot-shape-complex-use.cc"
|
||||
#include "hb-ot-shape-complex-vowel-constraints.cc"
|
||||
#include "hb-ot-shape-fallback.cc"
|
||||
#include "hb-ot-shape-normalize.cc"
|
||||
#include "hb-ot-shape.cc"
|
||||
#include "hb-ot-tag.cc"
|
||||
#include "hb-ot-var.cc"
|
||||
#include "hb-set.cc"
|
||||
#include "hb-shape-plan.cc"
|
||||
#include "hb-shape.cc"
|
||||
#include "hb-shaper.cc"
|
||||
#include "hb-static.cc"
|
||||
#include "hb-style.cc"
|
||||
#include "hb-ucd.cc"
|
||||
#include "hb-unicode.cc"
|
||||
#include "hb-glib.cc"
|
||||
#include "hb-ft.cc"
|
||||
#include "hb-graphite2.cc"
|
||||
#include "hb-uniscribe.cc"
|
||||
#include "hb-gdi.cc"
|
||||
#include "hb-directwrite.cc"
|
||||
#include "hb-coretext.cc"
|
||||
@@ -1,13 +0,0 @@
|
||||
prefix=/usr/local
|
||||
exec_prefix=/usr/local
|
||||
libdir=/usr/local/lib
|
||||
includedir=/usr/local/include
|
||||
|
||||
Name: harfbuzz
|
||||
Description: HarfBuzz text shaping library
|
||||
Version: 1.5.1
|
||||
|
||||
Libs: -L${libdir} -lharfbuzz
|
||||
Libs.private:
|
||||
Requires.private: glib-2.0 >= 2.19.1
|
||||
Cflags: -I${includedir}/harfbuzz
|
||||
@@ -8,6 +8,6 @@ Description: HarfBuzz text shaping library
|
||||
Version: %VERSION%
|
||||
|
||||
Libs: -L${libdir} -lharfbuzz
|
||||
Libs.private: %libs_private%
|
||||
Libs.private: -lm %libs_private%
|
||||
Requires.private: %requires_private%
|
||||
Cflags: -I${includedir}/harfbuzz
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_AAT_LAYOUT_ANKR_TABLE_HH
|
||||
#define HB_AAT_LAYOUT_ANKR_TABLE_HH
|
||||
|
||||
#include "hb-aat-layout-common.hh"
|
||||
|
||||
/*
|
||||
* ankr -- Anchor Point
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ankr.html
|
||||
*/
|
||||
#define HB_AAT_TAG_ankr HB_TAG('a','n','k','r')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
|
||||
struct Anchor
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
public:
|
||||
FWORD xCoordinate;
|
||||
FWORD yCoordinate;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
|
||||
typedef Array32Of<Anchor> GlyphAnchors;
|
||||
|
||||
struct ankr
|
||||
{
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_ankr;
|
||||
|
||||
const Anchor &get_anchor (hb_codepoint_t glyph_id,
|
||||
unsigned int i,
|
||||
unsigned int num_glyphs) const
|
||||
{
|
||||
const NNOffset16To<GlyphAnchors> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs);
|
||||
if (!offset)
|
||||
return Null (Anchor);
|
||||
const GlyphAnchors &anchors = &(this+anchorData) + *offset;
|
||||
return anchors[i];
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
version == 0 &&
|
||||
c->check_range (this, anchorData) &&
|
||||
lookupTable.sanitize (c, this, &(this+anchorData))));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 version; /* Version number (set to zero) */
|
||||
HBUINT16 flags; /* Flags (currently unused; set to zero) */
|
||||
Offset32To<Lookup<NNOffset16To<GlyphAnchors>>>
|
||||
lookupTable; /* Offset to the table's lookup table */
|
||||
NNOffset32To<HBUINT8>
|
||||
anchorData; /* Offset to the glyph data table */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (12);
|
||||
};
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_ANKR_TABLE_HH */
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_AAT_LAYOUT_BSLN_TABLE_HH
|
||||
#define HB_AAT_LAYOUT_BSLN_TABLE_HH
|
||||
|
||||
#include "hb-aat-layout-common.hh"
|
||||
|
||||
/*
|
||||
* bsln -- Baseline
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bsln.html
|
||||
*/
|
||||
#define HB_AAT_TAG_bsln HB_TAG('b','s','l','n')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
|
||||
struct BaselineTableFormat0Part
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
// Roman, Ideographic centered, Ideographic low, Hanging and Math
|
||||
// are the default defined ones, but any other maybe accessed also.
|
||||
HBINT16 deltas[32]; /* These are the FUnit distance deltas from
|
||||
* the font's natural baseline to the other
|
||||
* baselines used in the font. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (64);
|
||||
};
|
||||
|
||||
struct BaselineTableFormat1Part
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
lookupTable.sanitize (c)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBINT16 deltas[32]; /* ditto */
|
||||
Lookup<HBUINT16>
|
||||
lookupTable; /* Lookup table that maps glyphs to their
|
||||
* baseline values. */
|
||||
public:
|
||||
DEFINE_SIZE_MIN (66);
|
||||
};
|
||||
|
||||
struct BaselineTableFormat2Part
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBGlyphID stdGlyph; /* The specific glyph index number in this
|
||||
* font that is used to set the baseline values.
|
||||
* This is the standard glyph.
|
||||
* This glyph must contain a set of control points
|
||||
* (whose numbers are contained in the ctlPoints field)
|
||||
* that are used to determine baseline distances. */
|
||||
HBUINT16 ctlPoints[32]; /* Set of control point numbers,
|
||||
* associated with the standard glyph.
|
||||
* A value of 0xFFFF means there is no corresponding
|
||||
* control point in the standard glyph. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (66);
|
||||
};
|
||||
|
||||
struct BaselineTableFormat3Part
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) && lookupTable.sanitize (c)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBGlyphID stdGlyph; /* ditto */
|
||||
HBUINT16 ctlPoints[32]; /* ditto */
|
||||
Lookup<HBUINT16>
|
||||
lookupTable; /* Lookup table that maps glyphs to their
|
||||
* baseline values. */
|
||||
public:
|
||||
DEFINE_SIZE_MIN (68);
|
||||
};
|
||||
|
||||
struct bsln
|
||||
{
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_bsln;
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (unlikely (!(c->check_struct (this) && defaultBaseline < 32)))
|
||||
return_trace (false);
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case 0: return_trace (parts.format0.sanitize (c));
|
||||
case 1: return_trace (parts.format1.sanitize (c));
|
||||
case 2: return_trace (parts.format2.sanitize (c));
|
||||
case 3: return_trace (parts.format3.sanitize (c));
|
||||
default:return_trace (true);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
FixedVersion<>version; /* Version number of the Baseline table. */
|
||||
HBUINT16 format; /* Format of the baseline table. Only one baseline
|
||||
* format may be selected for the font. */
|
||||
HBUINT16 defaultBaseline;/* Default baseline value for all glyphs.
|
||||
* This value can be from 0 through 31. */
|
||||
union {
|
||||
// Distance-Based Formats
|
||||
BaselineTableFormat0Part format0;
|
||||
BaselineTableFormat1Part format1;
|
||||
// Control Point-based Formats
|
||||
BaselineTableFormat2Part format2;
|
||||
BaselineTableFormat3Part format3;
|
||||
} parts;
|
||||
public:
|
||||
DEFINE_SIZE_MIN (8);
|
||||
};
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_BSLN_TABLE_HH */
|
||||
@@ -0,0 +1,890 @@
|
||||
/*
|
||||
* Copyright © 2017 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_AAT_LAYOUT_COMMON_HH
|
||||
#define HB_AAT_LAYOUT_COMMON_HH
|
||||
|
||||
#include "hb-aat-layout.hh"
|
||||
#include "hb-open-type.hh"
|
||||
|
||||
namespace OT {
|
||||
struct GDEF;
|
||||
};
|
||||
|
||||
namespace AAT {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
|
||||
/*
|
||||
* Lookup Table
|
||||
*/
|
||||
|
||||
template <typename T> struct Lookup;
|
||||
|
||||
template <typename T>
|
||||
struct LookupFormat0
|
||||
{
|
||||
friend struct Lookup<T>;
|
||||
|
||||
private:
|
||||
const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
|
||||
{
|
||||
if (unlikely (glyph_id >= num_glyphs)) return nullptr;
|
||||
return &arrayZ[glyph_id];
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (arrayZ.sanitize (c, c->get_num_glyphs ()));
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (arrayZ.sanitize (c, c->get_num_glyphs (), base));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 0 */
|
||||
UnsizedArrayOf<T>
|
||||
arrayZ; /* Array of lookup values, indexed by glyph index. */
|
||||
public:
|
||||
DEFINE_SIZE_UNBOUNDED (2);
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct LookupSegmentSingle
|
||||
{
|
||||
static constexpr unsigned TerminationWordCount = 2u;
|
||||
|
||||
int cmp (hb_codepoint_t g) const
|
||||
{ return g < first ? -1 : g <= last ? 0 : +1 ; }
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && value.sanitize (c));
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && value.sanitize (c, base));
|
||||
}
|
||||
|
||||
HBGlyphID last; /* Last GlyphID in this segment */
|
||||
HBGlyphID first; /* First GlyphID in this segment */
|
||||
T value; /* The lookup value (only one) */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4 + T::static_size);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct LookupFormat2
|
||||
{
|
||||
friend struct Lookup<T>;
|
||||
|
||||
private:
|
||||
const T* get_value (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
const LookupSegmentSingle<T> *v = segments.bsearch (glyph_id);
|
||||
return v ? &v->value : nullptr;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (segments.sanitize (c));
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (segments.sanitize (c, base));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 2 */
|
||||
VarSizedBinSearchArrayOf<LookupSegmentSingle<T>>
|
||||
segments; /* The actual segments. These must already be sorted,
|
||||
* according to the first word in each one (the last
|
||||
* glyph in each segment). */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (8, segments);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct LookupSegmentArray
|
||||
{
|
||||
static constexpr unsigned TerminationWordCount = 2u;
|
||||
|
||||
const T* get_value (hb_codepoint_t glyph_id, const void *base) const
|
||||
{
|
||||
return first <= glyph_id && glyph_id <= last ? &(base+valuesZ)[glyph_id - first] : nullptr;
|
||||
}
|
||||
|
||||
int cmp (hb_codepoint_t g) const
|
||||
{ return g < first ? -1 : g <= last ? 0 : +1; }
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) &&
|
||||
first <= last &&
|
||||
valuesZ.sanitize (c, base, last - first + 1));
|
||||
}
|
||||
template <typename ...Ts>
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base, Ts&&... ds) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) &&
|
||||
first <= last &&
|
||||
valuesZ.sanitize (c, base, last - first + 1, hb_forward<Ts> (ds)...));
|
||||
}
|
||||
|
||||
HBGlyphID last; /* Last GlyphID in this segment */
|
||||
HBGlyphID first; /* First GlyphID in this segment */
|
||||
NNOffset16To<UnsizedArrayOf<T>>
|
||||
valuesZ; /* A 16-bit offset from the start of
|
||||
* the table to the data. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (6);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct LookupFormat4
|
||||
{
|
||||
friend struct Lookup<T>;
|
||||
|
||||
private:
|
||||
const T* get_value (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
const LookupSegmentArray<T> *v = segments.bsearch (glyph_id);
|
||||
return v ? v->get_value (glyph_id, this) : nullptr;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (segments.sanitize (c, this));
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (segments.sanitize (c, this, base));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 4 */
|
||||
VarSizedBinSearchArrayOf<LookupSegmentArray<T>>
|
||||
segments; /* The actual segments. These must already be sorted,
|
||||
* according to the first word in each one (the last
|
||||
* glyph in each segment). */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (8, segments);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct LookupSingle
|
||||
{
|
||||
static constexpr unsigned TerminationWordCount = 1u;
|
||||
|
||||
int cmp (hb_codepoint_t g) const { return glyph.cmp (g); }
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && value.sanitize (c));
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && value.sanitize (c, base));
|
||||
}
|
||||
|
||||
HBGlyphID glyph; /* Last GlyphID */
|
||||
T value; /* The lookup value (only one) */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (2 + T::static_size);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct LookupFormat6
|
||||
{
|
||||
friend struct Lookup<T>;
|
||||
|
||||
private:
|
||||
const T* get_value (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
const LookupSingle<T> *v = entries.bsearch (glyph_id);
|
||||
return v ? &v->value : nullptr;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (entries.sanitize (c));
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (entries.sanitize (c, base));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 6 */
|
||||
VarSizedBinSearchArrayOf<LookupSingle<T>>
|
||||
entries; /* The actual entries, sorted by glyph index. */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (8, entries);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct LookupFormat8
|
||||
{
|
||||
friend struct Lookup<T>;
|
||||
|
||||
private:
|
||||
const T* get_value (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ?
|
||||
&valueArrayZ[glyph_id - firstGlyph] : nullptr;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount));
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount, base));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 8 */
|
||||
HBGlyphID firstGlyph; /* First glyph index included in the trimmed array. */
|
||||
HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last
|
||||
* glyph minus the value of firstGlyph plus 1). */
|
||||
UnsizedArrayOf<T>
|
||||
valueArrayZ; /* The lookup values (indexed by the glyph index
|
||||
* minus the value of firstGlyph). */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (6, valueArrayZ);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct LookupFormat10
|
||||
{
|
||||
friend struct Lookup<T>;
|
||||
|
||||
private:
|
||||
const typename T::type get_value_or_null (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
if (!(firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount))
|
||||
return Null (T);
|
||||
|
||||
const HBUINT8 *p = &valueArrayZ[(glyph_id - firstGlyph) * valueSize];
|
||||
|
||||
unsigned int v = 0;
|
||||
unsigned int count = valueSize;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
v = (v << 8) | *p++;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) &&
|
||||
valueSize <= 4 &&
|
||||
valueArrayZ.sanitize (c, glyphCount * valueSize));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 8 */
|
||||
HBUINT16 valueSize; /* Byte size of each value. */
|
||||
HBGlyphID firstGlyph; /* First glyph index included in the trimmed array. */
|
||||
HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last
|
||||
* glyph minus the value of firstGlyph plus 1). */
|
||||
UnsizedArrayOf<HBUINT8>
|
||||
valueArrayZ; /* The lookup values (indexed by the glyph index
|
||||
* minus the value of firstGlyph). */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (8, valueArrayZ);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Lookup
|
||||
{
|
||||
const T* get_value (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
|
||||
{
|
||||
switch (u.format) {
|
||||
case 0: return u.format0.get_value (glyph_id, num_glyphs);
|
||||
case 2: return u.format2.get_value (glyph_id);
|
||||
case 4: return u.format4.get_value (glyph_id);
|
||||
case 6: return u.format6.get_value (glyph_id);
|
||||
case 8: return u.format8.get_value (glyph_id);
|
||||
default:return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const typename T::type get_value_or_null (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
|
||||
{
|
||||
switch (u.format) {
|
||||
/* Format 10 cannot return a pointer. */
|
||||
case 10: return u.format10.get_value_or_null (glyph_id);
|
||||
default:
|
||||
const T *v = get_value (glyph_id, num_glyphs);
|
||||
return v ? *v : Null (T);
|
||||
}
|
||||
}
|
||||
|
||||
typename T::type get_class (hb_codepoint_t glyph_id,
|
||||
unsigned int num_glyphs,
|
||||
unsigned int outOfRange) const
|
||||
{
|
||||
const T *v = get_value (glyph_id, num_glyphs);
|
||||
return v ? *v : outOfRange;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (!u.format.sanitize (c)) return_trace (false);
|
||||
switch (u.format) {
|
||||
case 0: return_trace (u.format0.sanitize (c));
|
||||
case 2: return_trace (u.format2.sanitize (c));
|
||||
case 4: return_trace (u.format4.sanitize (c));
|
||||
case 6: return_trace (u.format6.sanitize (c));
|
||||
case 8: return_trace (u.format8.sanitize (c));
|
||||
case 10: return_trace (u.format10.sanitize (c));
|
||||
default:return_trace (true);
|
||||
}
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (!u.format.sanitize (c)) return_trace (false);
|
||||
switch (u.format) {
|
||||
case 0: return_trace (u.format0.sanitize (c, base));
|
||||
case 2: return_trace (u.format2.sanitize (c, base));
|
||||
case 4: return_trace (u.format4.sanitize (c, base));
|
||||
case 6: return_trace (u.format6.sanitize (c, base));
|
||||
case 8: return_trace (u.format8.sanitize (c, base));
|
||||
case 10: return_trace (false); /* We don't support format10 here currently. */
|
||||
default:return_trace (true);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
union {
|
||||
HBUINT16 format; /* Format identifier */
|
||||
LookupFormat0<T> format0;
|
||||
LookupFormat2<T> format2;
|
||||
LookupFormat4<T> format4;
|
||||
LookupFormat6<T> format6;
|
||||
LookupFormat8<T> format8;
|
||||
LookupFormat10<T> format10;
|
||||
} u;
|
||||
public:
|
||||
DEFINE_SIZE_UNION (2, format);
|
||||
};
|
||||
/* Lookup 0 has unbounded size (dependant on num_glyphs). So we need to defined
|
||||
* special NULL objects for Lookup<> objects, but since it's template our macros
|
||||
* don't work. So we have to hand-code them here. UGLY. */
|
||||
} /* Close namespace. */
|
||||
/* Ugly hand-coded null objects for template Lookup<> :(. */
|
||||
extern HB_INTERNAL const unsigned char _hb_Null_AAT_Lookup[2];
|
||||
template <typename T>
|
||||
struct Null<AAT::Lookup<T>> {
|
||||
static AAT::Lookup<T> const & get_null ()
|
||||
{ return *reinterpret_cast<const AAT::Lookup<T> *> (_hb_Null_AAT_Lookup); }
|
||||
};
|
||||
namespace AAT {
|
||||
|
||||
enum { DELETED_GLYPH = 0xFFFF };
|
||||
|
||||
/*
|
||||
* (Extended) State Table
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
struct Entry
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
/* Note, we don't recurse-sanitize data because we don't access it.
|
||||
* That said, in our DEFINE_SIZE_STATIC we access T::static_size,
|
||||
* which ensures that data has a simple sanitize(). To be determined
|
||||
* if I need to remove that as well.
|
||||
*
|
||||
* HOWEVER! Because we are a template, our DEFINE_SIZE_STATIC
|
||||
* assertion wouldn't be checked, hence the line below. */
|
||||
static_assert (T::static_size, "");
|
||||
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
public:
|
||||
HBUINT16 newState; /* Byte offset from beginning of state table
|
||||
* to the new state. Really?!?! Or just state
|
||||
* number? The latter in morx for sure. */
|
||||
HBUINT16 flags; /* Table specific. */
|
||||
T data; /* Optional offsets to per-glyph tables. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4 + T::static_size);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Entry<void>
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c, unsigned int count /*XXX Unused?*/) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
public:
|
||||
HBUINT16 newState; /* Byte offset from beginning of state table to the new state. */
|
||||
HBUINT16 flags; /* Table specific. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
|
||||
template <typename Types, typename Extra>
|
||||
struct StateTable
|
||||
{
|
||||
typedef typename Types::HBUINT HBUINT;
|
||||
typedef typename Types::HBUSHORT HBUSHORT;
|
||||
typedef typename Types::ClassTypeNarrow ClassType;
|
||||
|
||||
enum State
|
||||
{
|
||||
STATE_START_OF_TEXT = 0,
|
||||
STATE_START_OF_LINE = 1,
|
||||
};
|
||||
enum Class
|
||||
{
|
||||
CLASS_END_OF_TEXT = 0,
|
||||
CLASS_OUT_OF_BOUNDS = 1,
|
||||
CLASS_DELETED_GLYPH = 2,
|
||||
CLASS_END_OF_LINE = 3,
|
||||
};
|
||||
|
||||
int new_state (unsigned int newState) const
|
||||
{ return Types::extended ? newState : ((int) newState - (int) stateArrayTable) / (int) nClasses; }
|
||||
|
||||
unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
|
||||
{
|
||||
if (unlikely (glyph_id == DELETED_GLYPH)) return CLASS_DELETED_GLYPH;
|
||||
return (this+classTable).get_class (glyph_id, num_glyphs, 1);
|
||||
}
|
||||
|
||||
const Entry<Extra> *get_entries () const
|
||||
{ return (this+entryTable).arrayZ; }
|
||||
|
||||
const Entry<Extra> &get_entry (int state, unsigned int klass) const
|
||||
{
|
||||
if (unlikely (klass >= nClasses))
|
||||
klass = StateTable::CLASS_OUT_OF_BOUNDS;
|
||||
|
||||
const HBUSHORT *states = (this+stateArrayTable).arrayZ;
|
||||
const Entry<Extra> *entries = (this+entryTable).arrayZ;
|
||||
|
||||
unsigned int entry = states[state * nClasses + klass];
|
||||
DEBUG_MSG (APPLY, nullptr, "e%u", entry);
|
||||
|
||||
return entries[entry];
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c,
|
||||
unsigned int *num_entries_out = nullptr) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (unlikely (!(c->check_struct (this) &&
|
||||
nClasses >= 4 /* Ensure pre-defined classes fit. */ &&
|
||||
classTable.sanitize (c, this)))) return_trace (false);
|
||||
|
||||
const HBUSHORT *states = (this+stateArrayTable).arrayZ;
|
||||
const Entry<Extra> *entries = (this+entryTable).arrayZ;
|
||||
|
||||
unsigned int num_classes = nClasses;
|
||||
if (unlikely (hb_unsigned_mul_overflows (num_classes, states[0].static_size)))
|
||||
return_trace (false);
|
||||
unsigned int row_stride = num_classes * states[0].static_size;
|
||||
|
||||
/* Apple 'kern' table has this peculiarity:
|
||||
*
|
||||
* "Because the stateTableOffset in the state table header is (strictly
|
||||
* speaking) redundant, some 'kern' tables use it to record an initial
|
||||
* state where that should not be StartOfText. To determine if this is
|
||||
* done, calculate what the stateTableOffset should be. If it's different
|
||||
* from the actual stateTableOffset, use it as the initial state."
|
||||
*
|
||||
* We implement this by calling the initial state zero, but allow *negative*
|
||||
* states if the start state indeed was not the first state. Since the code
|
||||
* is shared, this will also apply to 'mort' table. The 'kerx' / 'morx'
|
||||
* tables are not affected since those address states by index, not offset.
|
||||
*/
|
||||
|
||||
int min_state = 0;
|
||||
int max_state = 0;
|
||||
unsigned int num_entries = 0;
|
||||
|
||||
int state_pos = 0;
|
||||
int state_neg = 0;
|
||||
unsigned int entry = 0;
|
||||
while (min_state < state_neg || state_pos <= max_state)
|
||||
{
|
||||
if (min_state < state_neg)
|
||||
{
|
||||
/* Negative states. */
|
||||
if (unlikely (hb_unsigned_mul_overflows (min_state, num_classes)))
|
||||
return_trace (false);
|
||||
if (unlikely (!c->check_range (&states[min_state * num_classes],
|
||||
-min_state,
|
||||
row_stride)))
|
||||
return_trace (false);
|
||||
if ((c->max_ops -= state_neg - min_state) <= 0)
|
||||
return_trace (false);
|
||||
{ /* Sweep new states. */
|
||||
const HBUSHORT *stop = &states[min_state * num_classes];
|
||||
if (unlikely (stop > states))
|
||||
return_trace (false);
|
||||
for (const HBUSHORT *p = states; stop < p; p--)
|
||||
num_entries = hb_max (num_entries, *(p - 1) + 1u);
|
||||
state_neg = min_state;
|
||||
}
|
||||
}
|
||||
|
||||
if (state_pos <= max_state)
|
||||
{
|
||||
/* Positive states. */
|
||||
if (unlikely (!c->check_range (states,
|
||||
max_state + 1,
|
||||
row_stride)))
|
||||
return_trace (false);
|
||||
if ((c->max_ops -= max_state - state_pos + 1) <= 0)
|
||||
return_trace (false);
|
||||
{ /* Sweep new states. */
|
||||
if (unlikely (hb_unsigned_mul_overflows ((max_state + 1), num_classes)))
|
||||
return_trace (false);
|
||||
const HBUSHORT *stop = &states[(max_state + 1) * num_classes];
|
||||
if (unlikely (stop < states))
|
||||
return_trace (false);
|
||||
for (const HBUSHORT *p = &states[state_pos * num_classes]; p < stop; p++)
|
||||
num_entries = hb_max (num_entries, *p + 1u);
|
||||
state_pos = max_state + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely (!c->check_array (entries, num_entries)))
|
||||
return_trace (false);
|
||||
if ((c->max_ops -= num_entries - entry) <= 0)
|
||||
return_trace (false);
|
||||
{ /* Sweep new entries. */
|
||||
const Entry<Extra> *stop = &entries[num_entries];
|
||||
for (const Entry<Extra> *p = &entries[entry]; p < stop; p++)
|
||||
{
|
||||
int newState = new_state (p->newState);
|
||||
min_state = hb_min (min_state, newState);
|
||||
max_state = hb_max (max_state, newState);
|
||||
}
|
||||
entry = num_entries;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_entries_out)
|
||||
*num_entries_out = num_entries;
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT nClasses; /* Number of classes, which is the number of indices
|
||||
* in a single line in the state array. */
|
||||
NNOffsetTo<ClassType, HBUINT>
|
||||
classTable; /* Offset to the class table. */
|
||||
NNOffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT>
|
||||
stateArrayTable;/* Offset to the state array. */
|
||||
NNOffsetTo<UnsizedArrayOf<Entry<Extra>>, HBUINT>
|
||||
entryTable; /* Offset to the entry array. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4 * sizeof (HBUINT));
|
||||
};
|
||||
|
||||
template <typename HBUCHAR>
|
||||
struct ClassTable
|
||||
{
|
||||
unsigned int get_class (hb_codepoint_t glyph_id, unsigned int outOfRange) const
|
||||
{
|
||||
unsigned int i = glyph_id - firstGlyph;
|
||||
return i >= classArray.len ? outOfRange : classArray.arrayZ[i];
|
||||
}
|
||||
unsigned int get_class (hb_codepoint_t glyph_id,
|
||||
unsigned int num_glyphs HB_UNUSED,
|
||||
unsigned int outOfRange) const
|
||||
{
|
||||
return get_class (glyph_id, outOfRange);
|
||||
}
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && classArray.sanitize (c));
|
||||
}
|
||||
protected:
|
||||
HBGlyphID firstGlyph; /* First glyph index included in the trimmed array. */
|
||||
Array16Of<HBUCHAR> classArray; /* The class codes (indexed by glyph index minus
|
||||
* firstGlyph). */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (4, classArray);
|
||||
};
|
||||
|
||||
struct ObsoleteTypes
|
||||
{
|
||||
static constexpr bool extended = false;
|
||||
typedef HBUINT16 HBUINT;
|
||||
typedef HBUINT8 HBUSHORT;
|
||||
typedef ClassTable<HBUINT8> ClassTypeNarrow;
|
||||
typedef ClassTable<HBUINT16> ClassTypeWide;
|
||||
|
||||
template <typename T>
|
||||
static unsigned int offsetToIndex (unsigned int offset,
|
||||
const void *base,
|
||||
const T *array)
|
||||
{
|
||||
/* https://github.com/harfbuzz/harfbuzz/issues/2816 */
|
||||
return (offset - unsigned ((const char *) array - (const char *) base)) / T::static_size;
|
||||
}
|
||||
template <typename T>
|
||||
static unsigned int byteOffsetToIndex (unsigned int offset,
|
||||
const void *base,
|
||||
const T *array)
|
||||
{
|
||||
return offsetToIndex (offset, base, array);
|
||||
}
|
||||
template <typename T>
|
||||
static unsigned int wordOffsetToIndex (unsigned int offset,
|
||||
const void *base,
|
||||
const T *array)
|
||||
{
|
||||
return offsetToIndex (2 * offset, base, array);
|
||||
}
|
||||
};
|
||||
struct ExtendedTypes
|
||||
{
|
||||
static constexpr bool extended = true;
|
||||
typedef HBUINT32 HBUINT;
|
||||
typedef HBUINT16 HBUSHORT;
|
||||
typedef Lookup<HBUINT16> ClassTypeNarrow;
|
||||
typedef Lookup<HBUINT16> ClassTypeWide;
|
||||
|
||||
template <typename T>
|
||||
static unsigned int offsetToIndex (unsigned int offset,
|
||||
const void *base HB_UNUSED,
|
||||
const T *array HB_UNUSED)
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
template <typename T>
|
||||
static unsigned int byteOffsetToIndex (unsigned int offset,
|
||||
const void *base HB_UNUSED,
|
||||
const T *array HB_UNUSED)
|
||||
{
|
||||
return offset / 2;
|
||||
}
|
||||
template <typename T>
|
||||
static unsigned int wordOffsetToIndex (unsigned int offset,
|
||||
const void *base HB_UNUSED,
|
||||
const T *array HB_UNUSED)
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Types, typename EntryData>
|
||||
struct StateTableDriver
|
||||
{
|
||||
using StateTableT = StateTable<Types, EntryData>;
|
||||
using EntryT = Entry<EntryData>;
|
||||
|
||||
StateTableDriver (const StateTableT &machine_,
|
||||
hb_buffer_t *buffer_,
|
||||
hb_face_t *face_) :
|
||||
machine (machine_),
|
||||
buffer (buffer_),
|
||||
num_glyphs (face_->get_num_glyphs ()) {}
|
||||
|
||||
template <typename context_t>
|
||||
void drive (context_t *c)
|
||||
{
|
||||
if (!c->in_place)
|
||||
buffer->clear_output ();
|
||||
|
||||
int state = StateTableT::STATE_START_OF_TEXT;
|
||||
for (buffer->idx = 0; buffer->successful;)
|
||||
{
|
||||
unsigned int klass = buffer->idx < buffer->len ?
|
||||
machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) :
|
||||
(unsigned) StateTableT::CLASS_END_OF_TEXT;
|
||||
DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
|
||||
const EntryT &entry = machine.get_entry (state, klass);
|
||||
const int next_state = machine.new_state (entry.newState);
|
||||
|
||||
/* Conditions under which it's guaranteed safe-to-break before current glyph:
|
||||
*
|
||||
* 1. There was no action in this transition; and
|
||||
*
|
||||
* 2. If we break before current glyph, the results will be the same. That
|
||||
* is guaranteed if:
|
||||
*
|
||||
* 2a. We were already in start-of-text state; or
|
||||
*
|
||||
* 2b. We are epsilon-transitioning to start-of-text state; or
|
||||
*
|
||||
* 2c. Starting from start-of-text state seeing current glyph:
|
||||
*
|
||||
* 2c'. There won't be any actions; and
|
||||
*
|
||||
* 2c". We would end up in the same state that we were going to end up
|
||||
* in now, including whether epsilon-transitioning.
|
||||
*
|
||||
* and
|
||||
*
|
||||
* 3. If we break before current glyph, there won't be any end-of-text action
|
||||
* after previous glyph.
|
||||
*
|
||||
* This triples the transitions we need to look up, but is worth returning
|
||||
* granular unsafe-to-break results. See eg.:
|
||||
*
|
||||
* https://github.com/harfbuzz/harfbuzz/issues/2860
|
||||
*/
|
||||
const EntryT *wouldbe_entry;
|
||||
bool safe_to_break =
|
||||
/* 1. */
|
||||
!c->is_actionable (this, entry)
|
||||
&&
|
||||
/* 2. */
|
||||
(
|
||||
/* 2a. */
|
||||
state == StateTableT::STATE_START_OF_TEXT
|
||||
||
|
||||
/* 2b. */
|
||||
(
|
||||
(entry.flags & context_t::DontAdvance) &&
|
||||
next_state == StateTableT::STATE_START_OF_TEXT
|
||||
)
|
||||
||
|
||||
/* 2c. */
|
||||
(
|
||||
wouldbe_entry = &machine.get_entry (StateTableT::STATE_START_OF_TEXT, klass)
|
||||
,
|
||||
/* 2c'. */
|
||||
!c->is_actionable (this, *wouldbe_entry)
|
||||
&&
|
||||
/* 2c". */
|
||||
(
|
||||
next_state == machine.new_state (wouldbe_entry->newState)
|
||||
&&
|
||||
(entry.flags & context_t::DontAdvance) == (wouldbe_entry->flags & context_t::DontAdvance)
|
||||
)
|
||||
)
|
||||
)
|
||||
&&
|
||||
/* 3. */
|
||||
!c->is_actionable (this, machine.get_entry (state, StateTableT::CLASS_END_OF_TEXT))
|
||||
;
|
||||
|
||||
if (!safe_to_break && buffer->backtrack_len () && buffer->idx < buffer->len)
|
||||
buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
|
||||
|
||||
c->transition (this, entry);
|
||||
|
||||
state = next_state;
|
||||
DEBUG_MSG (APPLY, nullptr, "s%d", state);
|
||||
|
||||
if (buffer->idx == buffer->len || unlikely (!buffer->successful))
|
||||
break;
|
||||
|
||||
if (!(entry.flags & context_t::DontAdvance) || buffer->max_ops-- <= 0)
|
||||
(void) buffer->next_glyph ();
|
||||
}
|
||||
|
||||
if (!c->in_place)
|
||||
buffer->swap_buffers ();
|
||||
}
|
||||
|
||||
public:
|
||||
const StateTableT &machine;
|
||||
hb_buffer_t *buffer;
|
||||
unsigned int num_glyphs;
|
||||
};
|
||||
|
||||
|
||||
struct ankr;
|
||||
|
||||
struct hb_aat_apply_context_t :
|
||||
hb_dispatch_context_t<hb_aat_apply_context_t, bool, HB_DEBUG_APPLY>
|
||||
{
|
||||
const char *get_name () { return "APPLY"; }
|
||||
template <typename T>
|
||||
return_t dispatch (const T &obj) { return obj.apply (this); }
|
||||
static return_t default_return_value () { return false; }
|
||||
bool stop_sublookup_iteration (return_t r) const { return r; }
|
||||
|
||||
const hb_ot_shape_plan_t *plan;
|
||||
hb_font_t *font;
|
||||
hb_face_t *face;
|
||||
hb_buffer_t *buffer;
|
||||
hb_sanitize_context_t sanitizer;
|
||||
const ankr *ankr_table;
|
||||
const OT::GDEF *gdef_table;
|
||||
|
||||
/* Unused. For debug tracing only. */
|
||||
unsigned int lookup_index;
|
||||
|
||||
HB_INTERNAL hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_,
|
||||
hb_font_t *font_,
|
||||
hb_buffer_t *buffer_,
|
||||
hb_blob_t *blob = const_cast<hb_blob_t *> (&Null (hb_blob_t)));
|
||||
|
||||
HB_INTERNAL ~hb_aat_apply_context_t ();
|
||||
|
||||
HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_);
|
||||
|
||||
void set_lookup_index (unsigned int i) { lookup_index = i; }
|
||||
};
|
||||
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_COMMON_HH */
|
||||
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_AAT_LAYOUT_FEAT_TABLE_HH
|
||||
#define HB_AAT_LAYOUT_FEAT_TABLE_HH
|
||||
|
||||
#include "hb-aat-layout-common.hh"
|
||||
|
||||
/*
|
||||
* feat -- Feature Name
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html
|
||||
*/
|
||||
#define HB_AAT_TAG_feat HB_TAG('f','e','a','t')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
|
||||
struct SettingName
|
||||
{
|
||||
friend struct FeatureName;
|
||||
|
||||
int cmp (hb_aat_layout_feature_selector_t key) const
|
||||
{ return (int) key - (int) setting; }
|
||||
|
||||
hb_aat_layout_feature_selector_t get_selector () const
|
||||
{ return (hb_aat_layout_feature_selector_t) (unsigned) setting; }
|
||||
|
||||
hb_aat_layout_feature_selector_info_t get_info (hb_aat_layout_feature_selector_t default_selector) const
|
||||
{
|
||||
return {
|
||||
nameIndex,
|
||||
(hb_aat_layout_feature_selector_t) (unsigned int) setting,
|
||||
default_selector == HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID
|
||||
? (hb_aat_layout_feature_selector_t) (setting + 1)
|
||||
: default_selector,
|
||||
0
|
||||
};
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 setting; /* The setting. */
|
||||
NameID nameIndex; /* The name table index for the setting's name. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
DECLARE_NULL_NAMESPACE_BYTES (AAT, SettingName);
|
||||
|
||||
struct feat;
|
||||
|
||||
struct FeatureName
|
||||
{
|
||||
int cmp (hb_aat_layout_feature_type_t key) const
|
||||
{ return (int) key - (int) feature; }
|
||||
|
||||
enum {
|
||||
Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */
|
||||
NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in
|
||||
* the setting name array for this feature should
|
||||
* be taken as the default for the feature
|
||||
* (if one is required). If set, then bits 0-15 of this
|
||||
* featureFlags field contain the index of the setting
|
||||
* which is to be taken as the default. */
|
||||
IndexMask = 0x00FF /* If bits 30 and 31 are set, then these sixteen bits
|
||||
* indicate the index of the setting in the setting name
|
||||
* array for this feature which should be taken
|
||||
* as the default. */
|
||||
};
|
||||
|
||||
unsigned int get_selector_infos (unsigned int start_offset,
|
||||
unsigned int *selectors_count, /* IN/OUT. May be NULL. */
|
||||
hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
|
||||
unsigned int *pdefault_index, /* OUT. May be NULL. */
|
||||
const void *base) const
|
||||
{
|
||||
hb_array_t< const SettingName> settings_table = (base+settingTableZ).as_array (nSettings);
|
||||
|
||||
static_assert (Index::NOT_FOUND_INDEX == HB_AAT_LAYOUT_NO_SELECTOR_INDEX, "");
|
||||
|
||||
hb_aat_layout_feature_selector_t default_selector = HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID;
|
||||
unsigned int default_index = Index::NOT_FOUND_INDEX;
|
||||
if (featureFlags & Exclusive)
|
||||
{
|
||||
default_index = (featureFlags & NotDefault) ? featureFlags & IndexMask : 0;
|
||||
default_selector = settings_table[default_index].get_selector ();
|
||||
}
|
||||
if (pdefault_index)
|
||||
*pdefault_index = default_index;
|
||||
|
||||
if (selectors_count)
|
||||
{
|
||||
+ settings_table.sub_array (start_offset, selectors_count)
|
||||
| hb_map ([=] (const SettingName& setting) { return setting.get_info (default_selector); })
|
||||
| hb_sink (hb_array (selectors, *selectors_count))
|
||||
;
|
||||
}
|
||||
return settings_table.length;
|
||||
}
|
||||
|
||||
hb_aat_layout_feature_type_t get_feature_type () const
|
||||
{ return (hb_aat_layout_feature_type_t) (unsigned int) feature; }
|
||||
|
||||
hb_ot_name_id_t get_feature_name_id () const { return nameIndex; }
|
||||
|
||||
bool is_exclusive () const { return featureFlags & Exclusive; }
|
||||
|
||||
/* A FeatureName with no settings is meaningless */
|
||||
bool has_data () const { return nSettings; }
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
(base+settingTableZ).sanitize (c, nSettings)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 feature; /* Feature type. */
|
||||
HBUINT16 nSettings; /* The number of records in the setting name array. */
|
||||
NNOffset32To<UnsizedArrayOf<SettingName>>
|
||||
settingTableZ; /* Offset in bytes from the beginning of this table to
|
||||
* this feature's setting name array. The actual type of
|
||||
* record this offset refers to will depend on the
|
||||
* exclusivity value, as described below. */
|
||||
HBUINT16 featureFlags; /* Single-bit flags associated with the feature type. */
|
||||
HBINT16 nameIndex; /* The name table index for the feature's name.
|
||||
* This index has values greater than 255 and
|
||||
* less than 32768. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (12);
|
||||
};
|
||||
|
||||
struct feat
|
||||
{
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_feat;
|
||||
|
||||
bool has_data () const { return version.to_int (); }
|
||||
|
||||
unsigned int get_feature_types (unsigned int start_offset,
|
||||
unsigned int *count,
|
||||
hb_aat_layout_feature_type_t *features) const
|
||||
{
|
||||
if (count)
|
||||
{
|
||||
+ namesZ.as_array (featureNameCount).sub_array (start_offset, count)
|
||||
| hb_map (&FeatureName::get_feature_type)
|
||||
| hb_sink (hb_array (features, *count))
|
||||
;
|
||||
}
|
||||
return featureNameCount;
|
||||
}
|
||||
|
||||
bool exposes_feature (hb_aat_layout_feature_type_t feature_type) const
|
||||
{ return get_feature (feature_type).has_data (); }
|
||||
|
||||
const FeatureName& get_feature (hb_aat_layout_feature_type_t feature_type) const
|
||||
{ return namesZ.bsearch (featureNameCount, feature_type); }
|
||||
|
||||
hb_ot_name_id_t get_feature_name_id (hb_aat_layout_feature_type_t feature) const
|
||||
{ return get_feature (feature).get_feature_name_id (); }
|
||||
|
||||
unsigned int get_selector_infos (hb_aat_layout_feature_type_t feature_type,
|
||||
unsigned int start_offset,
|
||||
unsigned int *selectors_count, /* IN/OUT. May be NULL. */
|
||||
hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
|
||||
unsigned int *default_index /* OUT. May be NULL. */) const
|
||||
{
|
||||
return get_feature (feature_type).get_selector_infos (start_offset, selectors_count, selectors,
|
||||
default_index, this);
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
version.major == 1 &&
|
||||
namesZ.sanitize (c, featureNameCount, this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
FixedVersion<>version; /* Version number of the feature name table
|
||||
* (0x00010000 for the current version). */
|
||||
HBUINT16 featureNameCount;
|
||||
/* The number of entries in the feature name array. */
|
||||
HBUINT16 reserved1; /* Reserved (set to zero). */
|
||||
HBUINT32 reserved2; /* Reserved (set to zero). */
|
||||
SortedUnsizedArrayOf<FeatureName>
|
||||
namesZ; /* The feature name array. */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (12, namesZ);
|
||||
};
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_FEAT_TABLE_HH */
|
||||
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_AAT_LAYOUT_JUST_TABLE_HH
|
||||
#define HB_AAT_LAYOUT_JUST_TABLE_HH
|
||||
|
||||
#include "hb-aat-layout-common.hh"
|
||||
#include "hb-ot-layout.hh"
|
||||
#include "hb-open-type.hh"
|
||||
|
||||
#include "hb-aat-layout-morx-table.hh"
|
||||
|
||||
/*
|
||||
* just -- Justification
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6just.html
|
||||
*/
|
||||
#define HB_AAT_TAG_just HB_TAG('j','u','s','t')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
|
||||
struct ActionSubrecordHeader
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
HBUINT16 actionClass; /* The JustClass value associated with this
|
||||
* ActionSubrecord. */
|
||||
HBUINT16 actionType; /* The type of postcompensation action. */
|
||||
HBUINT16 actionLength; /* Length of this ActionSubrecord record, which
|
||||
* must be a multiple of 4. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (6);
|
||||
};
|
||||
|
||||
struct DecompositionAction
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
ActionSubrecordHeader
|
||||
header;
|
||||
HBFixed lowerLimit; /* If the distance factor is less than this value,
|
||||
* then the ligature is decomposed. */
|
||||
HBFixed upperLimit; /* If the distance factor is greater than this value,
|
||||
* then the ligature is decomposed. */
|
||||
HBUINT16 order; /* Numerical order in which this ligature will
|
||||
* be decomposed; you may want infrequent ligatures
|
||||
* to decompose before more frequent ones. The ligatures
|
||||
* on the line of text will decompose in increasing
|
||||
* value of this field. */
|
||||
Array16Of<HBUINT16>
|
||||
decomposedglyphs;
|
||||
/* Number of 16-bit glyph indexes that follow;
|
||||
* the ligature will be decomposed into these glyphs.
|
||||
*
|
||||
* Array of decomposed glyphs. */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (18, decomposedglyphs);
|
||||
};
|
||||
|
||||
struct UnconditionalAddGlyphAction
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
protected:
|
||||
ActionSubrecordHeader
|
||||
header;
|
||||
HBGlyphID addGlyph; /* Glyph that should be added if the distance factor
|
||||
* is growing. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (8);
|
||||
};
|
||||
|
||||
struct ConditionalAddGlyphAction
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
ActionSubrecordHeader
|
||||
header;
|
||||
HBFixed substThreshold; /* Distance growth factor (in ems) at which
|
||||
* this glyph is replaced and the growth factor
|
||||
* recalculated. */
|
||||
HBGlyphID addGlyph; /* Glyph to be added as kashida. If this value is
|
||||
* 0xFFFF, no extra glyph will be added. Note that
|
||||
* generally when a glyph is added, justification
|
||||
* will need to be redone. */
|
||||
HBGlyphID substGlyph; /* Glyph to be substituted for this glyph if the
|
||||
* growth factor equals or exceeds the value of
|
||||
* substThreshold. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (14);
|
||||
};
|
||||
|
||||
struct DuctileGlyphAction
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
ActionSubrecordHeader
|
||||
header;
|
||||
HBUINT32 variationAxis; /* The 4-byte tag identifying the ductile axis.
|
||||
* This would normally be 0x64756374 ('duct'),
|
||||
* but you may use any axis the font contains. */
|
||||
HBFixed minimumLimit; /* The lowest value for the ductility axis tha
|
||||
* still yields an acceptable appearance. Normally
|
||||
* this will be 1.0. */
|
||||
HBFixed noStretchValue; /* This is the default value that corresponds to
|
||||
* no change in appearance. Normally, this will
|
||||
* be 1.0. */
|
||||
HBFixed maximumLimit; /* The highest value for the ductility axis that
|
||||
* still yields an acceptable appearance. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (22);
|
||||
};
|
||||
|
||||
struct RepeatedAddGlyphAction
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
ActionSubrecordHeader
|
||||
header;
|
||||
HBUINT16 flags; /* Currently unused; set to 0. */
|
||||
HBGlyphID glyph; /* Glyph that should be added if the distance factor
|
||||
* is growing. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (10);
|
||||
};
|
||||
|
||||
struct ActionSubrecord
|
||||
{
|
||||
unsigned int get_length () const { return u.header.actionLength; }
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (unlikely (!c->check_struct (this)))
|
||||
return_trace (false);
|
||||
|
||||
switch (u.header.actionType)
|
||||
{
|
||||
case 0: return_trace (u.decompositionAction.sanitize (c));
|
||||
case 1: return_trace (u.unconditionalAddGlyphAction.sanitize (c));
|
||||
case 2: return_trace (u.conditionalAddGlyphAction.sanitize (c));
|
||||
// case 3: return_trace (u.stretchGlyphAction.sanitize (c));
|
||||
case 4: return_trace (u.decompositionAction.sanitize (c));
|
||||
case 5: return_trace (u.decompositionAction.sanitize (c));
|
||||
default: return_trace (true);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
union {
|
||||
ActionSubrecordHeader header;
|
||||
DecompositionAction decompositionAction;
|
||||
UnconditionalAddGlyphAction unconditionalAddGlyphAction;
|
||||
ConditionalAddGlyphAction conditionalAddGlyphAction;
|
||||
/* StretchGlyphAction stretchGlyphAction; -- Not supported by CoreText */
|
||||
DuctileGlyphAction ductileGlyphAction;
|
||||
RepeatedAddGlyphAction repeatedAddGlyphAction;
|
||||
} u; /* Data. The format of this data depends on
|
||||
* the value of the actionType field. */
|
||||
public:
|
||||
DEFINE_SIZE_UNION (6, header);
|
||||
};
|
||||
|
||||
struct PostcompensationActionChain
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (unlikely (!c->check_struct (this)))
|
||||
return_trace (false);
|
||||
|
||||
unsigned int offset = min_size;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
const ActionSubrecord& subrecord = StructAtOffset<ActionSubrecord> (this, offset);
|
||||
if (unlikely (!subrecord.sanitize (c))) return_trace (false);
|
||||
offset += subrecord.get_length ();
|
||||
}
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT32 count;
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
|
||||
struct JustWidthDeltaEntry
|
||||
{
|
||||
enum Flags
|
||||
{
|
||||
Reserved1 =0xE000,/* Reserved. You should set these bits to zero. */
|
||||
UnlimiteGap =0x1000,/* The glyph can take unlimited gap. When this
|
||||
* glyph participates in the justification process,
|
||||
* it and any other glyphs on the line having this
|
||||
* bit set absorb all the remaining gap. */
|
||||
Reserved2 =0x0FF0,/* Reserved. You should set these bits to zero. */
|
||||
Priority =0x000F /* The justification priority of the glyph. */
|
||||
};
|
||||
|
||||
enum Priority
|
||||
{
|
||||
Kashida = 0, /* Kashida priority. This is the highest priority
|
||||
* during justification. */
|
||||
Whitespace = 1, /* Whitespace priority. Any whitespace glyphs (as
|
||||
* identified in the glyph properties table) will
|
||||
* get this priority. */
|
||||
InterCharacter = 2, /* Inter-character priority. Give this to any
|
||||
* remaining glyphs. */
|
||||
NullPriority = 3 /* Null priority. You should set this priority for
|
||||
* glyphs that only participate in justification
|
||||
* after the above priorities. Normally all glyphs
|
||||
* have one of the previous three values. If you
|
||||
* don't want a glyph to participate in justification,
|
||||
* and you don't want to set its factors to zero,
|
||||
* you may instead assign it to the null priority. */
|
||||
};
|
||||
|
||||
protected:
|
||||
HBFixed beforeGrowLimit;/* The ratio by which the advance width of the
|
||||
* glyph is permitted to grow on the left or top side. */
|
||||
HBFixed beforeShrinkLimit;
|
||||
/* The ratio by which the advance width of the
|
||||
* glyph is permitted to shrink on the left or top side. */
|
||||
HBFixed afterGrowLimit; /* The ratio by which the advance width of the glyph
|
||||
* is permitted to shrink on the left or top side. */
|
||||
HBFixed afterShrinkLimit;
|
||||
/* The ratio by which the advance width of the glyph
|
||||
* is at most permitted to shrink on the right or
|
||||
* bottom side. */
|
||||
HBUINT16 growFlags; /* Flags controlling the grow case. */
|
||||
HBUINT16 shrinkFlags; /* Flags controlling the shrink case. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (20);
|
||||
};
|
||||
|
||||
struct WidthDeltaPair
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT32 justClass; /* The justification category associated
|
||||
* with the wdRecord field. Only 7 bits of
|
||||
* this field are used. (The other bits are
|
||||
* used as padding to guarantee longword
|
||||
* alignment of the following record). */
|
||||
JustWidthDeltaEntry
|
||||
wdRecord; /* The actual width delta record. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (24);
|
||||
};
|
||||
|
||||
typedef OT::Array32Of<WidthDeltaPair> WidthDeltaCluster;
|
||||
|
||||
struct JustificationCategory
|
||||
{
|
||||
typedef void EntryData;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
SetMark =0x8000,/* If set, make the current glyph the marked
|
||||
* glyph. */
|
||||
DontAdvance =0x4000,/* If set, don't advance to the next glyph before
|
||||
* going to the new state. */
|
||||
MarkCategory =0x3F80,/* The justification category for the marked
|
||||
* glyph if nonzero. */
|
||||
CurrentCategory =0x007F /* The justification category for the current
|
||||
* glyph if nonzero. */
|
||||
};
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
morphHeader.sanitize (c) &&
|
||||
stHeader.sanitize (c)));
|
||||
}
|
||||
|
||||
protected:
|
||||
ChainSubtable<ObsoleteTypes>
|
||||
morphHeader; /* Metamorphosis-style subtable header. */
|
||||
StateTable<ObsoleteTypes, EntryData>
|
||||
stHeader; /* The justification insertion state table header */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (30);
|
||||
};
|
||||
|
||||
struct JustificationHeader
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
justClassTable.sanitize (c, base, base) &&
|
||||
wdcTable.sanitize (c, base) &&
|
||||
pcTable.sanitize (c, base) &&
|
||||
lookupTable.sanitize (c, base)));
|
||||
}
|
||||
|
||||
protected:
|
||||
Offset16To<JustificationCategory>
|
||||
justClassTable; /* Offset to the justification category state table. */
|
||||
Offset16To<WidthDeltaCluster>
|
||||
wdcTable; /* Offset from start of justification table to start
|
||||
* of the subtable containing the width delta factors
|
||||
* for the glyphs in your font.
|
||||
*
|
||||
* The width delta clusters table. */
|
||||
Offset16To<PostcompensationActionChain>
|
||||
pcTable; /* Offset from start of justification table to start
|
||||
* of postcompensation subtable (set to zero if none).
|
||||
*
|
||||
* The postcompensation subtable, if present in the font. */
|
||||
Lookup<Offset16To<WidthDeltaCluster>>
|
||||
lookupTable; /* Lookup table associating glyphs with width delta
|
||||
* clusters. See the description of Width Delta Clusters
|
||||
* table for details on how to interpret the lookup values. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_MIN (8);
|
||||
};
|
||||
|
||||
struct just
|
||||
{
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_just;
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
version.major == 1 &&
|
||||
horizData.sanitize (c, this, this) &&
|
||||
vertData.sanitize (c, this, this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
FixedVersion<>version; /* Version of the justification table
|
||||
* (0x00010000u for version 1.0). */
|
||||
HBUINT16 format; /* Format of the justification table (set to 0). */
|
||||
Offset16To<JustificationHeader>
|
||||
horizData; /* Byte offset from the start of the justification table
|
||||
* to the header for tables that contain justification
|
||||
* information for horizontal text.
|
||||
* If you are not including this information,
|
||||
* store 0. */
|
||||
Offset16To<JustificationHeader>
|
||||
vertData; /* ditto, vertical */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (10);
|
||||
};
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_JUST_TABLE_HH */
|
||||
@@ -0,0 +1,999 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
* Copyright © 2018 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_AAT_LAYOUT_KERX_TABLE_HH
|
||||
#define HB_AAT_LAYOUT_KERX_TABLE_HH
|
||||
|
||||
#include "hb-kern.hh"
|
||||
#include "hb-aat-layout-ankr-table.hh"
|
||||
|
||||
/*
|
||||
* kerx -- Extended Kerning
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kerx.html
|
||||
*/
|
||||
#define HB_AAT_TAG_kerx HB_TAG('k','e','r','x')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
|
||||
static inline int
|
||||
kerxTupleKern (int value,
|
||||
unsigned int tupleCount,
|
||||
const void *base,
|
||||
hb_aat_apply_context_t *c)
|
||||
{
|
||||
if (likely (!tupleCount || !c)) return value;
|
||||
|
||||
unsigned int offset = value;
|
||||
const FWORD *pv = &StructAtOffset<FWORD> (base, offset);
|
||||
if (unlikely (!c->sanitizer.check_array (pv, tupleCount))) return 0;
|
||||
return *pv;
|
||||
}
|
||||
|
||||
|
||||
struct hb_glyph_pair_t
|
||||
{
|
||||
hb_codepoint_t left;
|
||||
hb_codepoint_t right;
|
||||
};
|
||||
|
||||
struct KernPair
|
||||
{
|
||||
int get_kerning () const { return value; }
|
||||
|
||||
int cmp (const hb_glyph_pair_t &o) const
|
||||
{
|
||||
int ret = left.cmp (o.left);
|
||||
if (ret) return ret;
|
||||
return right.cmp (o.right);
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBGlyphID left;
|
||||
HBGlyphID right;
|
||||
FWORD value;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (6);
|
||||
};
|
||||
|
||||
template <typename KernSubTableHeader>
|
||||
struct KerxSubTableFormat0
|
||||
{
|
||||
int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
|
||||
hb_aat_apply_context_t *c = nullptr) const
|
||||
{
|
||||
hb_glyph_pair_t pair = {left, right};
|
||||
int v = pairs.bsearch (pair).get_kerning ();
|
||||
return kerxTupleKern (v, header.tuple_count (), this, c);
|
||||
}
|
||||
|
||||
bool apply (hb_aat_apply_context_t *c) const
|
||||
{
|
||||
TRACE_APPLY (this);
|
||||
|
||||
if (!c->plan->requested_kerning)
|
||||
return false;
|
||||
|
||||
if (header.coverage & header.Backwards)
|
||||
return false;
|
||||
|
||||
accelerator_t accel (*this, c);
|
||||
hb_kern_machine_t<accelerator_t> machine (accel, header.coverage & header.CrossStream);
|
||||
machine.kern (c->font, c->buffer, c->plan->kern_mask);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
struct accelerator_t
|
||||
{
|
||||
const KerxSubTableFormat0 &table;
|
||||
hb_aat_apply_context_t *c;
|
||||
|
||||
accelerator_t (const KerxSubTableFormat0 &table_,
|
||||
hb_aat_apply_context_t *c_) :
|
||||
table (table_), c (c_) {}
|
||||
|
||||
int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
|
||||
{ return table.get_kerning (left, right, c); }
|
||||
};
|
||||
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (pairs.sanitize (c)));
|
||||
}
|
||||
|
||||
protected:
|
||||
KernSubTableHeader header;
|
||||
BinSearchArrayOf<KernPair, typename KernSubTableHeader::Types::HBUINT>
|
||||
pairs; /* Sorted kern records. */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 16, pairs);
|
||||
};
|
||||
|
||||
|
||||
template <bool extended>
|
||||
struct Format1Entry;
|
||||
|
||||
template <>
|
||||
struct Format1Entry<true>
|
||||
{
|
||||
enum Flags
|
||||
{
|
||||
Push = 0x8000, /* If set, push this glyph on the kerning stack. */
|
||||
DontAdvance = 0x4000, /* If set, don't advance to the next glyph
|
||||
* before going to the new state. */
|
||||
Reset = 0x2000, /* If set, reset the kerning data (clear the stack) */
|
||||
Reserved = 0x1FFF, /* Not used; set to 0. */
|
||||
};
|
||||
|
||||
struct EntryData
|
||||
{
|
||||
HBUINT16 kernActionIndex;/* Index into the kerning value array. If
|
||||
* this index is 0xFFFF, then no kerning
|
||||
* is to be performed. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (2);
|
||||
};
|
||||
|
||||
static bool performAction (const Entry<EntryData> &entry)
|
||||
{ return entry.data.kernActionIndex != 0xFFFF; }
|
||||
|
||||
static unsigned int kernActionIndex (const Entry<EntryData> &entry)
|
||||
{ return entry.data.kernActionIndex; }
|
||||
};
|
||||
template <>
|
||||
struct Format1Entry<false>
|
||||
{
|
||||
enum Flags
|
||||
{
|
||||
Push = 0x8000, /* If set, push this glyph on the kerning stack. */
|
||||
DontAdvance = 0x4000, /* If set, don't advance to the next glyph
|
||||
* before going to the new state. */
|
||||
Offset = 0x3FFF, /* Byte offset from beginning of subtable to the
|
||||
* value table for the glyphs on the kerning stack. */
|
||||
|
||||
Reset = 0x0000, /* Not supported? */
|
||||
};
|
||||
|
||||
typedef void EntryData;
|
||||
|
||||
static bool performAction (const Entry<EntryData> &entry)
|
||||
{ return entry.flags & Offset; }
|
||||
|
||||
static unsigned int kernActionIndex (const Entry<EntryData> &entry)
|
||||
{ return entry.flags & Offset; }
|
||||
};
|
||||
|
||||
template <typename KernSubTableHeader>
|
||||
struct KerxSubTableFormat1
|
||||
{
|
||||
typedef typename KernSubTableHeader::Types Types;
|
||||
typedef typename Types::HBUINT HBUINT;
|
||||
|
||||
typedef Format1Entry<Types::extended> Format1EntryT;
|
||||
typedef typename Format1EntryT::EntryData EntryData;
|
||||
|
||||
struct driver_context_t
|
||||
{
|
||||
static constexpr bool in_place = true;
|
||||
enum
|
||||
{
|
||||
DontAdvance = Format1EntryT::DontAdvance,
|
||||
};
|
||||
|
||||
driver_context_t (const KerxSubTableFormat1 *table_,
|
||||
hb_aat_apply_context_t *c_) :
|
||||
c (c_),
|
||||
table (table_),
|
||||
/* Apparently the offset kernAction is from the beginning of the state-machine,
|
||||
* similar to offsets in morx table, NOT from beginning of this table, like
|
||||
* other subtables in kerx. Discovered via testing. */
|
||||
kernAction (&table->machine + table->kernAction),
|
||||
depth (0),
|
||||
crossStream (table->header.coverage & table->header.CrossStream) {}
|
||||
|
||||
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
|
||||
const Entry<EntryData> &entry)
|
||||
{ return Format1EntryT::performAction (entry); }
|
||||
void transition (StateTableDriver<Types, EntryData> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
{
|
||||
hb_buffer_t *buffer = driver->buffer;
|
||||
unsigned int flags = entry.flags;
|
||||
|
||||
if (flags & Format1EntryT::Reset)
|
||||
depth = 0;
|
||||
|
||||
if (flags & Format1EntryT::Push)
|
||||
{
|
||||
if (likely (depth < ARRAY_LENGTH (stack)))
|
||||
stack[depth++] = buffer->idx;
|
||||
else
|
||||
depth = 0; /* Probably not what CoreText does, but better? */
|
||||
}
|
||||
|
||||
if (Format1EntryT::performAction (entry) && depth)
|
||||
{
|
||||
unsigned int tuple_count = hb_max (1u, table->header.tuple_count ());
|
||||
|
||||
unsigned int kern_idx = Format1EntryT::kernActionIndex (entry);
|
||||
kern_idx = Types::byteOffsetToIndex (kern_idx, &table->machine, kernAction.arrayZ);
|
||||
const FWORD *actions = &kernAction[kern_idx];
|
||||
if (!c->sanitizer.check_array (actions, depth, tuple_count))
|
||||
{
|
||||
depth = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
hb_mask_t kern_mask = c->plan->kern_mask;
|
||||
|
||||
/* From Apple 'kern' spec:
|
||||
* "Each pops one glyph from the kerning stack and applies the kerning value to it.
|
||||
* The end of the list is marked by an odd value... */
|
||||
bool last = false;
|
||||
while (!last && depth)
|
||||
{
|
||||
unsigned int idx = stack[--depth];
|
||||
int v = *actions;
|
||||
actions += tuple_count;
|
||||
if (idx >= buffer->len) continue;
|
||||
|
||||
/* "The end of the list is marked by an odd value..." */
|
||||
last = v & 1;
|
||||
v &= ~1;
|
||||
|
||||
hb_glyph_position_t &o = buffer->pos[idx];
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
|
||||
{
|
||||
if (crossStream)
|
||||
{
|
||||
/* The following flag is undocumented in the spec, but described
|
||||
* in the 'kern' table example. */
|
||||
if (v == -0x8000)
|
||||
{
|
||||
o.attach_type() = ATTACH_TYPE_NONE;
|
||||
o.attach_chain() = 0;
|
||||
o.y_offset = 0;
|
||||
}
|
||||
else if (o.attach_type())
|
||||
{
|
||||
o.y_offset += c->font->em_scale_y (v);
|
||||
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
|
||||
}
|
||||
}
|
||||
else if (buffer->info[idx].mask & kern_mask)
|
||||
{
|
||||
o.x_advance += c->font->em_scale_x (v);
|
||||
o.x_offset += c->font->em_scale_x (v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (crossStream)
|
||||
{
|
||||
/* CoreText doesn't do crossStream kerning in vertical. We do. */
|
||||
if (v == -0x8000)
|
||||
{
|
||||
o.attach_type() = ATTACH_TYPE_NONE;
|
||||
o.attach_chain() = 0;
|
||||
o.x_offset = 0;
|
||||
}
|
||||
else if (o.attach_type())
|
||||
{
|
||||
o.x_offset += c->font->em_scale_x (v);
|
||||
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
|
||||
}
|
||||
}
|
||||
else if (buffer->info[idx].mask & kern_mask)
|
||||
{
|
||||
o.y_advance += c->font->em_scale_y (v);
|
||||
o.y_offset += c->font->em_scale_y (v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
hb_aat_apply_context_t *c;
|
||||
const KerxSubTableFormat1 *table;
|
||||
const UnsizedArrayOf<FWORD> &kernAction;
|
||||
unsigned int stack[8];
|
||||
unsigned int depth;
|
||||
bool crossStream;
|
||||
};
|
||||
|
||||
bool apply (hb_aat_apply_context_t *c) const
|
||||
{
|
||||
TRACE_APPLY (this);
|
||||
|
||||
if (!c->plan->requested_kerning &&
|
||||
!(header.coverage & header.CrossStream))
|
||||
return false;
|
||||
|
||||
driver_context_t dc (this, c);
|
||||
|
||||
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->font->face);
|
||||
driver.drive (&dc);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
/* The rest of array sanitizations are done at run-time. */
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
machine.sanitize (c)));
|
||||
}
|
||||
|
||||
protected:
|
||||
KernSubTableHeader header;
|
||||
StateTable<Types, EntryData> machine;
|
||||
NNOffsetTo<UnsizedArrayOf<FWORD>, HBUINT> kernAction;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 5 * sizeof (HBUINT));
|
||||
};
|
||||
|
||||
template <typename KernSubTableHeader>
|
||||
struct KerxSubTableFormat2
|
||||
{
|
||||
typedef typename KernSubTableHeader::Types Types;
|
||||
typedef typename Types::HBUINT HBUINT;
|
||||
|
||||
int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
|
||||
hb_aat_apply_context_t *c) const
|
||||
{
|
||||
unsigned int num_glyphs = c->sanitizer.get_num_glyphs ();
|
||||
unsigned int l = (this+leftClassTable).get_class (left, num_glyphs, 0);
|
||||
unsigned int r = (this+rightClassTable).get_class (right, num_glyphs, 0);
|
||||
|
||||
const UnsizedArrayOf<FWORD> &arrayZ = this+array;
|
||||
unsigned int kern_idx = l + r;
|
||||
kern_idx = Types::offsetToIndex (kern_idx, this, arrayZ.arrayZ);
|
||||
const FWORD *v = &arrayZ[kern_idx];
|
||||
if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
|
||||
|
||||
return kerxTupleKern (*v, header.tuple_count (), this, c);
|
||||
}
|
||||
|
||||
bool apply (hb_aat_apply_context_t *c) const
|
||||
{
|
||||
TRACE_APPLY (this);
|
||||
|
||||
if (!c->plan->requested_kerning)
|
||||
return false;
|
||||
|
||||
if (header.coverage & header.Backwards)
|
||||
return false;
|
||||
|
||||
accelerator_t accel (*this, c);
|
||||
hb_kern_machine_t<accelerator_t> machine (accel, header.coverage & header.CrossStream);
|
||||
machine.kern (c->font, c->buffer, c->plan->kern_mask);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
struct accelerator_t
|
||||
{
|
||||
const KerxSubTableFormat2 &table;
|
||||
hb_aat_apply_context_t *c;
|
||||
|
||||
accelerator_t (const KerxSubTableFormat2 &table_,
|
||||
hb_aat_apply_context_t *c_) :
|
||||
table (table_), c (c_) {}
|
||||
|
||||
int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
|
||||
{ return table.get_kerning (left, right, c); }
|
||||
};
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
leftClassTable.sanitize (c, this) &&
|
||||
rightClassTable.sanitize (c, this) &&
|
||||
c->check_range (this, array)));
|
||||
}
|
||||
|
||||
protected:
|
||||
KernSubTableHeader header;
|
||||
HBUINT rowWidth; /* The width, in bytes, of a row in the table. */
|
||||
NNOffsetTo<typename Types::ClassTypeWide, HBUINT>
|
||||
leftClassTable; /* Offset from beginning of this subtable to
|
||||
* left-hand class table. */
|
||||
NNOffsetTo<typename Types::ClassTypeWide, HBUINT>
|
||||
rightClassTable;/* Offset from beginning of this subtable to
|
||||
* right-hand class table. */
|
||||
NNOffsetTo<UnsizedArrayOf<FWORD>, HBUINT>
|
||||
array; /* Offset from beginning of this subtable to
|
||||
* the start of the kerning array. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 4 * sizeof (HBUINT));
|
||||
};
|
||||
|
||||
template <typename KernSubTableHeader>
|
||||
struct KerxSubTableFormat4
|
||||
{
|
||||
typedef ExtendedTypes Types;
|
||||
|
||||
struct EntryData
|
||||
{
|
||||
HBUINT16 ankrActionIndex;/* Either 0xFFFF (for no action) or the index of
|
||||
* the action to perform. */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (2);
|
||||
};
|
||||
|
||||
struct driver_context_t
|
||||
{
|
||||
static constexpr bool in_place = true;
|
||||
enum Flags
|
||||
{
|
||||
Mark = 0x8000, /* If set, remember this glyph as the marked glyph. */
|
||||
DontAdvance = 0x4000, /* If set, don't advance to the next glyph before
|
||||
* going to the new state. */
|
||||
Reserved = 0x3FFF, /* Not used; set to 0. */
|
||||
};
|
||||
|
||||
enum SubTableFlags
|
||||
{
|
||||
ActionType = 0xC0000000, /* A two-bit field containing the action type. */
|
||||
Unused = 0x3F000000, /* Unused - must be zero. */
|
||||
Offset = 0x00FFFFFF, /* Masks the offset in bytes from the beginning
|
||||
* of the subtable to the beginning of the control
|
||||
* point table. */
|
||||
};
|
||||
|
||||
driver_context_t (const KerxSubTableFormat4 *table,
|
||||
hb_aat_apply_context_t *c_) :
|
||||
c (c_),
|
||||
action_type ((table->flags & ActionType) >> 30),
|
||||
ankrData ((HBUINT16 *) ((const char *) &table->machine + (table->flags & Offset))),
|
||||
mark_set (false),
|
||||
mark (0) {}
|
||||
|
||||
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
|
||||
const Entry<EntryData> &entry)
|
||||
{ return entry.data.ankrActionIndex != 0xFFFF; }
|
||||
void transition (StateTableDriver<Types, EntryData> *driver,
|
||||
const Entry<EntryData> &entry)
|
||||
{
|
||||
hb_buffer_t *buffer = driver->buffer;
|
||||
|
||||
if (mark_set && entry.data.ankrActionIndex != 0xFFFF && buffer->idx < buffer->len)
|
||||
{
|
||||
hb_glyph_position_t &o = buffer->cur_pos();
|
||||
switch (action_type)
|
||||
{
|
||||
case 0: /* Control Point Actions.*/
|
||||
{
|
||||
/* Indexed into glyph outline. */
|
||||
/* Each action (record in ankrData) contains two 16-bit fields, so we must
|
||||
double the ankrActionIndex to get the correct offset here. */
|
||||
const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex * 2];
|
||||
if (!c->sanitizer.check_array (data, 2)) return;
|
||||
unsigned int markControlPoint = *data++;
|
||||
unsigned int currControlPoint = *data++;
|
||||
hb_position_t markX = 0;
|
||||
hb_position_t markY = 0;
|
||||
hb_position_t currX = 0;
|
||||
hb_position_t currY = 0;
|
||||
if (!c->font->get_glyph_contour_point_for_origin (c->buffer->info[mark].codepoint,
|
||||
markControlPoint,
|
||||
HB_DIRECTION_LTR /*XXX*/,
|
||||
&markX, &markY) ||
|
||||
!c->font->get_glyph_contour_point_for_origin (c->buffer->cur ().codepoint,
|
||||
currControlPoint,
|
||||
HB_DIRECTION_LTR /*XXX*/,
|
||||
&currX, &currY))
|
||||
return;
|
||||
|
||||
o.x_offset = markX - currX;
|
||||
o.y_offset = markY - currY;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: /* Anchor Point Actions. */
|
||||
{
|
||||
/* Indexed into 'ankr' table. */
|
||||
/* Each action (record in ankrData) contains two 16-bit fields, so we must
|
||||
double the ankrActionIndex to get the correct offset here. */
|
||||
const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex * 2];
|
||||
if (!c->sanitizer.check_array (data, 2)) return;
|
||||
unsigned int markAnchorPoint = *data++;
|
||||
unsigned int currAnchorPoint = *data++;
|
||||
const Anchor &markAnchor = c->ankr_table->get_anchor (c->buffer->info[mark].codepoint,
|
||||
markAnchorPoint,
|
||||
c->sanitizer.get_num_glyphs ());
|
||||
const Anchor &currAnchor = c->ankr_table->get_anchor (c->buffer->cur ().codepoint,
|
||||
currAnchorPoint,
|
||||
c->sanitizer.get_num_glyphs ());
|
||||
|
||||
o.x_offset = c->font->em_scale_x (markAnchor.xCoordinate) - c->font->em_scale_x (currAnchor.xCoordinate);
|
||||
o.y_offset = c->font->em_scale_y (markAnchor.yCoordinate) - c->font->em_scale_y (currAnchor.yCoordinate);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* Control Point Coordinate Actions. */
|
||||
{
|
||||
/* Each action contains four 16-bit fields, so we multiply the ankrActionIndex
|
||||
by 4 to get the correct offset for the given action. */
|
||||
const FWORD *data = (const FWORD *) &ankrData[entry.data.ankrActionIndex * 4];
|
||||
if (!c->sanitizer.check_array (data, 4)) return;
|
||||
int markX = *data++;
|
||||
int markY = *data++;
|
||||
int currX = *data++;
|
||||
int currY = *data++;
|
||||
|
||||
o.x_offset = c->font->em_scale_x (markX) - c->font->em_scale_x (currX);
|
||||
o.y_offset = c->font->em_scale_y (markY) - c->font->em_scale_y (currY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
o.attach_type() = ATTACH_TYPE_MARK;
|
||||
o.attach_chain() = (int) mark - (int) buffer->idx;
|
||||
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
|
||||
}
|
||||
|
||||
if (entry.flags & Mark)
|
||||
{
|
||||
mark_set = true;
|
||||
mark = buffer->idx;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
hb_aat_apply_context_t *c;
|
||||
unsigned int action_type;
|
||||
const HBUINT16 *ankrData;
|
||||
bool mark_set;
|
||||
unsigned int mark;
|
||||
};
|
||||
|
||||
bool apply (hb_aat_apply_context_t *c) const
|
||||
{
|
||||
TRACE_APPLY (this);
|
||||
|
||||
driver_context_t dc (this, c);
|
||||
|
||||
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->font->face);
|
||||
driver.drive (&dc);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
/* The rest of array sanitizations are done at run-time. */
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
machine.sanitize (c)));
|
||||
}
|
||||
|
||||
protected:
|
||||
KernSubTableHeader header;
|
||||
StateTable<Types, EntryData> machine;
|
||||
HBUINT32 flags;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 20);
|
||||
};
|
||||
|
||||
template <typename KernSubTableHeader>
|
||||
struct KerxSubTableFormat6
|
||||
{
|
||||
enum Flags
|
||||
{
|
||||
ValuesAreLong = 0x00000001,
|
||||
};
|
||||
|
||||
bool is_long () const { return flags & ValuesAreLong; }
|
||||
|
||||
int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
|
||||
hb_aat_apply_context_t *c) const
|
||||
{
|
||||
unsigned int num_glyphs = c->sanitizer.get_num_glyphs ();
|
||||
if (is_long ())
|
||||
{
|
||||
const typename U::Long &t = u.l;
|
||||
unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs);
|
||||
unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs);
|
||||
unsigned int offset = l + r;
|
||||
if (unlikely (offset < l)) return 0; /* Addition overflow. */
|
||||
if (unlikely (hb_unsigned_mul_overflows (offset, sizeof (FWORD32)))) return 0;
|
||||
const FWORD32 *v = &StructAtOffset<FWORD32> (&(this+t.array), offset * sizeof (FWORD32));
|
||||
if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
|
||||
return kerxTupleKern (*v, header.tuple_count (), &(this+vector), c);
|
||||
}
|
||||
else
|
||||
{
|
||||
const typename U::Short &t = u.s;
|
||||
unsigned int l = (this+t.rowIndexTable).get_value_or_null (left, num_glyphs);
|
||||
unsigned int r = (this+t.columnIndexTable).get_value_or_null (right, num_glyphs);
|
||||
unsigned int offset = l + r;
|
||||
const FWORD *v = &StructAtOffset<FWORD> (&(this+t.array), offset * sizeof (FWORD));
|
||||
if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
|
||||
return kerxTupleKern (*v, header.tuple_count (), &(this+vector), c);
|
||||
}
|
||||
}
|
||||
|
||||
bool apply (hb_aat_apply_context_t *c) const
|
||||
{
|
||||
TRACE_APPLY (this);
|
||||
|
||||
if (!c->plan->requested_kerning)
|
||||
return false;
|
||||
|
||||
if (header.coverage & header.Backwards)
|
||||
return false;
|
||||
|
||||
accelerator_t accel (*this, c);
|
||||
hb_kern_machine_t<accelerator_t> machine (accel, header.coverage & header.CrossStream);
|
||||
machine.kern (c->font, c->buffer, c->plan->kern_mask);
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
(is_long () ?
|
||||
(
|
||||
u.l.rowIndexTable.sanitize (c, this) &&
|
||||
u.l.columnIndexTable.sanitize (c, this) &&
|
||||
c->check_range (this, u.l.array)
|
||||
) : (
|
||||
u.s.rowIndexTable.sanitize (c, this) &&
|
||||
u.s.columnIndexTable.sanitize (c, this) &&
|
||||
c->check_range (this, u.s.array)
|
||||
)) &&
|
||||
(header.tuple_count () == 0 ||
|
||||
c->check_range (this, vector))));
|
||||
}
|
||||
|
||||
struct accelerator_t
|
||||
{
|
||||
const KerxSubTableFormat6 &table;
|
||||
hb_aat_apply_context_t *c;
|
||||
|
||||
accelerator_t (const KerxSubTableFormat6 &table_,
|
||||
hb_aat_apply_context_t *c_) :
|
||||
table (table_), c (c_) {}
|
||||
|
||||
int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
|
||||
{ return table.get_kerning (left, right, c); }
|
||||
};
|
||||
|
||||
protected:
|
||||
KernSubTableHeader header;
|
||||
HBUINT32 flags;
|
||||
HBUINT16 rowCount;
|
||||
HBUINT16 columnCount;
|
||||
union U
|
||||
{
|
||||
struct Long
|
||||
{
|
||||
NNOffset32To<Lookup<HBUINT32>> rowIndexTable;
|
||||
NNOffset32To<Lookup<HBUINT32>> columnIndexTable;
|
||||
NNOffset32To<UnsizedArrayOf<FWORD32>> array;
|
||||
} l;
|
||||
struct Short
|
||||
{
|
||||
NNOffset32To<Lookup<HBUINT16>> rowIndexTable;
|
||||
NNOffset32To<Lookup<HBUINT16>> columnIndexTable;
|
||||
NNOffset32To<UnsizedArrayOf<FWORD>> array;
|
||||
} s;
|
||||
} u;
|
||||
NNOffset32To<UnsizedArrayOf<FWORD>> vector;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24);
|
||||
};
|
||||
|
||||
|
||||
struct KerxSubTableHeader
|
||||
{
|
||||
typedef ExtendedTypes Types;
|
||||
|
||||
unsigned tuple_count () const { return tupleCount; }
|
||||
bool is_horizontal () const { return !(coverage & Vertical); }
|
||||
|
||||
enum Coverage
|
||||
{
|
||||
Vertical = 0x80000000u, /* Set if table has vertical kerning values. */
|
||||
CrossStream = 0x40000000u, /* Set if table has cross-stream kerning values. */
|
||||
Variation = 0x20000000u, /* Set if table has variation kerning values. */
|
||||
Backwards = 0x10000000u, /* If clear, process the glyphs forwards, that
|
||||
* is, from first to last in the glyph stream.
|
||||
* If we, process them from last to first.
|
||||
* This flag only applies to state-table based
|
||||
* 'kerx' subtables (types 1 and 4). */
|
||||
Reserved = 0x0FFFFF00u, /* Reserved, set to zero. */
|
||||
SubtableType= 0x000000FFu, /* Subtable type. */
|
||||
};
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
public:
|
||||
HBUINT32 length;
|
||||
HBUINT32 coverage;
|
||||
HBUINT32 tupleCount;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (12);
|
||||
};
|
||||
|
||||
struct KerxSubTable
|
||||
{
|
||||
friend struct kerx;
|
||||
|
||||
unsigned int get_size () const { return u.header.length; }
|
||||
unsigned int get_type () const { return u.header.coverage & u.header.SubtableType; }
|
||||
|
||||
template <typename context_t, typename ...Ts>
|
||||
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
||||
{
|
||||
unsigned int subtable_type = get_type ();
|
||||
TRACE_DISPATCH (this, subtable_type);
|
||||
switch (subtable_type) {
|
||||
case 0: return_trace (c->dispatch (u.format0, hb_forward<Ts> (ds)...));
|
||||
case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
|
||||
case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
|
||||
case 4: return_trace (c->dispatch (u.format4, hb_forward<Ts> (ds)...));
|
||||
case 6: return_trace (c->dispatch (u.format6, hb_forward<Ts> (ds)...));
|
||||
default: return_trace (c->default_return_value ());
|
||||
}
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (!u.header.sanitize (c) ||
|
||||
u.header.length <= u.header.static_size ||
|
||||
!c->check_range (this, u.header.length))
|
||||
return_trace (false);
|
||||
|
||||
return_trace (dispatch (c));
|
||||
}
|
||||
|
||||
public:
|
||||
union {
|
||||
KerxSubTableHeader header;
|
||||
KerxSubTableFormat0<KerxSubTableHeader> format0;
|
||||
KerxSubTableFormat1<KerxSubTableHeader> format1;
|
||||
KerxSubTableFormat2<KerxSubTableHeader> format2;
|
||||
KerxSubTableFormat4<KerxSubTableHeader> format4;
|
||||
KerxSubTableFormat6<KerxSubTableHeader> format6;
|
||||
} u;
|
||||
public:
|
||||
DEFINE_SIZE_MIN (12);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The 'kerx' Table
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
struct KerxTable
|
||||
{
|
||||
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
|
||||
const T* thiz () const { return static_cast<const T *> (this); }
|
||||
|
||||
bool has_state_machine () const
|
||||
{
|
||||
typedef typename T::SubTable SubTable;
|
||||
|
||||
const SubTable *st = &thiz()->firstSubTable;
|
||||
unsigned int count = thiz()->tableCount;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
if (st->get_type () == 1)
|
||||
return true;
|
||||
st = &StructAfter<SubTable> (*st);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool has_cross_stream () const
|
||||
{
|
||||
typedef typename T::SubTable SubTable;
|
||||
|
||||
const SubTable *st = &thiz()->firstSubTable;
|
||||
unsigned int count = thiz()->tableCount;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
if (st->u.header.coverage & st->u.header.CrossStream)
|
||||
return true;
|
||||
st = &StructAfter<SubTable> (*st);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
|
||||
{
|
||||
typedef typename T::SubTable SubTable;
|
||||
|
||||
int v = 0;
|
||||
const SubTable *st = &thiz()->firstSubTable;
|
||||
unsigned int count = thiz()->tableCount;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
if ((st->u.header.coverage & (st->u.header.Variation | st->u.header.CrossStream)) ||
|
||||
!st->u.header.is_horizontal ())
|
||||
continue;
|
||||
v += st->get_kerning (left, right);
|
||||
st = &StructAfter<SubTable> (*st);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
bool apply (AAT::hb_aat_apply_context_t *c) const
|
||||
{
|
||||
typedef typename T::SubTable SubTable;
|
||||
|
||||
bool ret = false;
|
||||
bool seenCrossStream = false;
|
||||
c->set_lookup_index (0);
|
||||
const SubTable *st = &thiz()->firstSubTable;
|
||||
unsigned int count = thiz()->tableCount;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
bool reverse;
|
||||
|
||||
if (!T::Types::extended && (st->u.header.coverage & st->u.header.Variation))
|
||||
goto skip;
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ())
|
||||
goto skip;
|
||||
|
||||
reverse = bool (st->u.header.coverage & st->u.header.Backwards) !=
|
||||
HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);
|
||||
|
||||
if (!c->buffer->message (c->font, "start subtable %d", c->lookup_index))
|
||||
goto skip;
|
||||
|
||||
if (!seenCrossStream &&
|
||||
(st->u.header.coverage & st->u.header.CrossStream))
|
||||
{
|
||||
/* Attach all glyphs into a chain. */
|
||||
seenCrossStream = true;
|
||||
hb_glyph_position_t *pos = c->buffer->pos;
|
||||
unsigned int count = c->buffer->len;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
pos[i].attach_type() = ATTACH_TYPE_CURSIVE;
|
||||
pos[i].attach_chain() = HB_DIRECTION_IS_FORWARD (c->buffer->props.direction) ? -1 : +1;
|
||||
/* We intentionally don't set HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT,
|
||||
* since there needs to be a non-zero attachment for post-positioning to
|
||||
* be needed. */
|
||||
}
|
||||
}
|
||||
|
||||
if (reverse)
|
||||
c->buffer->reverse ();
|
||||
|
||||
{
|
||||
/* See comment in sanitize() for conditional here. */
|
||||
hb_sanitize_with_object_t with (&c->sanitizer, i < count - 1 ? st : (const SubTable *) nullptr);
|
||||
ret |= st->dispatch (c);
|
||||
}
|
||||
|
||||
if (reverse)
|
||||
c->buffer->reverse ();
|
||||
|
||||
(void) c->buffer->message (c->font, "end subtable %d", c->lookup_index);
|
||||
|
||||
skip:
|
||||
st = &StructAfter<SubTable> (*st);
|
||||
c->set_lookup_index (c->lookup_index + 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (unlikely (!thiz()->version.sanitize (c) ||
|
||||
(unsigned) thiz()->version < (unsigned) T::minVersion ||
|
||||
!thiz()->tableCount.sanitize (c)))
|
||||
return_trace (false);
|
||||
|
||||
typedef typename T::SubTable SubTable;
|
||||
|
||||
const SubTable *st = &thiz()->firstSubTable;
|
||||
unsigned int count = thiz()->tableCount;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
if (unlikely (!st->u.header.sanitize (c)))
|
||||
return_trace (false);
|
||||
/* OpenType kern table has 2-byte subtable lengths. That's limiting.
|
||||
* MS implementation also only supports one subtable, of format 0,
|
||||
* anyway. Certain versions of some fonts, like Calibry, contain
|
||||
* kern subtable that exceeds 64kb. Looks like, the subtable length
|
||||
* is simply ignored. Which makes sense. It's only needed if you
|
||||
* have multiple subtables. To handle such fonts, we just ignore
|
||||
* the length for the last subtable. */
|
||||
hb_sanitize_with_object_t with (c, i < count - 1 ? st : (const SubTable *) nullptr);
|
||||
|
||||
if (unlikely (!st->sanitize (c)))
|
||||
return_trace (false);
|
||||
|
||||
st = &StructAfter<SubTable> (*st);
|
||||
}
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
};
|
||||
|
||||
struct kerx : KerxTable<kerx>
|
||||
{
|
||||
friend struct KerxTable<kerx>;
|
||||
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_kerx;
|
||||
static constexpr unsigned minVersion = 2u;
|
||||
|
||||
typedef KerxSubTableHeader SubTableHeader;
|
||||
typedef SubTableHeader::Types Types;
|
||||
typedef KerxSubTable SubTable;
|
||||
|
||||
bool has_data () const { return version; }
|
||||
|
||||
protected:
|
||||
HBUINT16 version; /* The version number of the extended kerning table
|
||||
* (currently 2, 3, or 4). */
|
||||
HBUINT16 unused; /* Set to 0. */
|
||||
HBUINT32 tableCount; /* The number of subtables included in the extended kerning
|
||||
* table. */
|
||||
SubTable firstSubTable; /* Subtables. */
|
||||
/*subtableGlyphCoverageArray*/ /* Only if version >= 3. We don't use. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_MIN (8);
|
||||
};
|
||||
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_KERX_TABLE_HH */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright © 2019 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_AAT_LAYOUT_OPBD_TABLE_HH
|
||||
#define HB_AAT_LAYOUT_OPBD_TABLE_HH
|
||||
|
||||
#include "hb-aat-layout-common.hh"
|
||||
#include "hb-open-type.hh"
|
||||
|
||||
/*
|
||||
* opbd -- Optical Bounds
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6opbd.html
|
||||
*/
|
||||
#define HB_AAT_TAG_opbd HB_TAG('o','p','b','d')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
struct OpticalBounds
|
||||
{
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this)));
|
||||
}
|
||||
|
||||
FWORD leftSide;
|
||||
FWORD topSide;
|
||||
FWORD rightSide;
|
||||
FWORD bottomSide;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (8);
|
||||
};
|
||||
|
||||
struct opbdFormat0
|
||||
{
|
||||
bool get_bounds (hb_font_t *font, hb_codepoint_t glyph_id,
|
||||
hb_glyph_extents_t *extents, const void *base) const
|
||||
{
|
||||
const Offset16To<OpticalBounds> *bounds_offset = lookupTable.get_value (glyph_id, font->face->get_num_glyphs ());
|
||||
if (!bounds_offset) return false;
|
||||
const OpticalBounds &bounds = base+*bounds_offset;
|
||||
|
||||
if (extents)
|
||||
*extents = {
|
||||
font->em_scale_x (bounds.leftSide),
|
||||
font->em_scale_y (bounds.topSide),
|
||||
font->em_scale_x (bounds.rightSide),
|
||||
font->em_scale_y (bounds.bottomSide)
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) && lookupTable.sanitize (c, base)));
|
||||
}
|
||||
|
||||
protected:
|
||||
Lookup<Offset16To<OpticalBounds>>
|
||||
lookupTable; /* Lookup table associating glyphs with the four
|
||||
* int16 values for the left-side, top-side,
|
||||
* right-side, and bottom-side optical bounds. */
|
||||
public:
|
||||
DEFINE_SIZE_MIN (2);
|
||||
};
|
||||
|
||||
struct opbdFormat1
|
||||
{
|
||||
bool get_bounds (hb_font_t *font, hb_codepoint_t glyph_id,
|
||||
hb_glyph_extents_t *extents, const void *base) const
|
||||
{
|
||||
const Offset16To<OpticalBounds> *bounds_offset = lookupTable.get_value (glyph_id, font->face->get_num_glyphs ());
|
||||
if (!bounds_offset) return false;
|
||||
const OpticalBounds &bounds = base+*bounds_offset;
|
||||
|
||||
hb_position_t left = 0, top = 0, right = 0, bottom = 0, ignore;
|
||||
if (font->get_glyph_contour_point (glyph_id, bounds.leftSide, &left, &ignore) ||
|
||||
font->get_glyph_contour_point (glyph_id, bounds.topSide, &ignore, &top) ||
|
||||
font->get_glyph_contour_point (glyph_id, bounds.rightSide, &right, &ignore) ||
|
||||
font->get_glyph_contour_point (glyph_id, bounds.bottomSide, &ignore, &bottom))
|
||||
{
|
||||
if (extents)
|
||||
*extents = {left, top, right, bottom};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) && lookupTable.sanitize (c, base)));
|
||||
}
|
||||
|
||||
protected:
|
||||
Lookup<Offset16To<OpticalBounds>>
|
||||
lookupTable; /* Lookup table associating glyphs with the four
|
||||
* int16 values for the left-side, top-side,
|
||||
* right-side, and bottom-side optical bounds. */
|
||||
public:
|
||||
DEFINE_SIZE_MIN (2);
|
||||
};
|
||||
|
||||
struct opbd
|
||||
{
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_opbd;
|
||||
|
||||
bool get_bounds (hb_font_t *font, hb_codepoint_t glyph_id,
|
||||
hb_glyph_extents_t *extents) const
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case 0: return u.format0.get_bounds (font, glyph_id, extents, this);
|
||||
case 1: return u.format1.get_bounds (font, glyph_id, extents, this);
|
||||
default:return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (unlikely (!c->check_struct (this) || version.major != 1))
|
||||
return_trace (false);
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case 0: return_trace (u.format0.sanitize (c, this));
|
||||
case 1: return_trace (u.format1.sanitize (c, this));
|
||||
default:return_trace (true);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
FixedVersion<>version; /* Version number of the optical bounds
|
||||
* table (0x00010000 for the current version). */
|
||||
HBUINT16 format; /* Format of the optical bounds table.
|
||||
* Format 0 indicates distance and Format 1 indicates
|
||||
* control point. */
|
||||
union {
|
||||
opbdFormat0 format0;
|
||||
opbdFormat1 format1;
|
||||
} u;
|
||||
public:
|
||||
DEFINE_SIZE_MIN (8);
|
||||
};
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_OPBD_TABLE_HH */
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
* Copyright © 2018 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_AAT_LAYOUT_TRAK_TABLE_HH
|
||||
#define HB_AAT_LAYOUT_TRAK_TABLE_HH
|
||||
|
||||
#include "hb-aat-layout-common.hh"
|
||||
#include "hb-ot-layout.hh"
|
||||
#include "hb-open-type.hh"
|
||||
|
||||
/*
|
||||
* trak -- Tracking
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6trak.html
|
||||
*/
|
||||
#define HB_AAT_TAG_trak HB_TAG('t','r','a','k')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
|
||||
struct TrackTableEntry
|
||||
{
|
||||
friend struct TrackData;
|
||||
|
||||
float get_track_value () const { return track.to_float (); }
|
||||
|
||||
int get_value (const void *base, unsigned int index,
|
||||
unsigned int table_size) const
|
||||
{ return (base+valuesZ).as_array (table_size)[index]; }
|
||||
|
||||
public:
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base,
|
||||
unsigned int table_size) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
(valuesZ.sanitize (c, base, table_size))));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBFixed track; /* Track value for this record. */
|
||||
NameID trackNameID; /* The 'name' table index for this track.
|
||||
* (a short word or phrase like "loose"
|
||||
* or "very tight") */
|
||||
NNOffset16To<UnsizedArrayOf<FWORD>>
|
||||
valuesZ; /* Offset from start of tracking table to
|
||||
* per-size tracking values for this track. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (8);
|
||||
};
|
||||
|
||||
struct TrackData
|
||||
{
|
||||
float interpolate_at (unsigned int idx,
|
||||
float target_size,
|
||||
const TrackTableEntry &trackTableEntry,
|
||||
const void *base) const
|
||||
{
|
||||
unsigned int sizes = nSizes;
|
||||
hb_array_t<const HBFixed> size_table ((base+sizeTable).arrayZ, sizes);
|
||||
|
||||
float s0 = size_table[idx].to_float ();
|
||||
float s1 = size_table[idx + 1].to_float ();
|
||||
float t = unlikely (s0 == s1) ? 0.f : (target_size - s0) / (s1 - s0);
|
||||
return t * trackTableEntry.get_value (base, idx + 1, sizes) +
|
||||
(1.f - t) * trackTableEntry.get_value (base, idx, sizes);
|
||||
}
|
||||
|
||||
int get_tracking (const void *base, float ptem) const
|
||||
{
|
||||
/*
|
||||
* Choose track.
|
||||
*/
|
||||
const TrackTableEntry *trackTableEntry = nullptr;
|
||||
unsigned int count = nTracks;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
/* Note: Seems like the track entries are sorted by values. But the
|
||||
* spec doesn't explicitly say that. It just mentions it in the example. */
|
||||
|
||||
/* For now we only seek for track entries with zero tracking value */
|
||||
|
||||
if (trackTable[i].get_track_value () == 0.f)
|
||||
{
|
||||
trackTableEntry = &trackTable[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!trackTableEntry) return 0.;
|
||||
|
||||
/*
|
||||
* Choose size.
|
||||
*/
|
||||
unsigned int sizes = nSizes;
|
||||
if (!sizes) return 0.;
|
||||
if (sizes == 1) return trackTableEntry->get_value (base, 0, sizes);
|
||||
|
||||
hb_array_t<const HBFixed> size_table ((base+sizeTable).arrayZ, sizes);
|
||||
unsigned int size_index;
|
||||
for (size_index = 0; size_index < sizes - 1; size_index++)
|
||||
if (size_table[size_index].to_float () >= ptem)
|
||||
break;
|
||||
|
||||
return roundf (interpolate_at (size_index ? size_index - 1 : 0, ptem,
|
||||
*trackTableEntry, base));
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
sizeTable.sanitize (c, base, nSizes) &&
|
||||
trackTable.sanitize (c, nTracks, base, nSizes)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 nTracks; /* Number of separate tracks included in this table. */
|
||||
HBUINT16 nSizes; /* Number of point sizes included in this table. */
|
||||
NNOffset32To<UnsizedArrayOf<HBFixed>>
|
||||
sizeTable; /* Offset from start of the tracking table to
|
||||
* Array[nSizes] of size values.. */
|
||||
UnsizedArrayOf<TrackTableEntry>
|
||||
trackTable; /* Array[nTracks] of TrackTableEntry records. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (8, trackTable);
|
||||
};
|
||||
|
||||
struct trak
|
||||
{
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_trak;
|
||||
|
||||
bool has_data () const { return version.to_int (); }
|
||||
|
||||
bool apply (hb_aat_apply_context_t *c) const
|
||||
{
|
||||
TRACE_APPLY (this);
|
||||
|
||||
hb_mask_t trak_mask = c->plan->trak_mask;
|
||||
|
||||
const float ptem = c->font->ptem;
|
||||
if (unlikely (ptem <= 0.f))
|
||||
return_trace (false);
|
||||
|
||||
hb_buffer_t *buffer = c->buffer;
|
||||
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
|
||||
{
|
||||
const TrackData &trackData = this+horizData;
|
||||
int tracking = trackData.get_tracking (this, ptem);
|
||||
hb_position_t offset_to_add = c->font->em_scalef_x (tracking / 2);
|
||||
hb_position_t advance_to_add = c->font->em_scalef_x (tracking);
|
||||
foreach_grapheme (buffer, start, end)
|
||||
{
|
||||
if (!(buffer->info[start].mask & trak_mask)) continue;
|
||||
buffer->pos[start].x_advance += advance_to_add;
|
||||
buffer->pos[start].x_offset += offset_to_add;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const TrackData &trackData = this+vertData;
|
||||
int tracking = trackData.get_tracking (this, ptem);
|
||||
hb_position_t offset_to_add = c->font->em_scalef_y (tracking / 2);
|
||||
hb_position_t advance_to_add = c->font->em_scalef_y (tracking);
|
||||
foreach_grapheme (buffer, start, end)
|
||||
{
|
||||
if (!(buffer->info[start].mask & trak_mask)) continue;
|
||||
buffer->pos[start].y_advance += advance_to_add;
|
||||
buffer->pos[start].y_offset += offset_to_add;
|
||||
}
|
||||
}
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
version.major == 1 &&
|
||||
horizData.sanitize (c, this, this) &&
|
||||
vertData.sanitize (c, this, this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
FixedVersion<>version; /* Version of the tracking table
|
||||
* (0x00010000u for version 1.0). */
|
||||
HBUINT16 format; /* Format of the tracking table (set to 0). */
|
||||
Offset16To<TrackData>
|
||||
horizData; /* Offset from start of tracking table to TrackData
|
||||
* for horizontal text (or 0 if none). */
|
||||
Offset16To<TrackData>
|
||||
vertData; /* Offset from start of tracking table to TrackData
|
||||
* for vertical text (or 0 if none). */
|
||||
HBUINT16 reserved; /* Reserved. Set to 0. */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (12);
|
||||
};
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_TRAK_TABLE_HH */
|
||||
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* Copyright © 2017 Google, Inc.
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
#include "hb-aat-layout.hh"
|
||||
#include "hb-aat-layout-ankr-table.hh"
|
||||
#include "hb-aat-layout-bsln-table.hh" // Just so we compile it; unused otherwise.
|
||||
#include "hb-aat-layout-feat-table.hh"
|
||||
#include "hb-aat-layout-just-table.hh" // Just so we compile it; unused otherwise.
|
||||
#include "hb-aat-layout-kerx-table.hh"
|
||||
#include "hb-aat-layout-morx-table.hh"
|
||||
#include "hb-aat-layout-trak-table.hh"
|
||||
#include "hb-aat-ltag-table.hh"
|
||||
|
||||
|
||||
/*
|
||||
* hb_aat_apply_context_t
|
||||
*/
|
||||
|
||||
/* Note: This context is used for kerning, even without AAT, hence the condition. */
|
||||
#if !defined(HB_NO_AAT) || !defined(HB_NO_OT_KERN)
|
||||
|
||||
AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_,
|
||||
hb_font_t *font_,
|
||||
hb_buffer_t *buffer_,
|
||||
hb_blob_t *blob) :
|
||||
plan (plan_),
|
||||
font (font_),
|
||||
face (font->face),
|
||||
buffer (buffer_),
|
||||
sanitizer (),
|
||||
ankr_table (&Null (AAT::ankr)),
|
||||
gdef_table (face->table.GDEF->table),
|
||||
lookup_index (0)
|
||||
{
|
||||
sanitizer.init (blob);
|
||||
sanitizer.set_num_glyphs (face->get_num_glyphs ());
|
||||
sanitizer.start_processing ();
|
||||
sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX);
|
||||
}
|
||||
|
||||
AAT::hb_aat_apply_context_t::~hb_aat_apply_context_t ()
|
||||
{ sanitizer.end_processing (); }
|
||||
|
||||
void
|
||||
AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_)
|
||||
{ ankr_table = ankr_table_; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:hb-aat-layout
|
||||
* @title: hb-aat-layout
|
||||
* @short_description: Apple Advanced Typography Layout
|
||||
* @include: hb-aat.h
|
||||
*
|
||||
* Functions for querying AAT Layout features in the font face.
|
||||
*
|
||||
* HarfBuzz supports all of the AAT tables used to implement shaping. Other
|
||||
* AAT tables and their associated features are not supported.
|
||||
**/
|
||||
|
||||
|
||||
#if !defined(HB_NO_AAT) || defined(HAVE_CORETEXT)
|
||||
|
||||
/* Mapping from OpenType feature tags to AAT feature names and selectors.
|
||||
*
|
||||
* Table data courtesy of Apple. Converted from mnemonics to integers
|
||||
* when moving to this file. */
|
||||
static const hb_aat_feature_mapping_t feature_mappings[] =
|
||||
{
|
||||
{HB_TAG ('a','f','r','c'), HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_VERTICAL_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_FRACTIONS},
|
||||
{HB_TAG ('c','2','p','c'), HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_PETITE_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_UPPER_CASE},
|
||||
{HB_TAG ('c','2','s','c'), HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_SMALL_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_UPPER_CASE},
|
||||
{HB_TAG ('c','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_OFF},
|
||||
{HB_TAG ('c','a','s','e'), HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_OFF},
|
||||
{HB_TAG ('c','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_OFF},
|
||||
{HB_TAG ('c','p','s','p'), HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_OFF},
|
||||
{HB_TAG ('c','s','w','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_OFF},
|
||||
{HB_TAG ('d','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_OFF},
|
||||
{HB_TAG ('e','x','p','t'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPERT_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('f','r','a','c'), HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAGONAL_FRACTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_FRACTIONS},
|
||||
{HB_TAG ('f','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('h','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_HALF_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('h','i','s','t'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_OFF},
|
||||
{HB_TAG ('h','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_OFF},
|
||||
{HB_TAG ('h','l','i','g'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_OFF},
|
||||
{HB_TAG ('h','n','g','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION, HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_TRANSLITERATION},
|
||||
{HB_TAG ('h','o','j','o'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_HOJO_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('h','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('i','t','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN, HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF},
|
||||
{HB_TAG ('j','p','0','4'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS2004_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('j','p','7','8'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1978_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('j','p','8','3'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1983_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('j','p','9','0'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1990_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('l','i','g','a'), HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES, HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_OFF},
|
||||
{HB_TAG ('l','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_NUMBERS, (hb_aat_layout_feature_selector_t) 2},
|
||||
{HB_TAG ('m','g','r','k'), HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS, HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_OFF},
|
||||
{HB_TAG ('n','l','c','k'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_NLCCHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('o','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_NUMBERS, (hb_aat_layout_feature_selector_t) 2},
|
||||
{HB_TAG ('o','r','d','n'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_ORDINALS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
|
||||
{HB_TAG ('p','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('p','c','a','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_PETITE_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_LOWER_CASE},
|
||||
{HB_TAG ('p','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('p','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_NUMBERS, (hb_aat_layout_feature_selector_t) 4},
|
||||
{HB_TAG ('p','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('q','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('r','u','b','y'), HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA, HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF},
|
||||
{HB_TAG ('s','i','n','f'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SCIENTIFIC_INFERIORS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
|
||||
{HB_TAG ('s','m','c','p'), HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE, HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_SMALL_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_LOWER_CASE},
|
||||
{HB_TAG ('s','m','p','l'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_SIMPLIFIED_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('s','s','0','1'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_OFF},
|
||||
{HB_TAG ('s','s','0','2'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_OFF},
|
||||
{HB_TAG ('s','s','0','3'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_OFF},
|
||||
{HB_TAG ('s','s','0','4'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_OFF},
|
||||
{HB_TAG ('s','s','0','5'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_OFF},
|
||||
{HB_TAG ('s','s','0','6'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_OFF},
|
||||
{HB_TAG ('s','s','0','7'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_OFF},
|
||||
{HB_TAG ('s','s','0','8'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_OFF},
|
||||
{HB_TAG ('s','s','0','9'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_OFF},
|
||||
{HB_TAG ('s','s','1','0'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_OFF},
|
||||
{HB_TAG ('s','s','1','1'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_OFF},
|
||||
{HB_TAG ('s','s','1','2'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_OFF},
|
||||
{HB_TAG ('s','s','1','3'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_OFF},
|
||||
{HB_TAG ('s','s','1','4'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_OFF},
|
||||
{HB_TAG ('s','s','1','5'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_OFF},
|
||||
{HB_TAG ('s','s','1','6'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_OFF},
|
||||
{HB_TAG ('s','s','1','7'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_OFF},
|
||||
{HB_TAG ('s','s','1','8'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_OFF},
|
||||
{HB_TAG ('s','s','1','9'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_OFF},
|
||||
{HB_TAG ('s','s','2','0'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_OFF},
|
||||
{HB_TAG ('s','u','b','s'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_INFERIORS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
|
||||
{HB_TAG ('s','u','p','s'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUPERIORS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION},
|
||||
{HB_TAG ('s','w','s','h'), HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES, HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_OFF},
|
||||
{HB_TAG ('t','i','t','l'), HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS, HB_AAT_LAYOUT_FEATURE_SELECTOR_TITLING_CAPS, HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLE_OPTIONS},
|
||||
{HB_TAG ('t','n','a','m'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_NAMES_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('t','n','u','m'), HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_NUMBERS, (hb_aat_layout_feature_selector_t) 4},
|
||||
{HB_TAG ('t','r','a','d'), HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE, HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_CHARACTERS, (hb_aat_layout_feature_selector_t) 16},
|
||||
{HB_TAG ('t','w','i','d'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('u','n','i','c'), HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE, (hb_aat_layout_feature_selector_t) 14, (hb_aat_layout_feature_selector_t) 15},
|
||||
{HB_TAG ('v','a','l','t'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('v','e','r','t'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF},
|
||||
{HB_TAG ('v','h','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_HALF_WIDTH_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('v','k','n','a'), HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_OFF},
|
||||
{HB_TAG ('v','p','a','l'), HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING, HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT, (hb_aat_layout_feature_selector_t) 7},
|
||||
{HB_TAG ('v','r','t','2'), HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF},
|
||||
{HB_TAG ('z','e','r','o'), HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS, HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_OFF},
|
||||
};
|
||||
|
||||
/**
|
||||
* hb_aat_layout_find_feature_mapping:
|
||||
* @tag: The requested #hb_tag_t feature tag
|
||||
*
|
||||
* Fetches the AAT feature-and-selector combination that corresponds
|
||||
* to a given OpenType feature tag.
|
||||
*
|
||||
* Return value: the AAT features and selectors corresponding to the
|
||||
* OpenType feature tag queried
|
||||
*
|
||||
**/
|
||||
const hb_aat_feature_mapping_t *
|
||||
hb_aat_layout_find_feature_mapping (hb_tag_t tag)
|
||||
{
|
||||
return hb_sorted_array (feature_mappings).bsearch (tag);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HB_NO_AAT
|
||||
|
||||
/*
|
||||
* mort/morx/kerx/trak
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
|
||||
hb_aat_map_t *map)
|
||||
{
|
||||
const AAT::morx& morx = *mapper->face->table.morx;
|
||||
if (morx.has_data ())
|
||||
{
|
||||
morx.compile_flags (mapper, map);
|
||||
return;
|
||||
}
|
||||
|
||||
const AAT::mort& mort = *mapper->face->table.mort;
|
||||
if (mort.has_data ())
|
||||
{
|
||||
mort.compile_flags (mapper, map);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hb_aat_layout_has_substitution:
|
||||
* @face: #hb_face_t to work upon
|
||||
*
|
||||
* Tests whether the specified face includes any substitutions in the
|
||||
* `morx` or `mort` tables.
|
||||
*
|
||||
* <note>Note: does not examine the `GSUB` table.</note>
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
* Since: 2.3.0
|
||||
*/
|
||||
hb_bool_t
|
||||
hb_aat_layout_has_substitution (hb_face_t *face)
|
||||
{
|
||||
return face->table.morx->has_data () ||
|
||||
face->table.mort->has_data ();
|
||||
}
|
||||
|
||||
void
|
||||
hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer)
|
||||
{
|
||||
hb_blob_t *morx_blob = font->face->table.morx.get_blob ();
|
||||
const AAT::morx& morx = *morx_blob->as<AAT::morx> ();
|
||||
if (morx.has_data ())
|
||||
{
|
||||
AAT::hb_aat_apply_context_t c (plan, font, buffer, morx_blob);
|
||||
if (!buffer->message (font, "start table morx")) return;
|
||||
morx.apply (&c);
|
||||
(void) buffer->message (font, "end table morx");
|
||||
return;
|
||||
}
|
||||
|
||||
hb_blob_t *mort_blob = font->face->table.mort.get_blob ();
|
||||
const AAT::mort& mort = *mort_blob->as<AAT::mort> ();
|
||||
if (mort.has_data ())
|
||||
{
|
||||
AAT::hb_aat_apply_context_t c (plan, font, buffer, mort_blob);
|
||||
if (!buffer->message (font, "start table mort")) return;
|
||||
mort.apply (&c);
|
||||
(void) buffer->message (font, "end table mort");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hb_aat_layout_zero_width_deleted_glyphs (hb_buffer_t *buffer)
|
||||
{
|
||||
unsigned int count = buffer->len;
|
||||
hb_glyph_info_t *info = buffer->info;
|
||||
hb_glyph_position_t *pos = buffer->pos;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (unlikely (info[i].codepoint == AAT::DELETED_GLYPH))
|
||||
pos[i].x_advance = pos[i].y_advance = pos[i].x_offset = pos[i].y_offset = 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_deleted_glyph (const hb_glyph_info_t *info)
|
||||
{
|
||||
return info->codepoint == AAT::DELETED_GLYPH;
|
||||
}
|
||||
|
||||
void
|
||||
hb_aat_layout_remove_deleted_glyphs (hb_buffer_t *buffer)
|
||||
{
|
||||
hb_ot_layout_delete_glyphs_inplace (buffer, is_deleted_glyph);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_aat_layout_has_positioning:
|
||||
* @face: #hb_face_t to work upon
|
||||
*
|
||||
* Tests whether the specified face includes any positioning information
|
||||
* in the `kerx` table.
|
||||
*
|
||||
* <note>Note: does not examine the `GPOS` table.</note>
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
* Since: 2.3.0
|
||||
*/
|
||||
hb_bool_t
|
||||
hb_aat_layout_has_positioning (hb_face_t *face)
|
||||
{
|
||||
return face->table.kerx->has_data ();
|
||||
}
|
||||
|
||||
void
|
||||
hb_aat_layout_position (const hb_ot_shape_plan_t *plan,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer)
|
||||
{
|
||||
hb_blob_t *kerx_blob = font->face->table.kerx.get_blob ();
|
||||
const AAT::kerx& kerx = *kerx_blob->as<AAT::kerx> ();
|
||||
|
||||
AAT::hb_aat_apply_context_t c (plan, font, buffer, kerx_blob);
|
||||
if (!buffer->message (font, "start table kerx")) return;
|
||||
c.set_ankr_table (font->face->table.ankr.get ());
|
||||
kerx.apply (&c);
|
||||
(void) buffer->message (font, "end table kerx");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hb_aat_layout_has_tracking:
|
||||
* @face:: #hb_face_t to work upon
|
||||
*
|
||||
* Tests whether the specified face includes any tracking information
|
||||
* in the `trak` table.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
* Since: 2.3.0
|
||||
*/
|
||||
hb_bool_t
|
||||
hb_aat_layout_has_tracking (hb_face_t *face)
|
||||
{
|
||||
return face->table.trak->has_data ();
|
||||
}
|
||||
|
||||
void
|
||||
hb_aat_layout_track (const hb_ot_shape_plan_t *plan,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer)
|
||||
{
|
||||
const AAT::trak& trak = *font->face->table.trak;
|
||||
|
||||
AAT::hb_aat_apply_context_t c (plan, font, buffer);
|
||||
trak.apply (&c);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_aat_layout_get_feature_types:
|
||||
* @face: #hb_face_t to work upon
|
||||
* @start_offset: offset of the first feature type to retrieve
|
||||
* @feature_count: (inout) (optional): Input = the maximum number of feature types to return;
|
||||
* Output = the actual number of feature types returned (may be zero)
|
||||
* @features: (out caller-allocates) (array length=feature_count): Array of feature types found
|
||||
*
|
||||
* Fetches a list of the AAT feature types included in the specified face.
|
||||
*
|
||||
* Return value: Number of all available feature types.
|
||||
*
|
||||
* Since: 2.2.0
|
||||
*/
|
||||
unsigned int
|
||||
hb_aat_layout_get_feature_types (hb_face_t *face,
|
||||
unsigned int start_offset,
|
||||
unsigned int *feature_count, /* IN/OUT. May be NULL. */
|
||||
hb_aat_layout_feature_type_t *features /* OUT. May be NULL. */)
|
||||
{
|
||||
return face->table.feat->get_feature_types (start_offset, feature_count, features);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_aat_layout_feature_type_get_name_id:
|
||||
* @face: #hb_face_t to work upon
|
||||
* @feature_type: The #hb_aat_layout_feature_type_t of the requested feature type
|
||||
*
|
||||
* Fetches the name identifier of the specified feature type in the face's `name` table.
|
||||
*
|
||||
* Return value: Name identifier of the requested feature type
|
||||
*
|
||||
* Since: 2.2.0
|
||||
*/
|
||||
hb_ot_name_id_t
|
||||
hb_aat_layout_feature_type_get_name_id (hb_face_t *face,
|
||||
hb_aat_layout_feature_type_t feature_type)
|
||||
{
|
||||
return face->table.feat->get_feature_name_id (feature_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_aat_layout_feature_type_get_selector_infos:
|
||||
* @face: #hb_face_t to work upon
|
||||
* @feature_type: The #hb_aat_layout_feature_type_t of the requested feature type
|
||||
* @start_offset: offset of the first feature type to retrieve
|
||||
* @selector_count: (inout) (optional): Input = the maximum number of selectors to return;
|
||||
* Output = the actual number of selectors returned (may be zero)
|
||||
* @selectors: (out caller-allocates) (array length=selector_count) (optional):
|
||||
* A buffer pointer. The selectors available for the feature type queries.
|
||||
* @default_index: (out) (optional): The index of the feature's default selector, if any
|
||||
*
|
||||
* Fetches a list of the selectors available for the specified feature in the given face.
|
||||
*
|
||||
* If upon return, @default_index is set to #HB_AAT_LAYOUT_NO_SELECTOR_INDEX, then
|
||||
* the feature type is non-exclusive. Otherwise, @default_index is the index of
|
||||
* the selector that is selected by default.
|
||||
*
|
||||
* Return value: Number of all available feature selectors
|
||||
*
|
||||
* Since: 2.2.0
|
||||
*/
|
||||
unsigned int
|
||||
hb_aat_layout_feature_type_get_selector_infos (hb_face_t *face,
|
||||
hb_aat_layout_feature_type_t feature_type,
|
||||
unsigned int start_offset,
|
||||
unsigned int *selector_count, /* IN/OUT. May be NULL. */
|
||||
hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
|
||||
unsigned int *default_index /* OUT. May be NULL. */)
|
||||
{
|
||||
return face->table.feat->get_selector_infos (feature_type, start_offset, selector_count, selectors, default_index);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,795 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if !defined(HB_AAT_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb-aat.h> instead."
|
||||
#endif
|
||||
|
||||
#ifndef HB_AAT_LAYOUT_H
|
||||
#define HB_AAT_LAYOUT_H
|
||||
|
||||
#include "hb.h"
|
||||
|
||||
#include "hb-ot.h"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* hb_aat_layout_feature_type_t:
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_INVALID: Initial, unset feature type
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC: [All Typographic Features](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type0)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES: [Ligatures](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type1)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CURISVE_CONNECTION: [Cursive Connection](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type2)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE: [Letter Case](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type3)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION: [Vertical Substitution](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type4)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_LINGUISTIC_REARRANGEMENT: [Linguistic Rearrangement](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type5)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING: [Number Spacing](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type6)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE: [Smart Swash](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type8)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE: [Diacritics](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type9)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION: [Vertical Position](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type10)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS: [Fractions](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type11)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_OVERLAPPING_CHARACTERS_TYPE: [Overlapping Characters](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type13)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS: [Typographic Extras](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type14)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS: [Mathematical Extras](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type15)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE: [Ornament Sets](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type16)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES: [Character Alternatives](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type17)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE: [Design Complexity](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type18)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS: [Style Options](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type19)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE: [Character Shape](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type20)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE: [Number Case](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type21)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING: [Text Spacing](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type22)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION: [Transliteration](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type23)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE: [Annotation](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type24)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_KANA_SPACING_TYPE: [Kana Spacing](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type25)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE: [Ideographic Spacing](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type26)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE: [Unicode Decomposition](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type27)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA: [Ruby Kana](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type28)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE: [CJK Symbol Alternatives](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type29)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE: [Ideographic Alternatives](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type30)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CJK_VERTICAL_ROMAN_PLACEMENT_TYPE: [CJK Vertical Roman Placement](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type31)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN: [Italic CJK Roman](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type32)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT: [Case Sensitive Layout](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type33)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA: [Alternate Kana](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type34)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES: [Stylistic Alternatives](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type35)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES: [Contextual Alternatives](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type36)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE: [Lower Case](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type37)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE: [Upper Case](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type38)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_LANGUAGE_TAG_TYPE: [Language Tag](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type39)
|
||||
* @HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE: [CJK Roman Spacing](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type103)
|
||||
*
|
||||
* The possible feature types defined for AAT shaping, from Apple [Font Feature Registry](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html).
|
||||
*
|
||||
* Since: 2.2.0
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_INVALID = 0xFFFF,
|
||||
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CURISVE_CONNECTION = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_LINGUISTIC_REARRANGEMENT = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE = 9,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION = 10,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS = 11,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_OVERLAPPING_CHARACTERS_TYPE = 13,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS = 14,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS = 15,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE = 16,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES = 17,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE = 18,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS = 19,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE = 20,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE = 21,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING = 22,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION = 23,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE = 24,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_KANA_SPACING_TYPE = 25,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE = 26,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE = 27,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA = 28,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE = 29,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE = 30,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CJK_VERTICAL_ROMAN_PLACEMENT_TYPE = 31,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN = 32,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT = 33,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA = 34,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES = 35,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES = 36,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE = 37,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE = 38,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_LANGUAGE_TAG_TYPE = 39,
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE = 103,
|
||||
|
||||
/*< private >*/
|
||||
_HB_AAT_LAYOUT_FEATURE_TYPE_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/
|
||||
} hb_aat_layout_feature_type_t;
|
||||
|
||||
/**
|
||||
* hb_aat_layout_feature_selector_t:
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID: Initial, unset feature selector
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_TYPE_FEATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_TYPE_FEATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_REQUIRED_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_REQUIRED_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LOGOS_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LOGOS_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_REBUS_PICTURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_REBUS_PICTURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DIPHTHONG_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DIPHTHONG_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SQUARED_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SQUARED_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ABBREV_SQUARED_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ABBREV_SQUARED_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SYMBOL_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SYMBOL_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_UNCONNECTED: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PARTIALLY_CONNECTED: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CURSIVE: for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_AND_LOWER_CASE: Deprecated
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_CAPS: Deprecated
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_LOWER_CASE: Deprecated
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SMALL_CAPS: Deprecated
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INITIAL_CAPS: Deprecated
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INITIAL_CAPS_AND_SMALL_CAPS: Deprecated
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LINGUISTIC_REARRANGEMENT_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_LINGUISTIC_REARRANGEMENT
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LINGUISTIC_REARRANGEMENT_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_LINGUISTIC_REARRANGEMENT
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_NUMBERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_NUMBERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_NUMBERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_NUMBERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_INITIAL_SWASHES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_INITIAL_SWASHES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_FINAL_SWASHES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_FINAL_SWASHES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_INITIAL_SWASHES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_INITIAL_SWASHES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_FINAL_SWASHES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_FINAL_SWASHES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NON_FINAL_SWASHES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NON_FINAL_SWASHES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SHOW_DIACRITICS: for #HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HIDE_DIACRITICS: for #HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DECOMPOSE_DIACRITICS: for #HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION: for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SUPERIORS: for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INFERIORS: for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ORDINALS: for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SCIENTIFIC_INFERIORS: for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_FRACTIONS: for #HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_VERTICAL_FRACTIONS: for #HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAGONAL_FRACTIONS: for #HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PREVENT_OVERLAP_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_OVERLAPPING_CHARACTERS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PREVENT_OVERLAP_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_OVERLAPPING_CHARACTERS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHENS_TO_EM_DASH_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHENS_TO_EM_DASH_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_EN_DASH_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_EN_DASH_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_FORM_INTERROBANG_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_FORM_INTERROBANG_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SMART_QUOTES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SMART_QUOTES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIODS_TO_ELLIPSIS_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIODS_TO_ELLIPSIS_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_MINUS_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_MINUS_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ASTERISK_TO_MULTIPLY_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ASTERISK_TO_MULTIPLY_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASH_TO_DIVIDE_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASH_TO_DIVIDE_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INEQUALITY_LIGATURES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INEQUALITY_LIGATURES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPONENTS_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPONENTS_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ORNAMENTS: for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DINGBATS: for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PI_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_FLEURONS: for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DECORATIVE_BORDERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INTERNATIONAL_SYMBOLS: for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_MATH_SYMBOLS: for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ALTERNATES: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL1: for #HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL2: for #HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL3: for #HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL4: for #HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL5: for #HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLE_OPTIONS: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DISPLAY_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ENGRAVED_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ILLUMINATED_CAPS: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TITLING_CAPS: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TALL_CAPS: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SIMPLIFIED_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1978_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1983_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1990_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_ONE: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_TWO: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_THREE: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_FOUR: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_FIVE: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPERT_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS2004_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HOJO_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NLCCHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_NAMES_CHARACTERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_NUMBERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_NUMBERS: for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_HALF_WIDTH_TEXT: for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_TRANSLITERATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HIRAGANA_TO_KATAKANA: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_KATAKANA_TO_HIRAGANA: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_KANA_TO_ROMANIZATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMANIZATION_TO_HIRAGANA: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMANIZATION_TO_KATAKANA: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_ONE: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_TWO: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_THREE: for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_BOX_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ROUNDED_BOX_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CIRCLE_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_CIRCLE_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PARENTHESIS_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIOD_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMAN_NUMERAL_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAMOND_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_BOX_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_ROUNDED_BOX_ANNOTATION: for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_KANA: for #HB_AAT_LAYOUT_FEATURE_TYPE_KANA_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_KANA: for #HB_AAT_LAYOUT_FEATURE_TYPE_KANA_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_IDEOGRAPHS: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_IDEOGRAPHS: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_IDEOGRAPHS: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CANONICAL_COMPOSITION_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CANONICAL_COMPOSITION_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_COMPATIBILITY_COMPOSITION_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_COMPATIBILITY_COMPOSITION_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRANSCODING_COMPOSITION_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_TRANSCODING_COMPOSITION_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_RUBY_KANA: Deprecated; use #HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF instead
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA: Deprecated; use #HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON instead
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_CJK_SYMBOL_ALTERNATIVES: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_ONE: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_TWO: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_THREE: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_FOUR: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_FIVE: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_IDEOGRAPHIC_ALTERNATIVES: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_ONE: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_TWO: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_THREE: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_FOUR: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_FIVE: for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_VERTICAL_ROMAN_CENTERED: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_VERTICAL_ROMAN_PLACEMENT_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_VERTICAL_ROMAN_HBASELINE: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_VERTICAL_ROMAN_PLACEMENT_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_CJK_ITALIC_ROMAN: Deprecated; use #HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF instead
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN: Deprecated; use #HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON instead
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLISTIC_ALTERNATES: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_ON: for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_OFF: for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_LOWER_CASE: for #HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_SMALL_CAPS: for #HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_PETITE_CAPS: for #HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_UPPER_CASE: for #HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_SMALL_CAPS: for #HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_PETITE_CAPS: for #HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_CJK_ROMAN: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_CJK_ROMAN: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_CJK_ROMAN: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE
|
||||
* @HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_CJK_ROMAN: for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE
|
||||
*
|
||||
* The selectors defined for specifying AAT feature settings.
|
||||
*
|
||||
* Since: 2.2.0
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID = 0xFFFF,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_TYPE_FEATURES_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_TYPE_FEATURES_OFF = 1,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_REQUIRED_LIGATURES_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_REQUIRED_LIGATURES_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_COMMON_LIGATURES_OFF = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_ON = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_RARE_LIGATURES_OFF = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LOGOS_ON = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LOGOS_OFF = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_REBUS_PICTURES_ON = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_REBUS_PICTURES_OFF = 9,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DIPHTHONG_LIGATURES_ON = 10,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DIPHTHONG_LIGATURES_OFF = 11,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SQUARED_LIGATURES_ON = 12,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SQUARED_LIGATURES_OFF = 13,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ABBREV_SQUARED_LIGATURES_ON = 14,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ABBREV_SQUARED_LIGATURES_OFF = 15,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SYMBOL_LIGATURES_ON = 16,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SYMBOL_LIGATURES_OFF = 17,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_ON = 18,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_LIGATURES_OFF = 19,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_ON = 20,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HISTORICAL_LIGATURES_OFF = 21,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LIGATURES */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_UNCONNECTED = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PARTIALLY_CONNECTED = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CURSIVE = 2,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_AND_LOWER_CASE = 0, /* deprecated */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_CAPS = 1, /* deprecated */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALL_LOWER_CASE = 2, /* deprecated */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SMALL_CAPS = 3, /* deprecated */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INITIAL_CAPS = 4, /* deprecated */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INITIAL_CAPS_AND_SMALL_CAPS = 5, /* deprecated */
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_SUBSTITUTION */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SUBSTITUTE_VERTICAL_FORMS_OFF = 1,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LINGUISTIC_REARRANGEMENT */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LINGUISTIC_REARRANGEMENT_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LINGUISTIC_REARRANGEMENT_OFF = 1,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_SPACING */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_NUMBERS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_NUMBERS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_NUMBERS = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_NUMBERS = 3,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_SMART_SWASH_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_INITIAL_SWASHES_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_INITIAL_SWASHES_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_FINAL_SWASHES_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_WORD_FINAL_SWASHES_OFF = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_INITIAL_SWASHES_ON = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_INITIAL_SWASHES_OFF = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_FINAL_SWASHES_ON = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LINE_FINAL_SWASHES_OFF = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NON_FINAL_SWASHES_ON = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NON_FINAL_SWASHES_OFF = 9,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_DIACRITICS_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SHOW_DIACRITICS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HIDE_DIACRITICS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DECOMPOSE_DIACRITICS = 2,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_VERTICAL_POSITION */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NORMAL_POSITION = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SUPERIORS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INFERIORS = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ORDINALS = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SCIENTIFIC_INFERIORS = 4,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_FRACTIONS */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_FRACTIONS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_VERTICAL_FRACTIONS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAGONAL_FRACTIONS = 2,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_OVERLAPPING_CHARACTERS_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PREVENT_OVERLAP_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PREVENT_OVERLAP_OFF = 1,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHENS_TO_EM_DASH_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHENS_TO_EM_DASH_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_EN_DASH_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_EN_DASH_OFF = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_ON = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_OFF = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_FORM_INTERROBANG_ON = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_FORM_INTERROBANG_OFF = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SMART_QUOTES_ON = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SMART_QUOTES_OFF = 9,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIODS_TO_ELLIPSIS_ON = 10,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIODS_TO_ELLIPSIS_OFF = 11,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_MATHEMATICAL_EXTRAS */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_MINUS_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HYPHEN_TO_MINUS_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ASTERISK_TO_MULTIPLY_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ASTERISK_TO_MULTIPLY_OFF = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASH_TO_DIVIDE_ON = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASH_TO_DIVIDE_OFF = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INEQUALITY_LIGATURES_ON = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INEQUALITY_LIGATURES_OFF = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPONENTS_ON = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPONENTS_OFF = 9,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_ON = 10,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_MATHEMATICAL_GREEK_OFF = 11,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ORNAMENT_SETS_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ORNAMENTS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DINGBATS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PI_CHARACTERS = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_FLEURONS = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DECORATIVE_BORDERS = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INTERNATIONAL_SYMBOLS = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_MATH_SYMBOLS = 6,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ALTERNATES = 0,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL1 = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL2 = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL3 = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL4 = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DESIGN_LEVEL5 = 4,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLE_OPTIONS */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLE_OPTIONS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DISPLAY_TEXT = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ENGRAVED_TEXT = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ILLUMINATED_CAPS = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TITLING_CAPS = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TALL_CAPS = 5,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_CHARACTERS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SIMPLIFIED_CHARACTERS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1978_CHARACTERS = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1983_CHARACTERS = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS1990_CHARACTERS = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_ONE = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_TWO = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_THREE = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_FOUR = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_ALT_FIVE = 9,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_EXPERT_CHARACTERS = 10,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_JIS2004_CHARACTERS = 11,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HOJO_CHARACTERS = 12,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NLCCHARACTERS = 13,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRADITIONAL_NAMES_CHARACTERS = 14,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_NUMBER_CASE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_NUMBERS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_NUMBERS = 1,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_TEXT_SPACING */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_TEXT = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_MONOSPACED_TEXT = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_TEXT = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_THIRD_WIDTH_TEXT = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_QUARTER_WIDTH_TEXT = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_PROPORTIONAL_TEXT = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALT_HALF_WIDTH_TEXT = 6,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_TRANSLITERATION */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_TRANSLITERATION = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HIRAGANA_TO_KATAKANA = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_KATAKANA_TO_HIRAGANA = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_KANA_TO_ROMANIZATION = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMANIZATION_TO_HIRAGANA = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMANIZATION_TO_KATAKANA = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_ONE = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_TWO = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HANJA_TO_HANGUL_ALT_THREE = 9,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ANNOTATION_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_ANNOTATION = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_BOX_ANNOTATION = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ROUNDED_BOX_ANNOTATION = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CIRCLE_ANNOTATION = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_CIRCLE_ANNOTATION = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PARENTHESIS_ANNOTATION = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PERIOD_ANNOTATION = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ROMAN_NUMERAL_ANNOTATION = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DIAMOND_ANNOTATION = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_BOX_ANNOTATION = 9,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_INVERTED_ROUNDED_BOX_ANNOTATION= 10,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_KANA_SPACING_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_KANA = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_KANA = 1,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_SPACING_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_IDEOGRAPHS = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_IDEOGRAPHS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_IDEOGRAPHS = 2,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_UNICODE_DECOMPOSITION_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CANONICAL_COMPOSITION_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CANONICAL_COMPOSITION_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_COMPATIBILITY_COMPOSITION_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_COMPATIBILITY_COMPOSITION_OFF = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRANSCODING_COMPOSITION_ON = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_TRANSCODING_COMPOSITION_OFF = 5,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_RUBY_KANA */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_RUBY_KANA = 0, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF instead */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA = 1, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON instead */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_RUBY_KANA_OFF = 3,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_SYMBOL_ALTERNATIVES_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_CJK_SYMBOL_ALTERNATIVES = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_ONE = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_TWO = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_THREE = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_FOUR = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_SYMBOL_ALT_FIVE = 5,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_IDEOGRAPHIC_ALTERNATIVES_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_IDEOGRAPHIC_ALTERNATIVES = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_ONE = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_TWO = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_THREE = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_FOUR = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_IDEOGRAPHIC_ALT_FIVE = 5,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_VERTICAL_ROMAN_PLACEMENT_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_VERTICAL_ROMAN_CENTERED = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_VERTICAL_ROMAN_HBASELINE = 1,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ITALIC_CJK_ROMAN */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_CJK_ITALIC_ROMAN = 0, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF instead */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN = 1, /* deprecated - use HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON instead */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CJK_ITALIC_ROMAN_OFF = 3,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CASE_SENSITIVE_LAYOUT */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_LAYOUT_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CASE_SENSITIVE_SPACING_OFF = 3,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_ALTERNATE_KANA */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_HORIZ_KANA_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_ALTERNATE_VERT_KANA_OFF = 3,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_STYLISTIC_ALTERNATIVES */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_NO_STYLISTIC_ALTERNATES = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ONE_OFF = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_ON = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWO_OFF = 5,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_ON = 6,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THREE_OFF = 7,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_ON = 8,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOUR_OFF = 9,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_ON = 10,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIVE_OFF = 11,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_ON = 12,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIX_OFF = 13,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_ON = 14,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVEN_OFF = 15,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_ON = 16,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHT_OFF = 17,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_ON = 18,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINE_OFF = 19,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_ON = 20,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TEN_OFF = 21,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_ON = 22,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_ELEVEN_OFF = 23,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_ON = 24,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWELVE_OFF = 25,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_ON = 26,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_THIRTEEN_OFF = 27,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_ON = 28,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FOURTEEN_OFF = 29,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_ON = 30,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_FIFTEEN_OFF = 31,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_ON = 32,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SIXTEEN_OFF = 33,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_ON = 34,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_SEVENTEEN_OFF = 35,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_ON = 36,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_EIGHTEEN_OFF = 37,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_ON = 38,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_NINETEEN_OFF = 39,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_ON = 40,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_STYLISTIC_ALT_TWENTY_OFF = 41,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CONTEXTUAL_ALTERNATIVES */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_ON = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_ALTERNATES_OFF = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_ON = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_SWASH_ALTERNATES_OFF = 3,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_ON = 4,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_CONTEXTUAL_SWASH_ALTERNATES_OFF= 5,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_LOWER_CASE = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_SMALL_CAPS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_PETITE_CAPS = 2,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_UPPER_CASE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_UPPER_CASE = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_SMALL_CAPS = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_UPPER_CASE_PETITE_CAPS = 2,
|
||||
|
||||
/* Selectors for #HB_AAT_LAYOUT_FEATURE_TYPE_CJK_ROMAN_SPACING_TYPE */
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_HALF_WIDTH_CJK_ROMAN = 0,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_PROPORTIONAL_CJK_ROMAN = 1,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_DEFAULT_CJK_ROMAN = 2,
|
||||
HB_AAT_LAYOUT_FEATURE_SELECTOR_FULL_WIDTH_CJK_ROMAN = 3,
|
||||
|
||||
/*< private >*/
|
||||
_HB_AAT_LAYOUT_FEATURE_SELECTOR_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/
|
||||
} hb_aat_layout_feature_selector_t;
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_aat_layout_get_feature_types (hb_face_t *face,
|
||||
unsigned int start_offset,
|
||||
unsigned int *feature_count, /* IN/OUT. May be NULL. */
|
||||
hb_aat_layout_feature_type_t *features /* OUT. May be NULL. */);
|
||||
|
||||
HB_EXTERN hb_ot_name_id_t
|
||||
hb_aat_layout_feature_type_get_name_id (hb_face_t *face,
|
||||
hb_aat_layout_feature_type_t feature_type);
|
||||
|
||||
/**
|
||||
* hb_aat_layout_feature_selector_info_t:
|
||||
* @name_id: The selector's name identifier
|
||||
* @enable: The value to turn the selector on
|
||||
* @disable: The value to turn the selector off
|
||||
*
|
||||
* Structure representing a setting for an #hb_aat_layout_feature_type_t.
|
||||
*/
|
||||
typedef struct hb_aat_layout_feature_selector_info_t {
|
||||
hb_ot_name_id_t name_id;
|
||||
hb_aat_layout_feature_selector_t enable;
|
||||
hb_aat_layout_feature_selector_t disable;
|
||||
/*< private >*/
|
||||
unsigned int reserved;
|
||||
} hb_aat_layout_feature_selector_info_t;
|
||||
|
||||
/**
|
||||
* HB_AAT_LAYOUT_NO_SELECTOR_INDEX
|
||||
*
|
||||
* Used when getting or setting AAT feature selectors. Indicates that
|
||||
* there is no selector index corresponding to the selector of interest.
|
||||
*
|
||||
*/
|
||||
#define HB_AAT_LAYOUT_NO_SELECTOR_INDEX 0xFFFFu
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_aat_layout_feature_type_get_selector_infos (hb_face_t *face,
|
||||
hb_aat_layout_feature_type_t feature_type,
|
||||
unsigned int start_offset,
|
||||
unsigned int *selector_count, /* IN/OUT. May be NULL. */
|
||||
hb_aat_layout_feature_selector_info_t *selectors, /* OUT. May be NULL. */
|
||||
unsigned int *default_index /* OUT. May be NULL. */);
|
||||
|
||||
|
||||
/*
|
||||
* morx/mort
|
||||
*/
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_aat_layout_has_substitution (hb_face_t *face);
|
||||
|
||||
|
||||
/*
|
||||
* kerx
|
||||
*/
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_aat_layout_has_positioning (hb_face_t *face);
|
||||
|
||||
|
||||
/*
|
||||
* trak
|
||||
*/
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_aat_layout_has_tracking (hb_face_t *face);
|
||||
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_H */
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright © 2017 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_AAT_LAYOUT_HH
|
||||
#define HB_AAT_LAYOUT_HH
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
#include "hb-ot-shape.hh"
|
||||
#include "hb-aat-ltag-table.hh"
|
||||
|
||||
struct hb_aat_feature_mapping_t
|
||||
{
|
||||
hb_tag_t otFeatureTag;
|
||||
hb_aat_layout_feature_type_t aatFeatureType;
|
||||
hb_aat_layout_feature_selector_t selectorToEnable;
|
||||
hb_aat_layout_feature_selector_t selectorToDisable;
|
||||
|
||||
int cmp (hb_tag_t key) const
|
||||
{ return key < otFeatureTag ? -1 : key > otFeatureTag ? 1 : 0; }
|
||||
};
|
||||
|
||||
HB_INTERNAL const hb_aat_feature_mapping_t *
|
||||
hb_aat_layout_find_feature_mapping (hb_tag_t tag);
|
||||
|
||||
HB_INTERNAL void
|
||||
hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
|
||||
hb_aat_map_t *map);
|
||||
|
||||
HB_INTERNAL void
|
||||
hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer);
|
||||
|
||||
HB_INTERNAL void
|
||||
hb_aat_layout_zero_width_deleted_glyphs (hb_buffer_t *buffer);
|
||||
|
||||
HB_INTERNAL void
|
||||
hb_aat_layout_remove_deleted_glyphs (hb_buffer_t *buffer);
|
||||
|
||||
HB_INTERNAL void
|
||||
hb_aat_layout_position (const hb_ot_shape_plan_t *plan,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer);
|
||||
|
||||
HB_INTERNAL void
|
||||
hb_aat_layout_track (const hb_ot_shape_plan_t *plan,
|
||||
hb_font_t *font,
|
||||
hb_buffer_t *buffer);
|
||||
|
||||
|
||||
#endif /* HB_AAT_LAYOUT_HH */
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_AAT_LTAG_TABLE_HH
|
||||
#define HB_AAT_LTAG_TABLE_HH
|
||||
|
||||
#include "hb-open-type.hh"
|
||||
|
||||
/*
|
||||
* ltag -- Language Tag
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ltag.html
|
||||
*/
|
||||
#define HB_AAT_TAG_ltag HB_TAG('l','t','a','g')
|
||||
|
||||
|
||||
namespace AAT {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
|
||||
struct FTStringRange
|
||||
{
|
||||
friend struct ltag;
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) && (base+tag).sanitize (c, length));
|
||||
}
|
||||
|
||||
protected:
|
||||
NNOffset16To<UnsizedArrayOf<HBUINT8>>
|
||||
tag; /* Offset from the start of the table to
|
||||
* the beginning of the string */
|
||||
HBUINT16 length; /* String length (in bytes) */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
|
||||
struct ltag
|
||||
{
|
||||
static constexpr hb_tag_t tableTag = HB_AAT_TAG_ltag;
|
||||
|
||||
hb_language_t get_language (unsigned int i) const
|
||||
{
|
||||
const FTStringRange &range = tagRanges[i];
|
||||
return hb_language_from_string ((const char *) (this+range.tag).arrayZ,
|
||||
range.length);
|
||||
}
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (likely (c->check_struct (this) &&
|
||||
version >= 1 &&
|
||||
tagRanges.sanitize (c, this)));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT32 version; /* Table version; currently 1 */
|
||||
HBUINT32 flags; /* Table flags; currently none defined */
|
||||
Array32Of<FTStringRange>
|
||||
tagRanges; /* Range for each tag's string */
|
||||
public:
|
||||
DEFINE_SIZE_ARRAY (12, tagRanges);
|
||||
};
|
||||
|
||||
} /* namespace AAT */
|
||||
|
||||
|
||||
#endif /* HB_AAT_LTAG_TABLE_HH */
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright © 2009,2010 Red Hat, Inc.
|
||||
* Copyright © 2010,2011,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.
|
||||
*
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
#ifndef HB_NO_AAT_SHAPE
|
||||
|
||||
#include "hb-aat-map.hh"
|
||||
|
||||
#include "hb-aat-layout.hh"
|
||||
#include "hb-aat-layout-feat-table.hh"
|
||||
|
||||
|
||||
void hb_aat_map_builder_t::add_feature (hb_tag_t tag, unsigned value)
|
||||
{
|
||||
if (!face->table.feat->has_data ()) return;
|
||||
|
||||
if (tag == HB_TAG ('a','a','l','t'))
|
||||
{
|
||||
if (!face->table.feat->exposes_feature (HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES))
|
||||
return;
|
||||
feature_info_t *info = features.push();
|
||||
info->type = HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES;
|
||||
info->setting = (hb_aat_layout_feature_selector_t) value;
|
||||
info->seq = features.length;
|
||||
info->is_exclusive = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const hb_aat_feature_mapping_t *mapping = hb_aat_layout_find_feature_mapping (tag);
|
||||
if (!mapping) return;
|
||||
|
||||
const AAT::FeatureName* feature = &face->table.feat->get_feature (mapping->aatFeatureType);
|
||||
if (!feature->has_data ())
|
||||
{
|
||||
/* Special case: Chain::compile_flags will fall back to the deprecated version of
|
||||
* small-caps if necessary, so we need to check for that possibility.
|
||||
* https://github.com/harfbuzz/harfbuzz/issues/2307 */
|
||||
if (mapping->aatFeatureType == HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE &&
|
||||
mapping->selectorToEnable == HB_AAT_LAYOUT_FEATURE_SELECTOR_LOWER_CASE_SMALL_CAPS)
|
||||
{
|
||||
feature = &face->table.feat->get_feature (HB_AAT_LAYOUT_FEATURE_TYPE_LETTER_CASE);
|
||||
if (!feature->has_data ()) return;
|
||||
}
|
||||
else return;
|
||||
}
|
||||
|
||||
feature_info_t *info = features.push();
|
||||
info->type = mapping->aatFeatureType;
|
||||
info->setting = value ? mapping->selectorToEnable : mapping->selectorToDisable;
|
||||
info->seq = features.length;
|
||||
info->is_exclusive = feature->is_exclusive ();
|
||||
}
|
||||
|
||||
void
|
||||
hb_aat_map_builder_t::compile (hb_aat_map_t &m)
|
||||
{
|
||||
/* Sort features and merge duplicates */
|
||||
if (features.length)
|
||||
{
|
||||
features.qsort ();
|
||||
unsigned int j = 0;
|
||||
for (unsigned int i = 1; i < features.length; i++)
|
||||
if (features[i].type != features[j].type ||
|
||||
/* Nonexclusive feature selectors come in even/odd pairs to turn a setting on/off
|
||||
* respectively, so we mask out the low-order bit when checking for "duplicates"
|
||||
* (selectors referring to the same feature setting) here. */
|
||||
(!features[i].is_exclusive && ((features[i].setting & ~1) != (features[j].setting & ~1))))
|
||||
features[++j] = features[i];
|
||||
features.shrink (j + 1);
|
||||
}
|
||||
|
||||
hb_aat_layout_compile_map (this, &m);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright © 2018 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_AAT_MAP_HH
|
||||
#define HB_AAT_MAP_HH
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
|
||||
struct hb_aat_map_t
|
||||
{
|
||||
friend struct hb_aat_map_builder_t;
|
||||
|
||||
public:
|
||||
|
||||
void init ()
|
||||
{
|
||||
memset (this, 0, sizeof (*this));
|
||||
chain_flags.init ();
|
||||
}
|
||||
void fini () { chain_flags.fini (); }
|
||||
|
||||
public:
|
||||
hb_vector_t<hb_mask_t> chain_flags;
|
||||
};
|
||||
|
||||
struct hb_aat_map_builder_t
|
||||
{
|
||||
public:
|
||||
|
||||
HB_INTERNAL hb_aat_map_builder_t (hb_face_t *face_,
|
||||
const hb_segment_properties_t *props_ HB_UNUSED) :
|
||||
face (face_) {}
|
||||
|
||||
HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value=1);
|
||||
|
||||
HB_INTERNAL void compile (hb_aat_map_t &m);
|
||||
|
||||
public:
|
||||
struct feature_info_t
|
||||
{
|
||||
hb_aat_layout_feature_type_t type;
|
||||
hb_aat_layout_feature_selector_t setting;
|
||||
bool is_exclusive;
|
||||
unsigned seq; /* For stable sorting only. */
|
||||
|
||||
HB_INTERNAL static int cmp (const void *pa, const void *pb)
|
||||
{
|
||||
const feature_info_t *a = (const feature_info_t *) pa;
|
||||
const feature_info_t *b = (const feature_info_t *) pb;
|
||||
if (a->type != b->type) return (a->type < b->type ? -1 : 1);
|
||||
if (!a->is_exclusive &&
|
||||
(a->setting & ~1) != (b->setting & ~1)) return (a->setting < b->setting ? -1 : 1);
|
||||
return (a->seq < b->seq ? -1 : a->seq > b->seq ? 1 : 0);
|
||||
}
|
||||
|
||||
/* compares type & setting only, not is_exclusive flag or seq number */
|
||||
int cmp (const feature_info_t& f) const
|
||||
{
|
||||
return (f.type != type) ? (f.type < type ? -1 : 1) :
|
||||
(f.setting != setting) ? (f.setting < setting ? -1 : 1) : 0;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
hb_face_t *face;
|
||||
|
||||
public:
|
||||
hb_sorted_vector_t<feature_info_t> features;
|
||||
};
|
||||
|
||||
|
||||
#endif /* HB_AAT_MAP_HH */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_AAT_H
|
||||
#define HB_AAT_H
|
||||
#define HB_AAT_H_IN
|
||||
|
||||
#include "hb.h"
|
||||
|
||||
#include "hb-aat-layout.h"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#undef HB_AAT_H_IN
|
||||
#endif /* HB_AAT_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* Copyright © 2018 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_ARRAY_HH
|
||||
#define HB_ARRAY_HH
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-algs.hh"
|
||||
#include "hb-iter.hh"
|
||||
#include "hb-null.hh"
|
||||
|
||||
|
||||
template <typename Type>
|
||||
struct hb_sorted_array_t;
|
||||
|
||||
template <typename Type>
|
||||
struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
|
||||
{
|
||||
/*
|
||||
* Constructors.
|
||||
*/
|
||||
hb_array_t () : arrayZ (nullptr), length (0), backwards_length (0) {}
|
||||
hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_), backwards_length (0) {}
|
||||
template <unsigned int length_>
|
||||
hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_), backwards_length (0) {}
|
||||
|
||||
template <typename U,
|
||||
hb_enable_if (hb_is_cr_convertible(U, Type))>
|
||||
hb_array_t (const hb_array_t<U> &o) :
|
||||
hb_iter_with_fallback_t<hb_array_t, Type&> (),
|
||||
arrayZ (o.arrayZ), length (o.length), backwards_length (o.backwards_length) {}
|
||||
template <typename U,
|
||||
hb_enable_if (hb_is_cr_convertible(U, Type))>
|
||||
hb_array_t& operator = (const hb_array_t<U> &o)
|
||||
{ arrayZ = o.arrayZ; length = o.length; backwards_length = o.backwards_length; return *this; }
|
||||
|
||||
/*
|
||||
* Iterator implementation.
|
||||
*/
|
||||
typedef Type& __item_t__;
|
||||
static constexpr bool is_random_access_iterator = true;
|
||||
Type& __item_at__ (unsigned i) const
|
||||
{
|
||||
if (unlikely (i >= length)) return CrapOrNull (Type);
|
||||
return arrayZ[i];
|
||||
}
|
||||
void __forward__ (unsigned n)
|
||||
{
|
||||
if (unlikely (n > length))
|
||||
n = length;
|
||||
length -= n;
|
||||
backwards_length += n;
|
||||
arrayZ += n;
|
||||
}
|
||||
void __rewind__ (unsigned n)
|
||||
{
|
||||
if (unlikely (n > backwards_length))
|
||||
n = backwards_length;
|
||||
length += n;
|
||||
backwards_length -= n;
|
||||
arrayZ -= n;
|
||||
}
|
||||
unsigned __len__ () const { return length; }
|
||||
/* Ouch. The operator== compares the contents of the array. For range-based for loops,
|
||||
* it's best if we can just compare arrayZ, though comparing contents is still fast,
|
||||
* but also would require that Type has operator==. As such, we optimize this operator
|
||||
* for range-based for loop and just compare arrayZ. No need to compare length, as we
|
||||
* assume we're only compared to .end(). */
|
||||
bool operator != (const hb_array_t& o) const
|
||||
{ return arrayZ != o.arrayZ; }
|
||||
|
||||
/* Extra operators.
|
||||
*/
|
||||
Type * operator & () const { return arrayZ; }
|
||||
operator hb_array_t<const Type> () { return hb_array_t<const Type> (arrayZ, length); }
|
||||
template <typename T> operator T * () const { return arrayZ; }
|
||||
|
||||
HB_INTERNAL bool operator == (const hb_array_t &o) const;
|
||||
|
||||
uint32_t hash () const {
|
||||
uint32_t current = 0;
|
||||
for (unsigned int i = 0; i < this->length; i++) {
|
||||
current = current * 31 + hb_hash (this->arrayZ[i]);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare, Sort, and Search.
|
||||
*/
|
||||
|
||||
/* Note: our compare is NOT lexicographic; it also does NOT call Type::cmp. */
|
||||
int cmp (const hb_array_t &a) const
|
||||
{
|
||||
if (length != a.length)
|
||||
return (int) a.length - (int) length;
|
||||
return hb_memcmp (a.arrayZ, arrayZ, get_size ());
|
||||
}
|
||||
HB_INTERNAL static int cmp (const void *pa, const void *pb)
|
||||
{
|
||||
hb_array_t *a = (hb_array_t *) pa;
|
||||
hb_array_t *b = (hb_array_t *) pb;
|
||||
return b->cmp (*a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Type *lsearch (const T &x, Type *not_found = nullptr)
|
||||
{
|
||||
unsigned i;
|
||||
return lfind (x, &i) ? &this->arrayZ[i] : not_found;
|
||||
}
|
||||
template <typename T>
|
||||
const Type *lsearch (const T &x, const Type *not_found = nullptr) const
|
||||
{
|
||||
unsigned i;
|
||||
return lfind (x, &i) ? &this->arrayZ[i] : not_found;
|
||||
}
|
||||
template <typename T>
|
||||
bool lfind (const T &x, unsigned *pos = nullptr) const
|
||||
{
|
||||
for (unsigned i = 0; i < length; ++i)
|
||||
if (hb_equal (x, this->arrayZ[i]))
|
||||
{
|
||||
if (pos)
|
||||
*pos = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
hb_sorted_array_t<Type> qsort (int (*cmp_)(const void*, const void*))
|
||||
{
|
||||
if (likely (length))
|
||||
hb_qsort (arrayZ, length, this->get_item_size (), cmp_);
|
||||
return hb_sorted_array_t<Type> (*this);
|
||||
}
|
||||
hb_sorted_array_t<Type> qsort ()
|
||||
{
|
||||
if (likely (length))
|
||||
hb_qsort (arrayZ, length, this->get_item_size (), Type::cmp);
|
||||
return hb_sorted_array_t<Type> (*this);
|
||||
}
|
||||
void qsort (unsigned int start, unsigned int end)
|
||||
{
|
||||
end = hb_min (end, length);
|
||||
assert (start <= end);
|
||||
if (likely (start < end))
|
||||
hb_qsort (arrayZ + start, end - start, this->get_item_size (), Type::cmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Other methods.
|
||||
*/
|
||||
|
||||
unsigned int get_size () const { return length * this->get_item_size (); }
|
||||
|
||||
/*
|
||||
* Reverse the order of items in this array in the range [start, end).
|
||||
*/
|
||||
void reverse (unsigned start = 0, unsigned end = -1)
|
||||
{
|
||||
start = hb_min (start, length);
|
||||
end = hb_min (end, length);
|
||||
|
||||
if (end < start + 2)
|
||||
return;
|
||||
|
||||
for (unsigned lhs = start, rhs = end - 1; lhs < rhs; lhs++, rhs--) {
|
||||
Type temp = arrayZ[rhs];
|
||||
arrayZ[rhs] = arrayZ[lhs];
|
||||
arrayZ[lhs] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
hb_array_t sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const
|
||||
{
|
||||
if (!start_offset && !seg_count)
|
||||
return *this;
|
||||
|
||||
unsigned int count = length;
|
||||
if (unlikely (start_offset > count))
|
||||
count = 0;
|
||||
else
|
||||
count -= start_offset;
|
||||
if (seg_count)
|
||||
count = *seg_count = hb_min (count, *seg_count);
|
||||
return hb_array_t (arrayZ + start_offset, count);
|
||||
}
|
||||
hb_array_t sub_array (unsigned int start_offset, unsigned int seg_count) const
|
||||
{ return sub_array (start_offset, &seg_count); }
|
||||
|
||||
hb_array_t truncate (unsigned length) const { return sub_array (0, length); }
|
||||
|
||||
template <typename T,
|
||||
unsigned P = sizeof (Type),
|
||||
hb_enable_if (P == 1)>
|
||||
const T *as () const
|
||||
{ return length < hb_min_size (T) ? &Null (T) : reinterpret_cast<const T *> (arrayZ); }
|
||||
|
||||
template <typename T,
|
||||
unsigned P = sizeof (Type),
|
||||
hb_enable_if (P == 1)>
|
||||
bool check_range (const T *p, unsigned int size = T::static_size) const
|
||||
{
|
||||
return arrayZ <= ((const char *) p)
|
||||
&& ((const char *) p) <= arrayZ + length
|
||||
&& (unsigned int) (arrayZ + length - (const char *) p) >= size;
|
||||
}
|
||||
|
||||
/* Only call if you allocated the underlying array using hb_malloc() or similar. */
|
||||
void fini ()
|
||||
{ hb_free ((void *) arrayZ); arrayZ = nullptr; length = 0; }
|
||||
|
||||
template <typename hb_serialize_context_t>
|
||||
hb_array_t copy (hb_serialize_context_t *c) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
auto* out = c->start_embed (arrayZ);
|
||||
if (unlikely (!c->extend_size (out, get_size ()))) return_trace (hb_array_t ());
|
||||
for (unsigned i = 0; i < length; i++)
|
||||
out[i] = arrayZ[i]; /* TODO: add version that calls c->copy() */
|
||||
return_trace (hb_array_t (out, length));
|
||||
}
|
||||
|
||||
template <typename hb_sanitize_context_t>
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{ return c->check_array (arrayZ, length); }
|
||||
|
||||
/*
|
||||
* Members
|
||||
*/
|
||||
|
||||
public:
|
||||
Type *arrayZ;
|
||||
unsigned int length;
|
||||
unsigned int backwards_length;
|
||||
};
|
||||
template <typename T> inline hb_array_t<T>
|
||||
hb_array (T *array, unsigned int length)
|
||||
{ return hb_array_t<T> (array, length); }
|
||||
template <typename T, unsigned int length_> inline hb_array_t<T>
|
||||
hb_array (T (&array_)[length_])
|
||||
{ return hb_array_t<T> (array_); }
|
||||
|
||||
enum hb_bfind_not_found_t
|
||||
{
|
||||
HB_BFIND_NOT_FOUND_DONT_STORE,
|
||||
HB_BFIND_NOT_FOUND_STORE,
|
||||
HB_BFIND_NOT_FOUND_STORE_CLOSEST,
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
struct hb_sorted_array_t :
|
||||
hb_iter_t<hb_sorted_array_t<Type>, Type&>,
|
||||
hb_array_t<Type>
|
||||
{
|
||||
typedef hb_iter_t<hb_sorted_array_t, Type&> iter_base_t;
|
||||
HB_ITER_USING (iter_base_t);
|
||||
static constexpr bool is_random_access_iterator = true;
|
||||
static constexpr bool is_sorted_iterator = true;
|
||||
|
||||
hb_sorted_array_t () : hb_array_t<Type> () {}
|
||||
hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {}
|
||||
template <unsigned int length_>
|
||||
hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {}
|
||||
|
||||
template <typename U,
|
||||
hb_enable_if (hb_is_cr_convertible(U, Type))>
|
||||
hb_sorted_array_t (const hb_array_t<U> &o) :
|
||||
hb_iter_t<hb_sorted_array_t, Type&> (),
|
||||
hb_array_t<Type> (o) {}
|
||||
template <typename U,
|
||||
hb_enable_if (hb_is_cr_convertible(U, Type))>
|
||||
hb_sorted_array_t& operator = (const hb_array_t<U> &o)
|
||||
{ hb_array_t<Type> (*this) = o; return *this; }
|
||||
|
||||
/* Iterator implementation. */
|
||||
bool operator != (const hb_sorted_array_t& o) const
|
||||
{ return this->arrayZ != o.arrayZ || this->length != o.length; }
|
||||
|
||||
hb_sorted_array_t sub_array (unsigned int start_offset, unsigned int *seg_count /* IN/OUT */) const
|
||||
{ return hb_sorted_array_t (((const hb_array_t<Type> *) (this))->sub_array (start_offset, seg_count)); }
|
||||
hb_sorted_array_t sub_array (unsigned int start_offset, unsigned int seg_count) const
|
||||
{ return sub_array (start_offset, &seg_count); }
|
||||
|
||||
hb_sorted_array_t truncate (unsigned length) const { return sub_array (0, length); }
|
||||
|
||||
template <typename T>
|
||||
Type *bsearch (const T &x, Type *not_found = nullptr)
|
||||
{
|
||||
unsigned int i;
|
||||
return bfind (x, &i) ? &this->arrayZ[i] : not_found;
|
||||
}
|
||||
template <typename T>
|
||||
const Type *bsearch (const T &x, const Type *not_found = nullptr) const
|
||||
{
|
||||
unsigned int i;
|
||||
return bfind (x, &i) ? &this->arrayZ[i] : not_found;
|
||||
}
|
||||
template <typename T>
|
||||
bool bfind (const T &x, unsigned int *i = nullptr,
|
||||
hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE,
|
||||
unsigned int to_store = (unsigned int) -1) const
|
||||
{
|
||||
unsigned pos;
|
||||
|
||||
if (bsearch_impl (x, &pos))
|
||||
{
|
||||
if (i)
|
||||
*i = pos;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
switch (not_found)
|
||||
{
|
||||
case HB_BFIND_NOT_FOUND_DONT_STORE:
|
||||
break;
|
||||
|
||||
case HB_BFIND_NOT_FOUND_STORE:
|
||||
*i = to_store;
|
||||
break;
|
||||
|
||||
case HB_BFIND_NOT_FOUND_STORE_CLOSEST:
|
||||
*i = pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template <typename T>
|
||||
bool bsearch_impl (const T &x, unsigned *pos) const
|
||||
{
|
||||
return hb_bsearch_impl (pos,
|
||||
x,
|
||||
this->arrayZ,
|
||||
this->length,
|
||||
sizeof (Type),
|
||||
_hb_cmp_method<T, Type>);
|
||||
}
|
||||
};
|
||||
template <typename T> inline hb_sorted_array_t<T>
|
||||
hb_sorted_array (T *array, unsigned int length)
|
||||
{ return hb_sorted_array_t<T> (array, length); }
|
||||
template <typename T, unsigned int length_> inline hb_sorted_array_t<T>
|
||||
hb_sorted_array (T (&array_)[length_])
|
||||
{ return hb_sorted_array_t<T> (array_); }
|
||||
|
||||
template <typename T>
|
||||
bool hb_array_t<T>::operator == (const hb_array_t<T> &o) const
|
||||
{
|
||||
if (o.length != this->length) return false;
|
||||
for (unsigned int i = 0; i < this->length; i++) {
|
||||
if (this->arrayZ[i] != o.arrayZ[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* TODO Specialize opeator== for hb_bytes_t and hb_ubytes_t. */
|
||||
|
||||
template <>
|
||||
inline uint32_t hb_array_t<const char>::hash () const {
|
||||
uint32_t current = 0;
|
||||
for (unsigned int i = 0; i < this->length; i++)
|
||||
current = current * 31 + (uint32_t) (this->arrayZ[i] * 2654435761u);
|
||||
return current;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline uint32_t hb_array_t<const unsigned char>::hash () const {
|
||||
uint32_t current = 0;
|
||||
for (unsigned int i = 0; i < this->length; i++)
|
||||
current = current * 31 + (uint32_t) (this->arrayZ[i] * 2654435761u);
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
typedef hb_array_t<const char> hb_bytes_t;
|
||||
typedef hb_array_t<const unsigned char> hb_ubytes_t;
|
||||
|
||||
|
||||
|
||||
#endif /* HB_ARRAY_HH */
|
||||
@@ -1,189 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2007 Chris Wilson
|
||||
* Copyright © 2009,2010 Red Hat, Inc.
|
||||
* Copyright © 2011,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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_ATOMIC_PRIVATE_HH
|
||||
#define HB_ATOMIC_PRIVATE_HH
|
||||
|
||||
#include "hb-private.hh"
|
||||
|
||||
|
||||
/* atomic_int */
|
||||
|
||||
/* We need external help for these */
|
||||
|
||||
#if defined(hb_atomic_int_impl_add) \
|
||||
&& defined(hb_atomic_ptr_impl_get) \
|
||||
&& defined(hb_atomic_ptr_impl_cmpexch)
|
||||
|
||||
/* Defined externally, i.e. in config.h; must have typedef'ed hb_atomic_int_impl_t as well. */
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__))
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/* MinGW has a convoluted history of supporting MemoryBarrier
|
||||
* properly. As such, define a function to wrap the whole
|
||||
* thing. */
|
||||
static inline void _HBMemoryBarrier (void) {
|
||||
#if !defined(MemoryBarrier)
|
||||
long dummy = 0;
|
||||
InterlockedExchange (&dummy, 1);
|
||||
#else
|
||||
MemoryBarrier ();
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef LONG hb_atomic_int_impl_t;
|
||||
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
|
||||
#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd (&(AI), (V))
|
||||
|
||||
#define hb_atomic_ptr_impl_get(P) (_HBMemoryBarrier (), (void *) *(P))
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(__APPLE__)
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
#ifdef __MAC_OS_X_MIN_REQUIRED
|
||||
#include <AvailabilityMacros.h>
|
||||
#elif defined(__IPHONE_OS_MIN_REQUIRED)
|
||||
#include <Availability.h>
|
||||
#endif
|
||||
|
||||
|
||||
typedef int32_t hb_atomic_int_impl_t;
|
||||
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
|
||||
#define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
|
||||
|
||||
#define hb_atomic_ptr_impl_get(P) (OSMemoryBarrier (), (void *) *(P))
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100)
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
|
||||
#else
|
||||
#if __ppc64__ || __x86_64__ || __aarch64__
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P))
|
||||
#else
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
|
||||
|
||||
typedef int hb_atomic_int_impl_t;
|
||||
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
|
||||
#define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add (&(AI), (V))
|
||||
|
||||
#define hb_atomic_ptr_impl_get(P) (void *) (__sync_synchronize (), *(P))
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N))
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(HAVE_SOLARIS_ATOMIC_OPS)
|
||||
|
||||
#include <atomic.h>
|
||||
#include <mbarrier.h>
|
||||
|
||||
typedef unsigned int hb_atomic_int_impl_t;
|
||||
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
|
||||
#define hb_atomic_int_impl_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V))
|
||||
|
||||
#define hb_atomic_ptr_impl_get(P) ( ({__machine_rw_barrier ();}), (void *) *(P))
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false)
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(_AIX) && defined(__IBMCPP__)
|
||||
|
||||
#include <builtins.h>
|
||||
|
||||
|
||||
static inline int _hb_fetch_and_add(volatile int* AI, unsigned int V) {
|
||||
__lwsync();
|
||||
int result = __fetch_and_add(AI, V);
|
||||
__isync();
|
||||
return result;
|
||||
}
|
||||
static inline int _hb_compare_and_swaplp(volatile long* P, long O, long N) {
|
||||
__sync();
|
||||
int result = __compare_and_swaplp (P, &O, N);
|
||||
__sync();
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef int hb_atomic_int_impl_t;
|
||||
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
|
||||
#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add (&(AI), (V))
|
||||
|
||||
#define hb_atomic_ptr_impl_get(P) (__sync(), (void *) *(P))
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N))
|
||||
|
||||
#elif !defined(HB_NO_MT)
|
||||
|
||||
#define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */
|
||||
|
||||
typedef volatile int hb_atomic_int_impl_t;
|
||||
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
|
||||
#define hb_atomic_int_impl_add(AI, V) (((AI) += (V)) - (V))
|
||||
|
||||
#define hb_atomic_ptr_impl_get(P) ((void *) *(P))
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false)
|
||||
|
||||
|
||||
#else /* HB_NO_MT */
|
||||
|
||||
typedef int hb_atomic_int_impl_t;
|
||||
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
|
||||
#define hb_atomic_int_impl_add(AI, V) (((AI) += (V)) - (V))
|
||||
|
||||
#define hb_atomic_ptr_impl_get(P) ((void *) *(P))
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define HB_ATOMIC_INT_INIT(V) {HB_ATOMIC_INT_IMPL_INIT(V)}
|
||||
|
||||
struct hb_atomic_int_t
|
||||
{
|
||||
hb_atomic_int_impl_t v;
|
||||
|
||||
inline void set_unsafe (int v_) { v = v_; }
|
||||
inline int get_unsafe (void) const { return v; }
|
||||
inline int inc (void) { return hb_atomic_int_impl_add (const_cast<hb_atomic_int_impl_t &> (v), 1); }
|
||||
inline int dec (void) { return hb_atomic_int_impl_add (const_cast<hb_atomic_int_impl_t &> (v), -1); }
|
||||
};
|
||||
|
||||
|
||||
#define hb_atomic_ptr_get(P) hb_atomic_ptr_impl_get(P)
|
||||
#define hb_atomic_ptr_cmpexch(P,O,N) hb_atomic_ptr_impl_cmpexch((P),(O),(N))
|
||||
|
||||
|
||||
#endif /* HB_ATOMIC_PRIVATE_HH */
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright © 2007 Chris Wilson
|
||||
* Copyright © 2009,2010 Red Hat, Inc.
|
||||
* Copyright © 2011,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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_ATOMIC_HH
|
||||
#define HB_ATOMIC_HH
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-meta.hh"
|
||||
|
||||
|
||||
/*
|
||||
* Atomic integers and pointers.
|
||||
*/
|
||||
|
||||
|
||||
/* We need external help for these */
|
||||
|
||||
#if defined(hb_atomic_int_impl_add) \
|
||||
&& defined(hb_atomic_ptr_impl_get) \
|
||||
&& defined(hb_atomic_ptr_impl_cmpexch)
|
||||
|
||||
/* Defined externally, i.e. in config.h. */
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT) && defined(__ATOMIC_ACQUIRE)
|
||||
|
||||
/* C++11-style GCC primitives. We prefer these as they don't require linking to libstdc++ / libc++. */
|
||||
|
||||
#define _hb_memory_barrier() __sync_synchronize ()
|
||||
|
||||
#define hb_atomic_int_impl_add(AI, V) __atomic_fetch_add ((AI), (V), __ATOMIC_ACQ_REL)
|
||||
#define hb_atomic_int_impl_set_relaxed(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELAXED)
|
||||
#define hb_atomic_int_impl_set(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELEASE)
|
||||
#define hb_atomic_int_impl_get_relaxed(AI) __atomic_load_n ((AI), __ATOMIC_RELAXED)
|
||||
#define hb_atomic_int_impl_get(AI) __atomic_load_n ((AI), __ATOMIC_ACQUIRE)
|
||||
|
||||
#define hb_atomic_ptr_impl_set_relaxed(P, V) __atomic_store_n ((P), (V), __ATOMIC_RELAXED)
|
||||
#define hb_atomic_ptr_impl_get_relaxed(P) __atomic_load_n ((P), __ATOMIC_RELAXED)
|
||||
#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_ACQUIRE)
|
||||
static inline bool
|
||||
_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
|
||||
{
|
||||
const void *O = O_; // Need lvalue
|
||||
return __atomic_compare_exchange_n ((void **) P, (void **) &O, (void *) N, true, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED);
|
||||
}
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))
|
||||
|
||||
|
||||
#elif !defined(HB_NO_MT)
|
||||
|
||||
/* C++11 atomics. */
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#define _hb_memory_barrier() std::atomic_thread_fence(std::memory_order_ack_rel)
|
||||
#define _hb_memory_r_barrier() std::atomic_thread_fence(std::memory_order_acquire)
|
||||
#define _hb_memory_w_barrier() std::atomic_thread_fence(std::memory_order_release)
|
||||
|
||||
#define hb_atomic_int_impl_add(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->fetch_add ((V), std::memory_order_acq_rel))
|
||||
#define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->store ((V), std::memory_order_relaxed))
|
||||
#define hb_atomic_int_impl_set(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->store ((V), std::memory_order_release))
|
||||
#define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast<std::atomic<int> const *> (AI)->load (std::memory_order_relaxed))
|
||||
#define hb_atomic_int_impl_get(AI) (reinterpret_cast<std::atomic<int> const *> (AI)->load (std::memory_order_acquire))
|
||||
|
||||
#define hb_atomic_ptr_impl_set_relaxed(P, V) (reinterpret_cast<std::atomic<void*> *> (P)->store ((V), std::memory_order_relaxed))
|
||||
#define hb_atomic_ptr_impl_get_relaxed(P) (reinterpret_cast<std::atomic<void*> const *> (P)->load (std::memory_order_relaxed))
|
||||
#define hb_atomic_ptr_impl_get(P) (reinterpret_cast<std::atomic<void*> *> (P)->load (std::memory_order_acquire))
|
||||
static inline bool
|
||||
_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
|
||||
{
|
||||
const void *O = O_; // Need lvalue
|
||||
return reinterpret_cast<std::atomic<const void*> *> (P)->compare_exchange_weak (O, N, std::memory_order_acq_rel, std::memory_order_relaxed);
|
||||
}
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))
|
||||
|
||||
|
||||
#elif defined(HB_NO_MT)
|
||||
|
||||
#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V))
|
||||
|
||||
#define _hb_memory_barrier() do {} while (0)
|
||||
|
||||
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false)
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#error "Could not find any system to define atomic_int macros."
|
||||
#error "Check hb-atomic.hh for possible resolutions."
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _hb_memory_r_barrier
|
||||
#define _hb_memory_r_barrier() _hb_memory_barrier ()
|
||||
#endif
|
||||
#ifndef _hb_memory_w_barrier
|
||||
#define _hb_memory_w_barrier() _hb_memory_barrier ()
|
||||
#endif
|
||||
#ifndef hb_atomic_int_impl_set_relaxed
|
||||
#define hb_atomic_int_impl_set_relaxed(AI, V) (*(AI) = (V))
|
||||
#endif
|
||||
#ifndef hb_atomic_int_impl_get_relaxed
|
||||
#define hb_atomic_int_impl_get_relaxed(AI) (*(AI))
|
||||
#endif
|
||||
|
||||
#ifndef hb_atomic_ptr_impl_set_relaxed
|
||||
#define hb_atomic_ptr_impl_set_relaxed(P, V) (*(P) = (V))
|
||||
#endif
|
||||
#ifndef hb_atomic_ptr_impl_get_relaxed
|
||||
#define hb_atomic_ptr_impl_get_relaxed(P) (*(P))
|
||||
#endif
|
||||
#ifndef hb_atomic_int_impl_set
|
||||
inline void hb_atomic_int_impl_set (int *AI, int v) { _hb_memory_w_barrier (); *AI = v; }
|
||||
#endif
|
||||
#ifndef hb_atomic_int_impl_get
|
||||
inline int hb_atomic_int_impl_get (const int *AI) { int v = *AI; _hb_memory_r_barrier (); return v; }
|
||||
#endif
|
||||
#ifndef hb_atomic_ptr_impl_get
|
||||
inline void *hb_atomic_ptr_impl_get (void ** const P) { void *v = *P; _hb_memory_r_barrier (); return v; }
|
||||
#endif
|
||||
|
||||
|
||||
struct hb_atomic_int_t
|
||||
{
|
||||
hb_atomic_int_t () = default;
|
||||
constexpr hb_atomic_int_t (int v) : v (v) {}
|
||||
|
||||
void set_relaxed (int v_) { hb_atomic_int_impl_set_relaxed (&v, v_); }
|
||||
void set (int v_) { hb_atomic_int_impl_set (&v, v_); }
|
||||
int get_relaxed () const { return hb_atomic_int_impl_get_relaxed (&v); }
|
||||
int get () const { return hb_atomic_int_impl_get (&v); }
|
||||
int inc () { return hb_atomic_int_impl_add (&v, 1); }
|
||||
int dec () { return hb_atomic_int_impl_add (&v, -1); }
|
||||
|
||||
int v = 0;
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
struct hb_atomic_ptr_t
|
||||
{
|
||||
typedef hb_remove_pointer<P> T;
|
||||
|
||||
hb_atomic_ptr_t () = default;
|
||||
constexpr hb_atomic_ptr_t (T* v) : v (v) {}
|
||||
|
||||
void init (T* v_ = nullptr) { set_relaxed (v_); }
|
||||
void set_relaxed (T* v_) { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
|
||||
T *get_relaxed () const { return (T *) hb_atomic_ptr_impl_get_relaxed (&v); }
|
||||
T *get () const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); }
|
||||
bool cmpexch (const T *old, T *new_) const { return hb_atomic_ptr_impl_cmpexch ((void **) &v, (void *) old, (void *) new_); }
|
||||
|
||||
T * operator -> () const { return get (); }
|
||||
template <typename C> operator C * () const { return get (); }
|
||||
|
||||
T *v = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif /* HB_ATOMIC_HH */
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright © 2019 Adobe 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.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
|
||||
#ifndef HB_BIMAP_HH
|
||||
#define HB_BIMAP_HH
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-map.hh"
|
||||
|
||||
/* Bi-directional map */
|
||||
struct hb_bimap_t
|
||||
{
|
||||
hb_bimap_t () { init (); }
|
||||
~hb_bimap_t () { fini (); }
|
||||
|
||||
void init ()
|
||||
{
|
||||
forw_map.init ();
|
||||
back_map.init ();
|
||||
}
|
||||
|
||||
void fini ()
|
||||
{
|
||||
forw_map.fini ();
|
||||
back_map.fini ();
|
||||
}
|
||||
|
||||
void reset ()
|
||||
{
|
||||
forw_map.reset ();
|
||||
back_map.reset ();
|
||||
}
|
||||
|
||||
bool in_error () const { return forw_map.in_error () || back_map.in_error (); }
|
||||
|
||||
void set (hb_codepoint_t lhs, hb_codepoint_t rhs)
|
||||
{
|
||||
if (unlikely (lhs == HB_MAP_VALUE_INVALID)) return;
|
||||
if (unlikely (rhs == HB_MAP_VALUE_INVALID)) { del (lhs); return; }
|
||||
forw_map.set (lhs, rhs);
|
||||
back_map.set (rhs, lhs);
|
||||
}
|
||||
|
||||
hb_codepoint_t get (hb_codepoint_t lhs) const { return forw_map.get (lhs); }
|
||||
hb_codepoint_t backward (hb_codepoint_t rhs) const { return back_map.get (rhs); }
|
||||
|
||||
hb_codepoint_t operator [] (hb_codepoint_t lhs) const { return get (lhs); }
|
||||
bool has (hb_codepoint_t lhs, hb_codepoint_t *vp = nullptr) const { return forw_map.has (lhs, vp); }
|
||||
|
||||
void del (hb_codepoint_t lhs)
|
||||
{
|
||||
back_map.del (get (lhs));
|
||||
forw_map.del (lhs);
|
||||
}
|
||||
|
||||
void clear ()
|
||||
{
|
||||
forw_map.clear ();
|
||||
back_map.clear ();
|
||||
}
|
||||
|
||||
bool is_empty () const { return get_population () == 0; }
|
||||
|
||||
unsigned int get_population () const { return forw_map.get_population (); }
|
||||
|
||||
protected:
|
||||
hb_map_t forw_map;
|
||||
hb_map_t back_map;
|
||||
};
|
||||
|
||||
/* Inremental bimap: only lhs is given, rhs is incrementally assigned */
|
||||
struct hb_inc_bimap_t : hb_bimap_t
|
||||
{
|
||||
hb_inc_bimap_t () { init (); }
|
||||
|
||||
void init ()
|
||||
{
|
||||
hb_bimap_t::init ();
|
||||
next_value = 0;
|
||||
}
|
||||
|
||||
/* Add a mapping from lhs to rhs with a unique value if lhs is unknown.
|
||||
* Return the rhs value as the result.
|
||||
*/
|
||||
hb_codepoint_t add (hb_codepoint_t lhs)
|
||||
{
|
||||
hb_codepoint_t rhs = forw_map[lhs];
|
||||
if (rhs == HB_MAP_VALUE_INVALID)
|
||||
{
|
||||
rhs = next_value++;
|
||||
set (lhs, rhs);
|
||||
}
|
||||
return rhs;
|
||||
}
|
||||
|
||||
hb_codepoint_t skip ()
|
||||
{ return next_value++; }
|
||||
|
||||
hb_codepoint_t get_next_value () const
|
||||
{ return next_value; }
|
||||
|
||||
void add_set (const hb_set_t *set)
|
||||
{
|
||||
hb_codepoint_t i = HB_SET_VALUE_INVALID;
|
||||
while (hb_set_next (set, &i)) add (i);
|
||||
}
|
||||
|
||||
/* Create an identity map. */
|
||||
bool identity (unsigned int size)
|
||||
{
|
||||
clear ();
|
||||
for (hb_codepoint_t i = 0; i < size; i++) set (i, i);
|
||||
return !in_error ();
|
||||
}
|
||||
|
||||
protected:
|
||||
static int cmp_id (const void* a, const void* b)
|
||||
{ return (int)*(const hb_codepoint_t *)a - (int)*(const hb_codepoint_t *)b; }
|
||||
|
||||
public:
|
||||
/* Optional: after finished adding all mappings in a random order,
|
||||
* reassign rhs to lhs so that they are in the same order. */
|
||||
void sort ()
|
||||
{
|
||||
hb_codepoint_t count = get_population ();
|
||||
hb_vector_t <hb_codepoint_t> work;
|
||||
work.resize (count);
|
||||
|
||||
for (hb_codepoint_t rhs = 0; rhs < count; rhs++)
|
||||
work[rhs] = back_map[rhs];
|
||||
|
||||
work.qsort (cmp_id);
|
||||
|
||||
clear ();
|
||||
for (hb_codepoint_t rhs = 0; rhs < count; rhs++)
|
||||
set (work[rhs], rhs);
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned int next_value;
|
||||
};
|
||||
|
||||
#endif /* HB_BIMAP_HH */
|
||||
+434
-136
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright © 2009 Red Hat, Inc.
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* This is part of HarfBuzz, a text shaping library.
|
||||
*
|
||||
@@ -24,14 +25,8 @@
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
/* http://www.oracle.com/technetwork/articles/servers-storage-dev/standardheaderfiles-453865.html */
|
||||
#ifndef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199309L
|
||||
#endif
|
||||
|
||||
#include "hb-private.hh"
|
||||
|
||||
#include "hb-object-private.hh"
|
||||
#include "hb.hh"
|
||||
#include "hb-blob.hh"
|
||||
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
@@ -40,50 +35,27 @@
|
||||
#include <sys/mman.h>
|
||||
#endif /* HAVE_SYS_MMAN_H */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
/**
|
||||
* SECTION: hb-blob
|
||||
* @title: hb-blob
|
||||
* @short_description: Binary data containers
|
||||
* @include: hb.h
|
||||
*
|
||||
* Blobs wrap a chunk of binary data to handle lifecycle management of data
|
||||
* while it is passed between client and HarfBuzz. Blobs are primarily used
|
||||
* to create font faces, but also to access font face tables, as well as
|
||||
* pass around other binary data.
|
||||
**/
|
||||
|
||||
|
||||
#ifndef HB_DEBUG_BLOB
|
||||
#define HB_DEBUG_BLOB (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
|
||||
struct hb_blob_t {
|
||||
hb_object_header_t header;
|
||||
ASSERT_POD ();
|
||||
|
||||
bool immutable;
|
||||
|
||||
const char *data;
|
||||
unsigned int length;
|
||||
hb_memory_mode_t mode;
|
||||
|
||||
void *user_data;
|
||||
hb_destroy_func_t destroy;
|
||||
};
|
||||
|
||||
|
||||
static bool _try_writable (hb_blob_t *blob);
|
||||
|
||||
static void
|
||||
_hb_blob_destroy_user_data (hb_blob_t *blob)
|
||||
{
|
||||
if (blob->destroy) {
|
||||
blob->destroy (blob->user_data);
|
||||
blob->user_data = NULL;
|
||||
blob->destroy = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_blob_create: (skip)
|
||||
* @data: 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.
|
||||
* @destroy: (nullable): 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.
|
||||
@@ -100,16 +72,54 @@ hb_blob_create (const char *data,
|
||||
void *user_data,
|
||||
hb_destroy_func_t destroy)
|
||||
{
|
||||
hb_blob_t *blob;
|
||||
|
||||
if (!length ||
|
||||
length >= 1u << 31 ||
|
||||
!(blob = hb_object_create<hb_blob_t> ())) {
|
||||
if (!length)
|
||||
{
|
||||
if (destroy)
|
||||
destroy (user_data);
|
||||
return hb_blob_get_empty ();
|
||||
}
|
||||
|
||||
hb_blob_t *blob = hb_blob_create_or_fail (data, length, mode,
|
||||
user_data, destroy);
|
||||
return likely (blob) ? blob : hb_blob_get_empty ();
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_blob_create_or_fail: (skip)
|
||||
* @data: Pointer to blob data.
|
||||
* @length: Length of @data in bytes.
|
||||
* @mode: Memory mode for @data.
|
||||
* @user_data: Data parameter to pass to @destroy.
|
||||
* @destroy: (nullable): 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.
|
||||
*
|
||||
* Note that this function returns a freshly-allocated empty blob even if @length
|
||||
* is zero. This is in contrast to hb_blob_create(), which returns the singleton
|
||||
* empty blob (as returned by hb_blob_get_empty()) if @length is zero.
|
||||
*
|
||||
* Return value: New blob, or %NULL if failed. Destroy with hb_blob_destroy().
|
||||
*
|
||||
* Since: 2.8.2
|
||||
**/
|
||||
hb_blob_t *
|
||||
hb_blob_create_or_fail (const char *data,
|
||||
unsigned int length,
|
||||
hb_memory_mode_t mode,
|
||||
void *user_data,
|
||||
hb_destroy_func_t destroy)
|
||||
{
|
||||
hb_blob_t *blob;
|
||||
|
||||
if (length >= 1u << 31 ||
|
||||
!(blob = hb_object_create<hb_blob_t> ()))
|
||||
{
|
||||
if (destroy)
|
||||
destroy (user_data);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
blob->data = data;
|
||||
blob->length = length;
|
||||
blob->mode = mode;
|
||||
@@ -119,15 +129,22 @@ hb_blob_create (const char *data,
|
||||
|
||||
if (blob->mode == HB_MEMORY_MODE_DUPLICATE) {
|
||||
blob->mode = HB_MEMORY_MODE_READONLY;
|
||||
if (!_try_writable (blob)) {
|
||||
if (!blob->try_make_writable ())
|
||||
{
|
||||
hb_blob_destroy (blob);
|
||||
return hb_blob_get_empty ();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
static void
|
||||
_hb_blob_destroy (void *data)
|
||||
{
|
||||
hb_blob_destroy ((hb_blob_t *) data);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_blob_create_sub_blob:
|
||||
* @parent: Parent blob.
|
||||
@@ -135,7 +152,7 @@ hb_blob_create (const char *data,
|
||||
* @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
|
||||
* 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.
|
||||
@@ -155,16 +172,41 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
|
||||
{
|
||||
hb_blob_t *blob;
|
||||
|
||||
if (!length || offset >= parent->length)
|
||||
if (!length || !parent || offset >= parent->length)
|
||||
return hb_blob_get_empty ();
|
||||
|
||||
hb_blob_make_immutable (parent);
|
||||
|
||||
blob = hb_blob_create (parent->data + offset,
|
||||
MIN (length, parent->length - offset),
|
||||
hb_min (length, parent->length - offset),
|
||||
HB_MEMORY_MODE_READONLY,
|
||||
hb_blob_reference (parent),
|
||||
(hb_destroy_func_t) hb_blob_destroy);
|
||||
_hb_blob_destroy);
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_blob_copy_writable_or_fail:
|
||||
* @blob: A blob.
|
||||
*
|
||||
* Makes a writable copy of @blob.
|
||||
*
|
||||
* Return value: The new blob, or nullptr if allocation failed
|
||||
*
|
||||
* Since: 1.8.0
|
||||
**/
|
||||
hb_blob_t *
|
||||
hb_blob_copy_writable_or_fail (hb_blob_t *blob)
|
||||
{
|
||||
blob = hb_blob_create (blob->data,
|
||||
blob->length,
|
||||
HB_MEMORY_MODE_DUPLICATE,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
if (unlikely (blob == hb_blob_get_empty ()))
|
||||
blob = nullptr;
|
||||
|
||||
return blob;
|
||||
}
|
||||
@@ -176,27 +218,14 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
|
||||
*
|
||||
* See TODO:link object types for more information.
|
||||
*
|
||||
* Return value: (transfer full): the empty blob.
|
||||
* Return value: (transfer full): The empty blob.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
hb_blob_t *
|
||||
hb_blob_get_empty (void)
|
||||
hb_blob_get_empty ()
|
||||
{
|
||||
static const hb_blob_t _hb_blob_nil = {
|
||||
HB_OBJECT_HEADER_STATIC,
|
||||
|
||||
true, /* immutable */
|
||||
|
||||
NULL, /* data */
|
||||
0, /* length */
|
||||
HB_MEMORY_MODE_READONLY, /* mode */
|
||||
|
||||
NULL, /* user_data */
|
||||
NULL /* destroy */
|
||||
};
|
||||
|
||||
return const_cast<hb_blob_t *> (&_hb_blob_nil);
|
||||
return const_cast<hb_blob_t *> (&Null (hb_blob_t));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +250,7 @@ hb_blob_reference (hb_blob_t *blob)
|
||||
* hb_blob_destroy: (skip)
|
||||
* @blob: a blob.
|
||||
*
|
||||
* Descreases the reference count on @blob, and if it reaches zero, destroys
|
||||
* Decreases 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.
|
||||
*
|
||||
@@ -234,20 +263,22 @@ hb_blob_destroy (hb_blob_t *blob)
|
||||
{
|
||||
if (!hb_object_destroy (blob)) return;
|
||||
|
||||
_hb_blob_destroy_user_data (blob);
|
||||
blob->fini_shallow ();
|
||||
|
||||
free (blob);
|
||||
hb_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.
|
||||
* @blob: An #hb_blob_t
|
||||
* @key: The user-data key to set
|
||||
* @data: A pointer to the user data to set
|
||||
* @destroy: (nullable): A callback to call when @data is not needed anymore
|
||||
* @replace: Whether to replace an existing data with the same key
|
||||
*
|
||||
* Return value:
|
||||
* Attaches a user-data key/data pair to the specified blob.
|
||||
*
|
||||
* Return value: %true if success, %false otherwise
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -263,12 +294,13 @@ hb_blob_set_user_data (hb_blob_t *blob,
|
||||
|
||||
/**
|
||||
* hb_blob_get_user_data: (skip)
|
||||
* @blob: a blob.
|
||||
* @key: key for data to get.
|
||||
* @blob: a blob
|
||||
* @key: The user-data key to query
|
||||
*
|
||||
*
|
||||
* Fetches the user data associated with the specified key,
|
||||
* attached to the specified font-functions structure.
|
||||
*
|
||||
* Return value: (transfer none):
|
||||
* Return value: (transfer none): A pointer to the user data
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -282,35 +314,35 @@ hb_blob_get_user_data (hb_blob_t *blob,
|
||||
|
||||
/**
|
||||
* hb_blob_make_immutable:
|
||||
* @blob: a blob.
|
||||
* @blob: a blob
|
||||
*
|
||||
*
|
||||
* Makes a blob immutable.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
void
|
||||
hb_blob_make_immutable (hb_blob_t *blob)
|
||||
{
|
||||
if (hb_object_is_inert (blob))
|
||||
if (hb_object_is_immutable (blob))
|
||||
return;
|
||||
|
||||
blob->immutable = true;
|
||||
hb_object_make_immutable (blob);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_blob_is_immutable:
|
||||
* @blob: a blob.
|
||||
*
|
||||
*
|
||||
* Tests whether a blob is immutable.
|
||||
*
|
||||
* Return value: TODO
|
||||
* Return value: %true if @blob is immutable, %false otherwise
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_blob_is_immutable (hb_blob_t *blob)
|
||||
{
|
||||
return blob->immutable;
|
||||
return hb_object_is_immutable (blob);
|
||||
}
|
||||
|
||||
|
||||
@@ -318,27 +350,26 @@ hb_blob_is_immutable (hb_blob_t *blob)
|
||||
* hb_blob_get_length:
|
||||
* @blob: a blob.
|
||||
*
|
||||
*
|
||||
* Fetches the length of a blob's data.
|
||||
*
|
||||
* Return value: the length of blob data in bytes.
|
||||
* Return value: the length of @blob data in bytes.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
unsigned int
|
||||
hb_blob_get_length (hb_blob_t *blob)
|
||||
{
|
||||
if(unlikely(!blob)) return 0; // wallpaper TenFourFox issue 309
|
||||
return blob->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_blob_get_data:
|
||||
* @blob: a blob.
|
||||
* @length: (out):
|
||||
* @length: (out): The length in bytes of the data retrieved
|
||||
*
|
||||
*
|
||||
* Fetches the data from a blob.
|
||||
*
|
||||
* Returns: (transfer none) (array length=length):
|
||||
* Returns: (transfer none) (array length=length): the byte data of @blob.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -370,22 +401,20 @@ hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
|
||||
char *
|
||||
hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
|
||||
{
|
||||
if (!_try_writable (blob)) {
|
||||
if (length)
|
||||
*length = 0;
|
||||
|
||||
return NULL;
|
||||
if (hb_object_is_immutable (blob) ||
|
||||
!blob->try_make_writable ())
|
||||
{
|
||||
if (length) *length = 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (length)
|
||||
*length = blob->length;
|
||||
|
||||
if (length) *length = blob->length;
|
||||
return const_cast<char *> (blob->data);
|
||||
}
|
||||
|
||||
|
||||
static hb_bool_t
|
||||
_try_make_writable_inplace_unix (hb_blob_t *blob)
|
||||
bool
|
||||
hb_blob_t::try_make_writable_inplace_unix ()
|
||||
{
|
||||
#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT)
|
||||
uintptr_t pagesize = -1, mask, length;
|
||||
@@ -400,25 +429,25 @@ _try_make_writable_inplace_unix (hb_blob_t *blob)
|
||||
#endif
|
||||
|
||||
if ((uintptr_t) -1L == pagesize) {
|
||||
DEBUG_MSG_FUNC (BLOB, blob, "failed to get pagesize: %s", strerror (errno));
|
||||
DEBUG_MSG_FUNC (BLOB, this, "failed to get pagesize: %s", strerror (errno));
|
||||
return false;
|
||||
}
|
||||
DEBUG_MSG_FUNC (BLOB, blob, "pagesize is %lu", (unsigned long) pagesize);
|
||||
DEBUG_MSG_FUNC (BLOB, this, "pagesize is %lu", (unsigned long) pagesize);
|
||||
|
||||
mask = ~(pagesize-1);
|
||||
addr = (const char *) (((uintptr_t) blob->data) & mask);
|
||||
length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr;
|
||||
DEBUG_MSG_FUNC (BLOB, blob,
|
||||
addr = (const char *) (((uintptr_t) this->data) & mask);
|
||||
length = (const char *) (((uintptr_t) this->data + this->length + pagesize-1) & mask) - addr;
|
||||
DEBUG_MSG_FUNC (BLOB, this,
|
||||
"calling mprotect on [%p..%p] (%lu bytes)",
|
||||
addr, addr+length, (unsigned long) length);
|
||||
if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) {
|
||||
DEBUG_MSG_FUNC (BLOB, blob, "mprotect failed: %s", strerror (errno));
|
||||
DEBUG_MSG_FUNC (BLOB, this, "mprotect failed: %s", strerror (errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
blob->mode = HB_MEMORY_MODE_WRITABLE;
|
||||
this->mode = HB_MEMORY_MODE_WRITABLE;
|
||||
|
||||
DEBUG_MSG_FUNC (BLOB, blob,
|
||||
DEBUG_MSG_FUNC (BLOB, this,
|
||||
"successfully made [%p..%p] (%lu bytes) writable\n",
|
||||
addr, addr+length, (unsigned long) length);
|
||||
return true;
|
||||
@@ -427,53 +456,322 @@ _try_make_writable_inplace_unix (hb_blob_t *blob)
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
_try_writable_inplace (hb_blob_t *blob)
|
||||
bool
|
||||
hb_blob_t::try_make_writable_inplace ()
|
||||
{
|
||||
DEBUG_MSG_FUNC (BLOB, blob, "making writable inplace\n");
|
||||
DEBUG_MSG_FUNC (BLOB, this, "making writable inplace\n");
|
||||
|
||||
if (_try_make_writable_inplace_unix (blob))
|
||||
if (this->try_make_writable_inplace_unix ())
|
||||
return true;
|
||||
|
||||
DEBUG_MSG_FUNC (BLOB, blob, "making writable -> FAILED\n");
|
||||
DEBUG_MSG_FUNC (BLOB, this, "making writable -> FAILED\n");
|
||||
|
||||
/* Failed to make writable inplace, mark that */
|
||||
blob->mode = HB_MEMORY_MODE_READONLY;
|
||||
this->mode = HB_MEMORY_MODE_READONLY;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
_try_writable (hb_blob_t *blob)
|
||||
bool
|
||||
hb_blob_t::try_make_writable ()
|
||||
{
|
||||
if (blob->immutable)
|
||||
return false;
|
||||
if (unlikely (!length))
|
||||
mode = HB_MEMORY_MODE_WRITABLE;
|
||||
|
||||
if (blob->mode == HB_MEMORY_MODE_WRITABLE)
|
||||
if (this->mode == HB_MEMORY_MODE_WRITABLE)
|
||||
return true;
|
||||
|
||||
if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE && _try_writable_inplace (blob))
|
||||
if (this->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE && this->try_make_writable_inplace ())
|
||||
return true;
|
||||
|
||||
if (blob->mode == HB_MEMORY_MODE_WRITABLE)
|
||||
if (this->mode == HB_MEMORY_MODE_WRITABLE)
|
||||
return true;
|
||||
|
||||
|
||||
DEBUG_MSG_FUNC (BLOB, blob, "current data is -> %p\n", blob->data);
|
||||
DEBUG_MSG_FUNC (BLOB, this, "current data is -> %p\n", this->data);
|
||||
|
||||
char *new_data;
|
||||
|
||||
new_data = (char *) malloc (blob->length);
|
||||
new_data = (char *) hb_malloc (this->length);
|
||||
if (unlikely (!new_data))
|
||||
return false;
|
||||
|
||||
DEBUG_MSG_FUNC (BLOB, blob, "dupped successfully -> %p\n", blob->data);
|
||||
DEBUG_MSG_FUNC (BLOB, this, "dupped successfully -> %p\n", this->data);
|
||||
|
||||
memcpy (new_data, blob->data, blob->length);
|
||||
_hb_blob_destroy_user_data (blob);
|
||||
blob->mode = HB_MEMORY_MODE_WRITABLE;
|
||||
blob->data = new_data;
|
||||
blob->user_data = new_data;
|
||||
blob->destroy = free;
|
||||
memcpy (new_data, this->data, this->length);
|
||||
this->destroy_user_data ();
|
||||
this->mode = HB_MEMORY_MODE_WRITABLE;
|
||||
this->data = new_data;
|
||||
this->user_data = new_data;
|
||||
this->destroy = hb_free;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mmap
|
||||
*/
|
||||
|
||||
#ifndef HB_NO_OPEN
|
||||
#ifdef HAVE_MMAP
|
||||
# if !defined(HB_NO_RESOURCE_FORK) && defined(__APPLE__)
|
||||
# include <sys/paths.h>
|
||||
# endif
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
# ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef MAP_NORESERVE
|
||||
# define MAP_NORESERVE 0
|
||||
#endif
|
||||
|
||||
struct hb_mapped_file_t
|
||||
{
|
||||
char *contents;
|
||||
unsigned long length;
|
||||
#ifdef _WIN32
|
||||
HANDLE mapping;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if (defined(HAVE_MMAP) || defined(_WIN32)) && !defined(HB_NO_MMAP)
|
||||
static void
|
||||
_hb_mapped_file_destroy (void *file_)
|
||||
{
|
||||
hb_mapped_file_t *file = (hb_mapped_file_t *) file_;
|
||||
#ifdef HAVE_MMAP
|
||||
munmap (file->contents, file->length);
|
||||
#elif defined(_WIN32)
|
||||
UnmapViewOfFile (file->contents);
|
||||
CloseHandle (file->mapping);
|
||||
#else
|
||||
assert (0); // If we don't have mmap we shouldn't reach here
|
||||
#endif
|
||||
|
||||
hb_free (file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _PATH_RSRCFORKSPEC
|
||||
static int
|
||||
_open_resource_fork (const char *file_name, hb_mapped_file_t *file)
|
||||
{
|
||||
size_t name_len = strlen (file_name);
|
||||
size_t len = name_len + sizeof (_PATH_RSRCFORKSPEC);
|
||||
|
||||
char *rsrc_name = (char *) hb_malloc (len);
|
||||
if (unlikely (!rsrc_name)) return -1;
|
||||
|
||||
strncpy (rsrc_name, file_name, name_len);
|
||||
strncpy (rsrc_name + name_len, _PATH_RSRCFORKSPEC,
|
||||
sizeof (_PATH_RSRCFORKSPEC) - 1);
|
||||
|
||||
int fd = open (rsrc_name, O_RDONLY | O_BINARY, 0);
|
||||
hb_free (rsrc_name);
|
||||
|
||||
if (fd != -1)
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat (fd, &st) != -1)
|
||||
file->length = (unsigned long) st.st_size;
|
||||
else
|
||||
{
|
||||
close (fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* hb_blob_create_from_file:
|
||||
* @file_name: A font filename
|
||||
*
|
||||
* Creates a new blob containing the data from the
|
||||
* specified binary font file.
|
||||
*
|
||||
* Returns: An #hb_blob_t pointer with the content of the file,
|
||||
* or hb_blob_get_empty() if failed.
|
||||
*
|
||||
* Since: 1.7.7
|
||||
**/
|
||||
hb_blob_t *
|
||||
hb_blob_create_from_file (const char *file_name)
|
||||
{
|
||||
hb_blob_t *blob = hb_blob_create_from_file_or_fail (file_name);
|
||||
return likely (blob) ? blob : hb_blob_get_empty ();
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_blob_create_from_file_or_fail:
|
||||
* @file_name: A font filename
|
||||
*
|
||||
* Creates a new blob containing the data from the
|
||||
* specified binary font file.
|
||||
*
|
||||
* Returns: An #hb_blob_t pointer with the content of the file,
|
||||
* or %NULL if failed.
|
||||
*
|
||||
* Since: 2.8.2
|
||||
**/
|
||||
hb_blob_t *
|
||||
hb_blob_create_from_file_or_fail (const char *file_name)
|
||||
{
|
||||
/* Adopted from glib's gmappedfile.c with Matthias Clasen and
|
||||
Allison Lortie permission but changed a lot to suit our need. */
|
||||
#if defined(HAVE_MMAP) && !defined(HB_NO_MMAP)
|
||||
hb_mapped_file_t *file = (hb_mapped_file_t *) hb_calloc (1, sizeof (hb_mapped_file_t));
|
||||
if (unlikely (!file)) return hb_blob_get_empty ();
|
||||
|
||||
int fd = open (file_name, O_RDONLY | O_BINARY, 0);
|
||||
if (unlikely (fd == -1)) goto fail_without_close;
|
||||
|
||||
struct stat st;
|
||||
if (unlikely (fstat (fd, &st) == -1)) goto fail;
|
||||
|
||||
file->length = (unsigned long) st.st_size;
|
||||
|
||||
#ifdef _PATH_RSRCFORKSPEC
|
||||
if (unlikely (file->length == 0))
|
||||
{
|
||||
int rfd = _open_resource_fork (file_name, file);
|
||||
if (rfd != -1)
|
||||
{
|
||||
close (fd);
|
||||
fd = rfd;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
file->contents = (char *) mmap (nullptr, file->length, PROT_READ,
|
||||
MAP_PRIVATE | MAP_NORESERVE, fd, 0);
|
||||
|
||||
if (unlikely (file->contents == MAP_FAILED)) goto fail;
|
||||
|
||||
close (fd);
|
||||
|
||||
return hb_blob_create_or_fail (file->contents, file->length,
|
||||
HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE, (void *) file,
|
||||
(hb_destroy_func_t) _hb_mapped_file_destroy);
|
||||
|
||||
fail:
|
||||
close (fd);
|
||||
fail_without_close:
|
||||
hb_free (file);
|
||||
|
||||
#elif defined(_WIN32) && !defined(HB_NO_MMAP)
|
||||
hb_mapped_file_t *file = (hb_mapped_file_t *) hb_calloc (1, sizeof (hb_mapped_file_t));
|
||||
if (unlikely (!file)) return hb_blob_get_empty ();
|
||||
|
||||
HANDLE fd;
|
||||
unsigned int size = strlen (file_name) + 1;
|
||||
wchar_t * wchar_file_name = (wchar_t *) hb_malloc (sizeof (wchar_t) * size);
|
||||
if (unlikely (!wchar_file_name)) goto fail_without_close;
|
||||
mbstowcs (wchar_file_name, file_name, size);
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
{
|
||||
CREATEFILE2_EXTENDED_PARAMETERS ceparams = { 0 };
|
||||
ceparams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
|
||||
ceparams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED & 0xFFFF;
|
||||
ceparams.dwFileFlags = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED & 0xFFF00000;
|
||||
ceparams.dwSecurityQosFlags = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED & 0x000F0000;
|
||||
ceparams.lpSecurityAttributes = nullptr;
|
||||
ceparams.hTemplateFile = nullptr;
|
||||
fd = CreateFile2 (wchar_file_name, GENERIC_READ, FILE_SHARE_READ,
|
||||
OPEN_EXISTING, &ceparams);
|
||||
}
|
||||
#else
|
||||
fd = CreateFileW (wchar_file_name, GENERIC_READ, FILE_SHARE_READ, nullptr,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,
|
||||
nullptr);
|
||||
#endif
|
||||
hb_free (wchar_file_name);
|
||||
|
||||
if (unlikely (fd == INVALID_HANDLE_VALUE)) goto fail_without_close;
|
||||
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
{
|
||||
LARGE_INTEGER length;
|
||||
GetFileSizeEx (fd, &length);
|
||||
file->length = length.LowPart;
|
||||
file->mapping = CreateFileMappingFromApp (fd, nullptr, PAGE_READONLY, length.QuadPart, nullptr);
|
||||
}
|
||||
#else
|
||||
file->length = (unsigned long) GetFileSize (fd, nullptr);
|
||||
file->mapping = CreateFileMapping (fd, nullptr, PAGE_READONLY, 0, 0, nullptr);
|
||||
#endif
|
||||
if (unlikely (!file->mapping)) goto fail;
|
||||
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
file->contents = (char *) MapViewOfFileFromApp (file->mapping, FILE_MAP_READ, 0, 0);
|
||||
#else
|
||||
file->contents = (char *) MapViewOfFile (file->mapping, FILE_MAP_READ, 0, 0, 0);
|
||||
#endif
|
||||
if (unlikely (!file->contents)) goto fail;
|
||||
|
||||
CloseHandle (fd);
|
||||
return hb_blob_create_or_fail (file->contents, file->length,
|
||||
HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE, (void *) file,
|
||||
(hb_destroy_func_t) _hb_mapped_file_destroy);
|
||||
|
||||
fail:
|
||||
CloseHandle (fd);
|
||||
fail_without_close:
|
||||
hb_free (file);
|
||||
|
||||
#endif
|
||||
|
||||
/* The following tries to read a file without knowing its size beforehand
|
||||
It's used as a fallback for systems without mmap or to read from pipes */
|
||||
unsigned long len = 0, allocated = BUFSIZ * 16;
|
||||
char *data = (char *) hb_malloc (allocated);
|
||||
if (unlikely (!data)) return nullptr;
|
||||
|
||||
FILE *fp = fopen (file_name, "rb");
|
||||
if (unlikely (!fp)) goto fread_fail_without_close;
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
if (allocated - len < BUFSIZ)
|
||||
{
|
||||
allocated *= 2;
|
||||
/* Don't allocate and go more than ~536MB, our mmap reader still
|
||||
can cover files like that but lets limit our fallback reader */
|
||||
if (unlikely (allocated > (2 << 28))) goto fread_fail;
|
||||
char *new_data = (char *) hb_realloc (data, allocated);
|
||||
if (unlikely (!new_data)) goto fread_fail;
|
||||
data = new_data;
|
||||
}
|
||||
|
||||
unsigned long addition = fread (data + len, 1, allocated - len, fp);
|
||||
|
||||
int err = ferror (fp);
|
||||
#ifdef EINTR // armcc doesn't have it
|
||||
if (unlikely (err == EINTR)) continue;
|
||||
#endif
|
||||
if (unlikely (err)) goto fread_fail;
|
||||
|
||||
len += addition;
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
return hb_blob_create_or_fail (data, len, HB_MEMORY_MODE_WRITABLE, data,
|
||||
(hb_destroy_func_t) hb_free);
|
||||
|
||||
fread_fail:
|
||||
fclose (fp);
|
||||
fread_fail_without_close:
|
||||
hb_free (data);
|
||||
return nullptr;
|
||||
}
|
||||
#endif /* !HB_NO_OPEN */
|
||||
|
||||
+45
-11
@@ -24,7 +24,7 @@
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_H_IN
|
||||
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb.h> instead."
|
||||
#endif
|
||||
|
||||
@@ -36,25 +36,36 @@
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
/*
|
||||
* Note re various memory-modes:
|
||||
/**
|
||||
* hb_memory_mode_t:
|
||||
* @HB_MEMORY_MODE_DUPLICATE: HarfBuzz immediately makes a copy of the data.
|
||||
* @HB_MEMORY_MODE_READONLY: HarfBuzz client will never modify the data,
|
||||
* and HarfBuzz will never modify the data.
|
||||
* @HB_MEMORY_MODE_WRITABLE: HarfBuzz client made a copy of the data solely
|
||||
* for HarfBuzz, so HarfBuzz may modify the data.
|
||||
* @HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE: See above
|
||||
*
|
||||
* Data type holding the memory modes available to
|
||||
* client programs.
|
||||
*
|
||||
* Regarding these various memory-modes:
|
||||
*
|
||||
* - In no case shall the HarfBuzz client modify memory
|
||||
* that is passed to HarfBuzz in a blob. If there is
|
||||
* any such possibility, MODE_DUPLICATE should be used
|
||||
* any such possibility, @HB_MEMORY_MODE_DUPLICATE should be used
|
||||
* such that HarfBuzz makes a copy immediately,
|
||||
*
|
||||
* - Use MODE_READONLY otherse, unless you really really
|
||||
* - Use @HB_MEMORY_MODE_READONLY otherwise, unless you really really
|
||||
* really know what you are doing,
|
||||
*
|
||||
* - MODE_WRITABLE is appropriate if you really made a
|
||||
* - @HB_MEMORY_MODE_WRITABLE is appropriate if you really made a
|
||||
* copy of data solely for the purpose of passing to
|
||||
* HarfBuzz and doing that just once (no reuse!),
|
||||
*
|
||||
* - If the font is mmap()ed, it's ok to use
|
||||
* READONLY_MAY_MAKE_WRITABLE, however, using that mode
|
||||
* correctly is very tricky. Use MODE_READONLY instead.
|
||||
*/
|
||||
* - If the font is mmap()ed, it's okay to use
|
||||
* @HB_MEMORY_READONLY_MAY_MAKE_WRITABLE, however, using that mode
|
||||
* correctly is very tricky. Use @HB_MEMORY_MODE_READONLY instead.
|
||||
**/
|
||||
typedef enum {
|
||||
HB_MEMORY_MODE_DUPLICATE,
|
||||
HB_MEMORY_MODE_READONLY,
|
||||
@@ -62,6 +73,14 @@ typedef enum {
|
||||
HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE
|
||||
} hb_memory_mode_t;
|
||||
|
||||
/**
|
||||
* hb_blob_t:
|
||||
*
|
||||
* Data type for blobs. A blob wraps a chunk of binary
|
||||
* data and facilitates its lifecycle management between
|
||||
* a client program and HarfBuzz.
|
||||
*
|
||||
**/
|
||||
typedef struct hb_blob_t hb_blob_t;
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
@@ -71,6 +90,19 @@ hb_blob_create (const char *data,
|
||||
void *user_data,
|
||||
hb_destroy_func_t destroy);
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
hb_blob_create_or_fail (const char *data,
|
||||
unsigned int length,
|
||||
hb_memory_mode_t mode,
|
||||
void *user_data,
|
||||
hb_destroy_func_t destroy);
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
hb_blob_create_from_file (const char *file_name);
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
hb_blob_create_from_file_or_fail (const char *file_name);
|
||||
|
||||
/* Always creates with MEMORY_MODE_READONLY.
|
||||
* Even if the parent blob is writable, we don't
|
||||
* want the user of the sub-blob to be able to
|
||||
@@ -82,6 +114,9 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
|
||||
unsigned int offset,
|
||||
unsigned int length);
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
hb_blob_copy_writable_or_fail (hb_blob_t *blob);
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
hb_blob_get_empty (void);
|
||||
|
||||
@@ -120,7 +155,6 @@ hb_blob_get_data (hb_blob_t *blob, unsigned int *length);
|
||||
HB_EXTERN char *
|
||||
hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length);
|
||||
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#endif /* HB_BLOB_H */
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright © 2009 Red Hat, Inc.
|
||||
* Copyright © 2018 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_BLOB_HH
|
||||
#define HB_BLOB_HH
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
|
||||
/*
|
||||
* hb_blob_t
|
||||
*/
|
||||
|
||||
struct hb_blob_t
|
||||
{
|
||||
void fini_shallow () { destroy_user_data (); }
|
||||
|
||||
void destroy_user_data ()
|
||||
{
|
||||
if (destroy)
|
||||
{
|
||||
destroy (user_data);
|
||||
user_data = nullptr;
|
||||
destroy = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
HB_INTERNAL bool try_make_writable ();
|
||||
HB_INTERNAL bool try_make_writable_inplace ();
|
||||
HB_INTERNAL bool try_make_writable_inplace_unix ();
|
||||
|
||||
hb_bytes_t as_bytes () const { return hb_bytes_t (data, length); }
|
||||
template <typename Type>
|
||||
const Type* as () const { return as_bytes ().as<Type> (); }
|
||||
|
||||
public:
|
||||
hb_object_header_t header;
|
||||
|
||||
const char *data;
|
||||
unsigned int length;
|
||||
hb_memory_mode_t mode;
|
||||
|
||||
void *user_data;
|
||||
hb_destroy_func_t destroy;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* hb_blob_ptr_t
|
||||
*/
|
||||
|
||||
template <typename P>
|
||||
struct hb_blob_ptr_t
|
||||
{
|
||||
typedef hb_remove_pointer<P> T;
|
||||
|
||||
hb_blob_ptr_t (hb_blob_t *b_ = nullptr) : b (b_) {}
|
||||
hb_blob_t * operator = (hb_blob_t *b_) { return b = b_; }
|
||||
const T * operator -> () const { return get (); }
|
||||
const T & operator * () const { return *get (); }
|
||||
template <typename C> operator const C * () const { return get (); }
|
||||
operator const char * () const { return (const char *) get (); }
|
||||
const T * get () const { return b->as<T> (); }
|
||||
hb_blob_t * get_blob () const { return b.get_raw (); }
|
||||
unsigned int get_length () const { return b.get ()->length; }
|
||||
void destroy () { hb_blob_destroy (b.get ()); b = nullptr; }
|
||||
|
||||
private:
|
||||
hb_nonnull_ptr_t<hb_blob_t> b;
|
||||
};
|
||||
|
||||
|
||||
#endif /* HB_BLOB_HH */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@
|
||||
#ifndef HB_BUFFER_DESERIALIZE_JSON_HH
|
||||
#define HB_BUFFER_DESERIALIZE_JSON_HH
|
||||
|
||||
#include "hb-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
%%{
|
||||
|
||||
@@ -42,7 +42,7 @@ action clear_item {
|
||||
|
||||
action add_item {
|
||||
buffer->add_info (info);
|
||||
if (buffer->in_error)
|
||||
if (unlikely (!buffer->successful))
|
||||
return false;
|
||||
buffer->pos[buffer->len - 1] = pos;
|
||||
*end_ptr = p;
|
||||
@@ -52,14 +52,18 @@ action tok {
|
||||
tok = p;
|
||||
}
|
||||
|
||||
action parse_glyph {
|
||||
action ensure_glyphs { if (unlikely (!buffer->ensure_glyphs ())) return false; }
|
||||
action ensure_unicode { if (unlikely (!buffer->ensure_unicode ())) return false; }
|
||||
|
||||
action parse_glyph_name {
|
||||
/* TODO Unescape \" and \\ if found. */
|
||||
if (!hb_font_glyph_from_string (font,
|
||||
tok, p - tok,
|
||||
&info.codepoint))
|
||||
return false;
|
||||
}
|
||||
|
||||
action parse_gid { if (!parse_uint (tok, p, &info.codepoint)) return false; }
|
||||
action parse_codepoint { if (!parse_uint (tok, p, &info.codepoint)) return false; }
|
||||
action parse_cluster { if (!parse_uint (tok, p, &info.cluster )) return false; }
|
||||
action parse_x_offset { if (!parse_int (tok, p, &pos.x_offset )) return false; }
|
||||
action parse_y_offset { if (!parse_int (tok, p, &pos.y_offset )) return false; }
|
||||
@@ -72,20 +76,27 @@ num = '-'? unum;
|
||||
comma = space* ',' space*;
|
||||
colon = space* ':' space*;
|
||||
|
||||
glyph_id = unum;
|
||||
glyph_name = alpha (alnum|'_'|'.'|'-')*;
|
||||
codepoint = unum;
|
||||
glyph_name = '"' ([^\\"] | '\\' [\\"])* '"';
|
||||
|
||||
glyph_string = '"' (glyph_name >tok %parse_glyph) '"';
|
||||
glyph_number = (glyph_id >tok %parse_gid);
|
||||
parse_glyph_name = (glyph_name >tok %parse_glyph_name);
|
||||
parse_codepoint = (codepoint >tok %parse_codepoint);
|
||||
|
||||
glyph = "\"g\"" colon (glyph_string | glyph_number);
|
||||
glyph = "\"g\"" colon (parse_glyph_name | parse_codepoint);
|
||||
unicode = "\"u\"" colon parse_codepoint;
|
||||
cluster = "\"cl\"" colon (unum >tok %parse_cluster);
|
||||
xoffset = "\"dx\"" colon (num >tok %parse_x_offset);
|
||||
yoffset = "\"dy\"" colon (num >tok %parse_y_offset);
|
||||
xadvance= "\"ax\"" colon (num >tok %parse_x_advance);
|
||||
yadvance= "\"ay\"" colon (num >tok %parse_y_advance);
|
||||
|
||||
element = glyph | cluster | xoffset | yoffset | xadvance | yadvance;
|
||||
element = glyph @ensure_glyphs
|
||||
| unicode @ensure_unicode
|
||||
| cluster
|
||||
| xoffset
|
||||
| yoffset
|
||||
| xadvance
|
||||
| yadvance;
|
||||
item =
|
||||
( '{' space* element (comma element)* space* '}')
|
||||
>clear_item
|
||||
@@ -97,7 +108,7 @@ main := space* item (comma item)* space* (','|']')?;
|
||||
}%%
|
||||
|
||||
static hb_bool_t
|
||||
_hb_buffer_deserialize_glyphs_json (hb_buffer_t *buffer,
|
||||
_hb_buffer_deserialize_json (hb_buffer_t *buffer,
|
||||
const char *buf,
|
||||
unsigned int buf_len,
|
||||
const char **end_ptr,
|
||||
@@ -106,7 +117,7 @@ _hb_buffer_deserialize_glyphs_json (hb_buffer_t *buffer,
|
||||
const char *p = buf, *pe = buf + buf_len;
|
||||
|
||||
/* Ensure we have positions. */
|
||||
(void) hb_buffer_get_glyph_positions (buffer, NULL);
|
||||
(void) hb_buffer_get_glyph_positions (buffer, nullptr);
|
||||
|
||||
while (p < pe && ISSPACE (*p))
|
||||
p++;
|
||||
@@ -115,7 +126,7 @@ _hb_buffer_deserialize_glyphs_json (hb_buffer_t *buffer,
|
||||
*end_ptr = ++p;
|
||||
}
|
||||
|
||||
const char *tok = NULL;
|
||||
const char *tok = nullptr;
|
||||
int cs;
|
||||
hb_glyph_info_t info = {0};
|
||||
hb_glyph_position_t pos = {0};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@
|
||||
#ifndef HB_BUFFER_DESERIALIZE_TEXT_HH
|
||||
#define HB_BUFFER_DESERIALIZE_TEXT_HH
|
||||
|
||||
#include "hb-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
%%{
|
||||
|
||||
@@ -42,7 +42,7 @@ action clear_item {
|
||||
|
||||
action add_item {
|
||||
buffer->add_info (info);
|
||||
if (buffer->in_error)
|
||||
if (unlikely (!buffer->successful))
|
||||
return false;
|
||||
buffer->pos[buffer->len - 1] = pos;
|
||||
*end_ptr = p;
|
||||
@@ -52,30 +52,37 @@ action tok {
|
||||
tok = p;
|
||||
}
|
||||
|
||||
action ensure_glyphs { if (unlikely (!buffer->ensure_glyphs ())) return false; }
|
||||
action ensure_unicode { if (unlikely (!buffer->ensure_unicode ())) return false; }
|
||||
|
||||
action parse_glyph {
|
||||
/* TODO Unescape delimeters. */
|
||||
if (!hb_font_glyph_from_string (font,
|
||||
tok, p - tok,
|
||||
&info.codepoint))
|
||||
return false;
|
||||
}
|
||||
|
||||
action parse_hexdigits {if (!parse_hex (tok, p, &info.codepoint )) return false; }
|
||||
|
||||
action parse_cluster { if (!parse_uint (tok, p, &info.cluster )) return false; }
|
||||
action parse_x_offset { if (!parse_int (tok, p, &pos.x_offset )) return false; }
|
||||
action parse_y_offset { if (!parse_int (tok, p, &pos.y_offset )) return false; }
|
||||
action parse_x_advance { if (!parse_int (tok, p, &pos.x_advance)) return false; }
|
||||
action parse_y_advance { if (!parse_int (tok, p, &pos.y_advance)) return false; }
|
||||
|
||||
unum = '0' | [1-9] digit*;
|
||||
unum = '0' | [1-9] digit*;
|
||||
num = '-'? unum;
|
||||
|
||||
glyph_id = unum;
|
||||
glyph_name = alpha (alnum|'_'|'.'|'-')*;
|
||||
glyph_name = ([^\\\]=@+,|] | '\\' [\\\]=@+,|]) *;
|
||||
|
||||
glyph = (glyph_id | glyph_name) >tok %parse_glyph;
|
||||
cluster = '=' (unum >tok %parse_cluster);
|
||||
offsets = '@' (num >tok %parse_x_offset) ',' (num >tok %parse_y_offset );
|
||||
advances= '+' (num >tok %parse_x_advance) (',' (num >tok %parse_y_advance))?;
|
||||
item =
|
||||
|
||||
glyph_item =
|
||||
(
|
||||
glyph
|
||||
cluster?
|
||||
@@ -83,15 +90,31 @@ item =
|
||||
advances?
|
||||
)
|
||||
>clear_item
|
||||
@ensure_glyphs
|
||||
%add_item
|
||||
;
|
||||
|
||||
main := space* item (space* '|' space* item)* space* ('|'|']')?;
|
||||
unicode = 'U' '+' xdigit+ >tok %parse_hexdigits;
|
||||
|
||||
unicode_item =
|
||||
(
|
||||
unicode
|
||||
cluster?
|
||||
)
|
||||
>clear_item
|
||||
@ensure_unicode
|
||||
%add_item
|
||||
;
|
||||
|
||||
glyphs = glyph_item (space* '|' space* glyph_item)* space* ('|'|']')?;
|
||||
unicodes = unicode_item (space* '|' space* unicode_item)* space* ('|'|'>')?;
|
||||
|
||||
main := space* ( ('[' glyphs) | ('<' unicodes) );
|
||||
|
||||
}%%
|
||||
|
||||
static hb_bool_t
|
||||
_hb_buffer_deserialize_glyphs_text (hb_buffer_t *buffer,
|
||||
_hb_buffer_deserialize_text (hb_buffer_t *buffer,
|
||||
const char *buf,
|
||||
unsigned int buf_len,
|
||||
const char **end_ptr,
|
||||
@@ -100,16 +123,12 @@ _hb_buffer_deserialize_glyphs_text (hb_buffer_t *buffer,
|
||||
const char *p = buf, *pe = buf + buf_len;
|
||||
|
||||
/* Ensure we have positions. */
|
||||
(void) hb_buffer_get_glyph_positions (buffer, NULL);
|
||||
(void) hb_buffer_get_glyph_positions (buffer, nullptr);
|
||||
|
||||
while (p < pe && ISSPACE (*p))
|
||||
p++;
|
||||
if (p < pe && *p == (buffer->len ? '|' : '['))
|
||||
{
|
||||
*end_ptr = ++p;
|
||||
}
|
||||
|
||||
const char *eof = pe, *tok = NULL;
|
||||
const char *eof = pe, *tok = nullptr;
|
||||
int cs;
|
||||
hb_glyph_info_t info = {0};
|
||||
hb_glyph_position_t pos = {0};
|
||||
|
||||
@@ -24,13 +24,17 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#include "hb-buffer-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
#ifndef HB_NO_BUFFER_SERIALIZE
|
||||
|
||||
#include "hb-buffer.hh"
|
||||
|
||||
|
||||
static const char *serialize_formats[] = {
|
||||
"text",
|
||||
"json",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -44,7 +48,7 @@ static const char *serialize_formats[] = {
|
||||
* Since: 0.9.7
|
||||
**/
|
||||
const char **
|
||||
hb_buffer_serialize_list_formats (void)
|
||||
hb_buffer_serialize_list_formats ()
|
||||
{
|
||||
return serialize_formats;
|
||||
}
|
||||
@@ -58,7 +62,7 @@ hb_buffer_serialize_list_formats (void)
|
||||
* @str is a valid buffer serialization format, use
|
||||
* hb_buffer_serialize_list_formats() to get the list of supported formats.
|
||||
*
|
||||
* Return value:
|
||||
* Return value:
|
||||
* The parsed #hb_buffer_serialize_format_t.
|
||||
*
|
||||
* Since: 0.9.7
|
||||
@@ -85,30 +89,31 @@ hb_buffer_serialize_format_from_string (const char *str, int len)
|
||||
const char *
|
||||
hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format)
|
||||
{
|
||||
switch (format)
|
||||
switch ((unsigned) format)
|
||||
{
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_TEXT: return serialize_formats[0];
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_JSON: return serialize_formats[1];
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_TEXT: return serialize_formats[0];
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_JSON: return serialize_formats[1];
|
||||
default:
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return NULL;
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL);
|
||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
|
||||
hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ?
|
||||
NULL : hb_buffer_get_glyph_positions (buffer, NULL);
|
||||
nullptr : hb_buffer_get_glyph_positions (buffer, nullptr);
|
||||
|
||||
*buf_consumed = 0;
|
||||
hb_position_t x = 0, y = 0;
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
{
|
||||
char b[1024];
|
||||
@@ -120,6 +125,8 @@ _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
|
||||
|
||||
if (i)
|
||||
*p++ = ',';
|
||||
else
|
||||
*p++ = '[';
|
||||
|
||||
*p++ = '{';
|
||||
|
||||
@@ -129,45 +136,49 @@ _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
|
||||
char g[128];
|
||||
hb_font_glyph_to_string (font, info[i].codepoint, g, sizeof (g));
|
||||
*p++ = '"';
|
||||
for (char *q = g; *q; q++) {
|
||||
if (*q == '"')
|
||||
for (char *q = g; *q; q++)
|
||||
{
|
||||
if (unlikely (*q == '"' || *q == '\\'))
|
||||
*p++ = '\\';
|
||||
*p++ = *q;
|
||||
}
|
||||
*p++ = '"';
|
||||
}
|
||||
else
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
|
||||
p += hb_max (0, 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 += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster));
|
||||
}
|
||||
|
||||
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS))
|
||||
{
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"dx\":%d,\"dy\":%d",
|
||||
pos[i].x_offset, pos[i].y_offset));
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"ax\":%d,\"ay\":%d",
|
||||
pos[i].x_advance, pos[i].y_advance));
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"dx\":%d,\"dy\":%d",
|
||||
x+pos[i].x_offset, y+pos[i].y_offset));
|
||||
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"ax\":%d,\"ay\":%d",
|
||||
pos[i].x_advance, pos[i].y_advance));
|
||||
}
|
||||
|
||||
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS)
|
||||
{
|
||||
if (info[i].mask & HB_GLYPH_FLAG_DEFINED)
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"fl\":%u", info[i].mask & HB_GLYPH_FLAG_DEFINED));
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"fl\":%u", info[i].mask & HB_GLYPH_FLAG_DEFINED));
|
||||
}
|
||||
|
||||
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS)
|
||||
{
|
||||
hb_glyph_extents_t extents;
|
||||
hb_font_get_glyph_extents(font, info[i].codepoint, &extents);
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"xb\":%d,\"yb\":%d",
|
||||
extents.x_bearing, extents.y_bearing));
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"w\":%d,\"h\":%d",
|
||||
extents.width, extents.height));
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"xb\":%d,\"yb\":%d",
|
||||
extents.x_bearing, extents.y_bearing));
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"w\":%d,\"h\":%d",
|
||||
extents.width, extents.height));
|
||||
}
|
||||
|
||||
*p++ = '}';
|
||||
if (i == end-1)
|
||||
*p++ = ']';
|
||||
|
||||
unsigned int l = p - b;
|
||||
if (buf_size > l)
|
||||
@@ -179,6 +190,65 @@ _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
|
||||
*buf = '\0';
|
||||
} else
|
||||
return i - start;
|
||||
|
||||
if (pos && (flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
|
||||
{
|
||||
x += pos[i].x_advance;
|
||||
y += pos[i].y_advance;
|
||||
}
|
||||
}
|
||||
|
||||
return end - start;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_hb_buffer_serialize_unicode_json (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
|
||||
|
||||
*buf_consumed = 0;
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
{
|
||||
char b[1024];
|
||||
char *p = b;
|
||||
|
||||
if (i)
|
||||
*p++ = ',';
|
||||
else
|
||||
*p++ = '[';
|
||||
|
||||
*p++ = '{';
|
||||
|
||||
APPEND ("\"u\":");
|
||||
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
|
||||
|
||||
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster));
|
||||
}
|
||||
|
||||
*p++ = '}';
|
||||
|
||||
if (i == end-1)
|
||||
*p++ = ']';
|
||||
|
||||
unsigned int l = p - b;
|
||||
if (buf_size > l)
|
||||
{
|
||||
memcpy (buf, b, l);
|
||||
buf += l;
|
||||
buf_size -= l;
|
||||
*buf_consumed += l;
|
||||
*buf = '\0';
|
||||
} else
|
||||
return i - start;
|
||||
|
||||
}
|
||||
|
||||
return end - start;
|
||||
@@ -186,19 +256,20 @@ _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
|
||||
|
||||
static unsigned int
|
||||
_hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL);
|
||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
|
||||
hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ?
|
||||
NULL : hb_buffer_get_glyph_positions (buffer, NULL);
|
||||
nullptr : hb_buffer_get_glyph_positions (buffer, nullptr);
|
||||
|
||||
*buf_consumed = 0;
|
||||
hb_position_t x = 0, y = 0;
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
{
|
||||
char b[1024];
|
||||
@@ -208,41 +279,51 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
||||
|
||||
if (i)
|
||||
*p++ = '|';
|
||||
else
|
||||
*p++ = '[';
|
||||
|
||||
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES))
|
||||
{
|
||||
/* TODO Escape delimiters we use. */
|
||||
hb_font_glyph_to_string (font, info[i].codepoint, p, 128);
|
||||
p += strlen (p);
|
||||
}
|
||||
else
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
|
||||
p += hb_max (0, 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 += hb_max (0, 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));
|
||||
if (x+pos[i].x_offset || y+pos[i].y_offset)
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", x+pos[i].x_offset, y+pos[i].y_offset));
|
||||
|
||||
*p++ = '+';
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance));
|
||||
if (pos[i].y_advance)
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance));
|
||||
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
|
||||
{
|
||||
*p++ = '+';
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance));
|
||||
if (pos[i].y_advance)
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance));
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS)
|
||||
{
|
||||
if (info[i].mask &HB_GLYPH_FLAG_DEFINED)
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "#%X", info[i].mask &HB_GLYPH_FLAG_DEFINED));
|
||||
if (info[i].mask & HB_GLYPH_FLAG_DEFINED)
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "#%X", info[i].mask &HB_GLYPH_FLAG_DEFINED));
|
||||
}
|
||||
|
||||
if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS)
|
||||
{
|
||||
hb_glyph_extents_t extents;
|
||||
hb_font_get_glyph_extents(font, info[i].codepoint, &extents);
|
||||
p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "<%d,%d,%d,%d>", extents.x_bearing, extents.y_bearing, extents.width, extents.height));
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "<%d,%d,%d,%d>", extents.x_bearing, extents.y_bearing, extents.width, extents.height));
|
||||
}
|
||||
|
||||
if (i == end-1) {
|
||||
*p++ = ']';
|
||||
}
|
||||
|
||||
unsigned int l = p - b;
|
||||
@@ -255,11 +336,62 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
||||
*buf = '\0';
|
||||
} else
|
||||
return i - start;
|
||||
|
||||
if (pos && (flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
|
||||
{
|
||||
x += pos[i].x_advance;
|
||||
y += pos[i].y_advance;
|
||||
}
|
||||
}
|
||||
|
||||
return end - start;
|
||||
}
|
||||
|
||||
|
||||
static unsigned int
|
||||
_hb_buffer_serialize_unicode_text (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
|
||||
*buf_consumed = 0;
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
{
|
||||
char b[1024];
|
||||
char *p = b;
|
||||
|
||||
if (i)
|
||||
*p++ = '|';
|
||||
else
|
||||
*p++ = '<';
|
||||
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "U+%04X", info[i].codepoint));
|
||||
|
||||
if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
|
||||
p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster));
|
||||
}
|
||||
|
||||
if (i == end-1)
|
||||
*p++ = '>';
|
||||
|
||||
unsigned int l = p - b;
|
||||
if (buf_size > l)
|
||||
{
|
||||
memcpy (buf, b, l);
|
||||
buf += l;
|
||||
buf_size -= l;
|
||||
*buf_consumed += l;
|
||||
*buf = '\0';
|
||||
} else
|
||||
return i - start;
|
||||
}
|
||||
return end - start;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_buffer_serialize_glyphs:
|
||||
* @buffer: an #hb_buffer_t buffer.
|
||||
@@ -268,8 +400,8 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
||||
* @buf: (out) (array length=buf_size) (element-type uint8_t): output string to
|
||||
* write serialized buffer into.
|
||||
* @buf_size: the size of @buf.
|
||||
* @buf_consumed: (out) (allow-none): if not %NULL, will be set to the number of byes written into @buf.
|
||||
* @font: (allow-none): the #hb_font_t used to shape this buffer, needed to
|
||||
* @buf_consumed: (out) (optional): if not %NULL, will be set to the number of byes written into @buf.
|
||||
* @font: (nullable): the #hb_font_t used to shape this buffer, needed to
|
||||
* read glyph names and extents. If %NULL, and empty font will be used.
|
||||
* @format: the #hb_buffer_serialize_format_t to use for formatting the output.
|
||||
* @flags: the #hb_buffer_serialize_flags_t that control what glyph properties
|
||||
@@ -286,6 +418,7 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
||||
* ```
|
||||
* [uni0651=0@518,0+0|uni0628=0+1897]
|
||||
* ```
|
||||
*
|
||||
* - The serialized glyphs are delimited with `[` and `]`.
|
||||
* - Glyphs are separated with `|`
|
||||
* - Each glyph starts with glyph name, or glyph index if
|
||||
@@ -294,30 +427,47 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
||||
* - If #HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS is not set, the #hb_glyph_position_t in the format:
|
||||
* - If both #hb_glyph_position_t.x_offset and #hb_glyph_position_t.y_offset are not 0, `@x_offset,y_offset`. Then,
|
||||
* - `+x_advance`, then `,y_advance` if #hb_glyph_position_t.y_advance is not 0. Then,
|
||||
* - If #HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS is set, the
|
||||
* #hb_glyph_extents_t in the format
|
||||
* `<x_bearing,y_bearing,width,height>`
|
||||
* - If #HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS is set, the #hb_glyph_extents_t in the format `<x_bearing,y_bearing,width,height>`
|
||||
*
|
||||
* ## json
|
||||
* TODO.
|
||||
* A machine-readable, structured format.
|
||||
* The serialized glyphs will look something like:
|
||||
*
|
||||
* Return value:
|
||||
* ```
|
||||
* [{"g":"uni0651","cl":0,"dx":518,"dy":0,"ax":0,"ay":0},
|
||||
* {"g":"uni0628","cl":0,"dx":0,"dy":0,"ax":1897,"ay":0}]
|
||||
* ```
|
||||
*
|
||||
* Each glyph is a JSON object, with the following properties:
|
||||
* - `g`: the glyph name or glyph index if
|
||||
* #HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES flag is set.
|
||||
* - `cl`: #hb_glyph_info_t.cluster if
|
||||
* #HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set.
|
||||
* - `dx`,`dy`,`ax`,`ay`: #hb_glyph_position_t.x_offset, #hb_glyph_position_t.y_offset,
|
||||
* #hb_glyph_position_t.x_advance and #hb_glyph_position_t.y_advance
|
||||
* respectively, if #HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS is not set.
|
||||
* - `xb`,`yb`,`w`,`h`: #hb_glyph_extents_t.x_bearing, #hb_glyph_extents_t.y_bearing,
|
||||
* #hb_glyph_extents_t.width and #hb_glyph_extents_t.height respectively if
|
||||
* #HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS is set.
|
||||
*
|
||||
* Return value:
|
||||
* The number of serialized items.
|
||||
*
|
||||
* Since: 0.9.7
|
||||
**/
|
||||
unsigned int
|
||||
hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
assert (start <= end && end <= buffer->len);
|
||||
end = hb_clamp (end, start, buffer->len);
|
||||
start = hb_min (start, end);
|
||||
|
||||
unsigned int sconsumed;
|
||||
if (!buf_consumed)
|
||||
@@ -326,8 +476,7 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
|
||||
if (buf_size)
|
||||
*buf = '\0';
|
||||
|
||||
assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) ||
|
||||
buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS);
|
||||
buffer->assert_glyphs ();
|
||||
|
||||
if (!buffer->have_positions)
|
||||
flags |= HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS;
|
||||
@@ -342,13 +491,13 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
|
||||
{
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
|
||||
return _hb_buffer_serialize_glyphs_text (buffer, start, end,
|
||||
buf, buf_size, buf_consumed,
|
||||
font, flags);
|
||||
buf, buf_size, buf_consumed,
|
||||
font, flags);
|
||||
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_JSON:
|
||||
return _hb_buffer_serialize_glyphs_json (buffer, start, end,
|
||||
buf, buf_size, buf_consumed,
|
||||
font, flags);
|
||||
buf, buf_size, buf_consumed,
|
||||
font, flags);
|
||||
|
||||
default:
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_INVALID:
|
||||
@@ -357,43 +506,214 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static hb_bool_t
|
||||
parse_uint (const char *pp, const char *end, uint32_t *pv)
|
||||
/**
|
||||
* hb_buffer_serialize_unicode:
|
||||
* @buffer: an #hb_buffer_t buffer.
|
||||
* @start: the first item in @buffer to serialize.
|
||||
* @end: the last item in @buffer to serialize.
|
||||
* @buf: (out) (array length=buf_size) (element-type uint8_t): output string to
|
||||
* write serialized buffer into.
|
||||
* @buf_size: the size of @buf.
|
||||
* @buf_consumed: (out) (optional): if not %NULL, will be set to the number of byes written into @buf.
|
||||
* @format: the #hb_buffer_serialize_format_t to use for formatting the output.
|
||||
* @flags: the #hb_buffer_serialize_flags_t that control what glyph properties
|
||||
* to serialize.
|
||||
*
|
||||
* Serializes @buffer into a textual representation of its content,
|
||||
* when the buffer contains Unicode codepoints (i.e., before shaping). This is
|
||||
* useful for showing the contents of the buffer, for example during debugging.
|
||||
* There are currently two supported serialization formats:
|
||||
*
|
||||
* ## text
|
||||
* A human-readable, plain text format.
|
||||
* The serialized codepoints will look something like:
|
||||
*
|
||||
* ```
|
||||
* <U+0651=0|U+0628=1>
|
||||
* ```
|
||||
*
|
||||
* - Glyphs are separated with `|`
|
||||
* - Unicode codepoints are expressed as zero-padded four (or more)
|
||||
* digit hexadecimal numbers preceded by `U+`
|
||||
* - If #HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set, the cluster
|
||||
* will be indicated with a `=` then #hb_glyph_info_t.cluster.
|
||||
*
|
||||
* ## json
|
||||
* A machine-readable, structured format.
|
||||
* The serialized codepoints will be a list of objects with the following
|
||||
* properties:
|
||||
* - `u`: the Unicode codepoint as a decimal integer
|
||||
* - `cl`: #hb_glyph_info_t.cluster if
|
||||
* #HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```
|
||||
* [{u:1617,cl:0},{u:1576,cl:1}]
|
||||
* ```
|
||||
*
|
||||
* Return value:
|
||||
* The number of serialized items.
|
||||
*
|
||||
* Since: 2.7.3
|
||||
**/
|
||||
unsigned int
|
||||
hb_buffer_serialize_unicode (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp));
|
||||
strncpy (buf, pp, len);
|
||||
buf[len] = '\0';
|
||||
end = hb_clamp (end, start, buffer->len);
|
||||
start = hb_min (start, end);
|
||||
|
||||
char *p = buf;
|
||||
char *pend = p;
|
||||
uint32_t v;
|
||||
unsigned int sconsumed;
|
||||
if (!buf_consumed)
|
||||
buf_consumed = &sconsumed;
|
||||
*buf_consumed = 0;
|
||||
if (buf_size)
|
||||
*buf = '\0';
|
||||
|
||||
errno = 0;
|
||||
v = strtol (p, &pend, 10);
|
||||
if (errno || p == pend || pend - p != end - pp)
|
||||
buffer->assert_unicode ();
|
||||
|
||||
if (unlikely (start == end))
|
||||
return 0;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
|
||||
return _hb_buffer_serialize_unicode_text (buffer, start, end,
|
||||
buf, buf_size, buf_consumed, flags);
|
||||
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_JSON:
|
||||
return _hb_buffer_serialize_unicode_json (buffer, start, end,
|
||||
buf, buf_size, buf_consumed, flags);
|
||||
|
||||
default:
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_INVALID:
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_hb_buffer_serialize_invalid (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
assert (!buffer->len);
|
||||
|
||||
unsigned int sconsumed;
|
||||
if (!buf_consumed)
|
||||
buf_consumed = &sconsumed;
|
||||
if (buf_size < 3)
|
||||
return 0;
|
||||
if (format == HB_BUFFER_SERIALIZE_FORMAT_JSON) {
|
||||
*buf++ = '[';
|
||||
*buf++ = ']';
|
||||
*buf = '\0';
|
||||
} else if (format == HB_BUFFER_SERIALIZE_FORMAT_TEXT) {
|
||||
*buf++ = '!';
|
||||
*buf++ = '!';
|
||||
*buf = '\0';
|
||||
}
|
||||
*buf_consumed = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_buffer_serialize:
|
||||
* @buffer: an #hb_buffer_t buffer.
|
||||
* @start: the first item in @buffer to serialize.
|
||||
* @end: the last item in @buffer to serialize.
|
||||
* @buf: (out) (array length=buf_size) (element-type uint8_t): output string to
|
||||
* write serialized buffer into.
|
||||
* @buf_size: the size of @buf.
|
||||
* @buf_consumed: (out) (optional): if not %NULL, will be set to the number of byes written into @buf.
|
||||
* @font: (nullable): the #hb_font_t used to shape this buffer, needed to
|
||||
* read glyph names and extents. If %NULL, and empty font will be used.
|
||||
* @format: the #hb_buffer_serialize_format_t to use for formatting the output.
|
||||
* @flags: the #hb_buffer_serialize_flags_t that control what glyph properties
|
||||
* to serialize.
|
||||
*
|
||||
* Serializes @buffer into a textual representation of its content, whether
|
||||
* Unicode codepoints or glyph identifiers and positioning information. This is
|
||||
* useful for showing the contents of the buffer, for example during debugging.
|
||||
* See the documentation of hb_buffer_serialize_unicode() and
|
||||
* hb_buffer_serialize_glyphs() for a description of the output format.
|
||||
*
|
||||
* Return value:
|
||||
* The number of serialized items.
|
||||
*
|
||||
* Since: 2.7.3
|
||||
**/
|
||||
unsigned int
|
||||
hb_buffer_serialize (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags)
|
||||
{
|
||||
switch (buffer->content_type)
|
||||
{
|
||||
|
||||
case HB_BUFFER_CONTENT_TYPE_GLYPHS:
|
||||
return hb_buffer_serialize_glyphs (buffer, start, end, buf, buf_size,
|
||||
buf_consumed, font, format, flags);
|
||||
|
||||
case HB_BUFFER_CONTENT_TYPE_UNICODE:
|
||||
return hb_buffer_serialize_unicode (buffer, start, end, buf, buf_size,
|
||||
buf_consumed, format, flags);
|
||||
|
||||
case HB_BUFFER_CONTENT_TYPE_INVALID:
|
||||
default:
|
||||
return _hb_buffer_serialize_invalid (buffer, start, end, buf, buf_size,
|
||||
buf_consumed, format, flags);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_int (const char *pp, const char *end, int32_t *pv)
|
||||
{
|
||||
int v;
|
||||
const char *p = pp;
|
||||
if (unlikely (!hb_parse_int (&p, end, &v, true/* whole buffer */)))
|
||||
return false;
|
||||
|
||||
*pv = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
static hb_bool_t
|
||||
parse_int (const char *pp, const char *end, int32_t *pv)
|
||||
static bool
|
||||
parse_uint (const char *pp, const char *end, uint32_t *pv)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp));
|
||||
strncpy (buf, pp, len);
|
||||
buf[len] = '\0';
|
||||
unsigned int v;
|
||||
const char *p = pp;
|
||||
if (unlikely (!hb_parse_uint (&p, end, &v, true/* whole buffer */)))
|
||||
return false;
|
||||
|
||||
char *p = buf;
|
||||
char *pend = p;
|
||||
int32_t v;
|
||||
*pv = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
v = strtol (p, &pend, 10);
|
||||
if (errno || p == pend || pend - p != end - pp)
|
||||
static bool
|
||||
parse_hex (const char *pp, const char *end, uint32_t *pv)
|
||||
{
|
||||
unsigned int v;
|
||||
const char *p = pp;
|
||||
if (unlikely (!hb_parse_uint (&p, end, &v, true/* whole buffer */, 16)))
|
||||
return false;
|
||||
|
||||
*pv = v;
|
||||
@@ -406,33 +726,41 @@ parse_int (const char *pp, const char *end, int32_t *pv)
|
||||
/**
|
||||
* hb_buffer_deserialize_glyphs:
|
||||
* @buffer: an #hb_buffer_t buffer.
|
||||
* @buf: (array length=buf_len):
|
||||
* @buf_len:
|
||||
* @end_ptr: (out):
|
||||
* @font:
|
||||
* @format:
|
||||
* @buf: (array length=buf_len): string to deserialize
|
||||
* @buf_len: the size of @buf, or -1 if it is %NULL-terminated
|
||||
* @end_ptr: (out) (optional): output pointer to the character after last
|
||||
* consumed one.
|
||||
* @font: (nullable): font for getting glyph IDs
|
||||
* @format: the #hb_buffer_serialize_format_t of the input @buf
|
||||
*
|
||||
*
|
||||
* Deserializes glyphs @buffer from textual representation in the format
|
||||
* produced by hb_buffer_serialize_glyphs().
|
||||
*
|
||||
* Return value:
|
||||
* Return value: %true if @buf is not fully consumed, %false otherwise.
|
||||
*
|
||||
* Since: 0.9.7
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
|
||||
const char *buf,
|
||||
int buf_len, /* -1 means nul-terminated */
|
||||
const char **end_ptr, /* May be NULL */
|
||||
hb_font_t *font, /* May be NULL */
|
||||
hb_buffer_serialize_format_t format)
|
||||
const char *buf,
|
||||
int buf_len, /* -1 means nul-terminated */
|
||||
const char **end_ptr, /* May be NULL */
|
||||
hb_font_t *font, /* May be NULL */
|
||||
hb_buffer_serialize_format_t format)
|
||||
{
|
||||
const char *end;
|
||||
if (!end_ptr)
|
||||
end_ptr = &end;
|
||||
*end_ptr = buf;
|
||||
|
||||
assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) ||
|
||||
buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS);
|
||||
buffer->assert_glyphs ();
|
||||
|
||||
if (unlikely (hb_object_is_immutable (buffer)))
|
||||
{
|
||||
if (end_ptr)
|
||||
*end_ptr = buf;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buf_len == -1)
|
||||
buf_len = strlen (buf);
|
||||
@@ -451,14 +779,14 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
|
||||
switch (format)
|
||||
{
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
|
||||
return _hb_buffer_deserialize_glyphs_text (buffer,
|
||||
buf, buf_len, end_ptr,
|
||||
font);
|
||||
return _hb_buffer_deserialize_text (buffer,
|
||||
buf, buf_len, end_ptr,
|
||||
font);
|
||||
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_JSON:
|
||||
return _hb_buffer_deserialize_glyphs_json (buffer,
|
||||
buf, buf_len, end_ptr,
|
||||
font);
|
||||
return _hb_buffer_deserialize_json (buffer,
|
||||
buf, buf_len, end_ptr,
|
||||
font);
|
||||
|
||||
default:
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_INVALID:
|
||||
@@ -466,3 +794,76 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hb_buffer_deserialize_unicode:
|
||||
* @buffer: an #hb_buffer_t buffer.
|
||||
* @buf: (array length=buf_len): string to deserialize
|
||||
* @buf_len: the size of @buf, or -1 if it is %NULL-terminated
|
||||
* @end_ptr: (out) (optional): output pointer to the character after last
|
||||
* consumed one.
|
||||
* @format: the #hb_buffer_serialize_format_t of the input @buf
|
||||
*
|
||||
* Deserializes Unicode @buffer from textual representation in the format
|
||||
* produced by hb_buffer_serialize_unicode().
|
||||
*
|
||||
* Return value: %true if @buf is not fully consumed, %false otherwise.
|
||||
*
|
||||
* Since: 2.7.3
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_buffer_deserialize_unicode (hb_buffer_t *buffer,
|
||||
const char *buf,
|
||||
int buf_len, /* -1 means nul-terminated */
|
||||
const char **end_ptr, /* May be NULL */
|
||||
hb_buffer_serialize_format_t format)
|
||||
{
|
||||
const char *end;
|
||||
if (!end_ptr)
|
||||
end_ptr = &end;
|
||||
*end_ptr = buf;
|
||||
|
||||
buffer->assert_unicode ();
|
||||
|
||||
if (unlikely (hb_object_is_immutable (buffer)))
|
||||
{
|
||||
if (end_ptr)
|
||||
*end_ptr = buf;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buf_len == -1)
|
||||
buf_len = strlen (buf);
|
||||
|
||||
if (!buf_len)
|
||||
{
|
||||
*end_ptr = buf;
|
||||
return false;
|
||||
}
|
||||
|
||||
hb_buffer_set_content_type (buffer, HB_BUFFER_CONTENT_TYPE_UNICODE);
|
||||
|
||||
hb_font_t* font = hb_font_get_empty ();
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
|
||||
return _hb_buffer_deserialize_text (buffer,
|
||||
buf, buf_len, end_ptr,
|
||||
font);
|
||||
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_JSON:
|
||||
return _hb_buffer_deserialize_json (buffer,
|
||||
buf, buf_len, end_ptr,
|
||||
font);
|
||||
|
||||
default:
|
||||
case HB_BUFFER_SERIALIZE_FORMAT_INVALID:
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+367
-362
File diff suppressed because it is too large
Load Diff
+177
-17
@@ -27,7 +27,7 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_H_IN
|
||||
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb.h> instead."
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,6 @@ HB_BEGIN_DECLS
|
||||
* hb_glyph_info_t:
|
||||
* @codepoint: either a Unicode code point (before shaping) or a glyph index
|
||||
* (after shaping).
|
||||
* @mask:
|
||||
* @cluster: the index of the character in the original text that corresponds
|
||||
* to this #hb_glyph_info_t, or whatever the client passes to
|
||||
* hb_buffer_add(). More than one #hb_glyph_info_t can have the same
|
||||
@@ -59,11 +58,12 @@ HB_BEGIN_DECLS
|
||||
*
|
||||
* The #hb_glyph_info_t is the structure that holds information about the
|
||||
* glyphs and their relation to input text.
|
||||
*
|
||||
*/
|
||||
typedef struct hb_glyph_info_t {
|
||||
hb_codepoint_t codepoint;
|
||||
hb_mask_t mask; /* Holds hb_glyph_flags_t after hb_shape(), plus other things. */
|
||||
/*< private >*/
|
||||
hb_mask_t mask;
|
||||
/*< public >*/
|
||||
uint32_t cluster;
|
||||
|
||||
/*< private >*/
|
||||
@@ -71,6 +71,29 @@ typedef struct hb_glyph_info_t {
|
||||
hb_var_int_t var2;
|
||||
} hb_glyph_info_t;
|
||||
|
||||
/**
|
||||
* hb_glyph_flags_t:
|
||||
* @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the
|
||||
* beginning of the cluster this glyph is part of,
|
||||
* then both sides need to be re-shaped, as the
|
||||
* result might be different. On the flip side,
|
||||
* it means that when this flag is not present,
|
||||
* then it's safe to break the glyph-run at the
|
||||
* beginning of this cluster, and the two sides
|
||||
* represent the exact same result one would get
|
||||
* if breaking input text at the beginning of
|
||||
* this cluster and shaping the two sides
|
||||
* separately. This can be used to optimize
|
||||
* paragraph layout, by avoiding re-shaping
|
||||
* of each line after line-breaking, or limiting
|
||||
* the reshaping to a small piece around the
|
||||
* breaking point only.
|
||||
* @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.
|
||||
*
|
||||
* Flags for #hb_glyph_info_t.
|
||||
*
|
||||
* Since: 1.5.0
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,
|
||||
|
||||
@@ -129,11 +152,16 @@ typedef struct hb_segment_properties_t {
|
||||
void *reserved2;
|
||||
} hb_segment_properties_t;
|
||||
|
||||
/**
|
||||
* HB_SEGMENT_PROPERTIES_DEFAULT:
|
||||
*
|
||||
* The default #hb_segment_properties_t of of freshly created #hb_buffer_t.
|
||||
*/
|
||||
#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \
|
||||
HB_SCRIPT_INVALID, \
|
||||
HB_LANGUAGE_INVALID, \
|
||||
NULL, \
|
||||
NULL}
|
||||
(void *) 0, \
|
||||
(void *) 0}
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_segment_properties_equal (const hb_segment_properties_t *a,
|
||||
@@ -182,6 +210,8 @@ hb_buffer_get_user_data (hb_buffer_t *buffer,
|
||||
* @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.
|
||||
* @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).
|
||||
* @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).
|
||||
*
|
||||
* The type of #hb_buffer_t contents.
|
||||
*/
|
||||
typedef enum {
|
||||
HB_BUFFER_CONTENT_TYPE_INVALID = 0,
|
||||
@@ -247,13 +277,27 @@ hb_buffer_guess_segment_properties (hb_buffer_t *buffer);
|
||||
* of the text without the full context.
|
||||
* @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text
|
||||
* paragraph can be applied to this buffer, similar to
|
||||
* @HB_BUFFER_FLAG_EOT.
|
||||
* @HB_BUFFER_FLAG_BOT.
|
||||
* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES:
|
||||
* flag indication that character with Default_Ignorable
|
||||
* Unicode property should use the corresponding glyph
|
||||
* from the font, instead of hiding them (currently done
|
||||
* by replacing them with the space glyph and zeroing the
|
||||
* advance width.)
|
||||
* from the font, instead of hiding them (done by
|
||||
* replacing them with the space glyph and zeroing the
|
||||
* advance width.) This flag takes precedence over
|
||||
* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.
|
||||
* @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES:
|
||||
* flag indication that character with Default_Ignorable
|
||||
* Unicode property should be removed from glyph string
|
||||
* instead of hiding them (done by replacing them with the
|
||||
* space glyph and zeroing the advance width.)
|
||||
* @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes
|
||||
* precedence over this flag. Since: 1.8.0
|
||||
* @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE:
|
||||
* flag indicating that a dotted circle should
|
||||
* not be inserted in the rendering of incorrect
|
||||
* character sequences (such at <0905 093E>). Since: 2.4
|
||||
*
|
||||
* Flags for #hb_buffer_t.
|
||||
*
|
||||
* Since: 0.9.20
|
||||
*/
|
||||
@@ -261,7 +305,9 @@ typedef enum { /*< flags >*/
|
||||
HB_BUFFER_FLAG_DEFAULT = 0x00000000u,
|
||||
HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */
|
||||
HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */
|
||||
HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u
|
||||
HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u,
|
||||
HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u,
|
||||
HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u
|
||||
} hb_buffer_flags_t;
|
||||
|
||||
HB_EXTERN void
|
||||
@@ -271,7 +317,32 @@ hb_buffer_set_flags (hb_buffer_t *buffer,
|
||||
HB_EXTERN hb_buffer_flags_t
|
||||
hb_buffer_get_flags (hb_buffer_t *buffer);
|
||||
|
||||
/*
|
||||
/**
|
||||
* hb_buffer_cluster_level_t:
|
||||
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into
|
||||
* monotone order.
|
||||
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order.
|
||||
* @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values.
|
||||
* @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level,
|
||||
* equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.
|
||||
*
|
||||
* Data type for holding HarfBuzz's clustering behavior options. The cluster level
|
||||
* dictates one aspect of how HarfBuzz will treat non-base characters
|
||||
* during shaping.
|
||||
*
|
||||
* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base
|
||||
* characters are merged into the cluster of the base character that precedes them.
|
||||
*
|
||||
* In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially
|
||||
* assigned their own cluster values, which are not merged into preceding base
|
||||
* clusters. This allows HarfBuzz to perform additional operations like reorder
|
||||
* sequences of adjacent marks.
|
||||
*
|
||||
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains
|
||||
* backward compatibility with older versions of HarfBuzz. New client programs that
|
||||
* do not need to maintain such backward compatibility are recommended to use
|
||||
* @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default.
|
||||
*
|
||||
* Since: 0.9.42
|
||||
*/
|
||||
typedef enum {
|
||||
@@ -305,6 +376,13 @@ hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,
|
||||
HB_EXTERN hb_codepoint_t
|
||||
hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,
|
||||
hb_codepoint_t invisible);
|
||||
|
||||
HB_EXTERN hb_codepoint_t
|
||||
hb_buffer_get_invisible_glyph (hb_buffer_t *buffer);
|
||||
|
||||
|
||||
HB_EXTERN void
|
||||
hb_buffer_reset (hb_buffer_t *buffer);
|
||||
@@ -314,7 +392,7 @@ hb_buffer_clear_contents (hb_buffer_t *buffer);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_buffer_pre_allocate (hb_buffer_t *buffer,
|
||||
unsigned int size);
|
||||
unsigned int size);
|
||||
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
@@ -390,11 +468,14 @@ hb_buffer_get_length (hb_buffer_t *buffer);
|
||||
|
||||
HB_EXTERN hb_glyph_info_t *
|
||||
hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
|
||||
unsigned int *length);
|
||||
unsigned int *length);
|
||||
|
||||
HB_EXTERN hb_glyph_position_t *
|
||||
hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
|
||||
unsigned int *length);
|
||||
unsigned int *length);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_buffer_has_positions (hb_buffer_t *buffer);
|
||||
|
||||
|
||||
HB_EXTERN void
|
||||
@@ -412,6 +493,9 @@ hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
|
||||
* @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.
|
||||
* @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.
|
||||
* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.
|
||||
* @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0
|
||||
* @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances,
|
||||
* glyph offsets will reflect absolute glyph positions. Since: 1.8.0
|
||||
*
|
||||
* Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().
|
||||
*
|
||||
@@ -423,7 +507,8 @@ typedef enum { /*< flags >*/
|
||||
HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,
|
||||
HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,
|
||||
HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u,
|
||||
HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u
|
||||
HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u,
|
||||
HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u
|
||||
} hb_buffer_serialize_flags_t;
|
||||
|
||||
/**
|
||||
@@ -463,6 +548,27 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_buffer_serialize_unicode (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_buffer_serialize (hb_buffer_t *buffer,
|
||||
unsigned int start,
|
||||
unsigned int end,
|
||||
char *buf,
|
||||
unsigned int buf_size,
|
||||
unsigned int *buf_consumed,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_format_t format,
|
||||
hb_buffer_serialize_flags_t flags);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
|
||||
const char *buf,
|
||||
@@ -471,11 +577,48 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
|
||||
hb_font_t *font,
|
||||
hb_buffer_serialize_format_t format);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_buffer_deserialize_unicode (hb_buffer_t *buffer,
|
||||
const char *buf,
|
||||
int buf_len,
|
||||
const char **end_ptr,
|
||||
hb_buffer_serialize_format_t format);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Compare buffers
|
||||
*/
|
||||
|
||||
/**
|
||||
* hb_buffer_diff_flags_t:
|
||||
* @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers.
|
||||
* @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different
|
||||
* #hb_buffer_content_type_t.
|
||||
* @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length.
|
||||
* @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the
|
||||
* reference buffer.
|
||||
* @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present
|
||||
* in the reference buffer.
|
||||
* @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint
|
||||
* @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster
|
||||
* @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t.
|
||||
* @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t.
|
||||
*
|
||||
* Flags from comparing two #hb_buffer_t's.
|
||||
*
|
||||
* Buffer with different #hb_buffer_content_type_t cannot be meaningfully
|
||||
* compared in any further detail.
|
||||
*
|
||||
* For buffers with differing length, the per-glyph comparison is not
|
||||
* attempted, though we do still scan reference buffer for dotted circle and
|
||||
* `.notdef` glyphs.
|
||||
*
|
||||
* If the buffers have the same length, we compare them glyph-by-glyph and
|
||||
* report which aspect(s) of the glyph info/position are different.
|
||||
*
|
||||
* Since: 1.5.0
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000,
|
||||
|
||||
@@ -504,7 +647,7 @@ typedef enum { /*< flags >*/
|
||||
} hb_buffer_diff_flags_t;
|
||||
|
||||
/* Compare the contents of two buffers, report types of differences. */
|
||||
hb_buffer_diff_flags_t
|
||||
HB_EXTERN hb_buffer_diff_flags_t
|
||||
hb_buffer_diff (hb_buffer_t *buffer,
|
||||
hb_buffer_t *reference,
|
||||
hb_codepoint_t dottedcircle_glyph,
|
||||
@@ -515,6 +658,23 @@ hb_buffer_diff (hb_buffer_t *buffer,
|
||||
* Debugging.
|
||||
*/
|
||||
|
||||
/**
|
||||
* hb_buffer_message_func_t:
|
||||
* @buffer: An #hb_buffer_t to work upon
|
||||
* @font: The #hb_font_t the @buffer is shaped with
|
||||
* @message: %NULL-terminated message passed to the function
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A callback method for #hb_buffer_t. The method gets called with the
|
||||
* #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a
|
||||
* message describing what step of the shaping process will be performed.
|
||||
* Returning %false from this method will skip this shaping step and move to
|
||||
* the next one.
|
||||
*
|
||||
* Return value: %true to perform the shaping step, %false to skip it.
|
||||
*
|
||||
* Since: 1.1.3
|
||||
*/
|
||||
typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,
|
||||
hb_font_t *font,
|
||||
const char *message,
|
||||
|
||||
@@ -27,26 +27,35 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_BUFFER_PRIVATE_HH
|
||||
#define HB_BUFFER_PRIVATE_HH
|
||||
#ifndef HB_BUFFER_HH
|
||||
#define HB_BUFFER_HH
|
||||
|
||||
#include "hb-private.hh"
|
||||
#include "hb-object-private.hh"
|
||||
#include "hb-unicode-private.hh"
|
||||
#include "hb.hh"
|
||||
#include "hb-unicode.hh"
|
||||
|
||||
|
||||
#ifndef HB_BUFFER_MAX_EXPANSION_FACTOR
|
||||
#define HB_BUFFER_MAX_EXPANSION_FACTOR 32
|
||||
#ifndef HB_BUFFER_MAX_LEN_FACTOR
|
||||
#define HB_BUFFER_MAX_LEN_FACTOR 64
|
||||
#endif
|
||||
#ifndef HB_BUFFER_MAX_LEN_MIN
|
||||
#define HB_BUFFER_MAX_LEN_MIN 8192
|
||||
#define HB_BUFFER_MAX_LEN_MIN 16384
|
||||
#endif
|
||||
#ifndef HB_BUFFER_MAX_LEN_DEFAULT
|
||||
#define HB_BUFFER_MAX_LEN_DEFAULT 0x3FFFFFFF /* Shaping more than a billion chars? Let us know! */
|
||||
#endif
|
||||
|
||||
ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20);
|
||||
ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
|
||||
#ifndef HB_BUFFER_MAX_OPS_FACTOR
|
||||
#define HB_BUFFER_MAX_OPS_FACTOR 1024
|
||||
#endif
|
||||
#ifndef HB_BUFFER_MAX_OPS_MIN
|
||||
#define HB_BUFFER_MAX_OPS_MIN 16384
|
||||
#endif
|
||||
#ifndef HB_BUFFER_MAX_OPS_DEFAULT
|
||||
#define HB_BUFFER_MAX_OPS_DEFAULT 0x1FFFFFFF /* Shaping more than a billion operations? Let us know! */
|
||||
#endif
|
||||
|
||||
static_assert ((sizeof (hb_glyph_info_t) == 20), "");
|
||||
static_assert ((sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)), "");
|
||||
|
||||
HB_MARK_AS_FLAG_T (hb_buffer_flags_t);
|
||||
HB_MARK_AS_FLAG_T (hb_buffer_serialize_flags_t);
|
||||
@@ -59,6 +68,7 @@ enum hb_buffer_scratch_flags_t {
|
||||
HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u,
|
||||
HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u,
|
||||
HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK = 0x00000010u,
|
||||
HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000020u,
|
||||
|
||||
/* Reserved for complex shapers' internal use. */
|
||||
HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u,
|
||||
@@ -73,23 +83,25 @@ HB_MARK_AS_FLAG_T (hb_buffer_scratch_flags_t);
|
||||
* hb_buffer_t
|
||||
*/
|
||||
|
||||
struct hb_buffer_t {
|
||||
struct hb_buffer_t
|
||||
{
|
||||
hb_object_header_t header;
|
||||
ASSERT_POD ();
|
||||
|
||||
/* Information about how the text in the buffer should be treated */
|
||||
hb_unicode_funcs_t *unicode; /* Unicode functions */
|
||||
hb_buffer_flags_t flags; /* BOT / EOT / etc. */
|
||||
hb_buffer_cluster_level_t cluster_level;
|
||||
hb_codepoint_t replacement; /* U+FFFD or something else. */
|
||||
hb_buffer_scratch_flags_t scratch_flags; /* Have space-flallback, etc. */
|
||||
hb_codepoint_t invisible; /* 0 or something else. */
|
||||
hb_buffer_scratch_flags_t scratch_flags; /* Have space-fallback, etc. */
|
||||
unsigned int max_len; /* Maximum allowed len. */
|
||||
int max_ops; /* Maximum allowed operations. */
|
||||
|
||||
/* Buffer contents */
|
||||
hb_buffer_content_type_t content_type;
|
||||
hb_segment_properties_t props; /* Script, language, direction */
|
||||
|
||||
bool in_error; /* Allocation failed */
|
||||
bool successful; /* Allocations successful */
|
||||
bool have_output; /* Whether we have an output buffer going on */
|
||||
bool have_positions; /* Whether we have positions */
|
||||
|
||||
@@ -102,37 +114,37 @@ struct hb_buffer_t {
|
||||
hb_glyph_info_t *out_info;
|
||||
hb_glyph_position_t *pos;
|
||||
|
||||
inline hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; }
|
||||
inline hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; }
|
||||
|
||||
inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; }
|
||||
inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; }
|
||||
|
||||
inline hb_glyph_info_t &prev (void) { return out_info[out_len ? out_len - 1 : 0]; }
|
||||
inline hb_glyph_info_t prev (void) const { return out_info[out_len ? out_len - 1 : 0]; }
|
||||
|
||||
inline bool has_separate_output (void) const { return info != out_info; }
|
||||
|
||||
unsigned int serial;
|
||||
|
||||
/* Text before / after the main buffer contents.
|
||||
* Always in Unicode, and ordered outward.
|
||||
* Index 0 is for "pre-context", 1 for "post-context". */
|
||||
static const unsigned int CONTEXT_LENGTH = 5;
|
||||
static constexpr unsigned CONTEXT_LENGTH = 5u;
|
||||
hb_codepoint_t context[2][CONTEXT_LENGTH];
|
||||
unsigned int context_len[2];
|
||||
|
||||
/* Debugging API */
|
||||
#ifndef HB_NO_BUFFER_MESSAGE
|
||||
hb_buffer_message_func_t message_func;
|
||||
void *message_data;
|
||||
hb_destroy_func_t message_destroy;
|
||||
unsigned message_depth; /* How deeply are we inside a message callback? */
|
||||
#else
|
||||
static constexpr unsigned message_depth = 0u;
|
||||
#endif
|
||||
|
||||
/* Internal debugging. */
|
||||
/* The bits here reflect current allocations of the bytes in glyph_info_t's var1 and var2. */
|
||||
#ifndef HB_NDEBUG
|
||||
uint8_t allocated_var_bits;
|
||||
#endif
|
||||
inline void allocate_var (unsigned int start, unsigned int count)
|
||||
|
||||
|
||||
/* Methods */
|
||||
|
||||
HB_NODISCARD bool in_error () const { return !successful; }
|
||||
|
||||
void allocate_var (unsigned int start, unsigned int count)
|
||||
{
|
||||
#ifndef HB_NDEBUG
|
||||
unsigned int end = start + count;
|
||||
@@ -142,7 +154,7 @@ struct hb_buffer_t {
|
||||
allocated_var_bits |= bits;
|
||||
#endif
|
||||
}
|
||||
inline void deallocate_var (unsigned int start, unsigned int count)
|
||||
void deallocate_var (unsigned int start, unsigned int count)
|
||||
{
|
||||
#ifndef HB_NDEBUG
|
||||
unsigned int end = start + count;
|
||||
@@ -152,7 +164,7 @@ struct hb_buffer_t {
|
||||
allocated_var_bits &= ~bits;
|
||||
#endif
|
||||
}
|
||||
inline void assert_var (unsigned int start, unsigned int count)
|
||||
void assert_var (unsigned int start, unsigned int count)
|
||||
{
|
||||
#ifndef HB_NDEBUG
|
||||
unsigned int end = start + count;
|
||||
@@ -161,76 +173,138 @@ struct hb_buffer_t {
|
||||
assert (bits == (allocated_var_bits & bits));
|
||||
#endif
|
||||
}
|
||||
inline void deallocate_var_all (void)
|
||||
void deallocate_var_all ()
|
||||
{
|
||||
#ifndef HB_NDEBUG
|
||||
allocated_var_bits = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; }
|
||||
hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; }
|
||||
|
||||
/* Methods */
|
||||
hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; }
|
||||
hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; }
|
||||
|
||||
HB_INTERNAL void reset (void);
|
||||
HB_INTERNAL void clear (void);
|
||||
hb_glyph_info_t &prev () { return out_info[out_len ? out_len - 1 : 0]; }
|
||||
hb_glyph_info_t prev () const { return out_info[out_len ? out_len - 1 : 0]; }
|
||||
|
||||
inline unsigned int backtrack_len (void) const
|
||||
{ return have_output? out_len : idx; }
|
||||
inline unsigned int lookahead_len (void) const
|
||||
{ return len - idx; }
|
||||
inline unsigned int next_serial (void) { return serial++; }
|
||||
HB_NODISCARD bool has_separate_output () const { return info != out_info; }
|
||||
|
||||
|
||||
HB_INTERNAL void reset ();
|
||||
HB_INTERNAL void clear ();
|
||||
|
||||
unsigned int backtrack_len () const { return have_output? out_len : idx; }
|
||||
unsigned int lookahead_len () const { return len - idx; }
|
||||
unsigned int next_serial () { return serial++; }
|
||||
|
||||
HB_INTERNAL void add (hb_codepoint_t codepoint,
|
||||
unsigned int cluster);
|
||||
HB_INTERNAL void add_info (const hb_glyph_info_t &glyph_info);
|
||||
|
||||
HB_INTERNAL void reverse_range (unsigned int start, unsigned int end);
|
||||
HB_INTERNAL void reverse (void);
|
||||
HB_INTERNAL void reverse_clusters (void);
|
||||
HB_INTERNAL void guess_segment_properties (void);
|
||||
HB_INTERNAL void reverse ();
|
||||
HB_INTERNAL void reverse_clusters ();
|
||||
HB_INTERNAL void guess_segment_properties ();
|
||||
|
||||
HB_INTERNAL void swap_buffers (void);
|
||||
HB_INTERNAL void remove_output (void);
|
||||
HB_INTERNAL void clear_output (void);
|
||||
HB_INTERNAL void clear_positions (void);
|
||||
HB_INTERNAL void swap_buffers ();
|
||||
HB_INTERNAL void remove_output ();
|
||||
HB_INTERNAL void clear_output ();
|
||||
HB_INTERNAL void clear_positions ();
|
||||
|
||||
HB_INTERNAL void replace_glyphs (unsigned int num_in,
|
||||
unsigned int num_out,
|
||||
const hb_codepoint_t *glyph_data);
|
||||
template <typename T>
|
||||
HB_NODISCARD bool replace_glyphs (unsigned int num_in,
|
||||
unsigned int num_out,
|
||||
const T *glyph_data)
|
||||
{
|
||||
if (unlikely (!make_room_for (num_in, num_out))) return false;
|
||||
|
||||
assert (idx + num_in <= len);
|
||||
|
||||
merge_clusters (idx, idx + num_in);
|
||||
|
||||
hb_glyph_info_t &orig_info = idx < len ? cur() : prev();
|
||||
|
||||
hb_glyph_info_t *pinfo = &out_info[out_len];
|
||||
for (unsigned int i = 0; i < num_out; i++)
|
||||
{
|
||||
*pinfo = orig_info;
|
||||
pinfo->codepoint = glyph_data[i];
|
||||
pinfo++;
|
||||
}
|
||||
|
||||
idx += num_in;
|
||||
out_len += num_out;
|
||||
return true;
|
||||
}
|
||||
|
||||
HB_NODISCARD bool replace_glyph (hb_codepoint_t glyph_index)
|
||||
{ return replace_glyphs (1, 1, &glyph_index); }
|
||||
|
||||
HB_INTERNAL void replace_glyph (hb_codepoint_t glyph_index);
|
||||
/* Makes a copy of the glyph at idx to output and replace glyph_index */
|
||||
HB_INTERNAL void output_glyph (hb_codepoint_t glyph_index);
|
||||
HB_INTERNAL void output_info (const hb_glyph_info_t &glyph_info);
|
||||
HB_NODISCARD bool output_glyph (hb_codepoint_t glyph_index)
|
||||
{ return replace_glyphs (0, 1, &glyph_index); }
|
||||
|
||||
HB_NODISCARD bool output_info (const hb_glyph_info_t &glyph_info)
|
||||
{
|
||||
if (unlikely (!make_room_for (0, 1))) return false;
|
||||
|
||||
out_info[out_len] = glyph_info;
|
||||
|
||||
out_len++;
|
||||
return true;
|
||||
}
|
||||
/* Copies glyph at idx to output but doesn't advance idx */
|
||||
HB_INTERNAL void copy_glyph (void);
|
||||
HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */
|
||||
HB_NODISCARD bool copy_glyph ()
|
||||
{
|
||||
/* Extra copy because cur()'s return can be freed within
|
||||
* output_info() call if buffer reallocates. */
|
||||
return output_info (hb_glyph_info_t (cur()));
|
||||
}
|
||||
|
||||
/* Copies glyph at idx to output and advance idx.
|
||||
* If there's no output, just advance idx. */
|
||||
inline void
|
||||
next_glyph (void)
|
||||
HB_NODISCARD bool next_glyph ()
|
||||
{
|
||||
if (have_output)
|
||||
{
|
||||
if (unlikely (out_info != info || out_len != idx)) {
|
||||
if (unlikely (!make_room_for (1, 1))) return;
|
||||
if (out_info != info || out_len != idx)
|
||||
{
|
||||
if (unlikely (!make_room_for (1, 1))) return false;
|
||||
out_info[out_len] = info[idx];
|
||||
}
|
||||
out_len++;
|
||||
}
|
||||
|
||||
idx++;
|
||||
return true;
|
||||
}
|
||||
/* Copies n glyphs at idx to output and advance idx.
|
||||
* If there's no output, just advance idx. */
|
||||
HB_NODISCARD bool next_glyphs (unsigned int n)
|
||||
{
|
||||
if (have_output)
|
||||
{
|
||||
if (out_info != info || out_len != idx)
|
||||
{
|
||||
if (unlikely (!make_room_for (n, n))) return false;
|
||||
memmove (out_info + out_len, info + idx, n * sizeof (out_info[0]));
|
||||
}
|
||||
out_len += n;
|
||||
}
|
||||
|
||||
idx += n;
|
||||
return true;
|
||||
}
|
||||
/* Advance idx without copying to output. */
|
||||
inline void skip_glyph (void) { idx++; }
|
||||
|
||||
inline void reset_masks (hb_mask_t mask)
|
||||
void skip_glyph () { idx++; }
|
||||
void reset_masks (hb_mask_t mask)
|
||||
{
|
||||
for (unsigned int j = 0; j < len; j++)
|
||||
info[j].mask = mask;
|
||||
}
|
||||
inline void add_masks (hb_mask_t mask)
|
||||
void add_masks (hb_mask_t mask)
|
||||
{
|
||||
for (unsigned int j = 0; j < len; j++)
|
||||
info[j].mask |= mask;
|
||||
@@ -238,7 +312,7 @@ struct hb_buffer_t {
|
||||
HB_INTERNAL void set_masks (hb_mask_t value, hb_mask_t mask,
|
||||
unsigned int cluster_start, unsigned int cluster_end);
|
||||
|
||||
inline void merge_clusters (unsigned int start, unsigned int end)
|
||||
void merge_clusters (unsigned int start, unsigned int end)
|
||||
{
|
||||
if (end - start < 2)
|
||||
return;
|
||||
@@ -247,10 +321,10 @@ struct hb_buffer_t {
|
||||
HB_INTERNAL void merge_clusters_impl (unsigned int start, unsigned int end);
|
||||
HB_INTERNAL void merge_out_clusters (unsigned int start, unsigned int end);
|
||||
/* Merge clusters for deleting current glyph, and skip it. */
|
||||
HB_INTERNAL void delete_glyph (void);
|
||||
HB_INTERNAL void delete_glyph ();
|
||||
|
||||
inline void unsafe_to_break (unsigned int start,
|
||||
unsigned int end)
|
||||
void unsafe_to_break (unsigned int start,
|
||||
unsigned int end)
|
||||
{
|
||||
if (end - start < 2)
|
||||
return;
|
||||
@@ -261,72 +335,132 @@ struct hb_buffer_t {
|
||||
|
||||
|
||||
/* Internal methods */
|
||||
HB_INTERNAL bool enlarge (unsigned int size);
|
||||
HB_NODISCARD HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */
|
||||
|
||||
inline bool ensure (unsigned int size)
|
||||
HB_NODISCARD HB_INTERNAL bool enlarge (unsigned int size);
|
||||
|
||||
HB_NODISCARD bool ensure (unsigned int size)
|
||||
{ return likely (!size || size < allocated) ? true : enlarge (size); }
|
||||
|
||||
inline bool ensure_inplace (unsigned int size)
|
||||
HB_NODISCARD bool ensure_inplace (unsigned int size)
|
||||
{ return likely (!size || size < allocated); }
|
||||
|
||||
HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
|
||||
HB_INTERNAL bool shift_forward (unsigned int count);
|
||||
void assert_glyphs ()
|
||||
{
|
||||
assert ((content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS) ||
|
||||
(!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
}
|
||||
void assert_unicode ()
|
||||
{
|
||||
assert ((content_type == HB_BUFFER_CONTENT_TYPE_UNICODE) ||
|
||||
(!len && (content_type == HB_BUFFER_CONTENT_TYPE_INVALID)));
|
||||
}
|
||||
HB_NODISCARD bool ensure_glyphs ()
|
||||
{
|
||||
if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
|
||||
{
|
||||
if (content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
|
||||
return false;
|
||||
assert (len == 0);
|
||||
content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
HB_NODISCARD bool ensure_unicode ()
|
||||
{
|
||||
if (unlikely (content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
|
||||
{
|
||||
if (content_type != HB_BUFFER_CONTENT_TYPE_INVALID)
|
||||
return false;
|
||||
assert (len == 0);
|
||||
content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HB_NODISCARD HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
|
||||
HB_NODISCARD HB_INTERNAL bool shift_forward (unsigned int count);
|
||||
|
||||
typedef long scratch_buffer_t;
|
||||
HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size);
|
||||
|
||||
inline void clear_context (unsigned int side) { context_len[side] = 0; }
|
||||
void clear_context (unsigned int side) { context_len[side] = 0; }
|
||||
|
||||
HB_INTERNAL void sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *));
|
||||
|
||||
inline bool messaging (void) { return unlikely (message_func); }
|
||||
inline bool message (hb_font_t *font, const char *fmt, ...) HB_PRINTF_FUNC(3, 4)
|
||||
bool messaging ()
|
||||
{
|
||||
#ifdef HB_NO_BUFFER_MESSAGE
|
||||
return false;
|
||||
#else
|
||||
return unlikely (message_func);
|
||||
#endif
|
||||
}
|
||||
bool message (hb_font_t *font, const char *fmt, ...) HB_PRINTF_FUNC(3, 4)
|
||||
{
|
||||
#ifdef HB_NO_BUFFER_MESSAGE
|
||||
return true;
|
||||
#else
|
||||
if (!messaging ())
|
||||
return true;
|
||||
|
||||
message_depth++;
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
bool ret = message_impl (font, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
message_depth--;
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
HB_INTERNAL bool message_impl (hb_font_t *font, const char *fmt, va_list ap) HB_PRINTF_FUNC(3, 0);
|
||||
|
||||
static inline void
|
||||
set_cluster (hb_glyph_info_t &info, unsigned int cluster, unsigned int mask = 0)
|
||||
static void
|
||||
set_cluster (hb_glyph_info_t &inf, unsigned int cluster, unsigned int mask = 0)
|
||||
{
|
||||
if (info.cluster != cluster)
|
||||
if (inf.cluster != cluster)
|
||||
{
|
||||
if (mask & HB_GLYPH_FLAG_UNSAFE_TO_BREAK)
|
||||
info.mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK;
|
||||
inf.mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK;
|
||||
else
|
||||
info.mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK;
|
||||
inf.mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK;
|
||||
}
|
||||
info.cluster = cluster;
|
||||
inf.cluster = cluster;
|
||||
}
|
||||
|
||||
int
|
||||
_unsafe_to_break_find_min_cluster (const hb_glyph_info_t *info,
|
||||
unsigned int
|
||||
_unsafe_to_break_find_min_cluster (const hb_glyph_info_t *infos,
|
||||
unsigned int start, unsigned int end,
|
||||
unsigned int cluster) const
|
||||
{
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
cluster = MIN (cluster, info[i].cluster);
|
||||
cluster = hb_min (cluster, infos[i].cluster);
|
||||
return cluster;
|
||||
}
|
||||
void
|
||||
_unsafe_to_break_set_mask (hb_glyph_info_t *info,
|
||||
_unsafe_to_break_set_mask (hb_glyph_info_t *infos,
|
||||
unsigned int start, unsigned int end,
|
||||
unsigned int cluster)
|
||||
{
|
||||
for (unsigned int i = start; i < end; i++)
|
||||
if (cluster != info[i].cluster)
|
||||
if (cluster != infos[i].cluster)
|
||||
{
|
||||
scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK;
|
||||
info[i].mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK;
|
||||
infos[i].mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
void unsafe_to_break_all () { unsafe_to_break_impl (0, len); }
|
||||
void safe_to_break_all ()
|
||||
{
|
||||
for (unsigned int i = 0; i < len; i++)
|
||||
info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK;
|
||||
}
|
||||
};
|
||||
DECLARE_NULL_INSTANCE (hb_buffer_t);
|
||||
|
||||
|
||||
/* Loop over clusters. Duplicated in foreach_syllable(). */
|
||||
@@ -359,4 +493,4 @@ _next_cluster (hb_buffer_t *buffer, unsigned int start)
|
||||
#define HB_BUFFER_ASSERT_VAR(b, var) HB_BUFFER_XALLOCATE_VAR (b, assert_var, var ())
|
||||
|
||||
|
||||
#endif /* HB_BUFFER_PRIVATE_HH */
|
||||
#endif /* HB_BUFFER_HH */
|
||||
@@ -24,51 +24,57 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_CACHE_PRIVATE_HH
|
||||
#define HB_CACHE_PRIVATE_HH
|
||||
#ifndef HB_CACHE_HH
|
||||
#define HB_CACHE_HH
|
||||
|
||||
#include "hb-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
|
||||
/* Implements a lock-free cache for int->int functions. */
|
||||
/* Implements a lockfree cache for int->int functions. */
|
||||
|
||||
template <unsigned int key_bits, unsigned int value_bits, unsigned int cache_bits>
|
||||
struct hb_cache_t
|
||||
{
|
||||
ASSERT_STATIC (key_bits >= cache_bits);
|
||||
ASSERT_STATIC (key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int));
|
||||
static_assert ((key_bits >= cache_bits), "");
|
||||
static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (hb_atomic_int_t)), "");
|
||||
static_assert (sizeof (hb_atomic_int_t) == sizeof (unsigned int), "");
|
||||
|
||||
inline void clear (void)
|
||||
void init () { clear (); }
|
||||
void fini () {}
|
||||
|
||||
void clear ()
|
||||
{
|
||||
memset (values, 255, sizeof (values));
|
||||
for (unsigned i = 0; i < ARRAY_LENGTH (values); i++)
|
||||
values[i].set_relaxed (-1);
|
||||
}
|
||||
|
||||
inline bool get (unsigned int key, unsigned int *value)
|
||||
bool get (unsigned int key, unsigned int *value) const
|
||||
{
|
||||
unsigned int k = key & ((1u<<cache_bits)-1);
|
||||
unsigned int v = values[k];
|
||||
if ((v >> value_bits) != (key >> cache_bits))
|
||||
unsigned int v = values[k].get_relaxed ();
|
||||
if ((key_bits + value_bits - cache_bits == 8 * sizeof (hb_atomic_int_t) && v == (unsigned int) -1) ||
|
||||
(v >> value_bits) != (key >> cache_bits))
|
||||
return false;
|
||||
*value = v & ((1u<<value_bits)-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool set (unsigned int key, unsigned int value)
|
||||
bool set (unsigned int key, unsigned int value)
|
||||
{
|
||||
if (unlikely ((key >> key_bits) || (value >> value_bits)))
|
||||
return false; /* Overflows */
|
||||
unsigned int k = key & ((1u<<cache_bits)-1);
|
||||
unsigned int v = ((key>>cache_bits)<<value_bits) | value;
|
||||
values[k] = v;
|
||||
values[k].set_relaxed (v);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int values[1u<<cache_bits];
|
||||
hb_atomic_int_t values[1u<<cache_bits];
|
||||
};
|
||||
|
||||
typedef hb_cache_t<21, 16, 8> hb_cmap_cache_t;
|
||||
typedef hb_cache_t<16, 24, 8> hb_advance_cache_t;
|
||||
|
||||
|
||||
#endif /* HB_CACHE_PRIVATE_HH */
|
||||
#endif /* HB_CACHE_HH */
|
||||
@@ -0,0 +1,688 @@
|
||||
/*
|
||||
* Copyright © 2018 Adobe 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.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
#ifndef HB_CFF_INTERP_COMMON_HH
|
||||
#define HB_CFF_INTERP_COMMON_HH
|
||||
|
||||
namespace CFF {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
typedef unsigned int op_code_t;
|
||||
|
||||
|
||||
/* === Dict operators === */
|
||||
|
||||
/* One byte operators (0-31) */
|
||||
#define OpCode_version 0 /* CFF Top */
|
||||
#define OpCode_Notice 1 /* CFF Top */
|
||||
#define OpCode_FullName 2 /* CFF Top */
|
||||
#define OpCode_FamilyName 3 /* CFF Top */
|
||||
#define OpCode_Weight 4 /* CFF Top */
|
||||
#define OpCode_FontBBox 5 /* CFF Top */
|
||||
#define OpCode_BlueValues 6 /* CFF Private, CFF2 Private */
|
||||
#define OpCode_OtherBlues 7 /* CFF Private, CFF2 Private */
|
||||
#define OpCode_FamilyBlues 8 /* CFF Private, CFF2 Private */
|
||||
#define OpCode_FamilyOtherBlues 9 /* CFF Private, CFF2 Private */
|
||||
#define OpCode_StdHW 10 /* CFF Private, CFF2 Private */
|
||||
#define OpCode_StdVW 11 /* CFF Private, CFF2 Private */
|
||||
#define OpCode_escape 12 /* All. Shared with CS */
|
||||
#define OpCode_UniqueID 13 /* CFF Top */
|
||||
#define OpCode_XUID 14 /* CFF Top */
|
||||
#define OpCode_charset 15 /* CFF Top (0) */
|
||||
#define OpCode_Encoding 16 /* CFF Top (0) */
|
||||
#define OpCode_CharStrings 17 /* CFF Top, CFF2 Top */
|
||||
#define OpCode_Private 18 /* CFF Top, CFF2 FD */
|
||||
#define OpCode_Subrs 19 /* CFF Private, CFF2 Private */
|
||||
#define OpCode_defaultWidthX 20 /* CFF Private (0) */
|
||||
#define OpCode_nominalWidthX 21 /* CFF Private (0) */
|
||||
#define OpCode_vsindexdict 22 /* CFF2 Private/CS */
|
||||
#define OpCode_blenddict 23 /* CFF2 Private/CS */
|
||||
#define OpCode_vstore 24 /* CFF2 Top */
|
||||
#define OpCode_reserved25 25
|
||||
#define OpCode_reserved26 26
|
||||
#define OpCode_reserved27 27
|
||||
|
||||
/* Numbers */
|
||||
#define OpCode_shortint 28 /* 16-bit integer, All */
|
||||
#define OpCode_longintdict 29 /* 32-bit integer, All */
|
||||
#define OpCode_BCD 30 /* Real number, CFF2 Top/FD */
|
||||
#define OpCode_reserved31 31
|
||||
|
||||
/* 1-byte integers */
|
||||
#define OpCode_OneByteIntFirst 32 /* All. beginning of the range of first byte ints */
|
||||
#define OpCode_OneByteIntLast 246 /* All. ending of the range of first byte int */
|
||||
|
||||
/* 2-byte integers */
|
||||
#define OpCode_TwoBytePosInt0 247 /* All. first byte of two byte positive int (+108 to +1131) */
|
||||
#define OpCode_TwoBytePosInt1 248
|
||||
#define OpCode_TwoBytePosInt2 249
|
||||
#define OpCode_TwoBytePosInt3 250
|
||||
|
||||
#define OpCode_TwoByteNegInt0 251 /* All. first byte of two byte negative int (-1131 to -108) */
|
||||
#define OpCode_TwoByteNegInt1 252
|
||||
#define OpCode_TwoByteNegInt2 253
|
||||
#define OpCode_TwoByteNegInt3 254
|
||||
|
||||
/* Two byte escape operators 12, (0-41) */
|
||||
#define OpCode_ESC_Base 256
|
||||
#define Make_OpCode_ESC(byte2) ((op_code_t)(OpCode_ESC_Base + (byte2)))
|
||||
|
||||
inline op_code_t Unmake_OpCode_ESC (op_code_t op) { return (op_code_t)(op - OpCode_ESC_Base); }
|
||||
inline bool Is_OpCode_ESC (op_code_t op) { return op >= OpCode_ESC_Base; }
|
||||
inline unsigned int OpCode_Size (op_code_t op) { return Is_OpCode_ESC (op) ? 2: 1; }
|
||||
|
||||
#define OpCode_Copyright Make_OpCode_ESC(0) /* CFF Top */
|
||||
#define OpCode_isFixedPitch Make_OpCode_ESC(1) /* CFF Top (false) */
|
||||
#define OpCode_ItalicAngle Make_OpCode_ESC(2) /* CFF Top (0) */
|
||||
#define OpCode_UnderlinePosition Make_OpCode_ESC(3) /* CFF Top (-100) */
|
||||
#define OpCode_UnderlineThickness Make_OpCode_ESC(4) /* CFF Top (50) */
|
||||
#define OpCode_PaintType Make_OpCode_ESC(5) /* CFF Top (0) */
|
||||
#define OpCode_CharstringType Make_OpCode_ESC(6) /* CFF Top (2) */
|
||||
#define OpCode_FontMatrix Make_OpCode_ESC(7) /* CFF Top, CFF2 Top (.001 0 0 .001 0 0)*/
|
||||
#define OpCode_StrokeWidth Make_OpCode_ESC(8) /* CFF Top (0) */
|
||||
#define OpCode_BlueScale Make_OpCode_ESC(9) /* CFF Private, CFF2 Private (0.039625) */
|
||||
#define OpCode_BlueShift Make_OpCode_ESC(10) /* CFF Private, CFF2 Private (7) */
|
||||
#define OpCode_BlueFuzz Make_OpCode_ESC(11) /* CFF Private, CFF2 Private (1) */
|
||||
#define OpCode_StemSnapH Make_OpCode_ESC(12) /* CFF Private, CFF2 Private */
|
||||
#define OpCode_StemSnapV Make_OpCode_ESC(13) /* CFF Private, CFF2 Private */
|
||||
#define OpCode_ForceBold Make_OpCode_ESC(14) /* CFF Private (false) */
|
||||
#define OpCode_reservedESC15 Make_OpCode_ESC(15)
|
||||
#define OpCode_reservedESC16 Make_OpCode_ESC(16)
|
||||
#define OpCode_LanguageGroup Make_OpCode_ESC(17) /* CFF Private, CFF2 Private (0) */
|
||||
#define OpCode_ExpansionFactor Make_OpCode_ESC(18) /* CFF Private, CFF2 Private (0.06) */
|
||||
#define OpCode_initialRandomSeed Make_OpCode_ESC(19) /* CFF Private (0) */
|
||||
#define OpCode_SyntheticBase Make_OpCode_ESC(20) /* CFF Top */
|
||||
#define OpCode_PostScript Make_OpCode_ESC(21) /* CFF Top */
|
||||
#define OpCode_BaseFontName Make_OpCode_ESC(22) /* CFF Top */
|
||||
#define OpCode_BaseFontBlend Make_OpCode_ESC(23) /* CFF Top */
|
||||
#define OpCode_reservedESC24 Make_OpCode_ESC(24)
|
||||
#define OpCode_reservedESC25 Make_OpCode_ESC(25)
|
||||
#define OpCode_reservedESC26 Make_OpCode_ESC(26)
|
||||
#define OpCode_reservedESC27 Make_OpCode_ESC(27)
|
||||
#define OpCode_reservedESC28 Make_OpCode_ESC(28)
|
||||
#define OpCode_reservedESC29 Make_OpCode_ESC(29)
|
||||
#define OpCode_ROS Make_OpCode_ESC(30) /* CFF Top_CID */
|
||||
#define OpCode_CIDFontVersion Make_OpCode_ESC(31) /* CFF Top_CID (0) */
|
||||
#define OpCode_CIDFontRevision Make_OpCode_ESC(32) /* CFF Top_CID (0) */
|
||||
#define OpCode_CIDFontType Make_OpCode_ESC(33) /* CFF Top_CID (0) */
|
||||
#define OpCode_CIDCount Make_OpCode_ESC(34) /* CFF Top_CID (8720) */
|
||||
#define OpCode_UIDBase Make_OpCode_ESC(35) /* CFF Top_CID */
|
||||
#define OpCode_FDArray Make_OpCode_ESC(36) /* CFF Top_CID, CFF2 Top */
|
||||
#define OpCode_FDSelect Make_OpCode_ESC(37) /* CFF Top_CID, CFF2 Top */
|
||||
#define OpCode_FontName Make_OpCode_ESC(38) /* CFF Top_CID */
|
||||
|
||||
|
||||
/* === CharString operators === */
|
||||
|
||||
#define OpCode_hstem 1 /* CFF, CFF2 */
|
||||
#define OpCode_Reserved2 2
|
||||
#define OpCode_vstem 3 /* CFF, CFF2 */
|
||||
#define OpCode_vmoveto 4 /* CFF, CFF2 */
|
||||
#define OpCode_rlineto 5 /* CFF, CFF2 */
|
||||
#define OpCode_hlineto 6 /* CFF, CFF2 */
|
||||
#define OpCode_vlineto 7 /* CFF, CFF2 */
|
||||
#define OpCode_rrcurveto 8 /* CFF, CFF2 */
|
||||
#define OpCode_Reserved9 9
|
||||
#define OpCode_callsubr 10 /* CFF, CFF2 */
|
||||
#define OpCode_return 11 /* CFF */
|
||||
//#define OpCode_escape 12 /* CFF, CFF2 */
|
||||
#define OpCode_Reserved13 13
|
||||
#define OpCode_endchar 14 /* CFF */
|
||||
#define OpCode_vsindexcs 15 /* CFF2 */
|
||||
#define OpCode_blendcs 16 /* CFF2 */
|
||||
#define OpCode_Reserved17 17
|
||||
#define OpCode_hstemhm 18 /* CFF, CFF2 */
|
||||
#define OpCode_hintmask 19 /* CFF, CFF2 */
|
||||
#define OpCode_cntrmask 20 /* CFF, CFF2 */
|
||||
#define OpCode_rmoveto 21 /* CFF, CFF2 */
|
||||
#define OpCode_hmoveto 22 /* CFF, CFF2 */
|
||||
#define OpCode_vstemhm 23 /* CFF, CFF2 */
|
||||
#define OpCode_rcurveline 24 /* CFF, CFF2 */
|
||||
#define OpCode_rlinecurve 25 /* CFF, CFF2 */
|
||||
#define OpCode_vvcurveto 26 /* CFF, CFF2 */
|
||||
#define OpCode_hhcurveto 27 /* CFF, CFF2 */
|
||||
//#define OpCode_shortint 28 /* CFF, CFF2 */
|
||||
#define OpCode_callgsubr 29 /* CFF, CFF2 */
|
||||
#define OpCode_vhcurveto 30 /* CFF, CFF2 */
|
||||
#define OpCode_hvcurveto 31 /* CFF, CFF2 */
|
||||
|
||||
#define OpCode_fixedcs 255 /* 32-bit fixed */
|
||||
|
||||
/* Two byte escape operators 12, (0-41) */
|
||||
#define OpCode_dotsection Make_OpCode_ESC(0) /* CFF (obsoleted) */
|
||||
#define OpCode_ReservedESC1 Make_OpCode_ESC(1)
|
||||
#define OpCode_ReservedESC2 Make_OpCode_ESC(2)
|
||||
#define OpCode_and Make_OpCode_ESC(3) /* CFF */
|
||||
#define OpCode_or Make_OpCode_ESC(4) /* CFF */
|
||||
#define OpCode_not Make_OpCode_ESC(5) /* CFF */
|
||||
#define OpCode_ReservedESC6 Make_OpCode_ESC(6)
|
||||
#define OpCode_ReservedESC7 Make_OpCode_ESC(7)
|
||||
#define OpCode_ReservedESC8 Make_OpCode_ESC(8)
|
||||
#define OpCode_abs Make_OpCode_ESC(9) /* CFF */
|
||||
#define OpCode_add Make_OpCode_ESC(10) /* CFF */
|
||||
#define OpCode_sub Make_OpCode_ESC(11) /* CFF */
|
||||
#define OpCode_div Make_OpCode_ESC(12) /* CFF */
|
||||
#define OpCode_ReservedESC13 Make_OpCode_ESC(13)
|
||||
#define OpCode_neg Make_OpCode_ESC(14) /* CFF */
|
||||
#define OpCode_eq Make_OpCode_ESC(15) /* CFF */
|
||||
#define OpCode_ReservedESC16 Make_OpCode_ESC(16)
|
||||
#define OpCode_ReservedESC17 Make_OpCode_ESC(17)
|
||||
#define OpCode_drop Make_OpCode_ESC(18) /* CFF */
|
||||
#define OpCode_ReservedESC19 Make_OpCode_ESC(19)
|
||||
#define OpCode_put Make_OpCode_ESC(20) /* CFF */
|
||||
#define OpCode_get Make_OpCode_ESC(21) /* CFF */
|
||||
#define OpCode_ifelse Make_OpCode_ESC(22) /* CFF */
|
||||
#define OpCode_random Make_OpCode_ESC(23) /* CFF */
|
||||
#define OpCode_mul Make_OpCode_ESC(24) /* CFF */
|
||||
//#define OpCode_reservedESC25 Make_OpCode_ESC(25)
|
||||
#define OpCode_sqrt Make_OpCode_ESC(26) /* CFF */
|
||||
#define OpCode_dup Make_OpCode_ESC(27) /* CFF */
|
||||
#define OpCode_exch Make_OpCode_ESC(28) /* CFF */
|
||||
#define OpCode_index Make_OpCode_ESC(29) /* CFF */
|
||||
#define OpCode_roll Make_OpCode_ESC(30) /* CFF */
|
||||
#define OpCode_reservedESC31 Make_OpCode_ESC(31)
|
||||
#define OpCode_reservedESC32 Make_OpCode_ESC(32)
|
||||
#define OpCode_reservedESC33 Make_OpCode_ESC(33)
|
||||
#define OpCode_hflex Make_OpCode_ESC(34) /* CFF, CFF2 */
|
||||
#define OpCode_flex Make_OpCode_ESC(35) /* CFF, CFF2 */
|
||||
#define OpCode_hflex1 Make_OpCode_ESC(36) /* CFF, CFF2 */
|
||||
#define OpCode_flex1 Make_OpCode_ESC(37) /* CFF, CFF2 */
|
||||
|
||||
|
||||
#define OpCode_Invalid 0xFFFFu
|
||||
|
||||
|
||||
struct number_t
|
||||
{
|
||||
void init () { set_real (0.0); }
|
||||
void fini () {}
|
||||
|
||||
void set_int (int v) { value = v; }
|
||||
int to_int () const { return value; }
|
||||
|
||||
void set_fixed (int32_t v) { value = v / 65536.0; }
|
||||
int32_t to_fixed () const { return value * 65536.0; }
|
||||
|
||||
void set_real (double v) { value = v; }
|
||||
double to_real () const { return value; }
|
||||
|
||||
bool in_int_range () const
|
||||
{ return ((double) (int16_t) to_int () == value); }
|
||||
|
||||
bool operator > (const number_t &n) const { return value > n.to_real (); }
|
||||
bool operator < (const number_t &n) const { return n > *this; }
|
||||
bool operator >= (const number_t &n) const { return !(*this < n); }
|
||||
bool operator <= (const number_t &n) const { return !(*this > n); }
|
||||
|
||||
const number_t &operator += (const number_t &n)
|
||||
{
|
||||
set_real (to_real () + n.to_real ());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
double value;
|
||||
};
|
||||
|
||||
/* byte string */
|
||||
struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
|
||||
{
|
||||
// encode 2-byte int (Dict/CharString) or 4-byte int (Dict)
|
||||
template <typename T, typename V>
|
||||
static bool serialize_int (hb_serialize_context_t *c, op_code_t intOp, V value)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
|
||||
HBUINT8 *p = c->allocate_size<HBUINT8> (1);
|
||||
if (unlikely (!p)) return_trace (false);
|
||||
*p = intOp;
|
||||
|
||||
T *ip = c->allocate_size<T> (T::static_size);
|
||||
if (unlikely (!ip)) return_trace (false);
|
||||
return_trace (c->check_assign (*ip, value, HB_SERIALIZE_ERROR_INT_OVERFLOW));
|
||||
}
|
||||
|
||||
template <typename V>
|
||||
static bool serialize_int4 (hb_serialize_context_t *c, V value)
|
||||
{ return serialize_int<HBINT32> (c, OpCode_longintdict, value); }
|
||||
|
||||
template <typename V>
|
||||
static bool serialize_int2 (hb_serialize_context_t *c, V value)
|
||||
{ return serialize_int<HBINT16> (c, OpCode_shortint, value); }
|
||||
|
||||
/* Defining null_size allows a Null object may be created. Should be safe because:
|
||||
* A descendent struct Dict uses a Null pointer to indicate a missing table,
|
||||
* checked before access.
|
||||
* byte_str_t, a wrapper struct pairing a byte pointer along with its length, always
|
||||
* checks the length before access. A Null pointer is used as the initial pointer
|
||||
* along with zero length by the default ctor.
|
||||
*/
|
||||
DEFINE_SIZE_MIN(0);
|
||||
};
|
||||
|
||||
/* Holder of a section of byte string within a CFFIndex entry */
|
||||
struct byte_str_t : hb_ubytes_t
|
||||
{
|
||||
byte_str_t ()
|
||||
: hb_ubytes_t () {}
|
||||
byte_str_t (const UnsizedByteStr& s, unsigned int l)
|
||||
: hb_ubytes_t ((const unsigned char*)&s, l) {}
|
||||
byte_str_t (const unsigned char *s, unsigned int l)
|
||||
: hb_ubytes_t (s, l) {}
|
||||
byte_str_t (const hb_ubytes_t &ub) /* conversion from hb_ubytes_t */
|
||||
: hb_ubytes_t (ub) {}
|
||||
|
||||
/* sub-string */
|
||||
byte_str_t sub_str (unsigned int offset, unsigned int len_) const
|
||||
{ return byte_str_t (hb_ubytes_t::sub_array (offset, len_)); }
|
||||
|
||||
bool check_limit (unsigned int offset, unsigned int count) const
|
||||
{ return (offset + count <= length); }
|
||||
};
|
||||
|
||||
/* A byte string associated with the current offset and an error condition */
|
||||
struct byte_str_ref_t
|
||||
{
|
||||
byte_str_ref_t () { init (); }
|
||||
|
||||
void init ()
|
||||
{
|
||||
str = byte_str_t ();
|
||||
offset = 0;
|
||||
error = false;
|
||||
}
|
||||
|
||||
void fini () {}
|
||||
|
||||
byte_str_ref_t (const byte_str_t &str_, unsigned int offset_ = 0)
|
||||
: str (str_), offset (offset_), error (false) {}
|
||||
|
||||
void reset (const byte_str_t &str_, unsigned int offset_ = 0)
|
||||
{
|
||||
str = str_;
|
||||
offset = offset_;
|
||||
error = false;
|
||||
}
|
||||
|
||||
const unsigned char& operator [] (int i) {
|
||||
if (unlikely ((unsigned int) (offset + i) >= str.length))
|
||||
{
|
||||
set_error ();
|
||||
return Null (unsigned char);
|
||||
}
|
||||
return str[offset + i];
|
||||
}
|
||||
|
||||
/* Conversion to byte_str_t */
|
||||
operator byte_str_t () const { return str.sub_str (offset, str.length - offset); }
|
||||
|
||||
byte_str_t sub_str (unsigned int offset_, unsigned int len_) const
|
||||
{ return str.sub_str (offset_, len_); }
|
||||
|
||||
bool avail (unsigned int count=1) const
|
||||
{ return (!in_error () && str.check_limit (offset, count)); }
|
||||
void inc (unsigned int count=1)
|
||||
{
|
||||
if (likely (!in_error () && (offset <= str.length) && (offset + count <= str.length)))
|
||||
{
|
||||
offset += count;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = str.length;
|
||||
set_error ();
|
||||
}
|
||||
}
|
||||
|
||||
void set_error () { error = true; }
|
||||
bool in_error () const { return error; }
|
||||
|
||||
byte_str_t str;
|
||||
unsigned int offset; /* beginning of the sub-string within str */
|
||||
|
||||
protected:
|
||||
bool error;
|
||||
};
|
||||
|
||||
typedef hb_vector_t<byte_str_t> byte_str_array_t;
|
||||
|
||||
/* stack */
|
||||
template <typename ELEM, int LIMIT>
|
||||
struct cff_stack_t
|
||||
{
|
||||
void init ()
|
||||
{
|
||||
error = false;
|
||||
count = 0;
|
||||
elements.init ();
|
||||
elements.resize (kSizeLimit);
|
||||
for (unsigned int i = 0; i < elements.length; i++)
|
||||
elements[i].init ();
|
||||
}
|
||||
void fini () { elements.fini_deep (); }
|
||||
|
||||
ELEM& operator [] (unsigned int i)
|
||||
{
|
||||
if (unlikely (i >= count)) set_error ();
|
||||
return elements[i];
|
||||
}
|
||||
|
||||
void push (const ELEM &v)
|
||||
{
|
||||
if (likely (count < elements.length))
|
||||
elements[count++] = v;
|
||||
else
|
||||
set_error ();
|
||||
}
|
||||
ELEM &push ()
|
||||
{
|
||||
if (likely (count < elements.length))
|
||||
return elements[count++];
|
||||
else
|
||||
{
|
||||
set_error ();
|
||||
return Crap (ELEM);
|
||||
}
|
||||
}
|
||||
|
||||
ELEM& pop ()
|
||||
{
|
||||
if (likely (count > 0))
|
||||
return elements[--count];
|
||||
else
|
||||
{
|
||||
set_error ();
|
||||
return Crap (ELEM);
|
||||
}
|
||||
}
|
||||
void pop (unsigned int n)
|
||||
{
|
||||
if (likely (count >= n))
|
||||
count -= n;
|
||||
else
|
||||
set_error ();
|
||||
}
|
||||
|
||||
const ELEM& peek ()
|
||||
{
|
||||
if (unlikely (count < 0))
|
||||
{
|
||||
set_error ();
|
||||
return Null (ELEM);
|
||||
}
|
||||
return elements[count - 1];
|
||||
}
|
||||
|
||||
void unpop ()
|
||||
{
|
||||
if (likely (count < elements.length))
|
||||
count++;
|
||||
else
|
||||
set_error ();
|
||||
}
|
||||
|
||||
void clear () { count = 0; }
|
||||
|
||||
bool in_error () const { return (error || elements.in_error ()); }
|
||||
void set_error () { error = true; }
|
||||
|
||||
unsigned int get_count () const { return count; }
|
||||
bool is_empty () const { return !count; }
|
||||
|
||||
static constexpr unsigned kSizeLimit = LIMIT;
|
||||
|
||||
protected:
|
||||
bool error;
|
||||
unsigned int count;
|
||||
hb_vector_t<ELEM> elements;
|
||||
};
|
||||
|
||||
/* argument stack */
|
||||
template <typename ARG=number_t>
|
||||
struct arg_stack_t : cff_stack_t<ARG, 513>
|
||||
{
|
||||
void push_int (int v)
|
||||
{
|
||||
ARG &n = S::push ();
|
||||
n.set_int (v);
|
||||
}
|
||||
|
||||
void push_fixed (int32_t v)
|
||||
{
|
||||
ARG &n = S::push ();
|
||||
n.set_fixed (v);
|
||||
}
|
||||
|
||||
void push_real (double v)
|
||||
{
|
||||
ARG &n = S::push ();
|
||||
n.set_real (v);
|
||||
}
|
||||
|
||||
ARG& pop_num () { return this->pop (); }
|
||||
|
||||
int pop_int () { return this->pop ().to_int (); }
|
||||
|
||||
unsigned int pop_uint ()
|
||||
{
|
||||
int i = pop_int ();
|
||||
if (unlikely (i < 0))
|
||||
{
|
||||
i = 0;
|
||||
S::set_error ();
|
||||
}
|
||||
return (unsigned) i;
|
||||
}
|
||||
|
||||
void push_longint_from_substr (byte_str_ref_t& str_ref)
|
||||
{
|
||||
push_int ((str_ref[0] << 24) | (str_ref[1] << 16) | (str_ref[2] << 8) | (str_ref[3]));
|
||||
str_ref.inc (4);
|
||||
}
|
||||
|
||||
bool push_fixed_from_substr (byte_str_ref_t& str_ref)
|
||||
{
|
||||
if (unlikely (!str_ref.avail (4)))
|
||||
return false;
|
||||
push_fixed ((int32_t)*(const HBUINT32*)&str_ref[0]);
|
||||
str_ref.inc (4);
|
||||
return true;
|
||||
}
|
||||
|
||||
hb_array_t<const ARG> get_subarray (unsigned int start) const
|
||||
{ return S::elements.sub_array (start); }
|
||||
|
||||
private:
|
||||
typedef cff_stack_t<ARG, 513> S;
|
||||
};
|
||||
|
||||
/* an operator prefixed by its operands in a byte string */
|
||||
struct op_str_t
|
||||
{
|
||||
void init () {}
|
||||
void fini () {}
|
||||
|
||||
op_code_t op;
|
||||
byte_str_t str;
|
||||
};
|
||||
|
||||
/* base of OP_SERIALIZER */
|
||||
struct op_serializer_t
|
||||
{
|
||||
protected:
|
||||
bool copy_opstr (hb_serialize_context_t *c, const op_str_t& opstr) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
|
||||
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
|
||||
if (unlikely (!d)) return_trace (false);
|
||||
memcpy (d, &opstr.str[0], opstr.str.length);
|
||||
return_trace (true);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename VAL>
|
||||
struct parsed_values_t
|
||||
{
|
||||
void init ()
|
||||
{
|
||||
opStart = 0;
|
||||
values.init ();
|
||||
}
|
||||
void fini () { values.fini_deep (); }
|
||||
|
||||
void add_op (op_code_t op, const byte_str_ref_t& str_ref = byte_str_ref_t ())
|
||||
{
|
||||
VAL *val = values.push ();
|
||||
val->op = op;
|
||||
val->str = str_ref.str.sub_str (opStart, str_ref.offset - opStart);
|
||||
opStart = str_ref.offset;
|
||||
}
|
||||
|
||||
void add_op (op_code_t op, const byte_str_ref_t& str_ref, const VAL &v)
|
||||
{
|
||||
VAL *val = values.push (v);
|
||||
val->op = op;
|
||||
val->str = str_ref.sub_str ( opStart, str_ref.offset - opStart);
|
||||
opStart = str_ref.offset;
|
||||
}
|
||||
|
||||
bool has_op (op_code_t op) const
|
||||
{
|
||||
for (unsigned int i = 0; i < get_count (); i++)
|
||||
if (get_value (i).op == op) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned get_count () const { return values.length; }
|
||||
const VAL &get_value (unsigned int i) const { return values[i]; }
|
||||
const VAL &operator [] (unsigned int i) const { return get_value (i); }
|
||||
|
||||
unsigned int opStart;
|
||||
hb_vector_t<VAL> values;
|
||||
};
|
||||
|
||||
template <typename ARG=number_t>
|
||||
struct interp_env_t
|
||||
{
|
||||
void init (const byte_str_t &str_)
|
||||
{
|
||||
str_ref.reset (str_);
|
||||
argStack.init ();
|
||||
error = false;
|
||||
}
|
||||
void fini () { argStack.fini (); }
|
||||
|
||||
bool in_error () const
|
||||
{ return error || str_ref.in_error () || argStack.in_error (); }
|
||||
|
||||
void set_error () { error = true; }
|
||||
|
||||
op_code_t fetch_op ()
|
||||
{
|
||||
op_code_t op = OpCode_Invalid;
|
||||
if (unlikely (!str_ref.avail ()))
|
||||
return OpCode_Invalid;
|
||||
op = (op_code_t)(unsigned char)str_ref[0];
|
||||
if (op == OpCode_escape) {
|
||||
if (unlikely (!str_ref.avail ()))
|
||||
return OpCode_Invalid;
|
||||
op = Make_OpCode_ESC(str_ref[1]);
|
||||
str_ref.inc ();
|
||||
}
|
||||
str_ref.inc ();
|
||||
return op;
|
||||
}
|
||||
|
||||
const ARG& eval_arg (unsigned int i) { return argStack[i]; }
|
||||
|
||||
ARG& pop_arg () { return argStack.pop (); }
|
||||
void pop_n_args (unsigned int n) { argStack.pop (n); }
|
||||
|
||||
void clear_args () { pop_n_args (argStack.get_count ()); }
|
||||
|
||||
byte_str_ref_t
|
||||
str_ref;
|
||||
arg_stack_t<ARG>
|
||||
argStack;
|
||||
protected:
|
||||
bool error;
|
||||
};
|
||||
|
||||
typedef interp_env_t<> num_interp_env_t;
|
||||
|
||||
template <typename ARG=number_t>
|
||||
struct opset_t
|
||||
{
|
||||
static void process_op (op_code_t op, interp_env_t<ARG>& env)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_shortint:
|
||||
env.argStack.push_int ((int16_t)((env.str_ref[0] << 8) | env.str_ref[1]));
|
||||
env.str_ref.inc (2);
|
||||
break;
|
||||
|
||||
case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
|
||||
case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
|
||||
env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.str_ref[0] + 108));
|
||||
env.str_ref.inc ();
|
||||
break;
|
||||
|
||||
case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
|
||||
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
|
||||
env.argStack.push_int ((-(int16_t)(op - OpCode_TwoByteNegInt0) * 256 - env.str_ref[0] - 108));
|
||||
env.str_ref.inc ();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* 1-byte integer */
|
||||
if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast)))
|
||||
{
|
||||
env.argStack.push_int ((int)op - 139);
|
||||
} else {
|
||||
/* invalid unknown operator */
|
||||
env.clear_args ();
|
||||
env.set_error ();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ENV>
|
||||
struct interpreter_t
|
||||
{
|
||||
~interpreter_t() { fini (); }
|
||||
|
||||
void fini () { env.fini (); }
|
||||
|
||||
ENV env;
|
||||
};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
||||
#endif /* HB_CFF_INTERP_COMMON_HH */
|
||||
@@ -0,0 +1,911 @@
|
||||
/*
|
||||
* Copyright © 2018 Adobe 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.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
#ifndef HB_CFF_INTERP_CS_COMMON_HH
|
||||
#define HB_CFF_INTERP_CS_COMMON_HH
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-cff-interp-common.hh"
|
||||
|
||||
namespace CFF {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
enum cs_type_t {
|
||||
CSType_CharString,
|
||||
CSType_GlobalSubr,
|
||||
CSType_LocalSubr
|
||||
};
|
||||
|
||||
struct call_context_t
|
||||
{
|
||||
void init (const byte_str_ref_t substr_=byte_str_ref_t (), cs_type_t type_=CSType_CharString, unsigned int subr_num_=0)
|
||||
{
|
||||
str_ref = substr_;
|
||||
type = type_;
|
||||
subr_num = subr_num_;
|
||||
}
|
||||
|
||||
void fini () {}
|
||||
|
||||
byte_str_ref_t str_ref;
|
||||
cs_type_t type;
|
||||
unsigned int subr_num;
|
||||
};
|
||||
|
||||
/* call stack */
|
||||
const unsigned int kMaxCallLimit = 10;
|
||||
struct call_stack_t : cff_stack_t<call_context_t, kMaxCallLimit> {};
|
||||
|
||||
template <typename SUBRS>
|
||||
struct biased_subrs_t
|
||||
{
|
||||
void init (const SUBRS *subrs_)
|
||||
{
|
||||
subrs = subrs_;
|
||||
unsigned int nSubrs = get_count ();
|
||||
if (nSubrs < 1240)
|
||||
bias = 107;
|
||||
else if (nSubrs < 33900)
|
||||
bias = 1131;
|
||||
else
|
||||
bias = 32768;
|
||||
}
|
||||
|
||||
void fini () {}
|
||||
|
||||
unsigned int get_count () const { return subrs ? subrs->count : 0; }
|
||||
unsigned int get_bias () const { return bias; }
|
||||
|
||||
byte_str_t operator [] (unsigned int index) const
|
||||
{
|
||||
if (unlikely (!subrs || index >= subrs->count))
|
||||
return Null (byte_str_t);
|
||||
else
|
||||
return (*subrs)[index];
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned int bias;
|
||||
const SUBRS *subrs;
|
||||
};
|
||||
|
||||
struct point_t
|
||||
{
|
||||
void init ()
|
||||
{
|
||||
x.init ();
|
||||
y.init ();
|
||||
}
|
||||
|
||||
void set_int (int _x, int _y)
|
||||
{
|
||||
x.set_int (_x);
|
||||
y.set_int (_y);
|
||||
}
|
||||
|
||||
void move_x (const number_t &dx) { x += dx; }
|
||||
void move_y (const number_t &dy) { y += dy; }
|
||||
void move (const number_t &dx, const number_t &dy) { move_x (dx); move_y (dy); }
|
||||
void move (const point_t &d) { move_x (d.x); move_y (d.y); }
|
||||
|
||||
number_t x;
|
||||
number_t y;
|
||||
};
|
||||
|
||||
template <typename ARG, typename SUBRS>
|
||||
struct cs_interp_env_t : interp_env_t<ARG>
|
||||
{
|
||||
void init (const byte_str_t &str, const SUBRS *globalSubrs_, const SUBRS *localSubrs_)
|
||||
{
|
||||
interp_env_t<ARG>::init (str);
|
||||
|
||||
context.init (str, CSType_CharString);
|
||||
seen_moveto = true;
|
||||
seen_hintmask = false;
|
||||
hstem_count = 0;
|
||||
vstem_count = 0;
|
||||
hintmask_size = 0;
|
||||
pt.init ();
|
||||
callStack.init ();
|
||||
globalSubrs.init (globalSubrs_);
|
||||
localSubrs.init (localSubrs_);
|
||||
}
|
||||
void fini ()
|
||||
{
|
||||
interp_env_t<ARG>::fini ();
|
||||
|
||||
callStack.fini ();
|
||||
globalSubrs.fini ();
|
||||
localSubrs.fini ();
|
||||
}
|
||||
|
||||
bool in_error () const
|
||||
{
|
||||
return callStack.in_error () || SUPER::in_error ();
|
||||
}
|
||||
|
||||
bool pop_subr_num (const biased_subrs_t<SUBRS>& biasedSubrs, unsigned int &subr_num)
|
||||
{
|
||||
subr_num = 0;
|
||||
int n = SUPER::argStack.pop_int ();
|
||||
n += biasedSubrs.get_bias ();
|
||||
if (unlikely ((n < 0) || ((unsigned int)n >= biasedSubrs.get_count ())))
|
||||
return false;
|
||||
|
||||
subr_num = (unsigned int)n;
|
||||
return true;
|
||||
}
|
||||
|
||||
void call_subr (const biased_subrs_t<SUBRS>& biasedSubrs, cs_type_t type)
|
||||
{
|
||||
unsigned int subr_num = 0;
|
||||
|
||||
if (unlikely (!pop_subr_num (biasedSubrs, subr_num)
|
||||
|| callStack.get_count () >= kMaxCallLimit))
|
||||
{
|
||||
SUPER::set_error ();
|
||||
return;
|
||||
}
|
||||
context.str_ref = SUPER::str_ref;
|
||||
callStack.push (context);
|
||||
|
||||
context.init ( biasedSubrs[subr_num], type, subr_num);
|
||||
SUPER::str_ref = context.str_ref;
|
||||
}
|
||||
|
||||
void return_from_subr ()
|
||||
{
|
||||
if (unlikely (SUPER::str_ref.in_error ()))
|
||||
SUPER::set_error ();
|
||||
context = callStack.pop ();
|
||||
SUPER::str_ref = context.str_ref;
|
||||
}
|
||||
|
||||
void determine_hintmask_size ()
|
||||
{
|
||||
if (!seen_hintmask)
|
||||
{
|
||||
vstem_count += SUPER::argStack.get_count() / 2;
|
||||
hintmask_size = (hstem_count + vstem_count + 7) >> 3;
|
||||
seen_hintmask = true;
|
||||
}
|
||||
}
|
||||
|
||||
void set_endchar (bool endchar_flag_) { endchar_flag = endchar_flag_; }
|
||||
bool is_endchar () const { return endchar_flag; }
|
||||
|
||||
const number_t &get_x () const { return pt.x; }
|
||||
const number_t &get_y () const { return pt.y; }
|
||||
const point_t &get_pt () const { return pt; }
|
||||
|
||||
void moveto (const point_t &pt_ ) { pt = pt_; }
|
||||
|
||||
public:
|
||||
call_context_t context;
|
||||
bool endchar_flag;
|
||||
bool seen_moveto;
|
||||
bool seen_hintmask;
|
||||
|
||||
unsigned int hstem_count;
|
||||
unsigned int vstem_count;
|
||||
unsigned int hintmask_size;
|
||||
call_stack_t callStack;
|
||||
biased_subrs_t<SUBRS> globalSubrs;
|
||||
biased_subrs_t<SUBRS> localSubrs;
|
||||
|
||||
private:
|
||||
point_t pt;
|
||||
|
||||
typedef interp_env_t<ARG> SUPER;
|
||||
};
|
||||
|
||||
template <typename ENV, typename PARAM>
|
||||
struct path_procs_null_t
|
||||
{
|
||||
static void rmoveto (ENV &env, PARAM& param) {}
|
||||
static void hmoveto (ENV &env, PARAM& param) {}
|
||||
static void vmoveto (ENV &env, PARAM& param) {}
|
||||
static void rlineto (ENV &env, PARAM& param) {}
|
||||
static void hlineto (ENV &env, PARAM& param) {}
|
||||
static void vlineto (ENV &env, PARAM& param) {}
|
||||
static void rrcurveto (ENV &env, PARAM& param) {}
|
||||
static void rcurveline (ENV &env, PARAM& param) {}
|
||||
static void rlinecurve (ENV &env, PARAM& param) {}
|
||||
static void vvcurveto (ENV &env, PARAM& param) {}
|
||||
static void hhcurveto (ENV &env, PARAM& param) {}
|
||||
static void vhcurveto (ENV &env, PARAM& param) {}
|
||||
static void hvcurveto (ENV &env, PARAM& param) {}
|
||||
static void moveto (ENV &env, PARAM& param, const point_t &pt) {}
|
||||
static void line (ENV &env, PARAM& param, const point_t &pt1) {}
|
||||
static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &pt3) {}
|
||||
static void hflex (ENV &env, PARAM& param) {}
|
||||
static void flex (ENV &env, PARAM& param) {}
|
||||
static void hflex1 (ENV &env, PARAM& param) {}
|
||||
static void flex1 (ENV &env, PARAM& param) {}
|
||||
};
|
||||
|
||||
template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename PATH=path_procs_null_t<ENV, PARAM>>
|
||||
struct cs_opset_t : opset_t<ARG>
|
||||
{
|
||||
static void process_op (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
switch (op) {
|
||||
|
||||
case OpCode_return:
|
||||
env.return_from_subr ();
|
||||
break;
|
||||
case OpCode_endchar:
|
||||
OPSET::check_width (op, env, param);
|
||||
env.set_endchar (true);
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
break;
|
||||
|
||||
case OpCode_fixedcs:
|
||||
env.argStack.push_fixed_from_substr (env.str_ref);
|
||||
break;
|
||||
|
||||
case OpCode_callsubr:
|
||||
env.call_subr (env.localSubrs, CSType_LocalSubr);
|
||||
break;
|
||||
|
||||
case OpCode_callgsubr:
|
||||
env.call_subr (env.globalSubrs, CSType_GlobalSubr);
|
||||
break;
|
||||
|
||||
case OpCode_hstem:
|
||||
case OpCode_hstemhm:
|
||||
OPSET::check_width (op, env, param);
|
||||
OPSET::process_hstem (op, env, param);
|
||||
break;
|
||||
case OpCode_vstem:
|
||||
case OpCode_vstemhm:
|
||||
OPSET::check_width (op, env, param);
|
||||
OPSET::process_vstem (op, env, param);
|
||||
break;
|
||||
case OpCode_hintmask:
|
||||
case OpCode_cntrmask:
|
||||
OPSET::check_width (op, env, param);
|
||||
OPSET::process_hintmask (op, env, param);
|
||||
break;
|
||||
case OpCode_rmoveto:
|
||||
OPSET::check_width (op, env, param);
|
||||
PATH::rmoveto (env, param);
|
||||
OPSET::process_post_move (op, env, param);
|
||||
break;
|
||||
case OpCode_hmoveto:
|
||||
OPSET::check_width (op, env, param);
|
||||
PATH::hmoveto (env, param);
|
||||
OPSET::process_post_move (op, env, param);
|
||||
break;
|
||||
case OpCode_vmoveto:
|
||||
OPSET::check_width (op, env, param);
|
||||
PATH::vmoveto (env, param);
|
||||
OPSET::process_post_move (op, env, param);
|
||||
break;
|
||||
case OpCode_rlineto:
|
||||
PATH::rlineto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_hlineto:
|
||||
PATH::hlineto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_vlineto:
|
||||
PATH::vlineto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_rrcurveto:
|
||||
PATH::rrcurveto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_rcurveline:
|
||||
PATH::rcurveline (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_rlinecurve:
|
||||
PATH::rlinecurve (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_vvcurveto:
|
||||
PATH::vvcurveto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_hhcurveto:
|
||||
PATH::hhcurveto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_vhcurveto:
|
||||
PATH::vhcurveto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
case OpCode_hvcurveto:
|
||||
PATH::hvcurveto (env, param);
|
||||
process_post_path (op, env, param);
|
||||
break;
|
||||
|
||||
case OpCode_hflex:
|
||||
PATH::hflex (env, param);
|
||||
OPSET::process_post_flex (op, env, param);
|
||||
break;
|
||||
|
||||
case OpCode_flex:
|
||||
PATH::flex (env, param);
|
||||
OPSET::process_post_flex (op, env, param);
|
||||
break;
|
||||
|
||||
case OpCode_hflex1:
|
||||
PATH::hflex1 (env, param);
|
||||
OPSET::process_post_flex (op, env, param);
|
||||
break;
|
||||
|
||||
case OpCode_flex1:
|
||||
PATH::flex1 (env, param);
|
||||
OPSET::process_post_flex (op, env, param);
|
||||
break;
|
||||
|
||||
default:
|
||||
SUPER::process_op (op, env);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void process_hstem (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
env.hstem_count += env.argStack.get_count () / 2;
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
}
|
||||
|
||||
static void process_vstem (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
env.vstem_count += env.argStack.get_count () / 2;
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
}
|
||||
|
||||
static void process_hintmask (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
env.determine_hintmask_size ();
|
||||
if (likely (env.str_ref.avail (env.hintmask_size)))
|
||||
{
|
||||
OPSET::flush_hintmask (op, env, param);
|
||||
env.str_ref.inc (env.hintmask_size);
|
||||
}
|
||||
}
|
||||
|
||||
static void process_post_flex (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
}
|
||||
|
||||
static void check_width (op_code_t op, ENV &env, PARAM& param)
|
||||
{}
|
||||
|
||||
static void process_post_move (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
if (!env.seen_moveto)
|
||||
{
|
||||
env.determine_hintmask_size ();
|
||||
env.seen_moveto = true;
|
||||
}
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
}
|
||||
|
||||
static void process_post_path (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
}
|
||||
|
||||
static void flush_args_and_op (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
OPSET::flush_args (env, param);
|
||||
OPSET::flush_op (op, env, param);
|
||||
}
|
||||
|
||||
static void flush_args (ENV &env, PARAM& param)
|
||||
{
|
||||
env.pop_n_args (env.argStack.get_count ());
|
||||
}
|
||||
|
||||
static void flush_op (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
}
|
||||
|
||||
static void flush_hintmask (op_code_t op, ENV &env, PARAM& param)
|
||||
{
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
}
|
||||
|
||||
static bool is_number_op (op_code_t op)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case OpCode_shortint:
|
||||
case OpCode_fixedcs:
|
||||
case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1:
|
||||
case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3:
|
||||
case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
|
||||
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
|
||||
return true;
|
||||
|
||||
default:
|
||||
/* 1-byte integer */
|
||||
return (OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef opset_t<ARG> SUPER;
|
||||
};
|
||||
|
||||
template <typename PATH, typename ENV, typename PARAM>
|
||||
struct path_procs_t
|
||||
{
|
||||
static void rmoveto (ENV &env, PARAM& param)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
const number_t &dy = env.pop_arg ();
|
||||
const number_t &dx = env.pop_arg ();
|
||||
pt1.move (dx, dy);
|
||||
PATH::moveto (env, param, pt1);
|
||||
}
|
||||
|
||||
static void hmoveto (ENV &env, PARAM& param)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move_x (env.pop_arg ());
|
||||
PATH::moveto (env, param, pt1);
|
||||
}
|
||||
|
||||
static void vmoveto (ENV &env, PARAM& param)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move_y (env.pop_arg ());
|
||||
PATH::moveto (env, param, pt1);
|
||||
}
|
||||
|
||||
static void rlineto (ENV &env, PARAM& param)
|
||||
{
|
||||
for (unsigned int i = 0; i + 2 <= env.argStack.get_count (); i += 2)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||
PATH::line (env, param, pt1);
|
||||
}
|
||||
}
|
||||
|
||||
static void hlineto (ENV &env, PARAM& param)
|
||||
{
|
||||
point_t pt1;
|
||||
unsigned int i = 0;
|
||||
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
||||
{
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_x (env.eval_arg (i));
|
||||
PATH::line (env, param, pt1);
|
||||
pt1.move_y (env.eval_arg (i+1));
|
||||
PATH::line (env, param, pt1);
|
||||
}
|
||||
if (i < env.argStack.get_count ())
|
||||
{
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_x (env.eval_arg (i));
|
||||
PATH::line (env, param, pt1);
|
||||
}
|
||||
}
|
||||
|
||||
static void vlineto (ENV &env, PARAM& param)
|
||||
{
|
||||
point_t pt1;
|
||||
unsigned int i = 0;
|
||||
for (; i + 2 <= env.argStack.get_count (); i += 2)
|
||||
{
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_y (env.eval_arg (i));
|
||||
PATH::line (env, param, pt1);
|
||||
pt1.move_x (env.eval_arg (i+1));
|
||||
PATH::line (env, param, pt1);
|
||||
}
|
||||
if (i < env.argStack.get_count ())
|
||||
{
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_y (env.eval_arg (i));
|
||||
PATH::line (env, param, pt1);
|
||||
}
|
||||
}
|
||||
|
||||
static void rrcurveto (ENV &env, PARAM& param)
|
||||
{
|
||||
for (unsigned int i = 0; i + 6 <= env.argStack.get_count (); i += 6)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
}
|
||||
}
|
||||
|
||||
static void rcurveline (ENV &env, PARAM& param)
|
||||
{
|
||||
unsigned int arg_count = env.argStack.get_count ();
|
||||
if (unlikely (arg_count < 8))
|
||||
return;
|
||||
|
||||
unsigned int i = 0;
|
||||
unsigned int curve_limit = arg_count - 2;
|
||||
for (; i + 6 <= curve_limit; i += 6)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
}
|
||||
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||
PATH::line (env, param, pt1);
|
||||
}
|
||||
|
||||
static void rlinecurve (ENV &env, PARAM& param)
|
||||
{
|
||||
unsigned int arg_count = env.argStack.get_count ();
|
||||
if (unlikely (arg_count < 8))
|
||||
return;
|
||||
|
||||
unsigned int i = 0;
|
||||
unsigned int line_limit = arg_count - 6;
|
||||
for (; i + 2 <= line_limit; i += 2)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||
PATH::line (env, param, pt1);
|
||||
}
|
||||
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+2), env.eval_arg (i+3));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move (env.eval_arg (i+4), env.eval_arg (i+5));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
}
|
||||
|
||||
static void vvcurveto (ENV &env, PARAM& param)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
point_t pt1 = env.get_pt ();
|
||||
if ((env.argStack.get_count () & 1) != 0)
|
||||
pt1.move_x (env.eval_arg (i++));
|
||||
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
||||
{
|
||||
pt1.move_y (env.eval_arg (i));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move_y (env.eval_arg (i+3));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
pt1 = env.get_pt ();
|
||||
}
|
||||
}
|
||||
|
||||
static void hhcurveto (ENV &env, PARAM& param)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
point_t pt1 = env.get_pt ();
|
||||
if ((env.argStack.get_count () & 1) != 0)
|
||||
pt1.move_y (env.eval_arg (i++));
|
||||
for (; i + 4 <= env.argStack.get_count (); i += 4)
|
||||
{
|
||||
pt1.move_x (env.eval_arg (i));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (i+3));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
pt1 = env.get_pt ();
|
||||
}
|
||||
}
|
||||
|
||||
static void vhcurveto (ENV &env, PARAM& param)
|
||||
{
|
||||
point_t pt1, pt2, pt3;
|
||||
unsigned int i = 0;
|
||||
if ((env.argStack.get_count () % 8) >= 4)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move_y (env.eval_arg (i));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (i+3));
|
||||
i += 4;
|
||||
|
||||
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
||||
{
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_x (env.eval_arg (i));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
pt3 = pt2;
|
||||
pt3.move_y (env.eval_arg (i+3));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
|
||||
pt1 = pt3;
|
||||
pt1.move_y (env.eval_arg (i+4));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
||||
pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (i+7));
|
||||
}
|
||||
if (i < env.argStack.get_count ())
|
||||
pt3.move_y (env.eval_arg (i));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
||||
{
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_y (env.eval_arg (i));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (i+3));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
|
||||
pt1 = pt3;
|
||||
pt1.move_x (env.eval_arg (i+4));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
||||
pt3 = pt2;
|
||||
pt3.move_y (env.eval_arg (i+7));
|
||||
if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0))
|
||||
pt3.move_x (env.eval_arg (i+8));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void hvcurveto (ENV &env, PARAM& param)
|
||||
{
|
||||
point_t pt1, pt2, pt3;
|
||||
unsigned int i = 0;
|
||||
if ((env.argStack.get_count () % 8) >= 4)
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move_x (env.eval_arg (i));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move_y (env.eval_arg (i+3));
|
||||
i += 4;
|
||||
|
||||
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
||||
{
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_y (env.eval_arg (i));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (i+3));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
|
||||
pt1 = pt3;
|
||||
pt1.move_x (env.eval_arg (i+4));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
||||
pt3 = pt2;
|
||||
pt3.move_y (env.eval_arg (i+7));
|
||||
}
|
||||
if (i < env.argStack.get_count ())
|
||||
pt3.move_x (env.eval_arg (i));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; i + 8 <= env.argStack.get_count (); i += 8)
|
||||
{
|
||||
pt1 = env.get_pt ();
|
||||
pt1.move_x (env.eval_arg (i));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+1), env.eval_arg (i+2));
|
||||
pt3 = pt2;
|
||||
pt3.move_y (env.eval_arg (i+3));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
|
||||
pt1 = pt3;
|
||||
pt1.move_y (env.eval_arg (i+4));
|
||||
pt2 = pt1;
|
||||
pt2.move (env.eval_arg (i+5), env.eval_arg (i+6));
|
||||
pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (i+7));
|
||||
if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0))
|
||||
pt3.move_y (env.eval_arg (i+8));
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* default actions to be overridden */
|
||||
static void moveto (ENV &env, PARAM& param, const point_t &pt)
|
||||
{ env.moveto (pt); }
|
||||
|
||||
static void line (ENV &env, PARAM& param, const point_t &pt1)
|
||||
{ PATH::moveto (env, param, pt1); }
|
||||
|
||||
static void curve (ENV &env, PARAM& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
|
||||
{ PATH::moveto (env, param, pt3); }
|
||||
|
||||
static void hflex (ENV &env, PARAM& param)
|
||||
{
|
||||
if (likely (env.argStack.get_count () == 7))
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move_x (env.eval_arg (0));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (1), env.eval_arg (2));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (3));
|
||||
point_t pt4 = pt3;
|
||||
pt4.move_x (env.eval_arg (4));
|
||||
point_t pt5 = pt4;
|
||||
pt5.move_x (env.eval_arg (5));
|
||||
pt5.y = pt1.y;
|
||||
point_t pt6 = pt5;
|
||||
pt6.move_x (env.eval_arg (6));
|
||||
|
||||
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
||||
}
|
||||
else
|
||||
env.set_error ();
|
||||
}
|
||||
|
||||
static void flex (ENV &env, PARAM& param)
|
||||
{
|
||||
if (likely (env.argStack.get_count () == 13))
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
||||
point_t pt4 = pt3;
|
||||
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
||||
point_t pt5 = pt4;
|
||||
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
||||
point_t pt6 = pt5;
|
||||
pt6.move (env.eval_arg (10), env.eval_arg (11));
|
||||
|
||||
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
||||
}
|
||||
else
|
||||
env.set_error ();
|
||||
}
|
||||
|
||||
static void hflex1 (ENV &env, PARAM& param)
|
||||
{
|
||||
if (likely (env.argStack.get_count () == 9))
|
||||
{
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move_x (env.eval_arg (4));
|
||||
point_t pt4 = pt3;
|
||||
pt4.move_x (env.eval_arg (5));
|
||||
point_t pt5 = pt4;
|
||||
pt5.move (env.eval_arg (6), env.eval_arg (7));
|
||||
point_t pt6 = pt5;
|
||||
pt6.move_x (env.eval_arg (8));
|
||||
pt6.y = env.get_pt ().y;
|
||||
|
||||
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
||||
}
|
||||
else
|
||||
env.set_error ();
|
||||
}
|
||||
|
||||
static void flex1 (ENV &env, PARAM& param)
|
||||
{
|
||||
if (likely (env.argStack.get_count () == 11))
|
||||
{
|
||||
point_t d;
|
||||
d.init ();
|
||||
for (unsigned int i = 0; i < 10; i += 2)
|
||||
d.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||
|
||||
point_t pt1 = env.get_pt ();
|
||||
pt1.move (env.eval_arg (0), env.eval_arg (1));
|
||||
point_t pt2 = pt1;
|
||||
pt2.move (env.eval_arg (2), env.eval_arg (3));
|
||||
point_t pt3 = pt2;
|
||||
pt3.move (env.eval_arg (4), env.eval_arg (5));
|
||||
point_t pt4 = pt3;
|
||||
pt4.move (env.eval_arg (6), env.eval_arg (7));
|
||||
point_t pt5 = pt4;
|
||||
pt5.move (env.eval_arg (8), env.eval_arg (9));
|
||||
point_t pt6 = pt5;
|
||||
|
||||
if (fabs (d.x.to_real ()) > fabs (d.y.to_real ()))
|
||||
{
|
||||
pt6.move_x (env.eval_arg (10));
|
||||
pt6.y = env.get_pt ().y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt6.x = env.get_pt ().x;
|
||||
pt6.move_y (env.eval_arg (10));
|
||||
}
|
||||
|
||||
curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6);
|
||||
}
|
||||
else
|
||||
env.set_error ();
|
||||
}
|
||||
|
||||
protected:
|
||||
static void curve2 (ENV &env, PARAM& param,
|
||||
const point_t &pt1, const point_t &pt2, const point_t &pt3,
|
||||
const point_t &pt4, const point_t &pt5, const point_t &pt6)
|
||||
{
|
||||
PATH::curve (env, param, pt1, pt2, pt3);
|
||||
PATH::curve (env, param, pt4, pt5, pt6);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ENV, typename OPSET, typename PARAM>
|
||||
struct cs_interpreter_t : interpreter_t<ENV>
|
||||
{
|
||||
bool interpret (PARAM& param)
|
||||
{
|
||||
SUPER::env.set_endchar (false);
|
||||
|
||||
for (;;) {
|
||||
OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param);
|
||||
if (unlikely (SUPER::env.in_error ()))
|
||||
return false;
|
||||
if (SUPER::env.is_endchar ())
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef interpreter_t<ENV> SUPER;
|
||||
};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
||||
#endif /* HB_CFF_INTERP_CS_COMMON_HH */
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright © 2018 Adobe 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.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
#ifndef HB_CFF_INTERP_DICT_COMMON_HH
|
||||
#define HB_CFF_INTERP_DICT_COMMON_HH
|
||||
|
||||
#include "hb-cff-interp-common.hh"
|
||||
|
||||
namespace CFF {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
/* an opstr and the parsed out dict value(s) */
|
||||
struct dict_val_t : op_str_t
|
||||
{
|
||||
void init () { single_val.set_int (0); }
|
||||
void fini () {}
|
||||
|
||||
number_t single_val;
|
||||
};
|
||||
|
||||
typedef dict_val_t num_dict_val_t;
|
||||
|
||||
template <typename VAL> struct dict_values_t : parsed_values_t<VAL> {};
|
||||
|
||||
template <typename OPSTR=op_str_t>
|
||||
struct top_dict_values_t : dict_values_t<OPSTR>
|
||||
{
|
||||
void init ()
|
||||
{
|
||||
dict_values_t<OPSTR>::init ();
|
||||
charStringsOffset = 0;
|
||||
FDArrayOffset = 0;
|
||||
}
|
||||
void fini () { dict_values_t<OPSTR>::fini (); }
|
||||
|
||||
unsigned int charStringsOffset;
|
||||
unsigned int FDArrayOffset;
|
||||
};
|
||||
|
||||
struct dict_opset_t : opset_t<number_t>
|
||||
{
|
||||
static void process_op (op_code_t op, interp_env_t<number_t>& env)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_longintdict: /* 5-byte integer */
|
||||
env.argStack.push_longint_from_substr (env.str_ref);
|
||||
break;
|
||||
|
||||
case OpCode_BCD: /* real number */
|
||||
env.argStack.push_real (parse_bcd (env.str_ref));
|
||||
break;
|
||||
|
||||
default:
|
||||
opset_t<number_t>::process_op (op, env);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Turns CFF's BCD format into strtod understandable string */
|
||||
static double parse_bcd (byte_str_ref_t& str_ref)
|
||||
{
|
||||
if (unlikely (str_ref.in_error ())) return .0;
|
||||
|
||||
enum Nibble { DECIMAL=10, EXP_POS, EXP_NEG, RESERVED, NEG, END };
|
||||
|
||||
char buf[32];
|
||||
unsigned char byte = 0;
|
||||
for (unsigned i = 0, count = 0; count < ARRAY_LENGTH (buf); ++i, ++count)
|
||||
{
|
||||
unsigned nibble;
|
||||
if (!(i & 1))
|
||||
{
|
||||
if (unlikely (!str_ref.avail ())) break;
|
||||
|
||||
byte = str_ref[0];
|
||||
str_ref.inc ();
|
||||
nibble = byte >> 4;
|
||||
}
|
||||
else
|
||||
nibble = byte & 0x0F;
|
||||
|
||||
if (unlikely (nibble == RESERVED)) break;
|
||||
else if (nibble == END)
|
||||
{
|
||||
const char *p = buf;
|
||||
double pv;
|
||||
if (unlikely (!hb_parse_double (&p, p + count, &pv, true/* whole buffer */)))
|
||||
break;
|
||||
return pv;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[count] = "0123456789.EE?-?"[nibble];
|
||||
if (nibble == EXP_NEG)
|
||||
{
|
||||
++count;
|
||||
if (unlikely (count == ARRAY_LENGTH (buf))) break;
|
||||
buf[count] = '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
str_ref.set_error ();
|
||||
return .0;
|
||||
}
|
||||
|
||||
static bool is_hint_op (op_code_t op)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case OpCode_BlueValues:
|
||||
case OpCode_OtherBlues:
|
||||
case OpCode_FamilyBlues:
|
||||
case OpCode_FamilyOtherBlues:
|
||||
case OpCode_StemSnapH:
|
||||
case OpCode_StemSnapV:
|
||||
case OpCode_StdHW:
|
||||
case OpCode_StdVW:
|
||||
case OpCode_BlueScale:
|
||||
case OpCode_BlueShift:
|
||||
case OpCode_BlueFuzz:
|
||||
case OpCode_ForceBold:
|
||||
case OpCode_LanguageGroup:
|
||||
case OpCode_ExpansionFactor:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename VAL=op_str_t>
|
||||
struct top_dict_opset_t : dict_opset_t
|
||||
{
|
||||
static void process_op (op_code_t op, interp_env_t<number_t>& env, top_dict_values_t<VAL> & dictval)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_CharStrings:
|
||||
dictval.charStringsOffset = env.argStack.pop_uint ();
|
||||
env.clear_args ();
|
||||
break;
|
||||
case OpCode_FDArray:
|
||||
dictval.FDArrayOffset = env.argStack.pop_uint ();
|
||||
env.clear_args ();
|
||||
break;
|
||||
case OpCode_FontMatrix:
|
||||
env.clear_args ();
|
||||
break;
|
||||
default:
|
||||
dict_opset_t::process_op (op, env);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM, typename ENV=num_interp_env_t>
|
||||
struct dict_interpreter_t : interpreter_t<ENV>
|
||||
{
|
||||
bool interpret (PARAM& param)
|
||||
{
|
||||
param.init ();
|
||||
while (SUPER::env.str_ref.avail ())
|
||||
{
|
||||
OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param);
|
||||
if (unlikely (SUPER::env.in_error ()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef interpreter_t<ENV> SUPER;
|
||||
};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
||||
#endif /* HB_CFF_INTERP_DICT_COMMON_HH */
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright © 2018 Adobe 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.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
#ifndef HB_CFF1_INTERP_CS_HH
|
||||
#define HB_CFF1_INTERP_CS_HH
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-cff-interp-cs-common.hh"
|
||||
|
||||
namespace CFF {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
typedef biased_subrs_t<CFF1Subrs> cff1_biased_subrs_t;
|
||||
|
||||
struct cff1_cs_interp_env_t : cs_interp_env_t<number_t, CFF1Subrs>
|
||||
{
|
||||
template <typename ACC>
|
||||
void init (const byte_str_t &str, ACC &acc, unsigned int fd)
|
||||
{
|
||||
SUPER::init (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs);
|
||||
processed_width = false;
|
||||
has_width = false;
|
||||
arg_start = 0;
|
||||
in_seac = false;
|
||||
}
|
||||
|
||||
void fini () { SUPER::fini (); }
|
||||
|
||||
void set_width (bool has_width_)
|
||||
{
|
||||
if (likely (!processed_width && (SUPER::argStack.get_count () > 0)))
|
||||
{
|
||||
if (has_width_)
|
||||
{
|
||||
width = SUPER::argStack[0];
|
||||
has_width = true;
|
||||
arg_start = 1;
|
||||
}
|
||||
}
|
||||
processed_width = true;
|
||||
}
|
||||
|
||||
void clear_args ()
|
||||
{
|
||||
arg_start = 0;
|
||||
SUPER::clear_args ();
|
||||
}
|
||||
|
||||
void set_in_seac (bool _in_seac) { in_seac = _in_seac; }
|
||||
|
||||
bool processed_width;
|
||||
bool has_width;
|
||||
unsigned int arg_start;
|
||||
number_t width;
|
||||
bool in_seac;
|
||||
|
||||
private:
|
||||
typedef cs_interp_env_t<number_t, CFF1Subrs> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM>>
|
||||
struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
|
||||
{
|
||||
/* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
|
||||
/* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */
|
||||
|
||||
static void process_op (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_dotsection:
|
||||
SUPER::flush_args_and_op (op, env, param);
|
||||
break;
|
||||
|
||||
case OpCode_endchar:
|
||||
OPSET::check_width (op, env, param);
|
||||
if (env.argStack.get_count () >= 4)
|
||||
{
|
||||
OPSET::process_seac (env, param);
|
||||
}
|
||||
OPSET::flush_args_and_op (op, env, param);
|
||||
env.set_endchar (true);
|
||||
break;
|
||||
|
||||
default:
|
||||
SUPER::process_op (op, env, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void check_width (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
|
||||
{
|
||||
if (!env.processed_width)
|
||||
{
|
||||
bool has_width = false;
|
||||
switch (op)
|
||||
{
|
||||
case OpCode_endchar:
|
||||
case OpCode_hstem:
|
||||
case OpCode_hstemhm:
|
||||
case OpCode_vstem:
|
||||
case OpCode_vstemhm:
|
||||
case OpCode_hintmask:
|
||||
case OpCode_cntrmask:
|
||||
has_width = ((env.argStack.get_count () & 1) != 0);
|
||||
break;
|
||||
case OpCode_hmoveto:
|
||||
case OpCode_vmoveto:
|
||||
has_width = (env.argStack.get_count () > 1);
|
||||
break;
|
||||
case OpCode_rmoveto:
|
||||
has_width = (env.argStack.get_count () > 2);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
env.set_width (has_width);
|
||||
}
|
||||
}
|
||||
|
||||
static void process_seac (cff1_cs_interp_env_t &env, PARAM& param)
|
||||
{
|
||||
}
|
||||
|
||||
static void flush_args (cff1_cs_interp_env_t &env, PARAM& param)
|
||||
{
|
||||
SUPER::flush_args (env, param);
|
||||
env.clear_args (); /* pop off width */
|
||||
}
|
||||
|
||||
private:
|
||||
typedef cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
struct cff1_cs_interpreter_t : cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM> {};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
||||
#endif /* HB_CFF1_INTERP_CS_HH */
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright © 2018 Adobe 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.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
#ifndef HB_CFF2_INTERP_CS_HH
|
||||
#define HB_CFF2_INTERP_CS_HH
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-cff-interp-cs-common.hh"
|
||||
|
||||
namespace CFF {
|
||||
|
||||
using namespace OT;
|
||||
|
||||
struct blend_arg_t : number_t
|
||||
{
|
||||
void init ()
|
||||
{
|
||||
number_t::init ();
|
||||
deltas.init ();
|
||||
}
|
||||
|
||||
void fini ()
|
||||
{
|
||||
number_t::fini ();
|
||||
deltas.fini_deep ();
|
||||
}
|
||||
|
||||
void set_int (int v) { reset_blends (); number_t::set_int (v); }
|
||||
void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); }
|
||||
void set_real (double v) { reset_blends (); number_t::set_real (v); }
|
||||
|
||||
void set_blends (unsigned int numValues_, unsigned int valueIndex_,
|
||||
unsigned int numBlends, hb_array_t<const blend_arg_t> blends_)
|
||||
{
|
||||
numValues = numValues_;
|
||||
valueIndex = valueIndex_;
|
||||
deltas.resize (numBlends);
|
||||
for (unsigned int i = 0; i < numBlends; i++)
|
||||
deltas[i] = blends_[i];
|
||||
}
|
||||
|
||||
bool blending () const { return deltas.length > 0; }
|
||||
void reset_blends ()
|
||||
{
|
||||
numValues = valueIndex = 0;
|
||||
deltas.resize (0);
|
||||
}
|
||||
|
||||
unsigned int numValues;
|
||||
unsigned int valueIndex;
|
||||
hb_vector_t<number_t> deltas;
|
||||
};
|
||||
|
||||
typedef interp_env_t<blend_arg_t> BlendInterpEnv;
|
||||
typedef biased_subrs_t<CFF2Subrs> cff2_biased_subrs_t;
|
||||
|
||||
struct cff2_cs_interp_env_t : cs_interp_env_t<blend_arg_t, CFF2Subrs>
|
||||
{
|
||||
template <typename ACC>
|
||||
void init (const byte_str_t &str, ACC &acc, unsigned int fd,
|
||||
const int *coords_=nullptr, unsigned int num_coords_=0)
|
||||
{
|
||||
SUPER::init (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs);
|
||||
|
||||
coords = coords_;
|
||||
num_coords = num_coords_;
|
||||
varStore = acc.varStore;
|
||||
seen_blend = false;
|
||||
seen_vsindex_ = false;
|
||||
scalars.init ();
|
||||
do_blend = num_coords && coords && varStore->size;
|
||||
set_ivs (acc.privateDicts[fd].ivs);
|
||||
}
|
||||
|
||||
void fini ()
|
||||
{
|
||||
scalars.fini ();
|
||||
SUPER::fini ();
|
||||
}
|
||||
|
||||
op_code_t fetch_op ()
|
||||
{
|
||||
if (this->str_ref.avail ())
|
||||
return SUPER::fetch_op ();
|
||||
|
||||
/* make up return or endchar op */
|
||||
if (this->callStack.is_empty ())
|
||||
return OpCode_endchar;
|
||||
else
|
||||
return OpCode_return;
|
||||
}
|
||||
|
||||
const blend_arg_t& eval_arg (unsigned int i)
|
||||
{
|
||||
blend_arg_t &arg = argStack[i];
|
||||
blend_arg (arg);
|
||||
return arg;
|
||||
}
|
||||
|
||||
const blend_arg_t& pop_arg ()
|
||||
{
|
||||
blend_arg_t &arg = argStack.pop ();
|
||||
blend_arg (arg);
|
||||
return arg;
|
||||
}
|
||||
|
||||
void process_blend ()
|
||||
{
|
||||
if (!seen_blend)
|
||||
{
|
||||
region_count = varStore->varStore.get_region_index_count (get_ivs ());
|
||||
if (do_blend)
|
||||
{
|
||||
if (unlikely (!scalars.resize (region_count)))
|
||||
set_error ();
|
||||
else
|
||||
varStore->varStore.get_scalars (get_ivs (), coords, num_coords,
|
||||
&scalars[0], region_count);
|
||||
}
|
||||
seen_blend = true;
|
||||
}
|
||||
}
|
||||
|
||||
void process_vsindex ()
|
||||
{
|
||||
unsigned int index = argStack.pop_uint ();
|
||||
if (unlikely (seen_vsindex () || seen_blend))
|
||||
{
|
||||
set_error ();
|
||||
}
|
||||
else
|
||||
{
|
||||
set_ivs (index);
|
||||
}
|
||||
seen_vsindex_ = true;
|
||||
}
|
||||
|
||||
unsigned int get_region_count () const { return region_count; }
|
||||
void set_region_count (unsigned int region_count_) { region_count = region_count_; }
|
||||
unsigned int get_ivs () const { return ivs; }
|
||||
void set_ivs (unsigned int ivs_) { ivs = ivs_; }
|
||||
bool seen_vsindex () const { return seen_vsindex_; }
|
||||
|
||||
protected:
|
||||
void blend_arg (blend_arg_t &arg)
|
||||
{
|
||||
if (do_blend && arg.blending ())
|
||||
{
|
||||
if (likely (scalars.length == arg.deltas.length))
|
||||
{
|
||||
double v = arg.to_real ();
|
||||
for (unsigned int i = 0; i < scalars.length; i++)
|
||||
{
|
||||
v += (double)scalars[i] * arg.deltas[i].to_real ();
|
||||
}
|
||||
arg.set_real (v);
|
||||
arg.deltas.resize (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
const int *coords;
|
||||
unsigned int num_coords;
|
||||
const CFF2VariationStore *varStore;
|
||||
unsigned int region_count;
|
||||
unsigned int ivs;
|
||||
hb_vector_t<float> scalars;
|
||||
bool do_blend;
|
||||
bool seen_vsindex_;
|
||||
bool seen_blend;
|
||||
|
||||
typedef cs_interp_env_t<blend_arg_t, CFF2Subrs> SUPER;
|
||||
};
|
||||
template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff2_cs_interp_env_t, PARAM>>
|
||||
struct cff2_cs_opset_t : cs_opset_t<blend_arg_t, OPSET, cff2_cs_interp_env_t, PARAM, PATH>
|
||||
{
|
||||
static void process_op (op_code_t op, cff2_cs_interp_env_t &env, PARAM& param)
|
||||
{
|
||||
switch (op) {
|
||||
case OpCode_callsubr:
|
||||
case OpCode_callgsubr:
|
||||
/* a subroutine number shoudln't be a blended value */
|
||||
if (unlikely (env.argStack.peek ().blending ()))
|
||||
{
|
||||
env.set_error ();
|
||||
break;
|
||||
}
|
||||
SUPER::process_op (op, env, param);
|
||||
break;
|
||||
|
||||
case OpCode_blendcs:
|
||||
OPSET::process_blend (env, param);
|
||||
break;
|
||||
|
||||
case OpCode_vsindexcs:
|
||||
if (unlikely (env.argStack.peek ().blending ()))
|
||||
{
|
||||
env.set_error ();
|
||||
break;
|
||||
}
|
||||
OPSET::process_vsindex (env, param);
|
||||
break;
|
||||
|
||||
default:
|
||||
SUPER::process_op (op, env, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void process_blend (cff2_cs_interp_env_t &env, PARAM& param)
|
||||
{
|
||||
unsigned int n, k;
|
||||
|
||||
env.process_blend ();
|
||||
k = env.get_region_count ();
|
||||
n = env.argStack.pop_uint ();
|
||||
/* copy the blend values into blend array of the default values */
|
||||
unsigned int start = env.argStack.get_count () - ((k+1) * n);
|
||||
/* let an obvious error case fail, but note CFF2 spec doesn't forbid n==0 */
|
||||
if (unlikely (start > env.argStack.get_count ()))
|
||||
{
|
||||
env.set_error ();
|
||||
return;
|
||||
}
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
{
|
||||
const hb_array_t<const blend_arg_t> blends = env.argStack.get_subarray (start + n + (i * k));
|
||||
env.argStack[start + i].set_blends (n, i, k, blends);
|
||||
}
|
||||
|
||||
/* pop off blend values leaving default values now adorned with blend values */
|
||||
env.argStack.pop (k * n);
|
||||
}
|
||||
|
||||
static void process_vsindex (cff2_cs_interp_env_t &env, PARAM& param)
|
||||
{
|
||||
env.process_vsindex ();
|
||||
env.clear_args ();
|
||||
}
|
||||
|
||||
private:
|
||||
typedef cs_opset_t<blend_arg_t, OPSET, cff2_cs_interp_env_t, PARAM, PATH> SUPER;
|
||||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
struct cff2_cs_interpreter_t : cs_interpreter_t<cff2_cs_interp_env_t, OPSET, PARAM> {};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
||||
#endif /* HB_CFF2_INTERP_CS_HH */
|
||||
+361
-204
@@ -26,30 +26,59 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#include "hb-private.hh"
|
||||
|
||||
#include "hb-mutex-private.hh"
|
||||
#include "hb-object-private.hh"
|
||||
#include "hb.hh"
|
||||
#include "hb-machinery.hh"
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#ifdef HB_NO_SETLOCALE
|
||||
#define setlocale(Category, Locale) "C"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SECTION:hb-common
|
||||
* @title: hb-common
|
||||
* @short_description: Common data types
|
||||
* @include: hb.h
|
||||
*
|
||||
* Common data types used across HarfBuzz are defined here.
|
||||
**/
|
||||
|
||||
|
||||
/* hb_options_t */
|
||||
|
||||
hb_options_union_t _hb_options;
|
||||
hb_atomic_int_t _hb_options;
|
||||
|
||||
void
|
||||
_hb_options_init (void)
|
||||
_hb_options_init ()
|
||||
{
|
||||
hb_options_union_t u;
|
||||
u.i = 0;
|
||||
u.opts.initialized = 1;
|
||||
u.opts.initialized = true;
|
||||
|
||||
char *c = getenv ("HB_OPTIONS");
|
||||
u.opts.uniscribe_bug_compatible = c && strstr (c, "uniscribe-bug-compatible");
|
||||
const char *c = getenv ("HB_OPTIONS");
|
||||
if (c)
|
||||
{
|
||||
while (*c)
|
||||
{
|
||||
const char *p = strchr (c, ':');
|
||||
if (!p)
|
||||
p = c + strlen (c);
|
||||
|
||||
#define OPTION(name, symbol) \
|
||||
if (0 == strncmp (c, name, p - c) && strlen (name) == static_cast<size_t>(p - c)) do { u.opts.symbol = true; } while (0)
|
||||
|
||||
OPTION ("uniscribe-bug-compatible", uniscribe_bug_compatible);
|
||||
|
||||
#undef OPTION
|
||||
|
||||
c = *p ? p + 1 : p;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* This is idempotent and threadsafe. */
|
||||
_hb_options = u;
|
||||
_hb_options.set_relaxed (u.i);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,12 +86,15 @@ _hb_options_init (void)
|
||||
|
||||
/**
|
||||
* hb_tag_from_string:
|
||||
* @str: (array length=len) (element-type uint8_t):
|
||||
* @len:
|
||||
* @str: (array length=len) (element-type uint8_t): String to convert
|
||||
* @len: Length of @str, or -1 if it is %NULL-terminated
|
||||
*
|
||||
*
|
||||
* Converts a string into an #hb_tag_t. Valid tags
|
||||
* are four characters. Shorter input strings will be
|
||||
* padded with spaces. Longer input strings will be
|
||||
* truncated.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: The #hb_tag_t corresponding to @str
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -82,15 +114,16 @@ hb_tag_from_string (const char *str, int len)
|
||||
for (; i < 4; i++)
|
||||
tag[i] = ' ';
|
||||
|
||||
return HB_TAG_CHAR4 (tag);
|
||||
return HB_TAG (tag[0], tag[1], tag[2], tag[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_tag_to_string:
|
||||
* @tag:
|
||||
* @buf: (out caller-allocates) (array fixed-size=4) (element-type uint8_t):
|
||||
* @tag: #hb_tag_t to convert
|
||||
* @buf: (out caller-allocates) (array fixed-size=4) (element-type uint8_t): Converted string
|
||||
*
|
||||
*
|
||||
* Converts an #hb_tag_t to a string and returns it in @buf.
|
||||
* Strings will be four characters long.
|
||||
*
|
||||
* Since: 0.9.5
|
||||
**/
|
||||
@@ -115,12 +148,17 @@ const char direction_strings[][4] = {
|
||||
|
||||
/**
|
||||
* hb_direction_from_string:
|
||||
* @str: (array length=len) (element-type uint8_t):
|
||||
* @len:
|
||||
* @str: (array length=len) (element-type uint8_t): String to convert
|
||||
* @len: Length of @str, or -1 if it is %NULL-terminated
|
||||
*
|
||||
* Converts a string to an #hb_direction_t.
|
||||
*
|
||||
* Matching is loose and applies only to the first letter. For
|
||||
* examples, "LTR" and "left-to-right" will both return #HB_DIRECTION_LTR.
|
||||
*
|
||||
* Unmatched strings will return #HB_DIRECTION_INVALID.
|
||||
*
|
||||
*
|
||||
* Return value:
|
||||
* Return value: The #hb_direction_t matching @str
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -143,11 +181,11 @@ hb_direction_from_string (const char *str, int len)
|
||||
|
||||
/**
|
||||
* hb_direction_to_string:
|
||||
* @direction:
|
||||
* @direction: The #hb_direction_t to convert
|
||||
*
|
||||
*
|
||||
* Converts an #hb_direction_t to a string.
|
||||
*
|
||||
* Return value: (transfer none):
|
||||
* Return value: (transfer none): The string corresponding to @direction
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -173,7 +211,7 @@ static const char canon_map[256] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0,
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0,
|
||||
'-', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, '-',
|
||||
0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, 0
|
||||
@@ -216,17 +254,14 @@ struct hb_language_item_t {
|
||||
struct hb_language_item_t *next;
|
||||
hb_language_t lang;
|
||||
|
||||
inline bool operator == (const char *s) const {
|
||||
return lang_equal (lang, s);
|
||||
}
|
||||
bool operator == (const char *s) const
|
||||
{ return lang_equal (lang, s); }
|
||||
|
||||
inline hb_language_item_t & operator = (const char *s) {
|
||||
/* If a custom allocated is used calling strdup() pairs
|
||||
badly with a call to the custom free() in finish() below.
|
||||
Therefore don't call strdup(), implement its behavior.
|
||||
*/
|
||||
hb_language_item_t & operator = (const char *s)
|
||||
{
|
||||
/* We can't call strdup(), because we allow custom allocators. */
|
||||
size_t len = strlen(s) + 1;
|
||||
lang = (hb_language_t) malloc(len);
|
||||
lang = (hb_language_t) hb_malloc(len);
|
||||
if (likely (lang))
|
||||
{
|
||||
memcpy((unsigned char *) lang, s, len);
|
||||
@@ -237,23 +272,28 @@ struct hb_language_item_t {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void finish (void) { free ((void *) lang); }
|
||||
void fini () { hb_free ((void *) lang); }
|
||||
};
|
||||
|
||||
|
||||
/* Thread-safe lock-free language list */
|
||||
/* Thread-safe lockfree language list */
|
||||
|
||||
static hb_language_item_t *langs;
|
||||
static hb_atomic_ptr_t <hb_language_item_t> langs;
|
||||
|
||||
#ifdef HB_USE_ATEXIT
|
||||
static
|
||||
void free_langs (void)
|
||||
#if HB_USE_ATEXIT
|
||||
static void
|
||||
free_langs ()
|
||||
{
|
||||
while (langs) {
|
||||
hb_language_item_t *next = langs->next;
|
||||
langs->finish ();
|
||||
free (langs);
|
||||
langs = next;
|
||||
retry:
|
||||
hb_language_item_t *first_lang = langs;
|
||||
if (unlikely (!langs.cmpexch (first_lang, nullptr)))
|
||||
goto retry;
|
||||
|
||||
while (first_lang) {
|
||||
hb_language_item_t *next = first_lang->next;
|
||||
first_lang->fini ();
|
||||
hb_free (first_lang);
|
||||
first_lang = next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -262,31 +302,32 @@ static hb_language_item_t *
|
||||
lang_find_or_insert (const char *key)
|
||||
{
|
||||
retry:
|
||||
hb_language_item_t *first_lang = (hb_language_item_t *) hb_atomic_ptr_get (&langs);
|
||||
hb_language_item_t *first_lang = langs;
|
||||
|
||||
for (hb_language_item_t *lang = first_lang; lang; lang = lang->next)
|
||||
if (*lang == key)
|
||||
return lang;
|
||||
|
||||
/* Not found; allocate one. */
|
||||
hb_language_item_t *lang = (hb_language_item_t *) calloc (1, sizeof (hb_language_item_t));
|
||||
hb_language_item_t *lang = (hb_language_item_t *) hb_calloc (1, sizeof (hb_language_item_t));
|
||||
if (unlikely (!lang))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
lang->next = first_lang;
|
||||
*lang = key;
|
||||
if (unlikely (!lang->lang))
|
||||
{
|
||||
free (lang);
|
||||
return NULL;
|
||||
hb_free (lang);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) {
|
||||
lang->finish ();
|
||||
free (lang);
|
||||
if (unlikely (!langs.cmpexch (first_lang, lang)))
|
||||
{
|
||||
lang->fini ();
|
||||
hb_free (lang);
|
||||
goto retry;
|
||||
}
|
||||
|
||||
#ifdef HB_USE_ATEXIT
|
||||
#if HB_USE_ATEXIT
|
||||
if (!first_lang)
|
||||
atexit (free_langs); /* First person registers atexit() callback. */
|
||||
#endif
|
||||
@@ -298,14 +339,14 @@ retry:
|
||||
/**
|
||||
* hb_language_from_string:
|
||||
* @str: (array length=len) (element-type uint8_t): a string representing
|
||||
* ISO 639 language code
|
||||
* a BCP 47 language tag
|
||||
* @len: length of the @str, or -1 if it is %NULL-terminated.
|
||||
*
|
||||
* Converts @str representing an ISO 639 language code to the corresponding
|
||||
* Converts @str representing a BCP 47 language tag to the corresponding
|
||||
* #hb_language_t.
|
||||
*
|
||||
* Return value: (transfer none):
|
||||
* The #hb_language_t corresponding to the ISO 639 language code.
|
||||
* The #hb_language_t corresponding to the BCP 47 language tag.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -315,12 +356,12 @@ hb_language_from_string (const char *str, int len)
|
||||
if (!str || !len || !*str)
|
||||
return HB_LANGUAGE_INVALID;
|
||||
|
||||
hb_language_item_t *item = NULL;
|
||||
hb_language_item_t *item = nullptr;
|
||||
if (len >= 0)
|
||||
{
|
||||
/* NUL-terminate it. */
|
||||
char strbuf[64];
|
||||
len = MIN (len, (int) sizeof (strbuf) - 1);
|
||||
len = hb_min (len, (int) sizeof (strbuf) - 1);
|
||||
memcpy (strbuf, str, len);
|
||||
strbuf[len] = '\0';
|
||||
item = lang_find_or_insert (strbuf);
|
||||
@@ -333,9 +374,9 @@ hb_language_from_string (const char *str, int len)
|
||||
|
||||
/**
|
||||
* hb_language_to_string:
|
||||
* @language: an #hb_language_t to convert.
|
||||
* @language: The #hb_language_t to convert
|
||||
*
|
||||
* See hb_language_from_string().
|
||||
* Converts an #hb_language_t to a string.
|
||||
*
|
||||
* Return value: (transfer none):
|
||||
* A %NULL-terminated string representing the @language. Must not be freed by
|
||||
@@ -346,31 +387,41 @@ hb_language_from_string (const char *str, int len)
|
||||
const char *
|
||||
hb_language_to_string (hb_language_t language)
|
||||
{
|
||||
/* This is actually NULL-safe! */
|
||||
if (unlikely (!language)) return nullptr;
|
||||
|
||||
return language->s;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_language_get_default:
|
||||
*
|
||||
*
|
||||
* Fetch the default language from current locale.
|
||||
*
|
||||
* Return value: (transfer none):
|
||||
* <note>Note that the first time this function is called, it calls
|
||||
* "setlocale (LC_CTYPE, nullptr)" to fetch current locale. The underlying
|
||||
* setlocale function is, in many implementations, NOT threadsafe. To avoid
|
||||
* problems, call this function once before multiple threads can call it.
|
||||
* This function is only used from hb_buffer_guess_segment_properties() by
|
||||
* HarfBuzz itself.</note>
|
||||
*
|
||||
* Return value: (transfer none): The default language of the locale as
|
||||
* an #hb_language_t
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
hb_language_t
|
||||
hb_language_get_default (void)
|
||||
hb_language_get_default ()
|
||||
{
|
||||
static hb_language_t default_language = HB_LANGUAGE_INVALID;
|
||||
static hb_atomic_ptr_t <hb_language_t> default_language;
|
||||
|
||||
hb_language_t language = (hb_language_t) hb_atomic_ptr_get (&default_language);
|
||||
if (unlikely (language == HB_LANGUAGE_INVALID)) {
|
||||
language = hb_language_from_string (setlocale (LC_CTYPE, NULL), -1);
|
||||
(void) hb_atomic_ptr_cmpexch (&default_language, HB_LANGUAGE_INVALID, language);
|
||||
hb_language_t language = default_language;
|
||||
if (unlikely (language == HB_LANGUAGE_INVALID))
|
||||
{
|
||||
language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1);
|
||||
(void) default_language.cmpexch (HB_LANGUAGE_INVALID, language);
|
||||
}
|
||||
|
||||
return default_language;
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
@@ -378,12 +429,12 @@ hb_language_get_default (void)
|
||||
|
||||
/**
|
||||
* hb_script_from_iso15924_tag:
|
||||
* @tag: an #hb_tag_t representing an ISO 15924 tag.
|
||||
* @tag: an #hb_tag_t representing an ISO 15924 tag.
|
||||
*
|
||||
* Converts an ISO 15924 script tag to a corresponding #hb_script_t.
|
||||
* Converts an ISO 15924 script tag to a corresponding #hb_script_t.
|
||||
*
|
||||
* Return value:
|
||||
* An #hb_script_t corresponding to the ISO 15924 tag.
|
||||
* Return value:
|
||||
* An #hb_script_t corresponding to the ISO 15924 tag.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -404,8 +455,13 @@ hb_script_from_iso15924_tag (hb_tag_t tag)
|
||||
case HB_TAG('Q','a','a','i'): return HB_SCRIPT_INHERITED;
|
||||
case HB_TAG('Q','a','a','c'): return HB_SCRIPT_COPTIC;
|
||||
|
||||
/* Script variants from http://unicode.org/iso15924/ */
|
||||
/* Script variants from https://unicode.org/iso15924/ */
|
||||
case HB_TAG('A','r','a','n'): return HB_SCRIPT_ARABIC;
|
||||
case HB_TAG('C','y','r','s'): return HB_SCRIPT_CYRILLIC;
|
||||
case HB_TAG('G','e','o','k'): return HB_SCRIPT_GEORGIAN;
|
||||
case HB_TAG('H','a','n','s'): return HB_SCRIPT_HAN;
|
||||
case HB_TAG('H','a','n','t'): return HB_SCRIPT_HAN;
|
||||
case HB_TAG('J','a','m','o'): return HB_SCRIPT_HANGUL;
|
||||
case HB_TAG('L','a','t','f'): return HB_SCRIPT_LATIN;
|
||||
case HB_TAG('L','a','t','g'): return HB_SCRIPT_LATIN;
|
||||
case HB_TAG('S','y','r','e'): return HB_SCRIPT_SYRIAC;
|
||||
@@ -424,15 +480,15 @@ hb_script_from_iso15924_tag (hb_tag_t tag)
|
||||
/**
|
||||
* hb_script_from_string:
|
||||
* @str: (array length=len) (element-type uint8_t): a string representing an
|
||||
* ISO 15924 tag.
|
||||
* ISO 15924 tag.
|
||||
* @len: length of the @str, or -1 if it is %NULL-terminated.
|
||||
*
|
||||
* Converts a string @str representing an ISO 15924 script tag to a
|
||||
* Converts a string @str representing an ISO 15924 script tag to a
|
||||
* corresponding #hb_script_t. Shorthand for hb_tag_from_string() then
|
||||
* hb_script_from_iso15924_tag().
|
||||
*
|
||||
* Return value:
|
||||
* An #hb_script_t corresponding to the ISO 15924 tag.
|
||||
* Return value:
|
||||
* An #hb_script_t corresponding to the ISO 15924 tag.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -444,12 +500,12 @@ hb_script_from_string (const char *str, int len)
|
||||
|
||||
/**
|
||||
* hb_script_to_iso15924_tag:
|
||||
* @script: an #hb_script_ to convert.
|
||||
* @script: an #hb_script_t to convert.
|
||||
*
|
||||
* See hb_script_from_iso15924_tag().
|
||||
* Converts an #hb_script_t to a corresponding ISO 15924 script tag.
|
||||
*
|
||||
* Return value:
|
||||
* An #hb_tag_t representing an ISO 15924 script tag.
|
||||
* An #hb_tag_t representing an ISO 15924 script tag.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -461,18 +517,23 @@ hb_script_to_iso15924_tag (hb_script_t script)
|
||||
|
||||
/**
|
||||
* hb_script_get_horizontal_direction:
|
||||
* @script:
|
||||
* @script: The #hb_script_t to query
|
||||
*
|
||||
*
|
||||
* Fetches the #hb_direction_t of a script when it is
|
||||
* set horizontally. All right-to-left scripts will return
|
||||
* #HB_DIRECTION_RTL. All left-to-right scripts will return
|
||||
* #HB_DIRECTION_LTR. Scripts that can be written either
|
||||
* horizontally or vertically will return #HB_DIRECTION_INVALID.
|
||||
* Unknown scripts will return #HB_DIRECTION_LTR.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: The horizontal #hb_direction_t of @script
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
hb_direction_t
|
||||
hb_script_get_horizontal_direction (hb_script_t script)
|
||||
{
|
||||
/* http://goo.gl/x9ilM */
|
||||
/* https://docs.google.com/spreadsheets/d/1Y90M0Ie3MUJ6UVCRDOypOtijlMDLNNyyLk36T6iMu0o */
|
||||
switch ((hb_tag_t) script)
|
||||
{
|
||||
/* Unicode-1.1 additions */
|
||||
@@ -521,57 +582,58 @@ hb_script_get_horizontal_direction (hb_script_t script)
|
||||
case HB_SCRIPT_PSALTER_PAHLAVI:
|
||||
|
||||
/* Unicode-8.0 additions */
|
||||
case HB_SCRIPT_OLD_HUNGARIAN:
|
||||
case HB_SCRIPT_HATRAN:
|
||||
|
||||
/* Unicode-9.0 additions */
|
||||
case HB_SCRIPT_ADLAM:
|
||||
|
||||
/* Unicode-11.0 additions */
|
||||
case HB_SCRIPT_HANIFI_ROHINGYA:
|
||||
case HB_SCRIPT_OLD_SOGDIAN:
|
||||
case HB_SCRIPT_SOGDIAN:
|
||||
|
||||
/* Unicode-12.0 additions */
|
||||
case HB_SCRIPT_ELYMAIC:
|
||||
|
||||
/* Unicode-13.0 additions */
|
||||
case HB_SCRIPT_CHORASMIAN:
|
||||
case HB_SCRIPT_YEZIDI:
|
||||
|
||||
return HB_DIRECTION_RTL;
|
||||
|
||||
|
||||
/* https://github.com/harfbuzz/harfbuzz/issues/1000 */
|
||||
case HB_SCRIPT_OLD_HUNGARIAN:
|
||||
case HB_SCRIPT_OLD_ITALIC:
|
||||
case HB_SCRIPT_RUNIC:
|
||||
|
||||
return HB_DIRECTION_INVALID;
|
||||
}
|
||||
|
||||
return HB_DIRECTION_LTR;
|
||||
}
|
||||
|
||||
|
||||
/* hb_user_data_array_t */
|
||||
|
||||
bool
|
||||
hb_user_data_array_t::set (hb_user_data_key_t *key,
|
||||
void * data,
|
||||
hb_destroy_func_t destroy,
|
||||
hb_bool_t replace)
|
||||
{
|
||||
if (!key)
|
||||
return false;
|
||||
|
||||
if (replace) {
|
||||
if (!data && !destroy) {
|
||||
items.remove (key, lock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
hb_user_data_item_t item = {key, data, destroy};
|
||||
bool ret = !!items.replace_or_insert (item, lock, (bool) replace);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *
|
||||
hb_user_data_array_t::get (hb_user_data_key_t *key)
|
||||
{
|
||||
hb_user_data_item_t item = {NULL, NULL, NULL};
|
||||
|
||||
return items.find (key, &item, lock) ? item.data : NULL;
|
||||
}
|
||||
|
||||
|
||||
/* hb_version */
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:hb-version
|
||||
* @title: hb-version
|
||||
* @short_description: Information about the version of HarfBuzz in use
|
||||
* @include: hb.h
|
||||
*
|
||||
* These functions and macros allow accessing version of the HarfBuzz
|
||||
* library used at compile- as well as run-time, and to direct code
|
||||
* conditionally based on those versions, again, at compile- or run-time.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* hb_version:
|
||||
* @major: (out): Library major version component.
|
||||
* @minor: (out): Library minor version component.
|
||||
* @micro: (out): Library micro version component.
|
||||
* @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.
|
||||
*
|
||||
@@ -592,25 +654,27 @@ hb_version (unsigned int *major,
|
||||
*
|
||||
* Returns library version as a string with three components.
|
||||
*
|
||||
* Return value: library version string.
|
||||
* Return value: Library version string
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
const char *
|
||||
hb_version_string (void)
|
||||
hb_version_string ()
|
||||
{
|
||||
return HB_VERSION_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_version_atleast:
|
||||
* @major:
|
||||
* @minor:
|
||||
* @micro:
|
||||
* @major: Library major version component
|
||||
* @minor: Library minor version component
|
||||
* @micro: Library micro version component
|
||||
*
|
||||
*
|
||||
* Tests the library version against a minimum value,
|
||||
* as three integer components.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: %true if the library is equal to or greater than
|
||||
* the test value, %false otherwise
|
||||
*
|
||||
* Since: 0.9.30
|
||||
**/
|
||||
@@ -649,70 +713,24 @@ parse_char (const char **pp, const char *end, char c)
|
||||
static bool
|
||||
parse_uint (const char **pp, const char *end, unsigned int *pv)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
|
||||
strncpy (buf, *pp, len);
|
||||
buf[len] = '\0';
|
||||
|
||||
char *p = buf;
|
||||
char *pend = p;
|
||||
unsigned int v;
|
||||
|
||||
/* Intentionally use strtol instead of strtoul, such that
|
||||
* -1 turns into "big number"... */
|
||||
errno = 0;
|
||||
v = strtol (p, &pend, 0);
|
||||
if (errno || p == pend)
|
||||
return false;
|
||||
/* Intentionally use hb_parse_int inside instead of hb_parse_uint,
|
||||
* such that -1 turns into "big number"... */
|
||||
int v;
|
||||
if (unlikely (!hb_parse_int (pp, end, &v))) return false;
|
||||
|
||||
*pv = v;
|
||||
*pp += pend - p;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_uint32 (const char **pp, const char *end, uint32_t *pv)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
|
||||
strncpy (buf, *pp, len);
|
||||
buf[len] = '\0';
|
||||
|
||||
char *p = buf;
|
||||
char *pend = p;
|
||||
unsigned int v;
|
||||
|
||||
/* Intentionally use strtol instead of strtoul, such that
|
||||
* -1 turns into "big number"... */
|
||||
errno = 0;
|
||||
v = strtol (p, &pend, 0);
|
||||
if (errno || p == pend)
|
||||
return false;
|
||||
/* Intentionally use hb_parse_int inside instead of hb_parse_uint,
|
||||
* such that -1 turns into "big number"... */
|
||||
int v;
|
||||
if (unlikely (!hb_parse_int (pp, end, &v))) return false;
|
||||
|
||||
*pv = v;
|
||||
*pp += pend - p;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
parse_float (const char **pp, const char *end, float *pv)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
|
||||
strncpy (buf, *pp, len);
|
||||
buf[len] = '\0';
|
||||
|
||||
char *p = buf;
|
||||
char *pend = p;
|
||||
float v;
|
||||
|
||||
errno = 0;
|
||||
v = strtod (p, &pend);
|
||||
if (errno || p == pend)
|
||||
return false;
|
||||
|
||||
*pv = v;
|
||||
*pp += pend - p;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -726,9 +744,14 @@ parse_bool (const char **pp, const char *end, uint32_t *pv)
|
||||
(*pp)++;
|
||||
|
||||
/* CSS allows on/off as aliases 1/0. */
|
||||
if (*pp - p == 2 || 0 == strncmp (p, "on", 2))
|
||||
if (*pp - p == 2
|
||||
&& TOLOWER (p[0]) == 'o'
|
||||
&& TOLOWER (p[1]) == 'n')
|
||||
*pv = 1;
|
||||
else if (*pp - p == 3 || 0 == strncmp (p, "off", 2))
|
||||
else if (*pp - p == 3
|
||||
&& TOLOWER (p[0]) == 'o'
|
||||
&& TOLOWER (p[1]) == 'f'
|
||||
&& TOLOWER (p[2]) == 'f')
|
||||
*pv = 0;
|
||||
else
|
||||
return false;
|
||||
@@ -765,7 +788,7 @@ parse_tag (const char **pp, const char *end, hb_tag_t *tag)
|
||||
}
|
||||
|
||||
const char *p = *pp;
|
||||
while (*pp < end && ISALNUM(**pp))
|
||||
while (*pp < end && (ISALNUM(**pp) || **pp == '_'))
|
||||
(*pp)++;
|
||||
|
||||
if (p == *pp || *pp - p > 4)
|
||||
@@ -794,15 +817,15 @@ parse_feature_indices (const char **pp, const char *end, hb_feature_t *feature)
|
||||
|
||||
bool has_start;
|
||||
|
||||
feature->start = 0;
|
||||
feature->end = (unsigned int) -1;
|
||||
feature->start = HB_FEATURE_GLOBAL_START;
|
||||
feature->end = HB_FEATURE_GLOBAL_END;
|
||||
|
||||
if (!parse_char (pp, end, '['))
|
||||
return true;
|
||||
|
||||
has_start = parse_uint (pp, end, &feature->start);
|
||||
|
||||
if (parse_char (pp, end, ':')) {
|
||||
if (parse_char (pp, end, ':') || parse_char (pp, end, ';')) {
|
||||
parse_uint (pp, end, &feature->end);
|
||||
} else {
|
||||
if (has_start)
|
||||
@@ -817,10 +840,10 @@ parse_feature_value_postfix (const char **pp, const char *end, hb_feature_t *fea
|
||||
{
|
||||
bool had_equal = parse_char (pp, end, '=');
|
||||
bool had_value = parse_uint32 (pp, end, &feature->value) ||
|
||||
parse_bool (pp, end, &feature->value);
|
||||
parse_bool (pp, end, &feature->value);
|
||||
/* CSS doesn't use equal-sign between tag and value.
|
||||
* If there was an equal-sign, then there *must* be a value.
|
||||
* A value without an eqaul-sign is ok, but not required. */
|
||||
* A value without an equal-sign is ok, but not required. */
|
||||
return !had_equal || had_value;
|
||||
}
|
||||
|
||||
@@ -843,10 +866,44 @@ parse_one_feature (const char **pp, const char *end, hb_feature_t *feature)
|
||||
*
|
||||
* Parses a string into a #hb_feature_t.
|
||||
*
|
||||
* TODO: document the syntax here.
|
||||
* The format for specifying feature strings follows. All valid CSS
|
||||
* font-feature-settings values other than 'normal' and the global values are
|
||||
* also accepted, though not documented below. CSS string escapes are not
|
||||
* supported.
|
||||
*
|
||||
* The range indices refer to the positions between Unicode characters. The
|
||||
* position before the first character is always 0.
|
||||
*
|
||||
* The format is Python-esque. Here is how it all works:
|
||||
*
|
||||
* <informaltable pgwide='1' align='left' frame='none'>
|
||||
* <tgroup cols='5'>
|
||||
* <thead>
|
||||
* <row><entry>Syntax</entry> <entry>Value</entry> <entry>Start</entry> <entry>End</entry></row>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <row><entry>Setting value:</entry></row>
|
||||
* <row><entry>kern</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row>
|
||||
* <row><entry>+kern</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row>
|
||||
* <row><entry>-kern</entry> <entry>0</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature off</entry></row>
|
||||
* <row><entry>kern=0</entry> <entry>0</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature off</entry></row>
|
||||
* <row><entry>kern=1</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row>
|
||||
* <row><entry>aalt=2</entry> <entry>2</entry> <entry>0</entry> <entry>∞</entry> <entry>Choose 2nd alternate</entry></row>
|
||||
* <row><entry>Setting index:</entry></row>
|
||||
* <row><entry>kern[]</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row>
|
||||
* <row><entry>kern[:]</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row>
|
||||
* <row><entry>kern[5:]</entry> <entry>1</entry> <entry>5</entry> <entry>∞</entry> <entry>Turn feature on, partial</entry></row>
|
||||
* <row><entry>kern[:5]</entry> <entry>1</entry> <entry>0</entry> <entry>5</entry> <entry>Turn feature on, partial</entry></row>
|
||||
* <row><entry>kern[3:5]</entry> <entry>1</entry> <entry>3</entry> <entry>5</entry> <entry>Turn feature on, range</entry></row>
|
||||
* <row><entry>kern[3]</entry> <entry>1</entry> <entry>3</entry> <entry>3+1</entry> <entry>Turn feature on, single char</entry></row>
|
||||
* <row><entry>Mixing it all:</entry></row>
|
||||
* <row><entry>aalt[3:5]=2</entry> <entry>2</entry> <entry>3</entry> <entry>5</entry> <entry>Turn 2nd alternate on for range</entry></row>
|
||||
* </tbody>
|
||||
* </tgroup>
|
||||
* </informaltable>
|
||||
*
|
||||
* Return value:
|
||||
* %true if @str is successfully parsed, %false otherwise.
|
||||
* %true if @str is successfully parsed, %false otherwise
|
||||
*
|
||||
* Since: 0.9.5
|
||||
**/
|
||||
@@ -897,25 +954,25 @@ hb_feature_to_string (hb_feature_t *feature,
|
||||
len += 4;
|
||||
while (len && s[len - 1] == ' ')
|
||||
len--;
|
||||
if (feature->start != 0 || feature->end != (unsigned int) -1)
|
||||
if (feature->start != HB_FEATURE_GLOBAL_START || feature->end != HB_FEATURE_GLOBAL_END)
|
||||
{
|
||||
s[len++] = '[';
|
||||
if (feature->start)
|
||||
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->start));
|
||||
len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", 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, "%u", feature->end));
|
||||
if (feature->end != HB_FEATURE_GLOBAL_END)
|
||||
len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->end));
|
||||
}
|
||||
s[len++] = ']';
|
||||
}
|
||||
if (feature->value > 1)
|
||||
{
|
||||
s[len++] = '=';
|
||||
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->value));
|
||||
len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->value));
|
||||
}
|
||||
assert (len < ARRAY_LENGTH (s));
|
||||
len = MIN (len, size - 1);
|
||||
len = hb_min (len, size - 1);
|
||||
memcpy (buf, s, len);
|
||||
buf[len] = '\0';
|
||||
}
|
||||
@@ -926,7 +983,11 @@ static bool
|
||||
parse_variation_value (const char **pp, const char *end, hb_variation_t *variation)
|
||||
{
|
||||
parse_char (pp, end, '='); /* Optional. */
|
||||
return parse_float (pp, end, &variation->value);
|
||||
double v;
|
||||
if (unlikely (!hb_parse_double (pp, end, &v))) return false;
|
||||
|
||||
variation->value = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -940,6 +1001,21 @@ parse_one_variation (const char **pp, const char *end, hb_variation_t *variation
|
||||
|
||||
/**
|
||||
* hb_variation_from_string:
|
||||
* @str: (array length=len) (element-type uint8_t): a string to parse
|
||||
* @len: length of @str, or -1 if string is %NULL terminated
|
||||
* @variation: (out): the #hb_variation_t to initialize with the parsed values
|
||||
*
|
||||
* Parses a string into a #hb_variation_t.
|
||||
*
|
||||
* The format for specifying variation settings follows. All valid CSS
|
||||
* font-variation-settings values other than 'normal' and 'inherited' are also
|
||||
* accepted, though, not documented below.
|
||||
*
|
||||
* The format is a tag, optionally followed by an equals sign, followed by a
|
||||
* number. For example `wght=500`, or `slnt=-7.5`.
|
||||
*
|
||||
* Return value:
|
||||
* %true if @str is successfully parsed, %false otherwise
|
||||
*
|
||||
* Since: 1.4.2
|
||||
*/
|
||||
@@ -966,6 +1042,13 @@ hb_variation_from_string (const char *str, int len,
|
||||
|
||||
/**
|
||||
* hb_variation_to_string:
|
||||
* @variation: an #hb_variation_t to convert
|
||||
* @buf: (array length=size) (out): output string
|
||||
* @size: the allocated size of @buf
|
||||
*
|
||||
* Converts an #hb_variation_t into a %NULL-terminated string in the format
|
||||
* understood by hb_variation_from_string(). The client in responsible for
|
||||
* allocating big enough size for @buf, 128 bytes is more than enough.
|
||||
*
|
||||
* Since: 1.4.2
|
||||
*/
|
||||
@@ -982,10 +1065,84 @@ hb_variation_to_string (hb_variation_t *variation,
|
||||
while (len && s[len - 1] == ' ')
|
||||
len--;
|
||||
s[len++] = '=';
|
||||
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", variation->value));
|
||||
len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", (double) variation->value));
|
||||
|
||||
assert (len < ARRAY_LENGTH (s));
|
||||
len = MIN (len, size - 1);
|
||||
len = hb_min (len, size - 1);
|
||||
memcpy (buf, s, len);
|
||||
buf[len] = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_color_get_alpha:
|
||||
* @color: an #hb_color_t we are interested in its channels.
|
||||
*
|
||||
* Fetches the alpha channel of the given @color.
|
||||
*
|
||||
* Return value: Alpha channel value
|
||||
*
|
||||
* Since: 2.1.0
|
||||
*/
|
||||
uint8_t
|
||||
(hb_color_get_alpha) (hb_color_t color)
|
||||
{
|
||||
return hb_color_get_alpha (color);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_color_get_red:
|
||||
* @color: an #hb_color_t we are interested in its channels.
|
||||
*
|
||||
* Fetches the red channel of the given @color.
|
||||
*
|
||||
* Return value: Red channel value
|
||||
*
|
||||
* Since: 2.1.0
|
||||
*/
|
||||
uint8_t
|
||||
(hb_color_get_red) (hb_color_t color)
|
||||
{
|
||||
return hb_color_get_red (color);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_color_get_green:
|
||||
* @color: an #hb_color_t we are interested in its channels.
|
||||
*
|
||||
* Fetches the green channel of the given @color.
|
||||
*
|
||||
* Return value: Green channel value
|
||||
*
|
||||
* Since: 2.1.0
|
||||
*/
|
||||
uint8_t
|
||||
(hb_color_get_green) (hb_color_t color)
|
||||
{
|
||||
return hb_color_get_green (color);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_color_get_blue:
|
||||
* @color: an #hb_color_t we are interested in its channels.
|
||||
*
|
||||
* Fetches the blue channel of the given @color.
|
||||
*
|
||||
* Return value: Blue channel value
|
||||
*
|
||||
* Since: 2.1.0
|
||||
*/
|
||||
uint8_t
|
||||
(hb_color_get_blue) (hb_color_t color)
|
||||
{
|
||||
return hb_color_get_blue (color);
|
||||
}
|
||||
|
||||
|
||||
/* If there is no visibility control, then hb-static.cc will NOT
|
||||
* define anything. Instead, we get it to define one set in here
|
||||
* only, so only libharfbuzz.so defines them, not other libs. */
|
||||
#ifdef HB_NO_VISIBILITY
|
||||
#undef HB_NO_VISIBILITY
|
||||
#include "hb-static.cc"
|
||||
#define HB_NO_VISIBILITY 1
|
||||
#endif
|
||||
|
||||
+613
-155
@@ -26,13 +26,17 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_H_IN
|
||||
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb.h> instead."
|
||||
#endif
|
||||
|
||||
#ifndef HB_COMMON_H
|
||||
#define HB_COMMON_H
|
||||
|
||||
#ifndef HB_EXTERN
|
||||
#define HB_EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifndef HB_BEGIN_DECLS
|
||||
# ifdef __cplusplus
|
||||
# define HB_BEGIN_DECLS extern "C" {
|
||||
@@ -43,16 +47,14 @@
|
||||
# endif /* !__cplusplus */
|
||||
#endif
|
||||
|
||||
#if !defined (HB_DONT_DEFINE_STDINT)
|
||||
|
||||
#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || \
|
||||
defined (_sgi) || defined (__sun) || defined (sun) || \
|
||||
defined (__digital__) || defined (__HP_cc)
|
||||
# include <inttypes.h>
|
||||
#elif defined (_AIX)
|
||||
# include <sys/inttypes.h>
|
||||
/* VS 2010 (_MSC_VER 1600) has stdint.h */
|
||||
#elif defined (_MSC_VER) && _MSC_VER < 1600
|
||||
/* VS 2010 (_MSC_VER 1600) has stdint.h */
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
@@ -61,19 +63,62 @@ typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#elif defined (__KERNEL__)
|
||||
# include <linux/types.h>
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define HB_DEPRECATED __attribute__((__deprecated__))
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
#define HB_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define HB_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
#define HB_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
|
||||
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
|
||||
#define HB_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
|
||||
#else
|
||||
#define HB_DEPRECATED_FOR(f) HB_DEPRECATED
|
||||
#endif
|
||||
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* hb_bool_t:
|
||||
*
|
||||
* Data type for booleans.
|
||||
*
|
||||
**/
|
||||
typedef int hb_bool_t;
|
||||
|
||||
/**
|
||||
* hb_codepoint_t:
|
||||
*
|
||||
* Data type for holding Unicode codepoints. Also
|
||||
* used to hold glyph IDs.
|
||||
*
|
||||
**/
|
||||
typedef uint32_t hb_codepoint_t;
|
||||
/**
|
||||
* hb_position_t:
|
||||
*
|
||||
* Data type for holding a single coordinate value.
|
||||
* Contour points and other multi-dimensional data are
|
||||
* stored as tuples of #hb_position_t's.
|
||||
*
|
||||
**/
|
||||
typedef int32_t hb_position_t;
|
||||
/**
|
||||
* hb_mask_t:
|
||||
*
|
||||
* Data type for bitmasks.
|
||||
*
|
||||
**/
|
||||
typedef uint32_t hb_mask_t;
|
||||
|
||||
typedef union _hb_var_int_t {
|
||||
@@ -88,13 +133,63 @@ typedef union _hb_var_int_t {
|
||||
|
||||
/* hb_tag_t */
|
||||
|
||||
/**
|
||||
* hb_tag_t:
|
||||
*
|
||||
* Data type for tag identifiers. Tags are four
|
||||
* byte integers, each byte representing a character.
|
||||
*
|
||||
* Tags are used to identify tables, design-variation axes,
|
||||
* scripts, languages, font features, and baselines with
|
||||
* human-readable names.
|
||||
*
|
||||
**/
|
||||
typedef uint32_t hb_tag_t;
|
||||
|
||||
#define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4))))
|
||||
#define HB_UNTAG(tag) ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag))
|
||||
/**
|
||||
* HB_TAG:
|
||||
* @c1: 1st character of the tag
|
||||
* @c2: 2nd character of the tag
|
||||
* @c3: 3rd character of the tag
|
||||
* @c4: 4th character of the tag
|
||||
*
|
||||
* Constructs an #hb_tag_t from four character literals.
|
||||
*
|
||||
**/
|
||||
#define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint32_t)(c1)&0xFF)<<24)|(((uint32_t)(c2)&0xFF)<<16)|(((uint32_t)(c3)&0xFF)<<8)|((uint32_t)(c4)&0xFF)))
|
||||
|
||||
/**
|
||||
* HB_UNTAG:
|
||||
* @tag: an #hb_tag_t
|
||||
*
|
||||
* Extracts four character literals from an #hb_tag_t.
|
||||
*
|
||||
* Since: 0.6.0
|
||||
*
|
||||
**/
|
||||
#define HB_UNTAG(tag) (uint8_t)(((tag)>>24)&0xFF), (uint8_t)(((tag)>>16)&0xFF), (uint8_t)(((tag)>>8)&0xFF), (uint8_t)((tag)&0xFF)
|
||||
|
||||
/**
|
||||
* HB_TAG_NONE:
|
||||
*
|
||||
* Unset #hb_tag_t.
|
||||
*/
|
||||
#define HB_TAG_NONE HB_TAG(0,0,0,0)
|
||||
/**
|
||||
* HB_TAG_MAX:
|
||||
*
|
||||
* Maximum possible unsigned #hb_tag_t.
|
||||
*
|
||||
* Since: 0.9.26
|
||||
*/
|
||||
#define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff)
|
||||
/**
|
||||
* HB_TAG_MAX_SIGNED:
|
||||
*
|
||||
* Maximum possible signed #hb_tag_t.
|
||||
*
|
||||
* Since: 0.9.33
|
||||
*/
|
||||
#define HB_TAG_MAX_SIGNED HB_TAG(0x7f,0xff,0xff,0xff)
|
||||
|
||||
/* len=-1 means str is NUL-terminated. */
|
||||
@@ -113,6 +208,13 @@ hb_tag_to_string (hb_tag_t tag, char *buf);
|
||||
* @HB_DIRECTION_RTL: Text is set horizontally from right to left.
|
||||
* @HB_DIRECTION_TTB: Text is set vertically from top to bottom.
|
||||
* @HB_DIRECTION_BTT: Text is set vertically from bottom to top.
|
||||
*
|
||||
* The direction of a text segment or buffer.
|
||||
*
|
||||
* A segment can also be tested for horizontal or vertical
|
||||
* orientation (irrespective of specific direction) with
|
||||
* HB_DIRECTION_IS_HORIZONTAL() or HB_DIRECTION_IS_VERTICAL().
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
HB_DIRECTION_INVALID = 0,
|
||||
@@ -129,17 +231,71 @@ hb_direction_from_string (const char *str, int len);
|
||||
HB_EXTERN const char *
|
||||
hb_direction_to_string (hb_direction_t direction);
|
||||
|
||||
/**
|
||||
* HB_DIRECTION_IS_VALID:
|
||||
* @dir: #hb_direction_t to test
|
||||
*
|
||||
* Tests whether a text direction is valid.
|
||||
*
|
||||
**/
|
||||
#define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4)
|
||||
/* Direction must be valid for the following */
|
||||
/**
|
||||
* HB_DIRECTION_IS_HORIZONTAL:
|
||||
* @dir: #hb_direction_t to test
|
||||
*
|
||||
* Tests whether a text direction is horizontal. Requires
|
||||
* that the direction be valid.
|
||||
*
|
||||
**/
|
||||
#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4)
|
||||
/**
|
||||
* HB_DIRECTION_IS_VERTICAL:
|
||||
* @dir: #hb_direction_t to test
|
||||
*
|
||||
* Tests whether a text direction is vertical. Requires
|
||||
* that the direction be valid.
|
||||
*
|
||||
**/
|
||||
#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6)
|
||||
/**
|
||||
* HB_DIRECTION_IS_FORWARD:
|
||||
* @dir: #hb_direction_t to test
|
||||
*
|
||||
* Tests whether a text direction moves forward (from left to right, or from
|
||||
* top to bottom). Requires that the direction be valid.
|
||||
*
|
||||
**/
|
||||
#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4)
|
||||
/**
|
||||
* HB_DIRECTION_IS_BACKWARD:
|
||||
* @dir: #hb_direction_t to test
|
||||
*
|
||||
* Tests whether a text direction moves backward (from right to left, or from
|
||||
* bottom to top). Requires that the direction be valid.
|
||||
*
|
||||
**/
|
||||
#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5)
|
||||
/**
|
||||
* HB_DIRECTION_REVERSE:
|
||||
* @dir: #hb_direction_t to reverse
|
||||
*
|
||||
* Reverses a text direction. Requires that the direction
|
||||
* be valid.
|
||||
*
|
||||
**/
|
||||
#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
|
||||
|
||||
|
||||
/* hb_language_t */
|
||||
|
||||
/**
|
||||
* hb_language_t:
|
||||
*
|
||||
* Data type for languages. Each #hb_language_t corresponds to a BCP 47
|
||||
* language tag.
|
||||
*
|
||||
*/
|
||||
typedef const struct hb_language_impl_t *hb_language_t;
|
||||
|
||||
HB_EXTERN hb_language_t
|
||||
@@ -148,190 +304,400 @@ hb_language_from_string (const char *str, int len);
|
||||
HB_EXTERN const char *
|
||||
hb_language_to_string (hb_language_t language);
|
||||
|
||||
#define HB_LANGUAGE_INVALID ((hb_language_t) NULL)
|
||||
/**
|
||||
* HB_LANGUAGE_INVALID:
|
||||
*
|
||||
* An unset #hb_language_t.
|
||||
*
|
||||
* Since: 0.6.0
|
||||
*/
|
||||
#define HB_LANGUAGE_INVALID ((hb_language_t) 0)
|
||||
|
||||
HB_EXTERN hb_language_t
|
||||
hb_language_get_default (void);
|
||||
|
||||
|
||||
/* hb_script_t */
|
||||
/**
|
||||
* hb_script_t:
|
||||
* @HB_SCRIPT_COMMON: `Zyyy`
|
||||
* @HB_SCRIPT_INHERITED: `Zinh`
|
||||
* @HB_SCRIPT_UNKNOWN: `Zzzz`
|
||||
* @HB_SCRIPT_ARABIC: `Arab`
|
||||
* @HB_SCRIPT_ARMENIAN: `Armn`
|
||||
* @HB_SCRIPT_BENGALI: `Beng`
|
||||
* @HB_SCRIPT_CYRILLIC: `Cyrl`
|
||||
* @HB_SCRIPT_DEVANAGARI: `Deva`
|
||||
* @HB_SCRIPT_GEORGIAN: `Geor`
|
||||
* @HB_SCRIPT_GREEK: `Grek`
|
||||
* @HB_SCRIPT_GUJARATI: `Gujr`
|
||||
* @HB_SCRIPT_GURMUKHI: `Guru`
|
||||
* @HB_SCRIPT_HANGUL: `Hang`
|
||||
* @HB_SCRIPT_HAN: `Hani`
|
||||
* @HB_SCRIPT_HEBREW: `Hebr`
|
||||
* @HB_SCRIPT_HIRAGANA: `Hira`
|
||||
* @HB_SCRIPT_KANNADA: `Knda`
|
||||
* @HB_SCRIPT_KATAKANA: `Kana`
|
||||
* @HB_SCRIPT_LAO: `Laoo`
|
||||
* @HB_SCRIPT_LATIN: `Latn`
|
||||
* @HB_SCRIPT_MALAYALAM: `Mlym`
|
||||
* @HB_SCRIPT_ORIYA: `Orya`
|
||||
* @HB_SCRIPT_TAMIL: `Taml`
|
||||
* @HB_SCRIPT_TELUGU: `Telu`
|
||||
* @HB_SCRIPT_THAI: `Thai`
|
||||
* @HB_SCRIPT_TIBETAN: `Tibt`
|
||||
* @HB_SCRIPT_BOPOMOFO: `Bopo`
|
||||
* @HB_SCRIPT_BRAILLE: `Brai`
|
||||
* @HB_SCRIPT_CANADIAN_SYLLABICS: `Cans`
|
||||
* @HB_SCRIPT_CHEROKEE: `Cher`
|
||||
* @HB_SCRIPT_ETHIOPIC: `Ethi`
|
||||
* @HB_SCRIPT_KHMER: `Khmr`
|
||||
* @HB_SCRIPT_MONGOLIAN: `Mong`
|
||||
* @HB_SCRIPT_MYANMAR: `Mymr`
|
||||
* @HB_SCRIPT_OGHAM: `Ogam`
|
||||
* @HB_SCRIPT_RUNIC: `Runr`
|
||||
* @HB_SCRIPT_SINHALA: `Sinh`
|
||||
* @HB_SCRIPT_SYRIAC: `Syrc`
|
||||
* @HB_SCRIPT_THAANA: `Thaa`
|
||||
* @HB_SCRIPT_YI: `Yiii`
|
||||
* @HB_SCRIPT_DESERET: `Dsrt`
|
||||
* @HB_SCRIPT_GOTHIC: `Goth`
|
||||
* @HB_SCRIPT_OLD_ITALIC: `Ital`
|
||||
* @HB_SCRIPT_BUHID: `Buhd`
|
||||
* @HB_SCRIPT_HANUNOO: `Hano`
|
||||
* @HB_SCRIPT_TAGALOG: `Tglg`
|
||||
* @HB_SCRIPT_TAGBANWA: `Tagb`
|
||||
* @HB_SCRIPT_CYPRIOT: `Cprt`
|
||||
* @HB_SCRIPT_LIMBU: `Limb`
|
||||
* @HB_SCRIPT_LINEAR_B: `Linb`
|
||||
* @HB_SCRIPT_OSMANYA: `Osma`
|
||||
* @HB_SCRIPT_SHAVIAN: `Shaw`
|
||||
* @HB_SCRIPT_TAI_LE: `Tale`
|
||||
* @HB_SCRIPT_UGARITIC: `Ugar`
|
||||
* @HB_SCRIPT_BUGINESE: `Bugi`
|
||||
* @HB_SCRIPT_COPTIC: `Copt`
|
||||
* @HB_SCRIPT_GLAGOLITIC: `Glag`
|
||||
* @HB_SCRIPT_KHAROSHTHI: `Khar`
|
||||
* @HB_SCRIPT_NEW_TAI_LUE: `Talu`
|
||||
* @HB_SCRIPT_OLD_PERSIAN: `Xpeo`
|
||||
* @HB_SCRIPT_SYLOTI_NAGRI: `Sylo`
|
||||
* @HB_SCRIPT_TIFINAGH: `Tfng`
|
||||
* @HB_SCRIPT_BALINESE: `Bali`
|
||||
* @HB_SCRIPT_CUNEIFORM: `Xsux`
|
||||
* @HB_SCRIPT_NKO: `Nkoo`
|
||||
* @HB_SCRIPT_PHAGS_PA: `Phag`
|
||||
* @HB_SCRIPT_PHOENICIAN: `Phnx`
|
||||
* @HB_SCRIPT_CARIAN: `Cari`
|
||||
* @HB_SCRIPT_CHAM: `Cham`
|
||||
* @HB_SCRIPT_KAYAH_LI: `Kali`
|
||||
* @HB_SCRIPT_LEPCHA: `Lepc`
|
||||
* @HB_SCRIPT_LYCIAN: `Lyci`
|
||||
* @HB_SCRIPT_LYDIAN: `Lydi`
|
||||
* @HB_SCRIPT_OL_CHIKI: `Olck`
|
||||
* @HB_SCRIPT_REJANG: `Rjng`
|
||||
* @HB_SCRIPT_SAURASHTRA: `Saur`
|
||||
* @HB_SCRIPT_SUNDANESE: `Sund`
|
||||
* @HB_SCRIPT_VAI: `Vaii`
|
||||
* @HB_SCRIPT_AVESTAN: `Avst`
|
||||
* @HB_SCRIPT_BAMUM: `Bamu`
|
||||
* @HB_SCRIPT_EGYPTIAN_HIEROGLYPHS: `Egyp`
|
||||
* @HB_SCRIPT_IMPERIAL_ARAMAIC: `Armi`
|
||||
* @HB_SCRIPT_INSCRIPTIONAL_PAHLAVI: `Phli`
|
||||
* @HB_SCRIPT_INSCRIPTIONAL_PARTHIAN: `Prti`
|
||||
* @HB_SCRIPT_JAVANESE: `Java`
|
||||
* @HB_SCRIPT_KAITHI: `Kthi`
|
||||
* @HB_SCRIPT_LISU: `Lisu`
|
||||
* @HB_SCRIPT_MEETEI_MAYEK: `Mtei`
|
||||
* @HB_SCRIPT_OLD_SOUTH_ARABIAN: `Sarb`
|
||||
* @HB_SCRIPT_OLD_TURKIC: `Orkh`
|
||||
* @HB_SCRIPT_SAMARITAN: `Samr`
|
||||
* @HB_SCRIPT_TAI_THAM: `Lana`
|
||||
* @HB_SCRIPT_TAI_VIET: `Tavt`
|
||||
* @HB_SCRIPT_BATAK: `Batk`
|
||||
* @HB_SCRIPT_BRAHMI: `Brah`
|
||||
* @HB_SCRIPT_MANDAIC: `Mand`
|
||||
* @HB_SCRIPT_CHAKMA: `Cakm`
|
||||
* @HB_SCRIPT_MEROITIC_CURSIVE: `Merc`
|
||||
* @HB_SCRIPT_MEROITIC_HIEROGLYPHS: `Mero`
|
||||
* @HB_SCRIPT_MIAO: `Plrd`
|
||||
* @HB_SCRIPT_SHARADA: `Shrd`
|
||||
* @HB_SCRIPT_SORA_SOMPENG: `Sora`
|
||||
* @HB_SCRIPT_TAKRI: `Takr`
|
||||
* @HB_SCRIPT_BASSA_VAH: `Bass`, Since: 0.9.30
|
||||
* @HB_SCRIPT_CAUCASIAN_ALBANIAN: `Aghb`, Since: 0.9.30
|
||||
* @HB_SCRIPT_DUPLOYAN: `Dupl`, Since: 0.9.30
|
||||
* @HB_SCRIPT_ELBASAN: `Elba`, Since: 0.9.30
|
||||
* @HB_SCRIPT_GRANTHA: `Gran`, Since: 0.9.30
|
||||
* @HB_SCRIPT_KHOJKI: `Khoj`, Since: 0.9.30
|
||||
* @HB_SCRIPT_KHUDAWADI: `Sind`, Since: 0.9.30
|
||||
* @HB_SCRIPT_LINEAR_A: `Lina`, Since: 0.9.30
|
||||
* @HB_SCRIPT_MAHAJANI: `Mahj`, Since: 0.9.30
|
||||
* @HB_SCRIPT_MANICHAEAN: `Mani`, Since: 0.9.30
|
||||
* @HB_SCRIPT_MENDE_KIKAKUI: `Mend`, Since: 0.9.30
|
||||
* @HB_SCRIPT_MODI: `Modi`, Since: 0.9.30
|
||||
* @HB_SCRIPT_MRO: `Mroo`, Since: 0.9.30
|
||||
* @HB_SCRIPT_NABATAEAN: `Nbat`, Since: 0.9.30
|
||||
* @HB_SCRIPT_OLD_NORTH_ARABIAN: `Narb`, Since: 0.9.30
|
||||
* @HB_SCRIPT_OLD_PERMIC: `Perm`, Since: 0.9.30
|
||||
* @HB_SCRIPT_PAHAWH_HMONG: `Hmng`, Since: 0.9.30
|
||||
* @HB_SCRIPT_PALMYRENE: `Palm`, Since: 0.9.30
|
||||
* @HB_SCRIPT_PAU_CIN_HAU: `Pauc`, Since: 0.9.30
|
||||
* @HB_SCRIPT_PSALTER_PAHLAVI: `Phlp`, Since: 0.9.30
|
||||
* @HB_SCRIPT_SIDDHAM: `Sidd`, Since: 0.9.30
|
||||
* @HB_SCRIPT_TIRHUTA: `Tirh`, Since: 0.9.30
|
||||
* @HB_SCRIPT_WARANG_CITI: `Wara`, Since: 0.9.30
|
||||
* @HB_SCRIPT_AHOM: `Ahom`, Since: 0.9.30
|
||||
* @HB_SCRIPT_ANATOLIAN_HIEROGLYPHS: `Hluw`, Since: 0.9.30
|
||||
* @HB_SCRIPT_HATRAN: `Hatr`, Since: 0.9.30
|
||||
* @HB_SCRIPT_MULTANI: `Mult`, Since: 0.9.30
|
||||
* @HB_SCRIPT_OLD_HUNGARIAN: `Hung`, Since: 0.9.30
|
||||
* @HB_SCRIPT_SIGNWRITING: `Sgnw`, Since: 0.9.30
|
||||
* @HB_SCRIPT_ADLAM: `Adlm`, Since: 1.3.0
|
||||
* @HB_SCRIPT_BHAIKSUKI: `Bhks`, Since: 1.3.0
|
||||
* @HB_SCRIPT_MARCHEN: `Marc`, Since: 1.3.0
|
||||
* @HB_SCRIPT_OSAGE: `Osge`, Since: 1.3.0
|
||||
* @HB_SCRIPT_TANGUT: `Tang`, Since: 1.3.0
|
||||
* @HB_SCRIPT_NEWA: `Newa`, Since: 1.3.0
|
||||
* @HB_SCRIPT_MASARAM_GONDI: `Gonm`, Since: 1.6.0
|
||||
* @HB_SCRIPT_NUSHU: `Nshu`, Since: 1.6.0
|
||||
* @HB_SCRIPT_SOYOMBO: `Soyo`, Since: 1.6.0
|
||||
* @HB_SCRIPT_ZANABAZAR_SQUARE: `Zanb`, Since: 1.6.0
|
||||
* @HB_SCRIPT_DOGRA: `Dogr`, Since: 1.8.0
|
||||
* @HB_SCRIPT_GUNJALA_GONDI: `Gong`, Since: 1.8.0
|
||||
* @HB_SCRIPT_HANIFI_ROHINGYA: `Rohg`, Since: 1.8.0
|
||||
* @HB_SCRIPT_MAKASAR: `Maka`, Since: 1.8.0
|
||||
* @HB_SCRIPT_MEDEFAIDRIN: `Medf`, Since: 1.8.0
|
||||
* @HB_SCRIPT_OLD_SOGDIAN: `Sogo`, Since: 1.8.0
|
||||
* @HB_SCRIPT_SOGDIAN: `Sogd`, Since: 1.8.0
|
||||
* @HB_SCRIPT_ELYMAIC: `Elym`, Since: 2.4.0
|
||||
* @HB_SCRIPT_NANDINAGARI: `Nand`, Since: 2.4.0
|
||||
* @HB_SCRIPT_NYIAKENG_PUACHUE_HMONG: `Hmnp`, Since: 2.4.0
|
||||
* @HB_SCRIPT_WANCHO: `Wcho`, Since: 2.4.0
|
||||
* @HB_SCRIPT_CHORASMIAN: `Chrs`, Since: 2.6.7
|
||||
* @HB_SCRIPT_DIVES_AKURU: `Diak`, Since: 2.6.7
|
||||
* @HB_SCRIPT_KHITAN_SMALL_SCRIPT: `Kits`, Since: 2.6.7
|
||||
* @HB_SCRIPT_YEZIDI: `Yezi`, Since: 2.6.7
|
||||
* @HB_SCRIPT_INVALID: No script set
|
||||
*
|
||||
* Data type for scripts. Each #hb_script_t's value is an #hb_tag_t corresponding
|
||||
* to the four-letter values defined by [ISO 15924](https://unicode.org/iso15924/).
|
||||
*
|
||||
* See also the Script (sc) property of the Unicode Character Database.
|
||||
*
|
||||
**/
|
||||
|
||||
/* http://unicode.org/iso15924/ */
|
||||
/* http://goo.gl/x9ilM */
|
||||
/* Unicode Character Database property: Script (sc) */
|
||||
/* https://docs.google.com/spreadsheets/d/1Y90M0Ie3MUJ6UVCRDOypOtijlMDLNNyyLk36T6iMu0o */
|
||||
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'),
|
||||
HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'), /*1.1*/
|
||||
HB_SCRIPT_INHERITED = HB_TAG ('Z','i','n','h'), /*1.1*/
|
||||
HB_SCRIPT_UNKNOWN = HB_TAG ('Z','z','z','z'), /*5.0*/
|
||||
|
||||
/*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'),
|
||||
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'), /*1.1*/
|
||||
|
||||
/*2.0*/ HB_SCRIPT_TIBETAN = HB_TAG ('T','i','b','t'),
|
||||
HB_SCRIPT_TIBETAN = HB_TAG ('T','i','b','t'), /*2.0*/
|
||||
|
||||
/*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'),
|
||||
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'), /*3.0*/
|
||||
|
||||
/*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'),
|
||||
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'), /*3.1*/
|
||||
|
||||
/*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'),
|
||||
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'), /*3.2*/
|
||||
|
||||
/*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'),
|
||||
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'), /*4.0*/
|
||||
|
||||
/*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'),
|
||||
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'), /*4.1*/
|
||||
|
||||
/*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'),
|
||||
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'), /*5.0*/
|
||||
|
||||
/*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'),
|
||||
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'), /*5.1*/
|
||||
|
||||
/*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'),
|
||||
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'), /*5.2*/
|
||||
|
||||
/*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'),
|
||||
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'), /*6.0*/
|
||||
|
||||
/*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'),
|
||||
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'), /*6.1*/
|
||||
|
||||
/*
|
||||
* Since: 0.9.30
|
||||
*/
|
||||
/*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 = HB_TAG ('M','o','d','i'),
|
||||
/*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 = HB_TAG ('P','a','u','c'),
|
||||
/*7.0*/ HB_SCRIPT_PSALTER_PAHLAVI = HB_TAG ('P','h','l','p'),
|
||||
/*7.0*/ HB_SCRIPT_SIDDHAM = HB_TAG ('S','i','d','d'),
|
||||
/*7.0*/ HB_SCRIPT_TIRHUTA = HB_TAG ('T','i','r','h'),
|
||||
/*7.0*/ HB_SCRIPT_WARANG_CITI = HB_TAG ('W','a','r','a'),
|
||||
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 = HB_TAG ('M','o','d','i'), /*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 = HB_TAG ('P','a','u','c'), /*7.0*/
|
||||
HB_SCRIPT_PSALTER_PAHLAVI = HB_TAG ('P','h','l','p'), /*7.0*/
|
||||
HB_SCRIPT_SIDDHAM = HB_TAG ('S','i','d','d'), /*7.0*/
|
||||
HB_SCRIPT_TIRHUTA = HB_TAG ('T','i','r','h'), /*7.0*/
|
||||
HB_SCRIPT_WARANG_CITI = HB_TAG ('W','a','r','a'), /*7.0*/
|
||||
|
||||
/*8.0*/ HB_SCRIPT_AHOM = HB_TAG ('A','h','o','m'),
|
||||
/*8.0*/ HB_SCRIPT_ANATOLIAN_HIEROGLYPHS = HB_TAG ('H','l','u','w'),
|
||||
/*8.0*/ HB_SCRIPT_HATRAN = HB_TAG ('H','a','t','r'),
|
||||
/*8.0*/ HB_SCRIPT_MULTANI = HB_TAG ('M','u','l','t'),
|
||||
/*8.0*/ HB_SCRIPT_OLD_HUNGARIAN = HB_TAG ('H','u','n','g'),
|
||||
/*8.0*/ HB_SCRIPT_SIGNWRITING = HB_TAG ('S','g','n','w'),
|
||||
HB_SCRIPT_AHOM = HB_TAG ('A','h','o','m'), /*8.0*/
|
||||
HB_SCRIPT_ANATOLIAN_HIEROGLYPHS = HB_TAG ('H','l','u','w'), /*8.0*/
|
||||
HB_SCRIPT_HATRAN = HB_TAG ('H','a','t','r'), /*8.0*/
|
||||
HB_SCRIPT_MULTANI = HB_TAG ('M','u','l','t'), /*8.0*/
|
||||
HB_SCRIPT_OLD_HUNGARIAN = HB_TAG ('H','u','n','g'), /*8.0*/
|
||||
HB_SCRIPT_SIGNWRITING = HB_TAG ('S','g','n','w'), /*8.0*/
|
||||
|
||||
/*
|
||||
* Since 1.3.0
|
||||
*/
|
||||
/*9.0*/ HB_SCRIPT_ADLAM = HB_TAG ('A','d','l','m'),
|
||||
/*9.0*/ HB_SCRIPT_BHAIKSUKI = HB_TAG ('B','h','k','s'),
|
||||
/*9.0*/ HB_SCRIPT_MARCHEN = HB_TAG ('M','a','r','c'),
|
||||
/*9.0*/ HB_SCRIPT_OSAGE = HB_TAG ('O','s','g','e'),
|
||||
/*9.0*/ HB_SCRIPT_TANGUT = HB_TAG ('T','a','n','g'),
|
||||
/*9.0*/ HB_SCRIPT_NEWA = HB_TAG ('N','e','w','a'),
|
||||
HB_SCRIPT_ADLAM = HB_TAG ('A','d','l','m'), /*9.0*/
|
||||
HB_SCRIPT_BHAIKSUKI = HB_TAG ('B','h','k','s'), /*9.0*/
|
||||
HB_SCRIPT_MARCHEN = HB_TAG ('M','a','r','c'), /*9.0*/
|
||||
HB_SCRIPT_OSAGE = HB_TAG ('O','s','g','e'), /*9.0*/
|
||||
HB_SCRIPT_TANGUT = HB_TAG ('T','a','n','g'), /*9.0*/
|
||||
HB_SCRIPT_NEWA = HB_TAG ('N','e','w','a'), /*9.0*/
|
||||
|
||||
/*
|
||||
* Since 1.6.0
|
||||
*/
|
||||
HB_SCRIPT_MASARAM_GONDI = HB_TAG ('G','o','n','m'), /*10.0*/
|
||||
HB_SCRIPT_NUSHU = HB_TAG ('N','s','h','u'), /*10.0*/
|
||||
HB_SCRIPT_SOYOMBO = HB_TAG ('S','o','y','o'), /*10.0*/
|
||||
HB_SCRIPT_ZANABAZAR_SQUARE = HB_TAG ('Z','a','n','b'), /*10.0*/
|
||||
|
||||
/*
|
||||
* Since 1.8.0
|
||||
*/
|
||||
HB_SCRIPT_DOGRA = HB_TAG ('D','o','g','r'), /*11.0*/
|
||||
HB_SCRIPT_GUNJALA_GONDI = HB_TAG ('G','o','n','g'), /*11.0*/
|
||||
HB_SCRIPT_HANIFI_ROHINGYA = HB_TAG ('R','o','h','g'), /*11.0*/
|
||||
HB_SCRIPT_MAKASAR = HB_TAG ('M','a','k','a'), /*11.0*/
|
||||
HB_SCRIPT_MEDEFAIDRIN = HB_TAG ('M','e','d','f'), /*11.0*/
|
||||
HB_SCRIPT_OLD_SOGDIAN = HB_TAG ('S','o','g','o'), /*11.0*/
|
||||
HB_SCRIPT_SOGDIAN = HB_TAG ('S','o','g','d'), /*11.0*/
|
||||
|
||||
/*
|
||||
* Since 2.4.0
|
||||
*/
|
||||
HB_SCRIPT_ELYMAIC = HB_TAG ('E','l','y','m'), /*12.0*/
|
||||
HB_SCRIPT_NANDINAGARI = HB_TAG ('N','a','n','d'), /*12.0*/
|
||||
HB_SCRIPT_NYIAKENG_PUACHUE_HMONG = HB_TAG ('H','m','n','p'), /*12.0*/
|
||||
HB_SCRIPT_WANCHO = HB_TAG ('W','c','h','o'), /*12.0*/
|
||||
|
||||
/*
|
||||
* Since 2.6.7
|
||||
*/
|
||||
HB_SCRIPT_CHORASMIAN = HB_TAG ('C','h','r','s'), /*13.0*/
|
||||
HB_SCRIPT_DIVES_AKURU = HB_TAG ('D','i','a','k'), /*13.0*/
|
||||
HB_SCRIPT_KHITAN_SMALL_SCRIPT = HB_TAG ('K','i','t','s'), /*13.0*/
|
||||
HB_SCRIPT_YEZIDI = HB_TAG ('Y','e','z','i'), /*13.0*/
|
||||
|
||||
/* No script set. */
|
||||
HB_SCRIPT_INVALID = HB_TAG_NONE,
|
||||
HB_SCRIPT_INVALID = HB_TAG_NONE,
|
||||
|
||||
/*< private >*/
|
||||
|
||||
/* Dummy values to ensure any hb_tag_t value can be passed/stored as hb_script_t
|
||||
* without risking undefined behavior. Include both a signed and unsigned max,
|
||||
* since technically enums are int, and indeed, hb_script_t ends up being signed.
|
||||
* without risking undefined behavior. We have two, for historical reasons.
|
||||
* HB_TAG_MAX used to be unsigned, but that was invalid Ansi C, so was changed
|
||||
* to _HB_SCRIPT_MAX_VALUE to be equal to HB_TAG_MAX_SIGNED as well.
|
||||
*
|
||||
* See this thread for technicalities:
|
||||
*
|
||||
* http://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
|
||||
* https://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
|
||||
*/
|
||||
_HB_SCRIPT_MAX_VALUE = HB_TAG_MAX, /*< skip >*/
|
||||
_HB_SCRIPT_MAX_VALUE = HB_TAG_MAX_SIGNED, /*< skip >*/
|
||||
_HB_SCRIPT_MAX_VALUE_SIGNED = HB_TAG_MAX_SIGNED /*< skip >*/
|
||||
|
||||
} hb_script_t;
|
||||
@@ -354,16 +720,64 @@ hb_script_get_horizontal_direction (hb_script_t script);
|
||||
|
||||
/* User data */
|
||||
|
||||
/**
|
||||
* hb_user_data_key_t:
|
||||
*
|
||||
* Data structure for holding user-data keys.
|
||||
*
|
||||
**/
|
||||
typedef struct hb_user_data_key_t {
|
||||
/*< private >*/
|
||||
char unused;
|
||||
} hb_user_data_key_t;
|
||||
|
||||
/**
|
||||
* hb_destroy_func_t:
|
||||
* @user_data: the data to be destroyed
|
||||
*
|
||||
* A virtual method for destroy user-data callbacks.
|
||||
*
|
||||
*/
|
||||
typedef void (*hb_destroy_func_t) (void *user_data);
|
||||
|
||||
|
||||
/* Font features and variations. */
|
||||
|
||||
/**
|
||||
* HB_FEATURE_GLOBAL_START:
|
||||
*
|
||||
* Special setting for #hb_feature_t.start to apply the feature from the start
|
||||
* of the buffer.
|
||||
*
|
||||
* Since: 2.0.0
|
||||
*/
|
||||
#define HB_FEATURE_GLOBAL_START 0
|
||||
|
||||
/**
|
||||
* HB_FEATURE_GLOBAL_END:
|
||||
*
|
||||
* Special setting for #hb_feature_t.end to apply the feature from to the end
|
||||
* of the buffer.
|
||||
*
|
||||
* Since: 2.0.0
|
||||
*/
|
||||
#define HB_FEATURE_GLOBAL_END ((unsigned int) -1)
|
||||
|
||||
/**
|
||||
* hb_feature_t:
|
||||
* @tag: The #hb_tag_t tag of the feature
|
||||
* @value: The value of the feature. 0 disables the feature, non-zero (usually
|
||||
* 1) enables the feature. For features implemented as lookup type 3 (like
|
||||
* 'salt') the @value is a one based index into the alternates.
|
||||
* @start: the cluster to start applying this feature setting (inclusive).
|
||||
* @end: the cluster to end applying this feature setting (exclusive).
|
||||
*
|
||||
* The #hb_feature_t is the structure that holds information about requested
|
||||
* feature application. The feature will be applied with the given value to all
|
||||
* glyphs which are in clusters between @start (inclusive) and @end (exclusive).
|
||||
* Setting start to #HB_FEATURE_GLOBAL_START and end to #HB_FEATURE_GLOBAL_END
|
||||
* specifies that the feature always applies to the entire buffer.
|
||||
*/
|
||||
typedef struct hb_feature_t {
|
||||
hb_tag_t tag;
|
||||
uint32_t value;
|
||||
@@ -381,7 +795,13 @@ hb_feature_to_string (hb_feature_t *feature,
|
||||
|
||||
/**
|
||||
* hb_variation_t:
|
||||
* @tag: The #hb_tag_t tag of the variation-axis name
|
||||
* @value: The value of the variation axis
|
||||
*
|
||||
* Data type for holding variation data. Registered OpenType
|
||||
* variation-axis tags are listed in
|
||||
* [OpenType Axis Tag Registry](https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg).
|
||||
*
|
||||
* Since: 1.4.2
|
||||
*/
|
||||
typedef struct hb_variation_t {
|
||||
@@ -397,6 +817,44 @@ HB_EXTERN void
|
||||
hb_variation_to_string (hb_variation_t *variation,
|
||||
char *buf, unsigned int size);
|
||||
|
||||
/**
|
||||
* hb_color_t:
|
||||
*
|
||||
* Data type for holding color values. Colors are eight bits per
|
||||
* channel RGB plus alpha transparency.
|
||||
*
|
||||
* Since: 2.1.0
|
||||
*/
|
||||
typedef uint32_t hb_color_t;
|
||||
|
||||
/**
|
||||
* HB_COLOR:
|
||||
* @b: blue channel value
|
||||
* @g: green channel value
|
||||
* @r: red channel value
|
||||
* @a: alpha channel value
|
||||
*
|
||||
* Constructs an #hb_color_t from four integers.
|
||||
*
|
||||
* Since: 2.1.0
|
||||
*/
|
||||
#define HB_COLOR(b,g,r,a) ((hb_color_t) HB_TAG ((b),(g),(r),(a)))
|
||||
|
||||
HB_EXTERN uint8_t
|
||||
hb_color_get_alpha (hb_color_t color);
|
||||
#define hb_color_get_alpha(color) ((color) & 0xFF)
|
||||
|
||||
HB_EXTERN uint8_t
|
||||
hb_color_get_red (hb_color_t color);
|
||||
#define hb_color_get_red(color) (((color) >> 8) & 0xFF)
|
||||
|
||||
HB_EXTERN uint8_t
|
||||
hb_color_get_green (hb_color_t color);
|
||||
#define hb_color_get_green(color) (((color) >> 16) & 0xFF)
|
||||
|
||||
HB_EXTERN uint8_t
|
||||
hb_color_get_blue (hb_color_t color);
|
||||
#define hb_color_get_blue(color) (((color) >> 24) & 0xFF)
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright © 2019 Facebook, 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.
|
||||
*
|
||||
* Facebook Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_CONFIG_HH
|
||||
#define HB_CONFIG_HH
|
||||
|
||||
#if 0 /* Make test happy. */
|
||||
#include "hb.hh"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HB_TINY
|
||||
#define HB_LEAN
|
||||
#define HB_MINI
|
||||
#define HB_NO_MT
|
||||
#define HB_NO_UCD_UNASSIGNED
|
||||
#ifndef NDEBUG
|
||||
#define NDEBUG
|
||||
#endif
|
||||
#ifndef __OPTIMIZE_SIZE__
|
||||
#define __OPTIMIZE_SIZE__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HB_LEAN
|
||||
#define HB_DISABLE_DEPRECATED
|
||||
#define HB_NDEBUG
|
||||
#define HB_NO_ATEXIT
|
||||
#define HB_NO_BUFFER_MESSAGE
|
||||
#define HB_NO_BUFFER_SERIALIZE
|
||||
#define HB_NO_BITMAP
|
||||
#define HB_NO_CFF
|
||||
#define HB_NO_COLOR
|
||||
#define HB_NO_DRAW
|
||||
#define HB_NO_ERRNO
|
||||
#define HB_NO_FACE_COLLECT_UNICODES
|
||||
#define HB_NO_GETENV
|
||||
#define HB_NO_HINTING
|
||||
#define HB_NO_LANGUAGE_PRIVATE_SUBTAG
|
||||
#define HB_NO_LAYOUT_FEATURE_PARAMS
|
||||
#define HB_NO_LAYOUT_COLLECT_GLYPHS
|
||||
#define HB_NO_LAYOUT_UNUSED
|
||||
#define HB_NO_MATH
|
||||
#define HB_NO_META
|
||||
#define HB_NO_METRICS
|
||||
#define HB_NO_MMAP
|
||||
#define HB_NO_NAME
|
||||
#define HB_NO_OPEN
|
||||
#define HB_NO_SETLOCALE
|
||||
#define HB_NO_OT_FONT_GLYPH_NAMES
|
||||
#define HB_NO_OT_SHAPE_FRACTIONS
|
||||
#define HB_NO_STYLE
|
||||
#define HB_NO_SUBSET_LAYOUT
|
||||
#define HB_NO_VAR
|
||||
#endif
|
||||
|
||||
#ifdef HB_MINI
|
||||
#define HB_NO_AAT
|
||||
#define HB_NO_LEGACY
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_OVERRIDE_H
|
||||
#include "config-override.h"
|
||||
#endif
|
||||
|
||||
/* Closure of options. */
|
||||
|
||||
#ifdef HB_DISABLE_DEPRECATED
|
||||
#define HB_IF_NOT_DEPRECATED(x)
|
||||
#else
|
||||
#define HB_IF_NOT_DEPRECATED(x) x
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_AAT
|
||||
#define HB_NO_OT_NAME_LANGUAGE_AAT
|
||||
#define HB_NO_AAT_SHAPE
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_BITMAP
|
||||
#define HB_NO_OT_FONT_BITMAP
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_CFF
|
||||
#define HB_NO_OT_FONT_CFF
|
||||
#define HB_NO_SUBSET_CFF
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_GETENV
|
||||
#define HB_NO_UNISCRIBE_BUG_COMPATIBLE
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_LEGACY
|
||||
#define HB_NO_CMAP_LEGACY_SUBTABLES
|
||||
#define HB_NO_FALLBACK_SHAPE
|
||||
#define HB_NO_OT_KERN
|
||||
#define HB_NO_OT_LAYOUT_BLOCKLIST
|
||||
#define HB_NO_OT_SHAPE_FALLBACK
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_NAME
|
||||
#define HB_NO_OT_NAME_LANGUAGE
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_OT
|
||||
#define HB_NO_OT_FONT
|
||||
#define HB_NO_OT_LAYOUT
|
||||
#define HB_NO_OT_TAG
|
||||
#define HB_NO_OT_SHAPE
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_OT_SHAPE
|
||||
#define HB_NO_AAT_SHAPE
|
||||
#endif
|
||||
|
||||
#ifdef HB_NO_OT_SHAPE_FALLBACK
|
||||
#define HB_NO_OT_SHAPE_COMPLEX_ARABIC_FALLBACK
|
||||
#define HB_NO_OT_SHAPE_COMPLEX_HEBREW_FALLBACK
|
||||
#define HB_NO_OT_SHAPE_COMPLEX_THAI_FALLBACK
|
||||
#define HB_NO_OT_SHAPE_COMPLEX_VOWEL_CONSTRAINTS
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#ifndef HB_NDEBUG
|
||||
#define HB_NDEBUG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __OPTIMIZE_SIZE__
|
||||
#ifndef HB_OPTIMIZE_SIZE
|
||||
#define HB_OPTIMIZE_SIZE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* HB_CONFIG_HH */
|
||||
+335
-481
File diff suppressed because it is too large
Load Diff
@@ -40,13 +40,49 @@
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* HB_CORETEXT_TAG_MORT:
|
||||
*
|
||||
* The #hb_tag_t tag for the `mort` (glyph metamorphosis) table,
|
||||
* which holds AAT features.
|
||||
*
|
||||
* For more information, see
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6mort.html
|
||||
*
|
||||
**/
|
||||
#define HB_CORETEXT_TAG_MORT HB_TAG('m','o','r','t')
|
||||
|
||||
/**
|
||||
* HB_CORETEXT_TAG_MORX:
|
||||
*
|
||||
* The #hb_tag_t tag for the `morx` (extended glyph metamorphosis)
|
||||
* table, which holds AAT features.
|
||||
*
|
||||
* For more information, see
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html
|
||||
*
|
||||
**/
|
||||
#define HB_CORETEXT_TAG_MORX HB_TAG('m','o','r','x')
|
||||
|
||||
/**
|
||||
* HB_CORETEXT_TAG_KERX:
|
||||
*
|
||||
* The #hb_tag_t tag for the `kerx` (extended kerning) table, which
|
||||
* holds AAT kerning information.
|
||||
*
|
||||
* For more information, see
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kerx.html
|
||||
*
|
||||
**/
|
||||
#define HB_CORETEXT_TAG_KERX HB_TAG('k','e','r','x')
|
||||
|
||||
|
||||
HB_EXTERN hb_face_t *
|
||||
hb_coretext_face_create (CGFontRef cg_font);
|
||||
|
||||
HB_EXTERN hb_font_t *
|
||||
hb_coretext_font_create (CTFontRef ct_font);
|
||||
|
||||
|
||||
HB_EXTERN CGFontRef
|
||||
hb_coretext_face_get_cg_font (hb_face_t *face);
|
||||
|
||||
@@ -0,0 +1,463 @@
|
||||
/*
|
||||
* Copyright © 2017 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_DEBUG_HH
|
||||
#define HB_DEBUG_HH
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-atomic.hh"
|
||||
#include "hb-algs.hh"
|
||||
|
||||
|
||||
#ifndef HB_DEBUG
|
||||
#define HB_DEBUG 0
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Global runtime options.
|
||||
*/
|
||||
|
||||
struct hb_options_t
|
||||
{
|
||||
bool unused : 1; /* In-case sign bit is here. */
|
||||
bool initialized : 1;
|
||||
bool uniscribe_bug_compatible : 1;
|
||||
};
|
||||
|
||||
union hb_options_union_t {
|
||||
int i;
|
||||
hb_options_t opts;
|
||||
};
|
||||
static_assert ((sizeof (hb_atomic_int_t) >= sizeof (hb_options_union_t)), "");
|
||||
|
||||
HB_INTERNAL void
|
||||
_hb_options_init ();
|
||||
|
||||
extern HB_INTERNAL hb_atomic_int_t _hb_options;
|
||||
|
||||
static inline hb_options_t
|
||||
hb_options ()
|
||||
{
|
||||
#ifdef HB_NO_GETENV
|
||||
return hb_options_t ();
|
||||
#endif
|
||||
/* Make a local copy, so we can access bitfield threadsafely. */
|
||||
hb_options_union_t u;
|
||||
u.i = _hb_options.get_relaxed ();
|
||||
|
||||
if (unlikely (!u.i))
|
||||
{
|
||||
_hb_options_init ();
|
||||
u.i = _hb_options.get_relaxed ();
|
||||
}
|
||||
|
||||
return u.opts;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Debug output (needs enabling at compile time.)
|
||||
*/
|
||||
|
||||
static inline bool
|
||||
_hb_debug (unsigned int level,
|
||||
unsigned int max_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))
|
||||
|
||||
static inline void
|
||||
_hb_print_func (const char *func)
|
||||
{
|
||||
if (func)
|
||||
{
|
||||
unsigned int func_len = strlen (func);
|
||||
/* Skip "static" */
|
||||
if (0 == strncmp (func, "static ", 7))
|
||||
func += 7;
|
||||
/* Skip "typename" */
|
||||
if (0 == strncmp (func, "typename ", 9))
|
||||
func += 9;
|
||||
/* Skip return type */
|
||||
const char *space = strchr (func, ' ');
|
||||
if (space)
|
||||
func = space + 1;
|
||||
/* Skip parameter list */
|
||||
const char *paren = strchr (func, '(');
|
||||
if (paren)
|
||||
func_len = paren - func;
|
||||
fprintf (stderr, "%.*s", func_len, func);
|
||||
}
|
||||
}
|
||||
|
||||
template <int max_level> static inline void
|
||||
_hb_debug_msg_va (const char *what,
|
||||
const void *obj,
|
||||
const char *func,
|
||||
bool indented,
|
||||
unsigned int level,
|
||||
int level_dir,
|
||||
const char *message,
|
||||
va_list ap) HB_PRINTF_FUNC(7, 0);
|
||||
template <int max_level> static inline void
|
||||
_hb_debug_msg_va (const char *what,
|
||||
const void *obj,
|
||||
const char *func,
|
||||
bool indented,
|
||||
unsigned int level,
|
||||
int level_dir,
|
||||
const char *message,
|
||||
va_list ap)
|
||||
{
|
||||
if (!_hb_debug (level, max_level))
|
||||
return;
|
||||
|
||||
fprintf (stderr, "%-10s", what ? what : "");
|
||||
|
||||
if (obj)
|
||||
fprintf (stderr, "(%*p) ", (unsigned int) (2 * sizeof (void *)), obj);
|
||||
else
|
||||
fprintf (stderr, " %*s ", (unsigned int) (2 * sizeof (void *)), "");
|
||||
|
||||
if (indented) {
|
||||
#define VBAR "\342\224\202" /* U+2502 BOX DRAWINGS LIGHT VERTICAL */
|
||||
#define VRBAR "\342\224\234" /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
|
||||
#define DLBAR "\342\225\256" /* U+256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT */
|
||||
#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
|
||||
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",
|
||||
level,
|
||||
bars + sizeof (bars) - 1 - hb_min ((unsigned int) sizeof (bars) - 1, (unsigned int) (sizeof (VBAR) - 1) * level),
|
||||
level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR);
|
||||
} else
|
||||
fprintf (stderr, " " VRBAR LBAR);
|
||||
|
||||
_hb_print_func (func);
|
||||
|
||||
if (message)
|
||||
{
|
||||
fprintf (stderr, ": ");
|
||||
vfprintf (stderr, message, ap);
|
||||
}
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
template <> inline void HB_PRINTF_FUNC(7, 0)
|
||||
_hb_debug_msg_va<0> (const char *what HB_UNUSED,
|
||||
const void *obj HB_UNUSED,
|
||||
const char *func HB_UNUSED,
|
||||
bool indented HB_UNUSED,
|
||||
unsigned int level HB_UNUSED,
|
||||
int level_dir HB_UNUSED,
|
||||
const char *message HB_UNUSED,
|
||||
va_list ap HB_UNUSED) {}
|
||||
|
||||
template <int max_level> static inline void
|
||||
_hb_debug_msg (const char *what,
|
||||
const void *obj,
|
||||
const char *func,
|
||||
bool indented,
|
||||
unsigned int level,
|
||||
int level_dir,
|
||||
const char *message,
|
||||
...) HB_PRINTF_FUNC(7, 8);
|
||||
template <int max_level> static inline void HB_PRINTF_FUNC(7, 8)
|
||||
_hb_debug_msg (const char *what,
|
||||
const void *obj,
|
||||
const char *func,
|
||||
bool indented,
|
||||
unsigned int level,
|
||||
int level_dir,
|
||||
const char *message,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, message);
|
||||
_hb_debug_msg_va<max_level> (what, obj, func, indented, level, level_dir, message, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
template <> inline void
|
||||
_hb_debug_msg<0> (const char *what HB_UNUSED,
|
||||
const void *obj HB_UNUSED,
|
||||
const char *func HB_UNUSED,
|
||||
bool indented HB_UNUSED,
|
||||
unsigned int level HB_UNUSED,
|
||||
int level_dir HB_UNUSED,
|
||||
const char *message HB_UNUSED,
|
||||
...) HB_PRINTF_FUNC(7, 8);
|
||||
template <> inline void HB_PRINTF_FUNC(7, 8)
|
||||
_hb_debug_msg<0> (const char *what HB_UNUSED,
|
||||
const void *obj HB_UNUSED,
|
||||
const char *func HB_UNUSED,
|
||||
bool indented HB_UNUSED,
|
||||
unsigned int level HB_UNUSED,
|
||||
int level_dir HB_UNUSED,
|
||||
const char *message HB_UNUSED,
|
||||
...) {}
|
||||
|
||||
#define DEBUG_MSG_LEVEL(WHAT, OBJ, LEVEL, LEVEL_DIR, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), nullptr, true, (LEVEL), (LEVEL_DIR), __VA_ARGS__)
|
||||
#define DEBUG_MSG(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), nullptr, false, 0, 0, __VA_ARGS__)
|
||||
#define DEBUG_MSG_FUNC(WHAT, OBJ, ...) _hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), HB_FUNC, false, 0, 0, __VA_ARGS__)
|
||||
|
||||
|
||||
/*
|
||||
* Printer
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
struct hb_printer_t {
|
||||
const char *print (const T&) { return "something"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hb_printer_t<bool> {
|
||||
const char *print (bool v) { return v ? "true" : "false"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hb_printer_t<hb_empty_t> {
|
||||
const char *print (hb_empty_t) { return ""; }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Trace
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
static inline void _hb_warn_no_return (bool returned)
|
||||
{
|
||||
if (unlikely (!returned)) {
|
||||
fprintf (stderr, "OUCH, returned with no call to return_trace(). This is a bug, please report.\n");
|
||||
}
|
||||
}
|
||||
template <>
|
||||
/*static*/ inline void _hb_warn_no_return<hb_empty_t> (bool returned HB_UNUSED)
|
||||
{}
|
||||
|
||||
template <int max_level, typename ret_t>
|
||||
struct hb_auto_trace_t
|
||||
{
|
||||
explicit inline hb_auto_trace_t (unsigned int *plevel_,
|
||||
const char *what_,
|
||||
const void *obj_,
|
||||
const char *func,
|
||||
const char *message,
|
||||
...) HB_PRINTF_FUNC(6, 7)
|
||||
: plevel (plevel_), what (what_), obj (obj_), returned (false)
|
||||
{
|
||||
if (plevel) ++*plevel;
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, message);
|
||||
_hb_debug_msg_va<max_level> (what, obj, func, true, plevel ? *plevel : 0, +1, message, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
~hb_auto_trace_t ()
|
||||
{
|
||||
_hb_warn_no_return<ret_t> (returned);
|
||||
if (!returned) {
|
||||
_hb_debug_msg<max_level> (what, obj, nullptr, true, plevel ? *plevel : 1, -1, " ");
|
||||
}
|
||||
if (plevel) --*plevel;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T ret (T&& v,
|
||||
const char *func = "",
|
||||
unsigned int line = 0)
|
||||
{
|
||||
if (unlikely (returned)) {
|
||||
fprintf (stderr, "OUCH, double calls to return_trace(). This is a bug, please report.\n");
|
||||
return hb_forward<T> (v);
|
||||
}
|
||||
|
||||
_hb_debug_msg<max_level> (what, obj, func, true, plevel ? *plevel : 1, -1,
|
||||
"return %s (line %d)",
|
||||
hb_printer_t<decltype (v)>().print (v), line);
|
||||
if (plevel) --*plevel;
|
||||
plevel = nullptr;
|
||||
returned = true;
|
||||
return hb_forward<T> (v);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int *plevel;
|
||||
const char *what;
|
||||
const void *obj;
|
||||
bool returned;
|
||||
};
|
||||
template <typename ret_t> /* Make sure we don't use hb_auto_trace_t when not tracing. */
|
||||
struct hb_auto_trace_t<0, ret_t>
|
||||
{
|
||||
explicit inline hb_auto_trace_t (unsigned int *plevel_,
|
||||
const char *what_,
|
||||
const void *obj_,
|
||||
const char *func,
|
||||
const char *message,
|
||||
...) HB_PRINTF_FUNC(6, 7) {}
|
||||
|
||||
template <typename T>
|
||||
T ret (T&& v,
|
||||
const char *func HB_UNUSED = nullptr,
|
||||
unsigned int line HB_UNUSED = 0) { return hb_forward<T> (v); }
|
||||
};
|
||||
|
||||
/* For disabled tracing; optimize out everything.
|
||||
* https://github.com/harfbuzz/harfbuzz/pull/605 */
|
||||
template <typename ret_t>
|
||||
struct hb_no_trace_t {
|
||||
template <typename T>
|
||||
T ret (T&& v,
|
||||
const char *func HB_UNUSED = nullptr,
|
||||
unsigned int line HB_UNUSED = 0) { return hb_forward<T> (v); }
|
||||
};
|
||||
|
||||
#define return_trace(RET) return trace.ret (RET, HB_FUNC, __LINE__)
|
||||
|
||||
|
||||
/*
|
||||
* Instances.
|
||||
*/
|
||||
|
||||
#ifndef HB_DEBUG_ARABIC
|
||||
#define HB_DEBUG_ARABIC (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_BLOB
|
||||
#define HB_DEBUG_BLOB (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_CORETEXT
|
||||
#define HB_DEBUG_CORETEXT (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_DIRECTWRITE
|
||||
#define HB_DEBUG_DIRECTWRITE (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_FT
|
||||
#define HB_DEBUG_FT (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_OBJECT
|
||||
#define HB_DEBUG_OBJECT (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_SHAPE_PLAN
|
||||
#define HB_DEBUG_SHAPE_PLAN (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_UNISCRIBE
|
||||
#define HB_DEBUG_UNISCRIBE (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* With tracing.
|
||||
*/
|
||||
|
||||
#ifndef HB_DEBUG_APPLY
|
||||
#define HB_DEBUG_APPLY (HB_DEBUG+0)
|
||||
#endif
|
||||
#if HB_DEBUG_APPLY
|
||||
#define TRACE_APPLY(this) \
|
||||
hb_auto_trace_t<HB_DEBUG_APPLY, bool> trace \
|
||||
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
|
||||
"idx %d gid %u lookup %d", \
|
||||
c->buffer->idx, c->buffer->cur().codepoint, (int) c->lookup_index)
|
||||
#else
|
||||
#define TRACE_APPLY(this) hb_no_trace_t<bool> trace
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_SANITIZE
|
||||
#define HB_DEBUG_SANITIZE (HB_DEBUG+0)
|
||||
#endif
|
||||
#if HB_DEBUG_SANITIZE
|
||||
#define TRACE_SANITIZE(this) \
|
||||
hb_auto_trace_t<HB_DEBUG_SANITIZE, bool> trace \
|
||||
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
|
||||
" ")
|
||||
#else
|
||||
#define TRACE_SANITIZE(this) hb_no_trace_t<bool> trace
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_SERIALIZE
|
||||
#define HB_DEBUG_SERIALIZE (HB_DEBUG+0)
|
||||
#endif
|
||||
#if HB_DEBUG_SERIALIZE
|
||||
#define TRACE_SERIALIZE(this) \
|
||||
hb_auto_trace_t<HB_DEBUG_SERIALIZE, bool> trace \
|
||||
(&c->debug_depth, "SERIALIZE", c, HB_FUNC, \
|
||||
" ")
|
||||
#else
|
||||
#define TRACE_SERIALIZE(this) hb_no_trace_t<bool> trace
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_SUBSET
|
||||
#define HB_DEBUG_SUBSET (HB_DEBUG+0)
|
||||
#endif
|
||||
#if HB_DEBUG_SUBSET
|
||||
#define TRACE_SUBSET(this) \
|
||||
hb_auto_trace_t<HB_DEBUG_SUBSET, bool> trace \
|
||||
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
|
||||
" ")
|
||||
#else
|
||||
#define TRACE_SUBSET(this) hb_no_trace_t<bool> trace
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_SUBSET_REPACK
|
||||
#define HB_DEBUG_SUBSET_REPACK (HB_DEBUG+0)
|
||||
#endif
|
||||
|
||||
#ifndef HB_DEBUG_DISPATCH
|
||||
#define HB_DEBUG_DISPATCH ( \
|
||||
HB_DEBUG_APPLY + \
|
||||
HB_DEBUG_SANITIZE + \
|
||||
HB_DEBUG_SERIALIZE + \
|
||||
HB_DEBUG_SUBSET + \
|
||||
0)
|
||||
#endif
|
||||
#if HB_DEBUG_DISPATCH
|
||||
#define TRACE_DISPATCH(this, format) \
|
||||
hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \
|
||||
(&c->debug_depth, c->get_name (), this, HB_FUNC, \
|
||||
"format %d", (int) format)
|
||||
#else
|
||||
#define TRACE_DISPATCH(this, format) hb_no_trace_t<typename context_t::return_t> trace
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* HB_DEBUG_HH */
|
||||
@@ -24,7 +24,7 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_H_IN
|
||||
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb.h> instead."
|
||||
#endif
|
||||
|
||||
@@ -34,26 +34,219 @@
|
||||
#include "hb-common.h"
|
||||
#include "hb-unicode.h"
|
||||
#include "hb-font.h"
|
||||
#include "hb-set.h"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:hb-deprecated
|
||||
* @title: hb-deprecated
|
||||
* @short_description: Deprecated API
|
||||
* @include: hb.h
|
||||
*
|
||||
* These API have been deprecated in favor of newer API, or because they
|
||||
* were deemed unnecessary.
|
||||
**/
|
||||
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
#ifndef HB_DISABLE_DEPRECATED
|
||||
|
||||
|
||||
/**
|
||||
* HB_SCRIPT_CANADIAN_ABORIGINAL:
|
||||
*
|
||||
* Use #HB_SCRIPT_CANADIAN_SYLLABICS instead:
|
||||
*
|
||||
* Deprecated: 0.9.20
|
||||
*/
|
||||
#define HB_SCRIPT_CANADIAN_ABORIGINAL HB_SCRIPT_CANADIAN_SYLLABICS
|
||||
|
||||
/**
|
||||
* HB_BUFFER_FLAGS_DEFAULT:
|
||||
*
|
||||
* Use #HB_BUFFER_FLAG_DEFAULT instead.
|
||||
*
|
||||
* Deprecated: 0.9.20
|
||||
*/
|
||||
#define HB_BUFFER_FLAGS_DEFAULT HB_BUFFER_FLAG_DEFAULT
|
||||
/**
|
||||
* HB_BUFFER_SERIALIZE_FLAGS_DEFAULT:
|
||||
*
|
||||
* Use #HB_BUFFER_SERIALIZE_FLAG_DEFAULT instead.
|
||||
*
|
||||
* Deprecated: 0.9.20
|
||||
*/
|
||||
#define HB_BUFFER_SERIALIZE_FLAGS_DEFAULT HB_BUFFER_SERIALIZE_FLAG_DEFAULT
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @unicode: The Unicode code point to query
|
||||
* @variation_selector: The variation-selector code point to query
|
||||
* @glyph: (out): The glyph ID retrieved
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the glyph ID for a specified Unicode code point
|
||||
* font, with an optional variation selector.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
* Deprecated: 1.2.3
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
|
||||
hb_codepoint_t *glyph,
|
||||
void *user_data);
|
||||
|
||||
HB_EXTERN void
|
||||
HB_EXTERN HB_DEPRECATED_FOR(hb_font_funcs_set_nominal_glyph_func and hb_font_funcs_set_variation_glyph_func) void
|
||||
hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
|
||||
hb_font_get_glyph_func_t func,
|
||||
void *user_data, hb_destroy_func_t destroy);
|
||||
|
||||
HB_EXTERN HB_DEPRECATED void
|
||||
hb_set_invert (hb_set_t *set);
|
||||
|
||||
/**
|
||||
* hb_unicode_eastasian_width_func_t:
|
||||
* @ufuncs: A Unicode-functions structure
|
||||
* @unicode: The code point to query
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_unicode_funcs_t structure.
|
||||
*
|
||||
* Deprecated: 2.0.0
|
||||
*/
|
||||
typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t *ufuncs,
|
||||
hb_codepoint_t unicode,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_unicode_funcs_set_eastasian_width_func:
|
||||
* @ufuncs: a Unicode-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_unicode_eastasian_width_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
* Deprecated: 2.0.0
|
||||
**/
|
||||
HB_EXTERN HB_DEPRECATED void
|
||||
hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
|
||||
hb_unicode_eastasian_width_func_t func,
|
||||
void *user_data, hb_destroy_func_t destroy);
|
||||
|
||||
/**
|
||||
* hb_unicode_eastasian_width:
|
||||
* @ufuncs: a Unicode-function structure
|
||||
* @unicode: The code point to query
|
||||
*
|
||||
* Don't use. Not used by HarfBuzz.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
* Deprecated: 2.0.0
|
||||
**/
|
||||
HB_EXTERN HB_DEPRECATED unsigned int
|
||||
hb_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs,
|
||||
hb_codepoint_t unicode);
|
||||
|
||||
|
||||
/**
|
||||
* hb_unicode_decompose_compatibility_func_t:
|
||||
* @ufuncs: a 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()
|
||||
*
|
||||
* Fully decompose @u to its Unicode compatibility decomposition. The codepoints of the decomposition will be written to @decomposed.
|
||||
* The complete length of the decomposition will be returned.
|
||||
*
|
||||
* If @u has no compatibility decomposition, zero should be returned.
|
||||
*
|
||||
* The Unicode standard guarantees that a buffer of length #HB_UNICODE_MAX_DECOMPOSITION_LEN codepoints will always be sufficient for any
|
||||
* compatibility decomposition plus an terminating value of 0. Consequently, @decompose must be allocated by the caller to be at least this length. Implementations
|
||||
* of this function type must ensure that they do not write past the provided array.
|
||||
*
|
||||
* Return value: number of codepoints in the full compatibility decomposition of @u, or 0 if no decomposition available.
|
||||
*
|
||||
* Deprecated: 2.0.0
|
||||
*/
|
||||
typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_funcs_t *ufuncs,
|
||||
hb_codepoint_t u,
|
||||
hb_codepoint_t *decomposed,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* HB_UNICODE_MAX_DECOMPOSITION_LEN:
|
||||
*
|
||||
* See Unicode 6.1 for details on the maximum decomposition length.
|
||||
*
|
||||
* Deprecated: 2.0.0
|
||||
*/
|
||||
#define HB_UNICODE_MAX_DECOMPOSITION_LEN (18+1) /* codepoints */
|
||||
|
||||
/**
|
||||
* hb_unicode_funcs_set_decompose_compatibility_func:
|
||||
* @ufuncs: A Unicode-functions structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_unicode_decompose_compatibility_func_t.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Since: 0.9.2
|
||||
* Deprecated: 2.0.0
|
||||
**/
|
||||
HB_EXTERN HB_DEPRECATED void
|
||||
hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs,
|
||||
hb_unicode_decompose_compatibility_func_t func,
|
||||
void *user_data, hb_destroy_func_t destroy);
|
||||
|
||||
HB_EXTERN HB_DEPRECATED unsigned int
|
||||
hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
|
||||
hb_codepoint_t u,
|
||||
hb_codepoint_t *decomposed);
|
||||
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_v_kerning_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the kerning-adjustment value for a glyph-pair in
|
||||
* the specified font, for vertical text segments.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_v_kerning_func:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_v_kerning_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
* Deprecated: 2.0.0
|
||||
**/
|
||||
HB_EXTERN 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_EXTERN hb_position_t
|
||||
hb_font_get_glyph_v_kerning (hb_font_t *font,
|
||||
hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
|
||||
|
||||
#endif
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
+498
-438
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2015 Ebrahim Byagowi
|
||||
* Copyright © 2015-2019 Ebrahim Byagowi
|
||||
*
|
||||
* This is part of HarfBuzz, a text shaping library.
|
||||
*
|
||||
@@ -29,9 +29,11 @@
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_directwrite_shape_experimental_width(hb_font_t *font, hb_buffer_t *buffer,
|
||||
const hb_feature_t *features, unsigned int num_features, float width);
|
||||
HB_EXTERN hb_face_t *
|
||||
hb_directwrite_face_create (IDWriteFontFace *font_face);
|
||||
|
||||
HB_EXTERN IDWriteFontFace *
|
||||
hb_directwrite_face_get_font_face (hb_face_t *face);
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright © 2007,2008,2009,2010 Red Hat, Inc.
|
||||
* Copyright © 2012,2018 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_DISPATCH_HH
|
||||
#define HB_DISPATCH_HH
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
/*
|
||||
* Dispatch
|
||||
*/
|
||||
|
||||
template <typename Context, typename Return=hb_empty_t, unsigned int MaxDebugDepth=0>
|
||||
struct hb_dispatch_context_t
|
||||
{
|
||||
private:
|
||||
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
|
||||
const Context* thiz () const { return static_cast<const Context *> (this); }
|
||||
Context* thiz () { return static_cast< Context *> (this); }
|
||||
public:
|
||||
const char *get_name () { return "UNKNOWN"; }
|
||||
static constexpr unsigned max_debug_depth = MaxDebugDepth;
|
||||
typedef Return return_t;
|
||||
template <typename T, typename F>
|
||||
bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; }
|
||||
template <typename T, typename ...Ts>
|
||||
return_t dispatch (const T &obj, Ts&&... ds)
|
||||
{ return obj.dispatch (thiz (), hb_forward<Ts> (ds)...); }
|
||||
static return_t no_dispatch_return_value () { return Context::default_return_value (); }
|
||||
static bool stop_sublookup_iteration (const return_t r HB_UNUSED) { return false; }
|
||||
unsigned debug_depth = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* HB_DISPATCH_HH */
|
||||
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright © 2019-2020 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
#ifndef HB_NO_DRAW
|
||||
#ifdef HB_EXPERIMENTAL_API
|
||||
|
||||
#include "hb-draw.hh"
|
||||
#include "hb-ot.h"
|
||||
#include "hb-ot-glyf-table.hh"
|
||||
#include "hb-ot-cff1-table.hh"
|
||||
#include "hb-ot-cff2-table.hh"
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_set_move_to_func:
|
||||
* @funcs: draw functions object
|
||||
* @move_to: move-to callback
|
||||
*
|
||||
* Sets move-to callback to the draw functions object.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
void
|
||||
hb_draw_funcs_set_move_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_move_to_func_t move_to)
|
||||
{
|
||||
if (unlikely (hb_object_is_immutable (funcs))) return;
|
||||
funcs->move_to = move_to;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_set_line_to_func:
|
||||
* @funcs: draw functions object
|
||||
* @line_to: line-to callback
|
||||
*
|
||||
* Sets line-to callback to the draw functions object.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
void
|
||||
hb_draw_funcs_set_line_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_line_to_func_t line_to)
|
||||
{
|
||||
if (unlikely (hb_object_is_immutable (funcs))) return;
|
||||
funcs->line_to = line_to;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_set_quadratic_to_func:
|
||||
* @funcs: draw functions object
|
||||
* @move_to: quadratic-to callback
|
||||
*
|
||||
* Sets quadratic-to callback to the draw functions object.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
void
|
||||
hb_draw_funcs_set_quadratic_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_quadratic_to_func_t quadratic_to)
|
||||
{
|
||||
if (unlikely (hb_object_is_immutable (funcs))) return;
|
||||
funcs->quadratic_to = quadratic_to;
|
||||
funcs->is_quadratic_to_set = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_set_cubic_to_func:
|
||||
* @funcs: draw functions
|
||||
* @cubic_to: cubic-to callback
|
||||
*
|
||||
* Sets cubic-to callback to the draw functions object.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
void
|
||||
hb_draw_funcs_set_cubic_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_cubic_to_func_t cubic_to)
|
||||
{
|
||||
if (unlikely (hb_object_is_immutable (funcs))) return;
|
||||
funcs->cubic_to = cubic_to;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_set_close_path_func:
|
||||
* @funcs: draw functions object
|
||||
* @close_path: close-path callback
|
||||
*
|
||||
* Sets close-path callback to the draw functions object.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
void
|
||||
hb_draw_funcs_set_close_path_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_close_path_func_t close_path)
|
||||
{
|
||||
if (unlikely (hb_object_is_immutable (funcs))) return;
|
||||
funcs->close_path = close_path;
|
||||
}
|
||||
|
||||
static void
|
||||
_move_to_nil (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *user_data HB_UNUSED) {}
|
||||
|
||||
static void
|
||||
_line_to_nil (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *user_data HB_UNUSED) {}
|
||||
|
||||
static void
|
||||
_quadratic_to_nil (hb_position_t control_x HB_UNUSED, hb_position_t control_y HB_UNUSED,
|
||||
hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED,
|
||||
void *user_data HB_UNUSED) {}
|
||||
|
||||
static void
|
||||
_cubic_to_nil (hb_position_t control1_x HB_UNUSED, hb_position_t control1_y HB_UNUSED,
|
||||
hb_position_t control2_x HB_UNUSED, hb_position_t control2_y HB_UNUSED,
|
||||
hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED,
|
||||
void *user_data HB_UNUSED) {}
|
||||
|
||||
static void
|
||||
_close_path_nil (void *user_data HB_UNUSED) {}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_create:
|
||||
*
|
||||
* Creates a new draw callbacks object.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
hb_draw_funcs_t *
|
||||
hb_draw_funcs_create ()
|
||||
{
|
||||
hb_draw_funcs_t *funcs;
|
||||
if (unlikely (!(funcs = hb_object_create<hb_draw_funcs_t> ())))
|
||||
return const_cast<hb_draw_funcs_t *> (&Null (hb_draw_funcs_t));
|
||||
|
||||
funcs->move_to = (hb_draw_move_to_func_t) _move_to_nil;
|
||||
funcs->line_to = (hb_draw_line_to_func_t) _line_to_nil;
|
||||
funcs->quadratic_to = (hb_draw_quadratic_to_func_t) _quadratic_to_nil;
|
||||
funcs->is_quadratic_to_set = false;
|
||||
funcs->cubic_to = (hb_draw_cubic_to_func_t) _cubic_to_nil;
|
||||
funcs->close_path = (hb_draw_close_path_func_t) _close_path_nil;
|
||||
return funcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_reference:
|
||||
* @funcs: draw functions
|
||||
*
|
||||
* Add to callbacks object refcount.
|
||||
*
|
||||
* Returns: The same object.
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
hb_draw_funcs_t *
|
||||
hb_draw_funcs_reference (hb_draw_funcs_t *funcs)
|
||||
{
|
||||
return hb_object_reference (funcs);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_destroy:
|
||||
* @funcs: draw functions
|
||||
*
|
||||
* Decreases refcount of callbacks object and deletes the object if it reaches
|
||||
* to zero.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
void
|
||||
hb_draw_funcs_destroy (hb_draw_funcs_t *funcs)
|
||||
{
|
||||
if (!hb_object_destroy (funcs)) return;
|
||||
|
||||
hb_free (funcs);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_make_immutable:
|
||||
* @funcs: draw functions
|
||||
*
|
||||
* Makes funcs object immutable.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
void
|
||||
hb_draw_funcs_make_immutable (hb_draw_funcs_t *funcs)
|
||||
{
|
||||
if (hb_object_is_immutable (funcs))
|
||||
return;
|
||||
|
||||
hb_object_make_immutable (funcs);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_is_immutable:
|
||||
* @funcs: draw functions
|
||||
*
|
||||
* Checks whether funcs is immutable.
|
||||
*
|
||||
* Returns: If is immutable.
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_draw_funcs_is_immutable (hb_draw_funcs_t *funcs)
|
||||
{
|
||||
return hb_object_is_immutable (funcs);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_font_draw_glyph:
|
||||
* @font: a font object
|
||||
* @glyph: a glyph id
|
||||
* @funcs: draw callbacks object
|
||||
* @user_data: parameter you like be passed to the callbacks when are called
|
||||
*
|
||||
* Draw a glyph.
|
||||
*
|
||||
* Returns: Whether the font had the glyph and the operation completed successfully.
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph,
|
||||
const hb_draw_funcs_t *funcs,
|
||||
void *user_data)
|
||||
{
|
||||
if (unlikely (funcs == &Null (hb_draw_funcs_t) ||
|
||||
glyph >= font->face->get_num_glyphs ()))
|
||||
return false;
|
||||
|
||||
draw_helper_t draw_helper (funcs, user_data);
|
||||
if (font->face->table.glyf->get_path (font, glyph, draw_helper)) return true;
|
||||
#ifndef HB_NO_CFF
|
||||
if (font->face->table.cff1->get_path (font, glyph, draw_helper)) return true;
|
||||
if (font->face->table.cff2->get_path (font, glyph, draw_helper)) return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright © 2019-2020 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb.h> instead."
|
||||
#endif
|
||||
|
||||
#ifndef HB_DRAW_H
|
||||
#define HB_DRAW_H
|
||||
|
||||
#include "hb.h"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
#ifdef HB_EXPERIMENTAL_API
|
||||
typedef void (*hb_draw_move_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data);
|
||||
typedef void (*hb_draw_line_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data);
|
||||
typedef void (*hb_draw_quadratic_to_func_t) (hb_position_t control_x, hb_position_t control_y,
|
||||
hb_position_t to_x, hb_position_t to_y,
|
||||
void *user_data);
|
||||
typedef void (*hb_draw_cubic_to_func_t) (hb_position_t control1_x, hb_position_t control1_y,
|
||||
hb_position_t control2_x, hb_position_t control2_y,
|
||||
hb_position_t to_x, hb_position_t to_y,
|
||||
void *user_data);
|
||||
typedef void (*hb_draw_close_path_func_t) (void *user_data);
|
||||
|
||||
/**
|
||||
* hb_draw_funcs_t:
|
||||
*
|
||||
* Glyph draw callbacks.
|
||||
*
|
||||
* _move_to, _line_to and _cubic_to calls are nessecary to be defined but we
|
||||
* translate _quadratic_to calls to _cubic_to if the callback isn't defined.
|
||||
*
|
||||
* Since: EXPERIMENTAL
|
||||
**/
|
||||
typedef struct hb_draw_funcs_t hb_draw_funcs_t;
|
||||
|
||||
HB_EXTERN void
|
||||
hb_draw_funcs_set_move_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_move_to_func_t move_to);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_draw_funcs_set_line_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_line_to_func_t line_to);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_draw_funcs_set_quadratic_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_quadratic_to_func_t quadratic_to);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_draw_funcs_set_cubic_to_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_cubic_to_func_t cubic_to);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_draw_funcs_set_close_path_func (hb_draw_funcs_t *funcs,
|
||||
hb_draw_close_path_func_t close_path);
|
||||
|
||||
HB_EXTERN hb_draw_funcs_t *
|
||||
hb_draw_funcs_create (void);
|
||||
|
||||
HB_EXTERN hb_draw_funcs_t *
|
||||
hb_draw_funcs_reference (hb_draw_funcs_t *funcs);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_draw_funcs_destroy (hb_draw_funcs_t *funcs);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_draw_funcs_make_immutable (hb_draw_funcs_t *funcs);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_draw_funcs_is_immutable (hb_draw_funcs_t *funcs);
|
||||
#endif
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#endif /* HB_DRAW_H */
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright © 2020 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_DRAW_HH
|
||||
#define HB_DRAW_HH
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
#ifdef HB_EXPERIMENTAL_API
|
||||
struct hb_draw_funcs_t
|
||||
{
|
||||
hb_object_header_t header;
|
||||
|
||||
hb_draw_move_to_func_t move_to;
|
||||
hb_draw_line_to_func_t line_to;
|
||||
hb_draw_quadratic_to_func_t quadratic_to;
|
||||
bool is_quadratic_to_set;
|
||||
hb_draw_cubic_to_func_t cubic_to;
|
||||
hb_draw_close_path_func_t close_path;
|
||||
};
|
||||
|
||||
struct draw_helper_t
|
||||
{
|
||||
draw_helper_t (const hb_draw_funcs_t *funcs_, void *user_data_)
|
||||
{
|
||||
funcs = funcs_;
|
||||
user_data = user_data_;
|
||||
path_open = false;
|
||||
path_start_x = current_x = path_start_y = current_y = 0;
|
||||
}
|
||||
~draw_helper_t () { end_path (); }
|
||||
|
||||
void move_to (hb_position_t x, hb_position_t y)
|
||||
{
|
||||
if (path_open) end_path ();
|
||||
current_x = path_start_x = x;
|
||||
current_y = path_start_y = y;
|
||||
}
|
||||
|
||||
void line_to (hb_position_t x, hb_position_t y)
|
||||
{
|
||||
if (equal_to_current (x, y)) return;
|
||||
if (!path_open) start_path ();
|
||||
funcs->line_to (x, y, user_data);
|
||||
current_x = x;
|
||||
current_y = y;
|
||||
}
|
||||
|
||||
void
|
||||
quadratic_to (hb_position_t control_x, hb_position_t control_y,
|
||||
hb_position_t to_x, hb_position_t to_y)
|
||||
{
|
||||
if (equal_to_current (control_x, control_y) && equal_to_current (to_x, to_y))
|
||||
return;
|
||||
if (!path_open) start_path ();
|
||||
if (funcs->is_quadratic_to_set)
|
||||
funcs->quadratic_to (control_x, control_y, to_x, to_y, user_data);
|
||||
else
|
||||
funcs->cubic_to (roundf ((current_x + 2.f * control_x) / 3.f),
|
||||
roundf ((current_y + 2.f * control_y) / 3.f),
|
||||
roundf ((to_x + 2.f * control_x) / 3.f),
|
||||
roundf ((to_y + 2.f * control_y) / 3.f),
|
||||
to_x, to_y, user_data);
|
||||
current_x = to_x;
|
||||
current_y = to_y;
|
||||
}
|
||||
|
||||
void
|
||||
cubic_to (hb_position_t control1_x, hb_position_t control1_y,
|
||||
hb_position_t control2_x, hb_position_t control2_y,
|
||||
hb_position_t to_x, hb_position_t to_y)
|
||||
{
|
||||
if (equal_to_current (control1_x, control1_y) &&
|
||||
equal_to_current (control2_x, control2_y) &&
|
||||
equal_to_current (to_x, to_y))
|
||||
return;
|
||||
if (!path_open) start_path ();
|
||||
funcs->cubic_to (control1_x, control1_y, control2_x, control2_y, to_x, to_y, user_data);
|
||||
current_x = to_x;
|
||||
current_y = to_y;
|
||||
}
|
||||
|
||||
void end_path ()
|
||||
{
|
||||
if (path_open)
|
||||
{
|
||||
if ((path_start_x != current_x) || (path_start_y != current_y))
|
||||
funcs->line_to (path_start_x, path_start_y, user_data);
|
||||
funcs->close_path (user_data);
|
||||
}
|
||||
path_open = false;
|
||||
path_start_x = current_x = path_start_y = current_y = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool equal_to_current (hb_position_t x, hb_position_t y)
|
||||
{ return current_x == x && current_y == y; }
|
||||
|
||||
void start_path ()
|
||||
{
|
||||
if (path_open) end_path ();
|
||||
path_open = true;
|
||||
funcs->move_to (path_start_x, path_start_y, user_data);
|
||||
}
|
||||
|
||||
hb_position_t path_start_x;
|
||||
hb_position_t path_start_y;
|
||||
|
||||
hb_position_t current_x;
|
||||
hb_position_t current_y;
|
||||
|
||||
bool path_open;
|
||||
const hb_draw_funcs_t *funcs;
|
||||
void *user_data;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HB_DRAW_HH */
|
||||
+414
-140
@@ -26,52 +26,91 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#include "hb-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
#include "hb-face-private.hh"
|
||||
#include "hb-open-file-private.hh"
|
||||
#include "hb-ot-head-table.hh"
|
||||
#include "hb-ot-maxp-table.hh"
|
||||
#include "hb-face.hh"
|
||||
#include "hb-blob.hh"
|
||||
#include "hb-open-file.hh"
|
||||
#include "hb-ot-face.hh"
|
||||
#include "hb-ot-cmap-table.hh"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:hb-face
|
||||
* @title: hb-face
|
||||
* @short_description: Font face objects
|
||||
* @include: hb.h
|
||||
*
|
||||
* A font face is an object that represents a single face from within a
|
||||
* font family.
|
||||
*
|
||||
* More precisely, a font face represents a single face in a binary font file.
|
||||
* Font faces are typically built from a binary blob and a face index.
|
||||
* Font faces are used to create fonts.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* hb_face_count:
|
||||
* @blob: a blob.
|
||||
*
|
||||
* Fetches the number of faces in a blob.
|
||||
*
|
||||
* Return value: Number of faces in @blob
|
||||
*
|
||||
* Since: 1.7.7
|
||||
**/
|
||||
unsigned int
|
||||
hb_face_count (hb_blob_t *blob)
|
||||
{
|
||||
if (unlikely (!blob))
|
||||
return 0;
|
||||
|
||||
/* TODO We shouldn't be sanitizing blob. Port to run sanitizer and return if not sane. */
|
||||
/* Make API signature const after. */
|
||||
hb_blob_t *sanitized = hb_sanitize_context_t ().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob));
|
||||
const OT::OpenTypeFontFile& ot = *sanitized->as<OT::OpenTypeFontFile> ();
|
||||
unsigned int ret = ot.get_face_count ();
|
||||
hb_blob_destroy (sanitized);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* hb_face_t
|
||||
*/
|
||||
|
||||
const hb_face_t _hb_face_nil = {
|
||||
DEFINE_NULL_INSTANCE (hb_face_t) =
|
||||
{
|
||||
HB_OBJECT_HEADER_STATIC,
|
||||
|
||||
true, /* immutable */
|
||||
|
||||
NULL, /* reference_table_func */
|
||||
NULL, /* user_data */
|
||||
NULL, /* destroy */
|
||||
nullptr, /* reference_table_func */
|
||||
nullptr, /* user_data */
|
||||
nullptr, /* destroy */
|
||||
|
||||
0, /* index */
|
||||
1000, /* upem */
|
||||
0, /* num_glyphs */
|
||||
|
||||
hb_face_t::DIRTY_NOTHING, /* dirty */
|
||||
|
||||
{
|
||||
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
|
||||
#include "hb-shaper-list.hh"
|
||||
#undef HB_SHAPER_IMPLEMENT
|
||||
},
|
||||
|
||||
NULL, /* shape_plans */
|
||||
/* Zero for the rest is fine. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* hb_face_create_for_tables:
|
||||
* @reference_table_func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @reference_table_func: (closure user_data) (destroy destroy) (scope notified): Table-referencing function
|
||||
* @user_data: A pointer to the user data
|
||||
* @destroy: (nullable): A callback to call when @data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Variant of hb_face_create(), built for those cases where it is more
|
||||
* convenient to provide data for individual tables instead of the whole font
|
||||
* data. With the caveat that hb_face_get_table_tags() does not currently work
|
||||
* with faces created this way.
|
||||
*
|
||||
* Return value: (transfer full)
|
||||
* Creates a new face object from the specified @user_data and @reference_table_func,
|
||||
* with the @destroy callback.
|
||||
*
|
||||
* Return value: (transfer full): The new face object
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -92,8 +131,10 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
|
||||
face->user_data = user_data;
|
||||
face->destroy = destroy;
|
||||
|
||||
face->upem = 0;
|
||||
face->num_glyphs = (unsigned int) -1;
|
||||
face->num_glyphs.set_relaxed (-1);
|
||||
|
||||
face->data.init0 (face);
|
||||
face->table.init0 (face);
|
||||
|
||||
return face;
|
||||
}
|
||||
@@ -109,9 +150,9 @@ _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 *) calloc (1, sizeof (hb_face_for_data_closure_t));
|
||||
closure = (hb_face_for_data_closure_t *) hb_calloc (1, sizeof (hb_face_for_data_closure_t));
|
||||
if (unlikely (!closure))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
closure->blob = blob;
|
||||
closure->index = index;
|
||||
@@ -120,10 +161,12 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
|
||||
}
|
||||
|
||||
static void
|
||||
_hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure)
|
||||
_hb_face_for_data_closure_destroy (void *data)
|
||||
{
|
||||
hb_face_for_data_closure_t *closure = (hb_face_for_data_closure_t *) data;
|
||||
|
||||
hb_blob_destroy (closure->blob);
|
||||
free (closure);
|
||||
hb_free (closure);
|
||||
}
|
||||
|
||||
static hb_blob_t *
|
||||
@@ -134,24 +177,28 @@ _hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void
|
||||
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::OpenTypeFontFile &ot_file = *data->blob->as<OT::OpenTypeFontFile> ();
|
||||
unsigned int base_offset;
|
||||
const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index, &base_offset);
|
||||
|
||||
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);
|
||||
hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, base_offset + table.offset, table.length);
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_create: (Xconstructor)
|
||||
* @blob:
|
||||
* @index:
|
||||
* @blob: #hb_blob_t to work upon
|
||||
* @index: The index of the face within @blob
|
||||
*
|
||||
*
|
||||
* Constructs a new face object from the specified blob and
|
||||
* a face index into that blob. This is used for blobs of
|
||||
* file formats such as Dfont and TTC that can contain more
|
||||
* than one face.
|
||||
*
|
||||
* Return value: (transfer full):
|
||||
* Return value: (transfer full): The new face object
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -164,14 +211,19 @@ hb_face_create (hb_blob_t *blob,
|
||||
if (unlikely (!blob))
|
||||
blob = hb_blob_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);
|
||||
blob = hb_sanitize_context_t ().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob));
|
||||
|
||||
hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (blob, index);
|
||||
|
||||
if (unlikely (!closure))
|
||||
{
|
||||
hb_blob_destroy (blob);
|
||||
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_for_data_closure_destroy);
|
||||
|
||||
face->index = index;
|
||||
|
||||
@@ -181,26 +233,26 @@ hb_face_create (hb_blob_t *blob,
|
||||
/**
|
||||
* hb_face_get_empty:
|
||||
*
|
||||
*
|
||||
* Fetches the singleton empty face object.
|
||||
*
|
||||
* Return value: (transfer full)
|
||||
* Return value: (transfer full): The empty face object
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
hb_face_t *
|
||||
hb_face_get_empty (void)
|
||||
hb_face_get_empty ()
|
||||
{
|
||||
return const_cast<hb_face_t *> (&_hb_face_nil);
|
||||
return const_cast<hb_face_t *> (&Null (hb_face_t));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hb_face_reference: (skip)
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Increases the reference count on a face object.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: The @face object
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -212,9 +264,11 @@ hb_face_reference (hb_face_t *face)
|
||||
|
||||
/**
|
||||
* hb_face_destroy: (skip)
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Decreases the reference count on a face object. When the
|
||||
* reference count reaches zero, the face is destroyed,
|
||||
* freeing all memory.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -227,31 +281,30 @@ hb_face_destroy (hb_face_t *face)
|
||||
{
|
||||
hb_face_t::plan_node_t *next = node->next;
|
||||
hb_shape_plan_destroy (node->shape_plan);
|
||||
free (node);
|
||||
hb_free (node);
|
||||
node = next;
|
||||
}
|
||||
|
||||
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face);
|
||||
#include "hb-shaper-list.hh"
|
||||
#undef HB_SHAPER_IMPLEMENT
|
||||
face->data.fini ();
|
||||
face->table.fini ();
|
||||
|
||||
if (face->destroy)
|
||||
face->destroy (face->user_data);
|
||||
|
||||
free (face);
|
||||
hb_free (face);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_set_user_data: (skip)
|
||||
* @face: a face.
|
||||
* @key:
|
||||
* @data:
|
||||
* @destroy:
|
||||
* @replace:
|
||||
* @face: A face object
|
||||
* @key: The user-data key to set
|
||||
* @data: A pointer to the user data
|
||||
* @destroy: (nullable): A callback to call when @data is not needed anymore
|
||||
* @replace: Whether to replace an existing data with the same key
|
||||
*
|
||||
*
|
||||
* Attaches a user-data key/data pair to the given face object.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: %true if success, %false otherwise
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -267,17 +320,18 @@ hb_face_set_user_data (hb_face_t *face,
|
||||
|
||||
/**
|
||||
* hb_face_get_user_data: (skip)
|
||||
* @face: a face.
|
||||
* @key:
|
||||
* @face: A face object
|
||||
* @key: The user-data key to query
|
||||
*
|
||||
*
|
||||
* Fetches the user data associated with the specified key,
|
||||
* attached to the specified face object.
|
||||
*
|
||||
* Return value: (transfer none):
|
||||
* Return value: (transfer none): A pointer to the user data
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
void *
|
||||
hb_face_get_user_data (hb_face_t *face,
|
||||
hb_face_get_user_data (const hb_face_t *face,
|
||||
hb_user_data_key_t *key)
|
||||
{
|
||||
return hb_object_get_user_data (face, key);
|
||||
@@ -285,63 +339,69 @@ hb_face_get_user_data (hb_face_t *face,
|
||||
|
||||
/**
|
||||
* hb_face_make_immutable:
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Makes the given face object immutable.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
void
|
||||
hb_face_make_immutable (hb_face_t *face)
|
||||
{
|
||||
if (unlikely (hb_object_is_inert (face)))
|
||||
if (hb_object_is_immutable (face))
|
||||
return;
|
||||
|
||||
face->immutable = true;
|
||||
hb_object_make_immutable (face);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_is_immutable:
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Tests whether the given face object is immutable.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: %true is @face is immutable, %false otherwise
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_face_is_immutable (hb_face_t *face)
|
||||
hb_face_is_immutable (const hb_face_t *face)
|
||||
{
|
||||
return face->immutable;
|
||||
return hb_object_is_immutable (face);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hb_face_reference_table:
|
||||
* @face: a face.
|
||||
* @tag:
|
||||
* @face: A face object
|
||||
* @tag: The #hb_tag_t of the table to query
|
||||
*
|
||||
*
|
||||
* Fetches a reference to the specified table within
|
||||
* the specified face.
|
||||
*
|
||||
* Return value: (transfer full):
|
||||
* Return value: (transfer full): A pointer to the @tag table within @face
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
hb_blob_t *
|
||||
hb_face_reference_table (hb_face_t *face,
|
||||
hb_tag_t tag)
|
||||
hb_face_reference_table (const hb_face_t *face,
|
||||
hb_tag_t tag)
|
||||
{
|
||||
if (unlikely (tag == HB_TAG_NONE))
|
||||
return hb_blob_get_empty ();
|
||||
|
||||
return face->reference_table (tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_reference_blob:
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Fetches a pointer to the binary blob that contains the
|
||||
* specified face. Returns an empty blob if referencing face data is not
|
||||
* possible.
|
||||
*
|
||||
* Return value: (transfer full):
|
||||
* Return value: (transfer full): A pointer to the blob for @face
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -353,10 +413,13 @@ hb_face_reference_blob (hb_face_t *face)
|
||||
|
||||
/**
|
||||
* hb_face_set_index:
|
||||
* @face: a face.
|
||||
* @index:
|
||||
* @face: A face object
|
||||
* @index: The index to assign
|
||||
*
|
||||
*
|
||||
* Assigns the specified face-index to @face. Fails if the
|
||||
* face is immutable.
|
||||
*
|
||||
* <note>Note: face indices within a collection are zero-based.</note>
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -364,39 +427,36 @@ void
|
||||
hb_face_set_index (hb_face_t *face,
|
||||
unsigned int index)
|
||||
{
|
||||
if (face->immutable)
|
||||
if (hb_object_is_immutable (face))
|
||||
return;
|
||||
|
||||
if (face->index == index)
|
||||
return;
|
||||
|
||||
face->dirty |= face->DIRTY_INDEX;
|
||||
|
||||
face->index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_get_index:
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Fetches the face-index corresponding to the given face.
|
||||
*
|
||||
* Return value:
|
||||
* <note>Note: face indices within a collection are zero-based.</note>
|
||||
*
|
||||
* Return value: The index of @face.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
unsigned int
|
||||
hb_face_get_index (hb_face_t *face)
|
||||
hb_face_get_index (const hb_face_t *face)
|
||||
{
|
||||
return face->index;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_set_upem:
|
||||
* @face: a face.
|
||||
* @upem:
|
||||
* @face: A face object
|
||||
* @upem: The units-per-em value to assign
|
||||
*
|
||||
*
|
||||
* Sets the units-per-em (upem) for a face object to the specified value.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -404,48 +464,34 @@ void
|
||||
hb_face_set_upem (hb_face_t *face,
|
||||
unsigned int upem)
|
||||
{
|
||||
if (face->immutable)
|
||||
if (hb_object_is_immutable (face))
|
||||
return;
|
||||
|
||||
if (face->upem == upem)
|
||||
return;
|
||||
|
||||
face->dirty |= face->DIRTY_UPEM;
|
||||
|
||||
face->upem = upem;
|
||||
face->upem.set_relaxed (upem);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_get_upem:
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Fetches the units-per-em (upem) value of the specified face object.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: The upem value of @face
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
unsigned int
|
||||
hb_face_get_upem (hb_face_t *face)
|
||||
hb_face_get_upem (const 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:
|
||||
* @face: A face object
|
||||
* @glyph_count: The glyph-count value to assign
|
||||
*
|
||||
*
|
||||
* Sets the glyph count for a face object to the specified value.
|
||||
*
|
||||
* Since: 0.9.7
|
||||
**/
|
||||
@@ -453,40 +499,268 @@ void
|
||||
hb_face_set_glyph_count (hb_face_t *face,
|
||||
unsigned int glyph_count)
|
||||
{
|
||||
if (face->immutable)
|
||||
if (hb_object_is_immutable (face))
|
||||
return;
|
||||
|
||||
if (face->num_glyphs == glyph_count)
|
||||
return;
|
||||
|
||||
face->dirty |= face->DIRTY_NUM_GLYPHS;
|
||||
|
||||
face->num_glyphs = glyph_count;
|
||||
face->num_glyphs.set_relaxed (glyph_count);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_get_glyph_count:
|
||||
* @face: a face.
|
||||
* @face: A face object
|
||||
*
|
||||
*
|
||||
* Fetches the glyph-count value of the specified face object.
|
||||
*
|
||||
* Return value:
|
||||
* Return value: The glyph-count value of @face
|
||||
*
|
||||
* Since: 0.9.7
|
||||
**/
|
||||
unsigned int
|
||||
hb_face_get_glyph_count (hb_face_t *face)
|
||||
hb_face_get_glyph_count (const hb_face_t *face)
|
||||
{
|
||||
return face->get_num_glyphs ();
|
||||
}
|
||||
|
||||
void
|
||||
hb_face_t::load_num_glyphs (void) const
|
||||
/**
|
||||
* hb_face_get_table_tags:
|
||||
* @face: A face object
|
||||
* @start_offset: The index of first table tag to retrieve
|
||||
* @table_count: (inout): Input = the maximum number of table tags to return;
|
||||
* Output = the actual number of table tags returned (may be zero)
|
||||
* @table_tags: (out) (array length=table_count): The array of table tags found
|
||||
*
|
||||
* Fetches a list of all table tags for a face, if possible. The list returned will
|
||||
* begin at the offset provided
|
||||
*
|
||||
* Return value: Total number of tables, or zero if it is not possible to list
|
||||
*
|
||||
* Since: 1.6.0
|
||||
**/
|
||||
unsigned int
|
||||
hb_face_get_table_tags (const hb_face_t *face,
|
||||
unsigned int start_offset,
|
||||
unsigned int *table_count, /* IN/OUT */
|
||||
hb_tag_t *table_tags /* OUT */)
|
||||
{
|
||||
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);
|
||||
if (face->destroy != (hb_destroy_func_t) _hb_face_for_data_closure_destroy)
|
||||
{
|
||||
if (table_count)
|
||||
*table_count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) face->user_data;
|
||||
|
||||
const OT::OpenTypeFontFile &ot_file = *data->blob->as<OT::OpenTypeFontFile> ();
|
||||
const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index);
|
||||
|
||||
return ot_face.get_table_tags (start_offset, table_count, table_tags);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Character set.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HB_NO_FACE_COLLECT_UNICODES
|
||||
/**
|
||||
* hb_face_collect_unicodes:
|
||||
* @face: A face object
|
||||
* @out: The set to add Unicode characters to
|
||||
*
|
||||
* Collects all of the Unicode characters covered by @face and adds
|
||||
* them to the #hb_set_t set @out.
|
||||
*
|
||||
* Since: 1.9.0
|
||||
*/
|
||||
void
|
||||
hb_face_collect_unicodes (hb_face_t *face,
|
||||
hb_set_t *out)
|
||||
{
|
||||
face->table.cmap->collect_unicodes (out, face->get_num_glyphs ());
|
||||
}
|
||||
/**
|
||||
* hb_face_collect_variation_selectors:
|
||||
* @face: A face object
|
||||
* @out: The set to add Variation Selector characters to
|
||||
*
|
||||
* Collects all Unicode "Variation Selector" characters covered by @face and adds
|
||||
* them to the #hb_set_t set @out.
|
||||
*
|
||||
* Since: 1.9.0
|
||||
*/
|
||||
void
|
||||
hb_face_collect_variation_selectors (hb_face_t *face,
|
||||
hb_set_t *out)
|
||||
{
|
||||
face->table.cmap->collect_variation_selectors (out);
|
||||
}
|
||||
/**
|
||||
* hb_face_collect_variation_unicodes:
|
||||
* @face: A face object
|
||||
* @variation_selector: The Variation Selector to query
|
||||
* @out: The set to add Unicode characters to
|
||||
*
|
||||
* Collects all Unicode characters for @variation_selector covered by @face and adds
|
||||
* them to the #hb_set_t set @out.
|
||||
*
|
||||
* Since: 1.9.0
|
||||
*/
|
||||
void
|
||||
hb_face_collect_variation_unicodes (hb_face_t *face,
|
||||
hb_codepoint_t variation_selector,
|
||||
hb_set_t *out)
|
||||
{
|
||||
face->table.cmap->collect_variation_unicodes (variation_selector, out);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* face-builder: A face that has add_table().
|
||||
*/
|
||||
|
||||
struct hb_face_builder_data_t
|
||||
{
|
||||
struct table_entry_t
|
||||
{
|
||||
int cmp (hb_tag_t t) const
|
||||
{
|
||||
if (t < tag) return -1;
|
||||
if (t > tag) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
hb_tag_t tag;
|
||||
hb_blob_t *blob;
|
||||
};
|
||||
|
||||
hb_vector_t<table_entry_t> tables;
|
||||
};
|
||||
|
||||
static hb_face_builder_data_t *
|
||||
_hb_face_builder_data_create ()
|
||||
{
|
||||
hb_face_builder_data_t *data = (hb_face_builder_data_t *) hb_calloc (1, sizeof (hb_face_builder_data_t));
|
||||
if (unlikely (!data))
|
||||
return nullptr;
|
||||
|
||||
data->tables.init ();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
_hb_face_builder_data_destroy (void *user_data)
|
||||
{
|
||||
hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data;
|
||||
|
||||
for (unsigned int i = 0; i < data->tables.length; i++)
|
||||
hb_blob_destroy (data->tables[i].blob);
|
||||
|
||||
data->tables.fini ();
|
||||
|
||||
hb_free (data);
|
||||
}
|
||||
|
||||
static hb_blob_t *
|
||||
_hb_face_builder_data_reference_blob (hb_face_builder_data_t *data)
|
||||
{
|
||||
|
||||
unsigned int table_count = data->tables.length;
|
||||
unsigned int face_length = table_count * 16 + 12;
|
||||
|
||||
for (unsigned int i = 0; i < table_count; i++)
|
||||
face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables[i].blob));
|
||||
|
||||
char *buf = (char *) hb_malloc (face_length);
|
||||
if (unlikely (!buf))
|
||||
return nullptr;
|
||||
|
||||
hb_serialize_context_t c (buf, face_length);
|
||||
c.propagate_error (data->tables);
|
||||
OT::OpenTypeFontFile *f = c.start_serialize<OT::OpenTypeFontFile> ();
|
||||
|
||||
bool is_cff = data->tables.lsearch (HB_TAG ('C','F','F',' ')) || data->tables.lsearch (HB_TAG ('C','F','F','2'));
|
||||
hb_tag_t sfnt_tag = is_cff ? OT::OpenTypeFontFile::CFFTag : OT::OpenTypeFontFile::TrueTypeTag;
|
||||
|
||||
bool ret = f->serialize_single (&c, sfnt_tag, data->tables.as_array ());
|
||||
|
||||
c.end_serialize ();
|
||||
|
||||
if (unlikely (!ret))
|
||||
{
|
||||
hb_free (buf);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return hb_blob_create (buf, face_length, HB_MEMORY_MODE_WRITABLE, buf, hb_free);
|
||||
}
|
||||
|
||||
static hb_blob_t *
|
||||
_hb_face_builder_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
|
||||
{
|
||||
hb_face_builder_data_t *data = (hb_face_builder_data_t *) user_data;
|
||||
|
||||
if (!tag)
|
||||
return _hb_face_builder_data_reference_blob (data);
|
||||
|
||||
hb_face_builder_data_t::table_entry_t *entry = data->tables.lsearch (tag);
|
||||
if (entry)
|
||||
return hb_blob_reference (entry->blob);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hb_face_builder_create:
|
||||
*
|
||||
* Creates a #hb_face_t that can be used with hb_face_builder_add_table().
|
||||
* After tables are added to the face, it can be compiled to a binary
|
||||
* font file by calling hb_face_reference_blob().
|
||||
*
|
||||
* Return value: (transfer full): New face.
|
||||
*
|
||||
* Since: 1.9.0
|
||||
**/
|
||||
hb_face_t *
|
||||
hb_face_builder_create ()
|
||||
{
|
||||
hb_face_builder_data_t *data = _hb_face_builder_data_create ();
|
||||
if (unlikely (!data)) return hb_face_get_empty ();
|
||||
|
||||
return hb_face_create_for_tables (_hb_face_builder_reference_table,
|
||||
data,
|
||||
_hb_face_builder_data_destroy);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_face_builder_add_table:
|
||||
* @face: A face object created with hb_face_builder_create()
|
||||
* @tag: The #hb_tag_t of the table to add
|
||||
* @blob: The blob containing the table data to add
|
||||
*
|
||||
* Add table for @tag with data provided by @blob to the face. @face must
|
||||
* be created using hb_face_builder_create().
|
||||
*
|
||||
* Since: 1.9.0
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_face_builder_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob)
|
||||
{
|
||||
if (unlikely (face->destroy != (hb_destroy_func_t) _hb_face_builder_data_destroy))
|
||||
return false;
|
||||
|
||||
hb_face_builder_data_t *data = (hb_face_builder_data_t *) face->user_data;
|
||||
|
||||
hb_face_builder_data_t::table_entry_t *entry = data->tables.push ();
|
||||
if (unlikely (data->tables.in_error()))
|
||||
return false;
|
||||
|
||||
entry->tag = tag;
|
||||
entry->blob = hb_blob_reference (blob);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_H_IN
|
||||
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb.h> instead."
|
||||
#endif
|
||||
|
||||
@@ -33,20 +33,44 @@
|
||||
|
||||
#include "hb-common.h"
|
||||
#include "hb-blob.h"
|
||||
#include "hb-set.h"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_face_count (hb_blob_t *blob);
|
||||
|
||||
|
||||
/*
|
||||
* hb_face_t
|
||||
*/
|
||||
|
||||
/**
|
||||
* hb_face_t:
|
||||
*
|
||||
* Data type for holding font faces.
|
||||
*
|
||||
**/
|
||||
typedef struct hb_face_t hb_face_t;
|
||||
|
||||
HB_EXTERN hb_face_t *
|
||||
hb_face_create (hb_blob_t *blob,
|
||||
unsigned int index);
|
||||
|
||||
/**
|
||||
* hb_reference_table_func_t:
|
||||
* @face: an #hb_face_t to reference table for
|
||||
* @tag: the tag of the table to reference
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* Callback function for hb_face_create_for_tables().
|
||||
*
|
||||
* Return value: (transfer full): A pointer to the @tag table within @face
|
||||
*
|
||||
* Since: 0.9.2
|
||||
*/
|
||||
|
||||
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 */
|
||||
@@ -71,21 +95,20 @@ hb_face_set_user_data (hb_face_t *face,
|
||||
hb_destroy_func_t destroy,
|
||||
hb_bool_t replace);
|
||||
|
||||
|
||||
HB_EXTERN void *
|
||||
hb_face_get_user_data (hb_face_t *face,
|
||||
hb_face_get_user_data (const hb_face_t *face,
|
||||
hb_user_data_key_t *key);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_face_make_immutable (hb_face_t *face);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_face_is_immutable (hb_face_t *face);
|
||||
hb_face_is_immutable (const hb_face_t *face);
|
||||
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
hb_face_reference_table (hb_face_t *face,
|
||||
hb_tag_t tag);
|
||||
hb_face_reference_table (const hb_face_t *face,
|
||||
hb_tag_t tag);
|
||||
|
||||
HB_EXTERN hb_blob_t *
|
||||
hb_face_reference_blob (hb_face_t *face);
|
||||
@@ -95,21 +118,58 @@ hb_face_set_index (hb_face_t *face,
|
||||
unsigned int index);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_face_get_index (hb_face_t *face);
|
||||
hb_face_get_index (const hb_face_t *face);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_face_set_upem (hb_face_t *face,
|
||||
unsigned int upem);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_face_get_upem (hb_face_t *face);
|
||||
hb_face_get_upem (const hb_face_t *face);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_face_set_glyph_count (hb_face_t *face,
|
||||
unsigned int glyph_count);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_face_get_glyph_count (hb_face_t *face);
|
||||
hb_face_get_glyph_count (const hb_face_t *face);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_face_get_table_tags (const hb_face_t *face,
|
||||
unsigned int start_offset,
|
||||
unsigned int *table_count, /* IN/OUT */
|
||||
hb_tag_t *table_tags /* OUT */);
|
||||
|
||||
|
||||
/*
|
||||
* Character set.
|
||||
*/
|
||||
|
||||
HB_EXTERN void
|
||||
hb_face_collect_unicodes (hb_face_t *face,
|
||||
hb_set_t *out);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_face_collect_variation_selectors (hb_face_t *face,
|
||||
hb_set_t *out);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_face_collect_variation_unicodes (hb_face_t *face,
|
||||
hb_codepoint_t variation_selector,
|
||||
hb_set_t *out);
|
||||
|
||||
|
||||
/*
|
||||
* Builder face.
|
||||
*/
|
||||
|
||||
HB_EXTERN hb_face_t *
|
||||
hb_face_builder_create (void);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_face_builder_add_table (hb_face_t *face,
|
||||
hb_tag_t tag,
|
||||
hb_blob_t *blob);
|
||||
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
@@ -26,54 +26,48 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_FACE_PRIVATE_HH
|
||||
#define HB_FACE_PRIVATE_HH
|
||||
#ifndef HB_FACE_HH
|
||||
#define HB_FACE_HH
|
||||
|
||||
#include "hb-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
#include "hb-object-private.hh"
|
||||
#include "hb-shaper-private.hh"
|
||||
#include "hb-shape-plan-private.hh"
|
||||
#include "hb-shaper.hh"
|
||||
#include "hb-shape-plan.hh"
|
||||
#include "hb-ot-face.hh"
|
||||
|
||||
|
||||
/*
|
||||
* hb_face_t
|
||||
*/
|
||||
|
||||
struct hb_face_t {
|
||||
hb_object_header_t header;
|
||||
ASSERT_POD ();
|
||||
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, face);
|
||||
#include "hb-shaper-list.hh"
|
||||
#undef HB_SHAPER_IMPLEMENT
|
||||
|
||||
hb_bool_t immutable;
|
||||
struct hb_face_t
|
||||
{
|
||||
hb_object_header_t header;
|
||||
|
||||
hb_reference_table_func_t reference_table_func;
|
||||
void *user_data;
|
||||
hb_destroy_func_t destroy;
|
||||
|
||||
unsigned int index; /* Face index in a collection, zero-based. */
|
||||
mutable unsigned int upem; /* Units-per-EM. */
|
||||
mutable unsigned int num_glyphs; /* Number of glyphs. */
|
||||
mutable hb_atomic_int_t upem; /* Units-per-EM. */
|
||||
mutable hb_atomic_int_t num_glyphs; /* Number of glyphs. */
|
||||
|
||||
enum dirty_t {
|
||||
DIRTY_NOTHING = 0x0000,
|
||||
DIRTY_INDEX = 0x0001,
|
||||
DIRTY_UPEM = 0x0002,
|
||||
DIRTY_NUM_GLYPHS = 0x0004,
|
||||
} dirty;
|
||||
|
||||
struct hb_shaper_data_t shaper_data; /* Various shaper data. */
|
||||
|
||||
/* Various non-shaping data. */
|
||||
/* ... */
|
||||
hb_shaper_object_dataset_t<hb_face_t> data;/* Various shaper data. */
|
||||
hb_ot_face_t table; /* All the face's tables. */
|
||||
|
||||
/* Cache */
|
||||
struct plan_node_t {
|
||||
struct plan_node_t
|
||||
{
|
||||
hb_shape_plan_t *shape_plan;
|
||||
plan_node_t *next;
|
||||
} *shape_plans;
|
||||
};
|
||||
hb_atomic_ptr_t<plan_node_t> shape_plans;
|
||||
|
||||
|
||||
inline hb_blob_t *reference_table (hb_tag_t tag) const
|
||||
hb_blob_t *reference_table (hb_tag_t tag) const
|
||||
{
|
||||
hb_blob_t *blob;
|
||||
|
||||
@@ -87,34 +81,29 @@ struct hb_face_t {
|
||||
return blob;
|
||||
}
|
||||
|
||||
inline HB_PURE_FUNC unsigned int get_upem (void) const
|
||||
unsigned int get_upem () const
|
||||
{
|
||||
if (unlikely (!upem))
|
||||
load_upem ();
|
||||
return upem;
|
||||
unsigned int ret = upem.get_relaxed ();
|
||||
if (unlikely (!ret))
|
||||
{
|
||||
return load_upem ();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int get_num_glyphs (void) const
|
||||
unsigned int get_num_glyphs () const
|
||||
{
|
||||
if (unlikely (num_glyphs == (unsigned int) -1))
|
||||
load_num_glyphs ();
|
||||
return num_glyphs;
|
||||
unsigned int ret = num_glyphs.get_relaxed ();
|
||||
if (unlikely (ret == UINT_MAX))
|
||||
return load_num_glyphs ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
HB_INTERNAL void load_upem (void) const;
|
||||
HB_INTERNAL void load_num_glyphs (void) const;
|
||||
HB_INTERNAL unsigned int load_upem () const;
|
||||
HB_INTERNAL unsigned int load_num_glyphs () const;
|
||||
};
|
||||
|
||||
HB_MARK_AS_FLAG_T (hb_face_t::dirty_t);
|
||||
|
||||
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
|
||||
DECLARE_NULL_INSTANCE (hb_face_t);
|
||||
|
||||
|
||||
#endif /* HB_FACE_PRIVATE_HH */
|
||||
#endif /* HB_FACE_HH */
|
||||
@@ -24,28 +24,24 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#define HB_SHAPER fallback
|
||||
#include "hb-shaper-impl-private.hh"
|
||||
|
||||
|
||||
HB_SHAPER_DATA_ENSURE_DEFINE(fallback, face)
|
||||
HB_SHAPER_DATA_ENSURE_DEFINE(fallback, font)
|
||||
#include "hb-shaper-impl.hh"
|
||||
|
||||
#ifndef HB_NO_FALLBACK_SHAPE
|
||||
|
||||
/*
|
||||
* shaper face data
|
||||
*/
|
||||
|
||||
struct hb_fallback_shaper_face_data_t {};
|
||||
struct hb_fallback_face_data_t {};
|
||||
|
||||
hb_fallback_shaper_face_data_t *
|
||||
hb_fallback_face_data_t *
|
||||
_hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED)
|
||||
{
|
||||
return (hb_fallback_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
||||
return (hb_fallback_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
||||
}
|
||||
|
||||
void
|
||||
_hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_UNUSED)
|
||||
_hb_fallback_shaper_face_data_destroy (hb_fallback_face_data_t *data HB_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -54,38 +50,16 @@ _hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_U
|
||||
* shaper font data
|
||||
*/
|
||||
|
||||
struct hb_fallback_shaper_font_data_t {};
|
||||
struct hb_fallback_font_data_t {};
|
||||
|
||||
hb_fallback_shaper_font_data_t *
|
||||
hb_fallback_font_data_t *
|
||||
_hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED)
|
||||
{
|
||||
return (hb_fallback_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
||||
return (hb_fallback_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
||||
}
|
||||
|
||||
void
|
||||
_hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data HB_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* shaper shape_plan data
|
||||
*/
|
||||
|
||||
struct hb_fallback_shaper_shape_plan_data_t {};
|
||||
|
||||
hb_fallback_shaper_shape_plan_data_t *
|
||||
_hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
|
||||
const hb_feature_t *user_features HB_UNUSED,
|
||||
unsigned int num_user_features HB_UNUSED,
|
||||
const int *coords HB_UNUSED,
|
||||
unsigned int num_coords HB_UNUSED)
|
||||
{
|
||||
return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
||||
}
|
||||
|
||||
void
|
||||
_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shaper_shape_plan_data_t *data HB_UNUSED)
|
||||
_hb_fallback_shaper_font_data_destroy (hb_fallback_font_data_t *data HB_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -143,5 +117,9 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
||||
if (HB_DIRECTION_IS_BACKWARD (direction))
|
||||
hb_buffer_reverse (buffer);
|
||||
|
||||
buffer->safe_to_break_all ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+1182
-641
File diff suppressed because it is too large
Load Diff
+538
-106
@@ -24,7 +24,7 @@
|
||||
* Red Hat Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_H_IN
|
||||
#if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
|
||||
#error "Include <hb.h> instead."
|
||||
#endif
|
||||
|
||||
@@ -33,10 +33,16 @@
|
||||
|
||||
#include "hb-common.h"
|
||||
#include "hb-face.h"
|
||||
#include "hb-draw.h"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* hb_font_t:
|
||||
*
|
||||
* Data type for holding fonts.
|
||||
*
|
||||
*/
|
||||
typedef struct hb_font_t hb_font_t;
|
||||
|
||||
|
||||
@@ -44,6 +50,19 @@ typedef struct hb_font_t hb_font_t;
|
||||
* hb_font_funcs_t
|
||||
*/
|
||||
|
||||
/**
|
||||
* hb_font_funcs_t:
|
||||
*
|
||||
* Data type containing a set of virtual methods used for
|
||||
* working on #hb_font_t font objects.
|
||||
*
|
||||
* HarfBuzz provides a lightweight default function for each of
|
||||
* the methods in #hb_font_funcs_t. Client programs can implement
|
||||
* their own replacements for the individual font functions, as
|
||||
* needed, and replace the default by calling the setter for a
|
||||
* method.
|
||||
*
|
||||
**/
|
||||
typedef struct hb_font_funcs_t hb_font_funcs_t;
|
||||
|
||||
HB_EXTERN hb_font_funcs_t *
|
||||
@@ -80,12 +99,21 @@ hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
|
||||
|
||||
/* font and glyph extents */
|
||||
|
||||
/* Note that typically ascender is positive and descender negative in coordinate systems that grow up. */
|
||||
typedef struct hb_font_extents_t
|
||||
{
|
||||
hb_position_t ascender; /* typographic ascender. */
|
||||
hb_position_t descender; /* typographic descender. */
|
||||
hb_position_t line_gap; /* suggested line spacing gap. */
|
||||
/**
|
||||
* hb_font_extents_t:
|
||||
* @ascender: The height of typographic ascenders.
|
||||
* @descender: The depth of typographic descenders.
|
||||
* @line_gap: The suggested line-spacing gap.
|
||||
*
|
||||
* Font-wide extent values, measured in font units.
|
||||
*
|
||||
* Note that typically @ascender is positive and @descender
|
||||
* negative, in coordinate systems that grow up.
|
||||
**/
|
||||
typedef struct hb_font_extents_t {
|
||||
hb_position_t ascender;
|
||||
hb_position_t descender;
|
||||
hb_position_t line_gap;
|
||||
/*< private >*/
|
||||
hb_position_t reserved9;
|
||||
hb_position_t reserved8;
|
||||
@@ -98,68 +126,386 @@ typedef struct hb_font_extents_t
|
||||
hb_position_t reserved1;
|
||||
} hb_font_extents_t;
|
||||
|
||||
/* Note that height is negative in coordinate systems that grow up. */
|
||||
typedef struct hb_glyph_extents_t
|
||||
{
|
||||
hb_position_t x_bearing; /* left side of glyph from origin. */
|
||||
hb_position_t y_bearing; /* top side of glyph from origin. */
|
||||
hb_position_t width; /* distance from left to right side. */
|
||||
hb_position_t height; /* distance from top to bottom side. */
|
||||
/**
|
||||
* hb_glyph_extents_t:
|
||||
* @x_bearing: Distance from the x-origin to the left extremum of the glyph.
|
||||
* @y_bearing: Distance from the top extremum of the glyph to the y-origin.
|
||||
* @width: Distance from the left extremum of the glyph to the right extremum.
|
||||
* @height: Distance from the top extremum of the glyph to the bottom extremum.
|
||||
*
|
||||
* Glyph extent values, measured in font units.
|
||||
*
|
||||
* Note that @height is negative, in coordinate systems that grow up.
|
||||
**/
|
||||
typedef struct hb_glyph_extents_t {
|
||||
hb_position_t x_bearing;
|
||||
hb_position_t y_bearing;
|
||||
hb_position_t width;
|
||||
hb_position_t height;
|
||||
} hb_glyph_extents_t;
|
||||
|
||||
/* func types */
|
||||
|
||||
/**
|
||||
* hb_font_get_font_extents_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @extents: (out): The font extents retrieved
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* This method should retrieve the extents for a font.
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_font_extents_t *metrics,
|
||||
hb_font_extents_t *extents,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_font_h_extents_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the extents for a font, for horizontal-direction
|
||||
* text segments. Extents must be returned in an #hb_glyph_extents output
|
||||
* parameter.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_get_font_v_extents_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the extents for a font, for vertical-direction
|
||||
* text segments. Extents must be returned in an #hb_glyph_extents output
|
||||
* parameter.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t;
|
||||
|
||||
|
||||
/**
|
||||
* hb_font_get_nominal_glyph_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @unicode: The Unicode code point to query
|
||||
* @glyph: (out): The glyph ID retrieved
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the nominal glyph ID for a specified Unicode code
|
||||
* point. Glyph IDs must be returned in a #hb_codepoint_t output parameter.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t unicode,
|
||||
hb_codepoint_t *glyph,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_variation_glyph_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @unicode: The Unicode code point to query
|
||||
* @variation_selector: The variation-selector code point to query
|
||||
* @glyph: (out): The glyph ID retrieved
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the glyph ID for a specified Unicode code point
|
||||
* followed by a specified Variation Selector code point. Glyph IDs must be
|
||||
* returned in a #hb_codepoint_t output parameter.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
|
||||
hb_codepoint_t *glyph,
|
||||
void *user_data);
|
||||
|
||||
|
||||
/**
|
||||
* hb_font_get_nominal_glyphs_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @count: number of code points to query
|
||||
* @first_unicode: The first Unicode code point to query
|
||||
* @unicode_stride: The stride between successive code points
|
||||
* @first_glyph: (out): The first glyph ID retrieved
|
||||
* @glyph_stride: The stride between successive glyph IDs
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the nominal glyph IDs for a sequence of
|
||||
* Unicode code points. Glyph IDs must be returned in a #hb_codepoint_t
|
||||
* output parameter.
|
||||
*
|
||||
* Return value: the number of code points processed
|
||||
*
|
||||
**/
|
||||
typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void *font_data,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_unicode,
|
||||
unsigned int unicode_stride,
|
||||
hb_codepoint_t *first_glyph,
|
||||
unsigned int glyph_stride,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_advance_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @glyph: The glyph ID to query
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the advance for a specified glyph. The
|
||||
* method must return an #hb_position_t.
|
||||
*
|
||||
* Return value: The advance of @glyph within @font
|
||||
*
|
||||
**/
|
||||
typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t glyph,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_h_advance_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the advance for a specified glyph, in
|
||||
* horizontal-direction text segments. Advances must be returned in
|
||||
* an #hb_position_t output parameter.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_v_advance_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the advance for a specified glyph, in
|
||||
* vertical-direction text segments. Advances must be returned in
|
||||
* an #hb_position_t output parameter.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_advances_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @count: The number of glyph IDs in the sequence queried
|
||||
* @first_glyph: The first glyph ID to query
|
||||
* @glyph_stride: The stride between successive glyph IDs
|
||||
* @first_advance: (out): The first advance retrieved
|
||||
* @advance_stride: The stride between successive advances
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the advances for a sequence of glyphs.
|
||||
*
|
||||
**/
|
||||
typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned glyph_stride,
|
||||
hb_position_t *first_advance,
|
||||
unsigned advance_stride,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_h_advances_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the advances for a sequence of glyphs, in
|
||||
* horizontal-direction text segments.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_v_advances_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the advances for a sequence of glyphs, in
|
||||
* vertical-direction text segments.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_origin_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @glyph: The glyph ID to query
|
||||
* @x: (out): The X coordinate of the origin
|
||||
* @y: (out): The Y coordinate of the origin
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the (X,Y) coordinates (in font units) of the
|
||||
* origin for a glyph. Each coordinate must be returned in an #hb_position_t
|
||||
* output parameter.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_h_origin_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the (X,Y) coordinates (in font units) of the
|
||||
* origin for a glyph, for horizontal-direction text segments. Each
|
||||
* coordinate must be returned in an #hb_position_t output parameter.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_v_origin_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the (X,Y) coordinates (in font units) of the
|
||||
* origin for a glyph, for vertical-direction text segments. Each coordinate
|
||||
* must be returned in an #hb_position_t output parameter.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_kerning_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @first_glyph: The glyph ID of the first glyph in the glyph pair
|
||||
* @second_glyph: The glyph ID of the second glyph in the glyph pair
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* This method should retrieve the kerning-adjustment value for a glyph-pair in
|
||||
* the specified font, for horizontal text segments.
|
||||
*
|
||||
**/
|
||||
typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
|
||||
void *user_data);
|
||||
/**
|
||||
* hb_font_get_glyph_h_kerning_func_t:
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the kerning-adjustment value for a glyph-pair in
|
||||
* the specified font, for horizontal text segments.
|
||||
*
|
||||
**/
|
||||
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
|
||||
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
|
||||
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_extents_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @glyph: The glyph ID to query
|
||||
* @extents: (out): The #hb_glyph_extents_t retrieved
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the extents for a specified glyph. Extents must be
|
||||
* returned in an #hb_glyph_extents output parameter.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t glyph,
|
||||
hb_glyph_extents_t *extents,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_contour_point_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @glyph: The glyph ID to query
|
||||
* @point_index: The contour-point index to query
|
||||
* @x: (out): The X value retrieved for the contour point
|
||||
* @y: (out): The Y value retrieved for the contour point
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the (X,Y) coordinates (in font units) for a
|
||||
* specified contour point in a glyph. Each coordinate must be returned as
|
||||
* an #hb_position_t output parameter.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t glyph, unsigned int point_index,
|
||||
hb_position_t *x, hb_position_t *y,
|
||||
void *user_data);
|
||||
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_name_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @glyph: The glyph ID to query
|
||||
* @name: (out) (array length=size): Name string retrieved for the glyph ID
|
||||
* @size: Length of the glyph-name string retrieved
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the glyph name that corresponds to a
|
||||
* glyph ID. The name should be returned in a string output parameter.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
|
||||
hb_codepoint_t glyph,
|
||||
char *name, unsigned int size,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* hb_font_get_glyph_from_name_func_t:
|
||||
* @font: #hb_font_t to work upon
|
||||
* @font_data: @font user data pointer
|
||||
* @name: (array length=len): The name string to query
|
||||
* @len: The length of the name queried
|
||||
* @glyph: (out): The glyph ID retrieved
|
||||
* @user_data: User data pointer passed by the caller
|
||||
*
|
||||
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||
*
|
||||
* This method should retrieve the glyph ID that corresponds to a glyph-name
|
||||
* string.
|
||||
*
|
||||
* Return value: %true if data found, %false otherwise
|
||||
*
|
||||
**/
|
||||
typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
|
||||
const char *name, int len, /* -1 means nul-terminated */
|
||||
hb_codepoint_t *glyph,
|
||||
@@ -170,12 +516,12 @@ typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_font_h_extents_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
*
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_font_h_extents_func_t.
|
||||
*
|
||||
* Since: 1.1.2
|
||||
**/
|
||||
@@ -186,12 +532,12 @@ hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_font_v_extents_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
*
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_font_v_extents_func_t.
|
||||
*
|
||||
* Since: 1.1.2
|
||||
**/
|
||||
@@ -202,12 +548,12 @@ hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_nominal_glyph_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_nominal_glyph_func_t.
|
||||
*
|
||||
* Since: 1.2.3
|
||||
**/
|
||||
@@ -217,13 +563,29 @@ hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs,
|
||||
void *user_data, hb_destroy_func_t destroy);
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_variation_glyph_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* hb_font_funcs_set_nominal_glyphs_func:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_nominal_glyphs_func_t.
|
||||
*
|
||||
* Since: 2.0.0
|
||||
**/
|
||||
HB_EXTERN void
|
||||
hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs,
|
||||
hb_font_get_nominal_glyphs_func_t func,
|
||||
void *user_data, hb_destroy_func_t destroy);
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_variation_glyph_func:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_variation_glyph_func_t.
|
||||
*
|
||||
* Since: 1.2.3
|
||||
**/
|
||||
@@ -234,12 +596,12 @@ hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_h_advance_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_h_advance_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -250,12 +612,12 @@ hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_v_advance_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_v_advance_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -265,13 +627,45 @@ hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
|
||||
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:
|
||||
* hb_font_funcs_set_glyph_h_advances_func:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_h_advances_func_t.
|
||||
*
|
||||
* Since: 1.8.6
|
||||
**/
|
||||
HB_EXTERN void
|
||||
hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs,
|
||||
hb_font_get_glyph_h_advances_func_t func,
|
||||
void *user_data, hb_destroy_func_t destroy);
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_v_advances_func:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_v_advances_func_t.
|
||||
*
|
||||
* Since: 1.8.6
|
||||
**/
|
||||
HB_EXTERN void
|
||||
hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs,
|
||||
hb_font_get_glyph_v_advances_func_t func,
|
||||
void *user_data, hb_destroy_func_t destroy);
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_h_origin_func:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_h_origin_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -282,12 +676,12 @@ hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_v_origin_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_v_origin_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -298,12 +692,12 @@ hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_h_kerning_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_h_kerning_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -312,30 +706,14 @@ 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: 0.9.2
|
||||
**/
|
||||
HB_EXTERN 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:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_extents_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -346,12 +724,12 @@ hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_contour_point_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_contour_point_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -362,12 +740,12 @@ hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_name_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_name_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -378,12 +756,12 @@ hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
|
||||
|
||||
/**
|
||||
* hb_font_funcs_set_glyph_from_name_func:
|
||||
* @ffuncs: font functions.
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified):
|
||||
* @user_data:
|
||||
* @destroy:
|
||||
* @ffuncs: A font-function structure
|
||||
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||
* @user_data: Data to pass to @func
|
||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||
*
|
||||
*
|
||||
* Sets the implementation function for #hb_font_get_glyph_from_name_func_t.
|
||||
*
|
||||
* Since: 0.9.2
|
||||
**/
|
||||
@@ -410,6 +788,14 @@ hb_font_get_variation_glyph (hb_font_t *font,
|
||||
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
|
||||
hb_codepoint_t *glyph);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_font_get_nominal_glyphs (hb_font_t *font,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_unicode,
|
||||
unsigned int unicode_stride,
|
||||
hb_codepoint_t *first_glyph,
|
||||
unsigned int glyph_stride);
|
||||
|
||||
HB_EXTERN hb_position_t
|
||||
hb_font_get_glyph_h_advance (hb_font_t *font,
|
||||
hb_codepoint_t glyph);
|
||||
@@ -417,6 +803,21 @@ HB_EXTERN hb_position_t
|
||||
hb_font_get_glyph_v_advance (hb_font_t *font,
|
||||
hb_codepoint_t glyph);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_font_get_glyph_h_advances (hb_font_t* font,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned glyph_stride,
|
||||
hb_position_t *first_advance,
|
||||
unsigned advance_stride);
|
||||
HB_EXTERN void
|
||||
hb_font_get_glyph_v_advances (hb_font_t* font,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned glyph_stride,
|
||||
hb_position_t *first_advance,
|
||||
unsigned advance_stride);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_font_get_glyph_h_origin (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
@@ -429,9 +830,6 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
|
||||
HB_EXTERN hb_position_t
|
||||
hb_font_get_glyph_h_kerning (hb_font_t *font,
|
||||
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
|
||||
HB_EXTERN hb_position_t
|
||||
hb_font_get_glyph_v_kerning (hb_font_t *font,
|
||||
hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_font_get_glyph_extents (hb_font_t *font,
|
||||
@@ -456,7 +854,7 @@ hb_font_get_glyph_from_name (hb_font_t *font,
|
||||
/* high-level funcs, with fallback */
|
||||
|
||||
/* Calls either hb_font_get_nominal_glyph() if variation_selector is 0,
|
||||
* otherwise callse hb_font_get_variation_glyph(). */
|
||||
* otherwise calls hb_font_get_variation_glyph(). */
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_font_get_glyph (hb_font_t *font,
|
||||
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
|
||||
@@ -472,6 +870,14 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y);
|
||||
HB_EXTERN void
|
||||
hb_font_get_glyph_advances_for_direction (hb_font_t* font,
|
||||
hb_direction_t direction,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned glyph_stride,
|
||||
hb_position_t *first_advance,
|
||||
unsigned advance_stride);
|
||||
HB_EXTERN void
|
||||
hb_font_get_glyph_origin_for_direction (hb_font_t *font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
@@ -580,8 +986,8 @@ hb_font_set_funcs (hb_font_t *font,
|
||||
/* Be *very* careful with this function! */
|
||||
HB_EXTERN void
|
||||
hb_font_set_funcs_data (hb_font_t *font,
|
||||
void *font_data,
|
||||
hb_destroy_func_t destroy);
|
||||
void *font_data,
|
||||
hb_destroy_func_t destroy);
|
||||
|
||||
|
||||
HB_EXTERN void
|
||||
@@ -607,6 +1013,16 @@ hb_font_get_ppem (hb_font_t *font,
|
||||
unsigned int *x_ppem,
|
||||
unsigned int *y_ppem);
|
||||
|
||||
/*
|
||||
* Point size per EM. Used for optical-sizing in CoreText.
|
||||
* A value of zero means "not set".
|
||||
*/
|
||||
HB_EXTERN void
|
||||
hb_font_set_ptem (hb_font_t *font, float ptem);
|
||||
|
||||
HB_EXTERN float
|
||||
hb_font_get_ptem (hb_font_t *font);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_font_set_variations (hb_font_t *font,
|
||||
const hb_variation_t *variations,
|
||||
@@ -617,6 +1033,12 @@ hb_font_set_var_coords_design (hb_font_t *font,
|
||||
const float *coords,
|
||||
unsigned int coords_length);
|
||||
|
||||
#ifdef HB_EXPERIMENTAL_API
|
||||
HB_EXTERN const float *
|
||||
hb_font_get_var_coords_design (hb_font_t *font,
|
||||
unsigned int *length);
|
||||
#endif
|
||||
|
||||
HB_EXTERN void
|
||||
hb_font_set_var_coords_normalized (hb_font_t *font,
|
||||
const int *coords, /* 2.14 normalized */
|
||||
@@ -626,6 +1048,16 @@ HB_EXTERN const int *
|
||||
hb_font_get_var_coords_normalized (hb_font_t *font,
|
||||
unsigned int *length);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_font_set_var_named_instance (hb_font_t *font,
|
||||
unsigned instance_index);
|
||||
|
||||
#ifdef HB_EXPERIMENTAL_API
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph,
|
||||
const hb_draw_funcs_t *funcs, void *user_data);
|
||||
#endif
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#endif /* HB_FONT_H */
|
||||
|
||||
@@ -26,15 +26,13 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#ifndef HB_FONT_PRIVATE_HH
|
||||
#define HB_FONT_PRIVATE_HH
|
||||
#ifndef HB_FONT_HH
|
||||
#define HB_FONT_HH
|
||||
|
||||
#include "hb-private.hh"
|
||||
|
||||
#include "hb-object-private.hh"
|
||||
#include "hb-face-private.hh"
|
||||
#include "hb-shaper-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
#include "hb-face.hh"
|
||||
#include "hb-shaper.hh"
|
||||
|
||||
|
||||
/*
|
||||
@@ -45,24 +43,25 @@
|
||||
HB_FONT_FUNC_IMPLEMENT (font_h_extents) \
|
||||
HB_FONT_FUNC_IMPLEMENT (font_v_extents) \
|
||||
HB_FONT_FUNC_IMPLEMENT (nominal_glyph) \
|
||||
HB_FONT_FUNC_IMPLEMENT (nominal_glyphs) \
|
||||
HB_FONT_FUNC_IMPLEMENT (variation_glyph) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_h_advances) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_v_advances) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \
|
||||
HB_IF_NOT_DEPRECATED (HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning)) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_extents) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_name) \
|
||||
HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \
|
||||
/* ^--- Add new callbacks here */
|
||||
|
||||
struct hb_font_funcs_t {
|
||||
struct hb_font_funcs_t
|
||||
{
|
||||
hb_object_header_t header;
|
||||
ASSERT_POD ();
|
||||
|
||||
hb_bool_t immutable;
|
||||
|
||||
struct {
|
||||
#define HB_FONT_FUNC_IMPLEMENT(name) void *name;
|
||||
@@ -83,85 +82,90 @@ struct hb_font_funcs_t {
|
||||
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
||||
#undef HB_FONT_FUNC_IMPLEMENT
|
||||
} f;
|
||||
void (*array[VAR]) (void);
|
||||
void (*array[0
|
||||
#define HB_FONT_FUNC_IMPLEMENT(name) +1
|
||||
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
||||
#undef HB_FONT_FUNC_IMPLEMENT
|
||||
]) ();
|
||||
} get;
|
||||
};
|
||||
|
||||
DECLARE_NULL_INSTANCE (hb_font_funcs_t);
|
||||
|
||||
|
||||
/*
|
||||
* hb_font_t
|
||||
*/
|
||||
|
||||
struct hb_font_t {
|
||||
hb_object_header_t header;
|
||||
ASSERT_POD ();
|
||||
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, font);
|
||||
#include "hb-shaper-list.hh"
|
||||
#undef HB_SHAPER_IMPLEMENT
|
||||
|
||||
hb_bool_t immutable;
|
||||
struct hb_font_t
|
||||
{
|
||||
hb_object_header_t header;
|
||||
|
||||
hb_font_t *parent;
|
||||
hb_face_t *face;
|
||||
|
||||
int x_scale;
|
||||
int y_scale;
|
||||
int32_t x_scale;
|
||||
int32_t y_scale;
|
||||
int64_t x_mult;
|
||||
int64_t y_mult;
|
||||
|
||||
unsigned int x_ppem;
|
||||
unsigned int y_ppem;
|
||||
|
||||
float ptem;
|
||||
|
||||
/* Font variation coordinates. */
|
||||
unsigned int num_coords;
|
||||
int *coords;
|
||||
float *design_coords;
|
||||
|
||||
hb_font_funcs_t *klass;
|
||||
void *user_data;
|
||||
hb_destroy_func_t destroy;
|
||||
|
||||
enum dirty_t {
|
||||
DIRTY_NOTHING = 0x0000,
|
||||
DIRTY_FACE = 0x0001,
|
||||
DIRTY_PARENT = 0x0002,
|
||||
DIRTY_FUNCS = 0x0004,
|
||||
DIRTY_SCALE = 0x0008,
|
||||
DIRTY_PPEM = 0x0010,
|
||||
DIRTY_VARIATIONS = 0x0020,
|
||||
} dirty;
|
||||
|
||||
struct hb_shaper_data_t shaper_data;
|
||||
hb_shaper_object_dataset_t<hb_font_t> data; /* Various shaper data. */
|
||||
|
||||
|
||||
/* Convert from font-space to user-space */
|
||||
inline int dir_scale (hb_direction_t direction)
|
||||
{ return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; }
|
||||
inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); }
|
||||
inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); }
|
||||
inline hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); }
|
||||
inline hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); }
|
||||
inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction)
|
||||
{ return em_scale (v, dir_scale (direction)); }
|
||||
int64_t dir_mult (hb_direction_t direction)
|
||||
{ return HB_DIRECTION_IS_VERTICAL(direction) ? y_mult : x_mult; }
|
||||
hb_position_t em_scale_x (int16_t v) { return em_mult (v, x_mult); }
|
||||
hb_position_t em_scale_y (int16_t v) { return em_mult (v, y_mult); }
|
||||
hb_position_t em_scalef_x (float v) { return em_scalef (v, x_scale); }
|
||||
hb_position_t em_scalef_y (float v) { return em_scalef (v, y_scale); }
|
||||
float em_fscale_x (int16_t v) { return em_fscale (v, x_scale); }
|
||||
float em_fscale_y (int16_t v) { return em_fscale (v, y_scale); }
|
||||
hb_position_t em_scale_dir (int16_t v, hb_direction_t direction)
|
||||
{ return em_mult (v, dir_mult (direction)); }
|
||||
|
||||
/* Convert from parent-font user-space to our user-space */
|
||||
inline hb_position_t parent_scale_x_distance (hb_position_t v) {
|
||||
hb_position_t parent_scale_x_distance (hb_position_t v)
|
||||
{
|
||||
if (unlikely (parent && parent->x_scale != x_scale))
|
||||
return (hb_position_t) (v * (int64_t) this->x_scale / this->parent->x_scale);
|
||||
return v;
|
||||
}
|
||||
inline hb_position_t parent_scale_y_distance (hb_position_t v) {
|
||||
hb_position_t parent_scale_y_distance (hb_position_t v)
|
||||
{
|
||||
if (unlikely (parent && parent->y_scale != y_scale))
|
||||
return (hb_position_t) (v * (int64_t) this->y_scale / this->parent->y_scale);
|
||||
return v;
|
||||
}
|
||||
inline hb_position_t parent_scale_x_position (hb_position_t v) {
|
||||
return parent_scale_x_distance (v);
|
||||
}
|
||||
inline hb_position_t parent_scale_y_position (hb_position_t v) {
|
||||
return parent_scale_y_distance (v);
|
||||
}
|
||||
hb_position_t parent_scale_x_position (hb_position_t v)
|
||||
{ return parent_scale_x_distance (v); }
|
||||
hb_position_t parent_scale_y_position (hb_position_t v)
|
||||
{ return parent_scale_y_distance (v); }
|
||||
|
||||
inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) {
|
||||
void parent_scale_distance (hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
*x = parent_scale_x_distance (*x);
|
||||
*y = parent_scale_y_distance (*y);
|
||||
}
|
||||
inline void parent_scale_position (hb_position_t *x, hb_position_t *y) {
|
||||
void parent_scale_position (hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
*x = parent_scale_x_position (*x);
|
||||
*y = parent_scale_y_position (*y);
|
||||
}
|
||||
@@ -170,27 +174,35 @@ struct hb_font_t {
|
||||
/* Public getters */
|
||||
|
||||
HB_INTERNAL bool has_func (unsigned int i);
|
||||
HB_INTERNAL bool has_func_set (unsigned int i);
|
||||
|
||||
/* has_* ... */
|
||||
#define HB_FONT_FUNC_IMPLEMENT(name) \
|
||||
bool \
|
||||
has_##name##_func (void) \
|
||||
has_##name##_func () \
|
||||
{ \
|
||||
hb_font_funcs_t *funcs = this->klass; \
|
||||
unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \
|
||||
return has_func (i); \
|
||||
} \
|
||||
bool \
|
||||
has_##name##_func_set () \
|
||||
{ \
|
||||
hb_font_funcs_t *funcs = this->klass; \
|
||||
unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \
|
||||
return has_func_set (i); \
|
||||
}
|
||||
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
||||
#undef HB_FONT_FUNC_IMPLEMENT
|
||||
|
||||
inline hb_bool_t get_font_h_extents (hb_font_extents_t *extents)
|
||||
hb_bool_t get_font_h_extents (hb_font_extents_t *extents)
|
||||
{
|
||||
memset (extents, 0, sizeof (*extents));
|
||||
return klass->get.f.font_h_extents (this, user_data,
|
||||
extents,
|
||||
klass->user_data.font_h_extents);
|
||||
}
|
||||
inline hb_bool_t get_font_v_extents (hb_font_extents_t *extents)
|
||||
hb_bool_t get_font_v_extents (hb_font_extents_t *extents)
|
||||
{
|
||||
memset (extents, 0, sizeof (*extents));
|
||||
return klass->get.f.font_v_extents (this, user_data,
|
||||
@@ -198,23 +210,35 @@ struct hb_font_t {
|
||||
klass->user_data.font_v_extents);
|
||||
}
|
||||
|
||||
inline bool has_glyph (hb_codepoint_t unicode)
|
||||
bool has_glyph (hb_codepoint_t unicode)
|
||||
{
|
||||
hb_codepoint_t glyph;
|
||||
return get_nominal_glyph (unicode, &glyph);
|
||||
}
|
||||
|
||||
inline hb_bool_t get_nominal_glyph (hb_codepoint_t unicode,
|
||||
hb_codepoint_t *glyph)
|
||||
hb_bool_t get_nominal_glyph (hb_codepoint_t unicode,
|
||||
hb_codepoint_t *glyph)
|
||||
{
|
||||
*glyph = 0;
|
||||
return klass->get.f.nominal_glyph (this, user_data,
|
||||
unicode, glyph,
|
||||
klass->user_data.nominal_glyph);
|
||||
}
|
||||
unsigned int get_nominal_glyphs (unsigned int count,
|
||||
const hb_codepoint_t *first_unicode,
|
||||
unsigned int unicode_stride,
|
||||
hb_codepoint_t *first_glyph,
|
||||
unsigned int glyph_stride)
|
||||
{
|
||||
return klass->get.f.nominal_glyphs (this, user_data,
|
||||
count,
|
||||
first_unicode, unicode_stride,
|
||||
first_glyph, glyph_stride,
|
||||
klass->user_data.nominal_glyphs);
|
||||
}
|
||||
|
||||
inline hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector,
|
||||
hb_codepoint_t *glyph)
|
||||
hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector,
|
||||
hb_codepoint_t *glyph)
|
||||
{
|
||||
*glyph = 0;
|
||||
return klass->get.f.variation_glyph (this, user_data,
|
||||
@@ -222,22 +246,48 @@ struct hb_font_t {
|
||||
klass->user_data.variation_glyph);
|
||||
}
|
||||
|
||||
inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph)
|
||||
hb_position_t get_glyph_h_advance (hb_codepoint_t glyph)
|
||||
{
|
||||
return klass->get.f.glyph_h_advance (this, user_data,
|
||||
glyph,
|
||||
klass->user_data.glyph_h_advance);
|
||||
}
|
||||
|
||||
inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph)
|
||||
hb_position_t get_glyph_v_advance (hb_codepoint_t glyph)
|
||||
{
|
||||
return klass->get.f.glyph_v_advance (this, user_data,
|
||||
glyph,
|
||||
klass->user_data.glyph_v_advance);
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void get_glyph_h_advances (unsigned int count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned int glyph_stride,
|
||||
hb_position_t *first_advance,
|
||||
unsigned int advance_stride)
|
||||
{
|
||||
return klass->get.f.glyph_h_advances (this, user_data,
|
||||
count,
|
||||
first_glyph, glyph_stride,
|
||||
first_advance, advance_stride,
|
||||
klass->user_data.glyph_h_advances);
|
||||
}
|
||||
|
||||
void get_glyph_v_advances (unsigned int count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned int glyph_stride,
|
||||
hb_position_t *first_advance,
|
||||
unsigned int advance_stride)
|
||||
{
|
||||
return klass->get.f.glyph_v_advances (this, user_data,
|
||||
count,
|
||||
first_glyph, glyph_stride,
|
||||
first_advance, advance_stride,
|
||||
klass->user_data.glyph_v_advances);
|
||||
}
|
||||
|
||||
hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
*x = *y = 0;
|
||||
return klass->get.f.glyph_h_origin (this, user_data,
|
||||
@@ -245,8 +295,8 @@ struct hb_font_t {
|
||||
klass->user_data.glyph_h_origin);
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
*x = *y = 0;
|
||||
return klass->get.f.glyph_v_origin (this, user_data,
|
||||
@@ -254,22 +304,32 @@ struct hb_font_t {
|
||||
klass->user_data.glyph_v_origin);
|
||||
}
|
||||
|
||||
inline hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
|
||||
hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph,
|
||||
hb_codepoint_t right_glyph)
|
||||
{
|
||||
#ifdef HB_DISABLE_DEPRECATED
|
||||
return 0;
|
||||
#else
|
||||
return klass->get.f.glyph_h_kerning (this, user_data,
|
||||
left_glyph, right_glyph,
|
||||
klass->user_data.glyph_h_kerning);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph)
|
||||
hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph,
|
||||
hb_codepoint_t bottom_glyph)
|
||||
{
|
||||
#ifdef HB_DISABLE_DEPRECATED
|
||||
return 0;
|
||||
#else
|
||||
return klass->get.f.glyph_v_kerning (this, user_data,
|
||||
top_glyph, bottom_glyph,
|
||||
klass->user_data.glyph_v_kerning);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_extents (hb_codepoint_t glyph,
|
||||
hb_glyph_extents_t *extents)
|
||||
hb_bool_t get_glyph_extents (hb_codepoint_t glyph,
|
||||
hb_glyph_extents_t *extents)
|
||||
{
|
||||
memset (extents, 0, sizeof (*extents));
|
||||
return klass->get.f.glyph_extents (this, user_data,
|
||||
@@ -278,8 +338,8 @@ struct hb_font_t {
|
||||
klass->user_data.glyph_extents);
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
*x = *y = 0;
|
||||
return klass->get.f.glyph_contour_point (this, user_data,
|
||||
@@ -288,8 +348,8 @@ struct hb_font_t {
|
||||
klass->user_data.glyph_contour_point);
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_name (hb_codepoint_t glyph,
|
||||
char *name, unsigned int size)
|
||||
hb_bool_t get_glyph_name (hb_codepoint_t glyph,
|
||||
char *name, unsigned int size)
|
||||
{
|
||||
if (size) *name = '\0';
|
||||
return klass->get.f.glyph_name (this, user_data,
|
||||
@@ -298,8 +358,8 @@ struct hb_font_t {
|
||||
klass->user_data.glyph_name);
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */
|
||||
hb_codepoint_t *glyph)
|
||||
hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */
|
||||
hb_codepoint_t *glyph)
|
||||
{
|
||||
*glyph = 0;
|
||||
if (len == -1) len = strlen (name);
|
||||
@@ -312,7 +372,7 @@ struct hb_font_t {
|
||||
|
||||
/* A bit higher-level, and with fallback */
|
||||
|
||||
inline void get_h_extents_with_fallback (hb_font_extents_t *extents)
|
||||
void get_h_extents_with_fallback (hb_font_extents_t *extents)
|
||||
{
|
||||
if (!get_font_h_extents (extents))
|
||||
{
|
||||
@@ -321,7 +381,7 @@ struct hb_font_t {
|
||||
extents->line_gap = 0;
|
||||
}
|
||||
}
|
||||
inline void get_v_extents_with_fallback (hb_font_extents_t *extents)
|
||||
void get_v_extents_with_fallback (hb_font_extents_t *extents)
|
||||
{
|
||||
if (!get_font_v_extents (extents))
|
||||
{
|
||||
@@ -331,8 +391,8 @@ struct hb_font_t {
|
||||
}
|
||||
}
|
||||
|
||||
inline void get_extents_for_direction (hb_direction_t direction,
|
||||
hb_font_extents_t *extents)
|
||||
void get_extents_for_direction (hb_direction_t direction,
|
||||
hb_font_extents_t *extents)
|
||||
{
|
||||
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
||||
get_h_extents_with_fallback (extents);
|
||||
@@ -340,21 +400,31 @@ struct hb_font_t {
|
||||
get_v_extents_with_fallback (extents);
|
||||
}
|
||||
|
||||
inline void get_glyph_advance_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void get_glyph_advance_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
|
||||
*x = *y = 0;
|
||||
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
||||
*x = get_glyph_h_advance (glyph);
|
||||
*y = 0;
|
||||
} else {
|
||||
*x = 0;
|
||||
else
|
||||
*y = get_glyph_v_advance (glyph);
|
||||
}
|
||||
}
|
||||
void get_glyph_advances_for_direction (hb_direction_t direction,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned glyph_stride,
|
||||
hb_position_t *first_advance,
|
||||
unsigned advance_stride)
|
||||
{
|
||||
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
||||
get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
|
||||
else
|
||||
get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
|
||||
}
|
||||
|
||||
inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void guess_v_origin_minus_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
*x = get_glyph_h_advance (glyph) / 2;
|
||||
|
||||
@@ -364,8 +434,8 @@ struct hb_font_t {
|
||||
*y = extents.ascender;
|
||||
}
|
||||
|
||||
inline void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
if (!get_glyph_h_origin (glyph, x, y) &&
|
||||
get_glyph_v_origin (glyph, x, y))
|
||||
@@ -375,8 +445,8 @@ struct hb_font_t {
|
||||
*x -= dx; *y -= dy;
|
||||
}
|
||||
}
|
||||
inline void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
if (!get_glyph_v_origin (glyph, x, y) &&
|
||||
get_glyph_h_origin (glyph, x, y))
|
||||
@@ -387,9 +457,9 @@ struct hb_font_t {
|
||||
}
|
||||
}
|
||||
|
||||
inline void get_glyph_origin_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void get_glyph_origin_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
||||
get_glyph_h_origin_with_fallback (glyph, x, y);
|
||||
@@ -397,8 +467,8 @@ struct hb_font_t {
|
||||
get_glyph_v_origin_with_fallback (glyph, x, y);
|
||||
}
|
||||
|
||||
inline void add_glyph_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void add_glyph_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
@@ -407,8 +477,8 @@ struct hb_font_t {
|
||||
*x += origin_x;
|
||||
*y += origin_y;
|
||||
}
|
||||
inline void add_glyph_v_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void add_glyph_v_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
@@ -417,9 +487,9 @@ struct hb_font_t {
|
||||
*x += origin_x;
|
||||
*y += origin_y;
|
||||
}
|
||||
inline void add_glyph_origin_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void add_glyph_origin_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
@@ -429,8 +499,8 @@ struct hb_font_t {
|
||||
*y += origin_y;
|
||||
}
|
||||
|
||||
inline void subtract_glyph_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void subtract_glyph_h_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
@@ -439,8 +509,8 @@ struct hb_font_t {
|
||||
*x -= origin_x;
|
||||
*y -= origin_y;
|
||||
}
|
||||
inline void subtract_glyph_v_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void subtract_glyph_v_origin (hb_codepoint_t glyph,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
@@ -449,9 +519,9 @@ struct hb_font_t {
|
||||
*x -= origin_x;
|
||||
*y -= origin_y;
|
||||
}
|
||||
inline void subtract_glyph_origin_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void subtract_glyph_origin_for_direction (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_position_t origin_x, origin_y;
|
||||
|
||||
@@ -461,22 +531,22 @@ struct hb_font_t {
|
||||
*y -= origin_y;
|
||||
}
|
||||
|
||||
inline void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
|
||||
*x = get_glyph_h_kerning (first_glyph, second_glyph);
|
||||
*y = 0;
|
||||
*x = get_glyph_h_kerning (first_glyph, second_glyph);
|
||||
} else {
|
||||
*x = 0;
|
||||
*y = get_glyph_v_kerning (first_glyph, second_glyph);
|
||||
}
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_glyph_extents_t *extents)
|
||||
hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph,
|
||||
hb_direction_t direction,
|
||||
hb_glyph_extents_t *extents)
|
||||
{
|
||||
hb_bool_t ret = get_glyph_extents (glyph, extents);
|
||||
|
||||
@@ -486,9 +556,9 @@ struct hb_font_t {
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index,
|
||||
hb_direction_t direction,
|
||||
hb_position_t *x, hb_position_t *y)
|
||||
{
|
||||
hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y);
|
||||
|
||||
@@ -499,7 +569,7 @@ struct hb_font_t {
|
||||
}
|
||||
|
||||
/* Generates gidDDD if glyph has no name. */
|
||||
inline void
|
||||
void
|
||||
glyph_to_string (hb_codepoint_t glyph,
|
||||
char *s, unsigned int size)
|
||||
{
|
||||
@@ -510,7 +580,7 @@ struct hb_font_t {
|
||||
}
|
||||
|
||||
/* Parses gidDDD and uniUUUU strings automatically. */
|
||||
inline hb_bool_t
|
||||
hb_bool_t
|
||||
glyph_from_string (const char *s, int len, /* -1 means nul-terminated */
|
||||
hb_codepoint_t *glyph)
|
||||
{
|
||||
@@ -540,26 +610,23 @@ struct hb_font_t {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline hb_position_t em_scale (int16_t v, int scale)
|
||||
void mults_changed ()
|
||||
{
|
||||
int upem = face->get_upem ();
|
||||
int64_t scaled = v * (int64_t) scale;
|
||||
scaled += scaled >= 0 ? upem/2 : -upem/2; /* Round. */
|
||||
return (hb_position_t) (scaled / upem);
|
||||
signed upem = face->get_upem ();
|
||||
x_mult = ((int64_t) x_scale << 16) / upem;
|
||||
y_mult = ((int64_t) y_scale << 16) / upem;
|
||||
}
|
||||
inline hb_position_t em_scalef (float v, int scale)
|
||||
|
||||
hb_position_t em_mult (int16_t v, int64_t mult)
|
||||
{
|
||||
return (hb_position_t) (v * scale / face->get_upem ());
|
||||
return (hb_position_t) ((v * mult) >> 16);
|
||||
}
|
||||
hb_position_t em_scalef (float v, int scale)
|
||||
{ return (hb_position_t) roundf (v * scale / face->get_upem ()); }
|
||||
float em_fscale (int16_t v, int scale)
|
||||
{ return (float) v * scale / face->get_upem (); }
|
||||
};
|
||||
|
||||
HB_MARK_AS_FLAG_T (hb_font_t::dirty_t);
|
||||
|
||||
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
|
||||
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font);
|
||||
#include "hb-shaper-list.hh"
|
||||
#undef HB_SHAPER_IMPLEMENT
|
||||
#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
|
||||
DECLARE_NULL_INSTANCE (hb_font_t);
|
||||
|
||||
|
||||
#endif /* HB_FONT_PRIVATE_HH */
|
||||
#endif /* HB_FONT_HH */
|
||||
+452
-173
File diff suppressed because it is too large
Load Diff
@@ -110,13 +110,25 @@ hb_ft_font_create_referenced (FT_Face ft_face);
|
||||
HB_EXTERN FT_Face
|
||||
hb_ft_font_get_face (hb_font_t *font);
|
||||
|
||||
HB_EXTERN FT_Face
|
||||
hb_ft_font_lock_face (hb_font_t *font);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_ft_font_unlock_face (hb_font_t *font);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_ft_font_set_load_flags (hb_font_t *font, int load_flags);
|
||||
|
||||
HB_EXTERN int
|
||||
hb_ft_font_get_load_flags (hb_font_t *font);
|
||||
|
||||
/* Makes an hb_font_t use FreeType internally to implement font functions. */
|
||||
/* Call when size or variations settings on underlying FT_Face change. */
|
||||
HB_EXTERN void
|
||||
hb_ft_font_changed (hb_font_t *font);
|
||||
|
||||
/* Makes an hb_font_t use FreeType internally to implement font functions.
|
||||
* Note: this internally creates an FT_Face. Use it when you create your
|
||||
* hb_face_t using hb_face_create(). */
|
||||
HB_EXTERN void
|
||||
hb_ft_font_set_funcs (hb_font_t *font);
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright © 2019 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "hb.hh"
|
||||
|
||||
#ifdef HAVE_GDI
|
||||
|
||||
#include "hb-gdi.h"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:hb-gdi
|
||||
* @title: hb-gdi
|
||||
* @short_description: GDI integration
|
||||
* @include: hb-gdi.h
|
||||
*
|
||||
* Functions for using HarfBuzz with GDI fonts.
|
||||
**/
|
||||
|
||||
static hb_blob_t *
|
||||
_hb_gdi_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
|
||||
{
|
||||
char *buffer = nullptr;
|
||||
DWORD length = 0;
|
||||
|
||||
HDC hdc = GetDC (nullptr);
|
||||
if (unlikely (!SelectObject (hdc, (HFONT) user_data))) goto fail;
|
||||
|
||||
length = GetFontData (hdc, hb_uint32_swap (tag), 0, buffer, length);
|
||||
if (unlikely (length == GDI_ERROR)) goto fail_with_releasedc;
|
||||
|
||||
buffer = (char *) hb_malloc (length);
|
||||
if (unlikely (!buffer)) goto fail_with_releasedc;
|
||||
length = GetFontData (hdc, hb_uint32_swap (tag), 0, buffer, length);
|
||||
if (unlikely (length == GDI_ERROR)) goto fail_with_releasedc_and_free;
|
||||
ReleaseDC (nullptr, hdc);
|
||||
|
||||
return hb_blob_create ((const char *) buffer, length, HB_MEMORY_MODE_WRITABLE, buffer, hb_free);
|
||||
|
||||
fail_with_releasedc_and_free:
|
||||
hb_free (buffer);
|
||||
fail_with_releasedc:
|
||||
ReleaseDC (nullptr, hdc);
|
||||
fail:
|
||||
return hb_blob_get_empty ();
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_gdi_face_create:
|
||||
* @hfont: a HFONT object.
|
||||
*
|
||||
* Constructs a new face object from the specified GDI HFONT.
|
||||
*
|
||||
* Return value: #hb_face_t object corresponding to the given input
|
||||
*
|
||||
* Since: 2.6.0
|
||||
**/
|
||||
hb_face_t *
|
||||
hb_gdi_face_create (HFONT hfont)
|
||||
{
|
||||
return hb_face_create_for_tables (_hb_gdi_reference_table, (void *) hfont, nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright © 2019 Ebrahim Byagowi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HB_GDI_H
|
||||
#define HB_GDI_H
|
||||
|
||||
#include "hb.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
HB_EXTERN hb_face_t *
|
||||
hb_gdi_face_create (HFONT hfont);
|
||||
|
||||
HB_END_DECLS
|
||||
|
||||
#endif /* HB_GDI_H */
|
||||
+102
-197
@@ -26,169 +26,61 @@
|
||||
* Google Author(s): Behdad Esfahbod
|
||||
*/
|
||||
|
||||
#include "hb-private.hh"
|
||||
#include "hb.hh"
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
|
||||
#include "hb-glib.h"
|
||||
|
||||
#include "hb-unicode-private.hh"
|
||||
#include "hb-machinery.hh"
|
||||
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,29,14)
|
||||
static const hb_script_t
|
||||
glib_script_to_script[] =
|
||||
{
|
||||
HB_SCRIPT_COMMON,
|
||||
HB_SCRIPT_INHERITED,
|
||||
HB_SCRIPT_ARABIC,
|
||||
HB_SCRIPT_ARMENIAN,
|
||||
HB_SCRIPT_BENGALI,
|
||||
HB_SCRIPT_BOPOMOFO,
|
||||
HB_SCRIPT_CHEROKEE,
|
||||
HB_SCRIPT_COPTIC,
|
||||
HB_SCRIPT_CYRILLIC,
|
||||
HB_SCRIPT_DESERET,
|
||||
HB_SCRIPT_DEVANAGARI,
|
||||
HB_SCRIPT_ETHIOPIC,
|
||||
HB_SCRIPT_GEORGIAN,
|
||||
HB_SCRIPT_GOTHIC,
|
||||
HB_SCRIPT_GREEK,
|
||||
HB_SCRIPT_GUJARATI,
|
||||
HB_SCRIPT_GURMUKHI,
|
||||
HB_SCRIPT_HAN,
|
||||
HB_SCRIPT_HANGUL,
|
||||
HB_SCRIPT_HEBREW,
|
||||
HB_SCRIPT_HIRAGANA,
|
||||
HB_SCRIPT_KANNADA,
|
||||
HB_SCRIPT_KATAKANA,
|
||||
HB_SCRIPT_KHMER,
|
||||
HB_SCRIPT_LAO,
|
||||
HB_SCRIPT_LATIN,
|
||||
HB_SCRIPT_MALAYALAM,
|
||||
HB_SCRIPT_MONGOLIAN,
|
||||
HB_SCRIPT_MYANMAR,
|
||||
HB_SCRIPT_OGHAM,
|
||||
HB_SCRIPT_OLD_ITALIC,
|
||||
HB_SCRIPT_ORIYA,
|
||||
HB_SCRIPT_RUNIC,
|
||||
HB_SCRIPT_SINHALA,
|
||||
HB_SCRIPT_SYRIAC,
|
||||
HB_SCRIPT_TAMIL,
|
||||
HB_SCRIPT_TELUGU,
|
||||
HB_SCRIPT_THAANA,
|
||||
HB_SCRIPT_THAI,
|
||||
HB_SCRIPT_TIBETAN,
|
||||
HB_SCRIPT_CANADIAN_SYLLABICS,
|
||||
HB_SCRIPT_YI,
|
||||
HB_SCRIPT_TAGALOG,
|
||||
HB_SCRIPT_HANUNOO,
|
||||
HB_SCRIPT_BUHID,
|
||||
HB_SCRIPT_TAGBANWA,
|
||||
/**
|
||||
* SECTION:hb-glib
|
||||
* @title: hb-glib
|
||||
* @short_description: GLib integration
|
||||
* @include: hb-glib.h
|
||||
*
|
||||
* Functions for using HarfBuzz with the GLib library.
|
||||
*
|
||||
* HarfBuzz supports using GLib to provide Unicode data, by attaching
|
||||
* GLib functions to the virtual methods in a #hb_unicode_funcs_t function
|
||||
* structure.
|
||||
**/
|
||||
|
||||
/* Unicode-4.0 additions */
|
||||
HB_SCRIPT_BRAILLE,
|
||||
HB_SCRIPT_CYPRIOT,
|
||||
HB_SCRIPT_LIMBU,
|
||||
HB_SCRIPT_OSMANYA,
|
||||
HB_SCRIPT_SHAVIAN,
|
||||
HB_SCRIPT_LINEAR_B,
|
||||
HB_SCRIPT_TAI_LE,
|
||||
HB_SCRIPT_UGARITIC,
|
||||
|
||||
/* Unicode-4.1 additions */
|
||||
HB_SCRIPT_NEW_TAI_LUE,
|
||||
HB_SCRIPT_BUGINESE,
|
||||
HB_SCRIPT_GLAGOLITIC,
|
||||
HB_SCRIPT_TIFINAGH,
|
||||
HB_SCRIPT_SYLOTI_NAGRI,
|
||||
HB_SCRIPT_OLD_PERSIAN,
|
||||
HB_SCRIPT_KHAROSHTHI,
|
||||
|
||||
/* Unicode-5.0 additions */
|
||||
HB_SCRIPT_UNKNOWN,
|
||||
HB_SCRIPT_BALINESE,
|
||||
HB_SCRIPT_CUNEIFORM,
|
||||
HB_SCRIPT_PHOENICIAN,
|
||||
HB_SCRIPT_PHAGS_PA,
|
||||
HB_SCRIPT_NKO,
|
||||
|
||||
/* Unicode-5.1 additions */
|
||||
HB_SCRIPT_KAYAH_LI,
|
||||
HB_SCRIPT_LEPCHA,
|
||||
HB_SCRIPT_REJANG,
|
||||
HB_SCRIPT_SUNDANESE,
|
||||
HB_SCRIPT_SAURASHTRA,
|
||||
HB_SCRIPT_CHAM,
|
||||
HB_SCRIPT_OL_CHIKI,
|
||||
HB_SCRIPT_VAI,
|
||||
HB_SCRIPT_CARIAN,
|
||||
HB_SCRIPT_LYCIAN,
|
||||
HB_SCRIPT_LYDIAN,
|
||||
|
||||
/* Unicode-5.2 additions */
|
||||
HB_SCRIPT_AVESTAN,
|
||||
HB_SCRIPT_BAMUM,
|
||||
HB_SCRIPT_EGYPTIAN_HIEROGLYPHS,
|
||||
HB_SCRIPT_IMPERIAL_ARAMAIC,
|
||||
HB_SCRIPT_INSCRIPTIONAL_PAHLAVI,
|
||||
HB_SCRIPT_INSCRIPTIONAL_PARTHIAN,
|
||||
HB_SCRIPT_JAVANESE,
|
||||
HB_SCRIPT_KAITHI,
|
||||
HB_SCRIPT_TAI_THAM,
|
||||
HB_SCRIPT_LISU,
|
||||
HB_SCRIPT_MEETEI_MAYEK,
|
||||
HB_SCRIPT_OLD_SOUTH_ARABIAN,
|
||||
HB_SCRIPT_OLD_TURKIC,
|
||||
HB_SCRIPT_SAMARITAN,
|
||||
HB_SCRIPT_TAI_VIET,
|
||||
|
||||
/* Unicode-6.0 additions */
|
||||
HB_SCRIPT_BATAK,
|
||||
HB_SCRIPT_BRAHMI,
|
||||
HB_SCRIPT_MANDAIC,
|
||||
|
||||
/* Unicode-6.1 additions */
|
||||
HB_SCRIPT_CHAKMA,
|
||||
HB_SCRIPT_MEROITIC_CURSIVE,
|
||||
HB_SCRIPT_MEROITIC_HIEROGLYPHS,
|
||||
HB_SCRIPT_MIAO,
|
||||
HB_SCRIPT_SHARADA,
|
||||
HB_SCRIPT_SORA_SOMPENG,
|
||||
HB_SCRIPT_TAKRI
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* hb_glib_script_to_script:
|
||||
* @script: The GUnicodeScript identifier to query
|
||||
*
|
||||
* Fetches the #hb_script_t script that corresponds to the
|
||||
* specified GUnicodeScript identifier.
|
||||
*
|
||||
* Return value: the #hb_script_t script found
|
||||
*
|
||||
* Since: 0.9.38
|
||||
**/
|
||||
hb_script_t
|
||||
hb_glib_script_to_script (GUnicodeScript script)
|
||||
{
|
||||
#if GLIB_CHECK_VERSION(2,29,14)
|
||||
return (hb_script_t) g_unicode_script_to_iso15924 (script);
|
||||
#else
|
||||
if (likely ((unsigned int) script < ARRAY_LENGTH (glib_script_to_script)))
|
||||
return glib_script_to_script[script];
|
||||
|
||||
if (unlikely (script == G_UNICODE_SCRIPT_INVALID_CODE))
|
||||
return HB_SCRIPT_INVALID;
|
||||
|
||||
return HB_SCRIPT_UNKNOWN;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_glib_script_from_script:
|
||||
* @script: The #hb_script_t to query
|
||||
*
|
||||
* Fetches the GUnicodeScript identifier that corresponds to the
|
||||
* specified #hb_script_t script.
|
||||
*
|
||||
* Return value: the GUnicodeScript identifier found
|
||||
*
|
||||
* Since: 0.9.38
|
||||
**/
|
||||
GUnicodeScript
|
||||
hb_glib_script_from_script (hb_script_t script)
|
||||
{
|
||||
#if GLIB_CHECK_VERSION(2,29,14)
|
||||
return g_unicode_script_from_iso15924 (script);
|
||||
#else
|
||||
unsigned int count = ARRAY_LENGTH (glib_script_to_script);
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
if (glib_script_to_script[i] == script)
|
||||
return (GUnicodeScript) i;
|
||||
|
||||
if (unlikely (script == HB_SCRIPT_INVALID))
|
||||
return G_UNICODE_SCRIPT_INVALID_CODE;
|
||||
|
||||
return G_UNICODE_SCRIPT_UNKNOWN;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -201,14 +93,6 @@ hb_glib_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
||||
return (hb_unicode_combining_class_t) g_unichar_combining_class (unicode);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
hb_glib_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
||||
hb_codepoint_t unicode,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
return g_unichar_iswide (unicode) ? 2 : 1;
|
||||
}
|
||||
|
||||
static hb_unicode_general_category_t
|
||||
hb_glib_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
||||
hb_codepoint_t unicode,
|
||||
@@ -333,58 +217,76 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
||||
hb_codepoint_t u,
|
||||
hb_codepoint_t *decomposed,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
#if GLIB_CHECK_VERSION(2,29,12)
|
||||
return g_unichar_fully_decompose (u, true, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN);
|
||||
|
||||
#if HB_USE_ATEXIT
|
||||
static void free_static_glib_funcs ();
|
||||
#endif
|
||||
|
||||
/* If the user doesn't have GLib >= 2.29.12 we have to perform
|
||||
* a round trip to UTF-8 and the associated memory management dance. */
|
||||
gchar utf8[6];
|
||||
gchar *utf8_decomposed, *c;
|
||||
gsize utf8_len, utf8_decomposed_len, i;
|
||||
|
||||
/* Convert @u to UTF-8 and normalise it in NFKD mode. This performs the compatibility decomposition. */
|
||||
utf8_len = g_unichar_to_utf8 (u, utf8);
|
||||
utf8_decomposed = g_utf8_normalize (utf8, utf8_len, G_NORMALIZE_NFKD);
|
||||
utf8_decomposed_len = g_utf8_strlen (utf8_decomposed, -1);
|
||||
|
||||
assert (utf8_decomposed_len <= HB_UNICODE_MAX_DECOMPOSITION_LEN);
|
||||
|
||||
for (i = 0, c = utf8_decomposed; i < utf8_decomposed_len; i++, c = g_utf8_next_char (c))
|
||||
*decomposed++ = g_utf8_get_char (c);
|
||||
|
||||
g_free (utf8_decomposed);
|
||||
|
||||
return utf8_decomposed_len;
|
||||
}
|
||||
|
||||
hb_unicode_funcs_t *
|
||||
hb_glib_get_unicode_funcs (void)
|
||||
static struct hb_glib_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t<hb_glib_unicode_funcs_lazy_loader_t>
|
||||
{
|
||||
static const hb_unicode_funcs_t _hb_glib_unicode_funcs = {
|
||||
HB_OBJECT_HEADER_STATIC,
|
||||
static hb_unicode_funcs_t *create ()
|
||||
{
|
||||
hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr);
|
||||
|
||||
NULL, /* parent */
|
||||
true, /* immutable */
|
||||
{
|
||||
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name,
|
||||
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
|
||||
#undef HB_UNICODE_FUNC_IMPLEMENT
|
||||
}
|
||||
};
|
||||
hb_unicode_funcs_set_combining_class_func (funcs, hb_glib_unicode_combining_class, nullptr, nullptr);
|
||||
hb_unicode_funcs_set_general_category_func (funcs, hb_glib_unicode_general_category, nullptr, nullptr);
|
||||
hb_unicode_funcs_set_mirroring_func (funcs, hb_glib_unicode_mirroring, nullptr, nullptr);
|
||||
hb_unicode_funcs_set_script_func (funcs, hb_glib_unicode_script, nullptr, nullptr);
|
||||
hb_unicode_funcs_set_compose_func (funcs, hb_glib_unicode_compose, nullptr, nullptr);
|
||||
hb_unicode_funcs_set_decompose_func (funcs, hb_glib_unicode_decompose, nullptr, nullptr);
|
||||
|
||||
return const_cast<hb_unicode_funcs_t *> (&_hb_glib_unicode_funcs);
|
||||
hb_unicode_funcs_make_immutable (funcs);
|
||||
|
||||
#if HB_USE_ATEXIT
|
||||
atexit (free_static_glib_funcs);
|
||||
#endif
|
||||
|
||||
return funcs;
|
||||
}
|
||||
} static_glib_funcs;
|
||||
|
||||
#if HB_USE_ATEXIT
|
||||
static
|
||||
void free_static_glib_funcs ()
|
||||
{
|
||||
static_glib_funcs.free_instance ();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* hb_glib_get_unicode_funcs:
|
||||
*
|
||||
* Fetches a Unicode-functions structure that is populated
|
||||
* with the appropriate GLib function for each method.
|
||||
*
|
||||
* Return value: (transfer none): a pointer to the #hb_unicode_funcs_t Unicode-functions structure
|
||||
*
|
||||
* Since: 0.9.38
|
||||
**/
|
||||
hb_unicode_funcs_t *
|
||||
hb_glib_get_unicode_funcs ()
|
||||
{
|
||||
return static_glib_funcs.get_unconst ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,31,10)
|
||||
|
||||
static void
|
||||
_hb_g_bytes_unref (void *data)
|
||||
{
|
||||
g_bytes_unref ((GBytes *) data);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_glib_blob_create:
|
||||
* @gbytes: the GBytes structure to work upon
|
||||
*
|
||||
* Creates an #hb_blob_t blob from the specified
|
||||
* GBytes data structure.
|
||||
*
|
||||
* Return value: (transfer full): the new #hb_blob_t blob object
|
||||
*
|
||||
* Since: 0.9.38
|
||||
**/
|
||||
@@ -397,6 +299,9 @@ hb_glib_blob_create (GBytes *gbytes)
|
||||
size,
|
||||
HB_MEMORY_MODE_READONLY,
|
||||
g_bytes_ref (gbytes),
|
||||
(hb_destroy_func_t) g_bytes_unref);
|
||||
_hb_g_bytes_unref);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user