Skip to content

Commit

Permalink
Add squash commit for third_party/harfbuzz-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlstrom-g authored Sep 27, 2023
2 parents 8fbc419 + 816489d commit 3b0b683
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 45 deletions.
92 changes: 53 additions & 39 deletions third_party/harfbuzz-ng/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@ import("//build/config/chrome_build.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni")

# The GYP build supports system harfbuzz for non-official builds when using
# pangoft2 1.31.0 or greater (which pulls it in).
# TODO(brettw) we can consider doing this as well, although the benefit is
# unclear and requires shelling out to a script to check the version.
#
# ChromeOS uses an up-to-date system one that we have control over, so we
# don't want to bloat the binary more by including another copy.

declare_args() {
# Blink uses a cutting-edge version of Harfbuzz; most Linux distros do not
# contain a new enough version of the code to work correctly. However,
# ChromeOS chroots (i.e, real ChromeOS builds for devices) do contain a
# new enough version of the library, and so this variable exists so that
# ChromeOS can build against the system lib and keep binary sizes smaller.
use_system_harfbuzz = false
# Since version 1.31.0, pangoft2 which we depend on pulls in harfbuzz
# anyways. However, we want to have control of the version of harfbuzz
# we use, so don't use system harfbuzz unless we are building for
# chrome os, where we have the system harfbuzz under control.
use_system_harfbuzz =
is_linux && is_chromeos && exec_script(pkg_config_script,
pkg_config_args + [
"--atleast-version=1.31.0",
"pangoft2",
],
"value")
}

