From dba1ac1b0e8f5f96974fc1119b318ae6127daa82 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 12 May 2019 15:33:31 -0700 Subject: [PATCH] [config] Disable buffer serialize routines in HB_TINY Part of https://github.com/harfbuzz/harfbuzz/issues/1652 --- src/hb-buffer-serialize.cc | 14 +++++++++++++- src/hb-config.hh | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/hb-buffer-serialize.cc b/src/hb-buffer-serialize.cc index dcbdcea45..d3732fd02 100644 --- a/src/hb-buffer-serialize.cc +++ b/src/hb-buffer-serialize.cc @@ -28,8 +28,10 @@ static const char *serialize_formats[] = { +#ifndef HB_NO_BUFFER_SERIALIZE "text", "json", +#endif nullptr }; @@ -85,10 +87,12 @@ hb_buffer_serialize_format_from_string (const char *str, int len) const char * hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format) { - switch (format) + switch ((unsigned) format) { +#ifndef HB_NO_BUFFER_SERIALIZE case HB_BUFFER_SERIALIZE_FORMAT_TEXT: return serialize_formats[0]; case HB_BUFFER_SERIALIZE_FORMAT_JSON: return serialize_formats[1]; +#endif default: case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return nullptr; } @@ -344,6 +348,10 @@ hb_buffer_serialize_glyphs (hb_buffer_t *buffer, if (buf_size) *buf = '\0'; +#ifdef HB_NO_BUFFER_SERIALIZE + return 0; +#endif + assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) || buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); @@ -449,6 +457,10 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, end_ptr = &end; *end_ptr = buf; +#ifdef HB_NO_BUFFER_SERIALIZE + return false; +#endif + assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) || buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); diff --git a/src/hb-config.hh b/src/hb-config.hh index e7e14df6a..2eab7d8b6 100644 --- a/src/hb-config.hh +++ b/src/hb-config.hh @@ -45,6 +45,7 @@ #ifdef HB_LEAN #define HB_DISABLE_DEPRECATED #define HB_NO_ATEXIT +#define HB_NO_BUFFER_SERIALIZE #define HB_NO_BITMAP #define HB_NO_CFF #define HB_NO_COLOR