rubysdl 1.3.1 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/MANIFEST +22 -2
  2. data/NEWS.en +80 -0
  3. data/NEWS.ja +83 -0
  4. data/README.en +2 -1
  5. data/README.ja +2 -2
  6. data/doc-en/Makefile +18 -0
  7. data/doc-en/cdrom.rsd +417 -0
  8. data/doc-en/collision.rsd +174 -0
  9. data/doc-en/event.rsd +1476 -0
  10. data/doc-en/font.rsd +811 -0
  11. data/doc-en/general.rsd +43 -0
  12. data/doc-en/init.rsd +168 -0
  13. data/doc-en/joystick.rsd +401 -0
  14. data/doc-en/mixer.rsd +869 -0
  15. data/doc-en/mpeg.rsd +585 -0
  16. data/doc-en/opengl.rsd +155 -0
  17. data/doc-en/sdlskk.rsd +472 -0
  18. data/doc-en/time.rsd +46 -0
  19. data/doc-en/video.rsd +2806 -0
  20. data/doc-en/wm.rsd +112 -0
  21. data/doc/Makefile +1 -1
  22. data/doc/cdrom.rsd +3 -3
  23. data/doc/event.rsd +178 -179
  24. data/doc/general.rsd +10 -0
  25. data/doc/init.rsd +2 -2
  26. data/doc/joystick.rsd +29 -5
  27. data/doc/mixer.rsd +20 -0
  28. data/doc/rsd.rb +42 -9
  29. data/doc/sdlskk.rsd +7 -7
  30. data/doc/video.rsd +461 -168
  31. data/doc/wm.rsd +2 -2
  32. data/extconf.rb +1 -8
  33. data/lib/rubysdl_aliases.rb +52 -190
  34. data/lib/rubysdl_compatible_ver1.rb +243 -0
  35. data/lib/sdl.rb +58 -92
  36. data/rubysdl.h +59 -68
  37. data/rubysdl_cdrom.c +125 -102
  38. data/{rubysdl_doc.en.rd → rubysdl_doc_old.en.rd} +3 -2
  39. data/rubysdl_event.c +318 -255
  40. data/rubysdl_event_key.c +299 -287
  41. data/rubysdl_image.c +37 -13
  42. data/rubysdl_joystick.c +180 -67
  43. data/rubysdl_kanji.c +61 -75
  44. data/rubysdl_main.c +65 -138
  45. data/rubysdl_mixer.c +339 -214
  46. data/rubysdl_mouse.c +50 -43
  47. data/rubysdl_opengl.c +31 -28
  48. data/rubysdl_pixel.c +17 -28
  49. data/rubysdl_ref.en.html +5658 -0
  50. data/rubysdl_ref.en.rd +6337 -0
  51. data/rubysdl_ref.html +2253 -1964
  52. data/rubysdl_ref.rd +823 -469
  53. data/rubysdl_rwops.c +9 -6
  54. data/rubysdl_sdlskk.c +137 -165
  55. data/rubysdl_sge_video.c +355 -469
  56. data/rubysdl_smpeg.c +189 -190
  57. data/rubysdl_time.c +1 -1
  58. data/rubysdl_ttf.c +147 -215
  59. data/rubysdl_video.c +486 -405
  60. data/rubysdl_wm.c +30 -30
  61. data/sample/aadraw.rb +9 -9
  62. data/sample/alpha.rb +12 -13
  63. data/sample/alphadraw.rb +10 -10
  64. data/sample/bfont.rb +4 -4
  65. data/sample/cdrom.rb +11 -4
  66. data/sample/collision.rb +20 -20
  67. data/sample/cursor.rb +5 -5
  68. data/sample/ellipses.rb +20 -16
  69. data/sample/event2.rb +11 -9
  70. data/sample/font.rb +4 -4
  71. data/sample/fpstimer.rb +3 -3
  72. data/sample/icon.bmp.gz +0 -0
  73. data/sample/icon.png +0 -0
  74. data/sample/joy2.rb +14 -14
  75. data/sample/kanji.rb +7 -7
  76. data/sample/load_from_io.rb +44 -0
  77. data/sample/movesp.rb +13 -12
  78. data/sample/playmod.rb +2 -3
  79. data/sample/plaympeg.rb +8 -8
  80. data/sample/playwave.rb +5 -6
  81. data/sample/sdlskk.rb +11 -11
  82. data/sample/sgetest.rb +14 -12
  83. data/sample/stetris.rb +12 -13
  84. data/sample/testgl.rb +13 -14
  85. data/sample/testsprite.rb +12 -11
  86. data/sample/transformblit.rb +23 -22
  87. metadata +62 -35
  88. data/rubysdl_event2.c +0 -417
