未验证 提交 9df700d4 编写于 作者: O openharmony_ci 提交者: Gitee

!21 升级harfbuzz到2.8.1

Merge pull request !21 from 郝烁/master
......@@ -2,7 +2,7 @@
set -e
meson --cross-file=.ci/win32-cross-file.txt win32build --wrap-mode=forcefallback -Dtests=disabled \
-Dglib=enabled -Dfreetype=enabled -Dgdi=enabled -Dcairo=enabled --buildtype=release $@
-Dglib=enabled -Dfreetype=enabled -Dgdi=enabled -Ddirectwrite=enabled -Dcairo=enabled --buildtype=release $@
ninja -Cwin32build -j3 # building with all the cores won't work fine with CricleCI for some reason
rm -rf win32build/harfbuzz-win32
......@@ -11,5 +11,5 @@ cp win32build/util/hb-*.exe win32build/harfbuzz-win32
find win32build -name '*.dll' -exec cp {} win32build/harfbuzz-win32 \;
i686-w64-mingw32-strip win32build/harfbuzz-win32/*.{dll,exe}
rm -f harfbuzz-win32.zip
(cd win32build/harfbuzz-win32 && zip ../../harfbuzz-win32.zip -r .)
(cd win32build && zip -r ../harfbuzz-win32.zip harfbuzz-win32)
echo "harfbuzz-win32.zip is ready."
version: 2
version: 2.1
jobs:
macos-10.12.6-aat-fonts:
macos:
xcode: "9.0.1"
steps:
- checkout
- run: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config ragel freetype glib cairo python3 ninja
- run: pip3 install meson --upgrade
- run: meson build
- run: meson compile -Cbuild # or ninja -Cbuild
- run: meson test -Cbuild --print-errorlogs
executors:
win32-executor:
docker:
- image: cimg/base:edge-20.04
autotools-executor:
docker:
- image: cimg/base:edge-20.04
macos-10.13.6-aat-fonts:
macos:
xcode: "10.1.0"
steps:
- checkout
- run: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config ragel freetype glib cairo python3 ninja
- run: pip3 install meson --upgrade
- run: meson build
- run: meson compile -Cbuild
- run: meson test -Cbuild --print-errorlogs
jobs:
macos-10.14.4-aat-fonts:
macos-10_14_4-aat-fonts:
macos:
xcode: "11.1.0"
steps:
......@@ -34,43 +20,57 @@ jobs:
- run: PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig" meson build -Dcoretext=enabled
- run: meson compile -Cbuild
- run: meson test -Cbuild --print-errorlogs
- store_artifacts:
path: build/meson-logs/
macos-10.15.3-aat-fonts:
macos-10_15_3-aat-fonts:
macos:
xcode: "11.4.0"
steps:
- checkout
- run: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config ragel freetype glib cairo python3 icu4c graphite2 gobject-introspection gtk-doc ninja
- run: pip3 install meson --upgrade
- run: PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig" meson build -Dcoretext=enabled -Dgraphite=enabled -Dauto_features=enabled
- run: PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig" meson build -Dcoretext=enabled -Dgraphite=enabled -Dauto_features=enabled -Dchafa=disabled
- run: meson compile -Cbuild
- run: meson test -Cbuild --print-errorlogs
- store_artifacts:
path: build/meson-logs/
# will be dropped with autotools removal
distcheck:
docker:
- image: ubuntu:20.04
executor: autotools-executor
steps:
- checkout
- run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y git ninja-build binutils libtool autoconf automake make gcc g++ pkg-config ragel gtk-doc-tools libfontconfig1-dev libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python3 python3-pip cmake
- run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y git ninja-build binutils libtool autoconf automake make gcc g++ pkg-config ragel gtk-doc-tools gobject-introspection libfreetype6-dev libglib2.0-dev libgirepository1.0-dev libcairo2-dev libicu-dev libgraphite2-dev python3 python3-pip
- run: pip3 install fonttools meson --upgrade
- run: ./autogen.sh
- run: make -j32
- run: make distcheck
- run: make -j2 distcheck
- run: rm harfbuzz-* && make distdir
- run: cd harfbuzz-* && meson build && ninja -Cbuild test
- run: cd harfbuzz-* && cmake -Bcmakebuild -H. && cmake --build cmakebuild
- run: cd harfbuzz-* && meson build && ninja -j2 -Cbuild test
- run: make dist
- persist_to_workspace:
root: .
paths: harfbuzz-*.tar.xz
publish-dist:
executor: autotools-executor
steps:
- checkout
- attach_workspace:
at: .
- run: |
.ci/publish_release_artifact.sh harfbuzz-$CIRCLE_TAG.tar.xz
fedora-valgrind:
docker:
- image: fedora
- image: fedora:33
steps:
- checkout
- run: dnf install -y pkg-config ragel valgrind gcc gcc-c++ meson git glib2-devel freetype-devel cairo-devel libicu-devel gobject-introspection-devel graphite2-devel redhat-rpm-config python python-pip || true
- run: meson build --buildtype=debugoptimized
- run: ninja -Cbuild -j9
# TOOD: increase timeouts and remove --no-suite=slow
- run: RUN_VALGRIND=1 HB_TEST_SHAPE_FUZZER_TIMEOUT=5 meson test -Cbuild --no-suite=slow --wrap='valgrind --leak-check=full --error-exitcode=1' --print-errorlogs
- run: RUN_VALGRIND=1 meson test -Cbuild --no-suite=slow --wrap='valgrind --leak-check=full --error-exitcode=1' --print-errorlogs
alpine:
docker:
......@@ -90,7 +90,6 @@ jobs:
- checkout
- run: pacman --noconfirm -Syu freetype2 meson git clang cairo icu gettext gobject-introspection gcc gcc-libs glib2 graphite pkg-config ragel python python-pip base-devel gtk-doc
- run: pip install flake8 fonttools
- run: pip install git+https://github.com/mesonbuild/meson
- run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
- run: meson build -Dgraphite=enabled -Dauto_features=enabled -Dexperimental_api=true
- run: meson compile -Cbuild -j9
......@@ -104,11 +103,7 @@ jobs:
- image: ubuntu:20.04
steps:
- checkout
- run: apt update || true; DEBIAN_FRONTEND=noninteractive apt install -y wget gnupg
#- run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
#- run: echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" > /etc/apt/sources.list.d/llvmdev.list
#- run: echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main" > /etc/apt/sources.list.d/llvmdevsrc.list
#- run: apt update || true
- run: apt update || true
- run: DEBIAN_FRONTEND=noninteractive apt install -y clang lld git binutils meson pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev
# asan+ubsan
- run: rm -rf build && meson build --default-library=static -Db_sanitize=address,undefined --buildtype=debugoptimized --wrap-mode=nodownload -Dexperimental_api=true
......@@ -119,31 +114,63 @@ jobs:
# msan, needs --force-fallback-for=glib,freetype2 also which doesn't work yet but runs fuzzer cases at least
- run: rm -rf build && meson build --default-library=static -Db_sanitize=memory --buildtype=debugoptimized --wrap-mode=nodownload -Dauto_features=disabled -Dtests=enabled -Dexperimental_api=true
- run: ninja -Cbuild -j8 && meson test -Cbuild --print-errorlogs | asan_symbolize | c++filt
# test -std=c++2a and -Weverything of nightly clang builds
- run: clang -c src/harfbuzz.cc src/hb-subset*.cc -DHB_NO_MT -Werror -std=c++2a
- run: clang -c src/hb-*.cc -DHB_NO_MT -Werror -Weverything -Wno-old-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-c++98-compat -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-sign-conversion -Wno-padded -Wno-shorten-64-to-32 -Wno-reserved-id-macro -Wno-float-conversion -Wno-format-pedantic -Wno-shadow -Wno-conversion -Wno-zero-as-null-pointer-constant -Wno-missing-field-initializers -Wno-used-but-marked-unused -Wno-unused-macros -Wno-comma -Wno-float-equal -Wno-disabled-macro-expansion -Wno-weak-vtables -Wno-unused-parameter -Wno-covered-switch-default -Wno-unreachable-code -Wno-unused-template -DHB_WITH_WIN1256
crossbuild-win32:
docker:
- image: ubuntu:20.04
executor: win32-executor
steps:
- checkout
- run: apt update && DEBIAN_FRONTEND=noninteractive apt install -y ninja-build binutils meson gcc g++ pkg-config ragel gtk-doc-tools libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python3 python3-pip git g++-mingw-w64-i686 zip
- run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y ninja-build binutils gcc g++ pkg-config ragel gtk-doc-tools libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python3 python3-pip git g++-mingw-w64-i686 zip
- run: pip3 install meson==0.56.0 --upgrade
- run: .ci/build-win32.sh
- store_artifacts:
path: harfbuzz-win32.zip
- persist_to_workspace:
root: .
paths: harfbuzz-win32.zip
publish-win32:
executor: win32-executor
steps:
- checkout
- attach_workspace:
at: .
- run: |
mv harfbuzz-win32{,-$CIRCLE_TAG}.zip
.ci/publish_release_artifact.sh harfbuzz-win32-$CIRCLE_TAG.zip
workflows:
version: 2
build:
jobs:
- macos-10.12.6-aat-fonts
- macos-10.13.6-aat-fonts
- macos-10.14.4-aat-fonts
- macos-10.15.3-aat-fonts
- distcheck # will be dropped with autotools removal
- macos-10_14_4-aat-fonts
- macos-10_15_3-aat-fonts
- distcheck: # will be dropped with autotools removal
filters:
tags:
only: /^\d+.\d+.\d+$/
- publish-dist:
requires:
- distcheck
filters:
tags:
only: /^\d+\.\d+\.\d+$/
branches:
ignore: /.*/
- fedora-valgrind
- alpine
- archlinux
#- archlinux
- sanitizers
- crossbuild-win32
- crossbuild-win32:
filters:
tags:
only: /^\d+.\d+.\d+$/
- publish-win32:
requires:
- crossbuild-win32
filters:
tags:
only: /^\d+\.\d+\.\d+$/
branches:
ignore: /.*/
......@@ -19,12 +19,12 @@ jobs:
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
# ideally we should've used meson and ninja here but it complains about coverage or something
- run: cov-analysis-linux64/bin/cov-build --dir cov-int clang src/hb-*.cc -DHAVE_FREETYPE -DHAVE_GRAPHITE2 -DHAVE_GLIB -DHAVE_ICU `pkg-config --cflags freetype2 graphite2 glib-2.0 icu-uc` -DHAVE_INTEL_ATOMIC_PRIMITIVES -DHAVE_ROUNDF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H -DHAVE_GETPAGESIZE -DHB_EXPERIMENTAL_API -c
- run: cov-analysis-linux64/bin/cov-build --dir cov-int clang src/hb-*.cc -DHAVE_FREETYPE -DHAVE_GRAPHITE2 -DHAVE_GLIB -DHAVE_ICU `pkg-config --cflags freetype2 graphite2 glib-2.0 icu-uc` -DHAVE_ROUNDF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H -DHAVE_GETPAGESIZE -DHB_EXPERIMENTAL_API -c
- run: tar czvf harfbuzz.tgz cov-int
- name: submit to coverity
run: |
curl \
......
......@@ -8,16 +8,15 @@ on:
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: sudo apt-get install pkg-config gcc ragel gcovr gtk-doc-tools libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python3 python3-setuptools ninja-build gobject-introspection libgirepository1.0-dev
- run: sudo pip3 install fonttools
- run: sudo pip3 install git+https://github.com/mesonbuild/meson
- run: sudo pip3 install fonttools meson==0.47.0
- name: run
run: meson build -Db_coverage=true --auto-features=enabled -Dgraphite=enabled -Doptimization=2
run: meson build -Db_coverage=true --auto-features=enabled -Dgraphite=enabled -Dchafa=disabled -Doptimization=2
- name: ci
run: meson test --print-errorlogs -Cbuild
......
......@@ -2,7 +2,9 @@ name: msvc
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
msvc:
......
......@@ -2,7 +2,9 @@ name: msys2
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
msys2:
......@@ -39,9 +41,12 @@ jobs:
mingw-w64-${{ matrix.MSYS2_ARCH }}-meson
mingw-w64-${{ matrix.MSYS2_ARCH }}-ninja
mingw-w64-${{ matrix.MSYS2_ARCH }}-pkg-config
mingw-w64-${{ matrix.MSYS2_ARCH }}-python-fonttools
mingw-w64-${{ matrix.MSYS2_ARCH }}-python3
mingw-w64-${{ matrix.MSYS2_ARCH }}-python
mingw-w64-${{ matrix.MSYS2_ARCH }}-python-pip
mingw-w64-${{ matrix.MSYS2_ARCH }}-ragel
- name: Install Python Dependencies
run: |
pip install --upgrade fonttools
- name: Build
run: |
meson build \
......@@ -49,7 +54,8 @@ jobs:
--auto-features=enabled \
-Ddirectwrite=enabled \
-Dgdi=enabled \
-Dgraphite=enabled
-Dgraphite=enabled \
-Dchafa=disabled
ninja -C build
- name: Test
run: |
......
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.0.0)
project(harfbuzz)
message(WARN "HarfBuzz has a Meson port and tries to migrate all the other build systems to it, please consider using it as we might remove our cmake port soon.")
......@@ -102,6 +102,10 @@ if (${HAVE_STDBOOL_H})
add_definitions(-DHAVE_STDBOOL_H)
endif ()
# https://github.com/harfbuzz/harfbuzz/pull/2874#issuecomment-782859099
if (NOT WIN32)
add_definitions("-DHAVE_PTHREAD")
endif ()
if (MSVC)
add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
......@@ -233,7 +237,7 @@ endif ()
if (HB_HAVE_ICU)
add_definitions(-DHAVE_ICU)
# https://github.com/WebKit/webkit/blob/master/Source/cmake/FindICU.cmake
# https://github.com/WebKit/webkit/blob/fdd7733f2f30eab7fe096a9791f98c60f62f49c0/Source/cmake/FindICU.cmake
find_package(PkgConfig)
pkg_check_modules(PC_ICU QUIET icu-uc)
......@@ -302,6 +306,7 @@ if (WIN32 AND HB_HAVE_DIRECTWRITE)
endif ()
if (HB_HAVE_GOBJECT)
add_definitions(-DHAVE_GOBJECT)
include (FindPerl)
# Use the hints from glib-2.0.pc to find glib-mkenums
......@@ -405,42 +410,13 @@ if (HB_HAVE_GOBJECT)
)
endif ()
## Atomic ops availability detection
file(WRITE "${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c"
" void memory_barrier (void) { __sync_synchronize (); }
int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
void mutex_unlock (int *m) { __sync_lock_release (m); }
int main () { return 0; }
")
try_compile(HB_HAVE_INTEL_ATOMIC_PRIMITIVES
${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives
${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c)
if (HB_HAVE_INTEL_ATOMIC_PRIMITIVES)
add_definitions(-DHAVE_INTEL_ATOMIC_PRIMITIVES)
endif ()
file(WRITE "${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c"
" #include <atomic.h>
/* This requires Solaris Studio 12.2 or newer: */
#include <mbarrier.h>
void memory_barrier (void) { __machine_rw_barrier (); }
int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
int main () { return 0; }
")
try_compile(HB_HAVE_SOLARIS_ATOMIC_OPS
${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops
${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c)
if (HB_HAVE_SOLARIS_ATOMIC_OPS)
add_definitions(-DHAVE_SOLARIS_ATOMIC_OPS)
endif ()
## Define harfbuzz library
add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers})
target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS})
target_include_directories(harfbuzz PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz>")
## Define harfbuzz-icu library
if (HB_HAVE_ICU)
......
......@@ -108,7 +108,7 @@ Defining `HB_NO_FALLBACK_SHAPE` however is pretty harmless. That removes the
By default HarfBuzz builds as a thread-safe library. The exception is that
the `HB_TINY` predefined configuring (more below) disables thread-safety.
If you do /not/ need thread-safety in the library (eg. you always call into
If you do *not* need thread-safety in the library (eg. you always call into
HarfBuzz from the same thread), you can disable thread-safety by defining
`HB_NO_MT`. As noted already, this is enabled by `HB_TINY`.
......@@ -144,7 +144,7 @@ overrides at the end.
## Notes
Note that the config option `HB_NO_CFF`, which is enabled by `HB_LEAN` and
`HB_TINY` does /not/ mean that the resulting library won't work with CFF fonts.
`HB_TINY` does *not* mean that the resulting library won't work with CFF fonts.
The library can shape valid CFF fonts just fine, with or without this option.
This option disables (among other things) the code to calculate glyph exntents
This option disables (among other things) the code to calculate glyph extents
for CFF fonts.
......@@ -20,7 +20,6 @@ EXTRA_DIST = \
meson.build \
meson_options.txt \
subprojects/expat.wrap \
subprojects/fontconfig.wrap \
subprojects/freetype2.wrap \
subprojects/glib.wrap \
subprojects/libffi.wrap \
......@@ -40,8 +39,7 @@ EXTRA_DIST = \
perf/texts/en-words.txt \
perf/texts/fa-monologue.txt \
perf/texts/fa-thelittleprince.txt \
meson-cc-tests/intel-atomic-primitives-test.c \
meson-cc-tests/solaris-atomic-operations.c \
mingw-configure.sh \
$(NULL)
MAINTAINERCLEANFILES = \
......
Overview of changes leading to 2.8.1
Tuesday, May 4, 2021
====================================
- Subsetter now fully supports GSUB/GPOS/GDEF tables (including variations); as
such, layout tables are retained by subsetter by default. (Garret Rieger, Qunxin Liu)
- Build scripts no longer check for FontConfig as HarfBuzz does not use it.
- hb-view supports iTerm2 and kitty inline image protocols (Khaled Hosny),
it can also use Chafa for terminal graphics if available (Hans Petter Jansson).
Overview of changes leading to 2.8.0
Tuesday, March 16, 2021
====================================
- Shape joining scripts other than Arabic/Syriac using the Universal Shaping Engine.
Previously these were shaped using the generalized Arabic shaper. (David Corbett)
- Fix regression in shaping of U+0B55 ORIYA SIGN OVERLINE. (David Corbett)
- Update language tags. (David Corbett)
- Variations: reduce error: do not round each interpolated delta. (Just van Rossum)
- Documentation improvements. (Khaled Hosny, Nathan Willis)
- Subsetter improvements: subsets most, if not all, lookup types now. (Garret Rieger, Qunxin Liu)
- Fuzzer-found fixes and other improvements when memory failures happen. (Behdad)
- Removed most atomic implementations now that we have C++11 atomic impl. (Behdad)
- General codebase upkeep; using more C++11 features: constexpr constructors, etc. (Behdad)
Overview of changes leading to 2.7.4
Sunday, December 27, 2020
====================================
- Fix missing --enable-introspection configure option from previous release
tarball.
- Documentation updates.
Overview of changes leading to 2.7.3
Wednesday, December 23, 2020
====================================
- Update USE shaper to 2020-08-13 specification, and other improvements.
- Don’t disable liga feature in myanmar shaper, to match Uniscribe.
- Improvements to language and script tags handling.
- Update language system tag registry to OpenType 1.8.4
- Support for serializing and deserializing Unicode buffers. Serialized buffers
are now delimited with `<>` or `[]` based on whether it is a Unicode or
glyphs buffer.
- Increase buffer work limits to handle fonts with many complex lookups.
- Handle more shaping operations in trace output.
- Memory access fixes.
- More OOM fixes.
- Improved documentation.
- Build system improvements.
- New API:
+hb_buffer_has_positions()
+hb_buffer_serialize()
+hb_buffer_serialize_unicode()
+hb_buffer_deserialize_unicode()
Overview of changes leading to 2.7.2
Saturday, August 29, 2020
====================================
......
......@@ -4,17 +4,33 @@ implementation and that specially is important where OpenType specification
is or wasn't that clear. For having access to Uniscribe on Linux/macOS these
steps are recommended:
1. Install Wine from your favorite package manager. On Fedora that's `dnf install wine`.
You want to follow the 32bit instructions. The 64bit equivalents are included
for reference.
2. And `mingw-w64` compiler.
With `brew` on macOS, you can have it like `brew install mingw-w64`.
On Fedora, with `dnf install mingw32-gcc-c++`, or `dnf install mingw64-gcc-c++` for the
64-bit Windows. Use `apt install g++-mingw-w64` on Debian.
1. Install Wine.
- Fedora: `dnf install wine`.
3. See how `.ci/build-win32.sh` uses meson or run that script anyway.
2. Install `mingw-w64` compiler.
- Fedora, 32bit: `dnf install mingw32-gcc-c++`
- Fedora, 64bit: `dnf install mingw64-gcc-c++`
- Debian: `apt install g++-mingw-w64`
- Mac: `brew install mingw-w64`
Now you can use hb-shape by `(cd win32build/harfbuzz-win32 && wine hb-shape.exe)`
but if you like to shape with the Microsoft Uniscribe,
3. If you have drank the `meson` koolaid, look at `.ci/build-win32.sh` to see how to
invoke `meson` now, or just run that script. Otherwise, here's how to use the
old trusty autotools instead:
a) Install dependencies.
- Fedora, 32bit: `dnf install mingw32-glib2 mingw32-cairo mingw32-freetype`
- Fedora, 64bit: `dnf install mingw64-glib2 mingw64-cairo mingw64-freetype`
b) Configure:
- `NOCONFIGURE=1 ./autogen.sh && mkdir winbuild && cd winbuild`
- 32bit: `../mingw-configure.sh i686`
- 64bit: `../mingw-configure.sh x86_64`
Now you can use `hb-shape` by `(cd win32build/util && wine hb-shape.exe)`
but if you like to shape with the Microsoft Uniscribe:
4. Bring a 32bit version of `usp10.dll` for yourself from `C:\Windows\SysWOW64\usp10.dll` of your
Windows installation (assuming you have a 64-bit installation, otherwise
......
AC_PREREQ([2.64])
AC_INIT([HarfBuzz],
[2.7.2],
[2.8.1],
[https://github.com/harfbuzz/harfbuzz/issues/new],
[harfbuzz],
[http://harfbuzz.org/])
......@@ -25,7 +25,7 @@ AM_PROG_CC_C_O
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX(11)
AC_SYS_LARGEFILE
PKG_PROG_PKG_CONFIG([0.20])
PKG_PROG_PKG_CONFIG([0.28])
AM_MISSING_PROG([RAGEL], [ragel])
AM_MISSING_PROG([GIT], [git])
......@@ -214,21 +214,21 @@ AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft)
dnl ==========================================================================
AC_ARG_WITH(fontconfig,
[AS_HELP_STRING([--with-fontconfig=@<:@yes/no/auto@:>@],
[Use fontconfig @<:@default=auto@:>@])],,
[with_fontconfig=auto])
have_fontconfig=false
if test "x$with_fontconfig" = "xyes" -o "x$with_fontconfig" = "xauto"; then
PKG_CHECK_MODULES(FONTCONFIG, fontconfig, have_fontconfig=true, :)
AC_ARG_WITH(chafa,
[AS_HELP_STRING([--with-chafa=@<:@yes/no/auto@:>@],
[Use chafa @<:@default=auto@:>@])],,
[with_chafa=auto])
have_chafa=false
if test "x$with_chafa" = "xyes" -o "x$with_chafa" = "xauto"; then
PKG_CHECK_MODULES(CHAFA, chafa >= 1.6.0, have_chafa=true, :)
fi
if test "x$with_fontconfig" = "xyes" -a "x$have_fontconfig" != "xtrue"; then
AC_MSG_ERROR([fontconfig support requested but not found])
if test "x$with_chafa" = "xyes" -a "x$have_chafa" != "xtrue"; then
AC_MSG_ERROR([chafa support requested but not found])
fi
if $have_fontconfig; then
AC_DEFINE(HAVE_FONTCONFIG, 1, [Have fontconfig library])
if $have_chafa; then
AC_DEFINE(HAVE_CHAFA, 1, [Have chafa terminal graphics library])
fi
AM_CONDITIONAL(HAVE_FONTCONFIG, $have_fontconfig)
AM_CONDITIONAL(HAVE_CHAFA, $have_chafa)
dnl ==========================================================================
......@@ -239,25 +239,6 @@ AC_ARG_WITH(icu,
have_icu=false
if test "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" -o "x$with_icu" = "xauto"; then
PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, :)
dnl Fallback to icu-config if ICU pkg-config files could not be found
if test "$have_icu" != "true"; then
AC_CHECK_TOOL(ICU_CONFIG, icu-config, no)
AC_MSG_CHECKING([for ICU by using icu-config fallback])
if test "$ICU_CONFIG" != "no" && "$ICU_CONFIG" --version >/dev/null; then
have_icu=true
# We don't use --cflags as this gives us a lot of things that we don't
# necessarily want, like debugging and optimization flags
# See man (1) icu-config for more info.
ICU_CFLAGS=`$ICU_CONFIG --cppflags`
ICU_LIBS=`$ICU_CONFIG --ldflags-searchpath --ldflags-libsonly`
AC_SUBST(ICU_CFLAGS)
AC_SUBST(ICU_LIBS)
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
fi
if test \( "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" \) -a "x$have_icu" != "xtrue"; then
AC_MSG_ERROR([icu support requested but icu-uc not found])
......@@ -436,45 +417,6 @@ AM_CONDITIONAL(HAVE_CORETEXT, $have_coretext)
dnl ===========================================================================
AC_CACHE_CHECK([for Intel atomic primitives], hb_cv_have_intel_atomic_primitives, [
hb_cv_have_intel_atomic_primitives=false
AC_TRY_LINK([
void memory_barrier (void) { __sync_synchronize (); }
int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
void mutex_unlock (int *m) { __sync_lock_release (m); }
], [], hb_cv_have_intel_atomic_primitives=true
)
])
if $hb_cv_have_intel_atomic_primitives; then
AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1, [Have Intel __sync_* atomic primitives])
fi
dnl ===========================================================================
AC_CACHE_CHECK([for Solaris atomic operations], hb_cv_have_solaris_atomic_ops, [
hb_cv_have_solaris_atomic_ops=false
AC_TRY_LINK([
#include <atomic.h>
/* This requires Solaris Studio 12.2 or newer: */
#include <mbarrier.h>
void memory_barrier (void) { __machine_rw_barrier (); }
int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
], [], hb_cv_have_solaris_atomic_ops=true
)
])
if $hb_cv_have_solaris_atomic_ops; then
AC_DEFINE(HAVE_SOLARIS_ATOMIC_OPS, 1, [Have Solaris __machine_*_barrier and atomic_* operations])
fi
if test "$os_win32" = no && ! $have_pthread; then
AC_CHECK_HEADERS(sched.h)
AC_SEARCH_LIBS(sched_yield,rt,AC_DEFINE(HAVE_SCHED_YIELD, 1, [Have sched_yield]))
fi
dnl ===========================================================================
AC_CONFIG_FILES([
Makefile
src/Makefile
......@@ -490,6 +432,7 @@ test/shaping/data/in-house/Makefile
test/shaping/data/text-rendering-tests/Makefile
test/subset/Makefile
test/subset/data/Makefile
test/subset/data/repack_tests/Makefile
docs/Makefile
docs/version.xml
])
......@@ -523,7 +466,7 @@ Font callbacks (the more the merrier):
Tools used for command-line utilities:
Cairo: ${have_cairo}
Fontconfig: ${have_fontconfig}
Chafa: ${have_chafa}
Additional shapers:
Graphite2: ${have_graphite2}
......
......@@ -29,15 +29,12 @@ SCANGOBJ_OPTIONS=
# Extra options to supply to gtkdoc-scan.
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
SCAN_OPTIONS=--rebuild-types --deprecated-guards="HB_DISABLE_DEPRECATED" \
--ignore-decorators="HB_EXTERN"
--ignore-decorators='HB_EXTERN|HB_DEPRECATED'
# Header files or dirs to ignore when scanning. Use base file/dir names
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
IGNORE_HFILES=`cd $(top_srcdir)/src; find . -path './*/*.h' | sed 's@^.*/@@'`
if HAVE_GOBJECT
else
IGNORE_HFILES+=hb-gobject.h hb-gobject-enums.h hb-gobject-structs.h
endif
# Extra options to supply to gtkdoc-mkdb.
# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml
......
......@@ -11,8 +11,7 @@
<title>HarfBuzz</title>
<graphic fileref="HarfBuzz.png" format="PNG" align="center"/>
<para>
HarfBuzz is an <ulink url="http://www.microsoft.com/typography/otspec/">OpenType</ulink>
text shaping engine. Using the HarfBuzz library allows
HarfBuzz is a text shaping library. Using the HarfBuzz library allows
programs to convert a sequence of Unicode input into
properly formatted and positioned glyph output&mdash;for any writing
system and language.
......@@ -27,7 +26,7 @@
</abstract>
</bookinfo>
<part>
<part id="user-manual">
<title>User's manual</title>
<xi:include href="usermanual-what-is-harfbuzz.xml"/>
<xi:include href="usermanual-install-harfbuzz.xml"/>
......@@ -42,7 +41,7 @@
<xi:include href="usermanual-integration.xml"/>
</part>
<part>
<part id="reference-manual">
<partinfo>
<releaseinfo>
This document is for HarfBuzz &version;.
......@@ -50,40 +49,9 @@
<ulink role="online-location" url="http://[SERVER]/libharfbuzz/index.html">http://[SERVER]/libharfbuzz/</ulink>.-->
</releaseinfo>
</partinfo>
<note>
<para>
The current HarfBuzz codebase is versioned 2.x.x and is stable
and under active maintenance. This is what is used in latest
versions of Firefox, GNOME, ChromeOS, Chrome, LibreOffice,
XeTeX, Android, and KDE, among other places.
</para>
<para>
Prior to 2012, the original HarfBuzz codebase (which, these
days, is referred to as <emphasis>harfbuzz-old</emphasis>) was
derived from code in <ulink
url="http://freetype.org/">FreeType</ulink>, <ulink
url="http://pango.org/">Pango</ulink>, and
<ulink url="http://qt-project.org/">Qt</ulink>.
It is <emphasis>not</emphasis> actively developed or
maintained, and is extremely buggy. All users of harfbuzz-old
are encouraged to switch over to the new HarfBuzz as soon as possible.
</para>
<para>
To make this distinction clearer in discussions, the current
HarfBuzz codebase is sometimes referred to as
<emphasis>harfbuzz-ng</emphasis>.
</para>
<para>
For reference purposes, the harfbuzz-old source tree is archived
<ulink
url="http://cgit.freedesktop.org/harfbuzz.old/">here</ulink>. There
are no release tarballs of harfbuzz-old whatsoever.
</para>
</note>
<title>Reference manual</title>
<chapter>
<chapter id="core-api">
<title>Core API</title>
<xi:include href="xml/hb-blob.xml"/>
<xi:include href="xml/hb-buffer.xml"/>
......@@ -99,31 +67,34 @@
<xi:include href="xml/hb-version.xml"/>
</chapter>
<chapter>
<chapter id="opentype-api">
<title>OpenType API</title>
<xi:include href="xml/hb-ot-color.xml"/>
<xi:include href="xml/hb-ot-font.xml"/>
<xi:include href="xml/hb-ot-layout.xml"/>
<xi:include href="xml/hb-ot-math.xml"/>
<xi:include href="xml/hb-ot-meta.xml"/>
<xi:include href="xml/hb-ot-metrics.xml"/>
<xi:include href="xml/hb-ot-name.xml"/>
<xi:include href="xml/hb-ot-shape.xml"/>
<xi:include href="xml/hb-ot-var.xml"/>
</chapter>
<chapter>
<chapter id="apple-advanced-typography-api">
<title>Apple Advanced Typography API</title>
<xi:include href="xml/hb-aat-layout.xml"/>
</chapter>
<chapter>
<chapter id="integration-api">
<title>Integration API</title>
<xi:include href="xml/hb-coretext.xml"/>
<xi:include href="xml/hb-ft.xml"/>
<xi:include href="xml/hb-glib.xml"/>
<xi:include href="xml/hb-gobject.xml"/>
<xi:include href="xml/hb-graphite2.xml"/>
<xi:include href="xml/hb-icu.xml"/>
<xi:include href="xml/hb-uniscribe.xml"/>
<xi:include href="xml/hb-gdi.xml"/>
<xi:include href="xml/hb-directwrite.xml"/>
</chapter>
<!--chapter id="object-tree">
......@@ -134,6 +105,10 @@
<index id="api-index-full"><title>API Index</title><xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include></index>
<index id="deprecated-api-index" role="deprecated"><title>Index of deprecated API</title><xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include></index>
<index id="api-index-2-7-3" role="2.7.3"><title>Index of new symbols in 2.7.3</title><xi:include href="xml/api-index-2.7.3.xml"><xi:fallback /></xi:include></index>
<index id="api-index-2-6-8" role="2.6.8"><title>Index of new symbols in 2.6.8</title><xi:include href="xml/api-index-2.6.8.xml"><xi:fallback /></xi:include></index>
<index id="api-index-2-6-5" role="2.6.5"><title>Index of new symbols in 2.6.5</title><xi:include href="xml/api-index-2.6.5.xml"><xi:fallback /></xi:include></index>
<index id="api-index-2-6-3" role="2.6.3"><title>Index of new symbols in 2.6.3</title><xi:include href="xml/api-index-2.6.3.xml"><xi:fallback /></xi:include></index>
<index id="api-index-2-6-0" role="2.6.0"><title>Index of new symbols in 2.6.0</title><xi:include href="xml/api-index-2.6.0.xml"><xi:fallback /></xi:include></index>
<index id="api-index-2-5-0" role="2.5.0"><title>Index of new symbols in 2.5.0</title><xi:include href="xml/api-index-2.5.0.xml"><xi:fallback /></xi:include></index>
<index id="api-index-2-4-0" role="2.4.0"><title>Index of new symbols in 2.4.0</title><xi:include href="xml/api-index-2.4.0.xml"><xi:fallback /></xi:include></index>
......@@ -148,10 +123,12 @@
<index id="api-index-1-8-0" role="1.8.0"><title>Index of new symbols in 1.8.0</title><xi:include href="xml/api-index-1.8.0.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-7-7" role="1.7.7"><title>Index of new symbols in 1.7.7</title><xi:include href="xml/api-index-1.7.7.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-7-5" role="1.7.5"><title>Index of new symbols in 1.7.5</title><xi:include href="xml/api-index-1.7.5.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-7-2" role="1.7.2"><title>Index of new symbols in 1.7.2</title><xi:include href="xml/api-index-1.7.2.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-6-0" role="1.6.0"><title>Index of new symbols in 1.6.0</title><xi:include href="xml/api-index-1.6.0.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-5-0" role="1.5.0"><title>Index of new symbols in 1.5.0</title><xi:include href="xml/api-index-1.5.0.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-4-3" role="1.4.3"><title>Index of new symbols in 1.4.3</title><xi:include href="xml/api-index-1.4.3.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-4-2" role="1.4.2"><title>Index of new symbols in 1.4.2</title><xi:include href="xml/api-index-1.4.2.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-4-0" role="1.4.0"><title>Index of new symbols in 1.4.0</title><xi:include href="xml/api-index-1.4.0.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-3-3" role="1.3.3"><title>Index of new symbols in 1.3.3</title><xi:include href="xml/api-index-1.3.3.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-2-3" role="1.2.3"><title>Index of new symbols in 1.2.3</title><xi:include href="xml/api-index-1.2.3.xml"><xi:fallback /></xi:include></index>
<index id="api-index-1-1-3" role="1.1.3"><title>Index of new symbols in 1.1.3</title><xi:include href="xml/api-index-1.1.3.xml"><xi:fallback /></xi:include></index>
......@@ -161,10 +138,13 @@
<index id="api-index-0-9-41" role="0.9.41"><title>Index of new symbols in 0.9.41</title><xi:include href="xml/api-index-0.9.41.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-39" role="0.9.39"><title>Index of new symbols in 0.9.39</title><xi:include href="xml/api-index-0.9.39.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-38" role="0.9.38"><title>Index of new symbols in 0.9.38</title><xi:include href="xml/api-index-0.9.38.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-33" role="0.9.33"><title>Index of new symbols in 0.9.33</title><xi:include href="xml/api-index-0.9.33.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-31" role="0.9.31"><title>Index of new symbols in 0.9.31</title><xi:include href="xml/api-index-0.9.31.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-30" role="0.9.30"><title>Index of new symbols in 0.9.30</title><xi:include href="xml/api-index-0.9.30.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-28" role="0.9.28"><title>Index of new symbols in 0.9.28</title><xi:include href="xml/api-index-0.9.28.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-26" role="0.9.26"><title>Index of new symbols in 0.9.26</title><xi:include href="xml/api-index-0.9.26.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-22" role="0.9.22"><title>Index of new symbols in 0.9.22</title><xi:include href="xml/api-index-0.9.22.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-21" role="0.9.21"><title>Index of new symbols in 0.9.21</title><xi:include href="xml/api-index-0.9.21.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-20" role="0.9.20"><title>Index of new symbols in 0.9.20</title><xi:include href="xml/api-index-0.9.20.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-11" role="0.9.11"><title>Index of new symbols in 0.9.11</title><xi:include href="xml/api-index-0.9.11.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-10" role="0.9.10"><title>Index of new symbols in 0.9.10</title><xi:include href="xml/api-index-0.9.10.xml"><xi:fallback /></xi:include></index>
......@@ -172,7 +152,37 @@
<index id="api-index-0-9-7" role="0.9.7"><title>Index of new symbols in 0.9.7</title><xi:include href="xml/api-index-0.9.7.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-5" role="0.9.5"><title>Index of new symbols in 0.9.5</title><xi:include href="xml/api-index-0.9.5.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-9-2" role="0.9.2"><title>Index of new symbols in 0.9.2</title><xi:include href="xml/api-index-0.9.2.xml"><xi:fallback /></xi:include></index>
<index id="api-index-0-6-0" role="0.6.0"><title>Index of new symbols in 0.6.0</title><xi:include href="xml/api-index-0.6.0.xml"><xi:fallback /></xi:include></index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
</part>
<note>
<para>
The current HarfBuzz codebase is versioned 2.x.x and is stable
and under active maintenance. This is what is used in latest
versions of Firefox, GNOME, ChromeOS, Chrome, LibreOffice,
XeTeX, Android, and KDE, among other places.
</para>
<para>
Prior to 2012, the original HarfBuzz codebase (which, these days, is
referred to as <emphasis>harfbuzz-old</emphasis>) was derived from code
in <ulink url="http://freetype.org/">FreeType</ulink>,
<ulink url="http://pango.org/">Pango</ulink>, and
<ulink url="http://qt-project.org/">Qt</ulink>.
It is <emphasis>not</emphasis> actively developed or maintained, and is
extremely buggy. All users of harfbuzz-old are encouraged to switch over
to the new HarfBuzz as soon as possible.
</para>
<para>
To make this distinction clearer in discussions, the current HarfBuzz
codebase is sometimes referred to as <emphasis>harfbuzz-ng</emphasis>.
</para>
<para>
For reference purposes, the harfbuzz-old source tree is archived
<ulink url="http://cgit.freedesktop.org/harfbuzz.old/">here</ulink>.
There are no release tarballs of harfbuzz-old whatsoever.
</para>
</note>
</book>
......@@ -80,6 +80,7 @@ hb_buffer_set_user_data
hb_buffer_get_user_data
hb_buffer_get_glyph_infos
hb_buffer_get_glyph_positions
hb_buffer_has_positions
hb_buffer_get_invisible_glyph
hb_buffer_set_invisible_glyph
hb_buffer_set_replacement_codepoint
......@@ -88,8 +89,11 @@ hb_buffer_normalize_glyphs
hb_buffer_reverse
hb_buffer_reverse_range
hb_buffer_reverse_clusters
hb_buffer_serialize
hb_buffer_serialize_glyphs
hb_buffer_deserialize_glyphs
hb_buffer_serialize_unicode
hb_buffer_deserialize_unicode
hb_buffer_serialize_format_from_string
hb_buffer_serialize_format_to_string
hb_buffer_serialize_list_formats
......@@ -141,7 +145,6 @@ hb_position_t
hb_tag_t
hb_script_t
hb_user_data_key_t
hb_var_int_t
HB_TAG
HB_TAG_NONE
HB_TAG_MAX
......@@ -159,6 +162,7 @@ HB_FEATURE_GLOBAL_START
<SUBSECTION Private>
HB_BEGIN_DECLS
HB_END_DECLS
hb_var_int_t
int16_t
int32_t
int64_t
......@@ -325,7 +329,6 @@ hb_font_get_scale
hb_font_get_user_data
hb_font_get_variation_glyph
hb_font_get_variation_glyph_func_t
hb_font_get_var_coords_design
hb_font_get_var_coords_normalized
hb_font_glyph_from_string
hb_font_glyph_to_string
......@@ -355,6 +358,11 @@ hb_font_get_font_h_extents_func_t
hb_font_get_font_v_extents_func_t
hb_font_get_h_extents
hb_font_get_v_extents
hb_font_extents_t
hb_glyph_extents_t
<SUBSECTION Private>
hb_font_get_var_coords_design
hb_font_draw_glyph
</SECTION>
<SECTION>
......@@ -386,78 +394,6 @@ hb_glib_script_to_script
hb_glib_blob_create
</SECTION>
<SECTION>
<FILE>hb-gobject</FILE>
HB_GOBJECT_TYPE_BLOB
HB_GOBJECT_TYPE_BUFFER
HB_GOBJECT_TYPE_BUFFER_CONTENT_TYPE
HB_GOBJECT_TYPE_BUFFER_DIFF_FLAGS
HB_GOBJECT_TYPE_BUFFER_FLAGS
HB_GOBJECT_TYPE_BUFFER_SERIALIZE_FLAGS
HB_GOBJECT_TYPE_BUFFER_SERIALIZE_FORMAT
HB_GOBJECT_TYPE_DIRECTION
HB_GOBJECT_TYPE_FACE
HB_GOBJECT_TYPE_FONT
HB_GOBJECT_TYPE_FONT_FUNCS
HB_GOBJECT_TYPE_GLYPH_FLAGS
HB_GOBJECT_TYPE_MAP
HB_GOBJECT_TYPE_MEMORY_MODE
HB_GOBJECT_TYPE_OT_COLOR_PALETTE_FLAGS
HB_GOBJECT_TYPE_OT_LAYOUT_GLYPH_CLASS
HB_GOBJECT_TYPE_OT_MATH_CONSTANT
HB_GOBJECT_TYPE_OT_MATH_GLYPH_PART
HB_GOBJECT_TYPE_OT_MATH_GLYPH_PART_FLAGS
HB_GOBJECT_TYPE_OT_MATH_GLYPH_VARIANT
HB_GOBJECT_TYPE_OT_MATH_KERN
HB_GOBJECT_TYPE_SCRIPT
HB_GOBJECT_TYPE_SHAPE_PLAN
HB_GOBJECT_TYPE_UNICODE_COMBINING_CLASS
HB_GOBJECT_TYPE_UNICODE_FUNCS
HB_GOBJECT_TYPE_UNICODE_GENERAL_CATEGORY
HB_GOBJECT_TYPE_BUFFER_CLUSTER_LEVEL
HB_GOBJECT_TYPE_FEATURE
HB_GOBJECT_TYPE_GLYPH_INFO
HB_GOBJECT_TYPE_GLYPH_POSITION
HB_GOBJECT_TYPE_SEGMENT_PROPERTIES
HB_GOBJECT_TYPE_SET
HB_GOBJECT_TYPE_USER_DATA_KEY
hb_gobject_blob_get_type
hb_gobject_buffer_content_type_get_type
hb_gobject_buffer_diff_flags_get_type
hb_gobject_buffer_flags_get_type
hb_gobject_buffer_get_type
hb_gobject_buffer_serialize_flags_get_type
hb_gobject_buffer_serialize_format_get_type
hb_gobject_direction_get_type
hb_gobject_face_get_type
hb_gobject_font_funcs_get_type
hb_gobject_font_get_type
hb_gobject_glyph_flags_get_type
hb_gobject_map_get_type
hb_gobject_memory_mode_get_type
hb_gobject_ot_color_palette_flags_get_type
hb_gobject_ot_layout_glyph_class_get_type
hb_gobject_ot_math_constant_get_type
hb_gobject_ot_math_glyph_part_get_type
hb_gobject_ot_math_glyph_part_flags_get_type
hb_gobject_ot_math_glyph_variant_get_type
hb_gobject_ot_math_kern_get_type
hb_gobject_script_get_type
hb_gobject_shape_plan_get_type
hb_gobject_unicode_combining_class_get_type
hb_gobject_unicode_funcs_get_type
hb_gobject_unicode_general_category_get_type
hb_gobject_buffer_cluster_level_get_type
hb_gobject_feature_get_type
hb_gobject_glyph_info_get_type
hb_gobject_glyph_position_get_type
hb_gobject_segment_properties_get_type
hb_gobject_set_get_type
hb_gobject_user_data_key_get_type
<SUBSECTION Private>
HB_GOBJECT_H_IN
</SECTION>
<SECTION>
<FILE>hb-graphite2</FILE>
HB_GRAPHITE2_TAG_SILF
......@@ -565,7 +501,6 @@ hb_ot_layout_get_glyphs_in_class
hb_ot_layout_get_ligature_carets
hb_ot_layout_get_size_params
hb_ot_layout_glyph_class_t
hb_ot_layout_glyph_sequence_func_t
hb_ot_layout_has_glyph_classes
hb_ot_layout_has_positioning
hb_ot_layout_has_substitution
......@@ -592,6 +527,8 @@ hb_ot_layout_language_get_required_feature_index
Xhb_ot_layout_lookup_enumerate_sequences
Xhb_ot_layout_lookup_position
Xhb_ot_layout_lookup_substitute
hb_ot_layout_glyph_sequence_t
hb_ot_layout_glyph_sequence_func_t
</SECTION>
<SECTION>
......
......@@ -40,23 +40,20 @@ html_images = [
'HarfBuzz.svg',
]
ignore_headers = []
if not have_gobject
ignore_headers += [
'hb-gobject.h',
'hb-gobject-enums.h',
'hb-gobject-enums-tmp.h',
'hb-gobject-structs.h',
]
endif
ignore_headers = [
'hb-gobject.h',
'hb-gobject-enums.h',
'hb-gobject-enums-tmp.h',
'hb-gobject-structs.h',
]
gnome.gtkdoc('harfbuzz',
main_sgml: 'harfbuzz-docs.xml',
src_dir: [join_paths(meson.current_source_dir(), '..'),
join_paths(meson.current_build_dir(), '..'),
src_dir: [join_paths(meson.current_source_dir(), '../src'),
join_paths(meson.current_build_dir(), '../src'),
],
scan_args: ['--deprecated-guards=HB_DISABLE_DEPRECATED',
'--ignore-decorators=HB_EXTERN',
'--ignore-decorators=HB_EXTERN|HB_DEPRECATED',
],
mkdb_args: ['--source-suffixes=h,cc',
'--xml-mode',
......@@ -65,5 +62,5 @@ gnome.gtkdoc('harfbuzz',
content_files: content_files,
html_assets: html_images,
ignore_headers: ignore_headers,
dependencies: [libharfbuzz_dep, libharfbuzz_gobject_dep],
dependencies: [libharfbuzz_dep],
install: true)
......@@ -136,10 +136,12 @@
determine which glyph to return.
</para>
<para>
The safest approach is to add all of the text available, then
use <parameter>item_offset</parameter> and
The safest approach is to add all of the text available (even
if your text contains a mix of scripts, directions, languages
and fonts), then use <parameter>item_offset</parameter> and
<parameter>item_length</parameter> to indicate which characters you
want shaped, so that HarfBuzz has access to any context.
want shaped (which must all have the same script, direction,
language and font), so that HarfBuzz has access to any context.
</para>
<para>
You can also add Unicode code points directly with
......
......@@ -260,18 +260,18 @@
</listitem>
</itemizedlist>
<para>
You can fetch the font-functions configuration for a font object
by calling <function>hb_font_get_font_funcs()</function>:
You can create new font-functions by calling
<function>hb_font_funcs_create()</function>:
</para>
<programlisting language="C">
hb_font_funcs_t *ffunctions;
ffunctions = hb_font_get_font_funcs (font);
hb_font_funcs_t *ffunctions = hb_font_funcs_create ();
hb_font_set_funcs (font, ffunctions, font_data, destroy);
</programlisting>
<para>
The individual methods can each be replaced with their own setter
The individual methods can each be set with their own setter
function, such as
<function>hb_font_funcs_set_nominal_glyph_func(*ffunctions,
func, *user_data, destroy)</function>.
<function>hb_font_funcs_set_nominal_glyph_func(ffunctions,
func, user_data, destroy)</function>.
</para>
<para>
Font-functions structures can be reused for multiple font
......@@ -291,6 +291,20 @@
programs from changing the configuration and introducing
inconsistencies and errors downstream.
</para>
<para>
To override only some functions while using the default implementation
for the others, you will need to create a sub-font. By default, the
sub-font uses the font functions of its parent except for the functions
that were explicitly set. The following code will override only the
<function>hb_font_get_nominal_glyph_func_t</function> for the sub-font:
</para>
<programlisting language="C">
hb_font_t *subfont = hb_font_create_sub_font (font)
hb_font_funcs_t *ffunctions = hb_font_funcs_create ();
hb_font_funcs_set_nominal_glyph_func (ffunctions, func, user_data, destroy);
hb_font_set_funcs (subfont, ffunctions, font_data, destroy);
hb_font_funcs_destroy (ffunctions);
</programlisting>
</section>
<section id="fonts-and-faces-native-opentype">
......
......@@ -6,7 +6,7 @@
]>
<chapter id="getting-started">
<title>Getting started with HarfBuzz</title>
<section>
<section id="an-overview-of-the-harfbuzz-shaping-api">
<title>An overview of the HarfBuzz shaping API</title>
<para>
The core of the HarfBuzz shaping API is the function
......@@ -73,7 +73,7 @@
</para>
</section>
<section>
<section id="terminology">
<title>Terminology</title>
<para>
......@@ -201,7 +201,7 @@
</section>
<section>
<section id="a-simple-shaping-example">
<title>A simple shaping example</title>
<para>
......@@ -216,6 +216,7 @@
</orderedlist>
<programlisting language="C">
#include &lt;hb.h&gt;
hb_buffer_t *buf;
buf = hb_buffer_create();
hb_buffer_add_utf8(buf, text, -1, 0, -1);
......@@ -235,15 +236,14 @@
<orderedlist numeration="arabic">
<listitem override="3">
<para>
Create a face and a font, using FreeType for now.
Create a face and a font from a font file.
</para>
</listitem>
</orderedlist>
<programlisting language="C">
#include &lt;hb-ft.h&gt;
FT_New_Face(ft_library, font_path, index, &amp;face);
FT_Set_Char_Size(face, 0, 1000, 0, 0);
hb_font_t *font = hb_ft_font_create(face);
hb_blob_t *blob = hb_blob_create_from_file(filename);
hb_face_t *face = hb_face_create(blob, 0);
hb_font_t *font = hb_font_create(face);
</programlisting>
<orderedlist numeration="arabic">
<listitem override="4">
......@@ -263,6 +263,7 @@
</listitem>
</orderedlist>
<programlisting language="C">
unsigned int glyph_count;
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &amp;glyph_count);
hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &amp;glyph_count);
</programlisting>
......@@ -274,13 +275,15 @@
</listitem>
</orderedlist>
<programlisting language="C">
for (i = 0; i &lt; glyph_count; ++i) {
glyphid = glyph_info[i].codepoint;
x_offset = glyph_pos[i].x_offset / 64.0;
y_offset = glyph_pos[i].y_offset / 64.0;
x_advance = glyph_pos[i].x_advance / 64.0;
y_advance = glyph_pos[i].y_advance / 64.0;
draw_glyph(glyphid, cursor_x + x_offset, cursor_y + y_offset);
hb_position_t cursor_x = 0;
hb_position_t cursor_y = 0;
for (unsigned int i = 0; i &lt; glyph_count; i++) {
hb_codepoint_t glyphid = glyph_info[i].codepoint;
hb_position_t x_offset = glyph_pos[i].x_offset;
hb_position_t y_offset = glyph_pos[i].y_offset;
hb_position_t x_advance = glyph_pos[i].x_advance;
hb_position_t y_advance = glyph_pos[i].y_advance;
/* draw_glyph(glyphid, cursor_x + x_offset, cursor_y + y_offset); */
cursor_x += x_advance;
cursor_y += y_advance;
}
......@@ -294,7 +297,9 @@
</orderedlist>
<programlisting language="C">
hb_buffer_destroy(buf);
hb_font_destroy(hb_ft_font);
hb_font_destroy(font);
hb_face_destroy(face);
hb_blob_destroy(blob);
</programlisting>
<para>
......
......@@ -50,13 +50,9 @@
</para>
<para>
For example, on an Ubuntu or Debian system, you would run:
<programlisting>
<command>sudo apt install</command> <package>gcc g++ libfreetype6-dev libglib2.0-dev libcairo2-dev</package>
</programlisting>
<programlisting><command>sudo apt install</command> <package>gcc g++ libfreetype6-dev libglib2.0-dev libcairo2-dev</package></programlisting>
On Fedora, RHEL, CentOS, or other Red-Hat&ndash;based systems, you would run:
<programlisting>
<command>sudo yum install</command> <package>gcc gcc-c++ freetype-devel glib2-devel cairo-devel</package>
</programlisting>
<programlisting><command>sudo yum install</command> <package>gcc gcc-c++ freetype-devel glib2-devel cairo-devel</package></programlisting>
</para>
......@@ -89,13 +85,9 @@
</para>
<para>
On Ubuntu or Debian, run:
<programlisting>
<command>sudo apt-get install</command> <package>meson pkg-config gtk-doc-tools</package>
</programlisting>
<programlisting><command>sudo apt-get install</command> <package>meson pkg-config gtk-doc-tools</package></programlisting>
On Fedora, RHEL, CentOS, run:
<programlisting>
<command>sudo yum install</command> <package>meson pkgconfig gtk-doc</package>
</programlisting>
<programlisting><command>sudo yum install</command> <package>meson pkgconfig gtk-doc</package></programlisting>
</para>
<para>
......@@ -110,8 +102,11 @@
<title>Building on Windows</title>
<para>
Install meson and use it like `meson build --wrap-mode=default`
or use vcpkg.
<ulink url="https://mesonbuild.com/Getting-meson.html">Install meson</ulink>
and run (from the console) <command>meson build</command> (by default
bundled dependencies are not built, <command>--wrap-mode=default</command>
overrides this), then <command>meson compile -C build</command> to
build HarfBuzz.
</para>
</section>
......@@ -128,15 +123,11 @@
<emphasis>(1)</emphasis> You must first install the
development packages for FreeType, Cairo, and GLib. If you are
using MacPorts, you should run:
<programlisting>
<command>sudo port install</command> <package>freetype glib2 cairo</package>
</programlisting>
<programlisting><command>sudo port install</command> <package>freetype glib2 cairo</package></programlisting>
</para>
<para>
If you are using Homebrew, you should run:
<programlisting>
<command>brew install</command> <package>freetype glib cairo</package>
</programlisting>
<programlisting><command>brew install</command> <package>freetype glib cairo</package></programlisting>
</para>
<para>
<emphasis>(2)</emphasis> The next step depends on whether you are building from the
......@@ -147,13 +138,9 @@
<emphasis>(2)(a)</emphasis> If you are installing HarfBuzz
from a downloaded tarball release, extract the tarball and
open a Terminal in the extracted source-code directory. Run:
<programlisting>
<command>meson build</command>
</programlisting>
<programlisting><command>meson build</command></programlisting>
followed by:
<programlisting>
<command>meson compile -C build</command>
</programlisting>
<programlisting><command>meson compile -C build</command></programlisting>
to build HarfBuzz.
</para>
<para>
......@@ -164,30 +151,20 @@
</para>
<para>If you are
using MacPorts, you should run:
<programlisting>
<command>sudo port install</command> <package>meson pkgconfig gtk-doc</package>
</programlisting>
<programlisting><command>sudo port install</command> <package>meson pkgconfig gtk-doc</package></programlisting>
to install the build dependencies.
</para>
<para>If you are using Homebrew, you should run:
<programlisting>
<command>brew install</command> <package>meson pkgconfig gtk-doc</package>
</programlisting>
<programlisting><command>brew install</command> <package>meson pkgconfig gtk-doc</package></programlisting>
Finally, you can run:
<programlisting>
<command>meson build</command>
</programlisting>
<programlisting><command>meson build</command></programlisting>
</para>
<para>
<emphasis>(3)</emphasis> You can now build HarfBuzz (on either
a MacPorts or a Homebrew system) by running:
<programlisting>
<command>meson build</command>
</programlisting>
<programlisting><command>meson build</command></programlisting>
followed by:
<programlisting>
<command>meson compile -C build</command>
</programlisting>
<programlisting><command>meson compile -C build</command></programlisting>
</para>
<para>
This should leave you with a shared
......@@ -261,26 +238,6 @@
</listitem>
</varlistentry>
<varlistentry>
<term><command>-Dfontconfig=enabled</command></term>
<listitem>
<para>
Use <ulink url="https://www.freedesktop.org/wiki/Software/fontconfig/">Fontconfig</ulink>. <emphasis>(Default = auto)</emphasis>
</para>
<para>
This option enables or disables usage of the Fontconfig
library, which provides font-matching functions and
provides access to font properties. The default setting
is to check for the presence of Fontconfig and, if it is
found, build with Fontconfig support.
</para>
<para>
Note: Fontconfig is used only by the HarfBuzz
command-line utilities, and not by the HarfBuzz library.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>-Dicu=enabled</command></term>
<listitem>
......
......@@ -232,7 +232,7 @@
different.
</para>
<para>
Blobs are an abstraction desgined to negotiate lifecycle and
Blobs are an abstraction designed to negotiate lifecycle and
permissions for raw pieces of data. For example, when you load
the raw font data into memory and want to pass it to HarfBuzz,
you do so in a <literal>hb_blob_t</literal> wrapper.
......
......@@ -48,14 +48,14 @@
<para>
If a font has a GDEF table, then that is used for
glyph classes; if not, HarfBuzz will fall back to Unicode
categorization by code point. If a font has an AAT "morx" table,
categorization by code point. If a font has an AAT <literal>morx</literal> table,
then it is used for substitutions; if not, but there is a GSUB
table, then the GSUB table is used. If the font has an AAT
"kerx" table, then it is used for positioning; if not, but
<literal>kerx</literal> table, then it is used for positioning; if not, but
there is a GPOS table, then the GPOS table is used. If neither
table is found, but there is a "kern" table, then HarfBuzz will
use the "kern" table. If there is no "kerx", no GPOS, and no
"kern", HarfBuzz will fall back to positioning marks itself.
table is found, but there is a <literal>kern</literal> table, then HarfBuzz will
use the <literal>kern</literal> table. If there is no <literal>kerx</literal>, no GPOS, and no
<literal>kern</literal>, HarfBuzz will fall back to positioning marks itself.
</para>
<para>
With a well-behaved OpenType font, you expect GDEF, GSUB, and
......@@ -149,9 +149,39 @@
also applies the <literal>calt</literal>,
<literal>clig</literal>, <literal>curs</literal>,
<literal>dist</literal>, <literal>kern</literal>,
<literal>liga</literal>, <literal>rclt</literal>,
and <literal>frac</literal> features.
<literal>liga</literal> and <literal>rclt</literal>, features.
</para>
<para>
Additionally, when HarfBuzz encounters a fraction slash
(<literal>U+2044</literal>), it looks backward and forward for decimal
digits (Unicode General Category = Nd), and enables features
<literal>numr</literal> on the sequence before the fraction slash,
<literal>dnom</literal> on the sequence after the fraction slash,
and <literal>frac</literal> on the whole sequence including the fraction
slash.
</para>
<para>
Some script-specific shaping models
(see <xref linkend="opentype-shaping-models" />) disable some of the
features listed above:
</para>
<itemizedlist>
<listitem>
<para>
Hangul: <literal>calt</literal>
</para>
</listitem>
<listitem>
<para>
Indic: <literal>liga</literal>
</para>
</listitem>
<listitem>
<para>
Khmer: <literal>liga</literal>
</para>
</listitem>
</itemizedlist>
<para>
If the text direction is vertical, HarfBuzz applies
the <literal>vert</literal> feature by default.
......
......@@ -10,8 +10,7 @@
HarfBuzz includes several auxiliary components in addition to the
main APIs. These include a set of command-line tools, a set of
lower-level APIs for common data types that may be of interest to
client programs, and an embedded library for working with
Unicode Character Database (UCD) data.
client programs.
</para>
<section id="utilities-command-line-tools">
......@@ -216,29 +215,4 @@
</para>
</section>
<section id="utilities-ucdn">
<title>UCDN</title>
<para>
HarfBuzz includes a copy of the <ulink
url="https://github.com/grigorig/ucdn">UCDN</ulink> (Unicode
Database and Normalization) library, which provides functions
for accessing basic Unicode character properties, performing
canonical composition, and performing both canonical and
compatibility decomposition.
</para>
<para>
Currently, UCDN supports direct queries for several more character
properties than HarfBuzz's built-in set of Unicode functions
does, such as the BiDirectional Class, East Asian Width, Paired
Bracket and Resolved Linebreak properties. If you need to access
more properties than HarfBuzz's internal implementation
provides, using the built-in UCDN functions may be a useful solution.
</para>
<para>
The built-in UCDN functions are compiled by default when
building HarfBuzz from source, but this can be disabled with a
compile-time switch.
</para>
</section>
</chapter>
......@@ -226,7 +226,7 @@
</section>
<section>
<section id="what-does-harfbuzz-do">
<title>What does HarfBuzz do?</title>
<para>
HarfBuzz provides text shaping through a cross-platform
......
void memory_barrier (void) { __sync_synchronize (); }
int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
void mutex_unlock (int *m) { __sync_lock_release (m); }
int main(void) { return 0;}
#include <atomic.h>
/* This requires Solaris Studio 12.2 or newer: */
#include <mbarrier.h>
void memory_barrier (void) { __machine_rw_barrier (); }
int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
int main(void) { return 0; }
project('harfbuzz', 'c', 'cpp',
meson_version: '>= 0.47.0',
version: '2.7.2',
version: '2.8.1',
default_options: [
'cpp_eh=none', # Just to support msvc, we are passing -fno-rtti also anyway
'cpp_rtti=false', # Just to support msvc, we are passing -fno-exceptions also anyway
......@@ -95,8 +95,6 @@ glib_dep = dependency('glib-2.0', required: get_option('glib'),
fallback: ['glib', 'libglib_dep'])
gobject_dep = dependency('gobject-2.0', required: get_option('gobject'),
fallback: ['glib', 'libgobject_dep'])
fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'),
fallback: ['fontconfig', 'fontconfig_dep'])
graphite2_dep = dependency('graphite2', required: get_option('graphite'))
icu_dep = null_dep
......@@ -127,38 +125,37 @@ cairo_dep = null_dep
cairo_ft_dep = null_dep
if not get_option('cairo').disabled()
cairo_dep = dependency('cairo', required: false)
cairo_ft_dep = dependency('cairo-ft', required: false)
if (not cairo_dep.found() and
cpp.get_id() == 'msvc' and
cpp.has_header('cairo.h'))
cairo_dep = cpp.find_library('cairo', required: false)
if cairo_dep.found() and cpp.has_function('cairo_ft_font_face_create_for_ft_face',
prefix: '#include <cairo-ft.h>',
dependencies: cairo_dep)
cairo_ft_dep = cairo_dep
endif
endif
if not cairo_dep.found()
# Note that we don't have harfbuzz -> cairo -> freetype2 -> harfbuzz fallback
# dependency cycle here because we have configured freetype2 above with
# harfbuzz support disabled, so when cairo will lookup freetype2 dependency
# it will be forced to use that one.
cairo_dep = dependency('cairo', fallback: ['cairo', 'libcairo_dep'],
required: get_option('cairo'))
endif
# Ensure that cairo-ft is fetched from the same library as cairo itself
if cairo_dep.found()
if cairo_dep.type_name() == 'internal'
# It is true at least for the port we have
cairo_ft_dep = cairo_dep
elif (cairo_dep.type_name() == 'library' and
cpp.has_function('cairo_ft_font_face_create_for_ft_face',
prefix: '#include <cairo-ft.h>',
dependencies: cairo_dep))
cairo_ft_dep = cairo_dep
else # including the most important type for us, 'pkgconfig'
cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo'))
# Requires Meson 0.54.0 to use cairo subproject
if meson.version().version_compare('>=0.54.0')
# Note that we don't have harfbuzz -> cairo -> freetype2 -> harfbuzz fallback
# dependency cycle here because we have configured freetype2 above with
# harfbuzz support disabled, so when cairo will lookup freetype2 dependency
# it will be forced to use that one.
cairo_dep = dependency('cairo', fallback: 'cairo', required: get_option('cairo'))
cairo_ft_dep = dependency('cairo-ft', fallback: 'cairo', required: get_option('cairo'))
elif get_option('cairo').enabled()
error('cairo feature is enabled but it cannot be found on the system and ' +
'meson>=0.54.0 is required to build it as subproject')
endif
endif
endif
chafa_dep = dependency('chafa', version: '>= 1.6.0', required: get_option('chafa'))
conf = configuration_data()
incconfig = include_directories('.')
......@@ -186,6 +183,10 @@ if cairo_ft_dep.found()
conf.set('HAVE_CAIRO_FT', 1)
endif
if chafa_dep.found()
conf.set('HAVE_CHAFA', 1)
endif
if graphite2_dep.found()
conf.set('HAVE_GRAPHITE2', 1)
endif
......@@ -220,10 +221,6 @@ if freetype_dep.found()
endif
endif
if fontconfig_dep.found()
conf.set('HAVE_FONTCONFIG', 1)
endif
gdi_uniscribe_deps = []
# GDI (Uniscribe) (Windows)
if host_machine.system() == 'windows' and not get_option('gdi').disabled()
......@@ -288,9 +285,6 @@ if host_machine.system() != 'windows'
if thread_dep.found()
conf.set('HAVE_PTHREAD', 1)
else
check_headers += ['sched.h']
check_funcs += ['sched_yield', {'link_with': 'rt'}]
endif
endif
......@@ -340,14 +334,6 @@ foreach check : check_funcs
endif
endforeach
if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics')
conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1)
endif
if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops')
conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1)
endif
subdir('src')
subdir('util')
......@@ -355,16 +341,8 @@ if not get_option('tests').disabled()
subdir('test')
endif
# get_option('wrap_mode') isn't available in <0.49 and this
# is just an internal tool
if meson.version().version_compare('>=0.49')
if (not get_option('benchmark').disabled() and
get_option('wrap_mode') != 'nodownload' and
host_machine.system() != 'windows' and
not meson.is_subproject() and
not meson.is_cross_build())
subdir('perf')
endif
if not get_option('benchmark').disabled()
subdir('perf')
endif
if not get_option('docs').disabled()
......@@ -391,7 +369,7 @@ build_summary = {
},
'Dependencies used for command-line utilities':
{'Cairo': conf.get('HAVE_CAIRO', 0) == 1,
'Fontconfig': conf.get('HAVE_FONTCONFIG', 0) == 1,
'Chafa': conf.get('HAVE_CHAFA', 0) == 1,
},
'Additional shapers':
{'Graphite2': conf.get('HAVE_GRAPHITE2', 0) == 1,
......@@ -405,6 +383,11 @@ build_summary = {
{'Documentation': conf.get('HAVE_GTK_DOC', 0) == 1,
'GObject bindings': conf.get('HAVE_GOBJECT', 0) == 1,
'Introspection': conf.get('HAVE_INTROSPECTION', 0) == 1,
'Experimental APIs': conf.get('HB_EXPERIMENTAL_API', 0) == 1,
},
'Testing':
{'Tests': get_option('tests').enabled(),
'Benchmark': get_option('benchmark').enabled(),
},
}
if meson.version().version_compare('>=0.53')
......
......@@ -5,8 +5,8 @@ option('gobject', type: 'feature', value: 'auto',
description: 'Enable GObject bindings')
option('cairo', type: 'feature', value: 'auto',
description: 'Use Cairo graphics library')
option('fontconfig', type: 'feature', value: 'auto',
description: 'Use fontconfig')
option('chafa', type: 'feature', value: 'auto',
description: 'Use Chafa terminal graphics library')
option('icu', type: 'feature', value: 'auto',
description: 'Enable ICU library unicode functions')
option('graphite', type: 'feature', value: 'disabled',
......@@ -28,7 +28,7 @@ option('introspection', type: 'feature', value: 'auto', yield: true,
option('docs', type: 'feature', value: 'auto', yield: true,
description: 'Generate documentation with gtk-doc')
option('benchmark', type: 'feature', value: 'auto',
option('benchmark', type: 'feature', value: 'disabled',
description: 'Enable benchmark tests')
option('icu_builtin', type: 'boolean', value: false,
description: 'Don\'t separate ICU support as harfbuzz-icu module')
......
......@@ -2841,7 +2841,6 @@ Deseret
DESERET
deserialize
DESERIALIZE
desgined
design
Design
DESIGN
......
......@@ -235,7 +235,8 @@ DEF_FILES += harfbuzz-gobject.def
endif
check: $(DEF_FILES) # For check-symbols.sh
CLEANFILES += $(DEF_FILES)
harfbuzz.def: $(HBHEADERS) $(HBNODISTHEADERS)
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 "$@" $^
......@@ -341,26 +342,7 @@ 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)
check_PROGRAMS += \
dump-indic-data \
dump-khmer-data \
dump-myanmar-data \
dump-use-data \
$(NULL)
dump_indic_data_SOURCES = dump-indic-data.cc hb-ot-shape-complex-indic-table.cc
dump_indic_data_CPPFLAGS = $(HBCFLAGS)
dump_indic_data_LDADD = libharfbuzz.la $(HBLIBS)
dump_khmer_data_SOURCES = dump-khmer-data.cc hb-ot-shape-complex-indic-table.cc
dump_khmer_data_CPPFLAGS = $(HBCFLAGS)
dump_khmer_data_LDADD = libharfbuzz.la $(HBLIBS)
dump_myanmar_data_SOURCES = dump-myanmar-data.cc hb-ot-shape-complex-indic-table.cc
dump_myanmar_data_CPPFLAGS = $(HBCFLAGS)
dump_myanmar_data_LDADD = libharfbuzz.la $(HBLIBS)
dump_use_data_SOURCES = dump-use-data.cc hb-ot-shape-complex-use-table.cc
dump_use_data_CPPFLAGS = $(HBCFLAGS)
dump_use_data_LDADD = libharfbuzz.la $(HBLIBS)
COMPILED_TESTS = test-algs test-array test-iter test-meta test-number test-ot-tag test-unicode-ranges test-bimap
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)
......@@ -374,6 +356,14 @@ 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)
......@@ -444,14 +434,7 @@ 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_AAT_H \
-DHB_AAT_H_IN \
-DHB_GOBJECT_H \
-DHB_GOBJECT_H_IN \
-DHB_NO_SINGLE_HEADER_ERROR \
-DHAVE_GOBJECT \
-DHB_EXTERN= \
$(NULL)
......
......@@ -120,10 +120,11 @@ HB_BASE_sources = \
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.cc \
hb-ot-shape-complex-use-table.hh \
hb-ot-shape-complex-use.cc \
hb-ot-shape-complex-use.hh \
hb-ot-shape-complex-vowel-constraints.cc \
hb-ot-shape-complex-vowel-constraints.hh \
hb-ot-shape-complex.hh \
......@@ -166,6 +167,7 @@ HB_BASE_sources = \
hb-unicode.hh \
hb-utf.hh \
hb-vector.hh \
hb-priority-queue.hh \
hb.hh \
$(NULL)
......@@ -265,10 +267,9 @@ HB_SUBSET_sources = \
hb-subset-input.hh \
hb-subset-plan.cc \
hb-subset-plan.hh \
hb-subset-plan.hh \
hb-subset.cc \
hb-subset.hh \
hb-subset.hh \
hb-repacker.hh \
$(NULL)
HB_SUBSET_headers = \
......
/*
* 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
*/
#include "hb-ot-shape-complex-khmer.hh"
int
main ()
{
for (hb_codepoint_t u = 0; u <= 0x10FFFF; u++)
{
hb_glyph_info_t info;
info.codepoint = u;
set_khmer_properties (info);
if (info.khmer_category() != INDIC_SYLLABIC_CATEGORY_OTHER)
printf("U+%04X %u\n", u,
info.khmer_category());
}
}
......@@ -2,17 +2,26 @@
"This tool is intended to be used from meson"
import os, sys, shutil
import os, sys, shutil, re
if len (sys.argv) < 5:
if len (sys.argv) < 4:
sys.exit(__doc__)
version = sys.argv[1]
major, minor, micro = version.split (".")
OUTPUT = sys.argv[2]
CURRENT_SOURCE_DIR = sys.argv[3]
INPUT = sys.argv[4]
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:
......
......@@ -200,7 +200,7 @@ 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
......@@ -234,7 +234,7 @@ occupancy = used * 100. / total
page_bits = 12
print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy))
print ()
print ("INDIC_TABLE_ELEMENT_TYPE")
print ("uint16_t")
print ("hb_indic_get_categories (hb_codepoint_t u)")
print ("{")
print (" switch (u >> %d)" % page_bits)
......
......@@ -25,10 +25,8 @@ Input files:
"""
import collections
import html
from html.parser import HTMLParser
def write (s):
sys.stdout.flush ()
sys.stdout.buffer.write (s.encode ('utf-8'))
import itertools
import re
import sys
......@@ -37,16 +35,18 @@ import unicodedata
if len (sys.argv) != 3:
sys.exit (__doc__)
from html import unescape
def html_unescape (parser, entity):
return unescape (entity)
def expect (condition, message=None):
if not condition:
if message is None:
raise AssertionError
raise AssertionError (message)
def write (s):
sys.stdout.flush ()
sys.stdout.buffer.write (s.encode ('utf-8'))
DEFAULT_LANGUAGE_SYSTEM = ''
# from https://www-01.sil.org/iso639-3/iso-639-3.tab
ISO_639_3_TO_1 = {
'aar': 'aa',
......@@ -381,10 +381,10 @@ class OpenTypeRegistryParser (HTMLParser):
self._current_tr[-1] += data
def handle_charref (self, name):
self.handle_data (html_unescape (self, '&#%s;' % name))
self.handle_data (html.unescape ('&#%s;' % name))
def handle_entityref (self, name):
self.handle_data (html_unescape (self, '&%s;' % name))
self.handle_data (html.unescape ('&%s;' % name))
def parse (self, filename):
"""Parse the OpenType language system tag registry.
......@@ -468,11 +468,8 @@ class OpenTypeRegistryParser (HTMLParser):
if ot_macrolanguages:
for ot_macrolanguage in ot_macrolanguages:
for language in languages:
# Remove the following condition if e.g. nn should map to NYN,NOR
# instead of just NYN.
if language not in original_ot_from_bcp_47:
self.add_language (language, ot_macrolanguage)
self.ranks[ot_macrolanguage] += 1
self.add_language (language, ot_macrolanguage)
self.ranks[ot_macrolanguage] += 1
else:
for language in languages:
if language in original_ot_from_bcp_47:
......@@ -556,7 +553,7 @@ class BCP47Parser (object):
self.grandfathered.add (subtag.lower ())
elif line.startswith ('Description: '):
description = line.split (' ', 1)[1].replace (' (individual language)', '')
description = re.sub (' (\((individual |macro)language\)|languages)$', '',
description = re.sub (' (\(family\)|\((individual |macro)language\)|languages)$', '',
description)
if subtag in self.names:
self.names[subtag] += '\n' + description
......@@ -591,7 +588,9 @@ class BCP47Parser (object):
elif not has_preferred_value and line.startswith ('Macrolanguage: '):
self._add_macrolanguage (line.split (' ')[1], subtag)
elif subtag_type == 'variant':
if line.startswith ('Prefix: '):
if line.startswith ('Deprecated: '):
self.scopes[subtag] = ' (retired code)' + self.scopes.get (subtag, '')
elif line.startswith ('Prefix: '):
self.prefixes[subtag].add (line.split (' ')[1])
elif line.startswith ('File-Date: '):
self.header = line
......@@ -622,6 +621,17 @@ class BCP47Parser (object):
for macrolanguage in macrolanguages:
self._add_macrolanguage (biggest_macrolanguage, macrolanguage)
def _get_name_piece (self, subtag):
"""Return the first name of a subtag plus its scope suffix.
Args:
subtag (str): A BCP 47 subtag.
Returns:
The name form of ``subtag``.
"""
return self.names[subtag].split ('\n')[0] + self.scopes.get (subtag, '')
def get_name (self, lt):
"""Return the names of the subtags in a language tag.
......@@ -631,13 +641,13 @@ class BCP47Parser (object):
Returns:
The name form of ``lt``.
"""
name = self.names[lt.language].split ('\n')[0]
name = self._get_name_piece (lt.language)
if lt.script:
name += '; ' + self.names[lt.script.title ()].split ('\n')[0]
name += '; ' + self._get_name_piece (lt.script.title ())
if lt.region:
name += '; ' + self.names[lt.region.upper ()].split ('\n')[0]
name += '; ' + self._get_name_piece (lt.region.upper ())
if lt.variant:
name += '; ' + self.names[lt.variant].split ('\n')[0]
name += '; ' + self._get_name_piece (lt.variant)
return name
bcp_47 = BCP47Parser ()
......@@ -673,22 +683,18 @@ ot.add_language ('und-fonnapa', 'APPH')
ot.remove_language_ot ('IRT')
ot.add_language ('ga-Latg', 'IRT')
ot.add_language ('hy-arevmda', 'HYE')
ot.remove_language_ot ('KGE')
ot.add_language ('und-Geok', 'KGE')
ot.add_language ('guk', 'GUK')
ot.names['GUK'] = 'Gumuz (SIL fonts)'
ot.ranks['GUK'] = ot.ranks['GMZ'] + 1
bcp_47.macrolanguages['id'] = {'in'}
bcp_47.macrolanguages['ijo'] = {'ijc'}
ot.add_language ('kht', 'KHN')
ot.names['KHN'] = ot.names['KHT'] + ' (Microsoft fonts)'
ot.names['KHT'] = ot.names['KHT'] + ' (OpenType spec and SIL fonts)'
ot.ranks['KHN'] = ot.ranks['KHT']
ot.ranks['KHT'] += 1
ot.ranks['KHN'] = ot.ranks['KHT'] + 1
ot.ranks['LCR'] = ot.ranks['MCR'] + 1
......@@ -706,6 +712,7 @@ ot.add_language ('qu', 'QUZ')
ot.add_language ('qub', 'QWH')
ot.add_language ('qud', 'QVI')
ot.add_language ('qug', 'QVI')
ot.add_language ('qul', 'QUH')
ot.add_language ('qup', 'QVI')
ot.add_language ('qur', 'QWH')
ot.add_language ('qus', 'QUH')
......@@ -736,10 +743,6 @@ ot.add_language ('qxw', 'QWH')
bcp_47.macrolanguages['ro'].remove ('mo')
bcp_47.macrolanguages['ro-MD'].add ('mo')
ot.add_language ('sgw', 'SGW')
ot.names['SGW'] = ot.names['CHG'] + ' (SIL fonts)'
ot.ranks['SGW'] = ot.ranks['CHG'] + 1
ot.remove_language_ot ('SYRE')
ot.remove_language_ot ('SYRJ')
ot.remove_language_ot ('SYRN')
......@@ -756,14 +759,17 @@ ot.add_language ('xwo', 'TOD')
ot.remove_language_ot ('ZHH')
ot.remove_language_ot ('ZHP')
ot.remove_language_ot ('ZHT')
ot.remove_language_ot ('ZHTM')
bcp_47.macrolanguages['zh'].remove ('lzh')
bcp_47.macrolanguages['zh'].remove ('yue')
ot.add_language ('zh-Hant-MO', 'ZHH')
ot.add_language ('zh-Hant-MO', 'ZHTM')
ot.add_language ('zh-Hant-HK', 'ZHH')
ot.add_language ('zh-Hans', 'ZHS')
ot.add_language ('zh-Hant', 'ZHT')
ot.add_language ('zh-HK', 'ZHH')
ot.add_language ('zh-MO', 'ZHH')
ot.add_language ('zh-MO', 'ZHTM')
ot.add_language ('zh-TW', 'ZHT')
ot.add_language ('lzh', 'ZHT')
ot.add_language ('lzh-Hans', 'ZHS')
......@@ -795,6 +801,7 @@ def rank_delta (bcp_47, ot):
disambiguation = {
'ALT': 'alt',
'ARK': 'rki',
'ATH': 'ath',
'BHI': 'bhb',
'BLN': 'bjt',
'BTI': 'beb',
......@@ -806,6 +813,7 @@ disambiguation = {
'ECR': 'crj',
'HAL': 'cfm',
'HND': 'hnd',
'HYE': 'hyw',
'KIS': 'kqs',
'KUI': 'uki',
'LRC': 'bqi',
......@@ -818,15 +826,24 @@ disambiguation = {
'QVI': 'qvi',
'QWH': 'qwh',
'SIG': 'stv',
'TNE': 'yrk',
'SRB': 'sr',
'SXT': 'xnj',
'ZHH': 'zh-HK',
'ZHS': 'zh-Hans',
'ZHT': 'zh-Hant',
'ZHTM': 'zh-MO',
}
ot.inherit_from_macrolanguages ()
bcp_47.remove_extra_macrolanguages ()
ot.inherit_from_macrolanguages ()
ot.names[DEFAULT_LANGUAGE_SYSTEM] = '*/'
ot.ranks[DEFAULT_LANGUAGE_SYSTEM] = max (ot.ranks.values ()) + 1
for tricky_ot_tag in filter (lambda tag: re.match ('[A-Z]{3}$', tag), ot.names):
possible_bcp_47_tag = tricky_ot_tag.lower ()
if possible_bcp_47_tag in bcp_47.names and not ot.from_bcp_47[possible_bcp_47_tag]:
ot.add_language (possible_bcp_47_tag, DEFAULT_LANGUAGE_SYSTEM)
bcp_47.macrolanguages[possible_bcp_47_tag] = set ()
ot.sort_languages ()
print ('/* == Start of generated table == */')
......@@ -855,6 +872,8 @@ def hb_tag (tag):
Returns:
A snippet of C++ representing ``tag``.
"""
if tag == DEFAULT_LANGUAGE_SYSTEM:
return 'HB_TAG_NONE\t '
return "HB_TAG('%s','%s','%s','%s')" % tuple (('%-4s' % tag)[:4])
def get_variant_set (name):
......@@ -903,14 +922,18 @@ for language, tags in sorted (ot.from_bcp_47.items ()):
print ('\t/* ', end='')
bcp_47_name = bcp_47.names.get (language, '')
bcp_47_name_candidates = bcp_47_name.split ('\n')
intersection = language_name_intersection (bcp_47_name, ot.names[tag])
ot_name = ot.names[tag]
scope = bcp_47.scopes.get (language, '')
if not intersection:
write ('%s%s -> %s' % (bcp_47_name_candidates[0], scope, ot.names[tag]))
if tag == DEFAULT_LANGUAGE_SYSTEM:
write (f'{bcp_47_name_candidates[0]}{scope} != {ot.names[language.upper ()]}')
else:
name = get_matching_language_name (intersection, bcp_47_name_candidates)
bcp_47.names[language] = name
write ('%s%s' % (name if len (name) > len (ot.names[tag]) else ot.names[tag], scope))
intersection = language_name_intersection (bcp_47_name, ot_name)
if not intersection:
write ('%s%s -> %s' % (bcp_47_name_candidates[0], scope, ot_name))
else:
name = get_matching_language_name (intersection, bcp_47_name_candidates)
bcp_47.names[language] = name
write ('%s%s' % (name if len (name) > len (ot_name) else ot_name, scope))
print (' */')
print ('};')
......@@ -992,22 +1015,24 @@ for initial, items in sorted (complex_tags.items ()):
print (" case '%s':" % initial)
for lt, tags in items:
print (' if (', end='')
script = lt.script
region = lt.region
if lt.grandfathered:
print ('0 == strcmp (&lang_str[1], "%s")' % lt.language[1:], end='')
else:
string_literal = lt.language[1:] + '-'
if lt.script:
string_literal += lt.script
lt.script = None
if lt.region:
string_literal += '-' + lt.region
lt.region = None
if script:
string_literal += script
script = None
if region:
string_literal += '-' + region
region = None
if string_literal[-1] == '-':
print ('0 == strncmp (&lang_str[1], "%s", %i)' % (string_literal, len (string_literal)), end='')
else:
print ('lang_matches (&lang_str[1], "%s")' % string_literal, end='')
print_subtag_matches (lt.script, True)
print_subtag_matches (lt.region, True)
print_subtag_matches (script, True)
print_subtag_matches (region, True)
print_subtag_matches (lt.variant, True)
print (')')
print (' {')
......@@ -1074,11 +1099,18 @@ def verify_disambiguation_dict ():
global disambiguation
global ot
for ot_tag, bcp_47_tags in ot.to_bcp_47.items ():
primary_tags = list (t for t in bcp_47_tags if t not in bcp_47.grandfathered and ot.from_bcp_47.get (t)[0] == ot_tag)
if ot_tag == DEFAULT_LANGUAGE_SYSTEM:
primary_tags = []
else:
primary_tags = list (t for t in bcp_47_tags if t not in bcp_47.grandfathered and ot.from_bcp_47.get (t)[0] == ot_tag)
if len (primary_tags) == 1:
expect (ot_tag not in disambiguation, 'unnecessary disambiguation for OT tag: %s' % ot_tag)
if '-' in primary_tags[0]:
disambiguation[ot_tag] = primary_tags[0]
else:
first_tag = sorted (t for t in bcp_47_tags if t not in bcp_47.grandfathered and ot_tag in ot.from_bcp_47.get (t))[0]
if primary_tags[0] != first_tag:
disambiguation[ot_tag] = primary_tags[0]
elif len (primary_tags) == 0:
expect (ot_tag not in disambiguation, 'There is no possible valid disambiguation for %s' % ot_tag)
else:
......@@ -1093,8 +1125,8 @@ def verify_disambiguation_dict ():
'%s is not a valid disambiguation for %s' % (disambiguation[ot_tag], ot_tag))
elif ot_tag not in disambiguation:
disambiguation[ot_tag] = macrolanguages[0]
different_primary_tags = sorted (t for t in primary_tags if not same_tag (t, ot.from_bcp_47.get (t)))
if different_primary_tags and disambiguation[ot_tag] == different_primary_tags[0] and '-' not in disambiguation[ot_tag]:
different_bcp_47_tags = sorted (t for t in bcp_47_tags if not same_tag (t, ot.from_bcp_47.get (t)))
if different_bcp_47_tags and disambiguation[ot_tag] == different_bcp_47_tags[0] and '-' not in disambiguation[ot_tag]:
del disambiguation[ot_tag]
for ot_tag in disambiguation.keys ():
expect (ot_tag in ot.to_bcp_47, 'unknown OT tag: %s' % ot_tag)
......
#!/usr/bin/env python3
# flake8: noqa: F821
"""usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt
"""usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt ArabicShaping.txt Blocks.txt IndicSyllabicCategory-Additional.txt IndicPositionalCategory-Additional.txt
Input file:
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:
if len (sys.argv) != 8:
sys.exit (__doc__)
BLACKLISTED_BLOCKS = ["Thai", "Lao"]
BLACKLISTED_BLOCKS = [
'Samaritan',
'Thai',
'Lao',
]
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 _ 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]
......@@ -42,16 +63,25 @@ 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]
......@@ -61,6 +91,29 @@ data[0][0x1B67] = defaults[0]
data[0][0x1B69] = defaults[0]
data[0][0x1B6A] = defaults[0]
data[0][0x2060] = defaults[0]
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'
......@@ -72,8 +125,6 @@ data[0][0x11C44] = 'Consonant_Placeholder'
data[0][0x11C45] = 'Consonant_Placeholder'
# TODO https://github.com/harfbuzz/harfbuzz/pull/1399
data[0][0x111C8] = 'Consonant_Placeholder'
for u in range (0xFE00, 0xFE0F + 1):
data[0][u] = defaults[0]
# Merge data into one dict:
for i,v in enumerate (defaults):
......@@ -86,7 +137,7 @@ 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 BLACKLISTED_BLOCKS}
data = combined
del combined
......@@ -133,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',
......@@ -150,6 +205,14 @@ property_names = [
'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):
......@@ -174,99 +237,86 @@ 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 [0x104B, 0x104E, 0x1B5B, 0x1B5C, 0x1B5F, 0x2022, 0x111C8, 0x11A3F, 0x11A45, 0x11C44, 0x11C45]) 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):
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):
return UISC in [Nukta, Gemination_Mark, Consonant_Killer]
def is_CONS_SUB(U, UISC, UGC):
#SPEC-DRAFT return UISC == Consonant_Subjoined
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_CONS_WITH_STACKER(U, UISC, UGC):
def is_CONS_WITH_STACKER(U, UISC, UGC, AJT):
return UISC == Consonant_With_Stacker
def is_HALANT(U, UISC, UGC):
def is_HALANT(U, UISC, UGC, AJT):
return (UISC in [Virama, Invisible_Stacker]
and not is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UGC)
and not is_SAKOT(U, UISC, UGC))
def is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UGC):
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):
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(U, UISC, UGC)
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):
def is_REPHA(U, UISC, UGC, AJT):
return UISC in [Consonant_Preceding_Repha, Consonant_Prefixed]
def is_SAKOT(U, UISC, UGC):
def is_SAKOT(U, UISC, UGC, AJT):
return U == 0x1A60
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] and U not in [0x1B62, 0x1B68]
def is_SYM_MOD(U, UISC, UGC):
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):
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):
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,
......@@ -276,16 +326,16 @@ use_mapping = {
'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,
}
......@@ -304,13 +354,13 @@ use_positions = {
},
'CM': {
'Abv': [Top],
'Blw': [Bottom],
'Blw': [Bottom, Overstruck],
},
'V': {
'Abv': [Top, Top_And_Bottom, Top_And_Bottom_And_Right, Top_And_Right],
'Blw': [Bottom, Overstruck, Bottom_And_Right],
'Pst': [Right, Top_And_Left, Top_And_Left_And_Right, Left_And_Right],
'Pre': [Left],
'Pst': [Right],
'Pre': [Left, Top_And_Left, Top_And_Left_And_Right, Left_And_Right],
},
'VM': {
'Abv': [Top],
......@@ -330,13 +380,14 @@ use_positions = {
'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
......@@ -346,20 +397,6 @@ def map_to_use(data):
# 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
if 0x0F86 <= U <= 0x0F87: UISC = Tone_Mark
# Overrides to allow NFC order matching syllable
# https://github.com/harfbuzz/harfbuzz/issues/1012
if UBlock == 'Tibetan' and is_VOWEL (U, UISC, UGC):
if UIPC == Top:
UIPC = Bottom
# TODO: https://github.com/harfbuzz/harfbuzz/pull/982
# also https://github.com/harfbuzz/harfbuzz/issues/1012
if UBlock == 'Chakma' and is_VOWEL (U, UISC, UGC):
if UIPC == Top:
UIPC = Bottom
elif UIPC == Bottom:
UIPC = Top
# TODO: https://github.com/harfbuzz/harfbuzz/pull/627
if 0x1BF2 <= U <= 0x1BF3: UISC = Nukta; UIPC = Bottom
......@@ -368,11 +405,11 @@ def map_to_use(data):
# the nasalization marks, maybe only for U+1CE9..U+1CF1.
if U == 0x1CED: UISC = Tone_Mark
# TODO: https://github.com/harfbuzz/harfbuzz/issues/1105
if U == 0x11134: UISC = Gemination_Mark
# 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)]
assert len(values) == 1, "%s %s %s %s" % (hex(U), UISC, UGC, values)
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
......@@ -380,9 +417,6 @@ def map_to_use(data):
# TODO: These should die, but have UIPC in Unicode 13.0.0
if U in [0x953, 0x954]: UIPC = Not_Applicable
# TODO: https://github.com/harfbuzz/harfbuzz/pull/2012
if U == 0x1C29: UIPC = Left
# 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
# TODO: https://github.com/harfbuzz/harfbuzz/pull/1037
......@@ -390,14 +424,18 @@ def map_to_use(data):
if U in [0x11302, 0x11303, 0x114C1]: UIPC = Top
if 0x1CF8 <= U <= 0x1CF9: UIPC = Top
assert (UIPC in [Not_Applicable, Visual_Order_Left] or
USE == 'R' 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)
......@@ -410,7 +448,7 @@ 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 (" * {} 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 (" *")
......@@ -419,11 +457,12 @@ for h in headers:
print (" * %s" % (l.strip()))
print (" */")
print ()
print ('#include "hb.hh"')
print ("#ifndef HB_OT_SHAPE_COMPLEX_USE_TABLE_HH")
print ("#define HB_OT_SHAPE_COMPLEX_USE_TABLE_HH")
print ()
print ('#ifndef HB_NO_OT_SHAPE')
print ('#include "hb.hh"')
print ()
print ('#include "hb-ot-shape-complex-use.hh"')
print ('#include "hb-ot-shape-complex-use-machine.hh"')
print ()
total = 0
......@@ -465,18 +504,20 @@ 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 ("#define %s USE(%s)" % (tag, tag))
print ('#pragma GCC diagnostic pop')
print ("")
print ("static const USE_TABLE_ELEMENT_TYPE use_table[] = {")
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
......@@ -507,7 +548,7 @@ occupancy = used * 100. / total
page_bits = 12
print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy))
print ()
print ("USE_TABLE_ELEMENT_TYPE")
print ("static inline uint8_t")
print ("hb_use_get_category (hb_codepoint_t u)")
print ("{")
print (" switch (u >> %d)" % page_bits)
......@@ -524,7 +565,7 @@ for p in sorted(pages):
print (" default:")
print (" break;")
print (" }")
print (" return USE_O;")
print (" return USE(O);")
print ("}")
print ()
for k in sorted(use_mapping.keys()):
......@@ -537,7 +578,7 @@ for k,v in sorted(use_positions.items()):
print ("#undef %s" % tag)
print ()
print ()
print ('#endif')
print ("#endif /* HB_OT_SHAPE_COMPLEX_USE_TABLE_HH */")
print ("/* == End of generated table == */")
# Maintain at least 50% occupancy in the table */
......
......@@ -101,7 +101,7 @@ class ConstraintSet (object):
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 ('{}buffer->next_glyph ();\n'.format (self._indent (depth + 1)))
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:
......@@ -171,15 +171,15 @@ print ()
print ('static void')
print ('_output_dotted_circle (hb_buffer_t *buffer)')
print ('{')
print (' hb_glyph_info_t &dottedcircle = buffer->output_glyph (0x25CCu);')
print (' _hb_glyph_info_reset_continuation (&dottedcircle);')
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 (' buffer->next_glyph ();')
print (' (void) buffer->next_glyph ();')
print ('}')
print ()
......@@ -200,7 +200,6 @@ print (' * collected from the USE script development spec.')
print (' *')
print (' * https://github.com/harfbuzz/harfbuzz/issues/1019')
print (' */')
print (' bool processed = false;')
print (' buffer->clear_output ();')
print (' unsigned int count = buffer->len;')
print (' switch ((unsigned) buffer->props.script)')
......@@ -212,22 +211,16 @@ for script, constraints in sorted (constraints.items (), key=lambda s_c: script_
print (' {')
print ('\tbool matched = false;')
write (str (constraints))
print ('\tbuffer->next_glyph ();')
print ('\t(void) buffer->next_glyph ();')
print ('\tif (matched) _output_with_dotted_circle (buffer);')
print (' }')
print (' processed = true;')
print (' break;')
print ()
print (' default:')
print (' break;')
print (' }')
print (' if (processed)')
print (' {')
print (' if (buffer->idx < count)')
print (' buffer->next_glyph ();')
print (' buffer->swap_buffers ();')
print (' }')
print (' buffer->swap_buffers ();')
print ('}')
print ()
......
......@@ -29,8 +29,8 @@
#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-table.cc"
#include "hb-ot-shape-complex-use.cc"
#include "hb-ot-shape-complex-vowel-constraints.cc"
#include "hb-ot-shape-fallback.cc"
......
......@@ -54,7 +54,7 @@ struct Anchor
DEFINE_SIZE_STATIC (4);
};
typedef LArrayOf<Anchor> GlyphAnchors;
typedef Array32Of<Anchor> GlyphAnchors;
struct ankr
{
......@@ -64,7 +64,7 @@ struct ankr
unsigned int i,
unsigned int num_glyphs) const
{
const NNOffsetTo<GlyphAnchors> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs);
const NNOffset16To<GlyphAnchors> *offset = (this+lookupTable).get_value (glyph_id, num_glyphs);
if (!offset)
return Null (Anchor);
const GlyphAnchors &anchors = &(this+anchorData) + *offset;
......@@ -83,9 +83,9 @@ struct ankr
protected:
HBUINT16 version; /* Version number (set to zero) */
HBUINT16 flags; /* Flags (currently unused; set to zero) */
LOffsetTo<Lookup<NNOffsetTo<GlyphAnchors>>>
Offset32To<Lookup<NNOffset16To<GlyphAnchors>>>
lookupTable; /* Offset to the table's lookup table */
LNNOffsetTo<HBUINT8>
NNOffset32To<HBUINT8>
anchorData; /* Offset to the glyph data table */
public:
......
......@@ -164,7 +164,7 @@ struct LookupSegmentArray
HBGlyphID last; /* Last GlyphID in this segment */
HBGlyphID first; /* First GlyphID in this segment */
NNOffsetTo<UnsizedArrayOf<T>>
NNOffset16To<UnsizedArrayOf<T>>
valuesZ; /* A 16-bit offset from the start of
* the table to the data. */
public:
......@@ -510,7 +510,7 @@ struct StateTable
const Entry<Extra> &get_entry (int state, unsigned int klass) const
{
if (unlikely (klass >= nClasses))
klass = StateTable<Types, Entry<Extra>>::CLASS_OUT_OF_BOUNDS;
klass = StateTable::CLASS_OUT_OF_BOUNDS;
const HBUSHORT *states = (this+stateArrayTable).arrayZ;
const Entry<Extra> *entries = (this+entryTable).arrayZ;
......@@ -576,7 +576,7 @@ struct StateTable
if (unlikely (stop > states))
return_trace (false);
for (const HBUSHORT *p = states; stop < p; p--)
num_entries = hb_max (num_entries, *(p - 1) + 1);
num_entries = hb_max (num_entries, *(p - 1) + 1u);
state_neg = min_state;
}
}
......@@ -597,7 +597,7 @@ struct StateTable
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 + 1);
num_entries = hb_max (num_entries, *p + 1u);
state_pos = max_state + 1;
}
}
......@@ -659,7 +659,7 @@ struct ClassTable
}
protected:
HBGlyphID firstGlyph; /* First glyph index included in the trimmed array. */
ArrayOf<HBUCHAR> classArray; /* The class codes (indexed by glyph index minus
Array16Of<HBUCHAR> classArray; /* The class codes (indexed by glyph index minus
* firstGlyph). */
public:
DEFINE_SIZE_ARRAY (4, classArray);
......@@ -678,7 +678,8 @@ struct ObsoleteTypes
const void *base,
const T *array)
{
return (offset - ((const char *) array - (const char *) base)) / T::static_size;
/* 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,
......@@ -729,7 +730,10 @@ struct ExtendedTypes
template <typename Types, typename EntryData>
struct StateTableDriver
{
StateTableDriver (const StateTable<Types, EntryData> &machine_,
using StateTableT = StateTable<Types, EntryData>;
using EntryT = Entry<EntryData>;
StateTableDriver (const StateTableT &machine_,
hb_buffer_t *buffer_,
hb_face_t *face_) :
machine (machine_),
......@@ -742,59 +746,101 @@ struct StateTableDriver
if (!c->in_place)
buffer->clear_output ();
int state = StateTable<Types, EntryData>::STATE_START_OF_TEXT;
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) StateTable<Types, EntryData>::CLASS_END_OF_TEXT;
(unsigned) StateTableT::CLASS_END_OF_TEXT;
DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
const Entry<EntryData> &entry = machine.get_entry (state, klass);
const EntryT &entry = machine.get_entry (state, klass);
const int next_state = machine.new_state (entry.newState);
/* Unsafe-to-break before this if not in state 0, as things might
* go differently if we start from state 0 here.
/* Conditions under which it's guaranteed safe-to-break before current glyph:
*
* Ugh. The indexing here is ugly... */
if (state && buffer->backtrack_len () && buffer->idx < buffer->len)
{
/* If there's no action and we're just epsilon-transitioning to state 0,
* safe to break. */
if (c->is_actionable (this, entry) ||
!(entry.newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT &&
entry.flags == context_t::DontAdvance))
buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
}
/* Unsafe-to-break if end-of-text would kick in here. */
if (buffer->idx + 2 <= buffer->len)
{
const Entry<EntryData> &end_entry = machine.get_entry (state, StateTable<Types, EntryData>::CLASS_END_OF_TEXT);
if (c->is_actionable (this, end_entry))
buffer->unsafe_to_break (buffer->idx, buffer->idx + 2);
}
* 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 = machine.new_state (entry.newState);
state = next_state;
DEBUG_MSG (APPLY, nullptr, "s%d", state);
if (buffer->idx == buffer->len)
if (buffer->idx == buffer->len || unlikely (!buffer->successful))
break;
if (!(entry.flags & context_t::DontAdvance) || buffer->max_ops-- <= 0)
buffer->next_glyph ();
(void) buffer->next_glyph ();
}
if (!c->in_place)
{
for (; buffer->successful && buffer->idx < buffer->len;)
buffer->next_glyph ();
buffer->swap_buffers ();
}
}
public:
const StateTable<Types, EntryData> &machine;
const StateTableT &machine;
hb_buffer_t *buffer;
unsigned int num_glyphs;
};
......
......@@ -144,7 +144,7 @@ struct FeatureName
protected:
HBUINT16 feature; /* Feature type. */
HBUINT16 nSettings; /* The number of records in the setting name array. */
LNNOffsetTo<UnsizedArrayOf<SettingName>>
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
......
......@@ -79,7 +79,7 @@ struct DecompositionAction
* to decompose before more frequent ones. The ligatures
* on the line of text will decompose in increasing
* value of this field. */
ArrayOf<HBUINT16>
Array16Of<HBUINT16>
decomposedglyphs;
/* Number of 16-bit glyph indexes that follow;
* the ligature will be decomposed into these glyphs.
......@@ -310,7 +310,7 @@ struct WidthDeltaPair
DEFINE_SIZE_STATIC (24);
};
typedef OT::LArrayOf<WidthDeltaPair> WidthDeltaCluster;
typedef OT::Array32Of<WidthDeltaPair> WidthDeltaCluster;
struct JustificationCategory
{
......@@ -358,20 +358,20 @@ struct JustificationHeader
}
protected:
OffsetTo<JustificationCategory>
Offset16To<JustificationCategory>
justClassTable; /* Offset to the justification category state table. */
OffsetTo<WidthDeltaCluster>
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. */
OffsetTo<PostcompensationActionChain>
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<OffsetTo<WidthDeltaCluster>>
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. */
......@@ -398,13 +398,13 @@ struct just
FixedVersion<>version; /* Version of the justification table
* (0x00010000u for version 1.0). */
HBUINT16 format; /* Format of the justification table (set to 0). */
OffsetTo<JustificationHeader>
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. */
OffsetTo<JustificationHeader>
Offset16To<JustificationHeader>
vertData; /* ditto, vertical */
public:
......
......@@ -710,18 +710,18 @@ struct KerxSubTableFormat6
{
struct Long
{
LNNOffsetTo<Lookup<HBUINT32>> rowIndexTable;
LNNOffsetTo<Lookup<HBUINT32>> columnIndexTable;
LNNOffsetTo<UnsizedArrayOf<FWORD32>> array;
NNOffset32To<Lookup<HBUINT32>> rowIndexTable;
NNOffset32To<Lookup<HBUINT32>> columnIndexTable;
NNOffset32To<UnsizedArrayOf<FWORD32>> array;
} l;
struct Short
{
LNNOffsetTo<Lookup<HBUINT16>> rowIndexTable;
LNNOffsetTo<Lookup<HBUINT16>> columnIndexTable;
LNNOffsetTo<UnsizedArrayOf<FWORD>> array;
NNOffset32To<Lookup<HBUINT16>> rowIndexTable;
NNOffset32To<Lookup<HBUINT16>> columnIndexTable;
NNOffset32To<UnsizedArrayOf<FWORD>> array;
} s;
} u;
LNNOffsetTo<UnsizedArrayOf<FWORD>> vector;
NNOffset32To<UnsizedArrayOf<FWORD>> vector;
public:
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 24);
};
......
......@@ -304,7 +304,7 @@ struct ContextualSubtable
bool mark_set;
unsigned int mark;
const ContextualSubtable *table;
const UnsizedOffsetListOf<Lookup<HBGlyphID>, HBUINT, false> &subs;
const UnsizedListOfOffset16To<Lookup<HBGlyphID>, HBUINT, false> &subs;
};
bool apply (hb_aat_apply_context_t *c) const
......@@ -337,9 +337,9 @@ struct ContextualSubtable
const EntryData &data = entries[i].data;
if (data.markIndex != 0xFFFF)
num_lookups = hb_max (num_lookups, 1 + data.markIndex);
num_lookups = hb_max (num_lookups, 1u + data.markIndex);
if (data.currentIndex != 0xFFFF)
num_lookups = hb_max (num_lookups, 1 + data.currentIndex);
num_lookups = hb_max (num_lookups, 1u + data.currentIndex);
}
return_trace (substitutionTables.sanitize (c, this, num_lookups));
......@@ -348,7 +348,7 @@ struct ContextualSubtable
protected:
StateTable<Types, EntryData>
machine;
NNOffsetTo<UnsizedOffsetListOf<Lookup<HBGlyphID>, HBUINT, false>, HBUINT>
NNOffsetTo<UnsizedListOfOffset16To<Lookup<HBGlyphID>, HBUINT, false>, HBUINT>
substitutionTables;
public:
DEFINE_SIZE_STATIC (20);
......@@ -499,7 +499,7 @@ struct LigatureSubtable
}
DEBUG_MSG (APPLY, nullptr, "Moving to stack position %u", cursor - 1);
buffer->move_to (match_positions[--cursor % ARRAY_LENGTH (match_positions)]);
if (unlikely (!buffer->move_to (match_positions[--cursor % ARRAY_LENGTH (match_positions)]))) return;
if (unlikely (!actionData->sanitize (&c->sanitizer))) break;
action = *actionData;
......@@ -525,25 +525,25 @@ struct LigatureSubtable
hb_codepoint_t lig = ligatureData;
DEBUG_MSG (APPLY, nullptr, "Produced ligature %u", lig);
buffer->replace_glyph (lig);
if (unlikely (!buffer->replace_glyph (lig))) return;
unsigned int lig_end = match_positions[(match_length - 1u) % ARRAY_LENGTH (match_positions)] + 1u;
/* Now go and delete all subsequent components. */
while (match_length - 1u > cursor)
{
DEBUG_MSG (APPLY, nullptr, "Skipping ligature component");
buffer->move_to (match_positions[--match_length % ARRAY_LENGTH (match_positions)]);
buffer->replace_glyph (DELETED_GLYPH);
if (unlikely (!buffer->move_to (match_positions[--match_length % ARRAY_LENGTH (match_positions)]))) return;
if (unlikely (!buffer->replace_glyph (DELETED_GLYPH))) return;
}
buffer->move_to (lig_end);
if (unlikely (!buffer->move_to (lig_end))) return;
buffer->merge_out_clusters (match_positions[cursor % ARRAY_LENGTH (match_positions)], buffer->out_len);
}
actionData++;
}
while (!(action & LigActionLast));
buffer->move_to (end);
if (unlikely (!buffer->move_to (end))) return;
}
}
......@@ -733,17 +733,16 @@ struct InsertionSubtable
bool before = flags & MarkedInsertBefore;
unsigned int end = buffer->out_len;
buffer->move_to (mark);
if (unlikely (!buffer->move_to (mark))) return;
if (buffer->idx < buffer->len && !before)
buffer->copy_glyph ();
if (unlikely (!buffer->copy_glyph ())) return;
/* TODO We ignore KashidaLike setting. */
for (unsigned int i = 0; i < count; i++)
buffer->output_glyph (glyphs[i]);
if (unlikely (!buffer->replace_glyphs (0, count, glyphs))) return;
if (buffer->idx < buffer->len && !before)
buffer->skip_glyph ();
buffer->move_to (end + count);
if (unlikely (!buffer->move_to (end + count))) return;
buffer->unsafe_to_break_from_outbuffer (mark, hb_min (buffer->idx + 1, buffer->len));
}
......@@ -764,10 +763,9 @@ struct InsertionSubtable
unsigned int end = buffer->out_len;
if (buffer->idx < buffer->len && !before)
buffer->copy_glyph ();
if (unlikely (!buffer->copy_glyph ())) return;
/* TODO We ignore KashidaLike setting. */
for (unsigned int i = 0; i < count; i++)
buffer->output_glyph (glyphs[i]);
if (unlikely (!buffer->replace_glyphs (0, count, glyphs))) return;
if (buffer->idx < buffer->len && !before)
buffer->skip_glyph ();
......@@ -786,7 +784,7 @@ struct InsertionSubtable
*
* https://github.com/harfbuzz/harfbuzz/issues/1224#issuecomment-427691417
*/
buffer->move_to ((flags & DontAdvance) ? end : end + count);
if (unlikely (!buffer->move_to ((flags & DontAdvance) ? end : end + count))) return;
}
}
......
......@@ -58,7 +58,7 @@ struct opbdFormat0
bool get_bounds (hb_font_t *font, hb_codepoint_t glyph_id,
hb_glyph_extents_t *extents, const void *base) const
{
const OffsetTo<OpticalBounds> *bounds_offset = lookupTable.get_value (glyph_id, font->face->get_num_glyphs ());
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;
......@@ -79,7 +79,7 @@ struct opbdFormat0
}
protected:
Lookup<OffsetTo<OpticalBounds>>
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. */
......@@ -92,7 +92,7 @@ struct opbdFormat1
bool get_bounds (hb_font_t *font, hb_codepoint_t glyph_id,
hb_glyph_extents_t *extents, const void *base) const
{
const OffsetTo<OpticalBounds> *bounds_offset = lookupTable.get_value (glyph_id, font->face->get_num_glyphs ());
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;
......@@ -116,7 +116,7 @@ struct opbdFormat1
}
protected:
Lookup<OffsetTo<OpticalBounds>>
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. */
......
......@@ -66,7 +66,7 @@ struct TrackTableEntry
NameID trackNameID; /* The 'name' table index for this track.
* (a short word or phrase like "loose"
* or "very tight") */
NNOffsetTo<UnsizedArrayOf<FWORD>>
NNOffset16To<UnsizedArrayOf<FWORD>>
valuesZ; /* Offset from start of tracking table to
* per-size tracking values for this track. */
......@@ -141,7 +141,7 @@ struct TrackData
protected:
HBUINT16 nTracks; /* Number of separate tracks included in this table. */
HBUINT16 nSizes; /* Number of point sizes included in this table. */
LNNOffsetTo<UnsizedArrayOf<HBFixed>>
NNOffset32To<UnsizedArrayOf<HBFixed>>
sizeTable; /* Offset from start of the tracking table to
* Array[nSizes] of size values.. */
UnsizedArrayOf<TrackTableEntry>
......@@ -212,10 +212,10 @@ struct trak
FixedVersion<>version; /* Version of the tracking table
* (0x00010000u for version 1.0). */
HBUINT16 format; /* Format of the tracking table (set to 0). */
OffsetTo<TrackData>
Offset16To<TrackData>
horizData; /* Offset from start of tracking table to TrackData
* for horizontal text (or 0 if none). */
OffsetTo<TrackData>
Offset16To<TrackData>
vertData; /* Offset from start of tracking table to TrackData
* for vertical text (or 0 if none). */
HBUINT16 reserved; /* Reserved. Set to 0. */
......
......@@ -79,13 +79,18 @@ AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_)
* @short_description: Apple Advanced Typography Layout
* @include: hb-aat.h
*
* Functions for querying OpenType Layout features in the font face.
* 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)
/* Table data courtesy of Apple. Converted from mnemonics to integers
/* 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[] =
{
......@@ -167,6 +172,17 @@ static const hb_aat_feature_mapping_t feature_mappings[] =
{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)
{
......@@ -202,11 +218,17 @@ hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
}
/*
/**
* hb_aat_layout_has_substitution:
* @face:
* @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
*
* Returns:
* Since: 2.3.0
*/
hb_bool_t
......@@ -263,11 +285,17 @@ 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:
* @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
*
* Returns:
* Since: 2.3.0
*/
hb_bool_t
......@@ -290,11 +318,15 @@ hb_aat_layout_position (const hb_ot_shape_plan_t *plan,
}
/*
/**
* hb_aat_layout_has_tracking:
* @face:
* @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
*
* Returns:
* Since: 2.3.0
*/
hb_bool_t
......@@ -316,10 +348,13 @@ hb_aat_layout_track (const hb_ot_shape_plan_t *plan,
/**
* hb_aat_layout_get_feature_types:
* @face: a face object
* @start_offset: iteration's start offset
* @feature_count:(inout) (allow-none): buffer size as input, filled size as output
* @features: (out caller-allocates) (array length=feature_count): features buffer
* @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.
*
......@@ -336,10 +371,12 @@ hb_aat_layout_get_feature_types (hb_face_t *face,
/**
* hb_aat_layout_feature_type_get_name_id:
* @face: a face object
* @feature_type: feature id
* @face: #hb_face_t to work upon
* @feature_type: The #hb_aat_layout_feature_type_t of the requested feature type
*
* Return value: Name ID index
* 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
*/
......@@ -351,19 +388,23 @@ hb_aat_layout_feature_type_get_name_id (hb_face_t *face,
}
/**
* hb_aat_layout_feature_type_get_selectors:
* @face: a face object
* @feature_type: feature id
* @start_offset: iteration's start offset
* @selector_count: (inout) (allow-none): buffer size as input, filled size as output
* @selectors: (out caller-allocates) (array length=selector_count): settings buffer
* @default_index: (out) (allow-none): index of default selector if any
* 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.
* Return value: Number of all available feature selectors
*
* Since: 2.2.0
*/
......
此差异已折叠。
......@@ -50,7 +50,7 @@ struct FTStringRange
}
protected:
NNOffsetTo<UnsizedArrayOf<HBUINT8>>
NNOffset16To<UnsizedArrayOf<HBUINT8>>
tag; /* Offset from the start of the table to
* the beginning of the string */
HBUINT16 length; /* String length (in bytes) */
......@@ -80,7 +80,7 @@ struct ltag
protected:
HBUINT32 version; /* Table version; currently 1 */
HBUINT32 flags; /* Table flags; currently none defined */
LArrayOf<FTStringRange>
Array32Of<FTStringRange>
tagRanges; /* Range for each tag's string */
public:
DEFINE_SIZE_ARRAY (12, tagRanges);
......
......@@ -35,6 +35,132 @@
#include "hb-number.hh"
/*
* Flags
*/
/* Enable bitwise ops on enums marked as flags_t */
/* To my surprise, looks like the function resolver is happy to silently cast
* one enum to another... So this doesn't provide the type-checking that I
* originally had in mind... :(.
*
* For MSVC warnings, see: https://github.com/harfbuzz/harfbuzz/pull/163
*/
#ifdef _MSC_VER
# pragma warning(disable:4200)
# pragma warning(disable:4800)
#endif
#define HB_MARK_AS_FLAG_T(T) \
extern "C++" { \
static inline constexpr T operator | (T l, T r) { return T ((unsigned) l | (unsigned) r); } \
static inline constexpr T operator & (T l, T r) { return T ((unsigned) l & (unsigned) r); } \
static inline constexpr T operator ^ (T l, T r) { return T ((unsigned) l ^ (unsigned) r); } \
static inline constexpr T operator ~ (T r) { return T (~(unsigned int) r); } \
static inline T& operator |= (T &l, T r) { l = l | r; return l; } \
static inline T& operator &= (T& l, T r) { l = l & r; return l; } \
static inline T& operator ^= (T& l, T r) { l = l ^ r; return l; } \
} \
static_assert (true, "")
/* Useful for set-operations on small enums.
* For example, for testing "x ∈ {x1, x2, x3}" use:
* (FLAG_UNSAFE(x) & (FLAG(x1) | FLAG(x2) | FLAG(x3)))
*/
#define FLAG(x) (static_assert_expr ((unsigned)(x) < 32) + (((uint32_t) 1U) << (unsigned)(x)))
#define FLAG_UNSAFE(x) ((unsigned)(x) < 32 ? (((uint32_t) 1U) << (unsigned)(x)) : 0)
#define FLAG_RANGE(x,y) (static_assert_expr ((x) < (y)) + FLAG(y+1) - FLAG(x))
#define FLAG64(x) (static_assert_expr ((unsigned)(x) < 64) + (((uint64_t) 1ULL) << (unsigned)(x)))
#define FLAG64_UNSAFE(x) ((unsigned)(x) < 64 ? (((uint64_t) 1ULL) << (unsigned)(x)) : 0)
/*
* Big-endian integers.
*/
/* Endian swap, used in Windows related backends */
static inline constexpr uint16_t hb_uint16_swap (uint16_t v)
{ return (v >> 8) | (v << 8); }
static inline constexpr uint32_t hb_uint32_swap (uint32_t v)
{ return (hb_uint16_swap (v) << 16) | hb_uint16_swap (v >> 16); }
template <typename Type, int Bytes = sizeof (Type)>
struct BEInt;
template <typename Type>
struct BEInt<Type, 1>
{
public:
BEInt () = default;
constexpr BEInt (Type V) : v {uint8_t (V)} {}
constexpr operator Type () const { return v; }
private: uint8_t v;
};
template <typename Type>
struct BEInt<Type, 2>
{
public:
BEInt () = default;
constexpr BEInt (Type V) : v {uint8_t ((V >> 8) & 0xFF),
uint8_t ((V ) & 0xFF)} {}
struct __attribute__((packed)) packed_uint16_t { uint16_t v; };
constexpr operator Type () const
{
#if ((defined(__GNUC__) && __GNUC__ >= 5) || defined(__clang__)) && \
defined(__BYTE_ORDER) && \
(__BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __BIG_ENDIAN)
/* Spoon-feed the compiler a big-endian integer with alignment 1.
* https://github.com/harfbuzz/harfbuzz/pull/1398 */
#if __BYTE_ORDER == __LITTLE_ENDIAN
return __builtin_bswap16 (((packed_uint16_t *) this)->v);
#else /* __BYTE_ORDER == __BIG_ENDIAN */
return ((packed_uint16_t *) this)->v;
#endif
#else
return (v[0] << 8)
+ (v[1] );
#endif
}
private: uint8_t v[2];
};
template <typename Type>
struct BEInt<Type, 3>
{
static_assert (!hb_is_signed (Type), "");
public:
BEInt () = default;
constexpr BEInt (Type V) : v {uint8_t ((V >> 16) & 0xFF),
uint8_t ((V >> 8) & 0xFF),
uint8_t ((V ) & 0xFF)} {}
constexpr operator Type () const { return (v[0] << 16)
+ (v[1] << 8)
+ (v[2] ); }
private: uint8_t v[3];
};
template <typename Type>
struct BEInt<Type, 4>
{
public:
BEInt () = default;
constexpr BEInt (Type V) : v {uint8_t ((V >> 24) & 0xFF),
uint8_t ((V >> 16) & 0xFF),
uint8_t ((V >> 8) & 0xFF),
uint8_t ((V ) & 0xFF)} {}
constexpr operator Type () const { return (v[0] << 24)
+ (v[1] << 16)
+ (v[2] << 8)
+ (v[3] ); }
private: uint8_t v[4];
};
/* Floats. */
/* We want our rounding towards +infinity. */
static inline float
_hb_roundf (float x) { return floorf (x + .5f); }
#define roundf(x) _hb_roundf(x)
/* Encodes three unsigned integers in one 64-bit number. If the inputs have more than 21 bits,
* values will be truncated / overlap, and might not decode exactly. */
#define HB_CODEPOINT_ENCODE3(x,y,z) (((uint64_t) (x) << 42) | ((uint64_t) (y) << 21) | (uint64_t) (z))
......@@ -48,6 +174,7 @@
#define HB_CODEPOINT_DECODE3_11_7_14_2(v) ((hb_codepoint_t) (((v) >> 14) & 0x007Fu) | 0x0300)
#define HB_CODEPOINT_DECODE3_11_7_14_3(v) ((hb_codepoint_t) (v) & 0x3FFFu)
struct
{
/* Note. This is dangerous in that if it's passed an rvalue, it returns rvalue-reference. */
......@@ -215,7 +342,9 @@ struct
template <typename Pred, typename Val> auto
impl (Pred&& p, Val &&v, hb_priority<1>) const HB_AUTO_RETURN
(hb_deref (hb_forward<Pred> (p)).has (hb_forward<Val> (v)))
(
hb_deref (hb_forward<Pred> (p)).has (hb_forward<Val> (v))
)
template <typename Pred, typename Val> auto
impl (Pred&& p, Val &&v, hb_priority<0>) const HB_AUTO_RETURN
......@@ -269,7 +398,9 @@ struct
template <typename Proj, typename Val> auto
impl (Proj&& f, Val &&v, hb_priority<2>) const HB_AUTO_RETURN
(hb_deref (hb_forward<Proj> (f)).get (hb_forward<Val> (v)))
(
hb_deref (hb_forward<Proj> (f)).get (hb_forward<Val> (v))
)
template <typename Proj, typename Val> auto
impl (Proj&& f, Val &&v, hb_priority<1>) const HB_AUTO_RETURN
......@@ -296,6 +427,40 @@ struct
}
HB_FUNCOBJ (hb_get);
struct
{
private:
template <typename T1, typename T2> auto
impl (T1&& v1, T2 &&v2, hb_priority<2>) const HB_AUTO_RETURN
(
hb_forward<T2> (v2).cmp (hb_forward<T1> (v1)) == 0
)
template <typename T1, typename T2> auto
impl (T1&& v1, T2 &&v2, hb_priority<1>) const HB_AUTO_RETURN
(
hb_forward<T1> (v1).cmp (hb_forward<T2> (v2)) == 0
)
template <typename T1, typename T2> auto
impl (T1&& v1, T2 &&v2, hb_priority<0>) const HB_AUTO_RETURN
(
hb_forward<T1> (v1) == hb_forward<T2> (v2)
)
public:
template <typename T1, typename T2> auto
operator () (T1&& v1, T2 &&v2) const HB_AUTO_RETURN
(
impl (hb_forward<T1> (v1),
hb_forward<T2> (v2),
hb_prioritize)
)
}
HB_FUNCOBJ (hb_equal);
template <typename T1, typename T2>
struct hb_pair_t
......@@ -350,14 +515,14 @@ struct
{
template <typename T, typename T2> constexpr auto
operator () (T&& a, T2&& b) const HB_AUTO_RETURN
(hb_forward<T> (a) <= hb_forward<T2> (b) ? hb_forward<T> (a) : hb_forward<T2> (b))
(a <= b ? hb_forward<T> (a) : hb_forward<T2> (b))
}
HB_FUNCOBJ (hb_min);
struct
{
template <typename T, typename T2> constexpr auto
operator () (T&& a, T2&& b) const HB_AUTO_RETURN
(hb_forward<T> (a) >= hb_forward<T2> (b) ? hb_forward<T> (a) : hb_forward<T2> (b))
(a >= b ? hb_forward<T> (a) : hb_forward<T2> (b))
}
HB_FUNCOBJ (hb_max);
struct
......@@ -375,7 +540,7 @@ HB_FUNCOBJ (hb_clamp);
/* Return the number of 1 bits in v. */
template <typename T>
static inline HB_CONST_FUNC unsigned int
static inline unsigned int
hb_popcount (T v)
{
#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
......@@ -416,7 +581,7 @@ hb_popcount (T v)
/* Returns the number of bits needed to store number */
template <typename T>
static inline HB_CONST_FUNC unsigned int
static inline unsigned int
hb_bit_storage (T v)
{
if (unlikely (!v)) return 0;
......@@ -490,7 +655,7 @@ hb_bit_storage (T v)
/* Returns the number of zero bits in the least significant side of v */
template <typename T>
static inline HB_CONST_FUNC unsigned int
static inline unsigned int
hb_ctz (T v)
{
if (unlikely (!v)) return 8 * sizeof (T);
......@@ -988,32 +1153,24 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o
struct hb_bitwise_and
{ HB_PARTIALIZE(2);
static constexpr bool passthru_left = false;
static constexpr bool passthru_right = false;
template <typename T> constexpr auto
operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & b)
}
HB_FUNCOBJ (hb_bitwise_and);
struct hb_bitwise_or
{ HB_PARTIALIZE(2);
static constexpr bool passthru_left = true;
static constexpr bool passthru_right = true;
template <typename T> constexpr auto
operator () (const T &a, const T &b) const HB_AUTO_RETURN (a | b)
}
HB_FUNCOBJ (hb_bitwise_or);
struct hb_bitwise_xor
{ HB_PARTIALIZE(2);
static constexpr bool passthru_left = true;
static constexpr bool passthru_right = true;
template <typename T> constexpr auto
operator () (const T &a, const T &b) const HB_AUTO_RETURN (a ^ b)
}
HB_FUNCOBJ (hb_bitwise_xor);
struct hb_bitwise_sub
{ HB_PARTIALIZE(2);
static constexpr bool passthru_left = true;
static constexpr bool passthru_right = false;
template <typename T> constexpr auto
operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & ~b)
}
......
......@@ -142,7 +142,7 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
bool lfind (const T &x, unsigned *pos = nullptr) const
{
for (unsigned i = 0; i < length; ++i)
if (!this->arrayZ[i].cmp (x))
if (hb_equal (x, this->arrayZ[i]))
{
if (pos)
*pos = i;
......@@ -219,7 +219,7 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&>
unsigned P = sizeof (Type),
hb_enable_if (P == 1)>
const T *as () const
{ return length < hb_null_size (T) ? &Null (T) : reinterpret_cast<const T *> (arrayZ); }
{ return length < hb_min_size (T) ? &Null (T) : reinterpret_cast<const T *> (arrayZ); }
template <typename T,
unsigned P = sizeof (Type),
......
......@@ -52,7 +52,7 @@
#elif !defined(HB_NO_MT) && defined(__ATOMIC_ACQUIRE)
/* C++11-style GCC primitives. */
/* C++11-style GCC primitives. We prefer these as they don't require linking to libstdc++ / libc++. */
#define _hb_memory_barrier() __sync_synchronize ()
......@@ -73,7 +73,8 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
}
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))
#elif !defined(HB_NO_MT) && __cplusplus >= 201103L
#elif !defined(HB_NO_MT)
/* C++11 atomics. */
......@@ -101,117 +102,6 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))
#elif !defined(HB_NO_MT) && defined(_WIN32)
#include <windows.h>
static inline void _hb_memory_barrier ()
{
#if !defined(MemoryBarrier) && !defined(__MINGW32_VERSION)
/* MinGW has a convoluted history of supporting MemoryBarrier. */
LONG dummy = 0;
InterlockedExchange (&dummy, 1);
#else
MemoryBarrier ();
#endif
}
#define _hb_memory_barrier() _hb_memory_barrier ()
#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((LONG *) (AI), (V))
static_assert ((sizeof (LONG) == sizeof (int)), "");
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((P), (N), (O)) == (O))
#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
#define _hb_memory_barrier() __sync_synchronize ()
#define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add ((AI), (V))
#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>
#define _hb_memory_r_barrier() __machine_r_barrier ()
#define _hb_memory_w_barrier() __machine_w_barrier ()
#define _hb_memory_barrier() __machine_rw_barrier ()
static inline int _hb_fetch_and_add (int *AI, int V)
{
_hb_memory_w_barrier ();
int result = atomic_add_int_nv ((uint_t *) AI, V) - V;
_hb_memory_r_barrier ();
return result;
}
static inline bool _hb_compare_and_swap_ptr (void **P, void *O, void *N)
{
_hb_memory_w_barrier ();
bool result = atomic_cas_ptr (P, O, N) == O;
_hb_memory_r_barrier ();
return result;
}
#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V))
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swap_ptr ((P), (O), (N))
#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
#define _hb_memory_barrier() OSMemoryBarrier ()
#define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), (AI)) - (V))
#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 ((O), (N), (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(_AIX) && (defined(__IBMCPP__) || defined(__ibmxl__))
#include <builtins.h>
#define _hb_memory_barrier() __lwsync ()
static inline int _hb_fetch_and_add (int *AI, int V)
{
_hb_memory_barrier ();
int result = __fetch_and_add (AI, V);
_hb_memory_barrier ();
return result;
}
static inline bool _hb_compare_and_swaplp (long *P, long O, long N)
{
_hb_memory_barrier ();
bool result = __compare_and_swaplp (P, &O, N);
_hb_memory_barrier ();
return result;
}
#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V))
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long *) (P), (long) (O), (long) (N))
static_assert ((sizeof (long) == sizeof (void *)), "");
#elif defined(HB_NO_MT)
#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V))
......@@ -259,9 +149,11 @@ inline void *hb_atomic_ptr_impl_get (void ** const P) { void *v = *P; _hb_memory
#endif
#define HB_ATOMIC_INT_INIT(V) {V}
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); }
......@@ -269,16 +161,17 @@ struct hb_atomic_int_t
int inc () { return hb_atomic_int_impl_add (&v, 1); }
int dec () { return hb_atomic_int_impl_add (&v, -1); }
int v;
int v = 0;
};
#define HB_ATOMIC_PTR_INIT(V) {V}
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); }
......@@ -288,7 +181,7 @@ struct hb_atomic_ptr_t
T * operator -> () const { return get (); }
template <typename C> operator C * () const { return get (); }
T *v;
T *v = nullptr;
};
......
......@@ -35,9 +35,6 @@
#include <sys/mman.h>
#endif /* HAVE_SYS_MMAN_H */
#include <stdio.h>
#include <stdlib.h>
/**
* SECTION: hb-blob
......@@ -58,7 +55,7 @@
* @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.
......@@ -116,7 +113,7 @@ _hb_blob_destroy (void *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.
......@@ -156,7 +153,7 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
*
* Makes a writable copy of @blob.
*
* Return value: New blob, or nullptr if allocation failed.
* Return value: The new blob, or nullptr if allocation failed
*
* Since: 1.8.0
**/
......@@ -182,7 +179,7 @@ hb_blob_copy_writable_or_fail (hb_blob_t *blob)
*
* 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
**/
......@@ -234,13 +231,15 @@ hb_blob_destroy (hb_blob_t *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
*
* Attaches a user-data key/data pair to the specified blob.
*
* Return value:
* Return value: %true if success, %false otherwise
*
* Since: 0.9.2
**/
......@@ -256,12 +255,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
**/
......@@ -275,9 +275,9 @@ 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
**/
......@@ -294,9 +294,9 @@ hb_blob_make_immutable (hb_blob_t *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
**/
......@@ -311,9 +311,9 @@ 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
**/
......@@ -326,11 +326,11 @@ hb_blob_get_length (hb_blob_t *blob)
/**
* 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
**/
......@@ -362,16 +362,14 @@ 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 (!blob->try_make_writable ()) {
if (length)
*length = 0;
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);
}
......@@ -437,8 +435,8 @@ hb_blob_t::try_make_writable_inplace ()
bool
hb_blob_t::try_make_writable ()
{
if (hb_object_is_immutable (this))
return false;
if (unlikely (!length))
mode = HB_MEMORY_MODE_WRITABLE;
if (this->mode == HB_MEMORY_MODE_WRITABLE)
return true;
......@@ -558,9 +556,12 @@ _open_resource_fork (const char *file_name, hb_mapped_file_t *file)
/**
* hb_blob_create_from_file:
* @file_name: font filename.
* @file_name: A font filename
*
* Creates a new blob containing the data from the
* specified binary font file.
*
* Returns: A hb_blob_t pointer with the content of the file
* Returns: An #hb_blob_t pointer with the content of the file
*
* Since: 1.7.7
**/
......
......@@ -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 otherwise, 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 *
......
......@@ -90,6 +90,7 @@ struct hb_blob_ptr_t
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;
};
......
此差异已折叠。
......@@ -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,
......
此差异已折叠。
......@@ -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
;
unicode = 'U' '+' xdigit+ >tok %parse_hexdigits;
unicode_item =
(
unicode
cluster?
)
>clear_item
@ensure_unicode
%add_item
;
main := space* item (space* '|' space* item)* space* ('|'|']')?;
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,
......@@ -104,10 +127,6 @@ _hb_buffer_deserialize_glyphs_text (hb_buffer_t *buffer,
while (p < pe && ISSPACE (*p))
p++;
if (p < pe && *p == (buffer->len ? '|' : '['))
{
*end_ptr = ++p;
}
const char *eof = pe, *tok = nullptr;
int cs;
......
此差异已折叠。
此差异已折叠。
......@@ -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
......@@ -59,8 +59,7 @@ 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
{
typedef struct hb_glyph_info_t {
hb_codepoint_t codepoint;
/*< private >*/
hb_mask_t mask;
......@@ -91,6 +90,8 @@ typedef struct hb_glyph_info_t
* 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 >*/
......@@ -151,6 +152,11 @@ 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, \
......@@ -204,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,
......@@ -289,6 +297,8 @@ hb_buffer_guess_segment_properties (hb_buffer_t *buffer);
* 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
*/
typedef enum { /*< flags >*/
......@@ -315,6 +325,23 @@ hb_buffer_get_flags (hb_buffer_t *buffer);
* @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
*/
......@@ -447,6 +474,9 @@ HB_EXTERN hb_glyph_position_t *
hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
unsigned int *length);
HB_EXTERN hb_bool_t
hb_buffer_has_positions (hb_buffer_t *buffer);
HB_EXTERN void
hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
......@@ -518,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,
......@@ -526,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,
......@@ -570,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,
......
......@@ -35,20 +35,20 @@
#ifndef HB_BUFFER_MAX_LEN_FACTOR
#define HB_BUFFER_MAX_LEN_FACTOR 32
#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
#ifndef HB_BUFFER_MAX_OPS_FACTOR
#define HB_BUFFER_MAX_OPS_FACTOR 64
#define HB_BUFFER_MAX_OPS_FACTOR 1024
#endif
#ifndef HB_BUFFER_MAX_OPS_MIN
#define HB_BUFFER_MAX_OPS_MIN 1024
#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! */
......@@ -139,7 +139,7 @@ struct hb_buffer_t
/* Methods */
bool in_error () const { return !successful; }
HB_NODISCARD bool in_error () const { return !successful; }
void allocate_var (unsigned int start, unsigned int count)
{
......@@ -186,7 +186,7 @@ struct hb_buffer_t
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]; }
bool has_separate_output () const { return info != out_info; }
HB_NODISCARD bool has_separate_output () const { return info != out_info; }
HB_INTERNAL void reset ();
......@@ -210,86 +210,89 @@ struct hb_buffer_t
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);
void replace_glyph (hb_codepoint_t glyph_index)
template <typename T>
HB_NODISCARD bool replace_glyphs (unsigned int num_in,
unsigned int num_out,
const T *glyph_data)
{
if (unlikely (out_info != info || out_len != idx)) {
if (unlikely (!make_room_for (1, 1))) return;
out_info[out_len] = info[idx];
}
out_info[out_len].codepoint = glyph_index;
if (unlikely (!make_room_for (num_in, num_out))) return false;
idx++;
out_len++;
}
/* Makes a copy of the glyph at idx to output and replace glyph_index */
hb_glyph_info_t & output_glyph (hb_codepoint_t glyph_index)
{
if (unlikely (!make_room_for (0, 1))) return Crap (hb_glyph_info_t);
assert (idx + num_in <= len);
if (unlikely (idx == len && !out_len))
return Crap (hb_glyph_info_t);
merge_clusters (idx, idx + num_in);
out_info[out_len] = idx < len ? info[idx] : out_info[out_len - 1];
out_info[out_len].codepoint = glyph_index;
hb_glyph_info_t &orig_info = idx < len ? cur() : prev();
out_len++;
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++;
}
return out_info[out_len - 1];
idx += num_in;
out_len += num_out;
return true;
}
void output_info (const hb_glyph_info_t &glyph_info)
HB_NODISCARD bool replace_glyph (hb_codepoint_t glyph_index)
{ return replace_glyphs (1, 1, &glyph_index); }
/* Makes a copy of the glyph at idx to output and replace glyph_index */
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;
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 */
void copy_glyph ()
HB_NODISCARD bool copy_glyph ()
{
if (unlikely (!make_room_for (0, 1))) return;
out_info[out_len] = info[idx];
out_len++;
/* 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. */
void
next_glyph ()
HB_NODISCARD bool next_glyph ()
{
if (have_output)
{
if (out_info != info || out_len != idx)
{
if (unlikely (!make_room_for (1, 1))) return;
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. */
void
next_glyphs (unsigned int n)
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;
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. */
void skip_glyph () { idx++; }
......@@ -329,18 +332,51 @@ struct hb_buffer_t
/* Internal methods */
HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */
HB_NODISCARD HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */
HB_INTERNAL bool enlarge (unsigned int size);
HB_NODISCARD HB_INTERNAL bool enlarge (unsigned int size);
bool ensure (unsigned int size)
HB_NODISCARD bool ensure (unsigned int size)
{ return likely (!size || size < allocated) ? true : enlarge (size); }
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);
......
......@@ -263,7 +263,7 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
T *ip = c->allocate_size<T> (T::static_size);
if (unlikely (!ip)) return_trace (false);
return_trace (c->check_assign (*ip, value));
return_trace (c->check_assign (*ip, value, HB_SERIALIZE_ERROR_INT_OVERFLOW));
}
template <typename V>
......
此差异已折叠。
此差异已折叠。
......@@ -86,6 +86,9 @@
#define HB_NO_LEGACY
#endif
#ifdef HAVE_CONFIG_OVERRIDE_H
#include "config-override.h"
#endif
/* Closure of options. */
......@@ -155,9 +158,5 @@
#endif
#endif
#ifdef HAVE_CONFIG_OVERRIDE_H
#include "config-override.h"
#endif
#endif /* HB_CONFIG_HH */
......@@ -34,7 +34,6 @@
#include "hb-coretext.h"
#include "hb-aat-layout.hh"
#include <math.h>
/**
......@@ -190,7 +189,10 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
* reconfiguring the cascade list causes CoreText crashes. For details, see
* crbug.com/549610 */
// 0x00070000 stands for "kCTVersionNumber10_10", see CoreText.h
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
if (&CTGetCoreTextVersion != nullptr && CTGetCoreTextVersion() < 0x00070000) {
#pragma GCC diagnostic pop
CFStringRef fontName = CTFontCopyPostScriptName (ct_font);
bool isEmojiFont = CFStringCompare (fontName, CFSTR("AppleColorEmoji"), 0) == kCFCompareEqualTo;
CFRelease (fontName);
......@@ -346,7 +348,7 @@ retry:
const hb_coretext_font_data_t *data = font->data.coretext;
if (unlikely (!data)) return nullptr;
if (fabs (CTFontGetSize ((CTFontRef) data) - (CGFloat) font->ptem) > .5)
if (fabs (CTFontGetSize ((CTFontRef) data) - (CGFloat) font->ptem) > (CGFloat) .5)
{
/* XXX-MT-bug
* Note that evaluating condition above can be dangerous if another thread
......@@ -402,7 +404,7 @@ hb_coretext_font_create (CTFontRef ct_font)
}
/**
* hb_coretext_face_get_ct_font:
* hb_coretext_font_get_ct_font:
* @font: #hb_font_t to work upon
*
* Fetches the CTFontRef associated with the specified
......@@ -858,7 +860,7 @@ resize_and_retry:
buffer->len = 0;
uint32_t status_and = ~0, status_or = 0;
double advances_so_far = 0;
CGFloat advances_so_far = 0;
/* For right-to-left runs, CoreText returns the glyphs positioned such that
* any trailing whitespace is to the left of (0,0). Adjust coordinate system
* to fix for that. Test with any RTL string with trailing spaces.
......@@ -880,10 +882,10 @@ resize_and_retry:
status_or |= run_status;
status_and &= run_status;
DEBUG_MSG (CORETEXT, run, "CTRunStatus: %x", run_status);
double run_advance = CTRunGetTypographicBounds (run, range_all, nullptr, nullptr, nullptr);
CGFloat run_advance = CTRunGetTypographicBounds (run, range_all, nullptr, nullptr, nullptr);
if (HB_DIRECTION_IS_VERTICAL (buffer->props.direction))
run_advance = -run_advance;
DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance);
DEBUG_MSG (CORETEXT, run, "Run advance: %g", (double) run_advance);
/* CoreText does automatic font fallback (AKA "cascading") for characters
* not supported by the requested font, and provides no way to turn it off,
......@@ -1062,7 +1064,7 @@ resize_and_retry:
hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult;
for (unsigned int j = 0; j < num_glyphs; j++)
{
double advance;
CGFloat advance;
if (likely (j + 1 < num_glyphs))
advance = positions[j + 1].x - positions[j].x;
else /* last glyph */
......@@ -1078,7 +1080,7 @@ resize_and_retry:
hb_position_t y_offset = (positions[0].y - advances_so_far) * y_mult;
for (unsigned int j = 0; j < num_glyphs; j++)
{
double advance;
CGFloat advance;
if (likely (j + 1 < num_glyphs))
advance = positions[j + 1].y - positions[j].y;
else /* last glyph */
......
......@@ -438,6 +438,10 @@ struct hb_no_trace_t {
#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 + \
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册