diff --git a/src/Makefile.sources b/src/Makefile.sources index 156b3ab50..81b5cde7a 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -63,7 +63,6 @@ HB_BASE_sources = \ hb-ot-cff2-table.cc \ hb-ot-cff2-table.hh \ hb-ot-cmap-table.hh \ - hb-ot-color-cbdt-table.cc \ hb-ot-color-cbdt-table.hh \ hb-ot-color-colr-table.hh \ hb-ot-color-cpal-table.hh \ @@ -254,7 +253,6 @@ HB_SUBSET_sources = \ hb-number.hh \ hb-ot-cff1-table.cc \ hb-ot-cff2-table.cc \ - hb-ot-color-cbdt-table.cc \ hb-static.cc \ hb-subset-cff-common.cc \ hb-subset-cff-common.hh \ diff --git a/src/harfbuzz.cc b/src/harfbuzz.cc index 1d5a39f05..6a07a9e0d 100644 --- a/src/harfbuzz.cc +++ b/src/harfbuzz.cc @@ -12,7 +12,6 @@ #include "hb-number.cc" #include "hb-ot-cff1-table.cc" #include "hb-ot-cff2-table.cc" -#include "hb-ot-color-cbdt-table.cc" #include "hb-ot-color.cc" #include "hb-ot-face.cc" #include "hb-ot-font.cc" diff --git a/src/hb-ot-color-cbdt-table.cc b/src/hb-ot-color-cbdt-table.cc deleted file mode 100644 index f132ce164..000000000 --- a/src/hb-ot-color-cbdt-table.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2020 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Calder Kitagawa - */ - -#include "hb-open-type.hh" - -#include "hb-ot-color-cbdt-table.hh" - -namespace OT { - -namespace CBDT_internal { - -bool copy_data_to_cbdt (hb_vector_t *cbdt_prime, - const void *data, - unsigned int length) -{ - unsigned int new_len = cbdt_prime->length + length; - if (unlikely (!cbdt_prime->alloc(new_len))) return false; - memcpy (cbdt_prime->arrayZ + cbdt_prime->length, data, length); - cbdt_prime->length = new_len; - return true; -} - -} - -bool CBLC::subset (hb_subset_context_t *c) const -{ - TRACE_SUBSET (this); - - auto* cblc_prime = c->serializer->start_embed (); - - // Use a vector as a secondary buffer as the tables need to be built in parallel. - hb_vector_t cbdt_prime; - - if (unlikely (!cblc_prime)) return_trace (false); - if (unlikely (!c->serializer->extend_min(cblc_prime))) return_trace (false); - cblc_prime->version = version; - - hb_blob_t* cbdt_blob = hb_sanitize_context_t ().reference_table (c->plan->source); - unsigned int cbdt_length; - CBDT* cbdt = (CBDT *) hb_blob_get_data (cbdt_blob, &cbdt_length); - if (unlikely (cbdt_length < CBDT::min_size)) return_trace (false); - CBDT_internal::copy_data_to_cbdt (&cbdt_prime, cbdt, CBDT::min_size); - - for (const BitmapSizeTable& table : + sizeTables.iter ()) - subset_size_table (c, table, (const char *) cbdt, cbdt_length, cblc_prime, &cbdt_prime); - - hb_blob_destroy (cbdt_blob); - - return_trace (CBLC::sink_cbdt (c, &cbdt_prime)); -} - -} /* namespace OT */ diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index 272d2d0b8..950a5cb9e 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -43,15 +43,6 @@ namespace OT { -namespace CBDT_internal { - -// Helper function internal to CBDT. -HB_INTERNAL bool copy_data_to_cbdt (hb_vector_t *cbdt_prime, - const void *data, - unsigned int length); - -} - struct cblc_bitmap_size_subset_context_t { const char *cbdt; @@ -69,6 +60,18 @@ struct cblc_bitmap_size_subset_context_t hb_codepoint_t end_glyph; /* OUT */ }; +static inline bool +_copy_data_to_cbdt (hb_vector_t *cbdt_prime, + const void *data, + unsigned length) +{ + unsigned int new_len = cbdt_prime->length + length; + if (unlikely (!cbdt_prime->alloc (new_len))) return false; + memcpy (cbdt_prime->arrayZ + cbdt_prime->length, data, length); + cbdt_prime->length = new_len; + return true; +} + struct SmallGlyphMetrics { bool sanitize (hb_sanitize_context_t *c) const @@ -279,7 +282,7 @@ struct IndexSubtable auto* header_prime = subtable_prime->get_header(); unsigned int new_local_offset = cbdt_prime->length - (unsigned int) header_prime->imageDataOffset; - if (unlikely (!CBDT_internal::copy_data_to_cbdt (cbdt_prime, cbdt + offset, length))) return_trace (false); + if (unlikely (!_copy_data_to_cbdt (cbdt_prime, cbdt + offset, length))) return_trace (false); return_trace (subtable_prime->add_offset (c, new_local_offset, size)); } @@ -868,8 +871,8 @@ struct CBDT return true; } - hb_blob_t* reference_png (hb_font_t *font, - hb_codepoint_t glyph) const + hb_blob_t* + reference_png (hb_font_t *font, hb_codepoint_t glyph) const { const void *base; const BitmapSizeTable &strike = this->cblc->choose_strike (font); @@ -944,6 +947,34 @@ struct CBDT DEFINE_SIZE_ARRAY(4, dataZ); }; +inline bool +CBLC::subset (hb_subset_context_t *c) const +{ + TRACE_SUBSET (this); + + auto* cblc_prime = c->serializer->start_embed (); + + // Use a vector as a secondary buffer as the tables need to be built in parallel. + hb_vector_t cbdt_prime; + + if (unlikely (!cblc_prime)) return_trace (false); + if (unlikely (!c->serializer->extend_min(cblc_prime))) return_trace (false); + cblc_prime->version = version; + + hb_blob_t* cbdt_blob = hb_sanitize_context_t ().reference_table (c->plan->source); + unsigned int cbdt_length; + CBDT* cbdt = (CBDT *) hb_blob_get_data (cbdt_blob, &cbdt_length); + if (unlikely (cbdt_length < CBDT::min_size)) return_trace (false); + _copy_data_to_cbdt (&cbdt_prime, cbdt, CBDT::min_size); + + for (const BitmapSizeTable& table : + sizeTables.iter ()) + subset_size_table (c, table, (const char *) cbdt, cbdt_length, cblc_prime, &cbdt_prime); + + hb_blob_destroy (cbdt_blob); + + return_trace (CBLC::sink_cbdt (c, &cbdt_prime)); +} + struct CBDT_accelerator_t : CBDT::accelerator_t {}; } /* namespace OT */