1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright © 2020 Google, Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * This is part of HarfBuzz, a text shaping library. 5cb93a386Sopenharmony_ci * 6cb93a386Sopenharmony_ci * Permission is hereby granted, without written agreement and without 7cb93a386Sopenharmony_ci * license or royalty fees, to use, copy, modify, and distribute this 8cb93a386Sopenharmony_ci * software and its documentation for any purpose, provided that the 9cb93a386Sopenharmony_ci * above copyright notice and the following two paragraphs appear in 10cb93a386Sopenharmony_ci * all copies of this software. 11cb93a386Sopenharmony_ci * 12cb93a386Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 13cb93a386Sopenharmony_ci * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 14cb93a386Sopenharmony_ci * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 15cb93a386Sopenharmony_ci * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 16cb93a386Sopenharmony_ci * DAMAGE. 17cb93a386Sopenharmony_ci * 18cb93a386Sopenharmony_ci * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 19cb93a386Sopenharmony_ci * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20cb93a386Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 21cb93a386Sopenharmony_ci * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 22cb93a386Sopenharmony_ci * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23cb93a386Sopenharmony_ci * 24cb93a386Sopenharmony_ci * Google Author(s): Calder Kitagawa 25cb93a386Sopenharmony_ci */ 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ci#include "hb-test.h" 28cb93a386Sopenharmony_ci#include "hb-subset-test.h" 29cb93a386Sopenharmony_ci 30cb93a386Sopenharmony_ci/* Unit tests for sbix subsetting */ 31cb93a386Sopenharmony_ci 32cb93a386Sopenharmony_cistatic void 33cb93a386Sopenharmony_citest_subset_sbix_noop (void) 34cb93a386Sopenharmony_ci{ 35cb93a386Sopenharmony_ci hb_face_t *face_XY = hb_test_open_font_file ("fonts/sbix.ttf"); 36cb93a386Sopenharmony_ci 37cb93a386Sopenharmony_ci hb_set_t *codepoints = hb_set_create (); 38cb93a386Sopenharmony_ci hb_face_t *face_XY_subset; 39cb93a386Sopenharmony_ci hb_set_add (codepoints, 88); 40cb93a386Sopenharmony_ci hb_set_add (codepoints, 89); 41cb93a386Sopenharmony_ci face_XY_subset = hb_subset_test_create_subset (face_XY, hb_subset_test_create_input (codepoints)); 42cb93a386Sopenharmony_ci hb_set_destroy (codepoints); 43cb93a386Sopenharmony_ci 44cb93a386Sopenharmony_ci hb_subset_test_check (face_XY, face_XY_subset, HB_TAG ('s','b','i','x')); 45cb93a386Sopenharmony_ci 46cb93a386Sopenharmony_ci hb_face_destroy (face_XY_subset); 47cb93a386Sopenharmony_ci hb_face_destroy (face_XY); 48cb93a386Sopenharmony_ci} 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_cistatic void 51cb93a386Sopenharmony_citest_subset_sbix_keep_one (void) 52cb93a386Sopenharmony_ci{ 53cb93a386Sopenharmony_ci hb_face_t *face_XY = hb_test_open_font_file ("fonts/sbix.ttf"); 54cb93a386Sopenharmony_ci hb_face_t *face_X = hb_test_open_font_file ("fonts/sbix_X.ttf"); 55cb93a386Sopenharmony_ci 56cb93a386Sopenharmony_ci hb_set_t *codepoints = hb_set_create (); 57cb93a386Sopenharmony_ci hb_face_t *face_X_subset; 58cb93a386Sopenharmony_ci hb_set_add (codepoints, 88); 59cb93a386Sopenharmony_ci face_X_subset = hb_subset_test_create_subset (face_XY, hb_subset_test_create_input (codepoints)); 60cb93a386Sopenharmony_ci hb_set_destroy (codepoints); 61cb93a386Sopenharmony_ci 62cb93a386Sopenharmony_ci hb_subset_test_check (face_X, face_X_subset, HB_TAG ('s','b','i','x')); 63cb93a386Sopenharmony_ci 64cb93a386Sopenharmony_ci hb_face_destroy (face_X_subset); 65cb93a386Sopenharmony_ci hb_face_destroy (face_XY); 66cb93a386Sopenharmony_ci hb_face_destroy (face_X); 67cb93a386Sopenharmony_ci} 68cb93a386Sopenharmony_ci 69cb93a386Sopenharmony_ci// TODO: add a test that doesn't use contiguous codepoints. 70cb93a386Sopenharmony_ci// TODO: add a test that keeps no codepoints. 71cb93a386Sopenharmony_ci 72cb93a386Sopenharmony_ciint 73cb93a386Sopenharmony_cimain (int argc, char **argv) 74cb93a386Sopenharmony_ci{ 75cb93a386Sopenharmony_ci hb_test_init (&argc, &argv); 76cb93a386Sopenharmony_ci 77cb93a386Sopenharmony_ci hb_test_add (test_subset_sbix_noop); 78cb93a386Sopenharmony_ci hb_test_add (test_subset_sbix_keep_one); 79cb93a386Sopenharmony_ci 80cb93a386Sopenharmony_ci return hb_test_run(); 81cb93a386Sopenharmony_ci} 82