data/rubysdl_time.c CHANGED
@@ -29,7 +29,7 @@ static VALUE sdl_delay(VALUE mod,VALUE ms)
29
29
  return Qnil;
30
30
  }
31
31
 
32
- void init_time()
32
+ void rubysdl_init_time(VALUE mSDL)
33
33
  {
34
34
  rb_define_module_function(mSDL,"getTicks",sdl_getTicks,0);
35
35
  rb_define_module_function(mSDL,"delay",sdl_delay,1);
data/rubysdl_ttf.c CHANGED
@@ -23,302 +23,234 @@
23
23
 
24
24
  typedef SDL_Surface* (*RenderFunc)(TTF_Font *,const char *,SDL_Color,SDL_Color);
25
25
 
26
- static int ttf_initialized=0;
27
- static int ttf_finalized=0;
26
+ static int ttf_init = 0;
27
+ static VALUE cTTFFont = Qnil;
28
28
 
29
- static void ttf_closeFont(TTF_Font *font)
29
+ static void Font_free(TTF_Font *font)
30
30
  {
31
- if( !ttf_finalized )
31
+ if(!rubysdl_is_quit())
32
32
  TTF_CloseFont(font);
33
33
  }
34
- static VALUE sdl_ttf_init(VALUE class)
34
+
35
+ GLOBAL_DEFINE_GET_STRUCT(TTF_Font, Get_TTF_Font, cTTFFont, "SDL::TT::Font");
36
+
37
+ static VALUE TTF_s_init(VALUE klass)
35
38
  {
36
- if( TTF_Init()== -1 )
39
+ rb_secure(4);
40
+ if(TTF_Init() == -1)
37
41
  rb_raise(eSDLError,"Couldn't initialize TTF engine: %s",TTF_GetError());
38
- ttf_initialized=1;
42
+ ttf_init = 1;
39
43
  return Qnil;
40
44
  }
41
- static VALUE sdl_ttf_wasInit(VALUE class)
45
+
46
+ static VALUE TTF_s_init_p(VALUE class)
42
47
  {
43
- return BOOL(TTF_WasInit());
48
+ return INT2BOOL(TTF_WasInit());
44
49
  }
45
50
 
46
- static VALUE sdl_ttf_open(int argc, VALUE *argv, VALUE class)
51
+ static VALUE Font_s_open(int argc, VALUE *argv, VALUE class)
47
52
  {
48
53
  TTF_Font *font;
49
54
  VALUE filename, size, index;
55
+
56
+ rb_secure(4);
50
57
  rb_scan_args( argc, argv, "21", &filename, &size, &index );
51
- if( NIL_P(index) )
52
- font=TTF_OpenFont( GETCSTR(filename),NUM2INT(size) );
58
+
59
+ SafeStringValue(filename);
60
+
61
+ if(NIL_P(index))
62
+ font = TTF_OpenFont(RSTRING_PTR(filename), NUM2INT(size));
53
63
  else
54
- #ifdef HAVE_TTF_OPENFONTINDEX
55
- font=TTF_OpenFontIndex( GETCSTR(filename),NUM2INT(size),NUM2INT(index) );
56
- #else
57
- if( index != 0)
58
- rb_raise(rb_eRuntimeError,"Not supported for selecting indivisual font face by SDL_ttf. The feature is in SDL_ttf 2.0.4 or later.");
59
- else
60
- font=TTF_OpenFont( GETCSTR(filename),NUM2INT(size) );
61
- #endif
62
- if( font==NULL )
63
- rb_raise(eSDLError,"Couldn't open font %s: %s",GETCSTR(filename),
64
- TTF_GetError());
65
- return Data_Wrap_Struct(class,0,ttf_closeFont,font);
64
+ font = TTF_OpenFontIndex(RSTRING_PTR(filename),
65
+ NUM2INT(size), NUM2INT(index));
66
+
67
+ if(font == NULL)
68
+ rb_raise(eSDLError,"Couldn't open font %s: %s",
69
+ RSTRING_PTR(filename), TTF_GetError());
70
+ return Data_Wrap_Struct(class, 0, Font_free, font);
66
71
  }
67
- static VALUE sdl_ttf_getFontStyle(VALUE obj)
72
+
73
+ static VALUE Font_style(VALUE self)
68
74
  {
69
- TTF_Font *font;
70
- Data_Get_Struct(obj,TTF_Font,font);
71
- return INT2FIX( TTF_GetFontStyle(font) );
75
+ return INT2FIX(TTF_GetFontStyle(Get_TTF_Font(self)));
72
76
  }
73
- static VALUE sdl_ttf_setFontStyle(VALUE obj,VALUE style)
77
+
78
+ static VALUE Font_set_style(VALUE self, VALUE style)
74
79
  {
75
- TTF_Font *font;
76
- Data_Get_Struct(obj,TTF_Font,font);
77
- TTF_SetFontStyle(font,NUM2UINT(style));
80
+ TTF_SetFontStyle(Get_TTF_Font(self), NUM2UINT(style));
78
81
  return Qnil;
79
82
  }
80
- static VALUE sdl_ttf_getFontFaces(VALUE obj)
81
- {
82
- #ifdef TTF_FONTFACES
83
- TTF_Font *font;
84
- Data_Get_Struct(obj,TTF_Font,font);
85
- return UINT2NUM( TTF_FontFaces(font) );
86
- #else
87
- rb_raise(rb_eRuntimeError,"Not supported. The feature is in SDL_ttf 2.0.4 or later.");
88
- #endif
89
- }
90
- static VALUE sdl_ttf_FontFaceIsFixedWidth(VALUE obj)
91
- {
92
- #ifdef TTF_FONTISFIXEDWIDTH
93
- TTF_Font *font;
94
- Data_Get_Struct(obj,TTF_Font,font);
95
- if( TTF_FontFaceIsFixedWidth(font) )
96
- return Qtrue;
97
- else
98
- return Qfalse;
99
- #else
100
- rb_raise(rb_eRuntimeError,"Not supported. The feature is in SDL_ttf 2.0.4 or later.");
101
- #endif
102
- }
103
- static VALUE sdl_ttf_FontFaceFamilyName(VALUE obj)
104
- {
105
- #ifdef TTF_FONTFACEFAMILYNAME
106
- TTF_Font *font;
107
- char* name;
108
-
109
- Data_Get_Struct(obj,TTF_Font,font);
110
- name = TTF_FontFaceFamilyName(font);
111
- if(name == NULL)
112
- return Qnil;
113
- else
114
- return rb_str_new2(name);
115
- #else
116
- rb_raise(rb_eRuntimeError,"Not supported. The feature is in SDL_ttf 2.0.4 or later.");
117
- #endif
118
- }
119
- static VALUE sdl_ttf_FontFaceStyleName(VALUE obj)
120
- {
121
- #ifdef TTF_FONTFACESTYLENAME
122
- TTF_Font *font;
123
- char* name;
124
-
125
- Data_Get_Struct(obj,TTF_Font,font);
126
- name = TTF_FontFaceStyleName(font);
127
- if(name == NULL)
128
- return Qnil;
129
- else
130
- return rb_str_new2( (const char *) );
131
- #else
132
- rb_raise(rb_eRuntimeError,"Not supported. The feature is in SDL_ttf 2.0.4 or later.");
133
- #endif
134
- }
135
- static VALUE sdl_ttf_sizeText(VALUE obj,VALUE text)
83
+
84
+ static VALUE Font_faces(VALUE self)
136
85
  {
137
- TTF_Font *font;
138
- int w,h;
139
- Data_Get_Struct(obj,TTF_Font,font);
140
- TTF_SizeUTF8(font,GETCSTR(text),&w,&h);
141
- return rb_ary_new3(2,INT2FIX(w),INT2FIX(h));
86
+ return UINT2NUM(TTF_FontFaces(Get_TTF_Font(self)));
142
87
  }
143
88
 
144
- static VALUE sdl_ttf_fontHeight(VALUE obj)
89
+ static VALUE Font_fixedWidth_p(VALUE self)
145
90
  {
146
- TTF_Font *font;
147
- Data_Get_Struct(obj,TTF_Font,font);
148
- return INT2FIX(TTF_FontHeight(font));
91
+ return INT2BOOL(TTF_FontFaceIsFixedWidth(Get_TTF_Font(self)));
149
92
  }
150
93
 
151
- static VALUE sdl_ttf_fontAscent(VALUE obj)
94
+ static VALUE string_or_nil(char* str)
152
95
  {
153
- TTF_Font *font;
154
- Data_Get_Struct(obj,TTF_Font,font);
155
- return INT2FIX(TTF_FontAscent(font));
96
+ if (str)
97
+ return rb_str_new2(str);
98
+ else
99
+ return Qnil;
156
100
  }
157
101
 
158
- static VALUE sdl_ttf_fontDescent(VALUE obj)
102
+ static VALUE Font_familyName(VALUE self)
159
103
  {
160
- TTF_Font *font;
161
- Data_Get_Struct(obj,TTF_Font,font);
162
- return INT2FIX(TTF_FontDescent(font));
104
+ return string_or_nil(TTF_FontFaceFamilyName(Get_TTF_Font(self)));
163
105
  }
164
106
 
165
- static VALUE sdl_ttf_fontLineSkip(VALUE obj)
107
+ static VALUE Font_styleName(VALUE self)
166
108
  {
167
- TTF_Font *font;
168
- Data_Get_Struct(obj,TTF_Font,font);
169
- return INT2FIX(TTF_FontLineSkip(font));
109
+ return string_or_nil(TTF_FontFaceStyleName(Get_TTF_Font(self)));
170
110
  }
171
111
 
172
- static VALUE ttf_draw(VALUE obj,VALUE dest,VALUE text,VALUE x,
173
- VALUE y,VALUE fgr,VALUE fgg,VALUE fgb,
174
- VALUE bgr,VALUE bgg,VALUE bgb,RenderFunc render)
112
+ static VALUE Font_textSize(VALUE self, VALUE text)
175
113
  {
176
- TTF_Font *font;
177
- SDL_Surface *destSurface, *tmpSurface;
178
- SDL_Color fg,bg;
179
- SDL_Rect destRect;
180
- int result;
181
- char *ctext=GETCSTR(text);
182
- /* If text=="" , TTF_RenderUTF8_Solid() and etc fail to render */
183
- if( ctext[0]=='\0' )return INT2FIX(0);
184
-
185
- if( !rb_obj_is_kind_of( dest,cSurface ) )
186
- rb_raise( rb_eArgError,"type mismatch(expect Surface)");
187
- Data_Get_Struct(obj,TTF_Font,font);
188
- Data_Get_Struct(dest,SDL_Surface,destSurface);
189
- fg.r=NUM2UINT(fgr); fg.g=NUM2UINT(fgg); fg.b=NUM2UINT(fgb);
190
- bg.r=NUM2UINT(bgr); bg.g=NUM2UINT(bgg); bg.b=NUM2UINT(bgb);
191
- SetRect(destRect,x,y,1,1);
192
-
193
- tmpSurface=render(font,ctext,fg,bg);
194
- if( tmpSurface==NULL )
195
- rb_raise(eSDLError,"Text Render fail: %s",TTF_GetError());
114
+ int w,h;
196
115
 
197
- result=SDL_BlitSurface(tmpSurface,NULL,destSurface,&destRect);
198
- SDL_FreeSurface(tmpSurface);
199
- if( result == -1 ){
200
- rb_raise(eSDLError,"SDL_BlitSurface fail: %s",SDL_GetError());
201
- }
202
- return INT2NUM(result);
116
+ StringValue(text);
117
+ TTF_SizeUTF8(Get_TTF_Font(self), RSTRING_PTR(text), &w, &h);
118
+ return rb_ary_new3(2, INT2FIX(w), INT2FIX(h));
203
119
  }
204
120
 
205
-
206
- static SDL_Surface* ttf_wrap_RenderUTF8_Solid(TTF_Font *font,
207
- const char *text,
208
- SDL_Color fg,
209
- SDL_Color bg)
121
+ static VALUE Font_height(VALUE self)
210
122
  {
211
- return TTF_RenderUTF8_Solid(font,text,fg);
123
+ return INT2FIX(TTF_FontHeight(Get_TTF_Font(self)));
212
124
  }
213
125
 
214
- static VALUE sdl_ttf_drawSolidUTF8(VALUE obj,VALUE dest,VALUE text,VALUE x,
215
- VALUE y,VALUE r,VALUE g,VALUE b)
126
+ static VALUE Font_ascent(VALUE self)
216
127
  {
217
- return ttf_draw(obj,dest,text,x,y,r,g,b,1,1,1,ttf_wrap_RenderUTF8_Solid);
128
+ return INT2FIX(TTF_FontAscent(Get_TTF_Font(self)));
218
129
  }
219
- static SDL_Surface* ttf_wrap_RenderUTF8_Blended(TTF_Font *font,
220
- const char *text,
221
- SDL_Color fg,
222
- SDL_Color bg)
130
+
131
+ static VALUE Font_descent(VALUE self)
223
132
  {
224
- return TTF_RenderUTF8_Blended(font,text,fg);
133
+ return INT2FIX(TTF_FontDescent(Get_TTF_Font(self)));
225
134
  }
226
135
 
227
- static VALUE sdl_ttf_drawBlendedUTF8(VALUE obj,VALUE dest,VALUE text,VALUE x,
228
- VALUE y,VALUE r,VALUE g,VALUE b)
136
+ static VALUE Font_lineSkip(VALUE self)
229
137
  {
230
- return ttf_draw(obj,dest,text,x,y,r,g,b,1,1,1,ttf_wrap_RenderUTF8_Blended);
138
+ return INT2FIX(TTF_FontLineSkip(Get_TTF_Font(self)));
231
139
  }
232
140
 
233
- static VALUE sdl_ttf_drawShadedUTF8(VALUE obj,VALUE dest, VALUE text,VALUE x,
234
- VALUE y,VALUE fgr,VALUE fgg,VALUE fgb,
235
- VALUE bgr,VALUE bgg,VALUE bgb)
141
+ static SDL_Color rgb_to_SDL_Color(VALUE r, VALUE g, VALUE b)
236
142
  {
237
- return ttf_draw(obj,dest,text,x,y,fgr,fgg,fgb,bgr,bgg,bgb,
238
- TTF_RenderUTF8_Shaded);
143
+ SDL_Color color;
144
+ color.r = NUM2UINT(r);
145
+ color.g = NUM2UINT(g);
146
+ color.b = NUM2UINT(b);
147
+ color.unused = 0;
148
+ return color;
239
149
  }
240
150
 
241
- static VALUE ttf_render(VALUE obj,VALUE text,VALUE fgr,VALUE fgg,VALUE fgb,
242
- VALUE bgr,VALUE bgg,VALUE bgb,RenderFunc render)
151
+ static VALUE render(VALUE self, VALUE text,
152
+ VALUE fgr,VALUE fgg,VALUE fgb,
153
+ VALUE bgr,VALUE bgg,VALUE bgb,
154
+ RenderFunc renderer)
243
155
  {
244
- TTF_Font *font;
245
156
  SDL_Surface *surface;
246
- SDL_Color fg,bg;
247
-
248
- Data_Get_Struct(obj,TTF_Font,font);
249
- fg.r=NUM2UINT(fgr); fg.g=NUM2UINT(fgg); fg.b=NUM2UINT(fgb);
250
- bg.r=NUM2UINT(bgr); bg.g=NUM2UINT(bgg); bg.b=NUM2UINT(bgb);
251
157
 
252
- surface = render( font, GETCSTR(text), fg, bg );
158
+ rb_secure(4);
159
+ StringValue(text);
253
160
 
254
- if( surface == NULL )
161
+ surface = renderer(Get_TTF_Font(self),
162
+ RSTRING_PTR(text),
163
+ rgb_to_SDL_Color(fgr, fgg, fgb),
164
+ rgb_to_SDL_Color(bgr, bgg, bgb));
165
+
166
+ if(surface == NULL)
255
167
  return Qnil;
256
168
 
257
- return Data_Wrap_Struct(cSurface,0,sdl_freeSurface,surface);
169
+ return Surface_create(surface);
170
+ }
171
+
172
+ static SDL_Surface* wrap_RenderUTF8_Solid(TTF_Font *font,
173
+ const char *text,
174
+ SDL_Color fg,
175
+ SDL_Color bg)
176
+ {
177
+ return TTF_RenderUTF8_Solid(font,text,fg);
258
178
  }
259
179
 
260
- static VALUE sdl_ttf_renderSolidUTF8(VALUE obj,VALUE text,VALUE r,
261
- VALUE g,VALUE b)
180
+ static SDL_Surface* wrap_RenderUTF8_Blended(TTF_Font *font,
181
+ const char *text,
182
+ SDL_Color fg,
183
+ SDL_Color bg)
262
184
  {
263
- return ttf_render(obj,text,r,g,b,1,1,1,ttf_wrap_RenderUTF8_Solid);
185
+ return TTF_RenderUTF8_Blended(font,text,fg);
264
186
  }
265
187
 
266
- static VALUE sdl_ttf_renderBlendedUTF8(VALUE obj,VALUE text,VALUE r,
267
- VALUE g,VALUE b)
188
+
189
+ /* 1 is ruby's zero */
190
+ static VALUE Font_renderSolidUTF8(VALUE self, VALUE text,
191
+ VALUE r, VALUE g, VALUE b)
192
+
268
193
  {
269
- return ttf_render(obj,text,r,g,b,1,1,1,ttf_wrap_RenderUTF8_Blended);
194
+ return render(self, text, r, g, b, 1, 1, 1,wrap_RenderUTF8_Solid);
270
195
  }
271
196
 
272
- static VALUE sdl_ttf_renderShadedUTF8(VALUE obj,VALUE text,
273
- VALUE fgr,VALUE fgg,VALUE fgb,
274
- VALUE bgr,VALUE bgg,VALUE bgb)
197
+ static VALUE Font_renderBlendedUTF8(VALUE self, VALUE text,
198
+ VALUE r, VALUE g, VALUE b)
199
+
275
200
  {
276
- return ttf_render(obj,text,fgr,fgg,fgb,bgr,bgg,bgb,TTF_RenderUTF8_Shaded);
201
+ return render(self, text, r, g, b, 1, 1, 1, wrap_RenderUTF8_Blended);
277
202
  }
278
203
 
279
- static void defineConstForTTF()
204
+ static VALUE Font_renderShadedUTF8(VALUE self, VALUE text,
205
+ VALUE fgr,VALUE fgg,VALUE fgb,
206
+ VALUE bgr,VALUE bgg,VALUE bgb)
280
207
  {
281
- rb_define_const(cTTF,"STYLE_NORMAL",UINT2NUM(TTF_STYLE_NORMAL));
282
- rb_define_const(cTTF,"STYLE_BOLD",UINT2NUM(TTF_STYLE_BOLD));
283
- rb_define_const(cTTF,"STYLE_ITALIC",UINT2NUM(TTF_STYLE_ITALIC));
284
- rb_define_const(cTTF,"STYLE_UNDERLINE",UINT2NUM(TTF_STYLE_UNDERLINE));
208
+ return render(self, text, fgr, fgg, fgb, bgr, bgg, bgb, TTF_RenderUTF8_Shaded);
285
209
  }
286
- void init_ttf()
210
+
211
+ void rubysdl_init_TTF(VALUE mSDL)
287
212
  {
288
- cTTF=rb_define_class_under(mSDL,"TTF",rb_cObject);
289
- rb_define_singleton_method(cTTF,"init",sdl_ttf_init,0);
290
- rb_define_singleton_method(cTTF,"init?",sdl_ttf_wasInit,0);
291
- rb_define_singleton_method(cTTF,"open",sdl_ttf_open,-1);
213
+ cTTFFont = rb_define_class_under(mSDL, "TTF", rb_cObject);
214
+
215
+ rb_undef_alloc_func(cTTFFont);
292
216
 
293
- rb_define_method(cTTF,"style",sdl_ttf_getFontStyle,0);
294
- rb_define_method(cTTF,"style=",sdl_ttf_setFontStyle,1);
295
- rb_define_method(cTTF,"textSize",sdl_ttf_sizeText,1);
296
- rb_define_method(cTTF,"faces",sdl_ttf_getFontFaces,0);
297
- rb_define_method(cTTF,"fixedWidth?",sdl_ttf_FontFaceIsFixedWidth,0);
298
- rb_define_method(cTTF,"familyName",sdl_ttf_FontFaceFamilyName,0);
299
- rb_define_method(cTTF,"styleName",sdl_ttf_FontFaceStyleName,0);
300
-
301
- rb_define_method(cTTF,"height",sdl_ttf_fontHeight,0);
302
- rb_define_method(cTTF,"ascent",sdl_ttf_fontAscent,0);
303
- rb_define_method(cTTF,"descent",sdl_ttf_fontDescent,0);
304
- rb_define_method(cTTF,"lineSkip",sdl_ttf_fontLineSkip,0);
217
+ rb_define_singleton_method(cTTFFont,"init",TTF_s_init,0);
218
+ rb_define_singleton_method(cTTFFont,"init?", TTF_s_init_p,0);
219
+ rb_define_singleton_method(cTTFFont,"open",Font_s_open,-1);
305
220
 
306
- rb_define_method(cTTF,"drawSolidUTF8",sdl_ttf_drawSolidUTF8,7);
307
- rb_define_method(cTTF,"drawBlendedUTF8",sdl_ttf_drawBlendedUTF8,7);
308
- rb_define_method(cTTF,"drawShadedUTF8",sdl_ttf_drawShadedUTF8,10);
221
+ rb_define_method(cTTFFont,"style",Font_style,0);
222
+ rb_define_method(cTTFFont,"style=",Font_set_style,1);
223
+ rb_define_method(cTTFFont,"textSize",Font_textSize,1);
224
+ rb_define_method(cTTFFont,"faces",Font_faces,0);
225
+ rb_define_method(cTTFFont,"fixedWidth?",Font_fixedWidth_p,0);
226
+ rb_define_method(cTTFFont,"familyName",Font_familyName,0);
227
+ rb_define_method(cTTFFont,"styleName",Font_styleName,0);
309
228
 
310
- rb_define_method(cTTF,"renderSolidUTF8",sdl_ttf_renderSolidUTF8,4);
311
- rb_define_method(cTTF,"renderBlendedUTF8",sdl_ttf_renderBlendedUTF8,4);
312
- rb_define_method(cTTF,"renderShadedUTF8",sdl_ttf_renderShadedUTF8,7);
229
+ rb_define_method(cTTFFont,"height",Font_height,0);
230
+ rb_define_method(cTTFFont,"ascent",Font_ascent,0);
231
+ rb_define_method(cTTFFont,"descent",Font_descent,0);
232
+ rb_define_method(cTTFFont,"lineSkip",Font_lineSkip,0);
313
233
 
314
- defineConstForTTF();
234
+ rb_define_method(cTTFFont,"renderSolidUTF8",Font_renderSolidUTF8,4);
235
+ rb_define_method(cTTFFont,"renderBlendedUTF8",Font_renderBlendedUTF8,4);
236
+ rb_define_method(cTTFFont,"renderShadedUTF8",Font_renderShadedUTF8,7);
237
+
238
+ rb_define_const(cTTFFont,"STYLE_NORMAL",UINT2NUM(TTF_STYLE_NORMAL));
239
+ rb_define_const(cTTFFont,"STYLE_BOLD",UINT2NUM(TTF_STYLE_BOLD));
240
+ rb_define_const(cTTFFont,"STYLE_ITALIC",UINT2NUM(TTF_STYLE_ITALIC));
241
+ rb_define_const(cTTFFont,"STYLE_UNDERLINE",UINT2NUM(TTF_STYLE_UNDERLINE));
315
242
  }
316
- void quit_ttf()
243
+
244
+ void rubysdl_quit_TTF(void)
317
245
  {
318
- if(ttf_initialized){
246
+ if(ttf_init)
319
247
  TTF_Quit();
320
- ttf_finalized=1;
321
- }
322
248
  }
323
-
249
+ #else /* HAVE_SDL_TTF */
250
+ void rubysdl_init_TTF(void)
251
+ {
252
+ }
253
+ void rubysdl_quit_TTF(void)
254
+ {
255
+ }
324
256
  #endif /* HAVE_SDL_TTF */