ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.245 by root, Fri Dec 28 15:05:20 2007 UTC vs.
Revision 1.252 by root, Fri Dec 28 17:30:33 2007 UTC

45#define G_DISABLE_CAST_CHECKS 45#define G_DISABLE_CAST_CHECKS
46 46
47#include <glib/gmacros.h> 47#include <glib/gmacros.h>
48 48
49#include <pango/pango.h> 49#include <pango/pango.h>
50
51#if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2))
52# define pango_layout_get_line_readonly pango_layout_get_line_readonly
53# define pango_layout_get_lines_readonly pango_layout_get_lines_readonly
54# define pango_layout_iter_get_line_readonly pango_layout_iter_get_line_readonly
55# define pango_layout_iter_get_run_readonly pango_layout_iter_get_run_readonly
56#endif
50 57
51#ifndef _WIN32 58#ifndef _WIN32
52# include <sys/types.h> 59# include <sys/types.h>
53# include <sys/socket.h> 60# include <sys/socket.h>
54# include <netinet/in.h> 61# include <netinet/in.h>
659 CODE: 666 CODE:
660{ 667{
661 opengl_fontmap = pango_opengl_font_map_new (); 668 opengl_fontmap = pango_opengl_font_map_new ();
662 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); 669 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0);
663 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); 670 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap);
671#if defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2)
672 pango_context_set_language (opengl_context, pango_language_from_string ("en"));
673 /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/
674#endif
664} 675}
665 676
666char * 677char *
667SDL_GetError () 678SDL_GetError ()
668 679
1165{ 1176{
1166 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 1177 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
1167 1178
1168 do 1179 do
1169 { 1180 {
1170 PangoLayoutRun *run = pango_layout_iter_get_run (iter); 1181 PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter);
1171 1182
1172 if (run && shape_attr_p (run)) 1183 if (run && shape_attr_p (run))
1173 { 1184 {
1174 PangoRectangle extents; 1185 PangoRectangle extents;
1175 pango_layout_iter_get_run_extents (iter, 0, &extents); 1186 pango_layout_iter_get_run_extents (iter, 0, &extents);
1279int 1290int
1280descent (DC::Layout self) 1291descent (DC::Layout self)
1281 CODE: 1292 CODE:
1282{ 1293{
1283 PangoRectangle rect; 1294 PangoRectangle rect;
1284 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1295 PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0);
1285 pango_layout_line_get_pixel_extents (line, 0, &rect); 1296 pango_layout_line_get_pixel_extents (line, 0, &rect);
1286 RETVAL = PANGO_DESCENT (rect); 1297 RETVAL = PANGO_DESCENT (rect);
1287} 1298}
1288 OUTPUT: 1299 OUTPUT:
1289 RETVAL 1300 RETVAL
1301 1312
1302void 1313void
1303cursor_pos (DC::Layout self, int index) 1314cursor_pos (DC::Layout self, int index)
1304 PPCODE: 1315 PPCODE:
1305{ 1316{
1306 PangoRectangle strong_pos; 1317 PangoRectangle pos;
1307 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1318 pango_layout_get_cursor_pos (self->pl, index, &pos, 0);
1308 1319
1309 EXTEND (SP, 3); 1320 EXTEND (SP, 3);
1310 PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); 1321 PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE)));
1311 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1322 PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE)));
1312 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1323 PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE)));
1313} 1324}
1314 1325
1315void 1326void
1316index_to_line_x (DC::Layout self, int index, int trailing = 0) 1327index_to_line_x (DC::Layout self, int index, int trailing = 0)
1317 PPCODE: 1328 PPCODE:
1318{ 1329{
1319 int line, x; 1330 int line, x;
1320 1331
1321 pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); 1332 pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x);
1322 1333#if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 17, 3))
1323#if !PANGO_VERSION_CHECK (1, 17. 3)
1324 /* pango bug: line is between 1..numlines, not 0..numlines-1 */ 1334 /* pango bug: line is between 1..numlines, not 0..numlines-1 */
1325 --line; 1335 --line;
1326#endif 1336#endif
1327
1328 EXTEND (SP, 2); 1337 EXTEND (SP, 2);
1329 PUSHs (sv_2mortal (newSViv (line))); 1338 PUSHs (sv_2mortal (newSViv (line)));
1330 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); 1339 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE)));
1331} 1340}
1332 1341
1338 int index, trailing; 1347 int index, trailing;
1339 1348
1340 if (line < 0) 1349 if (line < 0)
1341 XSRETURN_EMPTY; 1350 XSRETURN_EMPTY;
1342 1351
1343 if (!(lp = pango_layout_get_line (self->pl, line))) 1352 if (!(lp = pango_layout_get_line_readonly (self->pl, line)))
1344 XSRETURN_EMPTY; /* do better */ 1353 XSRETURN_EMPTY; /* do better */
1345 1354
1346 pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); 1355 pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing);
1347 1356
1348 EXTEND (SP, 2); 1357 EXTEND (SP, 2);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines