-
Notifications
You must be signed in to change notification settings - Fork 8
/
obj_font_opt.c
147 lines (130 loc) · 5.06 KB
/
obj_font_opt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* Copyright (C) 2007-2008 Geoff Richards
* Copyright (C) 2010-2011 Uli Schlachter
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
static int
font_options_create (lua_State *L) {
cairo_font_options_t **opt = create_fontopt_userdata(L);
*opt = cairo_font_options_create();
return 1;
}
static int
fontopt_eq (lua_State *L) {
cairo_font_options_t **obj1 = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_t **obj2 = luaL_checkudata(L, 2, OOCAIRO_MT_NAME_FONTOPT);
lua_pushboolean(L, cairo_font_options_equal(*obj1, *obj2));
return 1;
}
static int
fontopt_gc (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_destroy(*obj);
*obj = 0;
return 0;
}
static int
fontopt_copy (lua_State *L) {
cairo_font_options_t **orig = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_t **newobj = create_fontopt_userdata(L);
*newobj = cairo_font_options_copy(*orig);
return 1;
}
static int
fontopt_get_antialias (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
return antialias_to_lua(L, cairo_font_options_get_antialias(*obj));
}
static int
fontopt_get_hint_metrics (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
return hint_metrics_to_lua(L, cairo_font_options_get_hint_metrics(*obj));
}
static int
fontopt_get_hint_style (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
return hint_style_to_lua(L, cairo_font_options_get_hint_style(*obj));
}
static int
fontopt_get_subpixel_order (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
return subpixel_order_to_lua(L,
cairo_font_options_get_subpixel_order(*obj));
}
static int
fontopt_hash (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
lua_pushnumber(L, cairo_font_options_hash(*obj));
return 1;
}
static int
fontopt_merge (lua_State *L) {
cairo_font_options_t **obj1 = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_t **obj2 = luaL_checkudata(L, 2, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_merge(*obj1, *obj2);
return 0;
}
static int
fontopt_set_antialias (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_set_antialias(*obj, antialias_from_lua(L, 2));
return 0;
}
static int
fontopt_set_hint_metrics (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_set_hint_metrics(*obj, hint_metrics_from_lua(L, 2));
return 0;
}
static int
fontopt_set_hint_style (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_set_hint_style(*obj, hint_style_from_lua(L, 2));
return 0;
}
static int
fontopt_set_subpixel_order (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
cairo_font_options_set_subpixel_order(*obj, subpixel_order_from_lua(L, 2));
return 0;
}
static int
fontopt_status (lua_State *L) {
cairo_font_options_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_FONTOPT);
return push_cairo_status(L, cairo_font_options_status(*obj));
}
static const luaL_Reg
fontopt_methods[] = {
{ "__eq", fontopt_eq },
{ "__gc", fontopt_gc },
{ "copy", fontopt_copy },
{ "get_antialias", fontopt_get_antialias },
{ "get_hint_metrics", fontopt_get_hint_metrics },
{ "get_hint_style", fontopt_get_hint_style },
{ "get_subpixel_order", fontopt_get_subpixel_order },
{ "hash", fontopt_hash },
{ "merge", fontopt_merge },
{ "set_antialias", fontopt_set_antialias },
{ "set_hint_metrics", fontopt_set_hint_metrics },
{ "set_hint_style", fontopt_set_hint_style },
{ "set_subpixel_order", fontopt_set_subpixel_order },
{ "status", fontopt_status },
{ 0, 0 }
};
/* vi:set ts=4 sw=4 expandtab: */