From fca27860417812d51e40f040de97c10177b1250e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 11 May 2019 00:37:01 -0700 Subject: [PATCH] [config] Make HB_DISABLE_DEPRECATED actually compile Part of https://github.com/harfbuzz/harfbuzz/issues/1652 --- src/hb-config.hh | 7 +++++++ src/hb-font.cc | 8 ++++++++ src/hb-font.hh | 12 ++++++++++-- src/hb-graphite2.cc | 2 ++ src/hb-icu.cc | 2 +- src/hb-ot-layout.cc | 7 ++++++- src/hb-ot-shape-fallback.cc | 4 ++++ src/hb-ot-tag.cc | 4 ++++ src/hb-ot-var-fvar-table.hh | 6 ++++++ src/hb-ot-var.cc | 2 ++ src/hb-set.cc | 2 ++ src/hb-unicode.cc | 6 ++++++ src/hb-unicode.hh | 10 +++++++--- 13 files changed, 65 insertions(+), 7 deletions(-) diff --git a/src/hb-config.hh b/src/hb-config.hh index bd1becb79..087e669c9 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 c00f33329..19ee353eb 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -336,6 +336,7 @@ hb_font_get_glyph_v_origin_default (hb_font_t *font, 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 @@ hb_font_get_glyph_v_kerning_default (hb_font_t *font, { 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 @@ hb_font_get_glyph_v_origin (hb_font_t *font, 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 @@ hb_font_get_glyph_v_kerning (hb_font_t *font, { return font->get_glyph_v_kerning (top_glyph, bottom_glyph); } +#endif /** * hb_font_get_glyph_extents: @@ -1173,6 +1177,7 @@ hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, 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 @@ hb_font_get_glyph_kerning_for_direction (hb_font_t *font, { 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 @@ hb_font_get_var_coords_normalized (hb_font_t *font, } +#ifndef HB_DISABLE_DEPRECATED /* * Deprecated get_glyph_func(): */ @@ -2038,3 +2045,4 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, trampoline, trampoline_destroy); } +#endif diff --git a/src/hb-font.hh b/src/hb-font.hh index 4f5aa8a60..95551bfd2 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 @@ struct hb_font_t 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 fdb545342..5b1ba4515 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -202,6 +202,7 @@ _hb_graphite2_shaper_font_data_destroy (hb_graphite2_font_data_t *data HB_UNUSED { } +#ifndef HB_DISABLE_DEPRECATED /** * hb_graphite2_font_get_gr_font: * @@ -213,6 +214,7 @@ hb_graphite2_font_get_gr_font (hb_font_t *font HB_UNUSED) { return nullptr; } +#endif /* diff --git a/src/hb-icu.cc b/src/hb-icu.cc index c26c91d48..99305ae55 100644 --- a/src/hb-icu.cc +++ b/src/hb-icu.cc @@ -236,7 +236,7 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, /* 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 25ad22625..acc996158 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -512,6 +512,7 @@ hb_ot_layout_table_find_script (hb_face_t *face, return false; } +#ifndef HB_DISABLE_DEPRECATED /** * hb_ot_layout_table_choose_script: * @face: #hb_face_t to work upon @@ -533,6 +534,7 @@ hb_ot_layout_table_choose_script (hb_face_t *face, 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 @@ hb_ot_layout_script_get_language_tags (hb_face_t *face, } +#ifndef HB_DISABLE_DEPRECATED /** * hb_ot_layout_script_find_language: * @face: #hb_face_t to work upon @@ -697,6 +700,8 @@ hb_ot_layout_script_get_language_tags (hb_face_t *face, * * 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 @@ hb_ot_layout_script_find_language (hb_face_t *face, &language_tag, language_index); } +#endif /** @@ -728,7 +734,6 @@ hb_ot_layout_script_find_language (hb_face_t *face, * * 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 42b728fd1..573af8ec6 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -456,6 +456,7 @@ _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan, } +#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 @@ struct hb_ot_shape_fallback_kern_driver_t hb_font_t *font; hb_direction_t direction; }; +#endif /* Performs font-assisted kerning. */ void @@ -485,6 +487,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan, 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 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan, if (reverse) buffer->reverse (); +#endif } diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc index 4b42da42d..ad3635bda 100644 --- a/src/hb-ot-tag.cc +++ b/src/hb-ot-tag.cc @@ -113,6 +113,7 @@ hb_ot_new_tag_to_script (hb_tag_t tag) 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 @@ hb_ot_tags_from_script (hb_script_t script, *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 @@ struct LangTag /*{"??", {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_tag_from_language (hb_language_t language) 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 c73348ef4..aa89dce26 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -114,6 +114,7 @@ struct fvar 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 @@ struct fvar 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 @@ struct fvar 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 @@ struct fvar } return axisCount; } +#endif unsigned int get_axis_infos (unsigned int start_offset, unsigned int *axes_count /* IN/OUT */, @@ -185,6 +189,7 @@ struct fvar 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 @@ struct fvar *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 e327fb762..25a246a21 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -75,6 +75,7 @@ hb_ot_var_get_axis_count (hb_face_t *face) return face->table.fvar->get_axis_count (); } +#ifndef HB_DISABLE_DEPRECATED /** * hb_ot_var_get_axes: * @@ -104,6 +105,7 @@ hb_ot_var_find_axis (hb_face_t *face, { 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 068236264..fa9868809 100644 --- a/src/hb-set.cc +++ b/src/hb-set.cc @@ -389,6 +389,7 @@ hb_set_symmetric_difference (hb_set_t *set, set->symmetric_difference (other); } +#ifndef HB_DISABLE_DEPRECATED /** * hb_set_invert: * @set: a set. @@ -403,6 +404,7 @@ void 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 d32cace64..94106faee 100644 --- a/src/hb-unicode.cc +++ b/src/hb-unicode.cc @@ -60,6 +60,7 @@ hb_unicode_combining_class_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED, 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 @@ hb_unicode_eastasian_width_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED, { 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 @@ hb_unicode_decompose_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED, } +#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 @@ hb_unicode_decompose_compatibility_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED { return 0; } +#endif extern "C" hb_unicode_funcs_t *hb_glib_get_unicode_funcs (); @@ -425,6 +429,7 @@ hb_unicode_decompose (hb_unicode_funcs_t *ufuncs, return ufuncs->decompose (ab, a, b); } +#ifndef HB_DISABLE_DEPRECATED /** * hb_unicode_decompose_compatibility: * @ufuncs: Unicode functions. @@ -445,6 +450,7 @@ hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs, { 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 82ebb1064..80624c0ec 100644 --- a/src/hb-unicode.hh +++ b/src/hb-unicode.hh @@ -42,19 +42,19 @@ extern HB_INTERNAL const uint8_t _hb_modified_combining_class[256]; #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 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE 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;