if (use_system_harfbuzz) {
Expand Down Expand Up @@ -53,16 +66,16 @@ if (use_system_harfbuzz) {
}

if (!is_starboard) {
# See also chrome/browser/ui/libgtk2ui/BUILD.gn which pulls this.
config("pangoft2_link_hack") {
if (is_linux && use_pango && !is_chromeos && !is_official_build &&
current_cpu != "arm" && current_cpu != "mipsel" && !is_component_build) {
# These symbols are referenced from libpangoft2, which will be
# dynamically linked later.
ldflags = [ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ]
}
# See also chrome/browser/ui/libgtk2ui/BUILD.gn which pulls this.
config("pangoft2_link_hack") {
if (is_linux && use_pango && !is_chromeos && !is_official_build &&
current_cpu != "arm" && current_cpu != "mipsel" && !is_component_build) {
# These symbols are referenced from libpangoft2, which will be
# dynamically linked later.
ldflags = [ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ]
}
}
}

static_library("harfbuzz-ng") {
sources = [
Expand Down Expand Up @@ -188,31 +201,32 @@ if (use_system_harfbuzz) {
]

if (!is_starboard) {
if (is_mac) {
sources += [
"src/hb-coretext.cc",
"src/hb-coretext.h",
]
defines += [ "HAVE_CORETEXT" ]
}

if (is_mac) {
sources += [
"src/hb-coretext.cc",
"src/hb-coretext.h",
]
defines += [ "HAVE_CORETEXT" ]
}

# When without -fvisibility=hidden for pango to use the harfbuzz
# in the tree, all symbols pango needs must be included, or
# pango uses mixed versions of harfbuzz and leads to crash.
# See crbug.com/462689.
if (is_linux && use_pango && !is_chromeos && !is_official_build &&
current_cpu != "arm" && current_cpu != "mipsel") {
deps += [ "//build/linux:freetype2" ]
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
configs += [ "//build/config/linux:glib" ]
sources += [
"src/hb-ft.cc",
"src/hb-ft.h",
"src/hb-glib.cc",
"src/hb-glib.h",
]
}
# When without -fvisibility=hidden for pango to use the harfbuzz
# in the tree, all symbols pango needs must be included, or
# pango uses mixed versions of harfbuzz and leads to crash.
# See crbug.com/462689.
if (is_linux && use_pango && !is_chromeos && !is_official_build &&
current_cpu != "arm" && current_cpu != "mipsel") {
deps += [ "//build/linux:freetype2" ]
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
configs += [
"//build/config/linux:glib",
]
sources += [
"src/hb-ft.cc",
"src/hb-ft.h",
"src/hb-glib.cc",
"src/hb-glib.h",
]
}
}
}
}
}
4 changes: 2 additions & 2 deletions third_party/harfbuzz-ng/METADATA
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ description:
third_party {
url {
type: GIT
value: "https://github.com/harfbuzz/harfbuzz"
value: "https://chromium.googlesource.com/chromium/src"
}
version: "b24e93e3a4d98111c4684fa08e9080b471881d5c"
version: "48.0.2564.116"
last_upgrade_date {
year: 2015
month: 11
Expand Down
6 changes: 6 additions & 0 deletions third_party/harfbuzz-ng/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
4 changes: 0 additions & 4 deletions third_party/harfbuzz-ng/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ tarball's src folder over to src, then checking for removed or added files
and update our build recipes in BUILD.gn and harfbuzz.gyp accordingly, update
the NEWS file from HarfBuzz' release notes, and bump the version numbers
in README.chromium.

Local changes:
* merge https://github.com/behdad/harfbuzz/pull/203
* merge https://github.com/behdad/harfbuzz/pull/206
215 changes: 215 additions & 0 deletions third_party/harfbuzz-ng/harfbuzz.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

{
'includes': [
'../../build/win_precompile.gypi',
],
'variables': {
'conditions': [
['OS=="linux" and chromeos==1', {
# Since version 1.31.0, pangoft2 which we depend on pulls in harfbuzz
# anyways. However, we want to have control of the version of harfbuzz
# we use, so don't use system harfbuzz unless we are building for
# chrome os, where we have the system harfbuzz under control.
'use_system_harfbuzz%': '<!(python ../../build/check_return_value.py <(pkg-config) --atleast-version=1.31.0 pangoft2)',
}, {
'use_system_harfbuzz': 0,
}],
],
},
'conditions': [
['use_system_harfbuzz==0', {
'targets': [
{
'target_name': 'harfbuzz-ng',
'type': 'static_library',
'defines': [
'HAVE_OT',
'HAVE_ICU',
'HAVE_ICU_BUILTIN',
'HB_NO_MT',
],
'sources': [
'src/hb-atomic-private.hh',
'src/hb-blob.cc',
'src/hb-blob.h',
'src/hb-buffer.cc',
'src/hb-buffer-deserialize-json.hh',
'src/hb-buffer-deserialize-text.hh',
'src/hb-buffer.h',
'src/hb-buffer-private.hh',
'src/hb-buffer-serialize.cc',
'src/hb-cache-private.hh',
'src/hb-common.cc',
'src/hb-common.h',
'src/hb-deprecated.h',
'src/hb-face.cc',
'src/hb-face.h',
'src/hb-face-private.hh',
'src/hb-fallback-shape.cc',
'src/hb-font.cc',
'src/hb-font.h',
'src/hb-font-private.hh',
'src/hb.h',
'src/hb-icu.cc',
'src/hb-icu.h',
'src/hb-mutex-private.hh',
'src/hb-object-private.hh',
'src/hb-open-file-private.hh',
'src/hb-open-type-private.hh',
'src/hb-ot.h',
'src/hb-ot-font.cc',
'src/hb-ot-font.h',
'src/hb-ot-head-table.hh',
'src/hb-ot-hhea-table.hh',
'src/hb-ot-hmtx-table.hh',
'src/hb-ot-layout.cc',
'src/hb-ot-layout-common-private.hh',
'src/hb-ot-layout-gdef-table.hh',
'src/hb-ot-layout-gpos-table.hh',
'src/hb-ot-layout-gsubgpos-private.hh',
'src/hb-ot-layout-gsub-table.hh',
'src/hb-ot-layout.h',
'src/hb-ot-layout-private.hh',
'src/hb-ot-map.cc',
'src/hb-ot-map-private.hh',
'src/hb-ot-maxp-table.hh',
'src/hb-ot-name-table.hh',
'src/hb-ot-shape.cc',
'src/hb-ot-shape-complex-arabic.cc',
'src/hb-ot-shape-complex-arabic-fallback.hh',
'src/hb-ot-shape-complex-arabic-private.hh',
'src/hb-ot-shape-complex-arabic-table.hh',
'src/hb-ot-shape-complex-default.cc',
'src/hb-ot-shape-complex-hangul.cc',
'src/hb-ot-shape-complex-hebrew.cc',
'src/hb-ot-shape-complex-indic.cc',
'src/hb-ot-shape-complex-indic-machine.hh',
'src/hb-ot-shape-complex-indic-private.hh',
'src/hb-ot-shape-complex-indic-table.cc',
'src/hb-ot-shape-complex-myanmar.cc',
'src/hb-ot-shape-complex-myanmar-machine.hh',
'src/hb-ot-shape-complex-private.hh',
'src/hb-ot-shape-complex-thai.cc',
'src/hb-ot-shape-complex-tibetan.cc',
'src/hb-ot-shape-complex-use.cc',
'src/hb-ot-shape-complex-use-machine.hh',
'src/hb-ot-shape-complex-use-private.hh',
'src/hb-ot-shape-complex-use-table.cc',
'src/hb-ot-shape-fallback.cc',
'src/hb-ot-shape-fallback-private.hh',
'src/hb-ot-shape.h',
'src/hb-ot-shape-normalize.cc',
'src/hb-ot-shape-normalize-private.hh',
'src/hb-ot-shape-private.hh',
'src/hb-ot-tag.cc',
'src/hb-ot-tag.h',
'src/hb-private.hh',
'src/hb-set.cc',
'src/hb-set.h',
'src/hb-set-private.hh',
'src/hb-shape.cc',
'src/hb-shape.h',
'src/hb-shape-plan.cc',
'src/hb-shape-plan.h',
'src/hb-shape-plan-private.hh',
'src/hb-shaper.cc',
'src/hb-shaper-impl-private.hh',
'src/hb-shaper-list.hh',
'src/hb-shaper-private.hh',
'src/hb-unicode.cc',
'src/hb-unicode.h',
'src/hb-unicode-private.hh',
'src/hb-utf-private.hh',
'src/hb-version.h',
'src/hb-warning.cc',
],
'include_dirs': [
'src',
],
'direct_dependent_settings': {
'include_dirs': [
'src',
],
},
'dependencies': [
'../../third_party/icu/icu.gyp:icuuc',
],
'variables': {
'clang_warning_flags': [
'-Wno-unused-value',
# Harfbuzz uses unused typedefs for its static asserts (and its
# static asserts are strange enough that they can't be replaced
# by static_assert).
'-Wno-unused-local-typedef',
],
},
'conditions': [
['OS=="win"', {
# TODO(eae): C4267 on amd64. size_t -> int, size_t -> unsigned int
'msvs_disabled_warnings': [4267, 4334],
}],
['OS=="mac"', {
'defines': [
'HAVE_CORETEXT',
],
'sources': [
'src/hb-coretext.cc',
'src/hb-coretext.h',
],
}],
# When without -fvisibility=hidden for pango to use the harfbuzz
# in the tree, all symbols pango needs must be included, or
# pango uses mixed versions of harfbuzz and leads to crash.
# See crbug.com/462689.
['use_pango==1 and OS=="linux" and chromeos==0 and buildtype!="Official" and target_arch!="arm" and target_arch!="mipsel"', {
'cflags!': ['-fvisibility=hidden'],
'sources': [
'src/hb-ft.cc',
'src/hb-ft.h',
'src/hb-glib.cc',
'src/hb-glib.h',
],
'link_settings': {
'ldflags': [
# These symbols are referenced from libpangoft2, which will be
# dynamically linked later.
'-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs',
],
},
'dependencies': [
'../../build/linux/system.gyp:freetype2',
'../../build/linux/system.gyp:glib',
],
}],
],
},
],
}, { # use_system_harfbuzz==1
'targets': [
{
'target_name': 'harfbuzz-ng',
'type': 'none',
'cflags': [
'<!@(<(pkg-config) --cflags harfbuzz)',
],
'direct_dependent_settings': {
'cflags': [
'<!@(<(pkg-config) --cflags harfbuzz)',
],
},
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other harfbuzz)',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l harfbuzz)',
],
},
},
],
}],
],
}
5 changes: 5 additions & 0 deletions third_party/harfbuzz-ng/src/hb-coretext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
scratch += old_scratch_used;
scratch_size -= old_scratch_used;
}
retry:
{
string_ref = CFStringCreateWithCharactersNoCopy (NULL,
pchars, chars_len,
Expand Down Expand Up @@ -1128,6 +1129,10 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
* AAT shaper
*/

HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, face)
HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, font)


/*
* shaper face data
*/
Expand Down
2 changes: 2 additions & 0 deletions third_party/harfbuzz-ng/src/hb-face.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,5 @@ hb_face_t::load_num_glyphs (void) const
num_glyphs = maxp_table->get_num_glyphs ();
hb_blob_destroy (maxp_blob);
}


2 changes: 2 additions & 0 deletions third_party/harfbuzz-ng/src/hb-ot-tag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -929,3 +929,5 @@ hb_ot_tag_to_language (hb_tag_t tag)
return hb_language_from_string ((char *) buf, -1);
}
}


0 comments on commit 3b0b683

Please sign in to comment.