mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-15 01:18:13 +00:00
[instancer] add a unit testcase for instantiating item variations
This commit is contained in:
parent
7741fa3299
commit
c330c29175
3 changed files with 72 additions and 0 deletions
|
@ -458,6 +458,7 @@ COMPILED_TESTS = \
|
|||
test-classdef-graph \
|
||||
test-instancer-solver \
|
||||
test-tuple-varstore \
|
||||
test-item-varstore \
|
||||
$(NULL)
|
||||
COMPILED_TESTS_CPPFLAGS = $(HBCFLAGS) -DMAIN -UNDEBUG
|
||||
COMPILED_TESTS_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
@ -536,6 +537,10 @@ test_tuple_varstore_SOURCES = test-tuple-varstore.cc hb-subset-instancer-solver.
|
|||
test_tuple_varstore_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_tuple_varstore_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
test_item_varstore_SOURCES = test-item-varstore.cc hb-subset-instancer-solver.cc hb-static.cc
|
||||
test_item_varstore_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
|
||||
test_item_varstore_LDADD = $(COMPILED_TESTS_LDADD)
|
||||
|
||||
dist_check_SCRIPTS = \
|
||||
check-c-linkage-decls.py \
|
||||
check-externs.py \
|
||||
|
|
|
@ -703,6 +703,7 @@ if get_option('tests').enabled()
|
|||
'test-serialize': ['test-serialize.cc', 'hb-static.cc'],
|
||||
'test-set': ['test-set.cc', 'hb-static.cc'],
|
||||
'test-tuple-varstore': ['test-tuple-varstore.cc', 'hb-subset-instancer-solver.cc', 'hb-static.cc'],
|
||||
'test-item-varstore': ['test-item-varstore.cc', 'hb-subset-instancer-solver.cc', 'hb-static.cc'],
|
||||
'test-use-table': 'test-use-table.cc',
|
||||
'test-vector': ['test-vector.cc', 'hb-static.cc'],
|
||||
}
|
||||
|
|
66
src/test-item-varstore.cc
Normal file
66
src/test-item-varstore.cc
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#include "hb-ot-var-common.hh"
|
||||
#include "hb-ot-var-hvar-table.hh"
|
||||
// HVAR table data from SourceSerif4Variable-Roman_subset.otf
|
||||
const char hvar_data[] = "\x0\x1\x0\x0\x0\x0\x0\x14\x0\x0\x0\xc4\x0\x0\x0\x0\x0\x0\x0\x0\x0\x1\x0\x0\x0\x10\x0\x2\x0\x0\x0\x74\x0\x0\x0\x7a\x0\x2\x0\x8\xc0\x0\xc0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x40\x0\x40\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\xc0\x0\xc0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x40\x0\x40\x0\xc0\x0\xc0\x0\x0\x0\xc0\x0\xc0\x0\x0\x0\xc0\x0\xc0\x0\x0\x0\x0\x0\x40\x0\x40\x0\x0\x0\x40\x0\x40\x0\xc0\x0\xc0\x0\x0\x0\x0\x0\x40\x0\x40\x0\x0\x0\x40\x0\x40\x0\x0\x1\x0\x0\x0\x0\x0\x4\x0\x0\x0\x8\x0\x0\x0\x1\x0\x2\x0\x3\x0\x4\x0\x5\x0\x6\x0\x7\xf9\xf\x2f\xbf\xfb\xfb\x35\xf9\x4\x4\xf3\xb4\xf2\xfb\x2e\xf3\x4\x4\xe\xad\xfa\x1\x1a\x1\x15\x22\x59\xd6\xe3\xf6\x6\xf5\x0\x1\x0\x5\x0\x4\x7\x5\x6";
|
||||
|
||||
static void
|
||||
test_item_variations ()
|
||||
{
|
||||
const OT::HVAR* hvar_table = reinterpret_cast<const OT::HVAR*> (hvar_data);
|
||||
|
||||
hb_tag_t axis_tag = HB_TAG ('w', 'g', 'h', 't');
|
||||
hb_map_t axis_idx_tag_map;
|
||||
axis_idx_tag_map.set (0, axis_tag);
|
||||
|
||||
axis_tag = HB_TAG ('o', 'p', 's', 'z');
|
||||
axis_idx_tag_map.set (1, axis_tag);
|
||||
|
||||
OT::item_variations_t item_vars;
|
||||
const OT::VariationStore& src_var_store = hvar_table+(hvar_table->varStore);
|
||||
bool result = item_vars.create_from_item_varstore (src_var_store, axis_idx_tag_map);
|
||||
|
||||
assert (result);
|
||||
|
||||
/* partial instancing wght=300:800 */
|
||||
hb_hashmap_t<hb_tag_t, Triple> normalized_axes_location;
|
||||
normalized_axes_location.set (axis_tag, Triple (-0.512817f, 0.f, 0.700012f));
|
||||
|
||||
hb_hashmap_t<hb_tag_t, TripleDistances> axes_triple_distances;
|
||||
axes_triple_distances.set (axis_tag, TripleDistances (200.f, 500.f));
|
||||
|
||||
result = item_vars.instantiate (normalized_axes_location, axes_triple_distances);
|
||||
assert (result);
|
||||
result = item_vars.optimize ();
|
||||
assert (result);
|
||||
assert (item_vars.get_region_list().length == 8);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
test_item_variations ();
|
||||
}
|
Loading…
Add table
Reference in a new issue