Path: blob/master/thirdparty/harfbuzz/src/graph/gsubgpos-context.cc
9904 views
/*1* Copyright © 2022 Google, Inc.2*3* This is part of HarfBuzz, a text shaping library.4*5* Permission is hereby granted, without written agreement and without6* license or royalty fees, to use, copy, modify, and distribute this7* software and its documentation for any purpose, provided that the8* above copyright notice and the following two paragraphs appear in9* all copies of this software.10*11* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR12* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES13* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN14* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH15* DAMAGE.16*17* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,18* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND19* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS20* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO21* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.22*23* Google Author(s): Garret Rieger24*/2526#include "gsubgpos-graph.hh"2728namespace graph {2930gsubgpos_graph_context_t::gsubgpos_graph_context_t (hb_tag_t table_tag_,31graph_t& graph_)32: table_tag (table_tag_),33graph (graph_),34lookup_list_index (0),35lookups ()36{37if (table_tag_ != HB_OT_TAG_GPOS38&& table_tag_ != HB_OT_TAG_GSUB)39return;4041GSTAR* gstar = graph::GSTAR::graph_to_gstar (graph_);42if (gstar) {43gstar->find_lookups (graph, lookups);44lookup_list_index = gstar->get_lookup_list_index (graph_);45}46}4748unsigned gsubgpos_graph_context_t::create_node (unsigned size)49{50char* buffer = (char*) hb_calloc (1, size);51if (!buffer)52return -1;5354if (!add_buffer (buffer)) {55// Allocation did not get stored for freeing later.56hb_free (buffer);57return -1;58}5960return graph.new_node (buffer, buffer + size);61}6263unsigned gsubgpos_graph_context_t::num_non_ext_subtables () {64unsigned count = 0;65for (auto l : lookups.values ())66{67if (l->is_extension (table_tag)) continue;68count += l->number_of_subtables ();69}70return count;71}7273}747576