2 * Copyright (C) 2009 Red Hat, Inc.
4 * This is part of HarfBuzz, an OpenType Layout engine library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Red Hat Author(s): Behdad Esfahbod
27 #include "hb-private.h"
29 #include "hb-unicode-private.h"
35 static hb_codepoint_t hb_unicode_get_mirroring_char_nil (hb_codepoint_t unicode) { return unicode; }
36 static hb_category_t hb_unicode_get_general_category_nil (hb_codepoint_t unicode) { return HB_CATEGORY_OTHER_LETTER; }
37 static hb_script_t hb_unicode_get_script_nil (hb_codepoint_t unicode) { return HB_SCRIPT_UNKNOWN; }
38 static unsigned int hb_unicode_get_combining_class_nil (hb_codepoint_t unicode) { return 0; }
39 static unsigned int hb_unicode_get_eastasian_width_nil (hb_codepoint_t unicode) { return 1; }
41 static hb_unicode_funcs_t _hb_unicode_funcs_nil = {
42 HB_REFERENCE_COUNT_INVALID, /* ref_count */
44 hb_unicode_get_general_category_nil,
45 hb_unicode_get_combining_class_nil,
46 hb_unicode_get_mirroring_char_nil,
47 hb_unicode_get_script_nil,
48 hb_unicode_get_eastasian_width_nil
52 hb_unicode_funcs_create (void)
54 hb_unicode_funcs_t *ufuncs;
56 if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
57 return &_hb_unicode_funcs_nil;
59 *ufuncs = _hb_unicode_funcs_nil;
60 HB_OBJECT_DO_INIT (ufuncs);
66 hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs)
68 HB_OBJECT_DO_REFERENCE (ufuncs);
72 hb_unicode_funcs_get_reference_count (hb_unicode_funcs_t *ufuncs)
74 HB_OBJECT_DO_GET_REFERENCE_COUNT (ufuncs);
78 hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
80 HB_OBJECT_DO_DESTROY (ufuncs);
86 hb_unicode_funcs_copy (hb_unicode_funcs_t *other_ufuncs)
88 hb_unicode_funcs_t *ufuncs;
90 if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
91 return &_hb_unicode_funcs_nil;
93 *ufuncs = *other_ufuncs;
94 HB_OBJECT_DO_INIT (ufuncs);
101 hb_unicode_funcs_set_mirroring_char_func (hb_unicode_funcs_t *ufuncs,
102 hb_unicode_get_mirroring_char_func_t mirroring_char_func)
104 if (HB_OBJECT_IS_INERT (ufuncs))
107 ufuncs->get_mirroring_char = mirroring_char_func ? mirroring_char_func : hb_unicode_get_mirroring_char_nil;
111 hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
112 hb_unicode_get_general_category_func_t general_category_func)
114 if (HB_OBJECT_IS_INERT (ufuncs))
117 ufuncs->get_general_category = general_category_func ? general_category_func : hb_unicode_get_general_category_nil;
121 hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
122 hb_unicode_get_script_func_t script_func)
124 if (HB_OBJECT_IS_INERT (ufuncs))
127 ufuncs->get_script = script_func ? script_func : hb_unicode_get_script_nil;
131 hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
132 hb_unicode_get_combining_class_func_t combining_class_func)
134 if (HB_OBJECT_IS_INERT (ufuncs))
137 ufuncs->get_combining_class = combining_class_func ? combining_class_func : hb_unicode_get_combining_class_nil;
141 hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
142 hb_unicode_get_eastasian_width_func_t eastasian_width_func)
144 if (HB_OBJECT_IS_INERT (ufuncs))
147 ufuncs->get_eastasian_width = eastasian_width_func ? eastasian_width_func : hb_unicode_get_eastasian_width_nil;