From 56cfeda664bae608ccd21e46d36e867647ec770c Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 3 Jan 2013 09:48:38 +0000 Subject: harfbuzz-0.9.10 git-svn-id: svn://tug.org/texlive/trunk@28708 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/libs/harfbuzz/ChangeLog | 5 + Build/source/libs/harfbuzz/Makefile.in | 4 +- Build/source/libs/harfbuzz/configure | 34 +- .../harfbuzz/harfbuzz-0.9.10-PATCHES/ChangeLog | 32 + .../harfbuzz/harfbuzz-0.9.10-PATCHES/TL-Changes | 27 + Build/source/libs/harfbuzz/harfbuzz-0.9.10/AUTHORS | 8 + .../libs/harfbuzz/harfbuzz-0.9.10/Android.mk | 74 + .../libs/harfbuzz/harfbuzz-0.9.10/Makefile.am | 80 + Build/source/libs/harfbuzz/harfbuzz-0.9.10/NEWS | 617 ++++++ Build/source/libs/harfbuzz/harfbuzz-0.9.10/README | 7 + Build/source/libs/harfbuzz/harfbuzz-0.9.10/THANKS | 7 + Build/source/libs/harfbuzz/harfbuzz-0.9.10/TODO | 91 + .../libs/harfbuzz/harfbuzz-0.9.10/autogen.sh | 27 + .../libs/harfbuzz/harfbuzz-0.9.10/config.h.in | 150 ++ .../libs/harfbuzz/harfbuzz-0.9.10/configure.ac | 302 +++ .../libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.doap | 24 + .../libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.pc.in | 11 + .../libs/harfbuzz/harfbuzz-0.9.10/src/Makefile.am | 321 +++ .../harfbuzz-0.9.10/src/check-c-linkage-decls.sh | 28 + .../harfbuzz-0.9.10/src/check-exported-symbols.sh | 40 + .../harfbuzz-0.9.10/src/check-header-guards.sh | 25 + .../harfbuzz/harfbuzz-0.9.10/src/check-includes.sh | 42 + .../harfbuzz-0.9.10/src/check-internal-symbols.sh | 34 + .../harfbuzz-0.9.10/src/check-libstdc++.sh | 34 + .../harfbuzz-0.9.10/src/check-static-inits.sh | 39 + .../harfbuzz-0.9.10/src/gen-arabic-table.py | 197 ++ .../harfbuzz-0.9.10/src/gen-indic-table.py | 211 ++ .../harfbuzz-0.9.10/src/hb-atomic-private.hh | 124 ++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.cc | 325 +++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.h | 101 + .../harfbuzz-0.9.10/src/hb-buffer-private.hh | 199 ++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.cc | 1294 ++++++++++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.h | 323 +++ .../harfbuzz-0.9.10/src/hb-cache-private.hh | 74 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.cc | 418 ++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.h | 317 +++ .../harfbuzz/harfbuzz-0.9.10/src/hb-coretext.cc | 355 ++++ .../harfbuzz/harfbuzz-0.9.10/src/hb-coretext.h | 46 + .../harfbuzz-0.9.10/src/hb-fallback-shape.cc | 129 ++ .../harfbuzz-0.9.10/src/hb-font-private.hh | 469 +++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.cc | 1008 +++++++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.h | 454 +++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.cc | 493 +++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.h | 62 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.cc | 384 ++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.h | 52 + .../harfbuzz-0.9.10/src/hb-gobject-enums.cc.tmpl | 74 + .../harfbuzz-0.9.10/src/hb-gobject-structs.cc | 63 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject.h | 69 + .../harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.cc | 370 ++++ .../harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.h | 46 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu-le.cc | 215 ++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.cc | 372 ++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.h | 52 + .../harfbuzz-0.9.10/src/hb-mutex-private.hh | 130 ++ .../harfbuzz-0.9.10/src/hb-object-private.hh | 227 +++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-old.cc | 410 ++++ .../harfbuzz-0.9.10/src/hb-open-file-private.hh | 261 +++ .../harfbuzz-0.9.10/src/hb-open-type-private.hh | 962 +++++++++ .../harfbuzz-0.9.10/src/hb-ot-head-table.hh | 149 ++ .../harfbuzz-0.9.10/src/hb-ot-hhea-table.hh | 97 + .../harfbuzz-0.9.10/src/hb-ot-hmtx-table.hh | 92 + .../src/hb-ot-layout-common-private.hh | 1142 +++++++++++ .../harfbuzz-0.9.10/src/hb-ot-layout-gdef-table.hh | 431 ++++ .../harfbuzz-0.9.10/src/hb-ot-layout-gpos-table.hh | 1646 +++++++++++++++ .../harfbuzz-0.9.10/src/hb-ot-layout-gsub-table.hh | 1414 +++++++++++++ .../src/hb-ot-layout-gsubgpos-private.hh | 2146 ++++++++++++++++++++ .../harfbuzz-0.9.10/src/hb-ot-layout-private.hh | 220 ++ .../harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout.cc | 772 +++++++ .../harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout.h | 293 +++ .../harfbuzz-0.9.10/src/hb-ot-map-private.hh | 214 ++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-map.cc | 304 +++ .../harfbuzz-0.9.10/src/hb-ot-maxp-table.hh | 69 + .../harfbuzz-0.9.10/src/hb-ot-name-table.hh | 132 ++ .../src/hb-ot-shape-complex-arabic-fallback.hh | 253 +++ .../src/hb-ot-shape-complex-arabic-table.hh | 942 +++++++++ .../src/hb-ot-shape-complex-arabic.cc | 359 ++++ .../src/hb-ot-shape-complex-default.cc | 226 +++ .../src/hb-ot-shape-complex-indic-machine.hh | 1443 +++++++++++++ .../src/hb-ot-shape-complex-indic-machine.rl | 124 ++ .../src/hb-ot-shape-complex-indic-private.hh | 388 ++++ .../src/hb-ot-shape-complex-indic-table.hh | 872 ++++++++ .../src/hb-ot-shape-complex-indic.cc | 1413 +++++++++++++ .../src/hb-ot-shape-complex-private.hh | 313 +++ .../src/hb-ot-shape-complex-thai.cc | 378 ++++ .../src/hb-ot-shape-fallback-private.hh | 44 + .../harfbuzz-0.9.10/src/hb-ot-shape-fallback.cc | 409 ++++ .../src/hb-ot-shape-normalize-private.hh | 71 + .../harfbuzz-0.9.10/src/hb-ot-shape-normalize.cc | 408 ++++ .../harfbuzz-0.9.10/src/hb-ot-shape-private.hh | 125 ++ .../harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape.cc | 640 ++++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-tag.cc | 722 +++++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-tag.h | 59 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot.h | 49 + .../harfbuzz/harfbuzz-0.9.10/src/hb-private.hh | 857 ++++++++ .../harfbuzz/harfbuzz-0.9.10/src/hb-set-private.hh | 324 +++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-set.cc | 228 +++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-set.h | 152 ++ .../harfbuzz-0.9.10/src/hb-shape-plan-private.hh | 60 + .../harfbuzz/harfbuzz-0.9.10/src/hb-shape-plan.cc | 308 +++ .../harfbuzz/harfbuzz-0.9.10/src/hb-shape-plan.h | 89 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-shape.cc | 276 +++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-shape.h | 81 + .../harfbuzz-0.9.10/src/hb-shaper-impl-private.hh | 43 + .../harfbuzz/harfbuzz-0.9.10/src/hb-shaper-list.hh | 55 + .../harfbuzz-0.9.10/src/hb-shaper-private.hh | 106 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-shaper.cc | 109 + .../harfbuzz/harfbuzz-0.9.10/src/hb-tt-font.cc | 79 + .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-ucdn.cc | 208 ++ .../harfbuzz-0.9.10/src/hb-unicode-private.hh | 306 +++ .../harfbuzz/harfbuzz-0.9.10/src/hb-unicode.cc | 435 ++++ .../libs/harfbuzz/harfbuzz-0.9.10/src/hb-unicode.h | 357 ++++ .../harfbuzz/harfbuzz-0.9.10/src/hb-uniscribe.cc | 475 +++++ .../harfbuzz/harfbuzz-0.9.10/src/hb-uniscribe.h | 49 + .../harfbuzz/harfbuzz-0.9.10/src/hb-utf-private.hh | 204 ++ .../harfbuzz/harfbuzz-0.9.10/src/hb-version.h.in | 66 + .../harfbuzz/harfbuzz-0.9.10/src/hb-warning.cc | 39 + .../source/libs/harfbuzz/harfbuzz-0.9.10/src/hb.h | 45 + .../libs/harfbuzz/harfbuzz-0.9.10/src/main.cc | 197 ++ .../harfbuzz-0.9.10/src/test-size-params.cc | 93 + .../harfbuzz-0.9.10/src/test-would-substitute.cc | 103 + .../libs/harfbuzz/harfbuzz-0.9.10/src/test.cc | 132 ++ .../libs/harfbuzz/harfbuzz-0.9.8-PATCHES/ChangeLog | 25 - .../harfbuzz/harfbuzz-0.9.8-PATCHES/TL-Changes | 27 - .../harfbuzz/harfbuzz-0.9.8-PATCHES/patch-03-VOID | 57 - .../harfbuzz/harfbuzz-0.9.8-PATCHES/patch-04-MSV | 14 - Build/source/libs/harfbuzz/harfbuzz-0.9.8/AUTHORS | 8 - .../libs/harfbuzz/harfbuzz-0.9.8/Makefile.am | 79 - Build/source/libs/harfbuzz/harfbuzz-0.9.8/NEWS | 585 ------ Build/source/libs/harfbuzz/harfbuzz-0.9.8/README | 7 - Build/source/libs/harfbuzz/harfbuzz-0.9.8/THANKS | 7 - Build/source/libs/harfbuzz/harfbuzz-0.9.8/TODO | 102 - .../source/libs/harfbuzz/harfbuzz-0.9.8/autogen.sh | 27 - .../libs/harfbuzz/harfbuzz-0.9.8/config.h.in | 160 -- .../libs/harfbuzz/harfbuzz-0.9.8/configure.ac | 265 --- Build/source/libs/harfbuzz/harfbuzz-0.9.8/git.mk | 224 -- .../libs/harfbuzz/harfbuzz-0.9.8/harfbuzz.doap | 24 - .../libs/harfbuzz/harfbuzz-0.9.8/harfbuzz.pc.in | 11 - .../libs/harfbuzz/harfbuzz-0.9.8/src/Makefile.am | 317 --- .../harfbuzz-0.9.8/src/check-c-linkage-decls.sh | 28 - .../harfbuzz-0.9.8/src/check-exported-symbols.sh | 40 - .../harfbuzz-0.9.8/src/check-header-guards.sh | 25 - .../harfbuzz/harfbuzz-0.9.8/src/check-includes.sh | 42 - .../harfbuzz-0.9.8/src/check-internal-symbols.sh | 34 - .../harfbuzz/harfbuzz-0.9.8/src/check-libstdc++.sh | 34 - .../harfbuzz-0.9.8/src/check-static-inits.sh | 39 - .../harfbuzz-0.9.8/src/gen-arabic-table.py | 197 -- .../harfbuzz/harfbuzz-0.9.8/src/gen-indic-table.py | 211 -- .../harfbuzz-0.9.8/src/hb-atomic-private.hh | 111 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-blob.cc | 325 --- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-blob.h | 101 - .../harfbuzz-0.9.8/src/hb-buffer-private.hh | 199 -- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-buffer.cc | 1294 ------------ .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-buffer.h | 323 --- .../harfbuzz-0.9.8/src/hb-cache-private.hh | 74 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-common.cc | 418 ---- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-common.h | 317 --- .../harfbuzz/harfbuzz-0.9.8/src/hb-coretext.cc | 351 ---- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-coretext.h | 43 - .../harfbuzz-0.9.8/src/hb-fallback-shape.cc | 129 -- .../harfbuzz/harfbuzz-0.9.8/src/hb-font-private.hh | 469 ----- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-font.cc | 1008 --------- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-font.h | 454 ----- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-ft.cc | 493 ----- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-ft.h | 62 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-glib.cc | 384 ---- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-glib.h | 52 - .../harfbuzz-0.9.8/src/hb-gobject-enums.cc.tmpl | 74 - .../harfbuzz-0.9.8/src/hb-gobject-structs.cc | 63 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-gobject.h | 69 - .../harfbuzz/harfbuzz-0.9.8/src/hb-graphite2.cc | 348 ---- .../harfbuzz/harfbuzz-0.9.8/src/hb-graphite2.h | 40 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-icu-le.cc | 215 -- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-icu.cc | 372 ---- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-icu.h | 52 - .../harfbuzz-0.9.8/src/hb-mutex-private.hh | 130 -- .../harfbuzz-0.9.8/src/hb-object-private.hh | 227 --- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-old.cc | 410 ---- .../harfbuzz-0.9.8/src/hb-open-file-private.hh | 261 --- .../harfbuzz-0.9.8/src/hb-open-type-private.hh | 946 --------- .../harfbuzz-0.9.8/src/hb-ot-head-table.hh | 149 -- .../harfbuzz-0.9.8/src/hb-ot-hhea-table.hh | 97 - .../harfbuzz-0.9.8/src/hb-ot-hmtx-table.hh | 92 - .../src/hb-ot-layout-common-private.hh | 912 --------- .../harfbuzz-0.9.8/src/hb-ot-layout-gdef-table.hh | 431 ---- .../harfbuzz-0.9.8/src/hb-ot-layout-gpos-table.hh | 1646 --------------- .../harfbuzz-0.9.8/src/hb-ot-layout-gsub-table.hh | 1414 ------------- .../src/hb-ot-layout-gsubgpos-private.hh | 2120 ------------------- .../harfbuzz-0.9.8/src/hb-ot-layout-private.hh | 220 -- .../harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout.cc | 667 ------ .../harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout.h | 289 --- .../harfbuzz-0.9.8/src/hb-ot-map-private.hh | 214 -- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-map.cc | 304 --- .../harfbuzz-0.9.8/src/hb-ot-maxp-table.hh | 69 - .../harfbuzz-0.9.8/src/hb-ot-name-table.hh | 132 -- .../src/hb-ot-shape-complex-arabic-fallback.hh | 253 --- .../src/hb-ot-shape-complex-arabic-table.hh | 942 --------- .../src/hb-ot-shape-complex-arabic.cc | 359 ---- .../src/hb-ot-shape-complex-default.cc | 226 --- .../src/hb-ot-shape-complex-indic-machine.hh | 1322 ------------ .../src/hb-ot-shape-complex-indic-machine.rl | 124 -- .../src/hb-ot-shape-complex-indic-private.hh | 388 ---- .../src/hb-ot-shape-complex-indic-table.hh | 872 -------- .../src/hb-ot-shape-complex-indic.cc | 1392 ------------- .../src/hb-ot-shape-complex-private.hh | 313 --- .../harfbuzz-0.9.8/src/hb-ot-shape-complex-thai.cc | 378 ---- .../src/hb-ot-shape-fallback-private.hh | 44 - .../harfbuzz-0.9.8/src/hb-ot-shape-fallback.cc | 409 ---- .../src/hb-ot-shape-normalize-private.hh | 71 - .../harfbuzz-0.9.8/src/hb-ot-shape-normalize.cc | 408 ---- .../harfbuzz-0.9.8/src/hb-ot-shape-private.hh | 125 -- .../harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape.cc | 640 ------ .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-tag.cc | 714 ------- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-tag.h | 59 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot.h | 49 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-private.hh | 853 -------- .../harfbuzz/harfbuzz-0.9.8/src/hb-set-private.hh | 305 --- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-set.cc | 221 -- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-set.h | 149 -- .../harfbuzz-0.9.8/src/hb-shape-plan-private.hh | 60 - .../harfbuzz/harfbuzz-0.9.8/src/hb-shape-plan.cc | 308 --- .../harfbuzz/harfbuzz-0.9.8/src/hb-shape-plan.h | 89 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-shape.cc | 276 --- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-shape.h | 81 - .../harfbuzz-0.9.8/src/hb-shaper-impl-private.hh | 43 - .../harfbuzz/harfbuzz-0.9.8/src/hb-shaper-list.hh | 55 - .../harfbuzz-0.9.8/src/hb-shaper-private.hh | 106 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-shaper.cc | 109 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-tt-font.cc | 79 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-ucdn.cc | 205 -- .../harfbuzz-0.9.8/src/hb-unicode-private.hh | 306 --- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-unicode.cc | 435 ---- .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-unicode.h | 357 ---- .../harfbuzz/harfbuzz-0.9.8/src/hb-uniscribe.cc | 476 ----- .../harfbuzz/harfbuzz-0.9.8/src/hb-uniscribe.h | 49 - .../harfbuzz/harfbuzz-0.9.8/src/hb-utf-private.hh | 204 -- .../harfbuzz/harfbuzz-0.9.8/src/hb-version.h.in | 66 - .../libs/harfbuzz/harfbuzz-0.9.8/src/hb-warning.cc | 39 - Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb.h | 45 - .../libs/harfbuzz/harfbuzz-0.9.8/src/main.cc | 197 -- .../harfbuzz-0.9.8/src/test-size-params.cc | 98 - .../harfbuzz-0.9.8/src/test-would-substitute.cc | 103 - .../libs/harfbuzz/harfbuzz-0.9.8/src/test.cc | 132 -- Build/source/libs/harfbuzz/version.ac | 2 +- 244 files changed, 36166 insertions(+), 35713 deletions(-) create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/ChangeLog create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/TL-Changes create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/AUTHORS create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/Android.mk create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/Makefile.am create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/NEWS create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/README create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/THANKS create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/TODO create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/autogen.sh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/config.h.in create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/configure.ac create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.doap create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.pc.in create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/Makefile.am create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-c-linkage-decls.sh create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-exported-symbols.sh create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-header-guards.sh create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-includes.sh create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-internal-symbols.sh create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-libstdc++.sh create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-static-inits.sh create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-arabic-table.py create mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-indic-table.py create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-atomic-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-cache-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-fallback-shape.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-enums.cc.tmpl create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-structs.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu-le.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-mutex-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-object-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-old.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-file-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-type-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-head-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hhea-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hmtx-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-common-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-gdef-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-gpos-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-gsub-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-gsubgpos-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-map-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-map.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-maxp-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-name-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-arabic-fallback.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-arabic-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-arabic.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-default.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-indic-machine.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-indic-machine.rl create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-indic-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-indic-table.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-indic.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-complex-thai.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-fallback-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-fallback.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-normalize-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-normalize.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-shape.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-tag.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-tag.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-set-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-set.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-set.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shape-plan-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shape-plan.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shape-plan.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shape.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shape.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shaper-impl-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shaper-list.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shaper-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-shaper.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-tt-font.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ucdn.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-unicode-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-unicode.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-unicode.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-uniscribe.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-uniscribe.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-utf-private.hh create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-version.h.in create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-warning.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb.h create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/main.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/test-size-params.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/test-would-substitute.cc create mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/test.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8-PATCHES/ChangeLog delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8-PATCHES/TL-Changes delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8-PATCHES/patch-03-VOID delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8-PATCHES/patch-04-MSV delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/AUTHORS delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/Makefile.am delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/NEWS delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/README delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/THANKS delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/TODO delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/autogen.sh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/config.h.in delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/configure.ac delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/git.mk delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/harfbuzz.doap delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/harfbuzz.pc.in delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/Makefile.am delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/check-c-linkage-decls.sh delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/check-exported-symbols.sh delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/check-header-guards.sh delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/check-includes.sh delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/check-internal-symbols.sh delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/check-libstdc++.sh delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/check-static-inits.sh delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/gen-arabic-table.py delete mode 100755 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/gen-indic-table.py delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-atomic-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-blob.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-blob.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-buffer-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-buffer.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-buffer.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-cache-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-common.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-common.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-coretext.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-coretext.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-fallback-shape.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-font-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-font.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-font.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ft.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ft.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-glib.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-glib.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-gobject-enums.cc.tmpl delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-gobject-structs.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-gobject.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-graphite2.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-graphite2.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-icu-le.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-icu.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-icu.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-mutex-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-object-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-old.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-open-file-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-open-type-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-head-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-hhea-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-hmtx-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout-common-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout-gdef-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout-gpos-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout-gsub-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout-gsubgpos-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-layout.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-map-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-map.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-maxp-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-name-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-arabic-fallback.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-arabic-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-arabic.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-default.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-indic-machine.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-indic-machine.rl delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-indic-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-indic-table.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-indic.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-complex-thai.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-fallback-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-fallback.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-normalize-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-normalize.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-shape.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-tag.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot-tag.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ot.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-set-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-set.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-set.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shape-plan-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shape-plan.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shape-plan.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shape.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shape.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shaper-impl-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shaper-list.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shaper-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-shaper.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-tt-font.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-ucdn.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-unicode-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-unicode.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-unicode.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-uniscribe.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-uniscribe.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-utf-private.hh delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-version.h.in delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb-warning.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/hb.h delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/main.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/test-size-params.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/test-would-substitute.cc delete mode 100644 Build/source/libs/harfbuzz/harfbuzz-0.9.8/src/test.cc (limited to 'Build/source/libs/harfbuzz') diff --git a/Build/source/libs/harfbuzz/ChangeLog b/Build/source/libs/harfbuzz/ChangeLog index d1ed4aaaac3..130281a2a87 100644 --- a/Build/source/libs/harfbuzz/ChangeLog +++ b/Build/source/libs/harfbuzz/ChangeLog @@ -1,3 +1,8 @@ +2013-01-03 Khaled Hosny + + Import harfbuzz-0.9.10. + * version.ac: Adjust. + 2012-12-15 Peter Breitenlohner * configure.ac: Use KPSE_BASIC to enable silent rules. diff --git a/Build/source/libs/harfbuzz/Makefile.in b/Build/source/libs/harfbuzz/Makefile.in index f81212a712a..4d3a14f4daa 100644 --- a/Build/source/libs/harfbuzz/Makefile.in +++ b/Build/source/libs/harfbuzz/Makefile.in @@ -54,7 +54,7 @@ subdir = . DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in \ - $(top_srcdir)/harfbuzz-0.9.8/src/hb-version.h.in \ + $(top_srcdir)/harfbuzz-0.9.10/src/hb-version.h.in \ $(top_srcdir)/../../build-aux/depcomp ChangeLog \ ../../build-aux/config.guess ../../build-aux/config.sub \ ../../build-aux/depcomp ../../build-aux/install-sh \ @@ -514,7 +514,7 @@ $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) distclean-hdr: -rm -f config.h stamp-h1 -hb-version.h: $(top_builddir)/config.status $(top_srcdir)/harfbuzz-0.9.8/src/hb-version.h.in +hb-version.h: $(top_builddir)/config.status $(top_srcdir)/harfbuzz-0.9.10/src/hb-version.h.in cd $(top_builddir) && $(SHELL) ./config.status $@ clean-noinstLIBRARIES: diff --git a/Build/source/libs/harfbuzz/configure b/Build/source/libs/harfbuzz/configure index ac2977a3d67..9110243b246 100755 --- a/Build/source/libs/harfbuzz/configure +++ b/Build/source/libs/harfbuzz/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for harfbuzz for TeX Live 0.9.8. +# Generated by GNU Autoconf 2.69 for harfbuzz for TeX Live 0.9.10. # # Report bugs to . # @@ -590,12 +590,12 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='harfbuzz for TeX Live' PACKAGE_TARNAME='harfbuzz-for-tex-live' -PACKAGE_VERSION='0.9.8' -PACKAGE_STRING='harfbuzz for TeX Live 0.9.8' +PACKAGE_VERSION='0.9.10' +PACKAGE_STRING='harfbuzz for TeX Live 0.9.10' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' -ac_unique_file="harfbuzz-0.9.8/harfbuzz.pc.in" +ac_unique_file="harfbuzz-0.9.10/harfbuzz.pc.in" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -1360,7 +1360,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures harfbuzz for TeX Live 0.9.8 to adapt to many kinds of systems. +\`configure' configures harfbuzz for TeX Live 0.9.10 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1431,7 +1431,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of harfbuzz for TeX Live 0.9.8:";; + short | recursive ) echo "Configuration of harfbuzz for TeX Live 0.9.10:";; esac cat <<\_ACEOF @@ -1555,7 +1555,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -harfbuzz for TeX Live configure 0.9.8 +harfbuzz for TeX Live configure 0.9.10 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2045,7 +2045,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by harfbuzz for TeX Live $as_me 0.9.8, which was +It was created by harfbuzz for TeX Live $as_me 0.9.10, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3909,7 +3909,7 @@ fi # Define the identity of the package. PACKAGE='harfbuzz-for-tex-live' - VERSION='0.9.8' + VERSION='0.9.10' cat >>confdefs.h <<_ACEOF @@ -4065,8 +4065,8 @@ WARNING_CFLAGS=$kpse_cv_warning_cflags HB_VERSION_MAJOR=0 HB_VERSION_MINOR=9 -HB_VERSION_MICRO=8 -HB_VERSION=0.9.8 +HB_VERSION_MICRO=10 +HB_VERSION=0.9.10 ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -16486,7 +16486,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -harfbuzz for TeX Live config.lt 0.9.8 +harfbuzz for TeX Live config.lt 0.9.10 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -18302,14 +18302,14 @@ $as_echo "#define HAVE_INTEL_ATOMIC_PRIMITIVES 1" >>confdefs.h fi -HARFBUZZ_TREE=harfbuzz-0.9.8 +HARFBUZZ_TREE=harfbuzz-0.9.10 if test -f $srcdir/$HARFBUZZ_TREE/src/hb-version.h; then as_fn_error $? "Sorry, you must remove the file $HARFBUZZ_TREE/src/hb-version.h" "$LINENO" 5 fi -ac_config_files="$ac_config_files Makefile include/Makefile hb-version.h:harfbuzz-0.9.8/src/hb-version.h.in" +ac_config_files="$ac_config_files Makefile include/Makefile hb-version.h:harfbuzz-0.9.10/src/hb-version.h.in" cat >confcache <<\_ACEOF @@ -18858,7 +18858,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by harfbuzz for TeX Live $as_me 0.9.8, which was +This file was extended by harfbuzz for TeX Live $as_me 0.9.10, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -18924,7 +18924,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -harfbuzz for TeX Live config.status 0.9.8 +harfbuzz for TeX Live config.status 0.9.10 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -19434,7 +19434,7 @@ do "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; - "hb-version.h") CONFIG_FILES="$CONFIG_FILES hb-version.h:harfbuzz-0.9.8/src/hb-version.h.in" ;; + "hb-version.h") CONFIG_FILES="$CONFIG_FILES hb-version.h:harfbuzz-0.9.10/src/hb-version.h.in" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/ChangeLog b/Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/ChangeLog new file mode 100644 index 00000000000..a81eff6bede --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/ChangeLog @@ -0,0 +1,32 @@ +2013-01-03 Khaled Hosny + + Imported harfbuzz-0.9.10 source tree from: + http://www.freedesktop.org/software/harfbuzz/release/ + * patch-03-VOID (removed): Applied upstream. + * patch-04-MSV (removed): ditto. + +2012-12-06 Peter Breitenlohner + + * patch-04-MSV (new): From Akira for MS Visual Studio 2005. + +2012-12-05 Peter Breitenlohner + + Imported harfbuzz-0.9.8 source tree from: + http://cgit.freedesktop.org/harfbuzz/ + * patch-01-Khaled (removed): Now distributed, with + hb_ot_layout_position_get_size() renamed into + hb_ot_layout_get_size_params(). + * patch-02-oldmsvc (removed): Not needed. + +2012-12-02 Akira Kakuto + + * patch-02-oldmsvc (new): #error is not recognized by old msvcs. + +2012-11-30 Peter Breitenlohner + + * patch-01-Khaled (new): Partial update from git, from Khaled. + +2012-11-29 Peter Breitenlohner + + Imported harfbuzz-0.9.7 source tree from: + http://cgit.freedesktop.org/harfbuzz/ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/TL-Changes b/Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/TL-Changes new file mode 100644 index 00000000000..be519ce4cc3 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10-PATCHES/TL-Changes @@ -0,0 +1,27 @@ +Changes applied to the harfbuzz-0.9.10/ tree as obtained from: + http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.10.tar.bz2 + +Removed: + COPYING + INSTALL + compile + config.guess + config.sub + depcomp + install-sh + ltmain.sh + missing + Makefile.in + aclocal.m4 + configure + src/Makefile.in + +Removed unused dirs: + contrib + m4 + test + util + src/hb-icu-le + src/hb-old + src/hb-ucdn + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/AUTHORS b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/AUTHORS new file mode 100644 index 00000000000..c611d7d4769 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/AUTHORS @@ -0,0 +1,8 @@ +Behdad Esfahbod +Simon Hausmann +Martin Hosken +Jonathan Kew +Lars Knoll +Werner Lemberg +Owen Taylor +David Turner diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/Android.mk b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/Android.mk new file mode 100644 index 00000000000..832d55e475a --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/Android.mk @@ -0,0 +1,74 @@ +## +## Copyright (C) 2012 The Android Open Source Project +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +LOCAL_PATH:= $(call my-dir) + +############################################################# +# build the harfbuzz library +# + +include $(CLEAR_VARS) + +LOCAL_ARM_MODE := arm + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES:= \ + src/hb-blob.cc \ + src/hb-buffer.cc \ + src/hb-common.cc \ + src/hb-fallback-shape.cc \ + src/hb-font.cc \ + src/hb-ot-tag.cc \ + src/hb-set.cc \ + src/hb-shape.cc \ + src/hb-shape-plan.cc \ + src/hb-shaper.cc \ + src/hb-tt-font.cc \ + src/hb-unicode.cc \ + src/hb-warning.cc \ + src/hb-ot-layout.cc \ + src/hb-ot-map.cc \ + src/hb-ot-shape.cc \ + src/hb-ot-shape-complex-arabic.cc \ + src/hb-ot-shape-complex-default.cc \ + src/hb-ot-shape-complex-indic.cc \ + src/hb-ot-shape-complex-thai.cc \ + src/hb-ot-shape-normalize.cc \ + src/hb-ot-shape-fallback.cc \ + src/hb-icu.cc + +LOCAL_CPP_EXTENSION := .cc + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libicuuc \ + libicui18n \ + libutils + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/src \ + external/icu4c/common + +LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU + +LOCAL_LDLIBS += -lpthread + +LOCAL_MODULE:= libharfbuzz_ng + +include $(BUILD_SHARED_LIBRARY) + + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/Makefile.am b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/Makefile.am new file mode 100644 index 00000000000..d7181268797 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/Makefile.am @@ -0,0 +1,80 @@ +# Process this file with automake to produce Makefile.in + +NULL = + +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = src util test + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = harfbuzz.pc + +EXTRA_DIST = \ + autogen.sh \ + harfbuzz.doap \ + Android.mk \ + $(NULL) + +MAINTAINERCLEANFILES = \ + $(srcdir)/INSTALL \ + $(srcdir)/aclocal.m4 \ + $(srcdir)/autoscan.log \ + $(srcdir)/compile \ + $(srcdir)/config.guess \ + $(srcdir)/config.sub \ + $(srcdir)/configure.scan \ + $(srcdir)/depcomp \ + $(srcdir)/install-sh \ + $(srcdir)/ltmain.sh \ + $(srcdir)/missing \ + $(srcdir)/mkinstalldirs \ + $(srcdir)/ChangeLog \ + `find "$(srcdir)" -type f -name Makefile.in -print` + + +# +# ChangeLog generation +# +CHANGELOG_RANGE = +ChangeLog: + $(AM_V_GEN) if test -d "$(top_srcdir)/.git"; then \ + (GIT_DIR=$(top_srcdir)/.git $(top_srcdir)/missing --run \ + git log $(CHANGELOG_RANGE) --stat) | fmt --split-only > $@.tmp \ + && mv -f $@.tmp "$(srcdir)/ChangeLog" \ + || ($(RM) $@.tmp; \ + echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \ + (test -f $@ || echo git-log is required to generate this file >> "$(srcdir)/$@")); \ + else \ + test -f $@ || \ + (echo A git checkout and git-log is required to generate ChangeLog >&2 && \ + echo A git checkout and git-log is required to generate this file >> "$(srcdir)/$@"); \ + fi +.PHONY: $(srcdir)/ChangeLog + + +# +# Release engineering +# + +# TODO: Copy infrastructure from cairo + +TAR_OPTIONS = --owner=0 --group=0 +dist-hook: dist-clear-sticky-bits +# Clean up any sticky bits we may inherit from parent dir +dist-clear-sticky-bits: + chmod -R a-s $(distdir) + + +tar_file = $(PACKAGE_TARNAME)-$(VERSION).tar.bz2 +sha256_file = $(tar_file).sha256 +gpg_file = $(sha256_file).asc +$(sha256_file): $(tar_file) + sha256sum $^ > $@ +$(gpg_file): $(sha256_file) + @echo "Please enter your GPG password to sign the checksum." + gpg --armor --sign $^ + +release-files: $(tar_file) $(sha256_file) $(gpg_file) + + +-include $(top_srcdir)/git.mk diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/NEWS b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/NEWS new file mode 100644 index 00000000000..ef643f02134 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/NEWS @@ -0,0 +1,617 @@ +Overview of changes leading to 0.9.10 +Thursday, January 3, 2013 +===================================== + +- [Indic] Fixed rendering of Malayalam dot-reph +- Updated OT language tags. +- Updated graphite2 backend. +- Improved hb_ot_layout_get_size_params() logic. +- Improve hb-shape/hb-view help output. +- Fixed hb-set.h implementation to not crash. +- Fixed various issues with hb_ot_layout_collect_lookups(). +- Various build fixes. + +New API: + +hb_graphite2_face_get_gr_face() +hb_graphite2_font_get_gr_font() +hb_coretext_face_get_cg_font() + +Modified API: + +hb_ot_layout_get_size_params() + + +Overview of changes leading to 0.9.9 +Wednesday, December 5, 2012 +==================================== + +- Fix build on Windows. +- Minor improvements. + + +Overview of changes leading to 0.9.8 +Tuesday, December 4, 2012 +==================================== + + +- Actually implement hb_shape_plan_get_shaper (). +- Make UCDB data tables const. +- Lots of internal refactoring in OTLayout tables. +- Flesh out hb_ot_layout_lookup_collect_glyphs(). + +New API: + +hb_ot_layout_collect_lookups() +hb_ot_layout_get_size_params() + + +Overview of changes leading to 0.9.7 +Sunday, November 21, 2012 +==================================== + + +HarfBuzz "All-You-Can-Eat-Sushi" (aka Vancouver) Hackfest and follow-on fixes. + +- Fix Arabic contextual joining using pre-context text. +- Fix Sinhala "split matra" mess. +- Fix Khmer shaping with broken fonts. +- Implement Thai "PUA" shaping for old fonts. +- Do NOT route Kharoshthi script through the Indic shaper. +- Disable fallback positioning for Indic and Thai shapers. +- Misc fixes. + + +hb-shape / hb-view changes: + +- Add --text-before and --text-after +- Add --bot / --eot / --preserve-default-ignorables +- hb-shape --output-format=json + + +New API: + +hb_buffer_clear() + +hb_buffer_flags_t + +HB_BUFFER_FLAGS_DEFAULT +HB_BUFFER_FLAG_BOT +HB_BUFFER_FLAG_EOT +HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES + +hb_buffer_set_flags() +hb_buffer_get_flags() + +HB_BUFFER_SERIALIZE_FLAGS +hb_buffer_serialize_glyphs() +hb_buffer_deserialize_glyphs() +hb_buffer_serialize_list_formats() + +hb_set_add_range() +hb_set_del_range() +hb_set_get_population() +hb_set_next_range() + +hb_face_[sg]et_glyph_count() + +hb_segment_properties_t +HB_SEGMENT_PROPERTIES_DEFAULT +hb_segment_properties_equal() +hb_segment_properties_hash() + +hb_buffer_set_segment_properties() +hb_buffer_get_segment_properties() + +hb_ot_layout_glyph_class_t +hb_ot_layout_get_glyph_class() +hb_ot_layout_get_glyphs_in_class() + +hb_shape_plan_t +hb_shape_plan_create() +hb_shape_plan_create_cached() +hb_shape_plan_get_empty() +hb_shape_plan_reference() +hb_shape_plan_destroy() +hb_shape_plan_set_user_data() +hb_shape_plan_get_user_data() +hb_shape_plan_execute() +hb_shape_plan_get_shaper() + +hb_ot_shape_plan_collect_lookups() + + +API changes: + +- Remove "mask" parameter from hb_buffer_add(). +- Rename hb_ot_layout_would_substitute_lookup() and hb_ot_layout_substitute_closure_lookup(). +- hb-set.h API const correction. +- Renamed hb_set_min/max() to hb_set_get_min/max(). +- Rename hb_ot_layout_feature_get_lookup_indexes() to hb_ot_layout_feature_get_lookups(). +- Rename hb_buffer_guess_properties() to hb_buffer_guess_segment_properties(). + + + +Overview of changes leading to 0.9.6 +Sunday, November 13, 2012 +==================================== + +- Don't clear pre-context text if no new context is provided. +- Fix ReverseChainingSubstLookup, which was totally borked. +- Adjust output format of hb-shape a bit. +- Include config.h.in in-tree. Makes it easier for alternate build systems. +- Fix hb_buffer_set_length(buffer, 0) invalid memory allocation. +- Use ICU LayoutEngine's C API instead of C++. Avoids much headache. +- Drop glyphs for all of Unicode Default_Ignorable characters. +- Misc build fixes. + +Arabic shaper: +- Enable 'dlig' and 'mset' features in Arabic shaper. +- Implement 'Phags-pa shaping, improve Mongolian. + +Indic shaper: +- Decompose Sinhala split matras the way old HarfBuzz / Pango did. +- Initial support for Consonant Medials. +- Start adding new-style Myanmar shaping. +- Make reph and 'pref' logic introspect the font. +- Route Meetei-Mayek through the Indic shaper. +- Don't apply 'liga' in Indic shaper. +- Improve Malayalam pre-base reordering Ra interaction with Chillus. + + + +Overview of changes leading to 0.9.5 +Sunday, October 14, 2012 +==================================== + +- Synthetic-GSUB Arabic fallback shaping. + +- Misc Indic improvements. + +- Add build system support for pthread. + +- Imported UCDN for in-tree Unicode callbacks implementation. + +- Context-aware Arabic joining. + +- Misc other fixes. + +- New API: + + hb_feature_to/from-string() + hb_buffer_[sg]et_content_type() + + + +Overview of changes leading to 0.9.4 +Tuesday, Sep 03, 2012 +==================================== + +- Indic improvements with old-spec Malayalam. + +- Better fallback glyph positioning, specially with Thai / Lao marks. + +- Implement dotted-circle insertion. + +- Better Arabic fallback shaping / ligation. + +- Added ICU LayoutEngine backend for testing. Call it by the 'icu_le' name. + +- Misc fixes. + + + +Overview of changes leading to 0.9.3 +Friday, Aug 18, 2012 +==================================== + +- Fixed fallback mark positioning for left-to-right text. + +- Improve mark positioning for the remaining combining classes. + +- Unbreak Thai and fallback Arabic shaping. + +- Port Arabic shaper to shape-plan caching. + +- Use new ICU normalizer functions. + + + +Overview of changes leading to 0.9.2 +Friday, Aug 10, 2012 +==================================== + +- Over a thousand commits! This is the first major release of HarfBuzz. + +- HarfBuzz is feature-complete now! It should be in par, or better, than + both Pango's shapers and old HarfBuzz / Qt shapers. + +- New Indic shaper, supporting main Indic scripts, Sinhala, and Khmer. + +- Improved Arabic shaper, with fallback Arabic shaping, supporting Arabic, + Sinhala, N'ko, Mongolian, and Mandaic. + +- New Thai / Lao shaper. + +- Tibetan / Hangul support in the generic shaper. + +- Synthetic GDEF support for fonts without a GDEF table. + +- Fallback mark positioning for fonts without a GPOS table. + +- Unicode normalization shaping heuristic during glyph mapping. + +- New experimental Graphite2 backend. + +- New Uniscribe backend (primarily for testing). + +- New CoreText backend (primarily for testing). + +- Major optimization and speedup. + +- Test suites and testing infrastructure (work in progress). + +- Greatly improved hb-view cmdline tool. + +- hb-shape cmdline tool. + +- Unicode 6.1 support. + +Summary of API changes: + +o Changed API: + + - Users are expected to only include main header files now (ie. hb.h, + hb-glib.h, hb-ft.h, ...) + + - All struct tag names had their initial underscore removed. + Ie. "struct _hb_buffer_t" is "struct hb_buffer_t" now. + + - All set_user_data() functions now take a "replace" boolean parameter. + + - hb_buffer_create() takes zero arguments now. + Use hb_buffer_pre_allocate() to pre-allocate. + + - hb_buffer_add_utf*() now accept -1 for length parameteres, + meaning "nul-terminated". + + - hb_direction_t enum values changed. + + - All *_from_string() APIs now take a length parameter to allow for + non-nul-terminated strings. A -1 length means "nul-terminated". + + - Typedef for hb_language_t changed. + + - hb_get_table_func_t renamed to hb_reference_table_func_t. + + - hb_ot_layout_table_choose_script() + + - Various renames in hb-unicode.h. + +o New API: + + - hb_buffer_guess_properties() + Automatically called by hb_shape(). + + - hb_buffer_normalize_glyphs() + + - hb_tag_from_string() + + - hb-coretext.h + + - hb-uniscribe.h + + - hb_face_reference_blob() + - hb_face_[sg]et_index() + - hb_face_set_upem() + + - hb_font_get_glyph_name_func_t + hb_font_get_glyph_from_name_func_t + hb_font_funcs_set_glyph_name_func() + hb_font_funcs_set_glyph_from_name_func() + hb_font_get_glyph_name() + hb_font_get_glyph_from_name() + hb_font_glyph_to_string() + hb_font_glyph_from_string() + + - hb_font_set_funcs_data() + + - hb_ft_font_set_funcs() + - hb_ft_font_get_face() + + - hb-gobject.h (work in progress) + + - hb_ot_shape_glyphs_closure() + hb_ot_layout_substitute_closure_lookup() + + - hb-set.h + + - hb_shape_full() + + - hb_unicode_combining_class_t + + - hb_unicode_compose_func_t + hb_unicode_decompose_func_t + hb_unicode_decompose_compatibility_func_t + hb_unicode_funcs_set_compose_func() + hb_unicode_funcs_set_decompose_func() + hb_unicode_funcs_set_decompose_compatibility_func() + hb_unicode_compose() + hb_unicode_decompose() + hb_unicode_decompose_compatibility() + +o Removed API: + + - hb_ft_get_font_funcs() + + - hb_ot_layout_substitute_start() + hb_ot_layout_substitute_lookup() + hb_ot_layout_substitute_finish() + hb_ot_layout_position_start() + hb_ot_layout_position_lookup() + hb_ot_layout_position_finish() + + + +Overview of changes leading to 0.6.0 +Friday, May 27, 2011 +==================================== + +- Vertical text support in GPOS +- Almost all API entries have unit tests now, under test/ +- All thread-safety issues are fixed + +Summary of API changes follows. + + +* Simple Types API: + + o New API: + HB_LANGUAGE_INVALID + hb_language_get_default() + hb_direction_to_string() + hb_direction_from_string() + hb_script_get_horizontal_direction() + HB_UNTAG() + + o Renamed API: + hb_category_t renamed to hb_unicode_general_category_t + + o Changed API: + hb_language_t is a typed pointers now + + o Removed API: + HB_TAG_STR() + + +* Use ISO 15924 tags for hb_script_t: + + o New API: + hb_script_from_iso15924_tag() + hb_script_to_iso15924_tag() + hb_script_from_string() + + o Changed API: + HB_SCRIPT_* enum members changed value. + + +* Buffer API streamlined: + + o New API: + hb_buffer_reset() + hb_buffer_set_length() + hb_buffer_allocation_successful() + + o Renamed API: + hb_buffer_ensure() renamed to hb_buffer_pre_allocate() + hb_buffer_add_glyph() renamed to hb_buffer_add() + + o Removed API: + hb_buffer_clear() + hb_buffer_clear_positions() + + o Changed API: + hb_buffer_get_glyph_infos() takes an out length parameter now + hb_buffer_get_glyph_positions() takes an out length parameter now + + +* Blob API streamlined: + + o New API: + hb_blob_get_data() + hb_blob_get_data_writable() + + o Renamed API: + hb_blob_create_empty() renamed to hb_blob_get_empty() + + o Removed API: + hb_blob_lock() + hb_blob_unlock() + hb_blob_is_writable() + hb_blob_try_writable() + + o Changed API: + hb_blob_create() takes user_data before destroy now + + +* Unicode functions API: + + o Unicode function vectors can subclass other unicode function vectors now. + Unimplemented callbacks in the subclass automatically chainup to the parent. + + o All hb_unicode_funcs_t callbacks take a user_data now. Their setters + take a user_data and its respective destroy callback. + + o New API: + hb_unicode_funcs_get_empty() + hb_unicode_funcs_get_default() + hb_unicode_funcs_get_parent() + + o Changed API: + hb_unicode_funcs_create() now takes a parent_funcs. + + o Removed func getter functions: + hb_unicode_funcs_get_mirroring_func() + hb_unicode_funcs_get_general_category_func() + hb_unicode_funcs_get_script_func() + hb_unicode_funcs_get_combining_class_func() + hb_unicode_funcs_get_eastasian_width_func() + + +* Face API: + + o Renamed API: + hb_face_get_table() renamed to hb_face_reference_table() + hb_face_create_for_data() renamed to hb_face_create() + + o Changed API: + hb_face_create_for_tables() takes user_data before destroy now + hb_face_reference_table() returns empty blob instead of NULL + hb_get_table_func_t accepts the face as first parameter now + +* Font API: + + o Fonts can subclass other fonts now. Unimplemented callbacks in the + subclass automatically chainup to the parent. When chaining up, + scale is adjusted if the parent font has a different scale. + + o All hb_font_funcs_t callbacks take a user_data now. Their setters + take a user_data and its respective destroy callback. + + o New API: + hb_font_get_parent() + hb_font_funcs_get_empty() + hb_font_create_sub_font() + + o Removed API: + hb_font_funcs_copy() + hb_font_unset_funcs() + + o Removed func getter functions: + hb_font_funcs_get_glyph_func() + hb_font_funcs_get_glyph_advance_func() + hb_font_funcs_get_glyph_extents_func() + hb_font_funcs_get_contour_point_func() + hb_font_funcs_get_kerning_func() + + o Changed API: + hb_font_create() takes a face and references it now + hb_font_set_funcs() takes user_data before destroy now + hb_font_set_scale() accepts signed integers now + hb_font_get_contour_point_func_t now takes glyph first, then point_index + hb_font_get_glyph_func_t returns a success boolean now + + +* Changed object model: + + o All object types have a _get_empty() now: + hb_blob_get_empty() + hb_buffer_get_empty() + hb_face_get_empty() + hb_font_get_empty() + hb_font_funcs_get_empty() + hb_unicode_funcs_get_empty() + + o Added _set_user_data() and _get_user_data() for all object types: + hb_blob_get_user_data() + hb_blob_set_user_data() + hb_buffer_get_user_data() + hb_buffer_set_user_data() + hb_face_get_user_data() + hb_face_set_user_data() + hb_font_funcs_get_user_data() + hb_font_funcs_set_user_data() + hb_font_get_user_data() + hb_font_set_user_data() + hb_unicode_funcs_get_user_data() + hb_unicode_funcs_set_user_data() + + o Removed the _get_reference_count() from all object types: + hb_blob_get_reference_count() + hb_buffer_get_reference_count() + hb_face_get_reference_count() + hb_font_funcs_get_reference_count() + hb_font_get_reference_count() + hb_unicode_funcs_get_reference_count() + + o Added _make_immutable() and _is_immutable() for all object types except for buffer: + hb_blob_make_immutable() + hb_blob_is_immutable() + hb_face_make_immutable() + hb_face_is_immutable() + + +* Changed API for vertical text support + + o The following callbacks where removed: + hb_font_get_glyph_advance_func_t + hb_font_get_kerning_func_t + + o The following new callbacks added instead: + hb_font_get_glyph_h_advance_func_t + hb_font_get_glyph_v_advance_func_t + hb_font_get_glyph_h_origin_func_t + hb_font_get_glyph_v_origin_func_t + hb_font_get_glyph_h_kerning_func_t + hb_font_get_glyph_v_kerning_func_t + + o The following API removed as such: + hb_font_funcs_set_glyph_advance_func() + hb_font_funcs_set_kerning_func() + hb_font_get_glyph_advance() + hb_font_get_kerning() + + o New API added instead: + hb_font_funcs_set_glyph_h_advance_func() + hb_font_funcs_set_glyph_v_advance_func() + hb_font_funcs_set_glyph_h_origin_func() + hb_font_funcs_set_glyph_v_origin_func() + hb_font_funcs_set_glyph_h_kerning_func() + hb_font_funcs_set_glyph_v_kerning_func() + hb_font_get_glyph_h_advance() + hb_font_get_glyph_v_advance() + hb_font_get_glyph_h_origin() + hb_font_get_glyph_v_origin() + hb_font_get_glyph_h_kerning() + hb_font_get_glyph_v_kerning() + + o The following higher-leve API added for convenience: + hb_font_get_glyph_advance_for_direction() + hb_font_get_glyph_origin_for_direction() + hb_font_add_glyph_origin_for_direction() + hb_font_subtract_glyph_origin_for_direction() + hb_font_get_glyph_kerning_for_direction() + hb_font_get_glyph_extents_for_origin() + hb_font_get_glyph_contour_point_for_origin() + + +* OpenType Layout API: + + o New API: + hb_ot_layout_position_start() + hb_ot_layout_substitute_start() + hb_ot_layout_substitute_finish() + + +* Glue code: + + o New API: + hb_glib_script_to_script() + hb_glib_script_from_script() + hb_icu_script_to_script() + hb_icu_script_from_script() + + +* Version API added: + + o New API: + HB_VERSION_MAJOR + HB_VERSION_MINOR + HB_VERSION_MICRO + HB_VERSION_STRING + HB_VERSION_CHECK() + hb_version() + hb_version_string() + hb_version_check() + + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/README b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/README new file mode 100644 index 00000000000..74e739da52a --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/README @@ -0,0 +1,7 @@ +This is HarfBuzz, a text shaping library. + +For bug reports, mailing list, and other information please visit: + + http://harfbuzz.org/ + +For license information, see the file COPYING. diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/THANKS b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/THANKS new file mode 100644 index 00000000000..940cfde5c39 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/THANKS @@ -0,0 +1,7 @@ +Bradley Grainger +Khaled Hosny +Kenichi Ishibashi +Ryan Lortie +Jeff Muizelaar +suzuki toshiya +Philip Withnall diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/TODO b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/TODO new file mode 100644 index 00000000000..c93b33e62d7 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/TODO @@ -0,0 +1,91 @@ +General fixes: +============= + +- AAT 'morx' implementation. + +- Return "safe-to-break" bit from shaping. + +- Disable 'vert' if 'vrt2' is available (eg. Motoya fonts with arrow chars). + +- Fix TT 'kern' on/off and GPOS interaction (move kerning before GPOS). + +- Implement 'rand' feature. + +- mask propagation? (when ligation, "or" the masks). + +- Warn at compile time (and runtime with HB_DEBUG?) if no Unicode / font + funcs found / set. + +- Do proper rounding when scaling from font space? May be a non-issue. + +- Misc features: + * init/medi/fina/isol for non-cursive scripts + * vkna,hkna etc for kana, etc + * smpl,trad for ZHS / ZHT + + +API issues to fix before 1.0: +============================ + +- API to accept a list of languages. + +- Add default font_funcs / Unicode funcs API and to utils. + +- Add init_func to font_funcs. Adjust ft. + +- Add pkg-config files for glue codes (harfbuzz-glib, etc) + +- Figure out how many .so objects, how to link, etc + +- 'const' for getter APIs? (use mutable internally) + +- blob_from_file? + + +API additions +============= + +- Language to/from script. + +- Buffer (de)serialize API ala hb-shape? + +- Add hb-cairo glue + +- Add sanitize API (and a cached version, that saves result on blob user-data) + +- Add glib GBoxedType stuff and introspection + +- BCP 47 language handling / API (language_matches?) + +- Add hb_font_create_linear()? + +- Add query API for aalt-like features? + +- SFNT api? get_num_faces? get_table_tags? (there's something in stash) + +- Add segmentation API + +- Add hb-fribidi glue? + + +hb-view / hb-shape enhancements: +=============================== + +- Add --width, --height, --auto-size, --align, etc? + + +Tests to write: +============== + +- ot-layout enumeration API (needs font) + +- Finish test-shape.c, grep for TODO + +- Finish test-unicode.c, grep for TODO + +- GObject, FreeType, etc + +- hb_cache_t and relatives + +- hb_feature_to/from_string +- hb_buffer_[sg]et_contents diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/autogen.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/autogen.sh new file mode 100755 index 00000000000..47640c3e490 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/autogen.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +test -n "$srcdir" || srcdir=`dirname "$0"` +test -n "$srcdir" || srcdir=. + +olddir=`pwd` +cd $srcdir + +echo -n "checking for pkg-config... " +which pkg-config || { + echo "*** No pkg-config found, please install it ***" + exit 1 +} + +echo -n "checking for autoreconf... " +which autoreconf || { + echo "*** No autoreconf found, please install it ***" + exit 1 +} + +echo "running autoreconf --force --install --verbose" +autoreconf --force --install --verbose || exit $? + +cd $olddir +echo "running configure $@" +test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/config.h.in b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/config.h.in new file mode 100644 index 00000000000..0973c936bb2 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/config.h.in @@ -0,0 +1,150 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Have cairo graphics library */ +#undef HAVE_CAIRO + +/* Have cairo-ft support in cairo graphics library */ +#undef HAVE_CAIRO_FT + +/* Have Core Text backend */ +#undef HAVE_CORETEXT + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Have FreeType 2 library */ +#undef HAVE_FREETYPE + +/* Define to 1 if you have the `FT_Face_GetCharVariantIndex' function. */ +#undef HAVE_FT_FACE_GETCHARVARIANTINDEX + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Have glib2 library */ +#undef HAVE_GLIB + +/* Have gobject2 library */ +#undef HAVE_GOBJECT + +/* Have Graphite library */ +#undef HAVE_GRAPHITE2 + +/* Have gthread2 library */ +#undef HAVE_GTHREAD + +/* Have Old HarfBuzz backend */ +#undef HAVE_HB_OLD + +/* Have ICU library */ +#undef HAVE_ICU + +/* Have ICU Layout Engine library */ +#undef HAVE_ICU_LE + +/* Have Intel __sync_* atomic primitives */ +#undef HAVE_INTEL_ATOMIC_PRIMITIVES + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_IO_H + +/* Define to 1 if you have the `isatty' function. */ +#undef HAVE_ISATTY + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mmap' function. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the `mprotect' function. */ +#undef HAVE_MPROTECT + +/* Have native OpenType Layout backend */ +#undef HAVE_OT + +/* Have POSIX threads */ +#undef HAVE_PTHREAD + +/* Have PTHREAD_PRIO_INHERIT. */ +#undef HAVE_PTHREAD_PRIO_INHERIT + +/* Define to 1 if you have the header file. */ +#undef HAVE_SCHED_H + +/* Define to 1 if you have the `sched_yield' function. */ +#undef HAVE_SCHED_YIELD + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `sysconf' function. */ +#undef HAVE_SYSCONF + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Have UCDN Unicode functions */ +#undef HAVE_UCDN + +/* Have Uniscribe backend */ +#undef HAVE_UNISCRIBE + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `_setmode' function. */ +#undef HAVE__SETMODE + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +#undef PTHREAD_CREATE_JOINABLE + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/configure.ac b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/configure.ac new file mode 100644 index 00000000000..91ea7136938 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/configure.ac @@ -0,0 +1,302 @@ +AC_PREREQ([2.64]) +AC_INIT([HarfBuzz], + [0.9.10], + [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz], + [harfbuzz], + [http://harfbuzz.org/]) + +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SRCDIR([harfbuzz.pc.in]) +AC_CONFIG_HEADERS([config.h]) + +AM_INIT_AUTOMAKE([1.11.1 gnits dist-bzip2 no-dist-gzip -Wall no-define]) +AM_SILENT_RULES([yes]) + +# Initialize libtool +LT_PREREQ([2.2]) +LT_INIT([disable-static]) + +# Check for programs +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_CXX +PKG_PROG_PKG_CONFIG([0.20]) + +# Version +m4_define(hb_version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]])) +m4_define(hb_version_major,m4_argn(1,hb_version_triplet)) +m4_define(hb_version_minor,m4_argn(2,hb_version_triplet)) +m4_define(hb_version_micro,m4_argn(3,hb_version_triplet)) +HB_VERSION_MAJOR=hb_version_major +HB_VERSION_MINOR=hb_version_minor +HB_VERSION_MICRO=hb_version_micro +HB_VERSION=AC_PACKAGE_VERSION +AC_SUBST(HB_VERSION_MAJOR) +AC_SUBST(HB_VERSION_MINOR) +AC_SUBST(HB_VERSION_MICRO) +AC_SUBST(HB_VERSION) + +# Libtool version +m4_define([hb_version_int], + m4_eval(hb_version_major*10000 + hb_version_minor*100 + hb_version_micro)) +m4_if(m4_eval(hb_version_minor % 2), [1], + dnl for unstable releases + [m4_define([hb_libtool_revision], 0)], + dnl for stable releases + [m4_define([hb_libtool_revision], hb_version_micro)]) +m4_define([hb_libtool_age], + m4_eval(hb_version_int - hb_libtool_revision)) +m4_define([hb_libtool_current], + m4_eval(hb_version_major + hb_libtool_age)) +HB_LIBTOOL_VERSION_INFO=hb_libtool_current:hb_libtool_revision:hb_libtool_age +AC_SUBST(HB_LIBTOOL_VERSION_INFO) + +dnl GOBJECT_INTROSPECTION_CHECK([0.9.0]) +dnl GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) + +# Functions and headers +AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize sched_yield mmap _setmode isatty) +AC_CHECK_HEADERS(unistd.h sys/mman.h sched.h io.h) + +# Compiler flags +AC_CANONICAL_HOST +if test "x$GCC" = "xyes"; then + + # Make symbols link locally + LDFLAGS="$LDFLAGS -Bsymbolic-functions" + + # Make sure we don't link to libstdc++ + CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions" + + # Assorted warnings + CXXFLAGS="$CXXFLAGS -Wcast-align" + + case "$host" in + *-*-mingw*) + ;; + *) + # Hide inline methods + CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden" + ;; + esac + + case "$host" in + arm-*-*) + # Request byte alignment on arm + CXXFLAGS="$CXXFLAGS -mstructure-size-boundary=8" + ;; + esac +fi + +hb_os_win32=no +AC_MSG_CHECKING([for native Win32]) +case "$host" in + *-*-mingw*) + hb_os_win32=yes + ;; +esac +AC_MSG_RESULT([$hb_os_win32]) +AM_CONDITIONAL(OS_WIN32, test "$hb_os_win32" = "yes") + +have_pthread=false +if test "$hb_os_win32" = no; then + AX_PTHREAD([have_pthread=true]) +fi +if $have_pthread; then + AC_DEFINE(HAVE_PTHREAD, 1, [Have POSIX threads]) +fi +AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread) + +dnl ========================================================================== + +have_ot=true +if $have_ot; then + AC_DEFINE(HAVE_OT, 1, [Have native OpenType Layout backend]) +fi +AM_CONDITIONAL(HAVE_OT, $have_ot) + +dnl =========================================================================== + +have_hb_old=true +if $have_hb_old; then + AC_DEFINE(HAVE_HB_OLD, 1, [Have Old HarfBuzz backend]) +fi +AM_CONDITIONAL(HAVE_HB_OLD, $have_hb_old) + +dnl =========================================================================== + +have_ucdn=true +if $have_ucdn; then + AC_DEFINE(HAVE_UCDN, 1, [Have UCDN Unicode functions]) +fi +AM_CONDITIONAL(HAVE_UCDN, $have_ucdn) + +dnl =========================================================================== + +PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, have_glib=true, have_glib=false) +if $have_glib; then + AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library]) +fi +AM_CONDITIONAL(HAVE_GLIB, $have_glib) + +PKG_CHECK_MODULES(GTHREAD, gthread-2.0, have_gthread=true, have_gthread=false) +if $have_gthread; then + AC_DEFINE(HAVE_GTHREAD, 1, [Have gthread2 library]) +fi +AM_CONDITIONAL(HAVE_GTHREAD, $have_gthread) + +PKG_CHECK_MODULES(GOBJECT, gobject-2.0 glib-2.0 >= 2.16, have_gobject=true, have_gobject=false) +if $have_gobject; then + AC_DEFINE(HAVE_GOBJECT, 1, [Have gobject2 library]) + GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` + AC_SUBST(GLIB_MKENUMS) +fi +AM_CONDITIONAL(HAVE_GOBJECT, $have_gobject) + +dnl ========================================================================== + +PKG_CHECK_MODULES(CAIRO, cairo >= 1.8.0, have_cairo=true, have_cairo=false) +if $have_cairo; then + AC_DEFINE(HAVE_CAIRO, 1, [Have cairo graphics library]) +fi +AM_CONDITIONAL(HAVE_CAIRO, $have_cairo) + +PKG_CHECK_MODULES(CAIRO_FT, cairo-ft, have_cairo_ft=true, have_cairo_ft=false) +if $have_cairo_ft; then + AC_DEFINE(HAVE_CAIRO_FT, 1, [Have cairo-ft support in cairo graphics library]) +fi +AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft) + +dnl ========================================================================== + +PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, have_icu=false) +if $have_icu; then + AC_DEFINE(HAVE_ICU, 1, [Have ICU library]) +fi +AM_CONDITIONAL(HAVE_ICU, $have_icu) + +dnl ========================================================================== + +PKG_CHECK_MODULES(ICU_LE, icu-le icu-uc, have_icu_le=true, have_icu_le=false) +if $have_icu_le; then + AC_DEFINE(HAVE_ICU_LE, 1, [Have ICU Layout Engine library]) +fi +AM_CONDITIONAL(HAVE_ICU_LE, $have_icu_le) + +dnl ========================================================================== + +PKG_CHECK_MODULES(GRAPHITE2, graphite2, have_graphite=true, have_graphite=false) +if $have_graphite; then + AC_DEFINE(HAVE_GRAPHITE2, 1, [Have Graphite library]) +fi +AM_CONDITIONAL(HAVE_GRAPHITE2, $have_graphite) + +dnl ========================================================================== + +PKG_CHECK_MODULES(FREETYPE, freetype2 >= 2.3.8, have_freetype=true, have_freetype=false) +if $have_freetype; then + AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library]) + _save_libs="$LIBS" + _save_cflags="$CFLAGS" + LIBS="$LIBS $FREETYPE_LIBS" + CFLAGS="$CFLAGS $FREETYPE_CFLAGS" + AC_CHECK_FUNCS(FT_Face_GetCharVariantIndex) + LIBS="$_save_libs" + CFLAGS="$_save_cflags" +fi +AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype) + +dnl =========================================================================== + +AC_MSG_CHECKING([for ScriptShapeOpenType in usp10]) +saved_LIBS=$LIBS +LIBS="$LIBS -lusp10 -lgdi32" +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ + #define _WIN32_WINNT 0x0600 + #include + #include + ]], + ScriptShapeOpenType)], + [have_uniscribe=true; AC_MSG_RESULT(yes)], + [have_uniscribe=false;AC_MSG_RESULT(no)]) +LIBS=$saved_LIBS +if $have_uniscribe; then + UNISCRIBE_CFLAGS= + UNISCRIBE_LIBS="-lusp10 -lgdi32" + AC_SUBST(UNISCRIBE_CFLAGS) + AC_SUBST(UNISCRIBE_LIBS) + AC_DEFINE(HAVE_UNISCRIBE, 1, [Have Uniscribe backend]) +fi +AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe) + +dnl =========================================================================== + +AC_CHECK_TYPE(CTFontRef, have_coretext=true, have_coretext=false, [#include ]) +if $have_coretext; then + CORETEXT_CFLAGS= + CORETEXT_LIBS="-framework ApplicationServices" + AC_SUBST(CORETEXT_CFLAGS) + AC_SUBST(CORETEXT_LIBS) + AC_DEFINE(HAVE_CORETEXT, 1, [Have Core Text backend]) +fi +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_CONFIG_FILES([ +Makefile +harfbuzz.pc +src/Makefile +src/hb-version.h +src/hb-icu-le/Makefile +src/hb-old/Makefile +src/hb-ucdn/Makefile +util/Makefile +test/Makefile +test/api/Makefile +test/shaping/Makefile +]) + +AC_OUTPUT + +AC_MSG_NOTICE([ + +Build configuration: + +Unicode callbacks (you want at least one): + Glib: ${have_glib} + ICU: ${have_icu} + UCDN: ${have_ucdn} + +Font callbacks (the more the better): + FreeType: ${have_freetype} + +Tools used for command-line utilities: + Cairo: ${have_cairo} + +Additional shapers (the more the better): + Graphite2: ${have_graphite} + +Test / platform shapers (not normally needed): + CoreText: ${have_coretext} + ICU Layout Engine: ${have_icu_le} + Old HarfBuzz: ${have_hb_old} + Uniscribe: ${have_uniscribe} +]) diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.doap b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.doap new file mode 100644 index 00000000000..d2896ebefa8 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.doap @@ -0,0 +1,24 @@ + + + harfbuzz + Text shaping library + + + + + + + + + Behdad Esfahbod + + + + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.pc.in b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.pc.in new file mode 100644 index 00000000000..e92319e156c --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/harfbuzz.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: harfbuzz +Description: Text shaping library +Version: @VERSION@ + +Libs: -L${libdir} -lharfbuzz +Cflags: -I${includedir}/harfbuzz diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/Makefile.am b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/Makefile.am new file mode 100644 index 00000000000..558ce08ead9 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/Makefile.am @@ -0,0 +1,321 @@ +# Process this file with automake to produce Makefile.in + +NULL = +SUBDIRS = +DIST_SUBDIRS = +BUILT_SOURCES = +EXTRA_DIST = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = +DISTCHECK_CONFIGURE_FLAGS = --enable-introspection + +# The following warning options are useful for debugging: -Wpadded +#AM_CXXFLAGS = + +lib_LTLIBRARIES = libharfbuzz.la + +HBCFLAGS = +HBLIBS = +HBSOURCES = \ + hb-atomic-private.hh \ + hb-blob.cc \ + hb-buffer-private.hh \ + hb-buffer.cc \ + hb-cache-private.hh \ + hb-common.cc \ + hb-fallback-shape.cc \ + hb-font-private.hh \ + hb-font.cc \ + hb-mutex-private.hh \ + hb-object-private.hh \ + hb-open-file-private.hh \ + hb-open-type-private.hh \ + hb-ot-head-table.hh \ + hb-ot-hhea-table.hh \ + hb-ot-hmtx-table.hh \ + hb-ot-maxp-table.hh \ + hb-ot-name-table.hh \ + hb-ot-tag.cc \ + hb-private.hh \ + hb-set-private.hh \ + hb-set.cc \ + hb-shape.cc \ + hb-shape-plan-private.hh \ + hb-shape-plan.cc \ + hb-shaper-list.hh \ + hb-shaper-impl-private.hh \ + hb-shaper-private.hh \ + hb-shaper.cc \ + hb-tt-font.cc \ + hb-unicode-private.hh \ + hb-unicode.cc \ + hb-utf-private.hh \ + hb-warning.cc \ + $(NULL) +HBHEADERS = \ + hb.h \ + hb-blob.h \ + hb-buffer.h \ + hb-common.h \ + hb-font.h \ + hb-set.h \ + hb-shape.h \ + hb-shape-plan.h \ + hb-unicode.h \ + hb-version.h \ + $(NULL) + +if HAVE_OT +HBSOURCES += \ + hb-ot-layout.cc \ + hb-ot-layout-common-private.hh \ + hb-ot-layout-gdef-table.hh \ + hb-ot-layout-gpos-table.hh \ + hb-ot-layout-gsubgpos-private.hh \ + hb-ot-layout-gsub-table.hh \ + hb-ot-layout-private.hh \ + hb-ot-map.cc \ + hb-ot-map-private.hh \ + hb-ot-shape.cc \ + hb-ot-shape-complex-arabic.cc \ + hb-ot-shape-complex-arabic-fallback.hh \ + hb-ot-shape-complex-arabic-table.hh \ + hb-ot-shape-complex-default.cc \ + hb-ot-shape-complex-indic.cc \ + hb-ot-shape-complex-indic-machine.hh \ + hb-ot-shape-complex-indic-private.hh \ + hb-ot-shape-complex-indic-table.hh \ + hb-ot-shape-complex-thai.cc \ + hb-ot-shape-complex-private.hh \ + hb-ot-shape-normalize-private.hh \ + hb-ot-shape-normalize.cc \ + hb-ot-shape-fallback-private.hh \ + hb-ot-shape-fallback.cc \ + hb-ot-shape-private.hh \ + $(NULL) +HBHEADERS += \ + hb-ot.h \ + hb-ot-layout.h \ + hb-ot-tag.h \ + $(NULL) +endif + +if HAVE_PTHREAD +HBCFLAGS += $(PTHREAD_CFLAGS) +HBLIBS += $(PTHREAD_LIBS) +endif + +if HAVE_GLIB +HBCFLAGS += $(GLIB_CFLAGS) +HBLIBS += $(GLIB_LIBS) +HBSOURCES += hb-glib.cc +HBHEADERS += hb-glib.h +endif + +if HAVE_GOBJECT +HBCFLAGS += $(GOBJECT_CFLAGS) +HBLIBS += $(GOBJECT_LIBS) +HBSOURCES += hb-gobject-structs.cc +nodist_HBSOURCES = hb-gobject-enums.cc +HBHEADERS += hb-gobject.h +BUILT_SOURCES += hb-gobject-enums.cc +EXTRA_DIST += hb-gobject-enums.cc.tmpl +DISTCLEANFILES += hb-gobject-enums.cc + +hb-gobject-enums.cc: hb-gobject-enums.cc.tmpl $(HBHEADERS) + $(AM_V_GEN) $(GLIB_MKENUMS) --template $^ > "$@.tmp" && \ + mv "$@.tmp" "$@" || ( $(RM) "@.tmp" && false ) +endif + +if HAVE_ICU +HBCFLAGS += $(ICU_CFLAGS) +HBLIBS += $(ICU_LIBS) +HBSOURCES += hb-icu.cc +HBHEADERS += hb-icu.h +endif + +if HAVE_FREETYPE +HBCFLAGS += $(FREETYPE_CFLAGS) +HBLIBS += $(FREETYPE_LIBS) +HBSOURCES += hb-ft.cc +HBHEADERS += hb-ft.h +endif + +if HAVE_GRAPHITE2 +HBCFLAGS += $(GRAPHITE2_CFLAGS) +HBLIBS += $(GRAPHITE2_LIBS) +HBSOURCES += hb-graphite2.cc +HBHEADERS += hb-graphite2.h +endif + +if HAVE_UNISCRIBE +HBCFLAGS += $(UNISCRIBE_CFLAGS) +HBLIBS += $(UNISCRIBE_LIBS) +HBSOURCES += hb-uniscribe.cc +HBHEADERS += hb-uniscribe.h +endif + +if HAVE_CORETEXT +HBCFLAGS += $(CORETEXT_CFLAGS) +HBLIBS += $(CORETEXT_LIBS) +HBSOURCES += hb-coretext.cc +HBHEADERS += hb-coretext.h +endif + +if HAVE_HB_OLD +SUBDIRS += hb-old +HBCFLAGS += -I$(srcdir)/hb-old +HBLIBS += hb-old/libhb-old.la +HBSOURCES += hb-old.cc +endif +DIST_SUBDIRS += hb-old + +if HAVE_ICU_LE +SUBDIRS += hb-icu-le +HBCFLAGS += -I$(srcdir)/hb-icu-le +HBLIBS += hb-icu-le/libhb-icu-le.la +HBSOURCES += hb-icu-le.cc +endif +DIST_SUBDIRS += hb-icu-le + +if HAVE_UCDN +SUBDIRS += hb-ucdn +HBCFLAGS += -I$(srcdir)/hb-ucdn +HBLIBS += hb-ucdn/libhb-ucdn.la +HBSOURCES += hb-ucdn.cc +endif +DIST_SUBDIRS += hb-ucdn + + +# Put the library together + +if OS_WIN32 +export_symbols = -export-symbols harfbuzz.def +harfbuzz_def_dependency = harfbuzz.def +libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS) +else +if HAVE_ICU +libharfbuzz_la_LINK = $(CXXLINK) $(libharfbuzz_la_LDFLAGS) +else +# Use a C linker, not C++; Don't link to libstdc++ +libharfbuzz_la_LINK = $(LINK) $(libharfbuzz_la_LDFLAGS) +endif +endif + +libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS) +nodist_libharfbuzz_la_SOURCES = $(nodist_HBSOURCES) +libharfbuzz_la_CPPFLAGS = $(HBCFLAGS) +libharfbuzz_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HB_LIBTOOL_VERSION_INFO) $(export_symbols) -no-undefined +libharfbuzz_la_LIBADD = $(HBLIBS) +EXTRA_libharfbuzz_la_DEPENDENCIES = $(harfbuzz_def_dependency) +pkginclude_HEADERS = $(HBHEADERS) +nodist_pkginclude_HEADERS = hb-version.h + +CLEANFILES += harfbuzz.def +harfbuzz.def: $(HBHEADERS) + $(AM_V_GEN) (echo EXPORTS; \ + (cat $^ || echo 'hb_ERROR ()' ) | \ + $(EGREP) '^hb_.* \(' | \ + sed -e 's/ (.*//' | \ + LANG=C sort; \ + echo LIBRARY libharfbuzz-$(HB_VERSION_MAJOR).dll; \ + ) >"$@.tmp" + @ ! grep -q hb_ERROR "$@.tmp" && mv "$@.tmp" "$@" || ($(RM) "$@"; false) + + +GENERATORS = \ + gen-arabic-table.py \ + gen-indic-table.py \ + $(NULL) + +EXTRA_DIST += $(GENERATORS) + +unicode-tables: arabic-table indic-table + +indic-table: gen-indic-table.py IndicSyllabicCategory.txt IndicMatraCategory.txt Blocks.txt + $(AM_V_GEN) $(builddir)/$^ > hb-ot-shape-complex-indic-table.hh.tmp && \ + mv hb-ot-shape-complex-indic-table.hh.tmp $(srcdir)/hb-ot-shape-complex-indic-table.hh || \ + ($(RM) hb-ot-shape-complex-indic-table.hh.tmp; false) + +arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt + $(AM_V_GEN) $(builddir)/$^ > hb-ot-shape-complex-arabic-table.hh.tmp && \ + mv hb-ot-shape-complex-arabic-table.hh.tmp $(srcdir)/hb-ot-shape-complex-arabic-table.hh || \ + ($(RM) hb-ot-shape-complex-arabic-table.hh.tmp; false) + + +.PHONY: unicode-tables arabic-table indic-table + +EXTRA_DIST += hb-ot-shape-complex-indic-machine.rl +$(srcdir)/hb-ot-shape-complex-indic-machine.hh: hb-ot-shape-complex-indic-machine.rl + $(AM_V_GEN)$(top_srcdir)/missing --run ragel -e -F1 -o "$@.tmp" "$<" && \ + mv "$@.tmp" "$@" || ( $(RM) "$@.tmp" && false ) + +noinst_PROGRAMS = main test test-would-substitute test-size-params +bin_PROGRAMS = + +main_SOURCES = main.cc +main_CPPFLAGS = $(HBCFLAGS) +main_LDADD = libharfbuzz.la $(HBLIBS) + +test_SOURCES = test.cc +test_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS) +test_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS) + +test_would_substitute_SOURCES = test-would-substitute.cc +test_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS) +test_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS) + +test_size_params_SOURCES = test-size-params.cc +test_size_params_CPPFLAGS = $(HBCFLAGS) +test_size_params_LDADD = libharfbuzz.la $(HBLIBS) + +dist_check_SCRIPTS = \ + check-c-linkage-decls.sh \ + check-header-guards.sh \ + check-exported-symbols.sh \ + check-includes.sh \ + check-internal-symbols.sh \ + $(NULL) + +if HAVE_ICU +else +dist_check_SCRIPTS += check-libstdc++.sh +endif + +if HAVE_ICU_LE +else +dist_check_SCRIPTS += check-static-inits.sh +endif + +TESTS = $(dist_check_SCRIPTS) +TESTS_ENVIRONMENT = \ + srcdir="$(srcdir)" \ + MAKE="$(MAKE) $(AM_MAKEFLAGS)" \ + HBSOURCES="$(HBSOURCES)" \ + HBHEADERS="$(HBHEADERS)" \ + $(NULL) + +#-include $(INTROSPECTION_MAKEFILE) +#INTROSPECTION_GIRS = hb-1.0.gir +#INTROSPECTION_SCANNER_ARGS = -I$(srcdir) -n hb --identifier-prefix=hb_ +#INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) +# +#if HAVE_INTROSPECTION +# +#hb-1.0.gir: libharfbuzz.la +#hb_1_0_gir_INCLUDES = GObject-2.0 +#hb_1_0_gir_CFLAGS = $(INCLUDES) $(HBCFLAGS) -DHB_H -DHB_H_IN -DHB_OT_H -DHB_OT_H_IN +#hb_1_0_gir_LIBS = libharfbuzz.la +#hb_1_0_gir_FILES = $(HBHEADERS) +# +#girdir = $(datadir)/gir-1.0 +#gir_DATA = $(INTROSPECTION_GIRS) +# +#typelibdir = $(libdir)/girepository-1.0 +#typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) +# +#CLEANFILES += $(gir_DATA) $(typelib_DATA) +#endif + +-include $(top_srcdir)/git.mk diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-c-linkage-decls.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-c-linkage-decls.sh new file mode 100755 index 00000000000..44cdfa0f23c --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-c-linkage-decls.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +stat=0 + +test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'` +test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb*.h'` + + +for x in $HBHEADERS; do + test -f $srcdir/$x && x=$srcdir/$x + if ! grep -q HB_BEGIN_DECLS "$x" || ! grep -q HB_END_DECLS "$x"; then + echo "Ouch, file $x does not have HB_BEGIN_DECLS / HB_END_DECLS, but it should" + stat=1 + fi +done +for x in $HBSOURCES; do + test -f $srcdir/$x && x=$srcdir/$x + if grep -q HB_BEGIN_DECLS "$x" || grep -q HB_END_DECLS "$x"; then + echo "Ouch, file $x has HB_BEGIN_DECLS / HB_END_DECLS, but it shouldn't" + stat=1 + fi +done + +exit $stat diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-exported-symbols.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-exported-symbols.sh new file mode 100755 index 00000000000..6f0bf7fd823 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-exported-symbols.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +test -z "$MAKE" && MAKE=make +stat=0 + +if which nm 2>/dev/null >/dev/null; then + : +else + echo "check-exported-symbols.sh: 'nm' not found; skipping test" + exit 77 +fi + +defs="harfbuzz.def" +$MAKE $defs > /dev/null +tested=false +for def in $defs; do + lib=`echo "$def" | sed 's/[.]def$//;s@.*/@@'` + so=.libs/lib${lib}.so + if test -f "$so"; then + echo "Checking that $so has the same symbol list as $def" + { + echo EXPORTS + nm "$so" | grep ' [BCDGINRSTVW] ' | grep -v ' T _fini\>\| T _init\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>' | cut -d' ' -f3 + stat=1 + # cheat: copy the last line from the def file! + tail -n1 "$def" + } | diff "$def" - >&2 || stat=1 + tested=true + fi +done +if ! $tested; then + echo "check-exported-symbols.sh: libharfbuzz shared library not found; skipping test" + exit 77 +fi + +exit $stat diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-header-guards.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-header-guards.sh new file mode 100755 index 00000000000..af9fa7fc24e --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-header-guards.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +stat=0 + +test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'` +test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'` + + +for x in $HBHEADERS $HBSOURCES; do + test -f "$srcdir/$x" && x="$srcdir/$x" + echo "$x" | grep '[^h]$' -q && continue; + xx=`echo "$x" | sed 's@.*/@@'` + tag=`echo "$xx" | tr 'a-z.-' 'A-Z_'` + lines=`grep "\<$tag\>" "$x" | wc -l | sed 's/[ ]*//g'` + if test "x$lines" != x3; then + echo "Ouch, header file $x does not have correct preprocessor guards" + stat=1 + fi +done + +exit $stat diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-includes.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-includes.sh new file mode 100755 index 00000000000..79323a74fb2 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-includes.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +stat=0 + +test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'` +test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'` + + +cd "$srcdir" + + +echo 'Checking that public header files #include "hb-common.h" or "hb.h" first (or none)' + +for x in $HBHEADERS; do + grep '#.*\' "$x" /dev/null | head -n 1 +done | +grep -v '"hb-common[.]h"' | +grep -v '"hb[.]h"' | +grep -v 'hb-common[.]h:' | +grep -v 'hb[.]h:' | +grep . >&2 && stat=1 + + +echo 'Checking that source files #include "hb-*private.hh" first (or none)' + +for x in $HBSOURCES; do + grep '#.*\' "$x" /dev/null | head -n 1 +done | +grep -v '"hb-.*private[.]hh"' | +grep -v 'hb-private[.]hh:' | +grep . >&2 && stat=1 + + +echo 'Checking that there is no #include ' +grep '#.*\.*<.*hb' $HBHEADERS $HBSOURCES >&2 && stat=1 + + +exit $stat diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-internal-symbols.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-internal-symbols.sh new file mode 100755 index 00000000000..a8fdc537dd7 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-internal-symbols.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +stat=0 + + +if which nm 2>/dev/null >/dev/null; then + : +else + echo "check-internal-symbols.sh: 'nm' not found; skipping test" + exit 77 +fi + +tested=false +for suffix in .so; do + so=`echo .libs/libharfbuzz$suffix` + if test -f "$so"; then + echo "Checking that we are not exposing internal symbols" + if nm "$so" | grep ' [BCDGINRSTVW] ' | grep -v ' T _fini\>\| T _init\>\| T hb_\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>'; then + echo "Ouch, internal symbols exposed" + stat=1 + fi + tested=true + fi +done +if ! $tested; then + echo "check-internal-symbols.sh: libharfbuzz shared library not found; skipping test" + exit 77 +fi + +exit $stat diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-libstdc++.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-libstdc++.sh new file mode 100755 index 00000000000..e7e0e295e1a --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-libstdc++.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +stat=0 + + +if which ldd 2>/dev/null >/dev/null; then + : +else + echo "check-libstdc++.sh: 'ldd' not found; skipping test" + exit 77 +fi + +tested=false +for suffix in so dylib; do + so=.libs/libharfbuzz.$suffix + if test -f "$so"; then + echo "Checking that we are not linking to libstdc++" + if ldd $so | grep 'libstdc[+][+]'; then + echo "Ouch, linked to libstdc++" + stat=1 + fi + tested=true + fi +done +if ! $tested; then + echo "check-libstdc++.sh: libharfbuzz shared library not found; skipping test" + exit 77 +fi + +exit $stat diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-static-inits.sh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-static-inits.sh new file mode 100755 index 00000000000..bb0a7ff630d --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/check-static-inits.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +stat=0 + + +if which objdump 2>/dev/null >/dev/null; then + : +else + echo "check-static-inits.sh: 'objdump' not found; skipping test" + exit 77 +fi + +OBJS=.libs/*.o +if test "x`echo $OBJS`" = "x$OBJS" 2>/dev/null >/dev/null; then + echo "check-static-inits.sh: object files not found; skipping test" + exit 77 +fi + +echo "Checking that no object file has static initializers" +for obj in $OBJS; do + if objdump -t "$obj" | grep '[.]ctors'; then + echo "Ouch, $obj has static initializers" + stat=1 + fi +done + +echo "Checking that no object file has lazy static C++ constructors/destructors or other such stuff" +for obj in $OBJS; do + if objdump -t "$obj" | grep '__c'; then + echo "Ouch, $obj has lazy static C++ constructors/destructors or other such stuff" + stat=1 + fi +done + +exit $stat diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-arabic-table.py b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-arabic-table.py new file mode 100755 index 00000000000..da5a4fcbf5c --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-arabic-table.py @@ -0,0 +1,197 @@ +#!/usr/bin/python + +import sys +import os.path + +if len (sys.argv) != 3: + print >>sys.stderr, "usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt" + sys.exit (1) + +files = [file (x) for x in sys.argv[1:]] + +headers = [[files[0].readline (), files[0].readline ()]] +headers.append (["UnicodeData.txt does not have a header."]) +while files[0].readline ().find ('##################') < 0: + pass + + +def print_joining_table(f): + + print + print "static const uint8_t joining_table[] =" + print "{" + + min_u = 0x110000 + max_u = 0 + num = 0 + last = -1 + block = '' + for line in f: + + if line[0] == '#': + if line.find (" characters"): + block = line[2:].strip () + continue + + fields = [x.strip () for x in line.split (';')] + if len (fields) == 1: + continue + + u = int (fields[0], 16) + if u == 0x200C or u == 0x200D: + continue + if u < last: + raise Exception ("Input data character not sorted", u) + min_u = min (min_u, u) + max_u = max (max_u, u) + num += 1 + + if block: + print "\n /* %s */\n" % block + block = '' + + if last != -1: + last += 1 + while last < u: + print " JOINING_TYPE_X, /* %04X */" % last + last += 1 + else: + last = u + + if fields[3] in ["ALAPH", "DALATH RISH"]: + value = "JOINING_GROUP_" + fields[3].replace(' ', '_') + else: + value = "JOINING_TYPE_" + fields[2] + print " %s, /* %s */" % (value, '; '.join(fields)) + + print + print "};" + print + print "#define JOINING_TABLE_FIRST 0x%04X" % min_u + print "#define JOINING_TABLE_LAST 0x%04X" % max_u + print + + occupancy = num * 100 / (max_u - min_u + 1) + # Maintain at least 40% occupancy in the table */ + if occupancy < 40: + raise Exception ("Table too sparse, please investigate: ", occupancy) + +def print_shaping_table(f): + + shapes = {} + ligatures = {} + names = {} + for line in f: + + fields = [x.strip () for x in line.split (';')] + if fields[5][0:1] != '<': + continue + + items = fields[5].split (' ') + shape, items = items[0][1:-1], tuple (int (x, 16) for x in items[1:]) + + if not shape in ['initial', 'medial', 'isolated', 'final']: + continue + + c = int (fields[0], 16) + if len (items) != 1: + # We only care about lam-alef ligatures + if len (items) != 2 or items[0] != 0x0644 or items[1] not in [0x0622, 0x0623, 0x0625, 0x0627]: + continue + + # Save ligature + names[c] = fields[1] + if items not in ligatures: + ligatures[items] = {} + ligatures[items][shape] = c + pass + else: + # Save shape + if items[0] not in names: + names[items[0]] = fields[1] + else: + names[items[0]] = os.path.commonprefix ([names[items[0]], fields[1]]).strip () + if items[0] not in shapes: + shapes[items[0]] = {} + shapes[items[0]][shape] = c + + print + print "static const uint16_t shaping_table[][4] =" + print "{" + + keys = shapes.keys () + min_u, max_u = min (keys), max (keys) + for u in range (min_u, max_u + 1): + s = [shapes[u][shape] if u in shapes and shape in shapes[u] else 0 + for shape in ['initial', 'medial', 'final', 'isolated']] + value = ', '.join ("0x%04X" % c for c in s) + print " {%s}, /* U+%04X %s */" % (value, u, names[u] if u in names else "") + + print "};" + print + print "#define SHAPING_TABLE_FIRST 0x%04X" % min_u + print "#define SHAPING_TABLE_LAST 0x%04X" % max_u + print + + ligas = {} + for pair in ligatures.keys (): + for shape in ligatures[pair]: + c = ligatures[pair][shape] + if shape == 'isolated': + liga = (shapes[pair[0]]['initial'], shapes[pair[1]]['final']) + elif shape == 'final': + liga = (shapes[pair[0]]['medial'], shapes[pair[1]]['final']) + else: + raise Exception ("Unexpected shape", shape) + if liga[0] not in ligas: + ligas[liga[0]] = [] + ligas[liga[0]].append ((liga[1], c)) + max_i = max (len (ligas[l]) for l in ligas) + print + print "static const struct ligature_set_t {" + print " uint16_t first;" + print " struct ligature_pairs_t {" + print " uint16_t second;" + print " uint16_t ligature;" + print " } ligatures[%d];" % max_i + print "} ligature_table[] =" + print "{" + keys = ligas.keys () + keys.sort () + for first in keys: + + print " { 0x%04X, {" % (first) + for liga in ligas[first]: + print " { 0x%04X, 0x%04X }, /* %s */" % (liga[0], liga[1], names[liga[1]]) + print " }}," + + print "};" + print + + + +print "/* == Start of generated table == */" +print "/*" +print " * The following table is generated by running:" +print " *" +print " * ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt" +print " *" +print " * on files with these headers:" +print " *" +for h in headers: + for l in h: + print " * %s" % (l.strip()) +print " */" +print +print "#ifndef HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH" +print "#define HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH" +print + +print_joining_table (files[0]) +print_shaping_table (files[1]) + +print +print "#endif /* HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH */" +print +print "/* == End of generated table == */" + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-indic-table.py b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-indic-table.py new file mode 100755 index 00000000000..94aa2ab0728 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/gen-indic-table.py @@ -0,0 +1,211 @@ +#!/usr/bin/python + +import sys + +if len (sys.argv) != 4: + print >>sys.stderr, "usage: ./gen-indic-table.py IndicSyllabicCategory.txt IndicMatraCategory.txt Blocks.txt" + sys.exit (1) + +files = [file (x) for x in sys.argv[1:]] + +headers = [[f.readline () for i in range (2)] for f in files] + +blocks = {} +data = [{} for f in files] +values = [{} for f in files] +for i, f in enumerate (files): + for line in f: + + j = line.find ('#') + if j >= 0: + line = line[:j] + + fields = [x.strip () for x in line.split (';')] + if len (fields) == 1: + continue + + uu = fields[0].split ('..') + start = int (uu[0], 16) + if len (uu) == 1: + end = start + else: + end = int (uu[1], 16) + + t = fields[1] + + for u in range (start, end + 1): + data[i][u] = t + values[i][t] = values[i].get (t, 0) + 1 + + if i == 2: + blocks[t] = (start, end) + +# Merge data into one dict: +defaults = ('Other', 'Not_Applicable', 'No_Block') +for i,v in enumerate (defaults): + values[i][v] = values[i].get (v, 0) + 1 +combined = {} +for i,d in enumerate (data): + for u,v in d.items (): + if i == 2 and not u in combined: + continue + if not u in combined: + combined[u] = list (defaults) + combined[u][i] = v +data = combined +del combined +num = len (data) + +# Move the outliers NO-BREAK SPACE and DOTTED CIRCLE out +singles = {} +for u in [0x00A0, 0x25CC]: + singles[u] = data[u] + del data[u] + +print "/* == Start of generated table == */" +print "/*" +print " * The following table is generated by running:" +print " *" +print " * ./gen-indic-table.py IndicSyllabicCategory.txt IndicMatraCategory.txt Blocks.txt" +print " *" +print " * on files with these headers:" +print " *" +for h in headers: + for l in h: + print " * %s" % (l.strip()) +print " */" +print +print "#ifndef HB_OT_SHAPE_COMPLEX_INDIC_TABLE_HH" +print "#define HB_OT_SHAPE_COMPLEX_INDIC_TABLE_HH" +print + +# Shorten values +short = [{ + "Bindu": 'Bi', + "Visarga": 'Vs', + "Vowel": 'Vo', + "Vowel_Dependent": 'M', + "Other": 'x', +},{ + "Not_Applicable": 'x', +}] +all_shorts = [[],[]] + +# Add some of the values, to make them more readable, and to avoid duplicates + + +for i in range (2): + for v,s in short[i].items (): + all_shorts[i].append (s) + +what = ["INDIC_SYLLABIC_CATEGORY", "INDIC_MATRA_CATEGORY"] +what_short = ["ISC", "IMC"] +for i in range (2): + print + vv = values[i].keys () + vv.sort () + for v in vv: + v_no_and = v.replace ('_And_', '_') + if v in short[i]: + s = short[i][v] + else: + s = ''.join ([c for c in v_no_and if ord ('A') <= ord (c) <= ord ('Z')]) + if s in all_shorts[i]: + raise Exception ("Duplicate short value alias", v, s) + all_shorts[i].append (s) + short[i][v] = s + print "#define %s_%s %s_%s %s/* %3d chars; %s */" % \ + (what_short[i], s, what[i], v.upper (), \ + ' '* ((48-1 - len (what[i]) - 1 - len (v)) / 8), \ + values[i][v], v) +print +print "#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)" +print +print + +total = 0 +used = 0 +def print_block (block, start, end, data): + print + print + print " /* %s (%04X..%04X) */" % (block, start, end) + num = 0 + for u in range (start, end+1): + if u % 8 == 0: + print + print " /* %04X */" % u, + if u in data: + num += 1 + d = data.get (u, defaults) + sys.stdout.write ("%9s" % ("_(%s,%s)," % (short[0][d[0]], short[1][d[1]]))) + + global total, used + total += end - start + 1 + used += num + +uu = data.keys () +uu.sort () + +last = -1 +num = 0 +offset = 0 +starts = [] +ends = [] +print "static const INDIC_TABLE_ELEMENT_TYPE indic_table[] = {" +for u in uu: + if u <= last: + continue + block = data[u][2] + (start, end) = blocks[block] + + if start != last + 1: + if start - last <= 33: + print_block ("FILLER", last+1, start-1, data) + last = start-1 + else: + if last >= 0: + ends.append (last + 1) + offset += ends[-1] - starts[-1] + print + print + print "#define indic_offset_0x%04x %d" % (start, offset) + starts.append (start) + + print_block (block, start, end, data) + last = end +ends.append (last + 1) +offset += ends[-1] - starts[-1] +print +print +print "#define indic_offset_total %d" % offset +print +occupancy = used * 100. / total +print "}; /* Table occupancy: %d%% */" % occupancy +print +print "static INDIC_TABLE_ELEMENT_TYPE" +print "get_indic_categories (hb_codepoint_t u)" +print "{" +for (start,end) in zip (starts, ends): + offset = "indic_offset_0x%04x" % start + print " if (0x%04X <= u && u <= 0x%04X) return indic_table[u - 0x%04X + %s];" % (start, end, start, offset) +for u,d in singles.items (): + print " if (unlikely (u == 0x%04X)) return _(%s,%s);" % (u, short[0][d[0]], short[1][d[1]]) +print " return _(x,x);" +print "}" +print +print "#undef _" +for i in range (2): + print + vv = values[i].keys () + vv.sort () + for v in vv: + print "#undef %s_%s" % \ + (what_short[i], short[i][v]) +print +print "#endif /* HB_OT_SHAPE_COMPLEX_INDIC_TABLE_HH */" +print +print "/* == End of generated table == */" + +# Maintain at least 30% occupancy in the table */ +if occupancy < 30: + raise Exception ("Table too sparse, please investigate: ", occupancy) diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-atomic-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-atomic-private.hh new file mode 100644 index 00000000000..67579cdd442 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-atomic-private.hh @@ -0,0 +1,124 @@ +/* + * Copyright © 2007 Chris Wilson + * Copyright © 2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Contributor(s): + * Chris Wilson + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_ATOMIC_PRIVATE_HH +#define HB_ATOMIC_PRIVATE_HH + +#include "hb-private.hh" + + +/* atomic_int */ + +/* We need external help for these */ + +#if 0 + + +#elif !defined(HB_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__) + +#define WIN32_LEAN_AND_MEAN +#include + +/* mingw32 does not have MemoryBarrier. + * MemoryBarrier may be defined as a macro or a function. + * Just make a failsafe version for ourselves. */ +#ifdef MemoryBarrier +#define HBMemoryBarrier MemoryBarrier +#else +static inline void HBMemoryBarrier (void) { + long dummy = 0; + InterlockedExchange (&dummy, 1); +} +#endif + +typedef LONG hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V)) + +#define hb_atomic_ptr_get(P) (HBMemoryBarrier (), (void *) *(P)) +#define hb_atomic_ptr_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) + + +#elif !defined(HB_NO_MT) && defined(__APPLE__) + +#include +#ifdef __MAC_OS_X_MIN_REQUIRED +#include +#elif defined(__IPHONE_OS_MIN_REQUIRED) +#include +#endif + +typedef int32_t hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V)) + +#define hb_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P)) +#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100) +#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P)) +#else +#if __ppc64__ || __x86_64__ +#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P)) +#else +#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P)) +#endif +#endif + + +#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) + +typedef int hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) __sync_fetch_and_add (&(AI), (V)) + +#define hb_atomic_ptr_get(P) (void *) (__sync_synchronize (), *(P)) +#define hb_atomic_ptr_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N)) + + +#elif !defined(HB_NO_MT) + +#define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */ +typedef volatile int hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V)) + +#define hb_atomic_ptr_get(P) ((void *) *(P)) +#define hb_atomic_ptr_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false) + + +#else /* HB_NO_MT */ + +typedef int hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V)) + +#define hb_atomic_ptr_get(P) ((void *) *(P)) +#define hb_atomic_ptr_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false) + +#endif + +/* TODO Add tracing. */ + +#endif /* HB_ATOMIC_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.cc new file mode 100644 index 00000000000..b6e696be322 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.cc @@ -0,0 +1,325 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +#include "hb-blob.h" +#include "hb-object-private.hh" + +#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ +#include +#endif /* HAVE_SYS_MMAN_H */ + +#include +#include + + + +#ifndef HB_DEBUG_BLOB +#define HB_DEBUG_BLOB (HB_DEBUG+0) +#endif + + +struct hb_blob_t { + hb_object_header_t header; + ASSERT_POD (); + + bool immutable; + + const char *data; + unsigned int length; + hb_memory_mode_t mode; + + void *user_data; + hb_destroy_func_t destroy; +}; + + +static bool _try_writable (hb_blob_t *blob); + +static void +_hb_blob_destroy_user_data (hb_blob_t *blob) +{ + if (blob->destroy) { + blob->destroy (blob->user_data); + blob->user_data = NULL; + blob->destroy = NULL; + } +} + +hb_blob_t * +hb_blob_create (const char *data, + unsigned int length, + hb_memory_mode_t mode, + void *user_data, + hb_destroy_func_t destroy) +{ + hb_blob_t *blob; + + if (!length || !(blob = hb_object_create ())) { + if (destroy) + destroy (user_data); + return hb_blob_get_empty (); + } + + blob->data = data; + blob->length = length; + blob->mode = mode; + + blob->user_data = user_data; + blob->destroy = destroy; + + if (blob->mode == HB_MEMORY_MODE_DUPLICATE) { + blob->mode = HB_MEMORY_MODE_READONLY; + if (!_try_writable (blob)) { + hb_blob_destroy (blob); + return hb_blob_get_empty (); + } + } + + return blob; +} + +hb_blob_t * +hb_blob_create_sub_blob (hb_blob_t *parent, + unsigned int offset, + unsigned int length) +{ + hb_blob_t *blob; + + if (!length || offset >= parent->length) + return hb_blob_get_empty (); + + hb_blob_make_immutable (parent); + + blob = hb_blob_create (parent->data + offset, + MIN (length, parent->length - offset), + parent->mode, + hb_blob_reference (parent), + (hb_destroy_func_t) hb_blob_destroy); + + return blob; +} + +hb_blob_t * +hb_blob_get_empty (void) +{ + static const hb_blob_t _hb_blob_nil = { + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + NULL, /* data */ + 0, /* length */ + HB_MEMORY_MODE_READONLY, /* mode */ + + NULL, /* user_data */ + NULL /* destroy */ + }; + + return const_cast (&_hb_blob_nil); +} + +hb_blob_t * +hb_blob_reference (hb_blob_t *blob) +{ + return hb_object_reference (blob); +} + +void +hb_blob_destroy (hb_blob_t *blob) +{ + if (!hb_object_destroy (blob)) return; + + _hb_blob_destroy_user_data (blob); + + free (blob); +} + +hb_bool_t +hb_blob_set_user_data (hb_blob_t *blob, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return hb_object_set_user_data (blob, key, data, destroy, replace); +} + +void * +hb_blob_get_user_data (hb_blob_t *blob, + hb_user_data_key_t *key) +{ + return hb_object_get_user_data (blob, key); +} + + +void +hb_blob_make_immutable (hb_blob_t *blob) +{ + if (hb_object_is_inert (blob)) + return; + + blob->immutable = true; +} + +hb_bool_t +hb_blob_is_immutable (hb_blob_t *blob) +{ + return blob->immutable; +} + + +unsigned int +hb_blob_get_length (hb_blob_t *blob) +{ + return blob->length; +} + +const char * +hb_blob_get_data (hb_blob_t *blob, unsigned int *length) +{ + if (length) + *length = blob->length; + + return blob->data; +} + +char * +hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) +{ + if (!_try_writable (blob)) { + if (length) + *length = 0; + + return NULL; + } + + if (length) + *length = blob->length; + + return const_cast (blob->data); +} + + +static hb_bool_t +_try_make_writable_inplace_unix (hb_blob_t *blob) +{ +#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT) + uintptr_t pagesize = -1, mask, length; + const char *addr; + +#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) + pagesize = (uintptr_t) sysconf (_SC_PAGE_SIZE); +#elif defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) + pagesize = (uintptr_t) sysconf (_SC_PAGESIZE); +#elif defined(HAVE_GETPAGESIZE) + pagesize = (uintptr_t) getpagesize (); +#endif + + if ((uintptr_t) -1L == pagesize) { + DEBUG_MSG_FUNC (BLOB, blob, "failed to get pagesize: %s", strerror (errno)); + return false; + } + DEBUG_MSG_FUNC (BLOB, blob, "pagesize is %lu", (unsigned long) pagesize); + + mask = ~(pagesize-1); + addr = (const char *) (((uintptr_t) blob->data) & mask); + length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr; + DEBUG_MSG_FUNC (BLOB, blob, + "calling mprotect on [%p..%p] (%lu bytes)", + addr, addr+length, (unsigned long) length); + if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) { + DEBUG_MSG_FUNC (BLOB, blob, "mprotect failed: %s", strerror (errno)); + return false; + } + + blob->mode = HB_MEMORY_MODE_WRITABLE; + + DEBUG_MSG_FUNC (BLOB, blob, + "successfully made [%p..%p] (%lu bytes) writable\n", + addr, addr+length, (unsigned long) length); + return true; +#else + return false; +#endif +} + +static bool +_try_writable_inplace (hb_blob_t *blob) +{ + DEBUG_MSG_FUNC (BLOB, blob, "making writable inplace\n"); + + if (_try_make_writable_inplace_unix (blob)) + return true; + + DEBUG_MSG_FUNC (BLOB, blob, "making writable -> FAILED\n"); + + /* Failed to make writable inplace, mark that */ + blob->mode = HB_MEMORY_MODE_READONLY; + return false; +} + +static bool +_try_writable (hb_blob_t *blob) +{ + if (blob->immutable) + return false; + + if (blob->mode == HB_MEMORY_MODE_WRITABLE) + return true; + + if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE && _try_writable_inplace (blob)) + return true; + + if (blob->mode == HB_MEMORY_MODE_WRITABLE) + return true; + + + DEBUG_MSG_FUNC (BLOB, blob, "current data is -> %p\n", blob->data); + + char *new_data; + + new_data = (char *) malloc (blob->length); + if (unlikely (!new_data)) + return false; + + DEBUG_MSG_FUNC (BLOB, blob, "dupped successfully -> %p\n", blob->data); + + memcpy (new_data, blob->data, blob->length); + _hb_blob_destroy_user_data (blob); + blob->mode = HB_MEMORY_MODE_WRITABLE; + blob->data = new_data; + blob->user_data = new_data; + blob->destroy = free; + + return true; +} + + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.h new file mode 100644 index 00000000000..1a93baa46dc --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-blob.h @@ -0,0 +1,101 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + */ + +#ifndef HB_H_IN +#error "Include instead." +#endif + +#ifndef HB_BLOB_H +#define HB_BLOB_H + +#include "hb-common.h" + +HB_BEGIN_DECLS + + +typedef enum { + HB_MEMORY_MODE_DUPLICATE, + HB_MEMORY_MODE_READONLY, + HB_MEMORY_MODE_WRITABLE, + HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE +} hb_memory_mode_t; + +typedef struct hb_blob_t hb_blob_t; + +hb_blob_t * +hb_blob_create (const char *data, + unsigned int length, + hb_memory_mode_t mode, + void *user_data, + hb_destroy_func_t destroy); + +hb_blob_t * +hb_blob_create_sub_blob (hb_blob_t *parent, + unsigned int offset, + unsigned int length); + +hb_blob_t * +hb_blob_get_empty (void); + +hb_blob_t * +hb_blob_reference (hb_blob_t *blob); + +void +hb_blob_destroy (hb_blob_t *blob); + +hb_bool_t +hb_blob_set_user_data (hb_blob_t *blob, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + + +void * +hb_blob_get_user_data (hb_blob_t *blob, + hb_user_data_key_t *key); + + +void +hb_blob_make_immutable (hb_blob_t *blob); + +hb_bool_t +hb_blob_is_immutable (hb_blob_t *blob); + + +unsigned int +hb_blob_get_length (hb_blob_t *blob); + +const char * +hb_blob_get_data (hb_blob_t *blob, unsigned int *length); + +char * +hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length); + + +HB_END_DECLS + +#endif /* HB_BLOB_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer-private.hh new file mode 100644 index 00000000000..13cf4bb0e9b --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer-private.hh @@ -0,0 +1,199 @@ +/* + * Copyright © 1998-2004 David Turner and Werner Lemberg + * Copyright © 2004,2007,2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Owen Taylor, Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_BUFFER_PRIVATE_HH +#define HB_BUFFER_PRIVATE_HH + +#include "hb-private.hh" +#include "hb-buffer.h" +#include "hb-object-private.hh" +#include "hb-unicode-private.hh" + + +ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); +ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); + + +/* + * hb_buffer_t + */ + +struct hb_buffer_t { + hb_object_header_t header; + ASSERT_POD (); + + /* Information about how the text in the buffer should be treated */ + + hb_unicode_funcs_t *unicode; /* Unicode functions */ + hb_segment_properties_t props; /* Script, language, direction */ + hb_buffer_flags_t flags; /* BOT / EOT / etc. */ + + /* Buffer contents */ + + hb_buffer_content_type_t content_type; + + bool in_error; /* Allocation failed */ + bool have_output; /* Whether we have an output buffer going on */ + bool have_positions; /* Whether we have positions */ + + unsigned int idx; /* Cursor into ->info and ->pos arrays */ + unsigned int len; /* Length of ->info and ->pos arrays */ + unsigned int out_len; /* Length of ->out array if have_output */ + + unsigned int allocated; /* Length of allocated arrays */ + hb_glyph_info_t *info; + hb_glyph_info_t *out_info; + hb_glyph_position_t *pos; + + inline hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; } + inline hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; } + + inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; } + inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; } + + inline hb_glyph_info_t &prev (void) { return out_info[out_len - 1]; } + inline hb_glyph_info_t prev (void) const { return info[out_len - 1]; } + + unsigned int serial; + + /* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ + uint8_t allocated_var_bytes[8]; + const char *allocated_var_owner[8]; + + /* Text before / after the main buffer contents. + * Always in Unicode, and ordered outward. + * Index 0 is for "pre-context", 1 for "post-context". */ + static const unsigned int CONTEXT_LENGTH = 5; + hb_codepoint_t context[2][CONTEXT_LENGTH]; + unsigned int context_len[2]; + + + /* Methods */ + + HB_INTERNAL void reset (void); + HB_INTERNAL void clear (void); + + inline unsigned int backtrack_len (void) const + { return have_output? out_len : idx; } + inline unsigned int next_serial (void) { return serial++; } + + HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const char *owner); + HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, const char *owner); + HB_INTERNAL void assert_var (unsigned int byte_i, unsigned int count, const char *owner); + HB_INTERNAL void deallocate_var_all (void); + + HB_INTERNAL void add (hb_codepoint_t codepoint, + unsigned int cluster); + + HB_INTERNAL void reverse_range (unsigned int start, unsigned int end); + HB_INTERNAL void reverse (void); + HB_INTERNAL void reverse_clusters (void); + HB_INTERNAL void guess_segment_properties (void); + + HB_INTERNAL void swap_buffers (void); + HB_INTERNAL void remove_output (void); + HB_INTERNAL void clear_output (void); + HB_INTERNAL void clear_positions (void); + + HB_INTERNAL void replace_glyphs (unsigned int num_in, + unsigned int num_out, + const hb_codepoint_t *glyph_data); + + HB_INTERNAL void replace_glyph (hb_codepoint_t glyph_index); + /* Makes a copy of the glyph at idx to output and replace glyph_index */ + HB_INTERNAL void output_glyph (hb_codepoint_t glyph_index); + HB_INTERNAL void output_info (hb_glyph_info_t &glyph_info); + /* Copies glyph at idx to output but doesn't advance idx */ + HB_INTERNAL void copy_glyph (void); + /* Copies glyph at idx to output and advance idx. + * If there's no output, just advance idx. */ + inline void + next_glyph (void) + { + if (have_output) + { + if (unlikely (out_info != info || out_len != idx)) { + if (unlikely (!make_room_for (1, 1))) return; + out_info[out_len] = info[idx]; + } + out_len++; + } + + idx++; + } + + /* Advance idx without copying to output. */ + inline void skip_glyph (void) { idx++; } + + inline void reset_masks (hb_mask_t mask) + { + for (unsigned int j = 0; j < len; j++) + info[j].mask = mask; + } + inline void add_masks (hb_mask_t mask) + { + for (unsigned int j = 0; j < len; j++) + info[j].mask |= mask; + } + HB_INTERNAL void set_masks (hb_mask_t value, + hb_mask_t mask, + unsigned int cluster_start, + unsigned int cluster_end); + + HB_INTERNAL void merge_clusters (unsigned int start, + unsigned int end); + HB_INTERNAL void merge_out_clusters (unsigned int start, + unsigned int end); + + /* Internal methods */ + HB_INTERNAL bool enlarge (unsigned int size); + + inline bool ensure (unsigned int size) + { return likely (size < allocated) ? true : enlarge (size); } + + HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out); + + HB_INTERNAL void *get_scratch_buffer (unsigned int *size); + + inline void clear_context (unsigned int side) { context_len[side] = 0; } +}; + + +#define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \ + b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ + sizeof (b->info[0].var), owner) +#define HB_BUFFER_ALLOCATE_VAR(b, var) \ + HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var) +#define HB_BUFFER_DEALLOCATE_VAR(b, var) \ + HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var (), #var) +#define HB_BUFFER_ASSERT_VAR(b, var) \ + HB_BUFFER_XALLOCATE_VAR (b, assert_var, var (), #var) + + +#endif /* HB_BUFFER_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.cc new file mode 100644 index 00000000000..4b644e40217 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.cc @@ -0,0 +1,1294 @@ +/* + * Copyright © 1998-2004 David Turner and Werner Lemberg + * Copyright © 2004,2007,2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Owen Taylor, Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-buffer-private.hh" +#include "hb-utf-private.hh" + + +#ifndef HB_DEBUG_BUFFER +#define HB_DEBUG_BUFFER (HB_DEBUG+0) +#endif + + +hb_bool_t +hb_segment_properties_equal (const hb_segment_properties_t *a, + const hb_segment_properties_t *b) +{ + return a->direction == b->direction && + a->script == b->script && + a->language == b->language && + a->reserved1 == b->reserved1 && + a->reserved2 == b->reserved2; + +} + +unsigned int +hb_segment_properties_hash (const hb_segment_properties_t *p) +{ + return (unsigned int) p->direction ^ + (unsigned int) p->script ^ + (intptr_t) (p->language); +} + + + +/* Here is how the buffer works internally: + * + * There are two info pointers: info and out_info. They always have + * the same allocated size, but different lengths. + * + * As an optimization, both info and out_info may point to the + * same piece of memory, which is owned by info. This remains the + * case as long as out_len doesn't exceed i at any time. + * In that case, swap_buffers() is no-op and the glyph operations operate + * mostly in-place. + * + * As soon as out_info gets longer than info, out_info is moved over + * to an alternate buffer (which we reuse the pos buffer for!), and its + * current contents (out_len entries) are copied to the new place. + * This should all remain transparent to the user. swap_buffers() then + * switches info and out_info. + */ + + + +/* Internal API */ + +bool +hb_buffer_t::enlarge (unsigned int size) +{ + if (unlikely (in_error)) + return false; + + unsigned int new_allocated = allocated; + hb_glyph_position_t *new_pos = NULL; + hb_glyph_info_t *new_info = NULL; + bool separate_out = out_info != info; + + if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) + goto done; + + while (size >= new_allocated) + new_allocated += (new_allocated >> 1) + 32; + + ASSERT_STATIC (sizeof (info[0]) == sizeof (pos[0])); + if (unlikely (_hb_unsigned_int_mul_overflows (new_allocated, sizeof (info[0])))) + goto done; + + new_pos = (hb_glyph_position_t *) realloc (pos, new_allocated * sizeof (pos[0])); + new_info = (hb_glyph_info_t *) realloc (info, new_allocated * sizeof (info[0])); + +done: + if (unlikely (!new_pos || !new_info)) + in_error = true; + + if (likely (new_pos)) + pos = new_pos; + + if (likely (new_info)) + info = new_info; + + out_info = separate_out ? (hb_glyph_info_t *) pos : info; + if (likely (!in_error)) + allocated = new_allocated; + + return likely (!in_error); +} + +bool +hb_buffer_t::make_room_for (unsigned int num_in, + unsigned int num_out) +{ + if (unlikely (!ensure (out_len + num_out))) return false; + + if (out_info == info && + out_len + num_out > idx + num_in) + { + assert (have_output); + + out_info = (hb_glyph_info_t *) pos; + memcpy (out_info, info, out_len * sizeof (out_info[0])); + } + + return true; +} + +void * +hb_buffer_t::get_scratch_buffer (unsigned int *size) +{ + have_output = false; + have_positions = false; + + out_len = 0; + out_info = info; + + *size = allocated * sizeof (pos[0]); + return pos; +} + + + +/* HarfBuzz-Internal API */ + +void +hb_buffer_t::reset (void) +{ + if (unlikely (hb_object_is_inert (this))) + return; + + hb_unicode_funcs_destroy (unicode); + unicode = hb_unicode_funcs_get_default (); + + clear (); +} + +void +hb_buffer_t::clear (void) +{ + if (unlikely (hb_object_is_inert (this))) + return; + + hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; + props = default_props; + flags = HB_BUFFER_FLAGS_DEFAULT; + + content_type = HB_BUFFER_CONTENT_TYPE_INVALID; + in_error = false; + have_output = false; + have_positions = false; + + idx = 0; + len = 0; + out_len = 0; + out_info = info; + + serial = 0; + memset (allocated_var_bytes, 0, sizeof allocated_var_bytes); + memset (allocated_var_owner, 0, sizeof allocated_var_owner); + + memset (context, 0, sizeof context); + memset (context_len, 0, sizeof context_len); +} + +void +hb_buffer_t::add (hb_codepoint_t codepoint, + unsigned int cluster) +{ + hb_glyph_info_t *glyph; + + if (unlikely (!ensure (len + 1))) return; + + glyph = &info[len]; + + memset (glyph, 0, sizeof (*glyph)); + glyph->codepoint = codepoint; + glyph->mask = 1; + glyph->cluster = cluster; + + len++; +} + +void +hb_buffer_t::remove_output (void) +{ + if (unlikely (hb_object_is_inert (this))) + return; + + have_output = false; + have_positions = false; + + out_len = 0; + out_info = info; +} + +void +hb_buffer_t::clear_output (void) +{ + if (unlikely (hb_object_is_inert (this))) + return; + + have_output = true; + have_positions = false; + + out_len = 0; + out_info = info; +} + +void +hb_buffer_t::clear_positions (void) +{ + if (unlikely (hb_object_is_inert (this))) + return; + + have_output = false; + have_positions = true; + + out_len = 0; + out_info = info; + + memset (pos, 0, sizeof (pos[0]) * len); +} + +void +hb_buffer_t::swap_buffers (void) +{ + if (unlikely (in_error)) return; + + assert (have_output); + have_output = false; + + if (out_info != info) + { + hb_glyph_info_t *tmp_string; + tmp_string = info; + info = out_info; + out_info = tmp_string; + pos = (hb_glyph_position_t *) out_info; + } + + unsigned int tmp; + tmp = len; + len = out_len; + out_len = tmp; + + idx = 0; +} + + +void +hb_buffer_t::replace_glyphs (unsigned int num_in, + unsigned int num_out, + const uint32_t *glyph_data) +{ + if (unlikely (!make_room_for (num_in, num_out))) return; + + merge_clusters (idx, idx + num_in); + + hb_glyph_info_t orig_info = info[idx]; + hb_glyph_info_t *pinfo = &out_info[out_len]; + for (unsigned int i = 0; i < num_out; i++) + { + *pinfo = orig_info; + pinfo->codepoint = glyph_data[i]; + pinfo++; + } + + idx += num_in; + out_len += num_out; +} + +void +hb_buffer_t::output_glyph (hb_codepoint_t glyph_index) +{ + if (unlikely (!make_room_for (0, 1))) return; + + out_info[out_len] = info[idx]; + out_info[out_len].codepoint = glyph_index; + + out_len++; +} + +void +hb_buffer_t::output_info (hb_glyph_info_t &glyph_info) +{ + if (unlikely (!make_room_for (0, 1))) return; + + out_info[out_len] = glyph_info; + + out_len++; +} + +void +hb_buffer_t::copy_glyph (void) +{ + if (unlikely (!make_room_for (0, 1))) return; + + out_info[out_len] = info[idx]; + + out_len++; +} + +void +hb_buffer_t::replace_glyph (hb_codepoint_t glyph_index) +{ + 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; + + idx++; + out_len++; +} + + +void +hb_buffer_t::set_masks (hb_mask_t value, + hb_mask_t mask, + unsigned int cluster_start, + unsigned int cluster_end) +{ + hb_mask_t not_mask = ~mask; + value &= mask; + + if (!mask) + return; + + if (cluster_start == 0 && cluster_end == (unsigned int)-1) { + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + info[i].mask = (info[i].mask & not_mask) | value; + return; + } + + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (cluster_start <= info[i].cluster && info[i].cluster < cluster_end) + info[i].mask = (info[i].mask & not_mask) | value; +} + +void +hb_buffer_t::reverse_range (unsigned int start, + unsigned int end) +{ + unsigned int i, j; + + if (start == end - 1) + return; + + for (i = start, j = end - 1; i < j; i++, j--) { + hb_glyph_info_t t; + + t = info[i]; + info[i] = info[j]; + info[j] = t; + } + + if (pos) { + for (i = start, j = end - 1; i < j; i++, j--) { + hb_glyph_position_t t; + + t = pos[i]; + pos[i] = pos[j]; + pos[j] = t; + } + } +} + +void +hb_buffer_t::reverse (void) +{ + if (unlikely (!len)) + return; + + reverse_range (0, len); +} + +void +hb_buffer_t::reverse_clusters (void) +{ + unsigned int i, start, count, last_cluster; + + if (unlikely (!len)) + return; + + reverse (); + + count = len; + start = 0; + last_cluster = info[0].cluster; + for (i = 1; i < count; i++) { + if (last_cluster != info[i].cluster) { + reverse_range (start, i); + start = i; + last_cluster = info[i].cluster; + } + } + reverse_range (start, i); +} + +void +hb_buffer_t::merge_clusters (unsigned int start, + unsigned int end) +{ + if (unlikely (end - start < 2)) + return; + + unsigned int cluster = info[start].cluster; + + for (unsigned int i = start + 1; i < end; i++) + cluster = MIN (cluster, info[i].cluster); + + /* Extend end */ + while (end < len && info[end - 1].cluster == info[end].cluster) + end++; + + /* Extend start */ + while (idx < start && info[start - 1].cluster == info[start].cluster) + start--; + + /* If we hit the start of buffer, continue in out-buffer. */ + if (idx == start) + for (unsigned i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--) + out_info[i - 1].cluster = cluster; + + for (unsigned int i = start; i < end; i++) + info[i].cluster = cluster; +} +void +hb_buffer_t::merge_out_clusters (unsigned int start, + unsigned int end) +{ + if (unlikely (end - start < 2)) + return; + + unsigned int cluster = out_info[start].cluster; + + for (unsigned int i = start + 1; i < end; i++) + cluster = MIN (cluster, out_info[i].cluster); + + /* Extend start */ + while (start && out_info[start - 1].cluster == out_info[start].cluster) + start--; + + /* Extend end */ + while (end < out_len && out_info[end - 1].cluster == out_info[end].cluster) + end++; + + /* If we hit the end of out-buffer, continue in buffer. */ + if (end == out_len) + for (unsigned i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++) + info[i].cluster = cluster; + + for (unsigned int i = start; i < end; i++) + out_info[i].cluster = cluster; +} + +void +hb_buffer_t::guess_segment_properties (void) +{ + assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || + (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); + + /* If script is set to INVALID, guess from buffer contents */ + if (props.script == HB_SCRIPT_INVALID) { + for (unsigned int i = 0; i < len; i++) { + hb_script_t script = unicode->script (info[i].codepoint); + if (likely (script != HB_SCRIPT_COMMON && + script != HB_SCRIPT_INHERITED && + script != HB_SCRIPT_UNKNOWN)) { + props.script = script; + break; + } + } + } + + /* If direction is set to INVALID, guess from script */ + if (props.direction == HB_DIRECTION_INVALID) { + props.direction = hb_script_get_horizontal_direction (props.script); + } + + /* If language is not set, use default language from locale */ + if (props.language == HB_LANGUAGE_INVALID) { + /* TODO get_default_for_script? using $LANGUAGE */ + props.language = hb_language_get_default (); + } +} + + +static inline void +dump_var_allocation (const hb_buffer_t *buffer) +{ + char buf[80]; + for (unsigned int i = 0; i < 8; i++) + buf[i] = '0' + buffer->allocated_var_bytes[7 - i]; + buf[8] = '\0'; + DEBUG_MSG (BUFFER, buffer, + "Current var allocation: %s", + buf); +} + +void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner) +{ + assert (byte_i < 8 && byte_i + count <= 8); + + if (DEBUG (BUFFER)) + dump_var_allocation (this); + DEBUG_MSG (BUFFER, this, + "Allocating var bytes %d..%d for %s", + byte_i, byte_i + count - 1, owner); + + for (unsigned int i = byte_i; i < byte_i + count; i++) { + assert (!allocated_var_bytes[i]); + allocated_var_bytes[i]++; + allocated_var_owner[i] = owner; + } +} + +void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner) +{ + if (DEBUG (BUFFER)) + dump_var_allocation (this); + + DEBUG_MSG (BUFFER, this, + "Deallocating var bytes %d..%d for %s", + byte_i, byte_i + count - 1, owner); + + assert (byte_i < 8 && byte_i + count <= 8); + for (unsigned int i = byte_i; i < byte_i + count; i++) { + assert (allocated_var_bytes[i]); + assert (0 == strcmp (allocated_var_owner[i], owner)); + allocated_var_bytes[i]--; + } +} + +void hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner) +{ + if (DEBUG (BUFFER)) + dump_var_allocation (this); + + DEBUG_MSG (BUFFER, this, + "Asserting var bytes %d..%d for %s", + byte_i, byte_i + count - 1, owner); + + assert (byte_i < 8 && byte_i + count <= 8); + for (unsigned int i = byte_i; i < byte_i + count; i++) { + assert (allocated_var_bytes[i]); + assert (0 == strcmp (allocated_var_owner[i], owner)); + } +} + +void hb_buffer_t::deallocate_var_all (void) +{ + memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); + memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); +} + +/* Public API */ + +hb_buffer_t * +hb_buffer_create (void) +{ + hb_buffer_t *buffer; + + if (!(buffer = hb_object_create ())) + return hb_buffer_get_empty (); + + buffer->reset (); + + return buffer; +} + +hb_buffer_t * +hb_buffer_get_empty (void) +{ + static const hb_buffer_t _hb_buffer_nil = { + HB_OBJECT_HEADER_STATIC, + + const_cast (&_hb_unicode_funcs_nil), + HB_SEGMENT_PROPERTIES_DEFAULT, + HB_BUFFER_FLAGS_DEFAULT, + + HB_BUFFER_CONTENT_TYPE_INVALID, + true, /* in_error */ + true, /* have_output */ + true /* have_positions */ + + /* Zero is good enough for everything else. */ + }; + + return const_cast (&_hb_buffer_nil); +} + +hb_buffer_t * +hb_buffer_reference (hb_buffer_t *buffer) +{ + return hb_object_reference (buffer); +} + +void +hb_buffer_destroy (hb_buffer_t *buffer) +{ + if (!hb_object_destroy (buffer)) return; + + hb_unicode_funcs_destroy (buffer->unicode); + + free (buffer->info); + free (buffer->pos); + + free (buffer); +} + +hb_bool_t +hb_buffer_set_user_data (hb_buffer_t *buffer, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return hb_object_set_user_data (buffer, key, data, destroy, replace); +} + +void * +hb_buffer_get_user_data (hb_buffer_t *buffer, + hb_user_data_key_t *key) +{ + return hb_object_get_user_data (buffer, key); +} + + +void +hb_buffer_set_content_type (hb_buffer_t *buffer, + hb_buffer_content_type_t content_type) +{ + buffer->content_type = content_type; +} + +hb_buffer_content_type_t +hb_buffer_get_content_type (hb_buffer_t *buffer) +{ + return buffer->content_type; +} + + +void +hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, + hb_unicode_funcs_t *unicode) +{ + if (unlikely (hb_object_is_inert (buffer))) + return; + + if (!unicode) + unicode = hb_unicode_funcs_get_default (); + + + hb_unicode_funcs_reference (unicode); + hb_unicode_funcs_destroy (buffer->unicode); + buffer->unicode = unicode; +} + +hb_unicode_funcs_t * +hb_buffer_get_unicode_funcs (hb_buffer_t *buffer) +{ + return buffer->unicode; +} + +void +hb_buffer_set_direction (hb_buffer_t *buffer, + hb_direction_t direction) + +{ + if (unlikely (hb_object_is_inert (buffer))) + return; + + buffer->props.direction = direction; +} + +hb_direction_t +hb_buffer_get_direction (hb_buffer_t *buffer) +{ + return buffer->props.direction; +} + +void +hb_buffer_set_script (hb_buffer_t *buffer, + hb_script_t script) +{ + if (unlikely (hb_object_is_inert (buffer))) + return; + + buffer->props.script = script; +} + +hb_script_t +hb_buffer_get_script (hb_buffer_t *buffer) +{ + return buffer->props.script; +} + +void +hb_buffer_set_language (hb_buffer_t *buffer, + hb_language_t language) +{ + if (unlikely (hb_object_is_inert (buffer))) + return; + + buffer->props.language = language; +} + +hb_language_t +hb_buffer_get_language (hb_buffer_t *buffer) +{ + return buffer->props.language; +} + +void +hb_buffer_set_segment_properties (hb_buffer_t *buffer, + const hb_segment_properties_t *props) +{ + if (unlikely (hb_object_is_inert (buffer))) + return; + + buffer->props = *props; +} + +void +hb_buffer_get_segment_properties (hb_buffer_t *buffer, + hb_segment_properties_t *props) +{ + *props = buffer->props; +} + + +void +hb_buffer_set_flags (hb_buffer_t *buffer, + hb_buffer_flags_t flags) +{ + if (unlikely (hb_object_is_inert (buffer))) + return; + + buffer->flags = flags; +} + +hb_buffer_flags_t +hb_buffer_get_flags (hb_buffer_t *buffer) +{ + return buffer->flags; +} + + +void +hb_buffer_reset (hb_buffer_t *buffer) +{ + buffer->reset (); +} + +void +hb_buffer_clear (hb_buffer_t *buffer) +{ + buffer->clear (); +} + +hb_bool_t +hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) +{ + return buffer->ensure (size); +} + +hb_bool_t +hb_buffer_allocation_successful (hb_buffer_t *buffer) +{ + return !buffer->in_error; +} + +void +hb_buffer_add (hb_buffer_t *buffer, + hb_codepoint_t codepoint, + unsigned int cluster) +{ + buffer->add (codepoint, cluster); + buffer->clear_context (1); +} + +hb_bool_t +hb_buffer_set_length (hb_buffer_t *buffer, + unsigned int length) +{ + if (unlikely (hb_object_is_inert (buffer))) + return length == 0; + + if (!buffer->ensure (length)) + return false; + + /* Wipe the new space */ + if (length > buffer->len) { + memset (buffer->info + buffer->len, 0, sizeof (buffer->info[0]) * (length - buffer->len)); + if (buffer->have_positions) + memset (buffer->pos + buffer->len, 0, sizeof (buffer->pos[0]) * (length - buffer->len)); + } + + buffer->len = length; + + if (!length) + buffer->clear_context (0); + buffer->clear_context (1); + + return true; +} + +unsigned int +hb_buffer_get_length (hb_buffer_t *buffer) +{ + return buffer->len; +} + +/* Return value valid as long as buffer not modified */ +hb_glyph_info_t * +hb_buffer_get_glyph_infos (hb_buffer_t *buffer, + unsigned int *length) +{ + if (length) + *length = buffer->len; + + return (hb_glyph_info_t *) buffer->info; +} + +/* Return value valid as long as buffer not modified */ +hb_glyph_position_t * +hb_buffer_get_glyph_positions (hb_buffer_t *buffer, + unsigned int *length) +{ + if (!buffer->have_positions) + buffer->clear_positions (); + + if (length) + *length = buffer->len; + + return (hb_glyph_position_t *) buffer->pos; +} + +void +hb_buffer_reverse (hb_buffer_t *buffer) +{ + buffer->reverse (); +} + +void +hb_buffer_reverse_clusters (hb_buffer_t *buffer) +{ + buffer->reverse_clusters (); +} + +void +hb_buffer_guess_segment_properties (hb_buffer_t *buffer) +{ + buffer->guess_segment_properties (); +} + +template +static inline void +hb_buffer_add_utf (hb_buffer_t *buffer, + const T *text, + int text_length, + unsigned int item_offset, + int item_length) +{ + assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || + (!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); + + if (unlikely (hb_object_is_inert (buffer))) + return; + + if (text_length == -1) + text_length = hb_utf_strlen (text); + + if (item_length == -1) + item_length = text_length - item_offset; + + buffer->ensure (buffer->len + item_length * sizeof (T) / 4); + + /* If buffer is empty and pre-context provided, install it. + * This check is written this way, to make sure people can + * provide pre-context in one add_utf() call, then provide + * text in a follow-up call. See: + * + * https://bugzilla.mozilla.org/show_bug.cgi?id=801410#c13 + */ + if (!buffer->len && item_offset > 0) + { + /* Add pre-context */ + buffer->clear_context (0); + const T *prev = text + item_offset; + const T *start = text; + while (start < prev && buffer->context_len[0] < buffer->CONTEXT_LENGTH) + { + hb_codepoint_t u; + prev = hb_utf_prev (prev, start, &u); + buffer->context[0][buffer->context_len[0]++] = u; + } + } + + const T *next = text + item_offset; + const T *end = next + item_length; + while (next < end) + { + hb_codepoint_t u; + const T *old_next = next; + next = hb_utf_next (next, end, &u); + buffer->add (u, old_next - (const T *) text); + } + + /* Add post-context */ + buffer->clear_context (1); + end = text + text_length; + while (next < end && buffer->context_len[1] < buffer->CONTEXT_LENGTH) + { + hb_codepoint_t u; + next = hb_utf_next (next, end, &u); + buffer->context[1][buffer->context_len[1]++] = u; + } + + buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; +} + +void +hb_buffer_add_utf8 (hb_buffer_t *buffer, + const char *text, + int text_length, + unsigned int item_offset, + int item_length) +{ + hb_buffer_add_utf (buffer, (const uint8_t *) text, text_length, item_offset, item_length); +} + +void +hb_buffer_add_utf16 (hb_buffer_t *buffer, + const uint16_t *text, + int text_length, + unsigned int item_offset, + int item_length) +{ + hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); +} + +void +hb_buffer_add_utf32 (hb_buffer_t *buffer, + const uint32_t *text, + int text_length, + unsigned int item_offset, + int item_length) +{ + hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); +} + + +static int +compare_info_codepoint (const hb_glyph_info_t *pa, + const hb_glyph_info_t *pb) +{ + return (int) pb->codepoint - (int) pa->codepoint; +} + +static inline void +normalize_glyphs_cluster (hb_buffer_t *buffer, + unsigned int start, + unsigned int end, + bool backward) +{ + hb_glyph_position_t *pos = buffer->pos; + + /* Total cluster advance */ + hb_position_t total_x_advance = 0, total_y_advance = 0; + for (unsigned int i = start; i < end; i++) + { + total_x_advance += pos[i].x_advance; + total_y_advance += pos[i].y_advance; + } + + hb_position_t x_advance = 0, y_advance = 0; + for (unsigned int i = start; i < end; i++) + { + pos[i].x_offset += x_advance; + pos[i].y_offset += y_advance; + + x_advance += pos[i].x_advance; + y_advance += pos[i].y_advance; + + pos[i].x_advance = 0; + pos[i].y_advance = 0; + } + + if (backward) + { + /* Transfer all cluster advance to the last glyph. */ + pos[end - 1].x_advance = total_x_advance; + pos[end - 1].y_advance = total_y_advance; + + hb_bubble_sort (buffer->info + start, end - start - 1, compare_info_codepoint, buffer->pos + start); + } else { + /* Transfer all cluster advance to the first glyph. */ + pos[start].x_advance += total_x_advance; + pos[start].y_advance += total_y_advance; + for (unsigned int i = start + 1; i < end; i++) { + pos[i].x_offset -= total_x_advance; + pos[i].y_offset -= total_y_advance; + } + hb_bubble_sort (buffer->info + start + 1, end - start - 1, compare_info_codepoint, buffer->pos + start + 1); + } +} + +void +hb_buffer_normalize_glyphs (hb_buffer_t *buffer) +{ + assert (buffer->have_positions); + assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); + + bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); + + unsigned int count = buffer->len; + if (unlikely (!count)) return; + hb_glyph_info_t *info = buffer->info; + + unsigned int start = 0; + unsigned int end; + for (end = start + 1; end < count; end++) + if (info[start].cluster != info[end].cluster) { + normalize_glyphs_cluster (buffer, start, end, backward); + start = end; + } + normalize_glyphs_cluster (buffer, start, end, backward); +} + + +/* + * Serialize + */ + +static const char *serialize_formats[] = { + "text", + "json", + NULL +}; + +const char ** +hb_buffer_serialize_list_formats (void) +{ + return serialize_formats; +} + +hb_buffer_serialize_format_t +hb_buffer_serialize_format_from_string (const char *str, int len) +{ + /* Upper-case it. */ + return (hb_buffer_serialize_format_t) (hb_tag_from_string (str, len) & ~0x20202020); +} + +const char * +hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format) +{ + switch (format) + { + case HB_BUFFER_SERIALIZE_FORMAT_TEXT: return serialize_formats[0]; + case HB_BUFFER_SERIALIZE_FORMAT_JSON: return serialize_formats[1]; + default: + case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return NULL; + } +} + +static unsigned int +_hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer, + unsigned int start, + unsigned int end, + char *buf, + unsigned int buf_size, + unsigned int *buf_consumed, + hb_font_t *font, + hb_buffer_serialize_flags_t flags) +{ + hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL); + hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, NULL); + + *buf_consumed = 0; + for (unsigned int i = start; i < end; i++) + { + char b[1024]; + char *p = b; + + /* In the following code, we know b is large enough that no overflow can happen. */ + +#define APPEND(s) HB_STMT_START { strcpy (p, s); p += strlen (s); } HB_STMT_END + + if (i) + *p++ = ','; + + *p++ = '{'; + + APPEND ("\"g\":"); + if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES)) + { + char g[128]; + hb_font_glyph_to_string (font, info[i].codepoint, g, sizeof (g)); + *p++ = '"'; + for (char *q = g; *q; q++) { + if (*q == '"') + *p++ = '\\'; + *p++ = *q; + } + *p++ = '"'; + } + else + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint); + + if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) { + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster); + } + + if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS)) + { + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"dx\":%d,\"dy\":%d", + pos[i].x_offset, pos[i].y_offset); + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"ax\":%d,\"ay\":%d", + pos[i].x_advance, pos[i].y_advance); + } + + *p++ = '}'; + + if (buf_size > (p - b)) + { + unsigned int l = p - b; + memcpy (buf, b, l); + buf += l; + buf_size -= l; + *buf_consumed += l; + *buf = '\0'; + } else + return i - start; + } + + return end - start; +} + +static unsigned int +_hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer, + unsigned int start, + unsigned int end, + char *buf, + unsigned int buf_size, + unsigned int *buf_consumed, + hb_font_t *font, + hb_buffer_serialize_flags_t flags) +{ + hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL); + hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, NULL); + hb_direction_t direction = hb_buffer_get_direction (buffer); + + *buf_consumed = 0; + for (unsigned int i = start; i < end; i++) + { + char b[1024]; + char *p = b; + + /* In the following code, we know b is large enough that no overflow can happen. */ + + if (i) + *p++ = '|'; + + if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES)) + { + hb_font_glyph_to_string (font, info[i].codepoint, p, 128); + p += strlen (p); + } + else + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint); + + if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) { + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster); + } + + if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS)) + { + if (pos[i].x_offset || pos[i].y_offset) + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", pos[i].x_offset, pos[i].y_offset); + + *p++ = '+'; + if (HB_DIRECTION_IS_HORIZONTAL (direction) || pos[i].x_advance) + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance); + if (HB_DIRECTION_IS_VERTICAL (direction) || pos->y_advance) + p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance); + } + + if (buf_size > (p - b)) + { + unsigned int l = p - b; + memcpy (buf, b, l); + buf += l; + buf_size -= l; + *buf_consumed += l; + *buf = '\0'; + } else + return i - start; + } + + return end - start; +} + +/* Returns number of items, starting at start, that were serialized. */ +unsigned int +hb_buffer_serialize_glyphs (hb_buffer_t *buffer, + unsigned int start, + unsigned int end, + char *buf, + unsigned int buf_size, + unsigned int *buf_consumed, + hb_font_t *font, /* May be NULL */ + hb_buffer_serialize_format_t format, + hb_buffer_serialize_flags_t flags) +{ + assert (start <= end && end <= buffer->len); + + *buf_consumed = 0; + + assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) || + buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); + + if (unlikely (start == end)) + return 0; + + if (!font) + font = hb_font_get_empty (); + + switch (format) + { + case HB_BUFFER_SERIALIZE_FORMAT_TEXT: + return _hb_buffer_serialize_glyphs_text (buffer, start, end, + buf, buf_size, buf_consumed, + font, flags); + + case HB_BUFFER_SERIALIZE_FORMAT_JSON: + return _hb_buffer_serialize_glyphs_json (buffer, start, end, + buf, buf_size, buf_consumed, + font, flags); + + default: + case HB_BUFFER_SERIALIZE_FORMAT_INVALID: + return 0; + + } +} + +hb_bool_t +hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, + const char *buf, + unsigned int buf_len, + unsigned int *buf_consumed, + hb_font_t *font, /* May be NULL */ + hb_buffer_serialize_format_t format) +{ + return false; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.h new file mode 100644 index 00000000000..48ec4a527ad --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-buffer.h @@ -0,0 +1,323 @@ +/* + * Copyright © 1998-2004 David Turner and Werner Lemberg + * Copyright © 2004,2007,2009 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Owen Taylor, Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_H_IN +#error "Include instead." +#endif + +#ifndef HB_BUFFER_H +#define HB_BUFFER_H + +#include "hb-common.h" +#include "hb-unicode.h" +#include "hb-font.h" + +HB_BEGIN_DECLS + + +typedef struct hb_glyph_info_t { + hb_codepoint_t codepoint; + hb_mask_t mask; + uint32_t cluster; + + /*< private >*/ + hb_var_int_t var1; + hb_var_int_t var2; +} hb_glyph_info_t; + +typedef struct hb_glyph_position_t { + hb_position_t x_advance; + hb_position_t y_advance; + hb_position_t x_offset; + hb_position_t y_offset; + + /*< private >*/ + hb_var_int_t var; +} hb_glyph_position_t; + + +typedef struct hb_segment_properties_t { + hb_direction_t direction; + hb_script_t script; + hb_language_t language; + /*< private >*/ + void *reserved1; + void *reserved2; +} hb_segment_properties_t; + +#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ + HB_SCRIPT_INVALID, \ + HB_LANGUAGE_INVALID, \ + NULL, \ + NULL} + +hb_bool_t +hb_segment_properties_equal (const hb_segment_properties_t *a, + const hb_segment_properties_t *b); + +unsigned int +hb_segment_properties_hash (const hb_segment_properties_t *p); + + + +/* + * hb_buffer_t + */ + +typedef struct hb_buffer_t hb_buffer_t; + +hb_buffer_t * +hb_buffer_create (void); + +hb_buffer_t * +hb_buffer_get_empty (void); + +hb_buffer_t * +hb_buffer_reference (hb_buffer_t *buffer); + +void +hb_buffer_destroy (hb_buffer_t *buffer); + +hb_bool_t +hb_buffer_set_user_data (hb_buffer_t *buffer, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + +void * +hb_buffer_get_user_data (hb_buffer_t *buffer, + hb_user_data_key_t *key); + + +typedef enum { + HB_BUFFER_CONTENT_TYPE_INVALID = 0, + HB_BUFFER_CONTENT_TYPE_UNICODE, + HB_BUFFER_CONTENT_TYPE_GLYPHS +} hb_buffer_content_type_t; + +void +hb_buffer_set_content_type (hb_buffer_t *buffer, + hb_buffer_content_type_t content_type); + +hb_buffer_content_type_t +hb_buffer_get_content_type (hb_buffer_t *buffer); + + +void +hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, + hb_unicode_funcs_t *unicode_funcs); + +hb_unicode_funcs_t * +hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); + +void +hb_buffer_set_direction (hb_buffer_t *buffer, + hb_direction_t direction); + +hb_direction_t +hb_buffer_get_direction (hb_buffer_t *buffer); + +void +hb_buffer_set_script (hb_buffer_t *buffer, + hb_script_t script); + +hb_script_t +hb_buffer_get_script (hb_buffer_t *buffer); + +void +hb_buffer_set_language (hb_buffer_t *buffer, + hb_language_t language); + + +hb_language_t +hb_buffer_get_language (hb_buffer_t *buffer); + +void +hb_buffer_set_segment_properties (hb_buffer_t *buffer, + const hb_segment_properties_t *props); + +void +hb_buffer_get_segment_properties (hb_buffer_t *buffer, + hb_segment_properties_t *props); + +void +hb_buffer_guess_segment_properties (hb_buffer_t *buffer); + + +typedef enum { + HB_BUFFER_FLAGS_DEFAULT = 0x00000000, + HB_BUFFER_FLAG_BOT = 0x00000001, /* Beginning-of-text */ + HB_BUFFER_FLAG_EOT = 0x00000002, /* End-of-text */ + HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004 +} hb_buffer_flags_t; + +void +hb_buffer_set_flags (hb_buffer_t *buffer, + hb_buffer_flags_t flags); + +hb_buffer_flags_t +hb_buffer_get_flags (hb_buffer_t *buffer); + + +/* Resets the buffer. Afterwards it's as if it was just created, + * except that it has a larger buffer allocated perhaps... */ +void +hb_buffer_reset (hb_buffer_t *buffer); + +/* Like reset, but does NOT clear unicode_funcs. */ +void +hb_buffer_clear (hb_buffer_t *buffer); + +/* Returns false if allocation failed */ +hb_bool_t +hb_buffer_pre_allocate (hb_buffer_t *buffer, + unsigned int size); + + +/* Returns false if allocation has failed before */ +hb_bool_t +hb_buffer_allocation_successful (hb_buffer_t *buffer); + +void +hb_buffer_reverse (hb_buffer_t *buffer); + +void +hb_buffer_reverse_clusters (hb_buffer_t *buffer); + + +/* Filling the buffer in */ + +void +hb_buffer_add (hb_buffer_t *buffer, + hb_codepoint_t codepoint, + unsigned int cluster); + +void +hb_buffer_add_utf8 (hb_buffer_t *buffer, + const char *text, + int text_length, + unsigned int item_offset, + int item_length); + +void +hb_buffer_add_utf16 (hb_buffer_t *buffer, + const uint16_t *text, + int text_length, + unsigned int item_offset, + int item_length); + +void +hb_buffer_add_utf32 (hb_buffer_t *buffer, + const uint32_t *text, + int text_length, + unsigned int item_offset, + int item_length); + + +/* Clears any new items added at the end */ +hb_bool_t +hb_buffer_set_length (hb_buffer_t *buffer, + unsigned int length); + +/* Return value valid as long as buffer not modified */ +unsigned int +hb_buffer_get_length (hb_buffer_t *buffer); + +/* Getting glyphs out of the buffer */ + +/* Return value valid as long as buffer not modified */ +hb_glyph_info_t * +hb_buffer_get_glyph_infos (hb_buffer_t *buffer, + unsigned int *length); + +/* Return value valid as long as buffer not modified */ +hb_glyph_position_t * +hb_buffer_get_glyph_positions (hb_buffer_t *buffer, + unsigned int *length); + + +/* Reorders a glyph buffer to have canonical in-cluster glyph order / position. + * The resulting clusters should behave identical to pre-reordering clusters. + * NOTE: This has nothing to do with Unicode normalization. */ +void +hb_buffer_normalize_glyphs (hb_buffer_t *buffer); + + +/* + * Serialize + */ + +typedef enum { + HB_BUFFER_SERIALIZE_FLAGS_DEFAULT = 0x00000000, + HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001, + HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002, + HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004 +} hb_buffer_serialize_flags_t; + +typedef enum { + HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), + HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), + HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE +} hb_buffer_serialize_format_t; + +/* len=-1 means str is NUL-terminated. */ +hb_buffer_serialize_format_t +hb_buffer_serialize_format_from_string (const char *str, int len); + +const char * +hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); + +const char ** +hb_buffer_serialize_list_formats (void); + +/* Returns number of items, starting at start, that were serialized. */ +unsigned int +hb_buffer_serialize_glyphs (hb_buffer_t *buffer, + unsigned int start, + unsigned int end, + char *buf, + unsigned int buf_size, + unsigned int *buf_consumed, + hb_font_t *font, /* May be NULL */ + hb_buffer_serialize_format_t format, + hb_buffer_serialize_flags_t flags); + +hb_bool_t +hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, + const char *buf, + unsigned int buf_len, + unsigned int *buf_consumed, + hb_font_t *font, /* May be NULL */ + hb_buffer_serialize_format_t format); + + +HB_END_DECLS + +#endif /* HB_BUFFER_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-cache-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-cache-private.hh new file mode 100644 index 00000000000..19b70b7e395 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-cache-private.hh @@ -0,0 +1,74 @@ +/* + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_CACHE_PRIVATE_HH +#define HB_CACHE_PRIVATE_HH + +#include "hb-private.hh" + + +/* Implements a lock-free cache for int->int functions. */ + +template +struct hb_cache_t +{ + ASSERT_STATIC (key_bits >= cache_bits); + ASSERT_STATIC (key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int)); + + inline void clear (void) + { + memset (values, 255, sizeof (values)); + } + + inline bool get (unsigned int key, unsigned int *value) + { + unsigned int k = key & ((1<> value_bits) != (key >> cache_bits)) + return false; + *value = v & ((1<> key_bits) || (value >> value_bits))) + return false; /* Overflows */ + unsigned int k = key & ((1<>cache_bits)< hb_cmap_cache_t; +typedef hb_cache_t<16, 24, 8> hb_advance_cache_t; + + +#endif /* HB_CACHE_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.cc new file mode 100644 index 00000000000..9422555cfbc --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.cc @@ -0,0 +1,418 @@ +/* + * Copyright © 2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +#include "hb-version.h" + +#include "hb-mutex-private.hh" +#include "hb-object-private.hh" + +#include + + + +/* hb_tag_t */ + +hb_tag_t +hb_tag_from_string (const char *s, int len) +{ + char tag[4]; + unsigned int i; + + if (!s || !len || !*s) + return HB_TAG_NONE; + + if (len < 0 || len > 4) + len = 4; + for (i = 0; i < (unsigned) len && s[i]; i++) + tag[i] = s[i]; + for (; i < 4; i++) + tag[i] = ' '; + + return HB_TAG_CHAR4 (tag); +} + +void +hb_tag_to_string (hb_tag_t tag, char *buf) +{ + buf[0] = (char) (uint8_t) (tag >> 24); + buf[1] = (char) (uint8_t) (tag >> 16); + buf[2] = (char) (uint8_t) (tag >> 8); + buf[3] = (char) (uint8_t) (tag >> 0); +} + + +/* hb_direction_t */ + +const char direction_strings[][4] = { + "ltr", + "rtl", + "ttb", + "btt" +}; + +hb_direction_t +hb_direction_from_string (const char *str, int len) +{ + if (unlikely (!str || !len || !*str)) + return HB_DIRECTION_INVALID; + + /* Lets match loosely: just match the first letter, such that + * all of "ltr", "left-to-right", etc work! + */ + char c = TOLOWER (str[0]); + for (unsigned int i = 0; i < ARRAY_LENGTH (direction_strings); i++) + if (c == direction_strings[i][0]) + return (hb_direction_t) (HB_DIRECTION_LTR + i); + + return HB_DIRECTION_INVALID; +} + +const char * +hb_direction_to_string (hb_direction_t direction) +{ + if (likely ((unsigned int) (direction - HB_DIRECTION_LTR) + < ARRAY_LENGTH (direction_strings))) + return direction_strings[direction - HB_DIRECTION_LTR]; + + return "invalid"; +} + + +/* hb_language_t */ + +struct hb_language_impl_t { + const char s[1]; +}; + +static const char canon_map[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0, + '-', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, '-', + 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, 0 +}; + +static hb_bool_t +lang_equal (hb_language_t v1, + const void *v2) +{ + const unsigned char *p1 = (const unsigned char *) v1; + const unsigned char *p2 = (const unsigned char *) v2; + + while (*p1 && *p1 == canon_map[*p2]) + p1++, p2++; + + return *p1 == canon_map[*p2]; +} + +#if 0 +static unsigned int +lang_hash (const void *key) +{ + const unsigned char *p = key; + unsigned int h = 0; + while (canon_map[*p]) + { + h = (h << 5) - h + canon_map[*p]; + p++; + } + + return h; +} +#endif + + +struct hb_language_item_t { + + struct hb_language_item_t *next; + hb_language_t lang; + + inline bool operator == (const char *s) const { + return lang_equal (lang, s); + } + + inline hb_language_item_t & operator = (const char *s) { + lang = (hb_language_t) strdup (s); + for (unsigned char *p = (unsigned char *) lang; *p; p++) + *p = canon_map[*p]; + + return *this; + } + + void finish (void) { free (lang); } +}; + + +/* Thread-safe lock-free language list */ + +static hb_language_item_t *langs; + +static +void free_langs (void) +{ + while (langs) { + hb_language_item_t *next = langs->next; + langs->finish (); + free (langs); + langs = next; + } +} + +static hb_language_item_t * +lang_find_or_insert (const char *key) +{ +retry: + hb_language_item_t *first_lang = (hb_language_item_t *) hb_atomic_ptr_get (&langs); + + for (hb_language_item_t *lang = first_lang; lang; lang = lang->next) + if (*lang == key) + return lang; + + /* Not found; allocate one. */ + hb_language_item_t *lang = (hb_language_item_t *) calloc (1, sizeof (hb_language_item_t)); + if (unlikely (!lang)) + return NULL; + lang->next = first_lang; + *lang = key; + + if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) { + free (lang); + goto retry; + } + +#ifdef HAVE_ATEXIT + if (!first_lang) + atexit (free_langs); /* First person registers atexit() callback. */ +#endif + + return lang; +} + + +hb_language_t +hb_language_from_string (const char *str, int len) +{ + if (!str || !len || !*str) + return HB_LANGUAGE_INVALID; + + char strbuf[32]; + if (len >= 0) { + len = MIN (len, (int) sizeof (strbuf) - 1); + str = (char *) memcpy (strbuf, str, len); + strbuf[len] = '\0'; + } + + hb_language_item_t *item = lang_find_or_insert (str); + + return likely (item) ? item->lang : HB_LANGUAGE_INVALID; +} + +const char * +hb_language_to_string (hb_language_t language) +{ + /* This is actually NULL-safe! */ + return language->s; +} + +hb_language_t +hb_language_get_default (void) +{ + static hb_language_t default_language = HB_LANGUAGE_INVALID; + + hb_language_t language = (hb_language_t) hb_atomic_ptr_get (&default_language); + if (unlikely (language == HB_LANGUAGE_INVALID)) { + language = hb_language_from_string (setlocale (LC_CTYPE, NULL), -1); + hb_atomic_ptr_cmpexch (&default_language, HB_LANGUAGE_INVALID, language); + } + + return default_language; +} + + +/* hb_script_t */ + +hb_script_t +hb_script_from_iso15924_tag (hb_tag_t tag) +{ + if (unlikely (tag == HB_TAG_NONE)) + return HB_SCRIPT_INVALID; + + /* Be lenient, adjust case (one capital letter followed by three small letters) */ + tag = (tag & 0xDFDFDFDF) | 0x00202020; + + switch (tag) { + + /* These graduated from the 'Q' private-area codes, but + * the old code is still aliased by Unicode, and the Qaai + * one in use by ICU. */ + case HB_TAG('Q','a','a','i'): return HB_SCRIPT_INHERITED; + case HB_TAG('Q','a','a','c'): return HB_SCRIPT_COPTIC; + + /* Script variants from http://unicode.org/iso15924/ */ + case HB_TAG('C','y','r','s'): return HB_SCRIPT_CYRILLIC; + case HB_TAG('L','a','t','f'): return HB_SCRIPT_LATIN; + case HB_TAG('L','a','t','g'): return HB_SCRIPT_LATIN; + case HB_TAG('S','y','r','e'): return HB_SCRIPT_SYRIAC; + case HB_TAG('S','y','r','j'): return HB_SCRIPT_SYRIAC; + case HB_TAG('S','y','r','n'): return HB_SCRIPT_SYRIAC; + } + + /* If it looks right, just use the tag as a script */ + if (((uint32_t) tag & 0xE0E0E0E0) == 0x40606060) + return (hb_script_t) tag; + + /* Otherwise, return unknown */ + return HB_SCRIPT_UNKNOWN; +} + +hb_script_t +hb_script_from_string (const char *s, int len) +{ + return hb_script_from_iso15924_tag (hb_tag_from_string (s, len)); +} + +hb_tag_t +hb_script_to_iso15924_tag (hb_script_t script) +{ + return (hb_tag_t) script; +} + +hb_direction_t +hb_script_get_horizontal_direction (hb_script_t script) +{ + /* http://goo.gl/x9ilM */ + switch ((hb_tag_t) script) + { + /* Unicode-1.1 additions */ + case HB_SCRIPT_ARABIC: + case HB_SCRIPT_HEBREW: + + /* Unicode-3.0 additions */ + case HB_SCRIPT_SYRIAC: + case HB_SCRIPT_THAANA: + + /* Unicode-4.0 additions */ + case HB_SCRIPT_CYPRIOT: + + /* Unicode-4.1 additions */ + case HB_SCRIPT_KHAROSHTHI: + + /* Unicode-5.0 additions */ + case HB_SCRIPT_PHOENICIAN: + case HB_SCRIPT_NKO: + + /* Unicode-5.1 additions */ + case HB_SCRIPT_LYDIAN: + + /* Unicode-5.2 additions */ + case HB_SCRIPT_AVESTAN: + case HB_SCRIPT_IMPERIAL_ARAMAIC: + case HB_SCRIPT_INSCRIPTIONAL_PAHLAVI: + case HB_SCRIPT_INSCRIPTIONAL_PARTHIAN: + case HB_SCRIPT_OLD_SOUTH_ARABIAN: + case HB_SCRIPT_OLD_TURKIC: + case HB_SCRIPT_SAMARITAN: + + /* Unicode-6.0 additions */ + case HB_SCRIPT_MANDAIC: + + /* Unicode-6.1 additions */ + case HB_SCRIPT_MEROITIC_CURSIVE: + case HB_SCRIPT_MEROITIC_HIEROGLYPHS: + + return HB_DIRECTION_RTL; + } + + return HB_DIRECTION_LTR; +} + + +/* hb_user_data_array_t */ + +bool +hb_user_data_array_t::set (hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + if (!key) + return false; + + if (replace) { + if (!data && !destroy) { + items.remove (key, lock); + return true; + } + } + hb_user_data_item_t item = {key, data, destroy}; + bool ret = !!items.replace_or_insert (item, lock, replace); + + return ret; +} + +void * +hb_user_data_array_t::get (hb_user_data_key_t *key) +{ + hb_user_data_item_t item = {NULL }; + + return items.find (key, &item, lock) ? item.data : NULL; +} + + +/* hb_version */ + +void +hb_version (unsigned int *major, + unsigned int *minor, + unsigned int *micro) +{ + *major = HB_VERSION_MAJOR; + *minor = HB_VERSION_MINOR; + *micro = HB_VERSION_MICRO; +} + +const char * +hb_version_string (void) +{ + return HB_VERSION_STRING; +} + +hb_bool_t +hb_version_check (unsigned int major, + unsigned int minor, + unsigned int micro) +{ + return HB_VERSION_CHECK (major, minor, micro); +} + + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.h new file mode 100644 index 00000000000..cc221d33be9 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-common.h @@ -0,0 +1,317 @@ +/* + * Copyright © 2007,2008,2009 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_H_IN +#error "Include instead." +#endif + +#ifndef HB_COMMON_H +#define HB_COMMON_H + +#ifndef HB_BEGIN_DECLS +# ifdef __cplusplus +# define HB_BEGIN_DECLS extern "C" { +# define HB_END_DECLS } +# else /* !__cplusplus */ +# define HB_BEGIN_DECLS +# define HB_END_DECLS +# endif /* !__cplusplus */ +#endif + +#if !defined (HB_DONT_DEFINE_STDINT) + +#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || \ + defined (_sgi) || defined (__sun) || defined (sun) || \ + defined (__digital__) || defined (__HP_cc) +# include +#elif defined (_AIX) +# include +/* VS 2010 (_MSC_VER 1600) has stdint.h */ +#elif defined (_MSC_VER) && _MSC_VER < 1600 +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +# include +#endif + +#endif + +HB_BEGIN_DECLS + + +typedef int hb_bool_t; + +typedef uint32_t hb_codepoint_t; +typedef int32_t hb_position_t; +typedef uint32_t hb_mask_t; + +typedef union _hb_var_int_t { + uint32_t u32; + int32_t i32; + uint16_t u16[2]; + int16_t i16[2]; + uint8_t u8[4]; + int8_t i8[4]; +} hb_var_int_t; + + +/* hb_tag_t */ + +typedef uint32_t hb_tag_t; + +#define HB_TAG(a,b,c,d) ((hb_tag_t)((((uint8_t)(a))<<24)|(((uint8_t)(b))<<16)|(((uint8_t)(c))<<8)|((uint8_t)(d)))) +#define HB_UNTAG(tag) ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag)) + +#define HB_TAG_NONE HB_TAG(0,0,0,0) + +/* len=-1 means str is NUL-terminated. */ +hb_tag_t +hb_tag_from_string (const char *str, int len); + +/* buf should have 4 bytes. */ +void +hb_tag_to_string (hb_tag_t tag, char *buf); + + +/* hb_direction_t */ + +typedef enum { + HB_DIRECTION_INVALID = 0, + HB_DIRECTION_LTR = 4, + HB_DIRECTION_RTL, + HB_DIRECTION_TTB, + HB_DIRECTION_BTT +} hb_direction_t; + +/* len=-1 means str is NUL-terminated */ +hb_direction_t +hb_direction_from_string (const char *str, int len); + +const char * +hb_direction_to_string (hb_direction_t direction); + +#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4) +#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6) +#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4) +#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5) +#define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4) +#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) /* Direction must be valid */ + + +/* hb_language_t */ + +typedef struct hb_language_impl_t *hb_language_t; + +/* len=-1 means str is NUL-terminated */ +hb_language_t +hb_language_from_string (const char *str, int len); + +const char * +hb_language_to_string (hb_language_t language); + +#define HB_LANGUAGE_INVALID ((hb_language_t) NULL) + +hb_language_t +hb_language_get_default (void); + + +/* hb_script_t */ + +/* http://unicode.org/iso15924/ */ +/* http://goo.gl/x9ilM */ +/* Unicode Character Database property: Script (sc) */ +typedef enum +{ + /* Unicode-1.1 additions */ + HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'), + HB_SCRIPT_ARABIC = HB_TAG ('A','r','a','b'), + HB_SCRIPT_ARMENIAN = HB_TAG ('A','r','m','n'), + HB_SCRIPT_BENGALI = HB_TAG ('B','e','n','g'), + HB_SCRIPT_BOPOMOFO = HB_TAG ('B','o','p','o'), + HB_SCRIPT_CANADIAN_ABORIGINAL = HB_TAG ('C','a','n','s'), + HB_SCRIPT_CHEROKEE = HB_TAG ('C','h','e','r'), + HB_SCRIPT_COPTIC = HB_TAG ('C','o','p','t'), + HB_SCRIPT_CYRILLIC = HB_TAG ('C','y','r','l'), + HB_SCRIPT_DEVANAGARI = HB_TAG ('D','e','v','a'), + HB_SCRIPT_GEORGIAN = HB_TAG ('G','e','o','r'), + HB_SCRIPT_GREEK = HB_TAG ('G','r','e','k'), + HB_SCRIPT_GUJARATI = HB_TAG ('G','u','j','r'), + HB_SCRIPT_GURMUKHI = HB_TAG ('G','u','r','u'), + HB_SCRIPT_HANGUL = HB_TAG ('H','a','n','g'), + HB_SCRIPT_HAN = HB_TAG ('H','a','n','i'), + HB_SCRIPT_HEBREW = HB_TAG ('H','e','b','r'), + HB_SCRIPT_HIRAGANA = HB_TAG ('H','i','r','a'), + HB_SCRIPT_INHERITED = HB_TAG ('Z','i','n','h'), + HB_SCRIPT_KANNADA = HB_TAG ('K','n','d','a'), + HB_SCRIPT_KATAKANA = HB_TAG ('K','a','n','a'), + HB_SCRIPT_LAO = HB_TAG ('L','a','o','o'), + HB_SCRIPT_LATIN = HB_TAG ('L','a','t','n'), + HB_SCRIPT_MALAYALAM = HB_TAG ('M','l','y','m'), + HB_SCRIPT_MONGOLIAN = HB_TAG ('M','o','n','g'), + HB_SCRIPT_OGHAM = HB_TAG ('O','g','a','m'), + HB_SCRIPT_ORIYA = HB_TAG ('O','r','y','a'), + HB_SCRIPT_RUNIC = HB_TAG ('R','u','n','r'), + HB_SCRIPT_SYRIAC = HB_TAG ('S','y','r','c'), + HB_SCRIPT_TAMIL = HB_TAG ('T','a','m','l'), + HB_SCRIPT_TELUGU = HB_TAG ('T','e','l','u'), + HB_SCRIPT_THAI = HB_TAG ('T','h','a','i'), + HB_SCRIPT_YI = HB_TAG ('Y','i','i','i'), + + /* Unicode-2.0 additions */ + HB_SCRIPT_TIBETAN = HB_TAG ('T','i','b','t'), + + /* Unicode-3.0 additions */ + HB_SCRIPT_ETHIOPIC = HB_TAG ('E','t','h','i'), + HB_SCRIPT_KHMER = HB_TAG ('K','h','m','r'), + HB_SCRIPT_MYANMAR = HB_TAG ('M','y','m','r'), + HB_SCRIPT_SINHALA = HB_TAG ('S','i','n','h'), + HB_SCRIPT_THAANA = HB_TAG ('T','h','a','a'), + + /* Unicode-3.1 additions */ + HB_SCRIPT_DESERET = HB_TAG ('D','s','r','t'), + HB_SCRIPT_GOTHIC = HB_TAG ('G','o','t','h'), + HB_SCRIPT_OLD_ITALIC = HB_TAG ('I','t','a','l'), + + /* Unicode-3.2 additions */ + HB_SCRIPT_BUHID = HB_TAG ('B','u','h','d'), + HB_SCRIPT_HANUNOO = HB_TAG ('H','a','n','o'), + HB_SCRIPT_TAGALOG = HB_TAG ('T','g','l','g'), + HB_SCRIPT_TAGBANWA = HB_TAG ('T','a','g','b'), + + /* Unicode-4.0 additions */ + HB_SCRIPT_BRAILLE = HB_TAG ('B','r','a','i'), + HB_SCRIPT_CYPRIOT = HB_TAG ('C','p','r','t'), + HB_SCRIPT_LIMBU = HB_TAG ('L','i','m','b'), + HB_SCRIPT_LINEAR_B = HB_TAG ('L','i','n','b'), + HB_SCRIPT_OSMANYA = HB_TAG ('O','s','m','a'), + HB_SCRIPT_SHAVIAN = HB_TAG ('S','h','a','w'), + HB_SCRIPT_TAI_LE = HB_TAG ('T','a','l','e'), + HB_SCRIPT_UGARITIC = HB_TAG ('U','g','a','r'), + + /* Unicode-4.1 additions */ + HB_SCRIPT_BUGINESE = HB_TAG ('B','u','g','i'), + HB_SCRIPT_GLAGOLITIC = HB_TAG ('G','l','a','g'), + HB_SCRIPT_KHAROSHTHI = HB_TAG ('K','h','a','r'), + HB_SCRIPT_NEW_TAI_LUE = HB_TAG ('T','a','l','u'), + HB_SCRIPT_OLD_PERSIAN = HB_TAG ('X','p','e','o'), + HB_SCRIPT_SYLOTI_NAGRI = HB_TAG ('S','y','l','o'), + HB_SCRIPT_TIFINAGH = HB_TAG ('T','f','n','g'), + + /* Unicode-5.0 additions */ + HB_SCRIPT_BALINESE = HB_TAG ('B','a','l','i'), + HB_SCRIPT_CUNEIFORM = HB_TAG ('X','s','u','x'), + HB_SCRIPT_NKO = HB_TAG ('N','k','o','o'), + HB_SCRIPT_PHAGS_PA = HB_TAG ('P','h','a','g'), + HB_SCRIPT_PHOENICIAN = HB_TAG ('P','h','n','x'), + HB_SCRIPT_UNKNOWN = HB_TAG ('Z','z','z','z'), + + /* Unicode-5.1 additions */ + HB_SCRIPT_CARIAN = HB_TAG ('C','a','r','i'), + HB_SCRIPT_CHAM = HB_TAG ('C','h','a','m'), + HB_SCRIPT_KAYAH_LI = HB_TAG ('K','a','l','i'), + HB_SCRIPT_LEPCHA = HB_TAG ('L','e','p','c'), + HB_SCRIPT_LYCIAN = HB_TAG ('L','y','c','i'), + HB_SCRIPT_LYDIAN = HB_TAG ('L','y','d','i'), + HB_SCRIPT_OL_CHIKI = HB_TAG ('O','l','c','k'), + HB_SCRIPT_REJANG = HB_TAG ('R','j','n','g'), + HB_SCRIPT_SAURASHTRA = HB_TAG ('S','a','u','r'), + HB_SCRIPT_SUNDANESE = HB_TAG ('S','u','n','d'), + HB_SCRIPT_VAI = HB_TAG ('V','a','i','i'), + + /* Unicode-5.2 additions */ + HB_SCRIPT_AVESTAN = HB_TAG ('A','v','s','t'), + HB_SCRIPT_BAMUM = HB_TAG ('B','a','m','u'), + HB_SCRIPT_EGYPTIAN_HIEROGLYPHS = HB_TAG ('E','g','y','p'), + HB_SCRIPT_IMPERIAL_ARAMAIC = HB_TAG ('A','r','m','i'), + HB_SCRIPT_INSCRIPTIONAL_PAHLAVI = HB_TAG ('P','h','l','i'), + HB_SCRIPT_INSCRIPTIONAL_PARTHIAN = HB_TAG ('P','r','t','i'), + HB_SCRIPT_JAVANESE = HB_TAG ('J','a','v','a'), + HB_SCRIPT_KAITHI = HB_TAG ('K','t','h','i'), + HB_SCRIPT_LISU = HB_TAG ('L','i','s','u'), + HB_SCRIPT_MEETEI_MAYEK = HB_TAG ('M','t','e','i'), + HB_SCRIPT_OLD_SOUTH_ARABIAN = HB_TAG ('S','a','r','b'), + HB_SCRIPT_OLD_TURKIC = HB_TAG ('O','r','k','h'), + HB_SCRIPT_SAMARITAN = HB_TAG ('S','a','m','r'), + HB_SCRIPT_TAI_THAM = HB_TAG ('L','a','n','a'), + HB_SCRIPT_TAI_VIET = HB_TAG ('T','a','v','t'), + + /* Unicode-6.0 additions */ + HB_SCRIPT_BATAK = HB_TAG ('B','a','t','k'), + HB_SCRIPT_BRAHMI = HB_TAG ('B','r','a','h'), + HB_SCRIPT_MANDAIC = HB_TAG ('M','a','n','d'), + + /* Unicode-6.1 additions */ + HB_SCRIPT_CHAKMA = HB_TAG ('C','a','k','m'), + HB_SCRIPT_MEROITIC_CURSIVE = HB_TAG ('M','e','r','c'), + HB_SCRIPT_MEROITIC_HIEROGLYPHS = HB_TAG ('M','e','r','o'), + HB_SCRIPT_MIAO = HB_TAG ('P','l','r','d'), + HB_SCRIPT_SHARADA = HB_TAG ('S','h','r','d'), + HB_SCRIPT_SORA_SOMPENG = HB_TAG ('S','o','r','a'), + HB_SCRIPT_TAKRI = HB_TAG ('T','a','k','r'), + + /* No script set */ + HB_SCRIPT_INVALID = HB_TAG_NONE +} hb_script_t; + + +/* Script functions */ + +hb_script_t +hb_script_from_iso15924_tag (hb_tag_t tag); + +/* suger for tag_from_string() then script_from_iso15924_tag */ +/* len=-1 means s is NUL-terminated */ +hb_script_t +hb_script_from_string (const char *s, int len); + +hb_tag_t +hb_script_to_iso15924_tag (hb_script_t script); + +hb_direction_t +hb_script_get_horizontal_direction (hb_script_t script); + + +/* User data */ + +typedef struct hb_user_data_key_t { + /*< private >*/ + char unused; +} hb_user_data_key_t; + +typedef void (*hb_destroy_func_t) (void *user_data); + + +HB_END_DECLS + +#endif /* HB_COMMON_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.cc new file mode 100644 index 00000000000..8f94795928c --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.cc @@ -0,0 +1,355 @@ +/* + * Copyright © 2012 Mozilla Foundation. + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Mozilla Author(s): Jonathan Kew + * Google Author(s): Behdad Esfahbod + */ + +#define HB_SHAPER coretext +#include "hb-shaper-impl-private.hh" + +#include "hb-coretext.h" + + +#ifndef HB_DEBUG_CORETEXT +#define HB_DEBUG_CORETEXT (HB_DEBUG+0) +#endif + + +HB_SHAPER_DATA_ENSURE_DECLARE(coretext, face) +HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font) + + +/* + * shaper face data + */ + +struct hb_coretext_shaper_face_data_t { + CGFontRef cg_font; +}; + +static void +release_data (void *info, const void *data, size_t size) +{ + assert (hb_blob_get_length ((hb_blob_t *) info) == size && + hb_blob_get_data ((hb_blob_t *) info, NULL) == data); + + hb_blob_destroy ((hb_blob_t *) info); +} + +hb_coretext_shaper_face_data_t * +_hb_coretext_shaper_face_data_create (hb_face_t *face) +{ + hb_coretext_shaper_face_data_t *data = (hb_coretext_shaper_face_data_t *) calloc (1, sizeof (hb_coretext_shaper_face_data_t)); + if (unlikely (!data)) + return NULL; + + hb_blob_t *blob = hb_face_reference_blob (face); + unsigned int blob_length; + const char *blob_data = hb_blob_get_data (blob, &blob_length); + if (unlikely (!blob_length)) + DEBUG_MSG (CORETEXT, face, "Face has empty blob"); + + CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data); + data->cg_font = CGFontCreateWithDataProvider (provider); + CGDataProviderRelease (provider); + + if (unlikely (!data->cg_font)) { + DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed"); + free (data); + return NULL; + } + + return data; +} + +void +_hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data) +{ + CFRelease (data->cg_font); + free (data); +} + +CGFontRef +hb_coretext_face_get_cg_font (hb_face_t *face) +{ + if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL; + hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + return face_data->cg_font; +} + + +/* + * shaper font data + */ + +struct hb_coretext_shaper_font_data_t { + CTFontRef ct_font; +}; + +hb_coretext_shaper_font_data_t * +_hb_coretext_shaper_font_data_create (hb_font_t *font) +{ + if (unlikely (!hb_coretext_shaper_face_data_ensure (font->face))) return NULL; + + hb_coretext_shaper_font_data_t *data = (hb_coretext_shaper_font_data_t *) calloc (1, sizeof (hb_coretext_shaper_font_data_t)); + if (unlikely (!data)) + return NULL; + + hb_face_t *face = font->face; + hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + + data->ct_font = CTFontCreateWithGraphicsFont (face_data->cg_font, font->y_scale, NULL, NULL); + if (unlikely (!data->ct_font)) { + DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed"); + free (data); + return NULL; + } + + return data; +} + +void +_hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data) +{ + CFRelease (data->ct_font); + free (data); +} + + +/* + * shaper shape_plan data + */ + +struct hb_coretext_shaper_shape_plan_data_t {}; + +hb_coretext_shaper_shape_plan_data_t * +_hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, + const hb_feature_t *user_features HB_UNUSED, + unsigned int num_user_features HB_UNUSED) +{ + return (hb_coretext_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_t *data HB_UNUSED) +{ +} + +CTFontRef +hb_coretext_font_get_ct_font (hb_font_t *font) +{ + if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return NULL; + hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + return font_data->ct_font; +} + + +/* + * shaper + */ + +hb_bool_t +_hb_coretext_shape (hb_shape_plan_t *shape_plan, + hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features) +{ + hb_face_t *face = font->face; + hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + +#define FAIL(...) \ + HB_STMT_START { \ + DEBUG_MSG (CORETEXT, NULL, __VA_ARGS__); \ + return false; \ + } HB_STMT_END; + + unsigned int scratch_size; + char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size); + +#define utf16_index() var1.u32 + + UniChar *pchars = (UniChar *) scratch; + unsigned int chars_len = 0; + for (unsigned int i = 0; i < buffer->len; i++) { + hb_codepoint_t c = buffer->info[i].codepoint; + buffer->info[i].utf16_index() = chars_len; + if (likely (c < 0x10000)) + pchars[chars_len++] = c; + else if (unlikely (c >= 0x110000)) + pchars[chars_len++] = 0xFFFD; + else { + pchars[chars_len++] = 0xD800 + ((c - 0x10000) >> 10); + pchars[chars_len++] = 0xDC00 + ((c - 0x10000) & ((1 << 10) - 1)); + } + } + +#undef utf16_index + + CFStringRef string_ref = CFStringCreateWithCharactersNoCopy (kCFAllocatorDefault, + pchars, chars_len, + kCFAllocatorNull); + + CFDictionaryRef attrs = CFDictionaryCreate (kCFAllocatorDefault, + (const void**) &kCTFontAttributeName, + (const void**) &font_data->ct_font, + 1, /* count of attributes */ + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + /* TODO: support features */ + + CFAttributedStringRef attr_string = CFAttributedStringCreate (kCFAllocatorDefault, string_ref, attrs); + CFRelease (string_ref); + CFRelease (attrs); + + CTLineRef line = CTLineCreateWithAttributedString (attr_string); + CFRelease (attr_string); + + CFArrayRef glyph_runs = CTLineGetGlyphRuns (line); + unsigned int num_runs = CFArrayGetCount (glyph_runs); + + bool success = true; + buffer->len = 0; + + const CFRange range_all = CFRangeMake (0, 0); + + for (unsigned int i = 0; i < num_runs; i++) { + CTRunRef run = (CTRunRef) CFArrayGetValueAtIndex (glyph_runs, i); + + unsigned int num_glyphs = CTRunGetGlyphCount (run); + if (num_glyphs == 0) + continue; + + buffer->ensure (buffer->len + num_glyphs); + + /* Testing indicates that CTRunGetGlyphsPtr (almost?) always succeeds, + * and so copying data to our own buffer with CTRunGetGlyphs will be + * extremely rare. */ + + unsigned int scratch_size; + char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size); + +#define ALLOCATE_ARRAY(Type, name, len) \ + Type *name = (Type *) scratch; \ + scratch += (len) * sizeof ((name)[0]); \ + scratch_size -= (len) * sizeof ((name)[0]); + + const CGGlyph* glyphs = CTRunGetGlyphsPtr (run); + if (!glyphs) { + ALLOCATE_ARRAY (CGGlyph, glyph_buf, num_glyphs); + CTRunGetGlyphs (run, range_all, glyph_buf); + glyphs = glyph_buf; + } + + const CGPoint* positions = CTRunGetPositionsPtr (run); + if (!positions) { + ALLOCATE_ARRAY (CGPoint, position_buf, num_glyphs); + CTRunGetPositions (run, range_all, position_buf); + positions = position_buf; + } + + const CFIndex* string_indices = CTRunGetStringIndicesPtr (run); + if (!string_indices) { + ALLOCATE_ARRAY (CFIndex, index_buf, num_glyphs); + CTRunGetStringIndices (run, range_all, index_buf); + string_indices = index_buf; + } + +#undef ALLOCATE_ARRAY + + double run_width = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL); + + for (unsigned int j = 0; j < num_glyphs; j++) { + double advance = (j + 1 < num_glyphs ? positions[j + 1].x : positions[0].x + run_width) - positions[j].x; + + hb_glyph_info_t *info = &buffer->info[buffer->len]; + hb_glyph_position_t *pos = &buffer->pos[buffer->len]; + + info->codepoint = glyphs[j]; + info->cluster = string_indices[j]; + + /* Currently, we do all x-positioning by setting the advance, we never use x-offset. */ + info->mask = advance; + info->var1.u32 = 0; + info->var2.u32 = positions[j].y; + + buffer->len++; + } + } + + buffer->clear_positions (); + + unsigned int count = buffer->len; + for (unsigned int i = 0; i < count; ++i) { + hb_glyph_info_t *info = &buffer->info[i]; + hb_glyph_position_t *pos = &buffer->pos[i]; + + /* TODO vertical */ + pos->x_advance = info->mask; + pos->x_offset = info->var1.u32; + pos->y_offset = info->var2.u32; + } + + /* Fix up clusters so that we never return out-of-order indices; + * if core text has reordered glyphs, we'll merge them to the + * beginning of the reordered cluster. + * + * This does *not* mean we'll form the same clusters as Uniscribe + * or the native OT backend, only that the cluster indices will be + * monotonic in the output buffer. */ + if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) { + unsigned int prev_cluster = 0; + for (unsigned int i = 0; i < count; i++) { + unsigned int curr_cluster = buffer->info[i].cluster; + if (curr_cluster < prev_cluster) { + for (unsigned int j = i; j > 0; j--) { + if (buffer->info[j - 1].cluster > curr_cluster) + buffer->info[j - 1].cluster = curr_cluster; + else + break; + } + } + prev_cluster = curr_cluster; + } + } else { + unsigned int prev_cluster = (unsigned int)-1; + for (unsigned int i = 0; i < count; i++) { + unsigned int curr_cluster = buffer->info[i].cluster; + if (curr_cluster > prev_cluster) { + for (unsigned int j = i; j > 0; j--) { + if (buffer->info[j - 1].cluster < curr_cluster) + buffer->info[j - 1].cluster = curr_cluster; + else + break; + } + } + prev_cluster = curr_cluster; + } + } + + return true; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.h new file mode 100644 index 00000000000..c4954fa1b2c --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-coretext.h @@ -0,0 +1,46 @@ +/* + * Copyright © 2012 Mozilla Foundation. + * + * 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. + * + * Mozilla Author(s): Jonathan Kew + */ + +#ifndef HB_CORETEXT_H +#define HB_CORETEXT_H + +#include "hb.h" + +#include + +HB_BEGIN_DECLS + + +CGFontRef +hb_coretext_face_get_cg_font (hb_face_t *face); + +CTFontRef +hb_coretext_font_get_ct_font (hb_font_t *font); + + +HB_END_DECLS + +#endif /* HB_CORETEXT_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-fallback-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-fallback-shape.cc new file mode 100644 index 00000000000..bdc8a80c4bd --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-fallback-shape.cc @@ -0,0 +1,129 @@ +/* + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#define HB_SHAPER fallback +#include "hb-shaper-impl-private.hh" + + +/* + * shaper face data + */ + +struct hb_fallback_shaper_face_data_t {}; + +hb_fallback_shaper_face_data_t * +_hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED) +{ + return (hb_fallback_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_UNUSED) +{ +} + + +/* + * shaper font data + */ + +struct hb_fallback_shaper_font_data_t {}; + +hb_fallback_shaper_font_data_t * +_hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED) +{ + return (hb_fallback_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data HB_UNUSED) +{ +} + + +/* + * shaper shape_plan data + */ + +struct hb_fallback_shaper_shape_plan_data_t {}; + +hb_fallback_shaper_shape_plan_data_t * +_hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, + const hb_feature_t *user_features HB_UNUSED, + unsigned int num_user_features HB_UNUSED) +{ + return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shaper_shape_plan_data_t *data HB_UNUSED) +{ +} + + +/* + * shaper + */ + +hb_bool_t +_hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, + hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features HB_UNUSED, + unsigned int num_features HB_UNUSED) +{ + hb_codepoint_t space; + font->get_glyph (' ', 0, &space); + + buffer->guess_segment_properties (); + buffer->clear_positions (); + + unsigned int count = buffer->len; + + for (unsigned int i = 0; i < count; i++) + { + if (buffer->unicode->is_default_ignorable (buffer->info[i].codepoint)) { + buffer->info[i].codepoint = space; + buffer->pos[i].x_advance = 0; + buffer->pos[i].y_advance = 0; + continue; + } + font->get_glyph (buffer->info[i].codepoint, 0, &buffer->info[i].codepoint); + font->get_glyph_advance_for_direction (buffer->info[i].codepoint, + buffer->props.direction, + &buffer->pos[i].x_advance, + &buffer->pos[i].y_advance); + font->subtract_glyph_origin_for_direction (buffer->info[i].codepoint, + buffer->props.direction, + &buffer->pos[i].x_offset, + &buffer->pos[i].y_offset); + } + + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + hb_buffer_reverse (buffer); + + return true; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font-private.hh new file mode 100644 index 00000000000..48fbb0ee549 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font-private.hh @@ -0,0 +1,469 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_FONT_PRIVATE_HH +#define HB_FONT_PRIVATE_HH + +#include "hb-private.hh" + +#include "hb-font.h" +#include "hb-object-private.hh" +#include "hb-shaper-private.hh" +#include "hb-shape-plan-private.hh" + + + +/* + * hb_font_funcs_t + */ + +#define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \ + HB_FONT_FUNC_IMPLEMENT (glyph) \ + HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \ + HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \ + HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \ + HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \ + HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \ + HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \ + HB_FONT_FUNC_IMPLEMENT (glyph_extents) \ + HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \ + HB_FONT_FUNC_IMPLEMENT (glyph_name) \ + HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ + /* ^--- Add new callbacks here */ + +struct hb_font_funcs_t { + hb_object_header_t header; + ASSERT_POD (); + + hb_bool_t immutable; + + /* Don't access these directly. Call hb_font_get_*() instead. */ + + struct { +#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name; + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } get; + + struct { +#define HB_FONT_FUNC_IMPLEMENT(name) void *name; + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } user_data; + + struct { +#define HB_FONT_FUNC_IMPLEMENT(name) hb_destroy_func_t name; + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } destroy; +}; + + +/* + * hb_face_t + */ + +struct hb_face_t { + hb_object_header_t header; + ASSERT_POD (); + + hb_bool_t immutable; + + hb_reference_table_func_t reference_table_func; + void *user_data; + hb_destroy_func_t destroy; + + unsigned int index; + mutable unsigned int upem; + mutable unsigned int num_glyphs; + + struct hb_shaper_data_t shaper_data; + + struct plan_node_t { + hb_shape_plan_t *shape_plan; + plan_node_t *next; + } *shape_plans; + + + inline hb_blob_t *reference_table (hb_tag_t tag) const + { + hb_blob_t *blob; + + if (unlikely (!this || !reference_table_func)) + return hb_blob_get_empty (); + + blob = reference_table_func (/*XXX*/const_cast (this), tag, user_data); + if (unlikely (!blob)) + return hb_blob_get_empty (); + + return blob; + } + + inline unsigned int get_upem (void) const + { + if (unlikely (!upem)) + load_upem (); + return upem; + } + + inline unsigned int get_num_glyphs (void) const + { + if (unlikely (num_glyphs == (unsigned int) -1)) + load_num_glyphs (); + return num_glyphs; + } + + private: + HB_INTERNAL void load_upem (void) const; + HB_INTERNAL void load_num_glyphs (void) const; +}; + +#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face); +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT +#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS + + +/* + * hb_font_t + */ + +struct hb_font_t { + hb_object_header_t header; + ASSERT_POD (); + + hb_bool_t immutable; + + hb_font_t *parent; + hb_face_t *face; + + int x_scale; + int y_scale; + + unsigned int x_ppem; + unsigned int y_ppem; + + hb_font_funcs_t *klass; + void *user_data; + hb_destroy_func_t destroy; + + struct hb_shaper_data_t shaper_data; + + + /* Convert from font-space to user-space */ + inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); } + inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); } + + /* Convert from parent-font user-space to our user-space */ + inline hb_position_t parent_scale_x_distance (hb_position_t v) { + if (unlikely (parent && parent->x_scale != x_scale)) + return v * (int64_t) this->x_scale / this->parent->x_scale; + return v; + } + inline hb_position_t parent_scale_y_distance (hb_position_t v) { + if (unlikely (parent && parent->y_scale != y_scale)) + return v * (int64_t) this->y_scale / this->parent->y_scale; + return v; + } + inline hb_position_t parent_scale_x_position (hb_position_t v) { + return parent_scale_x_distance (v); + } + inline hb_position_t parent_scale_y_position (hb_position_t v) { + return parent_scale_y_distance (v); + } + + inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) { + *x = parent_scale_x_distance (*x); + *y = parent_scale_y_distance (*y); + } + inline void parent_scale_position (hb_position_t *x, hb_position_t *y) { + *x = parent_scale_x_position (*x); + *y = parent_scale_y_position (*y); + } + + + /* Public getters */ + + inline hb_bool_t get_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) + { + *glyph = 0; + return klass->get.glyph (this, user_data, + unicode, variation_selector, glyph, + klass->user_data.glyph); + } + + inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph) + { + return klass->get.glyph_h_advance (this, user_data, + glyph, + klass->user_data.glyph_h_advance); + } + + inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph) + { + return klass->get.glyph_v_advance (this, user_data, + glyph, + klass->user_data.glyph_v_advance); + } + + inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + *x = *y = 0; + return klass->get.glyph_h_origin (this, user_data, + glyph, x, y, + klass->user_data.glyph_h_origin); + } + + inline hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + *x = *y = 0; + return klass->get.glyph_v_origin (this, user_data, + glyph, x, y, + klass->user_data.glyph_v_origin); + } + + inline hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) + { + return klass->get.glyph_h_kerning (this, user_data, + left_glyph, right_glyph, + klass->user_data.glyph_h_kerning); + } + + inline hb_position_t get_glyph_v_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) + { + return klass->get.glyph_v_kerning (this, user_data, + left_glyph, right_glyph, + klass->user_data.glyph_v_kerning); + } + + inline hb_bool_t get_glyph_extents (hb_codepoint_t glyph, + hb_glyph_extents_t *extents) + { + memset (extents, 0, sizeof (*extents)); + return klass->get.glyph_extents (this, user_data, + glyph, + extents, + klass->user_data.glyph_extents); + } + + inline hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index, + hb_position_t *x, hb_position_t *y) + { + *x = *y = 0; + return klass->get.glyph_contour_point (this, user_data, + glyph, point_index, + x, y, + klass->user_data.glyph_contour_point); + } + + inline hb_bool_t get_glyph_name (hb_codepoint_t glyph, + char *name, unsigned int size) + { + if (size) *name = '\0'; + return klass->get.glyph_name (this, user_data, + glyph, + name, size, + klass->user_data.glyph_name); + } + + inline hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) + { + *glyph = 0; + if (len == -1) len = strlen (name); + return klass->get.glyph_from_name (this, user_data, + name, len, + glyph, + klass->user_data.glyph_from_name); + } + + + /* A bit higher-level, and with fallback */ + + inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { + *x = get_glyph_h_advance (glyph); + *y = 0; + } else { + *x = 0; + *y = get_glyph_v_advance (glyph); + } + } + + /* Internal only */ + inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + *x = get_glyph_h_advance (glyph) / 2; + + /* TODO use font_metics.ascent */ + *y = y_scale; + } + + inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { + hb_bool_t ret = get_glyph_h_origin (glyph, x, y); + if (!ret && (ret = get_glyph_v_origin (glyph, x, y))) { + hb_position_t dx, dy; + guess_v_origin_minus_h_origin (glyph, &dx, &dy); + *x -= dx; *y -= dy; + } + } else { + hb_bool_t ret = get_glyph_v_origin (glyph, x, y); + if (!ret && (ret = get_glyph_h_origin (glyph, x, y))) { + hb_position_t dx, dy; + guess_v_origin_minus_h_origin (glyph, &dx, &dy); + *x += dx; *y += dy; + } + } + } + + inline void add_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); + + *x += origin_x; + *y += origin_y; + } + + inline void subtract_glyph_origin_for_direction (hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + hb_position_t origin_x, origin_y; + + get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); + + *x -= origin_x; + *y -= origin_y; + } + + inline void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { + *x = get_glyph_h_kerning (first_glyph, second_glyph); + *y = 0; + } else { + *x = 0; + *y = get_glyph_v_kerning (first_glyph, second_glyph); + } + } + + inline hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph, + hb_direction_t direction, + hb_glyph_extents_t *extents) + { + hb_bool_t ret = get_glyph_extents (glyph, extents); + + if (ret) + subtract_glyph_origin_for_direction (glyph, direction, &extents->x_bearing, &extents->y_bearing); + + return ret; + } + + inline hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) + { + hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y); + + if (ret) + subtract_glyph_origin_for_direction (glyph, direction, x, y); + + return ret; + } + + /* Generates gidDDD if glyph has no name. */ + inline void + glyph_to_string (hb_codepoint_t glyph, + char *s, unsigned int size) + { + if (get_glyph_name (glyph, s, size)) return; + + snprintf (s, size, "gid%u", glyph); + } + + /* Parses gidDDD and uniUUUU strings automatically. */ + inline hb_bool_t + glyph_from_string (const char *s, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) + { + if (get_glyph_from_name (s, len, glyph)) return true; + + if (len == -1) len = strlen (s); + + /* Straight glyph index. */ + if (hb_codepoint_parse (s, len, 10, glyph)) + return true; + + if (len > 3) + { + /* gidDDD syntax for glyph indices. */ + if (0 == strncmp (s, "gid", 3) && + hb_codepoint_parse (s + 3, len - 3, 10, glyph)) + return true; + + /* uniUUUU and other Unicode character indices. */ + hb_codepoint_t unichar; + if (0 == strncmp (s, "uni", 3) && + hb_codepoint_parse (s + 3, len - 3, 16, &unichar) && + get_glyph (unichar, 0, glyph)) + return true; + } + + return false; + } + + private: + inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / hb_face_get_upem (this->face); } +}; + +#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font); +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT +#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS + + +#endif /* HB_FONT_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.cc new file mode 100644 index 00000000000..b59fdebaea7 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.cc @@ -0,0 +1,1008 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +#include "hb-ot-layout-private.hh" + +#include "hb-font-private.hh" +#include "hb-blob.h" +#include "hb-open-file-private.hh" +#include "hb-ot-head-table.hh" +#include "hb-ot-maxp-table.hh" + +#include "hb-cache-private.hh" + +#include + + + +/* + * hb_font_funcs_t + */ + +static hb_bool_t +hb_font_get_glyph_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) +{ + if (font->parent) + return font->parent->get_glyph (unicode, variation_selector, glyph); + + *glyph = 0; + return false; +} + +static hb_position_t +hb_font_get_glyph_h_advance_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) +{ + if (font->parent) + return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph)); + + return font->x_scale; +} + +static hb_position_t +hb_font_get_glyph_v_advance_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) +{ + if (font->parent) + return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph)); + + return font->y_scale; +} + +static hb_bool_t +hb_font_get_glyph_h_origin_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) +{ + if (font->parent) { + hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y); + if (ret) + font->parent_scale_position (x, y); + return ret; + } + + *x = *y = 0; + return false; +} + +static hb_bool_t +hb_font_get_glyph_v_origin_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) +{ + if (font->parent) { + hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y); + if (ret) + font->parent_scale_position (x, y); + return ret; + } + + *x = *y = 0; + return false; +} + +static hb_position_t +hb_font_get_glyph_h_kerning_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t left_glyph, + hb_codepoint_t right_glyph, + void *user_data HB_UNUSED) +{ + if (font->parent) + return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph)); + + return 0; +} + +static hb_position_t +hb_font_get_glyph_v_kerning_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t top_glyph, + hb_codepoint_t bottom_glyph, + void *user_data HB_UNUSED) +{ + if (font->parent) + return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph)); + + return 0; +} + +static hb_bool_t +hb_font_get_glyph_extents_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents, + void *user_data HB_UNUSED) +{ + if (font->parent) { + hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents); + if (ret) { + font->parent_scale_position (&extents->x_bearing, &extents->y_bearing); + font->parent_scale_distance (&extents->width, &extents->height); + } + return ret; + } + + memset (extents, 0, sizeof (*extents)); + return false; +} + +static hb_bool_t +hb_font_get_glyph_contour_point_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + unsigned int point_index, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) +{ + if (font->parent) { + hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y); + if (ret) + font->parent_scale_position (x, y); + return ret; + } + + *x = *y = 0; + return false; +} + +static hb_bool_t +hb_font_get_glyph_name_nil (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + char *name, unsigned int size, + void *user_data HB_UNUSED) +{ + if (font->parent) + return font->parent->get_glyph_name (glyph, name, size); + + if (size) *name = '\0'; + return false; +} + +static hb_bool_t +hb_font_get_glyph_from_name_nil (hb_font_t *font, + void *font_data HB_UNUSED, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) +{ + if (font->parent) + return font->parent->get_glyph_from_name (name, len, glyph); + + *glyph = 0; + return false; +} + + +static const hb_font_funcs_t _hb_font_funcs_nil = { + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + { +#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil, + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } +}; + + +hb_font_funcs_t * +hb_font_funcs_create (void) +{ + hb_font_funcs_t *ffuncs; + + if (!(ffuncs = hb_object_create ())) + return hb_font_funcs_get_empty (); + + ffuncs->get = _hb_font_funcs_nil.get; + + return ffuncs; +} + +hb_font_funcs_t * +hb_font_funcs_get_empty (void) +{ + return const_cast (&_hb_font_funcs_nil); +} + +hb_font_funcs_t * +hb_font_funcs_reference (hb_font_funcs_t *ffuncs) +{ + return hb_object_reference (ffuncs); +} + +void +hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) +{ + if (!hb_object_destroy (ffuncs)) return; + +#define HB_FONT_FUNC_IMPLEMENT(name) if (ffuncs->destroy.name) \ + ffuncs->destroy.name (ffuncs->user_data.name); + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + + free (ffuncs); +} + +hb_bool_t +hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return hb_object_set_user_data (ffuncs, key, data, destroy, replace); +} + +void * +hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, + hb_user_data_key_t *key) +{ + return hb_object_get_user_data (ffuncs, key); +} + + +void +hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) +{ + if (hb_object_is_inert (ffuncs)) + return; + + ffuncs->immutable = true; +} + +hb_bool_t +hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs) +{ + return ffuncs->immutable; +} + + +#define HB_FONT_FUNC_IMPLEMENT(name) \ + \ +void \ +hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ + hb_font_get_##name##_func_t func, \ + void *user_data, \ + hb_destroy_func_t destroy) \ +{ \ + if (ffuncs->immutable) { \ + if (destroy) \ + destroy (user_data); \ + return; \ + } \ + \ + if (ffuncs->destroy.name) \ + ffuncs->destroy.name (ffuncs->user_data.name); \ + \ + if (func) { \ + ffuncs->get.name = func; \ + ffuncs->user_data.name = user_data; \ + ffuncs->destroy.name = destroy; \ + } else { \ + ffuncs->get.name = hb_font_get_##name##_nil; \ + ffuncs->user_data.name = NULL; \ + ffuncs->destroy.name = NULL; \ + } \ +} + +HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + + +/* Public getters */ + +hb_bool_t +hb_font_get_glyph (hb_font_t *font, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) +{ + return font->get_glyph (unicode, variation_selector, glyph); +} + +hb_position_t +hb_font_get_glyph_h_advance (hb_font_t *font, + hb_codepoint_t glyph) +{ + return font->get_glyph_h_advance (glyph); +} + +hb_position_t +hb_font_get_glyph_v_advance (hb_font_t *font, + hb_codepoint_t glyph) +{ + return font->get_glyph_v_advance (glyph); +} + +hb_bool_t +hb_font_get_glyph_h_origin (hb_font_t *font, + hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) +{ + return font->get_glyph_h_origin (glyph, x, y); +} + +hb_bool_t +hb_font_get_glyph_v_origin (hb_font_t *font, + hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) +{ + return font->get_glyph_v_origin (glyph, x, y); +} + +hb_position_t +hb_font_get_glyph_h_kerning (hb_font_t *font, + hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) +{ + return font->get_glyph_h_kerning (left_glyph, right_glyph); +} + +hb_position_t +hb_font_get_glyph_v_kerning (hb_font_t *font, + hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) +{ + return font->get_glyph_v_kerning (left_glyph, right_glyph); +} + +hb_bool_t +hb_font_get_glyph_extents (hb_font_t *font, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents) +{ + return font->get_glyph_extents (glyph, extents); +} + +hb_bool_t +hb_font_get_glyph_contour_point (hb_font_t *font, + hb_codepoint_t glyph, unsigned int point_index, + hb_position_t *x, hb_position_t *y) +{ + return font->get_glyph_contour_point (glyph, point_index, x, y); +} + +hb_bool_t +hb_font_get_glyph_name (hb_font_t *font, + hb_codepoint_t glyph, + char *name, unsigned int size) +{ + return font->get_glyph_name (glyph, name, size); +} + +hb_bool_t +hb_font_get_glyph_from_name (hb_font_t *font, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) +{ + return font->get_glyph_from_name (name, len, glyph); +} + + +/* A bit higher-level, and with fallback */ + +void +hb_font_get_glyph_advance_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) +{ + return font->get_glyph_advance_for_direction (glyph, direction, x, y); +} + +void +hb_font_get_glyph_origin_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) +{ + return font->get_glyph_origin_for_direction (glyph, direction, x, y); +} + +void +hb_font_add_glyph_origin_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) +{ + return font->add_glyph_origin_for_direction (glyph, direction, x, y); +} + +void +hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) +{ + return font->subtract_glyph_origin_for_direction (glyph, direction, x, y); +} + +void +hb_font_get_glyph_kerning_for_direction (hb_font_t *font, + hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) +{ + return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y); +} + +hb_bool_t +hb_font_get_glyph_extents_for_origin (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_glyph_extents_t *extents) +{ + return font->get_glyph_extents_for_origin (glyph, direction, extents); +} + +hb_bool_t +hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, + hb_codepoint_t glyph, unsigned int point_index, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y) +{ + return font->get_glyph_contour_point_for_origin (glyph, point_index, direction, x, y); +} + +/* Generates gidDDD if glyph has no name. */ +void +hb_font_glyph_to_string (hb_font_t *font, + hb_codepoint_t glyph, + char *s, unsigned int size) +{ + font->glyph_to_string (glyph, s, size); +} + +/* Parses gidDDD and uniUUUU strings automatically. */ +hb_bool_t +hb_font_glyph_from_string (hb_font_t *font, + const char *s, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) +{ + return font->glyph_from_string (s, len, glyph); +} + + +/* + * hb_face_t + */ + +static const hb_face_t _hb_face_nil = { + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + NULL, /* reference_table_func */ + NULL, /* user_data */ + NULL, /* destroy */ + + 0, /* index */ + 1000, /* upem */ + 0, /* num_glyphs */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + }, + + NULL, /* shape_plans */ +}; + + +hb_face_t * +hb_face_create_for_tables (hb_reference_table_func_t reference_table_func, + void *user_data, + hb_destroy_func_t destroy) +{ + hb_face_t *face; + + if (!reference_table_func || !(face = hb_object_create ())) { + if (destroy) + destroy (user_data); + return hb_face_get_empty (); + } + + face->reference_table_func = reference_table_func; + face->user_data = user_data; + face->destroy = destroy; + + face->upem = 0; + face->num_glyphs = (unsigned int) -1; + + return face; +} + + +typedef struct hb_face_for_data_closure_t { + hb_blob_t *blob; + unsigned int index; +} hb_face_for_data_closure_t; + +static hb_face_for_data_closure_t * +_hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index) +{ + hb_face_for_data_closure_t *closure; + + closure = (hb_face_for_data_closure_t *) malloc (sizeof (hb_face_for_data_closure_t)); + if (unlikely (!closure)) + return NULL; + + closure->blob = blob; + closure->index = index; + + return closure; +} + +static void +_hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure) +{ + hb_blob_destroy (closure->blob); + free (closure); +} + +static hb_blob_t * +_hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) +{ + hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) user_data; + + if (tag == HB_TAG_NONE) + return hb_blob_reference (data->blob); + + const OT::OpenTypeFontFile &ot_file = *OT::Sanitizer::lock_instance (data->blob); + const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index); + + const OT::OpenTypeTable &table = ot_face.get_table_by_tag (tag); + + hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, table.offset, table.length); + + return blob; +} + +hb_face_t * +hb_face_create (hb_blob_t *blob, + unsigned int index) +{ + hb_face_t *face; + + if (unlikely (!blob || !hb_blob_get_length (blob))) + return hb_face_get_empty (); + + hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::Sanitizer::sanitize (hb_blob_reference (blob)), index); + + if (unlikely (!closure)) + return hb_face_get_empty (); + + face = hb_face_create_for_tables (_hb_face_for_data_reference_table, + closure, + (hb_destroy_func_t) _hb_face_for_data_closure_destroy); + + hb_face_set_index (face, index); + + return face; +} + +hb_face_t * +hb_face_get_empty (void) +{ + return const_cast (&_hb_face_nil); +} + + +hb_face_t * +hb_face_reference (hb_face_t *face) +{ + return hb_object_reference (face); +} + +void +hb_face_destroy (hb_face_t *face) +{ + if (!hb_object_destroy (face)) return; + + for (hb_face_t::plan_node_t *node = face->shape_plans; node; ) + { + hb_face_t::plan_node_t *next = node->next; + hb_shape_plan_destroy (node->shape_plan); + free (node); + node = next; + } + +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face); +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + + if (face->destroy) + face->destroy (face->user_data); + + free (face); +} + +hb_bool_t +hb_face_set_user_data (hb_face_t *face, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return hb_object_set_user_data (face, key, data, destroy, replace); +} + +void * +hb_face_get_user_data (hb_face_t *face, + hb_user_data_key_t *key) +{ + return hb_object_get_user_data (face, key); +} + +void +hb_face_make_immutable (hb_face_t *face) +{ + if (hb_object_is_inert (face)) + return; + + face->immutable = true; +} + +hb_bool_t +hb_face_is_immutable (hb_face_t *face) +{ + return face->immutable; +} + + +hb_blob_t * +hb_face_reference_table (hb_face_t *face, + hb_tag_t tag) +{ + return face->reference_table (tag); +} + +hb_blob_t * +hb_face_reference_blob (hb_face_t *face) +{ + return face->reference_table (HB_TAG_NONE); +} + +void +hb_face_set_index (hb_face_t *face, + unsigned int index) +{ + if (hb_object_is_inert (face)) + return; + + face->index = index; +} + +unsigned int +hb_face_get_index (hb_face_t *face) +{ + return face->index; +} + +void +hb_face_set_upem (hb_face_t *face, + unsigned int upem) +{ + if (hb_object_is_inert (face)) + return; + + face->upem = upem; +} + +unsigned int +hb_face_get_upem (hb_face_t *face) +{ + return face->get_upem (); +} + +void +hb_face_t::load_upem (void) const +{ + hb_blob_t *head_blob = OT::Sanitizer::sanitize (reference_table (HB_OT_TAG_head)); + const OT::head *head_table = OT::Sanitizer::lock_instance (head_blob); + upem = head_table->get_upem (); + hb_blob_destroy (head_blob); +} + +void +hb_face_set_glyph_count (hb_face_t *face, + unsigned int glyph_count) +{ + if (hb_object_is_inert (face)) + return; + + face->num_glyphs = glyph_count; +} + +unsigned int +hb_face_get_glyph_count (hb_face_t *face) +{ + return face->get_num_glyphs (); +} + +void +hb_face_t::load_num_glyphs (void) const +{ + hb_blob_t *maxp_blob = OT::Sanitizer::sanitize (reference_table (HB_OT_TAG_maxp)); + const OT::maxp *maxp_table = OT::Sanitizer::lock_instance (maxp_blob); + num_glyphs = maxp_table->get_num_glyphs (); + hb_blob_destroy (maxp_blob); +} + + +/* + * hb_font_t + */ + +hb_font_t * +hb_font_create (hb_face_t *face) +{ + hb_font_t *font; + + if (unlikely (!face)) + face = hb_face_get_empty (); + if (unlikely (hb_object_is_inert (face))) + return hb_font_get_empty (); + if (!(font = hb_object_create ())) + return hb_font_get_empty (); + + hb_face_make_immutable (face); + font->face = hb_face_reference (face); + font->klass = hb_font_funcs_get_empty (); + + return font; +} + +hb_font_t * +hb_font_create_sub_font (hb_font_t *parent) +{ + if (unlikely (!parent)) + return hb_font_get_empty (); + + hb_font_t *font = hb_font_create (parent->face); + + if (unlikely (hb_object_is_inert (font))) + return font; + + hb_font_make_immutable (parent); + font->parent = hb_font_reference (parent); + + font->x_scale = parent->x_scale; + font->y_scale = parent->y_scale; + font->x_ppem = parent->x_ppem; + font->y_ppem = parent->y_ppem; + + return font; +} + +hb_font_t * +hb_font_get_empty (void) +{ + static const hb_font_t _hb_font_nil = { + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + NULL, /* parent */ + const_cast (&_hb_face_nil), + + 0, /* x_scale */ + 0, /* y_scale */ + + 0, /* x_ppem */ + 0, /* y_ppem */ + + const_cast (&_hb_font_funcs_nil), /* klass */ + NULL, /* user_data */ + NULL, /* destroy */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + } + }; + + return const_cast (&_hb_font_nil); +} + +hb_font_t * +hb_font_reference (hb_font_t *font) +{ + return hb_object_reference (font); +} + +void +hb_font_destroy (hb_font_t *font) +{ + if (!hb_object_destroy (font)) return; + +#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font); +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + + if (font->destroy) + font->destroy (font->user_data); + + hb_font_destroy (font->parent); + hb_face_destroy (font->face); + hb_font_funcs_destroy (font->klass); + + free (font); +} + +hb_bool_t +hb_font_set_user_data (hb_font_t *font, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return hb_object_set_user_data (font, key, data, destroy, replace); +} + +void * +hb_font_get_user_data (hb_font_t *font, + hb_user_data_key_t *key) +{ + return hb_object_get_user_data (font, key); +} + +void +hb_font_make_immutable (hb_font_t *font) +{ + if (hb_object_is_inert (font)) + return; + + font->immutable = true; +} + +hb_bool_t +hb_font_is_immutable (hb_font_t *font) +{ + return font->immutable; +} + +hb_font_t * +hb_font_get_parent (hb_font_t *font) +{ + return font->parent; +} + +hb_face_t * +hb_font_get_face (hb_font_t *font) +{ + return font->face; +} + + +void +hb_font_set_funcs (hb_font_t *font, + hb_font_funcs_t *klass, + void *user_data, + hb_destroy_func_t destroy) +{ + if (font->immutable) { + if (destroy) + destroy (user_data); + return; + } + + if (font->destroy) + font->destroy (font->user_data); + + if (!klass) + klass = hb_font_funcs_get_empty (); + + hb_font_funcs_reference (klass); + hb_font_funcs_destroy (font->klass); + font->klass = klass; + font->user_data = user_data; + font->destroy = destroy; +} + +void +hb_font_set_funcs_data (hb_font_t *font, + void *user_data, + hb_destroy_func_t destroy) +{ + /* Destroy user_data? */ + if (font->immutable) { + if (destroy) + destroy (user_data); + return; + } + + if (font->destroy) + font->destroy (font->user_data); + + font->user_data = user_data; + font->destroy = destroy; +} + + +void +hb_font_set_scale (hb_font_t *font, + int x_scale, + int y_scale) +{ + if (font->immutable) + return; + + font->x_scale = x_scale; + font->y_scale = y_scale; +} + +void +hb_font_get_scale (hb_font_t *font, + int *x_scale, + int *y_scale) +{ + if (x_scale) *x_scale = font->x_scale; + if (y_scale) *y_scale = font->y_scale; +} + +void +hb_font_set_ppem (hb_font_t *font, + unsigned int x_ppem, + unsigned int y_ppem) +{ + if (font->immutable) + return; + + font->x_ppem = x_ppem; + font->y_ppem = y_ppem; +} + +void +hb_font_get_ppem (hb_font_t *font, + unsigned int *x_ppem, + unsigned int *y_ppem) +{ + if (x_ppem) *x_ppem = font->x_ppem; + if (y_ppem) *y_ppem = font->y_ppem; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.h new file mode 100644 index 00000000000..88d489551e8 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-font.h @@ -0,0 +1,454 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + */ + +#ifndef HB_H_IN +#error "Include instead." +#endif + +#ifndef HB_FONT_H +#define HB_FONT_H + +#include "hb-common.h" +#include "hb-blob.h" + +HB_BEGIN_DECLS + + +typedef struct hb_face_t hb_face_t; +typedef struct hb_font_t hb_font_t; + +/* + * hb_face_t + */ + +hb_face_t * +hb_face_create (hb_blob_t *blob, + unsigned int index); + +typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data); + +/* calls destroy() when not needing user_data anymore */ +hb_face_t * +hb_face_create_for_tables (hb_reference_table_func_t reference_table_func, + void *user_data, + hb_destroy_func_t destroy); + +hb_face_t * +hb_face_get_empty (void); + +hb_face_t * +hb_face_reference (hb_face_t *face); + +void +hb_face_destroy (hb_face_t *face); + +hb_bool_t +hb_face_set_user_data (hb_face_t *face, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + + +void * +hb_face_get_user_data (hb_face_t *face, + hb_user_data_key_t *key); + +void +hb_face_make_immutable (hb_face_t *face); + +hb_bool_t +hb_face_is_immutable (hb_face_t *face); + + +hb_blob_t * +hb_face_reference_table (hb_face_t *face, + hb_tag_t tag); + +hb_blob_t * +hb_face_reference_blob (hb_face_t *face); + +void +hb_face_set_index (hb_face_t *face, + unsigned int index); + +unsigned int +hb_face_get_index (hb_face_t *face); + +void +hb_face_set_upem (hb_face_t *face, + unsigned int upem); + +unsigned int +hb_face_get_upem (hb_face_t *face); + +void +hb_face_set_glyph_count (hb_face_t *face, + unsigned int glyph_count); + +unsigned int +hb_face_get_glyph_count (hb_face_t *face); + + +/* + * hb_font_funcs_t + */ + +typedef struct hb_font_funcs_t hb_font_funcs_t; + +hb_font_funcs_t * +hb_font_funcs_create (void); + +hb_font_funcs_t * +hb_font_funcs_get_empty (void); + +hb_font_funcs_t * +hb_font_funcs_reference (hb_font_funcs_t *ffuncs); + +void +hb_font_funcs_destroy (hb_font_funcs_t *ffuncs); + +hb_bool_t +hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + + +void * +hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, + hb_user_data_key_t *key); + + +void +hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs); + +hb_bool_t +hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs); + + +/* glyph extents */ + +typedef struct hb_glyph_extents_t +{ + hb_position_t x_bearing; + hb_position_t y_bearing; + hb_position_t width; + hb_position_t height; +} hb_glyph_extents_t; + + +/* func types */ + +typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data); + + +typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, + void *user_data); +typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t; +typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; + +typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y, + void *user_data); +typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t; +typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t; + +typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, + void *user_data); +typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t; +typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; + + +typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents, + void *user_data); +typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, unsigned int point_index, + hb_position_t *x, hb_position_t *y, + void *user_data); + + +typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, + char *name, unsigned int size, + void *user_data); +typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph, + void *user_data); + + +/* func setters */ + +void +hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_func_t glyph_func, + void *user_data, hb_destroy_func_t destroy); + +void +hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_h_advance_func_t func, + void *user_data, hb_destroy_func_t destroy); +void +hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_v_advance_func_t func, + void *user_data, hb_destroy_func_t destroy); + +void +hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_h_origin_func_t func, + void *user_data, hb_destroy_func_t destroy); +void +hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_v_origin_func_t func, + void *user_data, hb_destroy_func_t destroy); + +void +hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_h_kerning_func_t func, + void *user_data, hb_destroy_func_t destroy); +void +hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_v_kerning_func_t func, + void *user_data, hb_destroy_func_t destroy); + +void +hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_extents_func_t func, + void *user_data, hb_destroy_func_t destroy); +void +hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_contour_point_func_t func, + void *user_data, hb_destroy_func_t destroy); + +void +hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_name_func_t glyph_func, + void *user_data, hb_destroy_func_t destroy); +void +hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_from_name_func_t glyph_func, + void *user_data, hb_destroy_func_t destroy); + + +/* func dispatch */ + +hb_bool_t +hb_font_get_glyph (hb_font_t *font, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph); + +hb_position_t +hb_font_get_glyph_h_advance (hb_font_t *font, + hb_codepoint_t glyph); +hb_position_t +hb_font_get_glyph_v_advance (hb_font_t *font, + hb_codepoint_t glyph); + +hb_bool_t +hb_font_get_glyph_h_origin (hb_font_t *font, + hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y); +hb_bool_t +hb_font_get_glyph_v_origin (hb_font_t *font, + hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y); + +hb_position_t +hb_font_get_glyph_h_kerning (hb_font_t *font, + hb_codepoint_t left_glyph, hb_codepoint_t right_glyph); +hb_position_t +hb_font_get_glyph_v_kerning (hb_font_t *font, + hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph); + +hb_bool_t +hb_font_get_glyph_extents (hb_font_t *font, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents); + +hb_bool_t +hb_font_get_glyph_contour_point (hb_font_t *font, + hb_codepoint_t glyph, unsigned int point_index, + hb_position_t *x, hb_position_t *y); + +hb_bool_t +hb_font_get_glyph_name (hb_font_t *font, + hb_codepoint_t glyph, + char *name, unsigned int size); +hb_bool_t +hb_font_get_glyph_from_name (hb_font_t *font, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph); + + +/* high-level funcs, with fallback */ + +void +hb_font_get_glyph_advance_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y); +void +hb_font_get_glyph_origin_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y); +void +hb_font_add_glyph_origin_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y); +void +hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y); + +void +hb_font_get_glyph_kerning_for_direction (hb_font_t *font, + hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y); + +hb_bool_t +hb_font_get_glyph_extents_for_origin (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + hb_glyph_extents_t *extents); + +hb_bool_t +hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, + hb_codepoint_t glyph, unsigned int point_index, + hb_direction_t direction, + hb_position_t *x, hb_position_t *y); + +/* Generates gidDDD if glyph has no name. */ +void +hb_font_glyph_to_string (hb_font_t *font, + hb_codepoint_t glyph, + char *s, unsigned int size); +/* Parses gidDDD and uniUUUU strings automatically. */ +hb_bool_t +hb_font_glyph_from_string (hb_font_t *font, + const char *s, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph); + + +/* + * hb_font_t + */ + +/* Fonts are very light-weight objects */ + +hb_font_t * +hb_font_create (hb_face_t *face); + +hb_font_t * +hb_font_create_sub_font (hb_font_t *parent); + +hb_font_t * +hb_font_get_empty (void); + +hb_font_t * +hb_font_reference (hb_font_t *font); + +void +hb_font_destroy (hb_font_t *font); + +hb_bool_t +hb_font_set_user_data (hb_font_t *font, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + + +void * +hb_font_get_user_data (hb_font_t *font, + hb_user_data_key_t *key); + +void +hb_font_make_immutable (hb_font_t *font); + +hb_bool_t +hb_font_is_immutable (hb_font_t *font); + +hb_font_t * +hb_font_get_parent (hb_font_t *font); + +hb_face_t * +hb_font_get_face (hb_font_t *font); + + +void +hb_font_set_funcs (hb_font_t *font, + hb_font_funcs_t *klass, + void *font_data, + hb_destroy_func_t destroy); + +/* Be *very* careful with this function! */ +void +hb_font_set_funcs_data (hb_font_t *font, + void *font_data, + hb_destroy_func_t destroy); + + +void +hb_font_set_scale (hb_font_t *font, + int x_scale, + int y_scale); + +void +hb_font_get_scale (hb_font_t *font, + int *x_scale, + int *y_scale); + +/* + * A zero value means "no hinting in that direction" + */ +void +hb_font_set_ppem (hb_font_t *font, + unsigned int x_ppem, + unsigned int y_ppem); + +void +hb_font_get_ppem (hb_font_t *font, + unsigned int *x_ppem, + unsigned int *y_ppem); + + +HB_END_DECLS + +#endif /* HB_FONT_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.cc new file mode 100644 index 00000000000..6198185e9e4 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.cc @@ -0,0 +1,493 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2009 Keith Stribley + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +#include "hb-ft.h" + +#include "hb-font-private.hh" + +#include FT_ADVANCES_H +#include FT_TRUETYPE_TABLES_H + + + +#ifndef HB_DEBUG_FT +#define HB_DEBUG_FT (HB_DEBUG+0) +#endif + + +/* TODO: + * + * In general, this file does a fine job of what it's supposed to do. + * There are, however, things that need more work: + * + * - We don't handle any load_flags. That definitely has API implications. :( + * I believe hb_ft_font_create() should take load_flags input. + * In particular, FT_Get_Advance() without the NO_HINTING flag seems to be + * buggy. + * + * - We don't handle / allow for emboldening / obliqueing. + * + * - Rounding, etc? + * + * - In the future, we should add constructors to create fonts in font space. + * + * - I believe transforms are not correctly implemented. FreeType does not + * provide any API to get to the transform/delta set on the face. :( + * + * - Always use FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH? + * + * - FT_Load_Glyph() is exteremely costly. Do something about it? + */ + + +static hb_bool_t +hb_ft_get_glyph (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) + +{ + FT_Face ft_face = (FT_Face) font_data; + +#ifdef HAVE_FT_FACE_GETCHARVARIANTINDEX + if (unlikely (variation_selector)) { + *glyph = FT_Face_GetCharVariantIndex (ft_face, unicode, variation_selector); + if (*glyph) + return true; + } +#endif + + *glyph = FT_Get_Char_Index (ft_face, unicode); + return *glyph != 0; +} + +static hb_position_t +hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + int load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING; + FT_Fixed v; + + if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, &v))) + return 0; + + return v >> 10; +} + +static hb_position_t +hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + int load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING | FT_LOAD_VERTICAL_LAYOUT; + FT_Fixed v; + + if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, &v))) + return 0; + + /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates + * have a Y growing upward. Hence the extra negation. */ + return -v >> 10; +} + +static hb_bool_t +hb_ft_get_glyph_h_origin (hb_font_t *font HB_UNUSED, + void *font_data HB_UNUSED, + hb_codepoint_t glyph HB_UNUSED, + hb_position_t *x HB_UNUSED, + hb_position_t *y HB_UNUSED, + void *user_data HB_UNUSED) +{ + /* We always work in the horizontal coordinates. */ + return true; +} + +static hb_bool_t +hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + int load_flags = FT_LOAD_DEFAULT; + + if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) + return false; + + /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates + * have a Y growing upward. Hence the extra negation. */ + *x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBearingX; + *y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBearingY); + + return true; +} + +static hb_position_t +hb_ft_get_glyph_h_kerning (hb_font_t *font, + void *font_data, + hb_codepoint_t left_glyph, + hb_codepoint_t right_glyph, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + FT_Vector kerningv; + + FT_Kerning_Mode mode = font->x_ppem ? FT_KERNING_DEFAULT : FT_KERNING_UNFITTED; + if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, mode, &kerningv)) + return 0; + + return kerningv.x; +} + +static hb_position_t +hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED, + void *font_data HB_UNUSED, + hb_codepoint_t top_glyph HB_UNUSED, + hb_codepoint_t bottom_glyph HB_UNUSED, + void *user_data HB_UNUSED) +{ + /* FreeType API doesn't support vertical kerning */ + return 0; +} + +static hb_bool_t +hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + int load_flags = FT_LOAD_DEFAULT; + + if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) + return false; + + extents->x_bearing = ft_face->glyph->metrics.horiBearingX; + extents->y_bearing = ft_face->glyph->metrics.horiBearingY; + extents->width = ft_face->glyph->metrics.width; + extents->height = -ft_face->glyph->metrics.height; + return true; +} + +static hb_bool_t +hb_ft_get_glyph_contour_point (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + unsigned int point_index, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + int load_flags = FT_LOAD_DEFAULT; + + if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) + return false; + + if (unlikely (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)) + return false; + + if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points)) + return false; + + *x = ft_face->glyph->outline.points[point_index].x; + *y = ft_face->glyph->outline.points[point_index].y; + + return true; +} + +static hb_bool_t +hb_ft_get_glyph_name (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + char *name, unsigned int size, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + + hb_bool_t ret = !FT_Get_Glyph_Name (ft_face, glyph, name, size); + if (!ret || (size && !*name)) + snprintf (name, size, "gid%u", glyph); + + return ret; +} + +static hb_bool_t +hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED, + void *font_data, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) +{ + FT_Face ft_face = (FT_Face) font_data; + + if (len < 0) + *glyph = FT_Get_Name_Index (ft_face, (FT_String *) name); + else { + /* Make a nul-terminated version. */ + char buf[128]; + len = MIN (len, (int) sizeof (buf) - 1); + strncpy (buf, name, len); + buf[len] = '\0'; + *glyph = FT_Get_Name_Index (ft_face, buf); + } + + return *glyph != 0; +} + + +static hb_font_funcs_t * +_hb_ft_get_font_funcs (void) +{ + static const hb_font_funcs_t ft_ffuncs = { + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + { +#define HB_FONT_FUNC_IMPLEMENT(name) hb_ft_get_##name, + HB_FONT_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_FONT_FUNC_IMPLEMENT + } + }; + + return const_cast (&ft_ffuncs); +} + + +static hb_blob_t * +reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) +{ + FT_Face ft_face = (FT_Face) user_data; + FT_Byte *buffer; + FT_ULong length = 0; + FT_Error error; + + /* Note: FreeType like HarfBuzz uses the NONE tag for fetching the entire blob */ + + error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length); + if (error) + return NULL; + + buffer = (FT_Byte *) malloc (length); + if (buffer == NULL) + return NULL; + + error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length); + if (error) + return NULL; + + return hb_blob_create ((const char *) buffer, length, + HB_MEMORY_MODE_WRITABLE, + buffer, free); +} + + +hb_face_t * +hb_ft_face_create (FT_Face ft_face, + hb_destroy_func_t destroy) +{ + hb_face_t *face; + + if (ft_face->stream->read == NULL) { + hb_blob_t *blob; + + blob = hb_blob_create ((const char *) ft_face->stream->base, + (unsigned int) ft_face->stream->size, + /* TODO: We assume that it's mmap()'ed, but FreeType code + * suggests that there are cases we reach here but font is + * not mmapped. For example, when mmap() fails. No idea + * how to deal with it better here. */ + HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE, + ft_face, destroy); + face = hb_face_create (blob, ft_face->face_index); + hb_blob_destroy (blob); + } else { + face = hb_face_create_for_tables (reference_table, ft_face, destroy); + } + + hb_face_set_index (face, ft_face->face_index); + hb_face_set_upem (face, ft_face->units_per_EM); + + return face; +} + +static void +hb_ft_face_finalize (FT_Face ft_face) +{ + hb_face_destroy ((hb_face_t *) ft_face->generic.data); +} + +hb_face_t * +hb_ft_face_create_cached (FT_Face ft_face) +{ + if (unlikely (!ft_face->generic.data || ft_face->generic.finalizer != (FT_Generic_Finalizer) hb_ft_face_finalize)) + { + if (ft_face->generic.finalizer) + ft_face->generic.finalizer (ft_face); + + ft_face->generic.data = hb_ft_face_create (ft_face, NULL); + ft_face->generic.finalizer = (FT_Generic_Finalizer) hb_ft_face_finalize; + } + + return hb_face_reference ((hb_face_t *) ft_face->generic.data); +} + +static void +_do_nothing (void) +{ +} + + +hb_font_t * +hb_ft_font_create (FT_Face ft_face, + hb_destroy_func_t destroy) +{ + hb_font_t *font; + hb_face_t *face; + + face = hb_ft_face_create (ft_face, destroy); + font = hb_font_create (face); + hb_face_destroy (face); + hb_font_set_funcs (font, + _hb_ft_get_font_funcs (), + ft_face, (hb_destroy_func_t) _do_nothing); + hb_font_set_scale (font, + ((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM) >> 16, + ((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM) >> 16); + hb_font_set_ppem (font, + ft_face->size->metrics.x_ppem, + ft_face->size->metrics.y_ppem); + + return font; +} + + +/* Thread-safe, lock-free, FT_Library */ + +static FT_Library ft_library; + +static +void free_ft_library (void) +{ + FT_Done_FreeType (ft_library); +} + +static FT_Library +get_ft_library (void) +{ +retry: + FT_Library library = (FT_Library) hb_atomic_ptr_get (&ft_library); + + if (unlikely (!library)) + { + /* Not found; allocate one. */ + if (FT_Init_FreeType (&library)) + return NULL; + + if (!hb_atomic_ptr_cmpexch (&ft_library, NULL, library)) { + FT_Done_FreeType (library); + goto retry; + } + +#ifdef HAVE_ATEXIT + atexit (free_ft_library); /* First person registers atexit() callback. */ +#endif + } + + return library; +} + +static void +_release_blob (FT_Face ft_face) +{ + hb_blob_destroy ((hb_blob_t *) ft_face->generic.data); +} + +void +hb_ft_font_set_funcs (hb_font_t *font) +{ + hb_blob_t *blob = hb_face_reference_blob (font->face); + unsigned int blob_length; + const char *blob_data = hb_blob_get_data (blob, &blob_length); + if (unlikely (!blob_length)) + DEBUG_MSG (FT, font, "Font face has empty blob"); + + FT_Face ft_face = NULL; + FT_Error err = FT_New_Memory_Face (get_ft_library (), + (const FT_Byte *) blob_data, + blob_length, + hb_face_get_index (font->face), + &ft_face); + + if (unlikely (err)) { + hb_blob_destroy (blob); + DEBUG_MSG (FT, font, "Font face FT_New_Memory_Face() failed"); + return; + } + + FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE); + + assert (font->y_scale >= 0); + FT_Set_Char_Size (ft_face, + font->x_scale, font->y_scale, + 0, 0); +#if 0 + font->x_ppem * 72 * 64 / font->x_scale, + font->y_ppem * 72 * 64 / font->y_scale); +#endif + + ft_face->generic.data = blob; + ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob; + + hb_font_set_funcs (font, + _hb_ft_get_font_funcs (), + ft_face, + (hb_destroy_func_t) FT_Done_Face); +} + +FT_Face +hb_ft_font_get_face (hb_font_t *font) +{ + if (font->destroy == (hb_destroy_func_t) FT_Done_Face || + font->destroy == (hb_destroy_func_t) _do_nothing) + return (FT_Face) font->user_data; + + return NULL; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.h new file mode 100644 index 00000000000..696251e143f --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ft.h @@ -0,0 +1,62 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + */ + +#ifndef HB_FT_H +#define HB_FT_H + +#include "hb.h" + +#include +#include FT_FREETYPE_H + +HB_BEGIN_DECLS + +/* Note: FreeType is not thread-safe. Hence, these functions are not either. */ + +hb_face_t * +hb_ft_face_create (FT_Face ft_face, + hb_destroy_func_t destroy); + +hb_face_t * +hb_ft_face_create_cached (FT_Face ft_face); + +hb_font_t * +hb_ft_font_create (FT_Face ft_face, + hb_destroy_func_t destroy); + + + +/* Makes an hb_font_t use FreeType internally to implement font functions. */ +void +hb_ft_font_set_funcs (hb_font_t *font); + +FT_Face +hb_ft_font_get_face (hb_font_t *font); + + +HB_END_DECLS + +#endif /* HB_FT_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.cc new file mode 100644 index 00000000000..676e6601628 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.cc @@ -0,0 +1,384 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +#include "hb-glib.h" + +#include "hb-unicode-private.hh" + + +#if !GLIB_CHECK_VERSION(2,29,14) +static const hb_script_t +glib_script_to_script[] = +{ + HB_SCRIPT_COMMON, + HB_SCRIPT_INHERITED, + HB_SCRIPT_ARABIC, + HB_SCRIPT_ARMENIAN, + HB_SCRIPT_BENGALI, + HB_SCRIPT_BOPOMOFO, + HB_SCRIPT_CHEROKEE, + HB_SCRIPT_COPTIC, + HB_SCRIPT_CYRILLIC, + HB_SCRIPT_DESERET, + HB_SCRIPT_DEVANAGARI, + HB_SCRIPT_ETHIOPIC, + HB_SCRIPT_GEORGIAN, + HB_SCRIPT_GOTHIC, + HB_SCRIPT_GREEK, + HB_SCRIPT_GUJARATI, + HB_SCRIPT_GURMUKHI, + HB_SCRIPT_HAN, + HB_SCRIPT_HANGUL, + HB_SCRIPT_HEBREW, + HB_SCRIPT_HIRAGANA, + HB_SCRIPT_KANNADA, + HB_SCRIPT_KATAKANA, + HB_SCRIPT_KHMER, + HB_SCRIPT_LAO, + HB_SCRIPT_LATIN, + HB_SCRIPT_MALAYALAM, + HB_SCRIPT_MONGOLIAN, + HB_SCRIPT_MYANMAR, + HB_SCRIPT_OGHAM, + HB_SCRIPT_OLD_ITALIC, + HB_SCRIPT_ORIYA, + HB_SCRIPT_RUNIC, + HB_SCRIPT_SINHALA, + HB_SCRIPT_SYRIAC, + HB_SCRIPT_TAMIL, + HB_SCRIPT_TELUGU, + HB_SCRIPT_THAANA, + HB_SCRIPT_THAI, + HB_SCRIPT_TIBETAN, + HB_SCRIPT_CANADIAN_ABORIGINAL, + HB_SCRIPT_YI, + HB_SCRIPT_TAGALOG, + HB_SCRIPT_HANUNOO, + HB_SCRIPT_BUHID, + HB_SCRIPT_TAGBANWA, + + /* Unicode-4.0 additions */ + HB_SCRIPT_BRAILLE, + HB_SCRIPT_CYPRIOT, + HB_SCRIPT_LIMBU, + HB_SCRIPT_OSMANYA, + HB_SCRIPT_SHAVIAN, + HB_SCRIPT_LINEAR_B, + HB_SCRIPT_TAI_LE, + HB_SCRIPT_UGARITIC, + + /* Unicode-4.1 additions */ + HB_SCRIPT_NEW_TAI_LUE, + HB_SCRIPT_BUGINESE, + HB_SCRIPT_GLAGOLITIC, + HB_SCRIPT_TIFINAGH, + HB_SCRIPT_SYLOTI_NAGRI, + HB_SCRIPT_OLD_PERSIAN, + HB_SCRIPT_KHAROSHTHI, + + /* Unicode-5.0 additions */ + HB_SCRIPT_UNKNOWN, + HB_SCRIPT_BALINESE, + HB_SCRIPT_CUNEIFORM, + HB_SCRIPT_PHOENICIAN, + HB_SCRIPT_PHAGS_PA, + HB_SCRIPT_NKO, + + /* Unicode-5.1 additions */ + HB_SCRIPT_KAYAH_LI, + HB_SCRIPT_LEPCHA, + HB_SCRIPT_REJANG, + HB_SCRIPT_SUNDANESE, + HB_SCRIPT_SAURASHTRA, + HB_SCRIPT_CHAM, + HB_SCRIPT_OL_CHIKI, + HB_SCRIPT_VAI, + HB_SCRIPT_CARIAN, + HB_SCRIPT_LYCIAN, + HB_SCRIPT_LYDIAN, + + /* Unicode-5.2 additions */ + HB_SCRIPT_AVESTAN, + HB_SCRIPT_BAMUM, + HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, + HB_SCRIPT_IMPERIAL_ARAMAIC, + HB_SCRIPT_INSCRIPTIONAL_PAHLAVI, + HB_SCRIPT_INSCRIPTIONAL_PARTHIAN, + HB_SCRIPT_JAVANESE, + HB_SCRIPT_KAITHI, + HB_SCRIPT_TAI_THAM, + HB_SCRIPT_LISU, + HB_SCRIPT_MEETEI_MAYEK, + HB_SCRIPT_OLD_SOUTH_ARABIAN, + HB_SCRIPT_OLD_TURKIC, + HB_SCRIPT_SAMARITAN, + HB_SCRIPT_TAI_VIET, + + /* Unicode-6.0 additions */ + HB_SCRIPT_BATAK, + HB_SCRIPT_BRAHMI, + HB_SCRIPT_MANDAIC, + + /* Unicode-6.1 additions */ + HB_SCRIPT_CHAKMA, + HB_SCRIPT_MEROITIC_CURSIVE, + HB_SCRIPT_MEROITIC_HIEROGLYPHS, + HB_SCRIPT_MIAO, + HB_SCRIPT_SHARADA, + HB_SCRIPT_SORA_SOMPENG, + HB_SCRIPT_TAKRI +}; +#endif + +hb_script_t +hb_glib_script_to_script (GUnicodeScript script) +{ +#if GLIB_CHECK_VERSION(2,29,14) + return (hb_script_t) g_unicode_script_to_iso15924 (script); +#else + if (likely ((unsigned int) script < ARRAY_LENGTH (glib_script_to_script))) + return glib_script_to_script[script]; + + if (unlikely (script == G_UNICODE_SCRIPT_INVALID_CODE)) + return HB_SCRIPT_INVALID; + + return HB_SCRIPT_UNKNOWN; +#endif +} + +GUnicodeScript +hb_glib_script_from_script (hb_script_t script) +{ +#if GLIB_CHECK_VERSION(2,29,14) + return g_unicode_script_from_iso15924 (script); +#else + unsigned int count = ARRAY_LENGTH (glib_script_to_script); + for (unsigned int i = 0; i < count; i++) + if (glib_script_to_script[i] == script) + return (GUnicodeScript) i; + + if (unlikely (script == HB_SCRIPT_INVALID)) + return G_UNICODE_SCRIPT_INVALID_CODE; + + return G_UNICODE_SCRIPT_UNKNOWN; +#endif +} + + +static hb_unicode_combining_class_t +hb_glib_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) + +{ + return (hb_unicode_combining_class_t) g_unichar_combining_class (unicode); +} + +static unsigned int +hb_glib_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) +{ + return g_unichar_iswide (unicode) ? 2 : 1; +} + +static hb_unicode_general_category_t +hb_glib_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) + +{ + /* hb_unicode_general_category_t and GUnicodeType are identical */ + return (hb_unicode_general_category_t) g_unichar_type (unicode); +} + +static hb_codepoint_t +hb_glib_unicode_mirroring (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) +{ + g_unichar_get_mirror_char (unicode, &unicode); + return unicode; +} + +static hb_script_t +hb_glib_unicode_script (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) +{ + return hb_glib_script_to_script (g_unichar_get_script (unicode)); +} + +static hb_bool_t +hb_glib_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t a, + hb_codepoint_t b, + hb_codepoint_t *ab, + void *user_data HB_UNUSED) +{ +#if GLIB_CHECK_VERSION(2,29,12) + return g_unichar_compose (a, b, ab); +#endif + + /* We don't ifdef-out the fallback code such that compiler always + * sees it and makes sure it's compilable. */ + + gchar utf8[12]; + gchar *normalized; + int len; + hb_bool_t ret; + + len = g_unichar_to_utf8 (a, utf8); + len += g_unichar_to_utf8 (b, utf8 + len); + normalized = g_utf8_normalize (utf8, len, G_NORMALIZE_NFC); + len = g_utf8_strlen (normalized, -1); + if (unlikely (!len)) + return false; + + if (len == 1) { + *ab = g_utf8_get_char (normalized); + ret = true; + } else { + ret = false; + } + + g_free (normalized); + return ret; +} + +static hb_bool_t +hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t ab, + hb_codepoint_t *a, + hb_codepoint_t *b, + void *user_data HB_UNUSED) +{ +#if GLIB_CHECK_VERSION(2,29,12) + return g_unichar_decompose (ab, a, b); +#endif + + /* We don't ifdef-out the fallback code such that compiler always + * sees it and makes sure it's compilable. */ + + gchar utf8[6]; + gchar *normalized; + int len; + hb_bool_t ret; + + len = g_unichar_to_utf8 (ab, utf8); + normalized = g_utf8_normalize (utf8, len, G_NORMALIZE_NFD); + len = g_utf8_strlen (normalized, -1); + if (unlikely (!len)) + return false; + + if (len == 1) { + *a = g_utf8_get_char (normalized); + *b = 0; + ret = *a != ab; + } else if (len == 2) { + *a = g_utf8_get_char (normalized); + *b = g_utf8_get_char (g_utf8_next_char (normalized)); + /* Here's the ugly part: if ab decomposes to a single character and + * that character decomposes again, we have to detect that and undo + * the second part :-(. */ + gchar *recomposed = g_utf8_normalize (normalized, -1, G_NORMALIZE_NFC); + hb_codepoint_t c = g_utf8_get_char (recomposed); + if (c != ab && c != *a) { + *a = c; + *b = 0; + } + g_free (recomposed); + ret = true; + } else { + /* If decomposed to more than two characters, take the last one, + * and recompose the rest to get the first component. */ + gchar *end = g_utf8_offset_to_pointer (normalized, len - 1); + gchar *recomposed; + *b = g_utf8_get_char (end); + recomposed = g_utf8_normalize (normalized, end - normalized, G_NORMALIZE_NFC); + /* We expect that recomposed has exactly one character now. */ + *a = g_utf8_get_char (recomposed); + g_free (recomposed); + ret = true; + } + + g_free (normalized); + return ret; +} + +static unsigned int +hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t u, + hb_codepoint_t *decomposed, + void *user_data HB_UNUSED) +{ +#if GLIB_CHECK_VERSION(2,29,12) + return g_unichar_fully_decompose (u, TRUE, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN); +#endif + + /* If the user doesn't have GLib >= 2.29.12 we have to perform + * a round trip to UTF-8 and the associated memory management dance. */ + gchar utf8[6]; + gchar *utf8_decomposed, *c; + gsize utf8_len, utf8_decomposed_len, i; + + /* Convert @u to UTF-8 and normalise it in NFKD mode. This performs the compatibility decomposition. */ + utf8_len = g_unichar_to_utf8 (u, utf8); + utf8_decomposed = g_utf8_normalize (utf8, utf8_len, G_NORMALIZE_NFKD); + utf8_decomposed_len = g_utf8_strlen (utf8_decomposed, -1); + + assert (utf8_decomposed_len <= HB_UNICODE_MAX_DECOMPOSITION_LEN); + + for (i = 0, c = utf8_decomposed; i < utf8_decomposed_len; i++, c = g_utf8_next_char (c)) + *decomposed++ = g_utf8_get_char (c); + + g_free (utf8_decomposed); + + return utf8_decomposed_len; +} + +hb_unicode_funcs_t * +hb_glib_get_unicode_funcs (void) +{ + static const hb_unicode_funcs_t _hb_glib_unicode_funcs = { + HB_OBJECT_HEADER_STATIC, + + NULL, /* parent */ + true, /* immutable */ + { +#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name, + HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_UNICODE_FUNC_IMPLEMENT + } + }; + + return const_cast (&_hb_glib_unicode_funcs); +} + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.h new file mode 100644 index 00000000000..63a9d3366c5 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-glib.h @@ -0,0 +1,52 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_GLIB_H +#define HB_GLIB_H + +#include "hb.h" + +#include + +HB_BEGIN_DECLS + + +hb_script_t +hb_glib_script_to_script (GUnicodeScript script); + +GUnicodeScript +hb_glib_script_from_script (hb_script_t script); + + +hb_unicode_funcs_t * +hb_glib_get_unicode_funcs (void); + + +HB_END_DECLS + +#endif /* HB_GLIB_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-enums.cc.tmpl b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-enums.cc.tmpl new file mode 100644 index 00000000000..05abd898d4f --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-enums.cc.tmpl @@ -0,0 +1,74 @@ +/*** BEGIN file-header ***/ +/* + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +/* g++ didn't like older gtype.h gcc-only code path. */ +#include +#if !GLIB_CHECK_VERSION(2,29,16) +#undef __GNUC__ +#undef __GNUC_MINOR__ +#define __GNUC__ 2 +#define __GNUC_MINOR__ 6 +#endif + +#include "hb-gobject.h" + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from "@filename@" */ +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +inline static /* TODO(behdad) disable these for now until we fix them... */ +GType +@enum_name@_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + +/*** END value-tail ***/ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-structs.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-structs.cc new file mode 100644 index 00000000000..cec48542275 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject-structs.cc @@ -0,0 +1,63 @@ +/* + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +/* g++ didn't like older gtype.h gcc-only code path. */ +#include +#if !GLIB_CHECK_VERSION(2,29,16) +#undef __GNUC__ +#undef __GNUC_MINOR__ +#define __GNUC__ 2 +#define __GNUC_MINOR__ 6 +#endif + +#include "hb-gobject.h" + +#define _HB_DEFINE_BOXED_TYPE(Name,underscore_name,copy_func,free_func) \ +GType \ +underscore_name##_get_type (void) \ +{ \ + static volatile gsize type = 0; \ + if (g_once_init_enter (&type)) { \ + GType t = g_boxed_type_register_static (g_intern_static_string (#Name), \ + (GBoxedCopyFunc) copy_func, \ + (GBoxedFreeFunc) free_func); \ + g_once_init_leave (&type, t); \ + } \ + return type; \ +} + +#define HB_DEFINE_BOXED_TYPE(name) \ + _HB_DEFINE_BOXED_TYPE (hb_##name, hb_gobject_##name, hb_##name##_reference, hb_##name##_destroy); + +HB_DEFINE_BOXED_TYPE (buffer) +HB_DEFINE_BOXED_TYPE (blob) +HB_DEFINE_BOXED_TYPE (face) +HB_DEFINE_BOXED_TYPE (font) +HB_DEFINE_BOXED_TYPE (font_funcs) +HB_DEFINE_BOXED_TYPE (unicode_funcs) + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject.h new file mode 100644 index 00000000000..4f23fdd385d --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-gobject.h @@ -0,0 +1,69 @@ +/* + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_GOBJECT_H +#define HB_GOBJECT_H + +#include "hb.h" + +#include + +HB_BEGIN_DECLS + + +/* Objects */ + +#define HB_GOBJECT_TYPE_BLOB hb_gobject_blob_get_type () +GType +hb_gobject_blob_get_type (void); + +#define HB_GOBJECT_TYPE_BUFFER hb_gobject_buffer_get_type () +GType +hb_gobject_buffer_get_type (void); + +#define HB_GOBJECT_TYPE_FACE hb_gobject_face_get_type () +GType +hb_gobject_face_get_type (void); + +#define HB_GOBJECT_TYPE_FONT hb_gobject_font_get_type () +GType +hb_gobject_font_get_type (void); + +#define HB_GOBJECT_TYPE_FONT_FUNCS hb_gobject_font_funcs_get_type () +GType +hb_gobject_font_funcs_get_type (void); + +#define HB_GOBJECT_TYPE_UNICODE_FUNCS hb_gobject_unicode_funcs_get_type () +GType +hb_gobject_unicode_funcs_get_type (void); + + +/* Enums */ + + +HB_END_DECLS + +#endif /* HB_GOBJECT_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.cc new file mode 100644 index 00000000000..16ef9a4dabe --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.cc @@ -0,0 +1,370 @@ +/* + * Copyright © 2011 Martin Hosken + * Copyright © 2011 SIL International + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#define HB_SHAPER graphite2 +#define hb_graphite2_shaper_font_data_t gr_font +#include "hb-shaper-impl-private.hh" + +#include +#include + +#include "hb-graphite2.h" + +#include "hb-ot-tag.h" + + +HB_SHAPER_DATA_ENSURE_DECLARE(graphite2, face) +HB_SHAPER_DATA_ENSURE_DECLARE(graphite2, font) + + +/* + * shaper face data + */ + +typedef struct hb_graphite2_tablelist_t { + struct hb_graphite2_tablelist_t *next; + hb_blob_t *blob; + unsigned int tag; +} hb_graphite2_tablelist_t; + +struct hb_graphite2_shaper_face_data_t { + hb_face_t *face; + gr_face *grface; + hb_graphite2_tablelist_t *tlist; +}; + +static const void *hb_graphite2_get_table (const void *data, unsigned int tag, size_t *len) +{ + hb_graphite2_shaper_face_data_t *face_data = (hb_graphite2_shaper_face_data_t *) data; + hb_graphite2_tablelist_t *tlist = face_data->tlist; + + hb_blob_t *blob = NULL; + + for (hb_graphite2_tablelist_t *p = tlist; p; p = p->next) + if (p->tag == tag) { + blob = p->blob; + break; + } + + if (unlikely (!blob)) + { + blob = face_data->face->reference_table (tag); + + hb_graphite2_tablelist_t *p = (hb_graphite2_tablelist_t *) calloc (1, sizeof (hb_graphite2_tablelist_t)); + if (unlikely (!p)) { + hb_blob_destroy (blob); + return NULL; + } + p->blob = blob; + p->tag = tag; + + /* TODO Not thread-safe, but fairly harmless. + * We can do the double-chcked pointer cmpexch thing here. */ + p->next = face_data->tlist; + face_data->tlist = p; + } + + unsigned int tlen; + const char *d = hb_blob_get_data (blob, &tlen); + *len = tlen; + return d; +} + +hb_graphite2_shaper_face_data_t * +_hb_graphite2_shaper_face_data_create (hb_face_t *face) +{ + hb_blob_t *silf_blob = face->reference_table (HB_GRAPHITE2_TAG_SILF); + /* Umm, we just reference the table to check whether it exists. + * Maybe add better API for this? */ + if (!hb_blob_get_length (silf_blob)) + { + hb_blob_destroy (silf_blob); + return NULL; + } + hb_blob_destroy (silf_blob); + + hb_graphite2_shaper_face_data_t *data = (hb_graphite2_shaper_face_data_t *) calloc (1, sizeof (hb_graphite2_shaper_face_data_t)); + if (unlikely (!data)) + hb_blob_destroy (silf_blob); + + data->face = face; + data->grface = gr_make_face (data, &hb_graphite2_get_table, gr_face_preloadAll); + + if (unlikely (!data->grface)) { + free (data); + return NULL; + } + + return data; +} + +void +_hb_graphite2_shaper_face_data_destroy (hb_graphite2_shaper_face_data_t *data) +{ + hb_graphite2_tablelist_t *tlist = data->tlist; + + while (tlist) + { + hb_graphite2_tablelist_t *old = tlist; + hb_blob_destroy (tlist->blob); + tlist = tlist->next; + free (old); + } + + gr_face_destroy (data->grface); + + free (data); +} + +gr_face * +hb_graphite2_face_get_gr_face (hb_face_t *face) +{ + if (unlikely (!hb_graphite2_shaper_face_data_ensure (face))) return NULL; + return HB_SHAPER_DATA_GET (face)->grface; +} + + +/* + * shaper font data + */ + +static float hb_graphite2_get_advance (const void *hb_font, unsigned short gid) +{ + return ((hb_font_t *) hb_font)->get_glyph_h_advance (gid); +} + +hb_graphite2_shaper_font_data_t * +_hb_graphite2_shaper_font_data_create (hb_font_t *font) +{ + if (unlikely (!hb_graphite2_shaper_face_data_ensure (font->face))) return NULL; + + hb_face_t *face = font->face; + hb_graphite2_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + + return gr_make_font_with_advance_fn (font->x_scale, font, &hb_graphite2_get_advance, face_data->grface); +} + +void +_hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data) +{ + gr_font_destroy (data); +} + +gr_font * +hb_graphite2_font_get_gr_font (hb_font_t *font) +{ + if (unlikely (!hb_graphite2_shaper_font_data_ensure (font))) return NULL; + return HB_SHAPER_DATA_GET (font); +} + + +/* + * shaper shape_plan data + */ + +struct hb_graphite2_shaper_shape_plan_data_t {}; + +hb_graphite2_shaper_shape_plan_data_t * +_hb_graphite2_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, + const hb_feature_t *user_features HB_UNUSED, + unsigned int num_user_features HB_UNUSED) +{ + return (hb_graphite2_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shaper_shape_plan_data_t *data HB_UNUSED) +{ +} + + +/* + * shaper + */ + +struct hb_graphite2_cluster_t { + unsigned int base_char; + unsigned int num_chars; + unsigned int base_glyph; + unsigned int num_glyphs; +}; + +hb_bool_t +_hb_graphite2_shape (hb_shape_plan_t *shape_plan, + hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features) +{ + hb_face_t *face = font->face; + gr_face *grface = HB_SHAPER_DATA_GET (face)->grface; + gr_font *grfont = HB_SHAPER_DATA_GET (font); + + const char *lang = hb_language_to_string (hb_buffer_get_language (buffer)); + const char *lang_end = strchr (lang, '-'); + int lang_len = lang_end ? lang_end - lang : -1; + gr_feature_val *feats = gr_face_featureval_for_lang (grface, lang ? hb_tag_from_string (lang, lang_len) : 0); + + while (num_features--) + { + const gr_feature_ref *fref = gr_face_find_fref (grface, features->tag); + if (fref) + gr_fref_set_feature_value (fref, features->value, feats); + features++; + } + + gr_segment *seg = NULL; + const gr_slot *is; + unsigned int ci = 0, ic = 0; + float curradvx = 0., curradvy = 0.; + + unsigned int scratch_size; + char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size); + +#define ALLOCATE_ARRAY(Type, name, len) \ + Type *name = (Type *) scratch; \ + scratch += (len) * sizeof ((name)[0]); \ + scratch_size -= (len) * sizeof ((name)[0]); + + ALLOCATE_ARRAY (uint32_t, chars, buffer->len); + + for (unsigned int i = 0; i < buffer->len; ++i) + chars[i] = buffer->info[i].codepoint; + + hb_tag_t script_tag[2]; + hb_ot_tags_from_script (hb_buffer_get_script (buffer), &script_tag[0], &script_tag[1]); + + seg = gr_make_seg (grfont, grface, + script_tag[1] == HB_TAG_NONE ? script_tag[0] : script_tag[1], + feats, + gr_utf32, chars, buffer->len, + 2 | (hb_buffer_get_direction (buffer) == HB_DIRECTION_RTL ? 1 : 0)); + + if (unlikely (!seg)) { + if (feats) gr_featureval_destroy (feats); + return false; + } + + unsigned int glyph_count = gr_seg_n_slots (seg); + if (unlikely (!glyph_count)) { + if (feats) gr_featureval_destroy (feats); + gr_seg_destroy (seg); + return false; + } + + scratch = (char *) buffer->get_scratch_buffer (&scratch_size); + while ((sizeof (hb_graphite2_cluster_t) * buffer->len + + sizeof (hb_codepoint_t) * glyph_count) > scratch_size) + { + buffer->ensure (buffer->allocated * 2); + if (unlikely (buffer->in_error)) { + if (feats) gr_featureval_destroy (feats); + gr_seg_destroy (seg); + return false; + } + scratch = (char *) buffer->get_scratch_buffer (&scratch_size); + } + + ALLOCATE_ARRAY (hb_graphite2_cluster_t, clusters, buffer->len); + ALLOCATE_ARRAY (hb_codepoint_t, gids, glyph_count); + + memset (clusters, 0, sizeof (clusters[0]) * buffer->len); + + hb_codepoint_t *pg = gids; + for (is = gr_seg_first_slot (seg), ic = 0; is; is = gr_slot_next_in_segment (is), ic++) + { + unsigned int before = gr_slot_before (is); + unsigned int after = gr_slot_after (is); + *pg = gr_slot_gid (is); + pg++; + while (clusters[ci].base_char > before && ci) + { + clusters[ci-1].num_chars += clusters[ci].num_chars; + clusters[ci-1].num_glyphs += clusters[ci].num_glyphs; + ci--; + } + + if (gr_slot_can_insert_before (is) && clusters[ci].num_chars && before >= clusters[ci].base_char + clusters[ci].num_chars) + { + hb_graphite2_cluster_t *c = clusters + ci + 1; + c->base_char = clusters[ci].base_char + clusters[ci].num_chars; + c->num_chars = before - c->base_char; + c->base_glyph = ic; + c->num_glyphs = 0; + ci++; + } + clusters[ci].num_glyphs++; + + if (clusters[ci].base_char + clusters[ci].num_chars < after + 1) + clusters[ci].num_chars = after + 1 - clusters[ci].base_char; + } + ci++; + + //buffer->clear_output (); + for (unsigned int i = 0; i < ci; ++i) + { + for (unsigned int j = 0; j < clusters[i].num_glyphs; ++j) + { + hb_glyph_info_t *info = &buffer->info[clusters[i].base_glyph + j]; + info->codepoint = gids[clusters[i].base_glyph + j]; + info->cluster = gr_cinfo_base(gr_seg_cinfo(seg, clusters[i].base_char)); + } + } + buffer->len = glyph_count; + //buffer->swap_buffers (); + + if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) + curradvx = gr_seg_advance_X(seg); + + hb_glyph_position_t *pPos; + for (pPos = hb_buffer_get_glyph_positions (buffer, NULL), is = gr_seg_first_slot (seg); + is; pPos++, is = gr_slot_next_in_segment (is)) + { + pPos->x_offset = gr_slot_origin_X (is) - curradvx; + pPos->y_offset = gr_slot_origin_Y (is) - curradvy; + pPos->x_advance = gr_slot_advance_X (is, grface, grfont); + pPos->y_advance = gr_slot_advance_Y (is, grface, grfont); + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + curradvx -= pPos->x_advance; + pPos->x_offset = gr_slot_origin_X (is) - curradvx; + if (!HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + curradvx += pPos->x_advance; + pPos->y_offset = gr_slot_origin_Y (is) - curradvy; + curradvy += pPos->y_advance; + } + if (!HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx; + + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + hb_buffer_reverse_clusters (buffer); + + if (feats) gr_featureval_destroy (feats); + gr_seg_destroy (seg); + + return true; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.h new file mode 100644 index 00000000000..bea68f939b4 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-graphite2.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011 Martin Hosken + * Copyright (C) 2011 SIL International + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +#ifndef HB_GRAPHITE2_H +#define HB_GRAPHITE2_H + +#include "hb.h" + +HB_BEGIN_DECLS + + +#define HB_GRAPHITE2_TAG_SILF HB_TAG('S','i','l','f') + + +gr_face * +hb_graphite2_face_get_gr_face (hb_face_t *face); + +gr_font * +hb_graphite2_font_get_gr_font (hb_font_t *font); + + +HB_END_DECLS + +#endif /* HB_GRAPHITE2_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu-le.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu-le.cc new file mode 100644 index 00000000000..c05d330b957 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu-le.cc @@ -0,0 +1,215 @@ +/* + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#define HB_SHAPER icu_le +#define hb_icu_le_shaper_font_data_t PortableFontInstance +#include "hb-shaper-impl-private.hh" + +#include "hb-icu-le/PortableFontInstance.h" + +#include "layout/loengine.h" +#include "unicode/unistr.h" + +#include "hb-icu.h" + + +/* + * shaper face data + */ + +struct hb_icu_le_shaper_face_data_t {}; + +hb_icu_le_shaper_face_data_t * +_hb_icu_le_shaper_face_data_create (hb_face_t *face HB_UNUSED) +{ + return (hb_icu_le_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_icu_le_shaper_face_data_destroy (hb_icu_le_shaper_face_data_t *data HB_UNUSED) +{ +} + + +/* + * shaper font data + */ + +hb_icu_le_shaper_font_data_t * +_hb_icu_le_shaper_font_data_create (hb_font_t *font) +{ + LEErrorCode status = LE_NO_ERROR; + hb_icu_le_shaper_font_data_t *data = new PortableFontInstance (font->face, + font->x_scale, + font->y_scale, + status); + if (status != LE_NO_ERROR) { + delete (data); + return NULL; + } + + return data; +} + +void +_hb_icu_le_shaper_font_data_destroy (hb_icu_le_shaper_font_data_t *data) +{ + delete (data); +} + + +/* + * shaper shape_plan data + */ + +struct hb_icu_le_shaper_shape_plan_data_t {}; + +hb_icu_le_shaper_shape_plan_data_t * +_hb_icu_le_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, + const hb_feature_t *user_features, + unsigned int num_user_features) +{ + return (hb_icu_le_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_icu_le_shaper_shape_plan_data_destroy (hb_icu_le_shaper_shape_plan_data_t *data) +{ +} + + +/* + * shaper + */ + +hb_bool_t +_hb_icu_le_shape (hb_shape_plan_t *shape_plan, + hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features) +{ + LEFontInstance *font_instance = HB_SHAPER_DATA_GET (font); + le_int32 script_code = hb_icu_script_from_script (shape_plan->props.script); + le_int32 language_code = -1 /* TODO */; + le_int32 typography_flags = 3; /* Needed for ligatures and kerning */ + LEErrorCode status = LE_NO_ERROR; + le_engine *le = le_create ((const le_font *) font_instance, + script_code, + language_code, + typography_flags, + &status); + if (status != LE_NO_ERROR) + { le_close (le); return false; } + +retry: + + unsigned int scratch_size; + char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size); + +#define ALLOCATE_ARRAY(Type, name, len) \ + Type *name = (Type *) scratch; \ + scratch += (len) * sizeof ((name)[0]); \ + scratch_size -= (len) * sizeof ((name)[0]); + + ALLOCATE_ARRAY (LEUnicode, chars, buffer->len); + ALLOCATE_ARRAY (unsigned int, clusters, buffer->len); + + /* XXX Use UTF-16 decoder! */ + for (unsigned int i = 0; i < buffer->len; i++) { + chars[i] = buffer->info[i].codepoint; + clusters[i] = buffer->info[i].cluster; + } + + unsigned int glyph_count = le_layoutChars (le, + chars, + 0, + buffer->len, + buffer->len, + HB_DIRECTION_IS_BACKWARD (buffer->props.direction), + 0., 0., + &status); + if (status != LE_NO_ERROR) + { le_close (le); return false; } + + unsigned int num_glyphs = scratch_size / (sizeof (LEGlyphID) + + sizeof (le_int32) + + sizeof (float) * 2); + + if (unlikely (glyph_count >= num_glyphs || glyph_count > buffer->allocated)) { + buffer->ensure (buffer->allocated * 2); + if (buffer->in_error) + { le_close (le); return false; } + goto retry; + } + + ALLOCATE_ARRAY (LEGlyphID, glyphs, glyph_count); + ALLOCATE_ARRAY (le_int32, indices, glyph_count); + ALLOCATE_ARRAY (float, positions, glyph_count * 2 + 2); + + le_getGlyphs (le, glyphs, &status); + le_getCharIndices (le, indices, &status); + le_getGlyphPositions (le, positions, &status); + +#undef ALLOCATE_ARRAY + + /* Ok, we've got everything we need, now compose output buffer, + * very, *very*, carefully! */ + + unsigned int j = 0; + hb_glyph_info_t *info = buffer->info; + for (unsigned int i = 0; i < glyph_count; i++) + { + if (glyphs[i] >= 0xFFFE) + continue; + + info[j].codepoint = glyphs[i]; + info[j].cluster = clusters[indices[i]]; + + /* icu-le doesn't seem to have separate advance values. */ + info[j].mask = positions[2 * i + 2] - positions[2 * i]; + info[j].var1.u32 = 0; + info[j].var2.u32 = -positions[2 * i + 1]; + + j++; + } + buffer->len = j; + + buffer->clear_positions (); + + for (unsigned int i = 0; i < buffer->len; i++) { + hb_glyph_info_t *info = &buffer->info[i]; + hb_glyph_position_t *pos = &buffer->pos[i]; + + /* TODO vertical */ + pos->x_advance = info->mask; + pos->x_offset = info->var1.u32; + pos->y_offset = info->var2.u32; + } + + le_close (le); + return true; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.cc new file mode 100644 index 00000000000..c177be2c4b2 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.cc @@ -0,0 +1,372 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2009 Keith Stribley + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-private.hh" + +#include "hb-icu.h" + +#include "hb-unicode-private.hh" + +#include +#include +#include +#include + + +hb_script_t +hb_icu_script_to_script (UScriptCode script) +{ + if (unlikely (script == USCRIPT_INVALID_CODE)) + return HB_SCRIPT_INVALID; + + return hb_script_from_string (uscript_getShortName (script), -1); +} + +UScriptCode +hb_icu_script_from_script (hb_script_t script) +{ + if (unlikely (script == HB_SCRIPT_INVALID)) + return USCRIPT_INVALID_CODE; + + for (unsigned int i = 0; i < USCRIPT_CODE_LIMIT; i++) + if (unlikely (hb_icu_script_to_script ((UScriptCode) i) == script)) + return (UScriptCode) i; + + return USCRIPT_UNKNOWN; +} + + +static hb_unicode_combining_class_t +hb_icu_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) + +{ + return (hb_unicode_combining_class_t) u_getCombiningClass (unicode); +} + +static unsigned int +hb_icu_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) +{ + switch (u_getIntPropertyValue(unicode, UCHAR_EAST_ASIAN_WIDTH)) + { + case U_EA_WIDE: + case U_EA_FULLWIDTH: + return 2; + case U_EA_NEUTRAL: + case U_EA_AMBIGUOUS: + case U_EA_HALFWIDTH: + case U_EA_NARROW: + return 1; + } + return 1; +} + +static hb_unicode_general_category_t +hb_icu_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) +{ + switch (u_getIntPropertyValue(unicode, UCHAR_GENERAL_CATEGORY)) + { + case U_UNASSIGNED: return HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED; + + case U_UPPERCASE_LETTER: return HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER; + case U_LOWERCASE_LETTER: return HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER; + case U_TITLECASE_LETTER: return HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER; + case U_MODIFIER_LETTER: return HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER; + case U_OTHER_LETTER: return HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER; + + case U_NON_SPACING_MARK: return HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK; + case U_ENCLOSING_MARK: return HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK; + case U_COMBINING_SPACING_MARK: return HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK; + + case U_DECIMAL_DIGIT_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER; + case U_LETTER_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER; + case U_OTHER_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER; + + case U_SPACE_SEPARATOR: return HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR; + case U_LINE_SEPARATOR: return HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR; + case U_PARAGRAPH_SEPARATOR: return HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR; + + case U_CONTROL_CHAR: return HB_UNICODE_GENERAL_CATEGORY_CONTROL; + case U_FORMAT_CHAR: return HB_UNICODE_GENERAL_CATEGORY_FORMAT; + case U_PRIVATE_USE_CHAR: return HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE; + case U_SURROGATE: return HB_UNICODE_GENERAL_CATEGORY_SURROGATE; + + + case U_DASH_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION; + case U_START_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION; + case U_END_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION; + case U_CONNECTOR_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION; + case U_OTHER_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION; + + case U_MATH_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL; + case U_CURRENCY_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL; + case U_MODIFIER_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL; + case U_OTHER_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL; + + case U_INITIAL_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION; + case U_FINAL_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION; + } + + return HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED; +} + +static hb_codepoint_t +hb_icu_unicode_mirroring (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) +{ + return u_charMirror(unicode); +} + +static hb_script_t +hb_icu_unicode_script (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t unicode, + void *user_data HB_UNUSED) +{ + UErrorCode status = U_ZERO_ERROR; + UScriptCode scriptCode = uscript_getScript(unicode, &status); + + if (unlikely (U_FAILURE (status))) + return HB_SCRIPT_UNKNOWN; + + return hb_icu_script_to_script (scriptCode); +} + +#if U_ICU_VERSION_MAJOR_NUM >= 49 +static const UNormalizer2 *normalizer; +#endif + +static hb_bool_t +hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t a, + hb_codepoint_t b, + hb_codepoint_t *ab, + void *user_data HB_UNUSED) +{ +#if U_ICU_VERSION_MAJOR_NUM >= 49 + { + UChar32 ret = unorm2_composePair (normalizer, a, b); + if (ret < 0) return false; + *ab = ret; + return true; + } +#endif + + /* We don't ifdef-out the fallback code such that compiler always + * sees it and makes sure it's compilable. */ + + UChar utf16[4], normalized[5]; + unsigned int len; + hb_bool_t ret, err; + UErrorCode icu_err; + + len = 0; + err = false; + U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), a, err); + if (err) return false; + U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), b, err); + if (err) return false; + + icu_err = U_ZERO_ERROR; + len = unorm_normalize (utf16, len, UNORM_NFC, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); + if (U_FAILURE (icu_err)) + return false; + if (u_countChar32 (normalized, len) == 1) { + U16_GET_UNSAFE (normalized, 0, *ab); + ret = true; + } else { + ret = false; + } + + return ret; +} + +static hb_bool_t +hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t ab, + hb_codepoint_t *a, + hb_codepoint_t *b, + void *user_data HB_UNUSED) +{ +#if U_ICU_VERSION_MAJOR_NUM >= 49 + { + UChar decomposed[4]; + int len; + UErrorCode icu_err = U_ZERO_ERROR; + len = unorm2_getRawDecomposition (normalizer, ab, decomposed, + ARRAY_LENGTH (decomposed), &icu_err); + if (U_FAILURE (icu_err) || len < 0) return false; + + len = u_countChar32 (decomposed, len); + if (len == 1) { + U16_GET_UNSAFE (decomposed, 0, *a); + *b = 0; + return *a != ab; + } else if (len == 2) { + len =0; + U16_NEXT_UNSAFE (decomposed, len, *a); + U16_NEXT_UNSAFE (decomposed, len, *b); + } + return true; + } +#endif + + /* We don't ifdef-out the fallback code such that compiler always + * sees it and makes sure it's compilable. */ + + UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1]; + unsigned int len; + hb_bool_t ret, err; + UErrorCode icu_err; + + /* This function is a monster! Maybe it wasn't a good idea adding a + * pairwise decompose API... */ + /* Watchout for the dragons. Err, watchout for macros changing len. */ + + len = 0; + err = false; + U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), ab, err); + if (err) return false; + + icu_err = U_ZERO_ERROR; + len = unorm_normalize (utf16, len, UNORM_NFD, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); + if (U_FAILURE (icu_err)) + return false; + + len = u_countChar32 (normalized, len); + + if (len == 1) { + U16_GET_UNSAFE (normalized, 0, *a); + *b = 0; + ret = *a != ab; + } else if (len == 2) { + len =0; + U16_NEXT_UNSAFE (normalized, len, *a); + U16_NEXT_UNSAFE (normalized, len, *b); + + /* Here's the ugly part: if ab decomposes to a single character and + * that character decomposes again, we have to detect that and undo + * the second part :-(. */ + UChar recomposed[20]; + icu_err = U_ZERO_ERROR; + unorm_normalize (normalized, len, UNORM_NFC, 0, recomposed, ARRAY_LENGTH (recomposed), &icu_err); + if (U_FAILURE (icu_err)) + return false; + hb_codepoint_t c; + U16_GET_UNSAFE (recomposed, 0, c); + if (c != *a && c != ab) { + *a = c; + *b = 0; + } + ret = true; + } else { + /* If decomposed to more than two characters, take the last one, + * and recompose the rest to get the first component. */ + U16_PREV_UNSAFE (normalized, len, *b); /* Changes len in-place. */ + UChar recomposed[18 * 2]; + icu_err = U_ZERO_ERROR; + len = unorm_normalize (normalized, len, UNORM_NFC, 0, recomposed, ARRAY_LENGTH (recomposed), &icu_err); + if (U_FAILURE (icu_err)) + return false; + /* We expect that recomposed has exactly one character now. */ + if (unlikely (u_countChar32 (recomposed, len) != 1)) + return false; + U16_GET_UNSAFE (recomposed, 0, *a); + ret = true; + } + + return ret; +} + +static unsigned int +hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, + hb_codepoint_t u, + hb_codepoint_t *decomposed, + void *user_data HB_UNUSED) +{ + UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1]; + unsigned int len; + int32_t utf32_len; + hb_bool_t err; + UErrorCode icu_err; + + /* Copy @u into a UTF-16 array to be passed to ICU. */ + len = 0; + err = FALSE; + U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), u, err); + if (err) + return 0; + + /* Normalise the codepoint using NFKD mode. */ + icu_err = U_ZERO_ERROR; + len = unorm_normalize (utf16, len, UNORM_NFKD, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); + if (icu_err) + return 0; + + /* Convert the decomposed form from UTF-16 to UTF-32. */ + icu_err = U_ZERO_ERROR; + u_strToUTF32 ((UChar32*) decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN, &utf32_len, normalized, len, &icu_err); + if (icu_err) + return 0; + + return utf32_len; +} + + +hb_unicode_funcs_t * +hb_icu_get_unicode_funcs (void) +{ + static const hb_unicode_funcs_t _hb_icu_unicode_funcs = { + HB_OBJECT_HEADER_STATIC, + + NULL, /* parent */ + true, /* immutable */ + { +#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name, + HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS +#undef HB_UNICODE_FUNC_IMPLEMENT + } + }; + +#if U_ICU_VERSION_MAJOR_NUM >= 49 + if (!hb_atomic_ptr_get (&normalizer)) { + UErrorCode icu_err = U_ZERO_ERROR; + /* We ignore failure in getNFCInstace(). */ + hb_atomic_ptr_cmpexch (&normalizer, NULL, unorm2_getNFCInstance (&icu_err)); + } +#endif + return const_cast (&_hb_icu_unicode_funcs); +} + + diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.h b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.h new file mode 100644 index 00000000000..f2f35f0f2ce --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-icu.h @@ -0,0 +1,52 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_ICU_H +#define HB_ICU_H + +#include "hb.h" + +#include + +HB_BEGIN_DECLS + + +hb_script_t +hb_icu_script_to_script (UScriptCode script); + +UScriptCode +hb_icu_script_from_script (hb_script_t script); + + +hb_unicode_funcs_t * +hb_icu_get_unicode_funcs (void); + + +HB_END_DECLS + +#endif /* HB_ICU_H */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-mutex-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-mutex-private.hh new file mode 100644 index 00000000000..5b3a17e9174 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-mutex-private.hh @@ -0,0 +1,130 @@ +/* + * Copyright © 2007 Chris Wilson + * Copyright © 2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Contributor(s): + * Chris Wilson + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_MUTEX_PRIVATE_HH +#define HB_MUTEX_PRIVATE_HH + +#include "hb-private.hh" + + +/* mutex */ + +/* We need external help for these */ + +#if 0 + + +#elif !defined(HB_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__) + +#define WIN32_LEAN_AND_MEAN +#include +typedef CRITICAL_SECTION hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT { NULL, 0, 0, NULL, NULL, 0 } +#define hb_mutex_impl_init(M) InitializeCriticalSection (M) +#define hb_mutex_impl_lock(M) EnterCriticalSection (M) +#define hb_mutex_impl_unlock(M) LeaveCriticalSection (M) +#define hb_mutex_impl_finish(M) DeleteCriticalSection (M) + + +#elif !defined(HB_NO_MT) && (defined(HAVE_PTHREAD) || defined(__APPLE__)) + +#include +typedef pthread_mutex_t hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT PTHREAD_MUTEX_INITIALIZER +#define hb_mutex_impl_init(M) pthread_mutex_init (M, NULL) +#define hb_mutex_impl_lock(M) pthread_mutex_lock (M) +#define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M) +#define hb_mutex_impl_finish(M) pthread_mutex_destroy (M) + + +#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) +# include +# define HB_SCHED_YIELD() sched_yield () +#else +# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END +#endif + +/* This actually is not a totally awful implementation. */ +typedef volatile int hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT 0 +#define hb_mutex_impl_init(M) *(M) = 0 +#define hb_mutex_impl_lock(M) HB_STMT_START { while (__sync_lock_test_and_set((M), 1)) HB_SCHED_YIELD (); } HB_STMT_END +#define hb_mutex_impl_unlock(M) __sync_lock_release (M) +#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END + + +#elif !defined(HB_NO_MT) + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) +# include +# define HB_SCHED_YIELD() sched_yield () +#else +# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END +#endif + +#define HB_MUTEX_INT_NIL 1 /* Warn that fallback implementation is in use. */ +typedef volatile int hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT 0 +#define hb_mutex_impl_init(M) *(M) = 0 +#define hb_mutex_impl_lock(M) HB_STMT_START { while (*(M)) HB_SCHED_YIELD (); (*(M))++; } HB_STMT_END +#define hb_mutex_impl_unlock(M) (*(M))--; +#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END + + +#else /* HB_NO_MT */ + +typedef int hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT 0 +#define hb_mutex_impl_init(M) HB_STMT_START {} HB_STMT_END +#define hb_mutex_impl_lock(M) HB_STMT_START {} HB_STMT_END +#define hb_mutex_impl_unlock(M) HB_STMT_START {} HB_STMT_END +#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END + +#endif + + +#define HB_MUTEX_INIT {HB_MUTEX_IMPL_INIT} +struct hb_mutex_t +{ + /* TODO Add tracing. */ + + hb_mutex_impl_t m; + + inline void init (void) { hb_mutex_impl_init (&m); } + inline void lock (void) { hb_mutex_impl_lock (&m); } + inline void unlock (void) { hb_mutex_impl_unlock (&m); } + inline void finish (void) { hb_mutex_impl_finish (&m); } +}; + + +#endif /* HB_MUTEX_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-object-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-object-private.hh new file mode 100644 index 00000000000..8a9ae34dbee --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-object-private.hh @@ -0,0 +1,227 @@ +/* + * Copyright © 2007 Chris Wilson + * Copyright © 2009,2010 Red Hat, Inc. + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Contributor(s): + * Chris Wilson + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OBJECT_PRIVATE_HH +#define HB_OBJECT_PRIVATE_HH + +#include "hb-private.hh" + +#include "hb-atomic-private.hh" +#include "hb-mutex-private.hh" + + +/* Debug */ + +#ifndef HB_DEBUG_OBJECT +#define HB_DEBUG_OBJECT (HB_DEBUG+0) +#endif + + +/* reference_count */ + +#define HB_REFERENCE_COUNT_INVALID_VALUE ((hb_atomic_int_t) -1) +#define HB_REFERENCE_COUNT_INVALID {HB_REFERENCE_COUNT_INVALID_VALUE} +struct hb_reference_count_t +{ + hb_atomic_int_t ref_count; + + inline void init (int v) { ref_count = v; } + inline int inc (void) { return hb_atomic_int_add (const_cast (ref_count), 1); } + inline int dec (void) { return hb_atomic_int_add (const_cast (ref_count), -1); } + inline void finish (void) { ref_count = HB_REFERENCE_COUNT_INVALID_VALUE; } + + inline bool is_invalid (void) const { return ref_count == HB_REFERENCE_COUNT_INVALID_VALUE; } + +}; + + +/* user_data */ + +#define HB_USER_DATA_ARRAY_INIT {HB_MUTEX_INIT, HB_LOCKABLE_SET_INIT} +struct hb_user_data_array_t +{ + /* TODO Add tracing. */ + + struct hb_user_data_item_t { + hb_user_data_key_t *key; + void *data; + hb_destroy_func_t destroy; + + inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; } + inline bool operator == (hb_user_data_item_t &other) const { return key == other.key; } + + void finish (void) { if (destroy) destroy (data); } + }; + + hb_mutex_t lock; + hb_lockable_set_t items; + + inline void init (void) { lock.init (); items.init (); } + + HB_INTERNAL bool set (hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + + HB_INTERNAL void *get (hb_user_data_key_t *key); + + inline void finish (void) { items.finish (lock); lock.finish (); } +}; + + +/* object_header */ + +struct hb_object_header_t +{ + hb_reference_count_t ref_count; + hb_user_data_array_t user_data; + +#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INVALID, HB_USER_DATA_ARRAY_INIT} + + static inline void *create (unsigned int size) { + hb_object_header_t *obj = (hb_object_header_t *) calloc (1, size); + + if (likely (obj)) + obj->init (); + + return obj; + } + + inline void init (void) { + ref_count.init (1); + user_data.init (); + } + + inline bool is_inert (void) const { + return unlikely (ref_count.is_invalid ()); + } + + inline void reference (void) { + if (unlikely (!this || this->is_inert ())) + return; + ref_count.inc (); + } + + inline bool destroy (void) { + if (unlikely (!this || this->is_inert ())) + return false; + if (ref_count.dec () != 1) + return false; + + ref_count.finish (); /* Do this before user_data */ + user_data.finish (); + + return true; + } + + inline bool set_user_data (hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy_func, + hb_bool_t replace) { + if (unlikely (!this || this->is_inert ())) + return false; + + return user_data.set (key, data, destroy_func, replace); + } + + inline void *get_user_data (hb_user_data_key_t *key) { + if (unlikely (!this || this->is_inert ())) + return NULL; + + return user_data.get (key); + } + + inline void trace (const char *function) const { + if (unlikely (!this)) return; + /* TODO We cannot use DEBUG_MSG_FUNC here since that one currently only + * prints the class name and throws away the template info. */ + DEBUG_MSG (OBJECT, (void *) this, + "%s refcount=%d", + function, + this ? ref_count.ref_count : 0); + } + + private: + ASSERT_POD (); +}; + + +/* object */ + +template +static inline void hb_object_trace (const Type *obj, const char *function) +{ + obj->header.trace (function); +} +template +static inline Type *hb_object_create (void) +{ + Type *obj = (Type *) hb_object_header_t::create (sizeof (Type)); + hb_object_trace (obj, HB_FUNC); + return obj; +} +template +static inline bool hb_object_is_inert (const Type *obj) +{ + return unlikely (obj->header.is_inert ()); +} +template +static inline Type *hb_object_reference (Type *obj) +{ + hb_object_trace (obj, HB_FUNC); + obj->header.reference (); + return obj; +} +template +static inline bool hb_object_destroy (Type *obj) +{ + hb_object_trace (obj, HB_FUNC); + return obj->header.destroy (); +} +template +static inline bool hb_object_set_user_data (Type *obj, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return obj->header.set_user_data (key, data, destroy, replace); +} + +template +static inline void *hb_object_get_user_data (Type *obj, + hb_user_data_key_t *key) +{ + return obj->header.get_user_data (key); +} + + +#endif /* HB_OBJECT_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-old.cc b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-old.cc new file mode 100644 index 00000000000..a7ea8ed9bbe --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-old.cc @@ -0,0 +1,410 @@ +/* + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#define HB_SHAPER old +#define hb_old_shaper_face_data_t HB_FaceRec_ +#define hb_old_shaper_font_data_t HB_Font_ +#include "hb-shaper-impl-private.hh" + +#include + + +#ifndef HB_DEBUG_OLD +#define HB_DEBUG_OLD (HB_DEBUG+0) +#endif + + +static HB_Script +hb_old_script_from_script (hb_script_t script) +{ + switch ((hb_tag_t) script) + { + default: + case HB_SCRIPT_COMMON: return HB_Script_Common; + case HB_SCRIPT_GREEK: return HB_Script_Greek; + case HB_SCRIPT_CYRILLIC: return HB_Script_Cyrillic; + case HB_SCRIPT_ARMENIAN: return HB_Script_Armenian; + case HB_SCRIPT_HEBREW: return HB_Script_Hebrew; + case HB_SCRIPT_ARABIC: return HB_Script_Arabic; + case HB_SCRIPT_SYRIAC: return HB_Script_Syriac; + case HB_SCRIPT_THAANA: return HB_Script_Thaana; + case HB_SCRIPT_DEVANAGARI: return HB_Script_Devanagari; + case HB_SCRIPT_BENGALI: return HB_Script_Bengali; + case HB_SCRIPT_GURMUKHI: return HB_Script_Gurmukhi; + case HB_SCRIPT_GUJARATI: return HB_Script_Gujarati; + case HB_SCRIPT_ORIYA: return HB_Script_Oriya; + case HB_SCRIPT_TAMIL: return HB_Script_Tamil; + case HB_SCRIPT_TELUGU: return HB_Script_Telugu; + case HB_SCRIPT_KANNADA: return HB_Script_Kannada; + case HB_SCRIPT_MALAYALAM: return HB_Script_Malayalam; + case HB_SCRIPT_SINHALA: return HB_Script_Sinhala; + case HB_SCRIPT_THAI: return HB_Script_Thai; + case HB_SCRIPT_LAO: return HB_Script_Lao; + case HB_SCRIPT_TIBETAN: return HB_Script_Tibetan; + case HB_SCRIPT_MYANMAR: return HB_Script_Myanmar; + case HB_SCRIPT_GEORGIAN: return HB_Script_Georgian; + case HB_SCRIPT_HANGUL: return HB_Script_Hangul; + case HB_SCRIPT_OGHAM: return HB_Script_Ogham; + case HB_SCRIPT_RUNIC: return HB_Script_Runic; + case HB_SCRIPT_KHMER: return HB_Script_Khmer; + case HB_SCRIPT_NKO: return HB_Script_Nko; + case HB_SCRIPT_INHERITED: return HB_Script_Inherited; + } +} + + +static HB_Bool +hb_old_convertStringToGlyphIndices (HB_Font old_font, + const HB_UChar16 *string, + hb_uint32 length, + HB_Glyph *glyphs, + hb_uint32 *numGlyphs, + HB_Bool rightToLeft) +{ + hb_font_t *font = (hb_font_t *) old_font->userData; + + for (unsigned int i = 0; i < length; i++) + { + hb_codepoint_t u; + + /* XXX Handle UTF-16. Ugh */ + u = string[i]; + + if (rightToLeft) + u = hb_unicode_funcs_get_default ()->mirroring (u); + + font->get_glyph (u, 0, &u); /* TODO Variation selectors */ + + glyphs[i] = u; + } + *numGlyphs = length; /* XXX */ + + return true; +} + +static void +hb_old_getGlyphAdvances (HB_Font old_font, + const HB_Glyph *glyphs, + hb_uint32 numGlyphs, + HB_Fixed *advances, + int flags /*HB_ShaperFlag*/ HB_UNUSED) +{ + hb_font_t *font = (hb_font_t *) old_font->userData; + + for (unsigned int i = 0; i < numGlyphs; i++) + advances[i] = font->get_glyph_h_advance (glyphs[i]); +} + +static HB_Bool +hb_old_canRender (HB_Font old_font, + const HB_UChar16 *string, + hb_uint32 length) +{ + return true; /* TODO */ +} + +static HB_Error +hb_old_getPointInOutline (HB_Font old_font, + HB_Glyph glyph, + int flags /*HB_ShaperFlag*/, + hb_uint32 point, + HB_Fixed *xpos, + HB_Fixed *ypos, + hb_uint32 *nPoints) +{ + return HB_Err_Ok; /* TODO */ +} + +static void +hb_old_getGlyphMetrics (HB_Font old_font, + HB_Glyph glyph, + HB_GlyphMetrics *metrics) +{ + hb_font_t *font = (hb_font_t *) old_font->userData; + + hb_glyph_extents_t extents; + + font->get_glyph_extents (glyph, &extents); + + metrics->x = extents.x_bearing; + metrics->y = extents.y_bearing; + metrics->width = extents.width; + metrics->height = extents.height; + metrics->xOffset = font->get_glyph_h_advance (glyph); + metrics->yOffset = 0; +} + +static HB_Fixed +hb_old_getFontMetric (HB_Font old_font, + HB_FontMetric metric) +{ + hb_font_t *font = (hb_font_t *) old_font->userData; + + switch (metric) + { + case HB_FontAscent: + return font->y_scale; /* XXX We don't have ascent data yet. */ + + default: + return 0; + } +} + +static const HB_FontClass hb_old_font_class = { + hb_old_convertStringToGlyphIndices, + hb_old_getGlyphAdvances, + hb_old_canRender, + hb_old_getPointInOutline, + hb_old_getGlyphMetrics, + hb_old_getFontMetric +}; + + + +static HB_Error +table_func (void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length) +{ + hb_face_t *face = (hb_face_t *) font; + hb_blob_t *blob = face->reference_table ((hb_tag_t) tag); + unsigned int capacity = *length; + *length = hb_blob_get_length (blob); + memcpy (buffer, hb_blob_get_data (blob, NULL), MIN (capacity, *length)); + hb_blob_destroy (blob); + return HB_Err_Ok; +} + + +/* + * shaper face data + */ + +hb_old_shaper_face_data_t * +_hb_old_shaper_face_data_create (hb_face_t *face) +{ + return HB_NewFace (face, table_func); +} + +void +_hb_old_shaper_face_data_destroy (hb_old_shaper_face_data_t *data) +{ + HB_FreeFace (data); +} + + +/* + * shaper font data + */ + +hb_old_shaper_font_data_t * +_hb_old_shaper_font_data_create (hb_font_t *font) +{ + HB_FontRec *data = (HB_FontRec *) calloc (1, sizeof (HB_FontRec)); + if (unlikely (!data)) { + DEBUG_MSG (OLD, font, "malloc()ing HB_Font failed"); + return NULL; + } + + data->klass = &hb_old_font_class; + data->x_ppem = font->x_ppem; + data->y_ppem = font->y_ppem; + data->x_scale = font->x_scale; /* XXX */ + data->y_scale = font->y_scale; /* XXX */ + data->userData = font; + + return data; +} + +void +_hb_old_shaper_font_data_destroy (hb_old_shaper_font_data_t *data) +{ + free (data); +} + + +/* + * shaper shape_plan data + */ + +struct hb_old_shaper_shape_plan_data_t {}; + +hb_old_shaper_shape_plan_data_t * +_hb_old_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, + const hb_feature_t *user_features HB_UNUSED, + unsigned int num_user_features HB_UNUSED) +{ + return (hb_old_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; +} + +void +_hb_old_shaper_shape_plan_data_destroy (hb_old_shaper_shape_plan_data_t *data HB_UNUSED) +{ +} + + +/* + * shaper + */ + +hb_bool_t +_hb_old_shape (hb_shape_plan_t *shape_plan HB_UNUSED, + hb_font_t *font, + hb_buffer_t *buffer, + const hb_feature_t *features, + unsigned int num_features) +{ + hb_face_t *face = font->face; + HB_Face old_face = HB_SHAPER_DATA_GET (face); + HB_Font old_font = HB_SHAPER_DATA_GET (font); + + bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); + +retry: + + unsigned int scratch_size; + char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size); + +#define utf16_index() var1.u32 + HB_UChar16 *pchars = (HB_UChar16 *) scratch; + unsigned int chars_len = 0; + for (unsigned int i = 0; i < buffer->len; i++) { + hb_codepoint_t c = buffer->info[i].codepoint; + buffer->info[i].utf16_index() = chars_len; + if (likely (c < 0x10000)) + pchars[chars_len++] = c; + else if (unlikely (c >= 0x110000)) + pchars[chars_len++] = 0xFFFD; + else { + pchars[chars_len++] = 0xD800 + ((c - 0x10000) >> 10); + pchars[chars_len++] = 0xDC00 + ((c - 0x10000) & ((1 << 10) - 1)); + } + } + + +#define ALLOCATE_ARRAY(Type, name, len) \ + name = (Type *) scratch; \ + scratch += (len) * sizeof ((name)[0]); \ + scratch_size -= (len) * sizeof ((name)[0]); + + + HB_ShaperItem item = {0}; + + ALLOCATE_ARRAY (const HB_UChar16, item.string, chars_len); + ALLOCATE_ARRAY (unsigned short, item.log_clusters, chars_len + 2); + item.stringLength = chars_len; + item.item.pos = 0; + item.item.length = item.stringLength; + item.item.script = hb_old_script_from_script (buffer->props.script); + item.item.bidiLevel = backward ? 1 : 0; + + item.font = old_font; + item.face = old_face; + item.shaperFlags = 0; + + item.glyphIndicesPresent = false; + + /* TODO Alignment. */ + unsigned int num_glyphs = scratch_size / (sizeof (HB_Glyph) + + sizeof (HB_GlyphAttributes) + + sizeof (HB_Fixed) + + sizeof (HB_FixedPoint) + + sizeof (uint32_t)); + + item.num_glyphs = num_glyphs; + ALLOCATE_ARRAY (HB_Glyph, item.glyphs, num_glyphs); + ALLOCATE_ARRAY (HB_GlyphAttributes, item.attributes, num_glyphs); + ALLOCATE_ARRAY (HB_Fixed, item.advances, num_glyphs); + ALLOCATE_ARRAY (HB_FixedPoint, item.offsets, num_glyphs); + /* Apparently in some cases the offsets array will not be fully assigned to. + * Clear it. */ + memset (item.offsets, 0, num_glyphs * sizeof (item.offsets[0])); + uint32_t *vis_clusters; + ALLOCATE_ARRAY (uint32_t, vis_clusters, num_glyphs); + +#undef ALLOCATE_ARRAY + + if (!HB_ShapeItem (&item)) + { + if (unlikely (item.num_glyphs > num_glyphs)) + { + buffer->ensure (buffer->allocated * 2); + if (buffer->in_error) + return false; + goto retry; + } + return false; + } + num_glyphs = item.num_glyphs; + + /* Ok, we've got everything we need, now compose output buffer, + * very, *very*, carefully! */ + + /* Calculate visual-clusters. That's what we ship. */ + for (unsigned int i = 0; i < num_glyphs; i++) + vis_clusters[i] = -1; + for (unsigned int i = 0; i < buffer->len; i++) { + uint32_t *p = &vis_clusters[item.log_clusters[buffer->info[i].utf16_index()]]; + *p = MIN (*p, buffer->info[i].cluster); + } + for (unsigned int i = 1; i < num_glyphs; i++) + if (vis_clusters[i] == (uint32_t) -1) + vis_clusters[i] = vis_clusters[i - 1]; + +#undef utf16_index + + buffer->ensure (num_glyphs); + if (buffer->in_error) + return false; + + + buffer->len = num_glyphs; + hb_glyph_info_t *info = buffer->info; + for (unsigned int i = 0; i < num_glyphs; i++) + { + info[i].codepoint = item.glyphs[i]; + info[i].cluster = vis_clusters[i]; + + info[i].mask = item.advances[i]; + info[i].var1.u32 = item.offsets[i].x; + info[i].var2.u32 = item.offsets[i].y; + } + + buffer->clear_positions (); + + for (unsigned int i = 0; i < num_glyphs; ++i) { + hb_glyph_info_t *info = &buffer->info[i]; + hb_glyph_position_t *pos = &buffer->pos[i]; + + /* TODO vertical */ + pos->x_advance = info->mask; + pos->x_offset = info->var1.u32; + pos->y_offset = info->var2.u32; + } + + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + buffer->reverse (); + + return true; +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-file-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-file-private.hh new file mode 100644 index 00000000000..250504ae20b --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-file-private.hh @@ -0,0 +1,261 @@ +/* + * Copyright © 2007,2008,2009 Red Hat, Inc. + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OPEN_FILE_PRIVATE_HH +#define HB_OPEN_FILE_PRIVATE_HH + +#include "hb-open-type-private.hh" + + +namespace OT { + + +/* + * + * The OpenType Font File + * + */ + + +/* + * Organization of an OpenType Font + */ + +struct OpenTypeFontFile; +struct OffsetTable; +struct TTCHeader; + + +typedef struct TableRecord +{ + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this)); + } + + Tag tag; /* 4-byte identifier. */ + CheckSum checkSum; /* CheckSum for this table. */ + ULONG offset; /* Offset from beginning of TrueType font + * file. */ + ULONG length; /* Length of this table. */ + public: + DEFINE_SIZE_STATIC (16); +} OpenTypeTable; + +typedef struct OffsetTable +{ + friend struct OpenTypeFontFile; + + inline unsigned int get_table_count (void) const + { return numTables; } + inline const TableRecord& get_table (unsigned int i) const + { + if (unlikely (i >= numTables)) return Null(TableRecord); + return tables[i]; + } + inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const + { + Tag t; + t.set (tag); + unsigned int count = numTables; + for (unsigned int i = 0; i < count; i++) + { + if (t == tables[i].tag) + { + if (table_index) *table_index = i; + return true; + } + } + if (table_index) *table_index = Index::NOT_FOUND_INDEX; + return false; + } + inline const TableRecord& get_table_by_tag (hb_tag_t tag) const + { + unsigned int table_index; + find_table_index (tag, &table_index); + return get_table (table_index); + } + + public: + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this) && c->check_array (tables, TableRecord::static_size, numTables)); + } + + protected: + Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */ + USHORT numTables; /* Number of tables. */ + USHORT searchRange; /* (Maximum power of 2 <= numTables) x 16 */ + USHORT entrySelector; /* Log2(maximum power of 2 <= numTables). */ + USHORT rangeShift; /* NumTables x 16-searchRange. */ + TableRecord tables[VAR]; /* TableRecord entries. numTables items */ + public: + DEFINE_SIZE_ARRAY (12, tables); +} OpenTypeFontFace; + + +/* + * TrueType Collections + */ + +struct TTCHeaderVersion1 +{ + friend struct TTCHeader; + + inline unsigned int get_face_count (void) const { return table.len; } + inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (table.sanitize (c, this)); + } + + protected: + Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ + FixedVersion version; /* Version of the TTC Header (1.0), + * 0x00010000 */ + LongOffsetLongArrayOf + table; /* Array of offsets to the OffsetTable for each font + * from the beginning of the file */ + public: + DEFINE_SIZE_ARRAY (12, table); +}; + +struct TTCHeader +{ + friend struct OpenTypeFontFile; + + private: + + inline unsigned int get_face_count (void) const + { + switch (u.header.version.major) { + case 2: /* version 2 is compatible with version 1 */ + case 1: return u.version1.get_face_count (); + default:return 0; + } + } + inline const OpenTypeFontFace& get_face (unsigned int i) const + { + switch (u.header.version.major) { + case 2: /* version 2 is compatible with version 1 */ + case 1: return u.version1.get_face (i); + default:return Null(OpenTypeFontFace); + } + } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + if (unlikely (!u.header.version.sanitize (c))) return TRACE_RETURN (false); + switch (u.header.version.major) { + case 2: /* version 2 is compatible with version 1 */ + case 1: return TRACE_RETURN (u.version1.sanitize (c)); + default:return TRACE_RETURN (true); + } + } + + protected: + union { + struct { + Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ + FixedVersion version; /* Version of the TTC Header (1.0 or 2.0), + * 0x00010000 or 0x00020000 */ + } header; + TTCHeaderVersion1 version1; + } u; +}; + + +/* + * OpenType Font File + */ + +struct OpenTypeFontFile +{ + static const hb_tag_t CFFTag = HB_TAG ('O','T','T','O'); /* OpenType with Postscript outlines */ + static const hb_tag_t TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ); /* OpenType with TrueType outlines */ + static const hb_tag_t TTCTag = HB_TAG ('t','t','c','f'); /* TrueType Collection */ + static const hb_tag_t TrueTag = HB_TAG ('t','r','u','e'); /* Obsolete Apple TrueType */ + static const hb_tag_t Typ1Tag = HB_TAG ('t','y','p','1'); /* Obsolete Apple Type1 font in SFNT container */ + + inline hb_tag_t get_tag (void) const { return u.tag; } + + inline unsigned int get_face_count (void) const + { + switch (u.tag) { + case CFFTag: /* All the non-collection tags */ + case TrueTag: + case Typ1Tag: + case TrueTypeTag: return 1; + case TTCTag: return u.ttcHeader.get_face_count (); + default: return 0; + } + } + inline const OpenTypeFontFace& get_face (unsigned int i) const + { + switch (u.tag) { + /* Note: for non-collection SFNT data we ignore index. This is because + * Apple dfont container is a container of SFNT's. So each SFNT is a + * non-TTC, but the index is more than zero. */ + case CFFTag: /* All the non-collection tags */ + case TrueTag: + case Typ1Tag: + case TrueTypeTag: return u.fontFace; + case TTCTag: return u.ttcHeader.get_face (i); + default: return Null(OpenTypeFontFace); + } + } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + if (unlikely (!u.tag.sanitize (c))) return TRACE_RETURN (false); + switch (u.tag) { + case CFFTag: /* All the non-collection tags */ + case TrueTag: + case Typ1Tag: + case TrueTypeTag: return TRACE_RETURN (u.fontFace.sanitize (c)); + case TTCTag: return TRACE_RETURN (u.ttcHeader.sanitize (c)); + default: return TRACE_RETURN (true); + } + } + + protected: + union { + Tag tag; /* 4-byte identifier. */ + OpenTypeFontFace fontFace; + TTCHeader ttcHeader; + } u; + public: + DEFINE_SIZE_UNION (4, tag); +}; + + +} /* namespace OT */ + + +#endif /* HB_OPEN_FILE_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-type-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-type-private.hh new file mode 100644 index 00000000000..5bfeb165470 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-open-type-private.hh @@ -0,0 +1,962 @@ +/* + * Copyright © 2007,2008,2009,2010 Red Hat, Inc. + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OPEN_TYPE_PRIVATE_HH +#define HB_OPEN_TYPE_PRIVATE_HH + +#include "hb-private.hh" + +#include "hb-blob.h" + + +namespace OT { + + + +/* + * Casts + */ + +/* Cast to struct T, reference to reference */ +template +inline const Type& CastR(const TObject &X) +{ return reinterpret_cast (X); } +template +inline Type& CastR(TObject &X) +{ return reinterpret_cast (X); } + +/* Cast to struct T, pointer to pointer */ +template +inline const Type* CastP(const TObject *X) +{ return reinterpret_cast (X); } +template +inline Type* CastP(TObject *X) +{ return reinterpret_cast (X); } + +/* StructAtOffset(P,Ofs) returns the struct T& that is placed at memory + * location pointed to by P plus Ofs bytes. */ +template +inline const Type& StructAtOffset(const void *P, unsigned int offset) +{ return * reinterpret_cast ((const char *) P + offset); } +template +inline Type& StructAtOffset(void *P, unsigned int offset) +{ return * reinterpret_cast ((char *) P + offset); } + +/* StructAfter(X) returns the struct T& that is placed after X. + * Works with X of variable size also. X must implement get_size() */ +template +inline const Type& StructAfter(const TObject &X) +{ return StructAtOffset(&X, X.get_size()); } +template +inline Type& StructAfter(TObject &X) +{ return StructAtOffset(&X, X.get_size()); } + + + +/* + * Size checking + */ + +/* Check _assertion in a method environment */ +#define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \ + inline void _instance_assertion_on_line_##_line (void) const \ + { \ + ASSERT_STATIC (_assertion); \ + ASSERT_INSTANCE_POD (*this); /* Make sure it's POD. */ \ + } +# define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion) +# define DEFINE_INSTANCE_ASSERTION(_assertion) _DEFINE_INSTANCE_ASSERTION0 (__LINE__, _assertion) + +/* Check that _code compiles in a method environment */ +#define _DEFINE_COMPILES_ASSERTION1(_line, _code) \ + inline void _compiles_assertion_on_line_##_line (void) const \ + { _code; } +# define _DEFINE_COMPILES_ASSERTION0(_line, _code) _DEFINE_COMPILES_ASSERTION1 (_line, _code) +# define DEFINE_COMPILES_ASSERTION(_code) _DEFINE_COMPILES_ASSERTION0 (__LINE__, _code) + + +#define DEFINE_SIZE_STATIC(size) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)); \ + static const unsigned int static_size = (size); \ + static const unsigned int min_size = (size) + +/* Size signifying variable-sized array */ +#define VAR 1 + +#define DEFINE_SIZE_UNION(size, _member) \ + DEFINE_INSTANCE_ASSERTION (this->u._member.static_size == (size)); \ + static const unsigned int min_size = (size) + +#define DEFINE_SIZE_MIN(size) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)); \ + static const unsigned int min_size = (size) + +#define DEFINE_SIZE_ARRAY(size, array) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (array[0])); \ + DEFINE_COMPILES_ASSERTION ((void) array[0].static_size) \ + static const unsigned int min_size = (size) + +#define DEFINE_SIZE_ARRAY2(size, array1, array2) \ + DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (this->array1[0]) + sizeof (this->array2[0])); \ + DEFINE_COMPILES_ASSERTION ((void) array1[0].static_size; (void) array2[0].static_size) \ + static const unsigned int min_size = (size) + + + +/* + * Null objects + */ + +/* Global nul-content Null pool. Enlarge as necessary. */ +/* TODO This really should be a extern HB_INTERNAL and defined somewhere... */ +static const void *_NullPool[64 / sizeof (void *)]; + +/* Generic nul-content Null objects. */ +template +static inline const Type& Null (void) { + ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool)); + return *CastP (_NullPool); +} + +/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */ +#define DEFINE_NULL_DATA(Type, data) \ +static const char _Null##Type[sizeof (Type) + 1] = data; /* +1 is for nul-termination in data */ \ +template <> \ +inline const Type& Null (void) { \ + return *CastP (_Null##Type); \ +} /* The following line really exists such that we end in a place needing semicolon */ \ +ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type)) + +/* Accessor macro. */ +#define Null(Type) Null() + + + +/* + * Sanitize + */ + +#ifndef HB_DEBUG_SANITIZE +#define HB_DEBUG_SANITIZE (HB_DEBUG+0) +#endif + + +#define TRACE_SANITIZE(this) \ + hb_auto_trace_t trace \ + (&c->debug_depth, c->get_name (), this, HB_FUNC, \ + ""); + + +struct hb_sanitize_context_t +{ + inline const char *get_name (void) { return "SANITIZE"; } + static const unsigned int max_debug_depth = HB_DEBUG_SANITIZE; + typedef bool return_t; + template + inline return_t process (const T &obj) { return obj.sanitize (this); } + static return_t default_return_value (void) { return true; } + bool stop_sublookup_iteration (const return_t r HB_UNUSED) const { return false; } + + inline void init (hb_blob_t *b) + { + this->blob = hb_blob_reference (b); + this->writable = false; + } + + inline void start_processing (void) + { + this->start = hb_blob_get_data (this->blob, NULL); + this->end = this->start + hb_blob_get_length (this->blob); + this->edit_count = 0; + this->debug_depth = 0; + + DEBUG_MSG_LEVEL (SANITIZE, this->blob, 0, +1, + "start [%p..%p] (%lu bytes)", + this->start, this->end, + (unsigned long) (this->end - this->start)); + } + + inline void end_processing (void) + { + DEBUG_MSG_LEVEL (SANITIZE, this->blob, 0, -1, + "end [%p..%p] %u edit requests", + this->start, this->end, this->edit_count); + + hb_blob_destroy (this->blob); + this->blob = NULL; + this->start = this->end = NULL; + } + + inline bool check_range (const void *base, unsigned int len) const + { + const char *p = (const char *) base; + + hb_auto_trace_t trace + (&this->debug_depth, "SANITIZE", this->blob, NULL, + "check_range [%p..%p] (%d bytes) in [%p..%p]", + p, p + len, len, + this->start, this->end); + + return TRACE_RETURN (likely (this->start <= p && p <= this->end && (unsigned int) (this->end - p) >= len)); + } + + inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const + { + const char *p = (const char *) base; + bool overflows = _hb_unsigned_int_mul_overflows (len, record_size); + + hb_auto_trace_t trace + (&this->debug_depth, "SANITIZE", this->blob, NULL, + "check_array [%p..%p] (%d*%d=%ld bytes) in [%p..%p]", + p, p + (record_size * len), record_size, len, (unsigned long) record_size * len, + this->start, this->end); + + return TRACE_RETURN (likely (!overflows && this->check_range (base, record_size * len))); + } + + template + inline bool check_struct (const Type *obj) const + { + return likely (this->check_range (obj, obj->min_size)); + } + + inline bool may_edit (const void *base HB_UNUSED, unsigned int len HB_UNUSED) + { + const char *p = (const char *) base; + this->edit_count++; + + hb_auto_trace_t trace + (&this->debug_depth, "SANITIZE", this->blob, NULL, + "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s", + this->edit_count, + p, p + len, len, + this->start, this->end, + this->writable ? "GRANTED" : "DENIED"); + + return TRACE_RETURN (this->writable); + } + + mutable unsigned int debug_depth; + const char *start, *end; + bool writable; + unsigned int edit_count; + hb_blob_t *blob; +}; + + + +/* Template to sanitize an object. */ +template +struct Sanitizer +{ + static hb_blob_t *sanitize (hb_blob_t *blob) { + hb_sanitize_context_t c[1] = {{0}}; + bool sane; + + /* TODO is_sane() stuff */ + + c->init (blob); + + retry: + DEBUG_MSG_FUNC (SANITIZE, blob, "start"); + + c->start_processing (); + + if (unlikely (!c->start)) { + c->end_processing (); + return blob; + } + + Type *t = CastP (const_cast (c->start)); + + sane = t->sanitize (c); + if (sane) { + if (c->edit_count) { + DEBUG_MSG_FUNC (SANITIZE, blob, "passed first round with %d edits; going for second round", c->edit_count); + + /* sanitize again to ensure no toe-stepping */ + c->edit_count = 0; + sane = t->sanitize (c); + if (c->edit_count) { + DEBUG_MSG_FUNC (SANITIZE, blob, "requested %d edits in second round; FAILLING", c->edit_count); + sane = false; + } + } + } else { + unsigned int edit_count = c->edit_count; + if (edit_count && !c->writable) { + c->start = hb_blob_get_data_writable (blob, NULL); + c->end = c->start + hb_blob_get_length (blob); + + if (c->start) { + c->writable = true; + /* ok, we made it writable by relocating. try again */ + DEBUG_MSG_FUNC (SANITIZE, blob, "retry"); + goto retry; + } + } + } + + c->end_processing (); + + DEBUG_MSG_FUNC (SANITIZE, blob, sane ? "PASSED" : "FAILED"); + if (sane) + return blob; + else { + hb_blob_destroy (blob); + return hb_blob_get_empty (); + } + } + + static const Type* lock_instance (hb_blob_t *blob) { + hb_blob_make_immutable (blob); + const char *base = hb_blob_get_data (blob, NULL); + return unlikely (!base) ? &Null(Type) : CastP (base); + } +}; + + + +/* + * Serialize + */ + +#ifndef HB_DEBUG_SERIALIZE +#define HB_DEBUG_SERIALIZE (HB_DEBUG+0) +#endif + + +#define TRACE_SERIALIZE(this) \ + hb_auto_trace_t trace \ + (&c->debug_depth, "SERIALIZE", c, HB_FUNC, \ + ""); + + +struct hb_serialize_context_t +{ + inline hb_serialize_context_t (void *start, unsigned int size) + { + this->start = (char *) start; + this->end = this->start + size; + + this->ran_out_of_room = false; + this->head = this->start; + this->debug_depth = 0; + } + + template + inline Type *start_serialize (void) + { + DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, +1, + "start [%p..%p] (%lu bytes)", + this->start, this->end, + (unsigned long) (this->end - this->start)); + + return start_embed (); + } + + inline void end_serialize (void) + { + DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1, + "end [%p..%p] serialized %d bytes; %s", + this->start, this->end, + (int) (this->head - this->start), + this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room"); + + } + + template + inline Type *copy (void) + { + assert (!this->ran_out_of_room); + unsigned int len = this->head - this->start; + void *p = malloc (len); + if (p) + memcpy (p, this->start, len); + return reinterpret_cast (p); + } + + template + inline Type *allocate_size (unsigned int size) + { + if (unlikely (this->ran_out_of_room || this->end - this->head < size)) { + this->ran_out_of_room = true; + return NULL; + } + memset (this->head, 0, size); + char *ret = this->head; + this->head += size; + return reinterpret_cast (ret); + } + + template + inline Type *allocate_min (void) + { + return this->allocate_size (Type::min_size); + } + + template + inline Type *start_embed (void) + { + Type *ret = reinterpret_cast (this->head); + return ret; + } + + template + inline Type *embed (const Type &obj) + { + unsigned int size = obj.get_size (); + Type *ret = this->allocate_size (size); + if (unlikely (!ret)) return NULL; + memcpy (ret, obj, size); + return ret; + } + + template + inline Type *extend_min (Type &obj) + { + unsigned int size = obj.min_size; + assert (this->start <= (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); + if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return NULL; + return reinterpret_cast (&obj); + } + + template + inline Type *extend (Type &obj) + { + unsigned int size = obj.get_size (); + assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); + if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return NULL; + return reinterpret_cast (&obj); + } + + inline void truncate (void *head) + { + assert (this->start < head && head <= this->head); + this->head = (char *) head; + } + + unsigned int debug_depth; + char *start, *end, *head; + bool ran_out_of_room; +}; + +template +struct Supplier +{ + inline Supplier (const Type *array, unsigned int len_) + { + head = array; + len = len_; + } + inline const Type operator [] (unsigned int i) const + { + if (unlikely (i >= len)) return Type (); + return head[i]; + } + + inline void advance (unsigned int count) + { + if (unlikely (count > len)) + count = len; + len -= count; + head += count; + } + + private: + inline Supplier (const Supplier &); /* Disallow copy */ + inline Supplier& operator= (const Supplier &); /* Disallow copy */ + + unsigned int len; + const Type *head; +}; + + + + +/* + * + * The OpenType Font File: Data Types + */ + + +/* "The following data types are used in the OpenType font file. + * All OpenType fonts use Motorola-style byte ordering (Big Endian):" */ + +/* + * Int types + */ + + +template struct BEInt; + +template +struct BEInt +{ + public: + inline void set (Type i) { hb_be_uint16_put (v,i); } + inline operator Type (void) const { return hb_be_uint16_get (v); } + inline bool operator == (const BEInt& o) const { return hb_be_uint16_eq (v, o.v); } + inline bool operator != (const BEInt& o) const { return !(*this == o); } + private: uint8_t v[2]; +}; +template +struct BEInt +{ + public: + inline void set (Type i) { hb_be_uint32_put (v,i); } + inline operator Type (void) const { return hb_be_uint32_get (v); } + inline bool operator == (const BEInt& o) const { return hb_be_uint32_eq (v, o.v); } + inline bool operator != (const BEInt& o) const { return !(*this == o); } + private: uint8_t v[4]; +}; +template +struct BEInt +{ + public: + inline void set (Type i) { hb_be_uint24_put (v,i); } + inline operator Type (void) const { return hb_be_uint24_get (v); } + inline bool operator == (const BEInt& o) const { return hb_be_uint24_eq (v, o.v); } + inline bool operator != (const BEInt& o) const { return !(*this == o); } + private: uint8_t v[3]; +}; + +/* Integer types in big-endian order and no alignment requirement */ +template +struct IntType +{ + inline void set (Type i) { v.set (i); } + inline operator Type(void) const { return v; } + inline bool operator == (const IntType &o) const { return v == o.v; } + inline bool operator != (const IntType &o) const { return v != o.v; } + static inline int cmp (const IntType *a, const IntType *b) { return b->cmp (*a); } + inline int cmp (IntType va) const { Type a = va; Type b = v; return a < b ? -1 : a == b ? 0 : +1; } + inline int cmp (Type a) const { Type b = v; return a < b ? -1 : a == b ? 0 : +1; } + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (likely (c->check_struct (this))); + } + protected: + BEInt v; + public: + DEFINE_SIZE_STATIC (Size); +}; + +typedef IntType USHORT; /* 16-bit unsigned integer. */ +typedef IntType SHORT; /* 16-bit signed integer. */ +typedef IntType ULONG; /* 32-bit unsigned integer. */ +typedef IntType LONG; /* 32-bit signed integer. */ +typedef IntType UINT24; /* 24-bit unsigned integer. */ + +/* 16-bit signed integer (SHORT) that describes a quantity in FUnits. */ +typedef SHORT FWORD; + +/* 16-bit unsigned integer (USHORT) that describes a quantity in FUnits. */ +typedef USHORT UFWORD; + +/* Date represented in number of seconds since 12:00 midnight, January 1, + * 1904. The value is represented as a signed 64-bit integer. */ +struct LONGDATETIME +{ + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (likely (c->check_struct (this))); + } + private: + LONG major; + ULONG minor; + public: + DEFINE_SIZE_STATIC (8); +}; + +/* Array of four uint8s (length = 32 bits) used to identify a script, language + * system, feature, or baseline */ +struct Tag : ULONG +{ + /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ + inline operator const char* (void) const { return reinterpret_cast (&this->v); } + inline operator char* (void) { return reinterpret_cast (&this->v); } + public: + DEFINE_SIZE_STATIC (4); +}; +DEFINE_NULL_DATA (Tag, " "); + +/* Glyph index number, same as uint16 (length = 16 bits) */ +typedef USHORT GlyphID; + +/* Script/language-system/feature index */ +struct Index : USHORT { + static const unsigned int NOT_FOUND_INDEX = 0xFFFF; +}; +DEFINE_NULL_DATA (Index, "\xff\xff"); + +/* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */ +typedef USHORT Offset; + +/* LongOffset to a table, same as uint32 (length = 32 bits), Null offset = 0x00000000 */ +typedef ULONG LongOffset; + + +/* CheckSum */ +struct CheckSum : ULONG +{ + static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length) + { + uint32_t Sum = 0L; + ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size; + + while (Table < EndPtr) + Sum += *Table++; + return Sum; + } + public: + DEFINE_SIZE_STATIC (4); +}; + + +/* + * Version Numbers + */ + +struct FixedVersion +{ + inline uint32_t to_int (void) const { return (major << 16) + minor; } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this)); + } + + USHORT major; + USHORT minor; + public: + DEFINE_SIZE_STATIC (4); +}; + + + +/* + * Template subclasses of Offset and LongOffset that do the dereferencing. + * Use: (base+offset) + */ + +template +struct GenericOffsetTo : OffsetType +{ + inline const Type& operator () (const void *base) const + { + unsigned int offset = *this; + if (unlikely (!offset)) return Null(Type); + return StructAtOffset (base, offset); + } + inline Type& operator () (void *base) + { + unsigned int offset = *this; + return StructAtOffset (base, offset); + } + + inline Type& serialize (hb_serialize_context_t *c, void *base) + { + Type *t = c->start_embed (); + this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ + return *t; + } + + inline bool sanitize (hb_sanitize_context_t *c, void *base) { + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) return TRACE_RETURN (false); + unsigned int offset = *this; + if (unlikely (!offset)) return TRACE_RETURN (true); + Type &obj = StructAtOffset (base, offset); + return TRACE_RETURN (likely (obj.sanitize (c)) || neuter (c)); + } + template + inline bool sanitize (hb_sanitize_context_t *c, void *base, T user_data) { + TRACE_SANITIZE (this); + if (unlikely (!c->check_struct (this))) return TRACE_RETURN (false); + unsigned int offset = *this; + if (unlikely (!offset)) return TRACE_RETURN (true); + Type &obj = StructAtOffset (base, offset); + return TRACE_RETURN (likely (obj.sanitize (c, user_data)) || neuter (c)); + } + + inline bool try_set (hb_sanitize_context_t *c, const OffsetType &v) { + if (c->may_edit (this, this->static_size)) { + this->set (v); + return true; + } + return false; + } + /* Set the offset to Null */ + inline bool neuter (hb_sanitize_context_t *c) { + if (c->may_edit (this, this->static_size)) { + this->set (0); /* 0 is Null offset */ + return true; + } + return false; + } +}; +template +inline const Type& operator + (const Base &base, const GenericOffsetTo &offset) { return offset (base); } +template +inline Type& operator + (Base &base, GenericOffsetTo &offset) { return offset (base); } + +template +struct OffsetTo : GenericOffsetTo {}; + +template +struct LongOffsetTo : GenericOffsetTo {}; + + +/* + * Array Types + */ + +template +struct GenericArrayOf +{ + const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const + { + unsigned int count = len; + if (unlikely (start_offset > count)) + count = 0; + else + count -= start_offset; + count = MIN (count, *pcount); + *pcount = count; + return array + start_offset; + } + + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= len)) return Null(Type); + return array[i]; + } + inline Type& operator [] (unsigned int i) + { + return array[i]; + } + inline unsigned int get_size (void) const + { return len.static_size + len * Type::static_size; } + + inline bool serialize (hb_serialize_context_t *c, + unsigned int items_len) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); + len.set (items_len); /* TODO(serialize) Overflow? */ + if (unlikely (!c->extend (*this))) return TRACE_RETURN (false); + return TRACE_RETURN (true); + } + + inline bool serialize (hb_serialize_context_t *c, + Supplier &items, + unsigned int items_len) + { + TRACE_SERIALIZE (this); + if (unlikely (!serialize (c, items_len))) return TRACE_RETURN (false); + for (unsigned int i = 0; i < items_len; i++) + array[i] = items[i]; + items.advance (items_len); + return TRACE_RETURN (true); + } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); + + /* Note: for structs that do not reference other structs, + * we do not need to call their sanitize() as we already did + * a bound check on the aggregate array size. We just include + * a small unreachable expression to make sure the structs + * pointed to do have a simple sanitize(), ie. they do not + * reference other structs via offsets. + */ + (void) (false && array[0].sanitize (c)); + + return TRACE_RETURN (true); + } + inline bool sanitize (hb_sanitize_context_t *c, void *base) { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (unlikely (!array[i].sanitize (c, base))) + return TRACE_RETURN (false); + return TRACE_RETURN (true); + } + template + inline bool sanitize (hb_sanitize_context_t *c, void *base, T user_data) { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (unlikely (!array[i].sanitize (c, base, user_data))) + return TRACE_RETURN (false); + return TRACE_RETURN (true); + } + + private: + inline bool sanitize_shallow (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this) && c->check_array (this, Type::static_size, len)); + } + + public: + LenType len; + Type array[VAR]; + public: + DEFINE_SIZE_ARRAY (sizeof (LenType), array); +}; + +/* An array with a USHORT number of elements. */ +template +struct ArrayOf : GenericArrayOf {}; + +/* An array with a ULONG number of elements. */ +template +struct LongArrayOf : GenericArrayOf {}; + +/* Array of Offset's */ +template +struct OffsetArrayOf : ArrayOf > {}; + +/* Array of LongOffset's */ +template +struct LongOffsetArrayOf : ArrayOf > {}; + +/* LongArray of LongOffset's */ +template +struct LongOffsetLongArrayOf : LongArrayOf > {}; + +/* Array of offsets relative to the beginning of the array itself. */ +template +struct OffsetListOf : OffsetArrayOf +{ + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= this->len)) return Null(Type); + return this+this->array[i]; + } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (OffsetArrayOf::sanitize (c, this)); + } + template + inline bool sanitize (hb_sanitize_context_t *c, T user_data) { + TRACE_SANITIZE (this); + return TRACE_RETURN (OffsetArrayOf::sanitize (c, this, user_data)); + } +}; + + +/* An array with a USHORT number of elements, + * starting at second element. */ +template +struct HeadlessArrayOf +{ + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= len || !i)) return Null(Type); + return array[i-1]; + } + inline unsigned int get_size (void) const + { return len.static_size + (len ? len - 1 : 0) * Type::static_size; } + + inline bool serialize (hb_serialize_context_t *c, + Supplier &items, + unsigned int items_len) + { + TRACE_SERIALIZE (this); + if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); + len.set (items_len); /* TODO(serialize) Overflow? */ + if (unlikely (!items_len)) return TRACE_RETURN (true); + if (unlikely (!c->extend (*this))) return TRACE_RETURN (false); + for (unsigned int i = 0; i < items_len - 1; i++) + array[i] = items[i]; + items.advance (items_len - 1); + return TRACE_RETURN (true); + } + + inline bool sanitize_shallow (hb_sanitize_context_t *c) { + return c->check_struct (this) + && c->check_array (this, Type::static_size, len); + } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c))) return TRACE_RETURN (false); + + /* Note: for structs that do not reference other structs, + * we do not need to call their sanitize() as we already did + * a bound check on the aggregate array size. We just include + * a small unreachable expression to make sure the structs + * pointed to do have a simple sanitize(), ie. they do not + * reference other structs via offsets. + */ + (void) (false && array[0].sanitize (c)); + + return TRACE_RETURN (true); + } + + USHORT len; + Type array[VAR]; + public: + DEFINE_SIZE_ARRAY (sizeof (USHORT), array); +}; + + +/* An array with sorted elements. Supports binary searching. */ +template +struct SortedArrayOf : ArrayOf { + + template + inline int search (const SearchType &x) const { + unsigned int count = this->len; + /* Linear search is *much* faster for small counts. */ + if (likely (count < 32)) { + for (unsigned int i = 0; i < count; i++) + if (this->array[i].cmp (x) == 0) + return i; + return -1; + } else { + struct Cmp { + static int cmp (const SearchType *a, const Type *b) { return b->cmp (*a); } + }; + const Type *p = (const Type *) bsearch (&x, this->array, this->len, sizeof (this->array[0]), (hb_compare_func_t) Cmp::cmp); + return p ? p - this->array : -1; + } + } +}; + + +} /* namespace OT */ + + +#endif /* HB_OPEN_TYPE_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-head-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-head-table.hh new file mode 100644 index 00000000000..3a9451295de --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-head-table.hh @@ -0,0 +1,149 @@ +/* + * Copyright © 2010 Red Hat, Inc. + * Copyright © 2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OT_HEAD_TABLE_HH +#define HB_OT_HEAD_TABLE_HH + +#include "hb-open-type-private.hh" + + +namespace OT { + + +/* + * head -- Font Header + */ + +#define HB_OT_TAG_head HB_TAG('h','e','a','d') + +struct head +{ + static const hb_tag_t Tag = HB_OT_TAG_head; + + inline unsigned int get_upem (void) const { + unsigned int upem = unitsPerEm; + /* If no valid head table found, assume 1000, which matches typical Type1 usage. */ + return 16 <= upem && upem <= 16384 ? upem : 1000; + } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this) && likely (version.major == 1)); + } + + protected: + FixedVersion version; /* Version of the head table--currently + * 0x00010000 for version 1.0. */ + FixedVersion fontRevision; /* Set by font manufacturer. */ + ULONG checkSumAdjustment; /* To compute: set it to 0, sum the + * entire font as ULONG, then store + * 0xB1B0AFBA - sum. */ + ULONG magicNumber; /* Set to 0x5F0F3CF5. */ + USHORT flags; /* Bit 0: Baseline for font at y=0; + * Bit 1: Left sidebearing point at x=0; + * Bit 2: Instructions may depend on point size; + * Bit 3: Force ppem to integer values for all + * internal scaler math; may use fractional + * ppem sizes if this bit is clear; + * Bit 4: Instructions may alter advance width + * (the advance widths might not scale linearly); + + * Bits 5-10: These should be set according to + * Apple's specification. However, they are not + * implemented in OpenType. + * Bit 5: This bit should be set in fonts that are + * intended to e laid out vertically, and in + * which the glyphs have been drawn such that an + * x-coordinate of 0 corresponds to the desired + * vertical baseline. + * Bit 6: This bit must be set to zero. + * Bit 7: This bit should be set if the font + * requires layout for correct linguistic + * rendering (e.g. Arabic fonts). + * Bit 8: This bit should be set for a GX font + * which has one or more metamorphosis effects + * designated as happening by default. + * Bit 9: This bit should be set if the font + * contains any strong right-to-left glyphs. + * Bit 10: This bit should be set if the font + * contains Indic-style rearrangement effects. + + * Bit 11: Font data is 'lossless,' as a result + * of having been compressed and decompressed + * with the Agfa MicroType Express engine. + * Bit 12: Font converted (produce compatible metrics) + * Bit 13: Font optimized for ClearType™. + * Note, fonts that rely on embedded bitmaps (EBDT) + * for rendering should not be considered optimized + * for ClearType, and therefore should keep this bit + * cleared. + * Bit 14: Last Resort font. If set, indicates that + * the glyphs encoded in the cmap subtables are simply + * generic symbolic representations of code point + * ranges and don’t truly represent support for those + * code points. If unset, indicates that the glyphs + * encoded in the cmap subtables represent proper + * support for those code points. + * Bit 15: Reserved, set to 0. */ + USHORT unitsPerEm; /* Valid range is from 16 to 16384. This value + * should be a power of 2 for fonts that have + * TrueType outlines. */ + LONGDATETIME created; /* Number of seconds since 12:00 midnight, + January 1, 1904. 64-bit integer */ + LONGDATETIME modified; /* Number of seconds since 12:00 midnight, + January 1, 1904. 64-bit integer */ + SHORT xMin; /* For all glyph bounding boxes. */ + SHORT yMin; /* For all glyph bounding boxes. */ + SHORT xMax; /* For all glyph bounding boxes. */ + SHORT yMax; /* For all glyph bounding boxes. */ + USHORT macStyle; /* Bit 0: Bold (if set to 1); + * Bit 1: Italic (if set to 1) + * Bit 2: Underline (if set to 1) + * Bit 3: Outline (if set to 1) + * Bit 4: Shadow (if set to 1) + * Bit 5: Condensed (if set to 1) + * Bit 6: Extended (if set to 1) + * Bits 7-15: Reserved (set to 0). */ + USHORT lowestRecPPEM; /* Smallest readable size in pixels. */ + SHORT fontDirectionHint; /* Deprecated (Set to 2). + * 0: Fully mixed directional glyphs; + * 1: Only strongly left to right; + * 2: Like 1 but also contains neutrals; + * -1: Only strongly right to left; + * -2: Like -1 but also contains neutrals. */ + SHORT indexToLocFormat; /* 0 for short offsets, 1 for long. */ + SHORT glyphDataFormat; /* 0 for current format. */ + public: + DEFINE_SIZE_STATIC (54); +}; + + +} /* namespace OT */ + + +#endif /* HB_OT_HEAD_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hhea-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hhea-table.hh new file mode 100644 index 00000000000..2b89c4e0208 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hhea-table.hh @@ -0,0 +1,97 @@ +/* + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OT_HHEA_TABLE_HH +#define HB_OT_HHEA_TABLE_HH + +#include "hb-open-type-private.hh" + + +namespace OT { + + +/* + * hhea -- The Horizontal Header Table + */ + +#define HB_OT_TAG_hhea HB_TAG('h','h','e','a') + + +struct hhea +{ + static const hb_tag_t Tag = HB_OT_TAG_hhea; + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this) && likely (version.major == 1)); + } + + protected: + FixedVersion version; /* 0x00010000 for version 1.0. */ + FWORD ascender; /* Typographic ascent. + * (Distance from baseline of highest + * ascender) */ + FWORD descender; /* Typographic descent. + * (Distance from baseline of lowest + * descender) */ + FWORD lineGap; /* Typographic line gap. Negative + * LineGap values are treated as zero + * in Windows 3.1, System 6, and + * System 7. */ + UFWORD advanceWidthMax; /* Maximum advance width value in + * 'hmtx' table. */ + FWORD minLeftSideBearing; /* Minimum left sidebearing value in + * 'hmtx' table. */ + FWORD minRightSideBearing; /* Minimum right sidebearing value; + * calculated as Min(aw - lsb - + * (xMax - xMin)). */ + FWORD xMaxExtent; /* Max(lsb + (xMax - xMin)). */ + SHORT caretSlopeRise; /* Used to calculate the slope of the + * cursor (rise/run); 1 for vertical. */ + SHORT caretSlopeRun; /* 0 for vertical. */ + SHORT caretOffset; /* The amount by which a slanted + * highlight on a glyph needs + * to be shifted to produce the + * best appearance. Set to 0 for + * non--slanted fonts */ + SHORT reserved1; /* set to 0 */ + SHORT reserved2; /* set to 0 */ + SHORT reserved3; /* set to 0 */ + SHORT reserved4; /* set to 0 */ + SHORT metricDataFormat; /* 0 for current format. */ + USHORT numberOfHMetrics; /* Number of hMetric entries in 'hmtx' + * table */ + public: + DEFINE_SIZE_STATIC (36); +}; + + +} /* namespace OT */ + + +#endif /* HB_OT_HHEA_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hmtx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hmtx-table.hh new file mode 100644 index 00000000000..b94337d0be7 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-hmtx-table.hh @@ -0,0 +1,92 @@ +/* + * Copyright © 2011,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OT_HMTX_TABLE_HH +#define HB_OT_HMTX_TABLE_HH + +#include "hb-open-type-private.hh" + + +namespace OT { + + +/* + * hmtx -- The Horizontal Metrics Table + */ + +#define HB_OT_TAG_hmtx HB_TAG('h','m','t','x') + + +struct LongHorMetric +{ + USHORT advanceWidth; + SHORT lsb; + public: + DEFINE_SIZE_STATIC (4); +}; + +struct hmtx +{ + static const hb_tag_t Tag = HB_OT_TAG_hmtx; + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + /* We don't check for anything specific here. The users of the + * struct do all the hard work... */ + return TRACE_RETURN (true); + } + + protected: + LongHorMetric longHorMetric[VAR]; /* Paired advance width and left side + * bearing values for each glyph. The + * value numOfHMetrics comes from + * the 'hhea' table. If the font is + * monospaced, only one entry need + * be in the array, but that entry is + * required. The last entry applies to + * all subsequent glyphs. */ + SHORT leftSideBearingX[VAR]; /* Here the advanceWidth is assumed + * to be the same as the advanceWidth + * for the last entry above. The + * number of entries in this array is + * derived from numGlyphs (from 'maxp' + * table) minus numberOfHMetrics. This + * generally is used with a run of + * monospaced glyphs (e.g., Kanji + * fonts or Courier fonts). Only one + * run is allowed and it must be at + * the end. This allows a monospaced + * font to vary the left side bearing + * values for each glyph. */ + public: + DEFINE_SIZE_ARRAY2 (0, longHorMetric, leftSideBearingX); +}; + + +} /* namespace OT */ + + +#endif /* HB_OT_HMTX_TABLE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-common-private.hh b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-common-private.hh new file mode 100644 index 00000000000..e6018db1243 --- /dev/null +++ b/Build/source/libs/harfbuzz/harfbuzz-0.9.10/src/hb-ot-layout-common-private.hh @@ -0,0 +1,1142 @@ +/* + * Copyright © 2007,2008,2009 Red Hat, Inc. + * Copyright © 2010,2012 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH +#define HB_OT_LAYOUT_COMMON_PRIVATE_HH + +#include "hb-ot-layout-private.hh" +#include "hb-open-type-private.hh" +#include "hb-set-private.hh" + + +namespace OT { + + +#define NOT_COVERED ((unsigned int) -1) +#define MAX_NESTING_LEVEL 8 + + + +/* + * + * OpenType Layout Common Table Formats + * + */ + + +/* + * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList + */ + +template +struct Record +{ + inline int cmp (hb_tag_t a) const { + return tag.cmp (a); + } + + struct sanitize_closure_t { + hb_tag_t tag; + void *list_base; + }; + inline bool sanitize (hb_sanitize_context_t *c, void *base) { + TRACE_SANITIZE (this); + const sanitize_closure_t closure = {tag, base}; + return TRACE_RETURN (c->check_struct (this) && offset.sanitize (c, base, &closure)); + } + + Tag tag; /* 4-byte Tag identifier */ + OffsetTo + offset; /* Offset from beginning of object holding + * the Record */ + public: + DEFINE_SIZE_STATIC (6); +}; + +template +struct RecordArrayOf : SortedArrayOf > { + inline const Tag& get_tag (unsigned int i) const + { + /* We cheat slightly and don't define separate Null objects + * for Record types. Instead, we return the correct Null(Tag) + * here. */ + if (unlikely (i >= this->len)) return Null(Tag); + return (*this)[i].tag; + } + inline unsigned int get_tags (unsigned int start_offset, + unsigned int *record_count /* IN/OUT */, + hb_tag_t *record_tags /* OUT */) const + { + if (record_count) { + const Record *arr = this->sub_array (start_offset, record_count); + unsigned int count = *record_count; + for (unsigned int i = 0; i < count; i++) + record_tags[i] = arr[i].tag; + } + return this->len; + } + inline bool find_index (hb_tag_t tag, unsigned int *index) const + { + int i = this->search (tag); + if (i != -1) { + if (index) *index = i; + return true; + } else { + if (index) *index = Index::NOT_FOUND_INDEX; + return false; + } + } +}; + +template +struct RecordListOf : RecordArrayOf +{ + inline const Type& operator [] (unsigned int i) const + { return this+RecordArrayOf::operator [](i).offset; } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (RecordArrayOf::sanitize (c, this)); + } +}; + + +struct RangeRecord +{ + inline int cmp (hb_codepoint_t g) const { + hb_codepoint_t a = start, b = end; + return g < a ? -1 : g <= b ? 0 : +1 ; + } + + inline bool sanitize (hb_sanitize_context_t *c) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this)); + } + + inline bool intersects (const hb_set_t *glyphs) const { + return glyphs->intersects (start, end); + } + + template + inline void add_coverage (set_t *glyphs) const { + glyphs->add_range (start, end); + } + + GlyphID start; /* First GlyphID in the range */ + GlyphID end; /* Last GlyphID in the range */ + USHORT value; /* Value */ + public: + DEFINE_SIZE_STATIC (6); +}; +DEFINE_NULL_DATA (RangeRecord, "\000\001"); + + +struct IndexArray : ArrayOf +{ + inline unsigned int get_indexes (unsigned int start_offset, + unsigned int *_count /* IN/OUT */, + unsigned int *_indexes /* OUT */) const + { + if (_count) { + const USHORT *arr = this->sub_array (start_offset, _count); + unsigned int count = *_count; + for (unsigned int i = 0; i < count; i++) + _indexes[i] = arr[i]; + } + return this->len; + } +}; + + +struct Script; +struct LangSys; +struct Feature; + + +struct LangSys +{ + inline unsigned int get_feature_count (void) const + { return featureIndex.len; } + inline hb_tag_t get_feature_index (unsigned int i) const + { return featureIndex[i]; } + inline unsigned int get_feature_indexes (unsigned int start_offset, + unsigned int *feature_count /* IN/OUT */, + unsigned int *feature_indexes /* OUT */) const + { return featureIndex.get_indexes (start_offset, feature_count, feature_indexes); } + + inline bool has_required_feature (void) const { return reqFeatureIndex != 0xffff; } + inline unsigned int get_required_feature_index (void) const + { + if (reqFeatureIndex == 0xffff) + return Index::NOT_FOUND_INDEX; + return reqFeatureIndex;; + } + + inline bool sanitize (hb_sanitize_context_t *c, + const Record::sanitize_closure_t * = NULL) { + TRACE_SANITIZE (this); + return TRACE_RETURN (c->check_struct (this) && featureIndex.sanitize (c)); + } + + Offset lookupOrder; /* = Null (reserved for an offset to a + * reordering table) */ + USHORT reqFeatureIndex;/* Index of a feature required for this + * language system--if no required features + * = 0xFFFF */ + IndexArray featureIndex; /* Array of indices into the FeatureList */ + public: + DEFINE_SIZE_ARRAY (6, featureIndex); +}; +DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF"); + + +struct Script +{ + inline unsigned int get_lang_sys_count (void) const + { return langSys.len; } + inline const Tag& get_lang_sys_tag (unsigned int i) const + { return langSys.get_tag (i); } + inline unsigned int get_lang_sys_tags (unsigned int start_offset, + unsigned int *lang_sys_count /* IN/OUT */, + hb_tag_t *lang_sys_tags /* OUT */) const + { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } + inline const LangSys& get_lang_sys (unsigned int i) const + { + if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); + return this+langSys[i].offset; + } + inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const + { return langSys.find_index (tag, index); } + + inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } + inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } + + inline bool sanitize (hb_sanitize_context_t *c, + const Record