static cairo_rectangle_t * ar_card_theme_kde_get_card_extents (ArCardThemeKDE *theme, int card_id, const char *node) { ArSvg *svg; cairo_rectangle_t *card_extents; cairo_rectangle_t rect; cairo_surface_t *surface; cairo_t *cr; card_extents = &theme->card_extents[card_id]; /* Is it initalised yet? */ if (card_extents->width != 0. && card_extents->height != 0.) return card_extents; svg = ((ArCardThemePreimage *) theme)->cards_svg; surface = cairo_recording_surface_create (CAIRO_CONTENT_ALPHA, NULL); cr = cairo_create (surface); cairo_set_tolerance (cr, 1.); ar_profilestart ("getting ink extents for node %s", node); rsvg_handle_render_cairo_sub (RSVG_HANDLE (svg), cr, node); ar_profileend ("getting ink extents for node %s", node); cairo_destroy (cr); cairo_recording_surface_ink_extents (surface, &rect.x, &rect.y, &rect.width, &rect.height); cairo_surface_destroy (surface); ar_debug_print (AR_DEBUG_CARD_THEME, "card %s %.3f x%.3f at (%.3f | %.3f)\n", node, card_extents->width, card_extents->height, card_extents->x, card_extents->y); *card_extents = rect; /* Sanity check; necessary? */ if (rect.width == 0. || rect.height == 0.) return NULL; return card_extents; }
/** * ar_runtime_init: * * Initialises the runtime file localisator. This also calls setlocale, * and initialises gettext support and gnome-games debug support. * * NOTE: This must be called before using ANY other glib/gtk/etc function! * * Returns: %TRUE iff initialisation succeeded */ gboolean ar_runtime_init (const char *name) { gboolean retval; setlocale (LC_ALL, ""); #ifdef G_OS_WIN32 /* On Windows, when called from a console, get console output. This works * only with Windows XP or higher; Windows 2000 will not have console * output but it will just work fine. */ if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) { /* stdout is fine, presumably redirected to a file or pipe. * Make sure stdout goes somewhere, too. */ if (_get_osfhandle (fileno (stderr)) == -1) { dup2 (fileno (stdout), fileno (stderr)); } } else { typedef BOOL (* WINAPI AttachConsole_t) (DWORD); AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole"); if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) { freopen ("CONOUT$", "w", stdout); dup2 (fileno (stdout), 1); freopen ("CONOUT$", "w", stderr); dup2 (fileno (stderr), 2); } } #endif /* G_OS_WIN32 */ #if !GLIB_CHECK_VERSION(2, 35, 0) /* This also initialises gthread */ g_type_init (); #endif /* May call any glib function after this point */ ar_profilestart ("ar_runtime_init"); ar_debug_init (); app_name = g_strdup (name); bindtextdomain (GETTEXT_PACKAGE, ar_runtime_get_directory (AR_RUNTIME_LOCALE_DIRECTORY)); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #ifdef ENABLE_BINRELOC { const char *path; /* Now check that we can get the module installation directory */ path = ar_runtime_get_directory (AR_RUNTIME_PREFIX); ar_debug_print (AR_DEBUG_RUNTIME, "Relocation path: %s\n", path ? path : "(null)"); retval = path != NULL; } #else /* !ENABLE_BINRELOC */ retval = TRUE; #endif /* ENABLE_BINRELOC */ ar_profileend ("ar_runtime_init"); return retval; }