[HB] Flesh out Unicode funcs
[framework/uifw/harfbuzz.git] / src / hb-unicode.c
1 /*
2  * Copyright (C) 2009  Red Hat, Inc.
3  *
4  *  This is part of HarfBuzz, an OpenType Layout engine library.
5  *
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.
11  *
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
16  * DAMAGE.
17  *
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.
23  *
24  * Red Hat Author(s): Behdad Esfahbod
25  */
26
27 #include "hb-private.h"
28
29 #include "hb-unicode-private.h"
30
31 /*
32  * hb_unicode_funcs_t
33  */
34
35 static hb_unicode_funcs_t _hb_unicode_funcs_nil = {
36   HB_REFERENCE_COUNT_INVALID, /* ref_count */
37
38   NULL, /*get_general_category */
39   NULL, /*get_combining_class */
40   NULL, /*get_mirroring_char */
41   NULL, /*get_script */
42   NULL  /*get_eastasian_width */
43 };
44
45 hb_unicode_funcs_t *
46 hb_unicode_funcs_create (void)
47 {
48   hb_unicode_funcs_t *ufuncs;
49
50   if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
51     return &_hb_unicode_funcs_nil;
52
53   return ufuncs;
54 }
55
56 hb_unicode_funcs_t *
57 hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs)
58 {
59   HB_OBJECT_DO_REFERENCE (ufuncs);
60 }
61
62 unsigned int
63 hb_unicode_funcs_get_reference_count (hb_unicode_funcs_t *ufuncs)
64 {
65   HB_OBJECT_DO_GET_REFERENCE_COUNT (ufuncs);
66 }
67
68 void
69 hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
70 {
71   HB_OBJECT_DO_DESTROY (ufuncs);
72
73   free (ufuncs);
74 }
75
76 hb_unicode_funcs_t *
77 hb_unicode_funcs_copy (hb_unicode_funcs_t *other_ufuncs)
78 {
79   hb_unicode_funcs_t *ufuncs;
80
81   if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
82     return &_hb_unicode_funcs_nil;
83
84   *ufuncs = *other_ufuncs;
85   HB_OBJECT_DO_INIT (ufuncs);
86
87   return ufuncs;
88 }
89
90
91 void
92 hb_unicode_funcs_set_mirroring_char_func (hb_unicode_funcs_t *ufuncs,
93                                           hb_unicode_get_mirroring_char_func_t mirroring_char_func)
94 {
95   if (HB_OBJECT_IS_INERT (ufuncs))
96     return;
97
98   ufuncs->get_mirroring_char = mirroring_char_func;
99 }
100
101 void
102 hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
103                                             hb_unicode_get_general_category_func_t general_category_func)
104 {
105   if (HB_OBJECT_IS_INERT (ufuncs))
106     return;
107
108   ufuncs->get_general_category = general_category_func;
109 }
110
111 void
112 hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
113                                   hb_unicode_get_script_func_t script_func)
114 {
115   if (HB_OBJECT_IS_INERT (ufuncs))
116     return;
117
118   ufuncs->get_script = script_func;
119 }
120
121 void
122 hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
123                                            hb_unicode_get_combining_class_func_t combining_class_func)
124 {
125   if (HB_OBJECT_IS_INERT (ufuncs))
126     return;
127
128   ufuncs->get_combining_class = combining_class_func;
129 }
130
131 void
132 hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
133                                            hb_unicode_get_eastasian_width_func_t eastasian_width_func)
134 {
135   if (HB_OBJECT_IS_INERT (ufuncs))
136     return;
137
138   ufuncs->get_eastasian_width = eastasian_width_func;
139 }
140