Skip to content

Commit

Permalink
Updating harfbuzz to 8.3.0
Browse files Browse the repository at this point in the history
[This thread](https://2dimensions.slack.com/archives/C067PQQL3EK/p1708104838351439) had me looking through the harfbuzz codebase to see if we could change the way some of the symbols were exported (our renames was getting clashing defines).

That made me take a closer look at all the changes since 6.0.0 (the version we were pegged at). There are a ton of performance and stability changes since 6.0.0 that we really want (take a look at the [release page](https://github.com/harfbuzz/harfbuzz/releases) for a list).

So I took this opportunity to update our renames script, pin us to a new harfbuzz and branch it with some changes to disable exporting certain symbols that are normally accessed via defines in C++ but are exported as a courtesy to wrapping language bindings. We don't need those so I added a way to compile them out for us.

Diffs=
9d605a1fe Updating harfbuzz to 8.3.0 (#6652)

Co-authored-by: Luigi Rosso <[email protected]>
  • Loading branch information
luigi-rosso and luigi-rosso committed Feb 20, 2024
1 parent c6d407a commit 03d7c9c
Show file tree
Hide file tree
Showing 6 changed files with 714 additions and 355 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5cb42a9b0033a1b9d2360292b7ef14bf67e3d45e
9d605a1feb39dcad526ac9dda6b53b547921c58d
58 changes: 55 additions & 3 deletions dependencies/gen_harfbuzz_renames/gen_header.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,79 @@
import 'dart:collection';
import 'dart:io';

var skip = HashSet.from(
final skip = HashSet.from(
[
'hb_color_get_alpha',
'hb_color_get_green',
'hb_color_get_blue',
'hb_color_get_red',
'hb_glyph_info_get_glyph_flags',
'hb_declval',
],
);

final extras = HashSet.from(
[
'lookup_standard_encoding_for_code',
'lookup_expert_encoding_for_code',
'lookup_expert_charset_for_sid',
'lookup_expert_subset_charset_for_sid',
'lookup_standard_encoding_for_sid',
'accelerator_t',
'get_seac_components',
'data_destroy_arabic',
],
);

void main() {
final uniqueNames = HashSet<String>();
var header = StringBuffer();
header.writeln('// clang-format off');
header.writeln('// hb_*');
var contents = File('harfbuzz_names.txt').readAsStringSync();
RegExp exp = RegExp(r'\s_(hb_([a-zA-Z0-9_]*))$', multiLine: true);
RegExp exp = RegExp(r'\s(hb_([a-zA-Z0-9_]*))', multiLine: true);
Iterable<RegExpMatch> matches = exp.allMatches(contents);
for (final m in matches) {
var symbolName = m[1];
if (skip.contains(symbolName)) {
if (symbolName == null ||
skip.contains(symbolName) ||
uniqueNames.contains(symbolName)) {
continue;
}
uniqueNames.add(symbolName);
header.writeln('#define $symbolName rive_$symbolName');
}
header.writeln('// _hb_*');
{
RegExp exp = RegExp(r'\s_(hb_([a-zA-Z0-9_]*))', multiLine: true);
Iterable<RegExpMatch> matches = exp.allMatches(contents);
for (final m in matches) {
var symbolName = m[1];
if (symbolName == null ||
skip.contains(symbolName) ||
uniqueNames.contains(symbolName)) {
continue;
}
uniqueNames.add(symbolName);
header.writeln('#define $symbolName rive_$symbolName');
}
}
header.writeln('// __hb_*');
{
RegExp exp = RegExp(r'\s_(_hb_([a-zA-Z0-9_]*))', multiLine: true);
Iterable<RegExpMatch> matches = exp.allMatches(contents);
for (final m in matches) {
var symbolName = m[1];
if (symbolName == null ||
skip.contains(symbolName) ||
uniqueNames.contains(symbolName)) {
continue;
}
uniqueNames.add(symbolName);
header.writeln('#define $symbolName rive_$symbolName');
}
}
for (final symbolName in extras) {
header.writeln('#define $symbolName rive_$symbolName');
}
File('../rive_harfbuzz_renames.h').writeAsStringSync(header.toString());
Expand Down
13 changes: 11 additions & 2 deletions dependencies/premake5_harfbuzz.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('setup_compiler')
local dependency = require('dependency')
harfbuzz = dependency.github('harfbuzz/harfbuzz', '6.0.0')
harfbuzz = dependency.github('rive-app/harfbuzz', 'rive_8.3.0')

workspace('rive')
configurations({ 'debug', 'release' })
Expand Down Expand Up @@ -218,11 +218,14 @@ do
harfbuzz .. '/src/hb-vector.hh',
harfbuzz .. '/src/hb.hh',
harfbuzz .. '/src/graph/gsubgpos-context.cc',
harfbuzz .. '/src/hb-paint.cc',
harfbuzz .. '/src/hb-paint-extents.cc',
harfbuzz .. '/src/hb-outline.cc',
})

warnings('Off')

defines({ 'HAVE_OT', 'HB_NO_FALLBACK_SHAPE', 'HB_NO_WIN1256' })
defines({ 'HAVE_OT', 'HB_NO_FALLBACK_SHAPE', 'HB_NO_WIN1256', 'HB_NO_EXTERN_HELPERS' })

filter('system:emscripten')
do
Expand All @@ -238,6 +241,12 @@ do
'-Werror=vla',
})
end
filter('toolset:msc')
do
buildoptions({
'/bigobj',
})
end

filter('configurations:debug')
do
Expand Down
13 changes: 11 additions & 2 deletions dependencies/premake5_harfbuzz_v2.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dofile('rive_build_config.lua')

local dependency = require('dependency')
harfbuzz = dependency.github('harfbuzz/harfbuzz', '6.0.0')
harfbuzz = dependency.github('rive-app/harfbuzz', 'rive_8.3.0')

newoption({
trigger = 'no-harfbuzz-renames',
Expand Down Expand Up @@ -217,11 +217,14 @@ do
harfbuzz .. '/src/hb-vector.hh',
harfbuzz .. '/src/hb.hh',
harfbuzz .. '/src/graph/gsubgpos-context.cc',
harfbuzz .. '/src/hb-paint.cc',
harfbuzz .. '/src/hb-paint-extents.cc',
harfbuzz .. '/src/hb-outline.cc',
})

warnings('Off')

defines({ 'HAVE_OT', 'HB_NO_FALLBACK_SHAPE', 'HB_NO_WIN1256' })
defines({ 'HAVE_OT', 'HB_NO_FALLBACK_SHAPE', 'HB_NO_WIN1256', 'HB_NO_EXTERN_HELPERS' })

filter('toolset:not msc')
do
Expand All @@ -232,6 +235,12 @@ do
'-Werror=vla',
})
end
filter('toolset:msc')
do
buildoptions({
'/bigobj',
})
end

filter('options:config=release')
do
Expand Down
Loading

0 comments on commit 03d7c9c

Please sign in to comment.