Skip to content

Commit 66684b1

Browse files
garretriegerSkCQ
authored andcommitted
Roll HarfBuzz from 2.6.4 to 2.8.2-147
https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git/+log/3a74ee528255cc027d84b204a87b5c25e47bff79..368e9578873798e2d17ed78a0474dec7d4e9d6c0 Additionally adds a build option that switches to the new harfbuzz subsetting api which is coming in the next version of harfbuzz. Change-Id: I924a7b4978412d636d4c8d19f5c6021ea3c73d21 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433737 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
1 parent 058e936 commit 66684b1

File tree

7 files changed

+39
-6
lines changed

7 files changed

+39
-6
lines changed

BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,9 @@ optional("pdf") {
10471047
if (skia_use_icu && skia_use_harfbuzz && skia_pdf_subset_harfbuzz) {
10481048
deps += [ "//third_party/harfbuzz" ]
10491049
defines = [ "SK_PDF_USE_HARFBUZZ_SUBSET" ]
1050+
if (skia_subset_harfbuzz_new_api) {
1051+
defines += [ "SK_HARFBUZZ_SUBSET_NEW_API" ]
1052+
}
10501053
} else if (skia_use_icu && skia_use_sfntly) {
10511054
deps += [ "//third_party/sfntly" ]
10521055
defines = [ "SK_PDF_USE_SFNTLY" ]

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ deps = {
2424
"third_party/externals/egl-registry" : "https://skia.googlesource.com/external/github.com/KhronosGroup/EGL-Registry@a0bca08de07c7d7651047bedc0b653cfaaa4f2ae",
2525
"third_party/externals/expat" : "https://chromium.googlesource.com/external/github.com/libexpat/libexpat.git@a28238bdeebc087071777001245df1876a11f5ee",
2626
"third_party/externals/freetype" : "https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@47b1a541cb1943d85da3976b93f9a5ed490288e2",
27-
"third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@3a74ee528255cc027d84b204a87b5c25e47bff79",
27+
"third_party/externals/harfbuzz" : "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@368e9578873798e2d17ed78a0474dec7d4e9d6c0",
2828
"third_party/externals/icu" : "https://chromium.googlesource.com/chromium/deps/icu.git@a0718d4f121727e30b8d52c7a189ebf5ab52421f",
2929
"third_party/externals/imgui" : "https://skia.googlesource.com/external/github.com/ocornut/imgui.git@9418dcb69355558f70de260483424412c5ca2fce",
3030
"third_party/externals/libgifcodec" : "https://skia.googlesource.com/libgifcodec@fd59fa92a0c86788dcdd84d091e1ce81eda06a77",

gn/gn_to_bp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ def generate_args(target_os, enable_gpu, renderengine = False):
402402
# files.
403403
'target_cpu': '"none"',
404404

405+
# disable harfbuzz new subsetting api until android picks up harfbuzz 3.0.0
406+
'skia_subset_harfbuzz_new_api': 'false',
407+
405408
# Use the custom FontMgr, as the framework will handle fonts.
406409
'skia_enable_fontmgr_custom_directory': 'false',
407410
'skia_enable_fontmgr_custom_embedded': 'false',

gn/skia.gni

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ declare_args() {
3434
skia_include_multiframe_procs = false
3535
skia_lex = false
3636
skia_libgifcodec_path = "third_party/externals/libgifcodec"
37-
skia_pdf_subset_harfbuzz =
38-
false # TODO: set skia_pdf_subset_harfbuzz to skia_use_harfbuzz.
3937
skia_qt_path = getenv("QT_PATH")
4038
skia_skqp_global_error_tolerance = 0
4139
skia_tools_require_resources = false
@@ -99,6 +97,11 @@ declare_args() {
9997
skia_use_libfuzzer_defaults = true
10098
}
10199

100+
declare_args() {
101+
skia_pdf_subset_harfbuzz = skia_use_harfbuzz
102+
skia_subset_harfbuzz_new_api = !is_fuchsia
103+
}
104+
102105
declare_args() {
103106
skia_compile_sksl_tests = skia_compile_processors
104107
skia_enable_fontmgr_android = skia_use_expat && skia_use_freetype

src/pdf/SkPDFSubsetFont.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,21 @@ static sk_sp<SkData> subset_harfbuzz(sk_sp<SkData> fontData,
7171
hb_set_t* glyphs = hb_subset_input_glyph_set(input.get());
7272
glyphUsage.getSetValues([&glyphs](unsigned gid) { hb_set_add(glyphs, gid);});
7373

74+
#if defined(SK_HARFBUZZ_SUBSET_NEW_API)
75+
// TODO: When possible, check if a font is 'tricky' with FT_IS_TRICKY.
76+
// If it isn't known if a font is 'tricky', retain the hints.
77+
hb_subset_input_set_flags(input.get(), HB_SUBSET_FLAGS_RETAIN_GIDS);
78+
HBFace subset(hb_subset_or_fail(face.get(), input.get()));
79+
#else
7480
hb_subset_input_set_retain_gids(input.get(), true);
7581
// TODO: When possible, check if a font is 'tricky' with FT_IS_TRICKY.
7682
// If it isn't known if a font is 'tricky', retain the hints.
7783
hb_subset_input_set_drop_hints(input.get(), false);
7884
HBFace subset(hb_subset(face.get(), input.get()));
85+
#endif
86+
if (!subset) {
87+
return nullptr;
88+
}
7989
HBBlob result(hb_face_reference_blob(subset.get()));
8090
return to_data(std::move(result));
8191
}
@@ -178,4 +188,3 @@ sk_sp<SkData> SkPDFSubsetFont(sk_sp<SkData>, const SkPDFGlyphUse&, SkPDF::Metada
178188
return nullptr;
179189
}
180190
#endif // defined(SK_PDF_USE_SFNTLY)
181-

third_party/harfbuzz/BUILD.gn

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ if (skia_use_system_harfbuzz) {
1414
system("harfbuzz") {
1515
include_dirs = [ "/usr/include/harfbuzz" ]
1616
libs = [ "harfbuzz" ]
17+
if (skia_pdf_subset_harfbuzz) {
18+
libs += [ "harfbuzz-subset" ]
19+
}
1720
}
1821
} else {
1922
third_party("harfbuzz") {
@@ -25,8 +28,8 @@ if (skia_use_system_harfbuzz) {
2528
defines = [
2629
#"HAVE_ICU",
2730
#"HAVE_ICU_BUILTIN",
28-
"HAVE_INTEL_ATOMIC_PRIMITIVES",
2931
"HAVE_OT",
32+
"HAVE_CONFIG_OVERRIDE_H",
3033
]
3134
public = [
3235
"$_src/hb-blob.h",
@@ -181,9 +184,10 @@ if (skia_use_system_harfbuzz) {
181184
"$_src/hb-ot-shape-complex-myanmar-machine.hh",
182185
"$_src/hb-ot-shape-complex-myanmar.cc",
183186
"$_src/hb-ot-shape-complex-myanmar.hh",
187+
"$_src/hb-ot-shape-complex-syllabic.cc",
188+
"$_src/hb-ot-shape-complex-syllabic.hh",
184189
"$_src/hb-ot-shape-complex-thai.cc",
185190
"$_src/hb-ot-shape-complex-use-machine.hh",
186-
"$_src/hb-ot-shape-complex-use-table.cc",
187191
"$_src/hb-ot-shape-complex-use.cc",
188192
"$_src/hb-ot-shape-complex-use.hh",
189193
"$_src/hb-ot-shape-complex-vowel-constraints.cc",
@@ -241,6 +245,7 @@ if (skia_use_system_harfbuzz) {
241245
"$_src/hb-utf.hh",
242246
"$_src/hb-vector.hh",
243247
"$_src/hb.hh",
248+
"config-override.h",
244249
]
245250
}
246251
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Adds a mutex implementation based on c++ mutex to harfbuzz.
3+
*/
4+
#include <mutex>
5+
6+
using hb_mutex_impl_t = std::mutex;
7+
#define hb_mutex_impl_init(M) HB_STMT_START { new (M) hb_mutex_impl_t; } HB_STMT_END
8+
#define hb_mutex_impl_lock(M) (M)->lock ()
9+
#define hb_mutex_impl_unlock(M) (M)->unlock ()
10+
#define hb_mutex_impl_finish(M) HB_STMT_START { (M)->~hb_mutex_impl_t(); } HB_STMT_END

0 commit comments

Comments
 (0)