Skip to content

Commit f5593a3

Browse files
authored
feat(compat.harfbuzz): switch no-freetype for 14.3.0 (revision 2) (#860)
A feature, off by default, so the default build is the one it was. The backend's HAVE_* defines move from cxxflags into a generated config.h, read under HAVE_CONFIG_H (hb-config.hh still supplies every other default), and the switch leaves them out (MCPP_FEATURE_NO_FREETYPE is defined for the package's own units). Why: with HAVE_FREETYPE, hb_font_create() reaches hb_ft_font_set_funcs through hb_font_set_funcs_using()'s table of backends, so every program that makes a font links all of FreeType (its core and every driver) whether or not it names FreeType. A consumer whose fonts take HarfBuzz's own `ot` functions (the first in that table, the default) turns the switch on and carries none of it; the functions of <hb-ft.h> are then not defined.
1 parent 4191fe3 commit f5593a3

1 file changed

Lines changed: 43 additions & 15 deletions

File tree

‎pkgs/c/compat.harfbuzz.lua‎

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
-- naming only HAVE_FREETYPE selects precisely the FreeType backend without
1818
-- editing anything.
1919
--
20-
-- NO config.h. HarfBuzz reads one only under HAVE_CONFIG_H, which is not
21-
-- defined here; `hb-config.hh` then supplies the defaults. That is what keeps
22-
-- this a source-only package with no configure step.
20+
-- ONE GENERATED config.h, no configure step. HarfBuzz reads a config.h under
21+
-- HAVE_CONFIG_H; the one below (mcpp_generated/config.h) only names the
22+
-- backend's HAVE_* switches, so `hb-config.hh` still supplies every default.
23+
-- It exists for the switch no-freetype (below), which a command-line define
24+
-- could not take back.
2325
--
2426
-- HB_NO_MT IS DELIBERATELY NOT SET. It drops HarfBuzz's atomics and locks,
2527
-- which is only sound when the consumer guarantees single-threaded use --
@@ -42,8 +44,9 @@ package = {
4244
},
4345
sha256 = "566e996a1b40486954fb7110ffe6eb88a0f7958bb466cdb023b0302618acea4a",
4446
-- 1: hb-ft with FreeType's variation and transform entry points
45-
-- (the HAVE_FT_* cxxflags below): installed copies take them.
46-
revision = 1,
47+
-- (the HAVE_FT_* below): installed copies take them.
48+
-- 2: the switch no-freetype, read in the generated config.h.
49+
revision = 2,
4750
},
4851
},
4952
macosx = {
@@ -54,8 +57,9 @@ package = {
5457
},
5558
sha256 = "566e996a1b40486954fb7110ffe6eb88a0f7958bb466cdb023b0302618acea4a",
5659
-- 1: hb-ft with FreeType's variation and transform entry points
57-
-- (the HAVE_FT_* cxxflags below): installed copies take them.
58-
revision = 1,
60+
-- (the HAVE_FT_* below): installed copies take them.
61+
-- 2: the switch no-freetype, read in the generated config.h.
62+
revision = 2,
5963
},
6064
},
6165
windows = {
@@ -66,16 +70,17 @@ package = {
6670
},
6771
sha256 = "566e996a1b40486954fb7110ffe6eb88a0f7958bb466cdb023b0302618acea4a",
6872
-- 1: hb-ft with FreeType's variation and transform entry points
69-
-- (the HAVE_FT_* cxxflags below): installed copies take them.
70-
revision = 1,
73+
-- (the HAVE_FT_* below): installed copies take them.
74+
-- 2: the switch no-freetype, read in the generated config.h.
75+
revision = 2,
7176
},
7277
},
7378
},
7479

7580
mcpp = {
7681
language = "c++23",
7782
import_std = false,
78-
include_dirs = { "*/src" },
83+
include_dirs = { "mcpp_generated", "*/src" },
7984
sources = { "*/src/harfbuzz.cc" },
8085
-- HAVE_FREETYPE turns on hb-ft.cc inside the amalgamation, which is
8186
-- what makes <hb-ft.h> more than a set of declarations. The public
@@ -90,11 +95,34 @@ package = {
9095
-- face's FT_Set_Transform, and upstream's shaping suites fail with
9196
-- --font-funcs=ft on every variable font (TestGVAR*, TestHVAR*,
9297
-- TestCVARGVAR*, HBTest-VF …).
93-
cxxflags = { "-DHAVE_FREETYPE=1",
94-
"-DHAVE_FT_GET_VAR_BLEND_COORDINATES=1",
95-
"-DHAVE_FT_SET_VAR_BLEND_COORDINATES=1",
96-
"-DHAVE_FT_DONE_MM_VAR=1",
97-
"-DHAVE_FT_GET_TRANSFORM=1" },
98+
--
99+
-- They are in config.h, not cxxflags, for the switch no-freetype:
100+
-- with HAVE_FREETYPE, hb_font_create() reaches hb_ft_font_set_funcs
101+
-- through hb_font_set_funcs_using()'s table of backends, so every
102+
-- program that makes a font links all of FreeType (its core and every
103+
-- driver), whether or not it ever names FreeType. A consumer whose
104+
-- fonts take HarfBuzz's own `ot` functions (the default first in that
105+
-- table) turns it on and carries none of it; <hb-ft.h>'s functions
106+
-- are then not defined.
107+
cxxflags = { "-DHAVE_CONFIG_H=1" },
108+
generated_files = {
109+
["mcpp_generated/config.h"] = [==[
110+
/* compat.harfbuzz: the backend HarfBuzz is built with. mcpp defines
111+
MCPP_FEATURE_NO_FREETYPE for this package's units when the switch is on. */
112+
#ifndef MCPP_FEATURE_NO_FREETYPE
113+
#define HAVE_FREETYPE 1
114+
#define HAVE_FT_GET_VAR_BLEND_COORDINATES 1
115+
#define HAVE_FT_SET_VAR_BLEND_COORDINATES 1
116+
#define HAVE_FT_DONE_MM_VAR 1
117+
#define HAVE_FT_GET_TRANSFORM 1
118+
#endif
119+
]==],
120+
},
121+
-- no-freetype HarfBuzz without its FreeType backend (hb-ft): off by
122+
-- default, the build it always was.
123+
features = {
124+
["no-freetype"] = {},
125+
},
98126
targets = { ["harfbuzz"] = { kind = "lib" } },
99127
deps = { ["compat.freetype"] = "2.13.3" },
100128
linux = {

0 commit comments

Comments
 (0)