[config] Make HB_DISABLE_DEPRECATED actually compile
Part of https://github.com/harfbuzz/harfbuzz/issues/1652
diff --git a/src/hb-config.hh b/src/hb-config.hh
index bd1becb..087e669 100644
--- a/src/hb-config.hh
+++ b/src/hb-config.hh
@@ -41,6 +41,7 @@
#endif
#ifdef HB_LEAN
+#define HB_DISABLE_DEPRECATED
#define HB_NO_BITMAP
#define HB_NO_CFF
#define HB_NO_MATH
@@ -54,6 +55,12 @@
/* Closure. */
+#ifdef HB_DISABLE_DEPRECATED
+#define HB_IF_NOT_DEPRECATED(x)
+#else
+#define HB_IF_NOT_DEPRECATED(x) x
+#endif
+
#ifdef HB_NO_AAT
#define HB_NO_SHAPE_AAT
#endif
diff --git a/src/hb-font.cc b/src/hb-font.cc
index c00f333..19ee353 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -336,6 +336,7 @@
return ret;
}
+#ifndef HB_DISABLE_DEPRECATED
static hb_position_t
hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
@@ -373,6 +374,7 @@
{
return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph));
}
+#endif
static hb_bool_t
hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
@@ -925,6 +927,7 @@
return font->get_glyph_v_origin (glyph, x, y);
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_font_get_glyph_h_kerning:
* @font: a font.
@@ -964,6 +967,7 @@
{
return font->get_glyph_v_kerning (top_glyph, bottom_glyph);
}
+#endif
/**
* hb_font_get_glyph_extents:
@@ -1173,6 +1177,7 @@
return font->subtract_glyph_origin_for_direction (glyph, direction, x, y);
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_font_get_glyph_kerning_for_direction:
* @font: a font.
@@ -1195,6 +1200,7 @@
{
return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y);
}
+#endif
/**
* hb_font_get_glyph_extents_for_origin:
@@ -1916,6 +1922,7 @@
}
+#ifndef HB_DISABLE_DEPRECATED
/*
* Deprecated get_glyph_func():
*/
@@ -2038,3 +2045,4 @@
trampoline,
trampoline_destroy);
}
+#endif
diff --git a/src/hb-font.hh b/src/hb-font.hh
index 4f5aa8a..95551bf 100644
--- a/src/hb-font.hh
+++ b/src/hb-font.hh
@@ -51,8 +51,8 @@
HB_FONT_FUNC_IMPLEMENT (glyph_v_advances) \
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_IF_NOT_DEPRECATED (HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning)) \
+ HB_IF_NOT_DEPRECATED (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) \
@@ -304,17 +304,25 @@
hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph)
{
+#ifdef HB_DISABLE_DEPRECATED
+ return 0;
+#else
return klass->get.f.glyph_h_kerning (this, user_data,
left_glyph, right_glyph,
klass->user_data.glyph_h_kerning);
+#endif
}
hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph,
hb_codepoint_t bottom_glyph)
{
+#ifdef HB_DISABLE_DEPRECATED
+ return 0;
+#else
return klass->get.f.glyph_v_kerning (this, user_data,
top_glyph, bottom_glyph,
klass->user_data.glyph_v_kerning);
+#endif
}
hb_bool_t get_glyph_extents (hb_codepoint_t glyph,
diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc
index fdb5453..5b1ba45 100644
--- a/src/hb-graphite2.cc
+++ b/src/hb-graphite2.cc
@@ -202,6 +202,7 @@
{
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_graphite2_font_get_gr_font:
*
@@ -213,6 +214,7 @@
{
return nullptr;
}
+#endif
/*
diff --git a/src/hb-icu.cc b/src/hb-icu.cc
index c26c91d..99305ae 100644
--- a/src/hb-icu.cc
+++ b/src/hb-icu.cc
@@ -236,7 +236,7 @@
/* 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];
+ UChar utf16[2], normalized[2 * 19/*HB_UNICODE_MAX_DECOMPOSITION_LEN*/ + 1];
unsigned int len;
hb_bool_t ret, err;
UErrorCode icu_err;
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 25ad226..acc9961 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -512,6 +512,7 @@
return false;
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_ot_layout_table_choose_script:
* @face: #hb_face_t to work upon
@@ -533,6 +534,7 @@
for (t = script_tags; *t; t++);
return hb_ot_layout_table_select_script (face, table_tag, t - script_tags, script_tags, script_index, chosen_script);
}
+#endif
/**
* hb_ot_layout_table_select_script:
@@ -684,6 +686,7 @@
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_ot_layout_script_find_language:
* @face: #hb_face_t to work upon
@@ -697,6 +700,8 @@
*
* Return value: true if the language tag is found, false otherwise
*
+ * Since: ??
+ * Deprecated: ??
**/
hb_bool_t
hb_ot_layout_script_find_language (hb_face_t *face,
@@ -712,6 +717,7 @@
&language_tag,
language_index);
}
+#endif
/**
@@ -728,7 +734,6 @@
*
* Return value: true if the language tag is found, false otherwise
*
- *
* Since: 2.0.0
**/
hb_bool_t
diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc
index 42b728f..573af8e 100644
--- a/src/hb-ot-shape-fallback.cc
+++ b/src/hb-ot-shape-fallback.cc
@@ -456,6 +456,7 @@
}
+#ifndef HB_DISABLE_DEPRECATED
struct hb_ot_shape_fallback_kern_driver_t
{
hb_ot_shape_fallback_kern_driver_t (hb_font_t *font_,
@@ -474,6 +475,7 @@
hb_font_t *font;
hb_direction_t direction;
};
+#endif
/* Performs font-assisted kerning. */
void
@@ -485,6 +487,7 @@
return;
#endif
+#ifndef HB_DISABLE_DEPRECATED
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction) ?
!font->has_glyph_h_kerning_func () :
!font->has_glyph_v_kerning_func ())
@@ -501,6 +504,7 @@
if (reverse)
buffer->reverse ();
+#endif
}
diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc
index 4b42da4..ad3635b 100644
--- a/src/hb-ot-tag.cc
+++ b/src/hb-ot-tag.cc
@@ -113,6 +113,7 @@
return HB_SCRIPT_UNKNOWN;
}
+#ifndef HB_DISABLE_DEPRECATED
void
hb_ot_tags_from_script (hb_script_t script,
hb_tag_t *script_tag_1,
@@ -124,6 +125,7 @@
*script_tag_1 = count > 0 ? tags[0] : HB_OT_TAG_DEFAULT_SCRIPT;
*script_tag_2 = count > 1 ? tags[1] : HB_OT_TAG_DEFAULT_SCRIPT;
}
+#endif
/*
* Complete list at:
@@ -230,6 +232,7 @@
/*{"??", {HB_TAG('Y','I','C',' ')}},*/ /* Yi Classic */
/*{"zh?", {HB_TAG('Z','H','P',' ')}},*/ /* Chinese Phonetic */
+#ifndef HB_DISABLE_DEPRECATED
hb_tag_t
hb_ot_tag_from_language (hb_language_t language)
{
@@ -238,6 +241,7 @@
hb_ot_tags_from_script_and_language (HB_SCRIPT_UNKNOWN, language, nullptr, nullptr, &count, tags);
return count > 0 ? tags[0] : HB_OT_TAG_DEFAULT_LANGUAGE;
}
+#endif
static void
hb_ot_tags_from_language (const char *lang_str,
diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index c73348e..aa89dce 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -114,6 +114,7 @@
unsigned int get_axis_count () const { return axisCount; }
+#ifndef HB_DISABLE_DEPRECATED
void get_axis_deprecated (unsigned int axis_index,
hb_ot_var_axis_t *info) const
{
@@ -125,6 +126,7 @@
info->min_value = hb_min (info->default_value, axis.minValue / 65536.f);
info->max_value = hb_max (info->default_value, axis.maxValue / 65536.f);
}
+#endif
void get_axis_info (unsigned int axis_index,
hb_ot_var_axis_info_t *info) const
@@ -141,6 +143,7 @@
info->reserved = 0;
}
+#ifndef HB_DISABLE_DEPRECATED
unsigned int get_axes_deprecated (unsigned int start_offset,
unsigned int *axes_count /* IN/OUT */,
hb_ot_var_axis_t *axes_array /* OUT */) const
@@ -162,6 +165,7 @@
}
return axisCount;
}
+#endif
unsigned int get_axis_infos (unsigned int start_offset,
unsigned int *axes_count /* IN/OUT */,
@@ -185,6 +189,7 @@
return axisCount;
}
+#ifndef HB_DISABLE_DEPRECATED
bool find_axis_deprecated (hb_tag_t tag,
unsigned int *axis_index,
hb_ot_var_axis_t *info) const
@@ -203,6 +208,7 @@
*axis_index = HB_OT_VAR_NO_AXIS_INDEX;
return false;
}
+#endif
bool find_axis_info (hb_tag_t tag,
hb_ot_var_axis_info_t *info) const
diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc
index e327fb7..25a246a 100644
--- a/src/hb-ot-var.cc
+++ b/src/hb-ot-var.cc
@@ -75,6 +75,7 @@
return face->table.fvar->get_axis_count ();
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_ot_var_get_axes:
*
@@ -104,6 +105,7 @@
{
return face->table.fvar->find_axis_deprecated (axis_tag, axis_index, axis_info);
}
+#endif
/**
* hb_ot_var_get_axis_infos:
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 0682362..fa98688 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -389,6 +389,7 @@
set->symmetric_difference (other);
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_set_invert:
* @set: a set.
@@ -403,6 +404,7 @@
hb_set_invert (hb_set_t *set HB_UNUSED)
{
}
+#endif
/**
* hb_set_get_population:
diff --git a/src/hb-unicode.cc b/src/hb-unicode.cc
index d32cace..94106fa 100644
--- a/src/hb-unicode.cc
+++ b/src/hb-unicode.cc
@@ -60,6 +60,7 @@
return HB_UNICODE_COMBINING_CLASS_NOT_REORDERED;
}
+#ifndef HB_DISABLE_DEPRECATED
static unsigned int
hb_unicode_eastasian_width_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t unicode HB_UNUSED,
@@ -67,6 +68,7 @@
{
return 1;
}
+#endif
static hb_unicode_general_category_t
hb_unicode_general_category_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
@@ -113,6 +115,7 @@
}
+#ifndef HB_DISABLE_DEPRECATED
static unsigned int
hb_unicode_decompose_compatibility_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t u HB_UNUSED,
@@ -121,6 +124,7 @@
{
return 0;
}
+#endif
extern "C" hb_unicode_funcs_t *hb_glib_get_unicode_funcs ();
@@ -425,6 +429,7 @@
return ufuncs->decompose (ab, a, b);
}
+#ifndef HB_DISABLE_DEPRECATED
/**
* hb_unicode_decompose_compatibility:
* @ufuncs: Unicode functions.
@@ -445,6 +450,7 @@
{
return ufuncs->decompose_compatibility (u, decomposed);
}
+#endif
/* See hb-unicode.hh for details. */
diff --git a/src/hb-unicode.hh b/src/hb-unicode.hh
index 82ebb10..80624c0 100644
--- a/src/hb-unicode.hh
+++ b/src/hb-unicode.hh
@@ -42,19 +42,19 @@
#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS \
HB_UNICODE_FUNC_IMPLEMENT (combining_class) \
- HB_UNICODE_FUNC_IMPLEMENT (eastasian_width) \
+ HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (eastasian_width)) \
HB_UNICODE_FUNC_IMPLEMENT (general_category) \
HB_UNICODE_FUNC_IMPLEMENT (mirroring) \
HB_UNICODE_FUNC_IMPLEMENT (script) \
HB_UNICODE_FUNC_IMPLEMENT (compose) \
HB_UNICODE_FUNC_IMPLEMENT (decompose) \
- HB_UNICODE_FUNC_IMPLEMENT (decompose_compatibility) \
+ HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (decompose_compatibility)) \
/* ^--- Add new callbacks here */
/* Simple callbacks are those taking a hb_codepoint_t and returning a hb_codepoint_t */
#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE \
HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_combining_class_t, combining_class) \
- HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width) \
+ HB_IF_NOT_DEPRECATED (HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width)) \
HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_general_category_t, general_category) \
HB_UNICODE_FUNC_IMPLEMENT (hb_codepoint_t, mirroring) \
HB_UNICODE_FUNC_IMPLEMENT (hb_script_t, script) \
@@ -89,7 +89,11 @@
unsigned int decompose_compatibility (hb_codepoint_t u,
hb_codepoint_t *decomposed)
{
+#ifdef HB_DISABLE_DEPRECATED
+ unsigned int ret = 0;
+#else
unsigned int ret = func.decompose_compatibility (this, u, decomposed, user_data.decompose_compatibility);
+#endif
if (ret == 1 && u == decomposed[0]) {
decomposed[0] = 0;
return 0;