Author: tom
Date: Fri Dec 12 11:05:07 2008
New Revision: 3525
URL: http://svn.slimdevices.com?rev=3525&root=Jive&view=rev
Log:
Initial SDL_Pango work-in-progress.
Modified:
7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive.h
7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_font.c
7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
Modified: 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive.h
URL:
http://svn.slimdevices.com/7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive.h?rev=3525&root=Jive&r1=3524&r2=3525&view=diff
==============================================================================
--- 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive.h (original)
+++ 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive.h Fri Dec 12
11:05:07 2008
@@ -14,6 +14,7 @@
#include <SDL_ttf.h>
#include <SDL_gfxPrimitives.h>
#include <SDL_rotozoom.h>
+#include <SDL_Pango.h>
/* target frame rate 14 fps - may be tuned per platform, should be /2 */
@@ -274,6 +275,9 @@
/* global counter used to invalidate widget */
extern Uint32 jive_origin;
+
+/*hack - global sdl_pango context*/
+extern SDLPango_Context *pangocontext;
/* Util functions */
void jive_print_stack(lua_State *L, char *str);
Modified: 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_font.c
URL:
http://svn.slimdevices.com/7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_font.c?rev=3525&root=Jive&r1=3524&r2=3525&view=diff
==============================================================================
--- 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_font.c (original)
+++ 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_font.c Fri Dec
12 11:05:07 2008
@@ -7,6 +7,7 @@
#include "common.h"
#include "jive.h"
+//#include <pango/pango.h>
static const char *JIVE_FONT_MAGIC = "Font";
@@ -250,12 +251,41 @@
}
JiveSurface *jive_font_draw_text(JiveFont *font, Uint32 color, const char
*str) {
- assert(font && font->magic == JIVE_FONT_MAGIC);
-
- return jive_surface_new_SDLSurface(str ? font->draw(font, color, str) :
NULL);
-}
-
-JiveSurface *jive_font_ndraw_text(JiveFont *font, Uint32 color, const char
*str, size_t len) {
+ JiveSurface *jive_surface;
+// PangoAttrList *attr_list;
+// PangoAttribute *attr;
+// GSList *open_attrs, *attr_walk;
+
+// attr_list = pango_attr_list_new();
+
+// char *markedup;
+//
+// markedup = malloc(strlen(str) + 200);
+// if (color == 926365695) {
+// // fprintf(stderr, "shadow: %d", color);
+// sprintf(markedup, "%s%s%s", "<span foreground=\"#373737\"
letter_spacing=\"-400\">", str, "</span>");
+//// sprintf(markedup, "%s%s%s", "<span foreground=\"#373737\"
weight=\"bold\" stretch=\"ultracondensed\" font_family=\"FreeSans\"
size=\"15000\">", str, "</span>");
+// } else {
+// // fprintf(stderr, "whitish: %d", color);
+// sprintf(markedup, "%s%s%s", "<span foreground=\"#E7E7E7\"
letter_spacing=\"-400\">", str, "</span>");
+//// sprintf(markedup, "%s%s%s", "<span foreground=\"#E7E7E7\"
weight=\"bold\" stretch=\"ultraexpanded\" font_family=\"FreeSans\"
size=\"15000\">", str, "</span>");
+//
+// }
+// SDLPango_SetMarkup(pangocontext, markedup, -1);
+
+ SDLPango_SetText(pangocontext, str, -1);
+ assert(font && font->magic == JIVE_FONT_MAGIC);
+ jive_surface = jive_surface_new_SDLSurface(str ?
SDLPango_CreateSurfaceDraw (pangocontext) : NULL);
+// return jive_surface_new_SDLSurface(str ? font->draw(font, color, str) :
NULL);
+
+// pango_layout_set_attributes(pangocontext->layout, attr_list);
+// pango_attr_list_unref(attr_list);
+
+ return jive_surface;
+
+}
+
+JiveSurface *jive_font_ndraw_text(JiveFont *font, Uint32 color, const char
*str, size_t len) {
JiveSurface *srf;
char *tmp;
Modified: 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
URL:
http://svn.slimdevices.com/7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_framework.c?rev=3525&root=Jive&r1=3524&r2=3525&view=diff
==============================================================================
--- 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
(original)
+++ 7.4/branches/pango/squeezeplay/src/squeezeplay/src/ui/jive_framework.c Fri
Dec 12 11:05:07 2008
@@ -25,6 +25,7 @@
/* performance warning thresholds, 0 = disabled */
struct jive_perfwarn perfwarn = { 0, 0, 0, 0, 0, 0 };
+SDLPango_Context *pangocontext;
/* Frame rate calculations */
//static Uint32 framedue = 0;
@@ -140,7 +141,19 @@
SDL_Quit();
exit(-1);
}
-
+ if (SDLPango_Init() == -1) {
+ fprintf(stderr, "SDLPango Init failed.\n");
+ SDL_Quit();
+ exit(-1);
+ }
+
+ pangocontext = SDLPango_CreateContext_GivenFontDesc("FreeSans Bold 15");
+
+ SDLPango_SetDpi(pangocontext, 75.0, 75.0);
+
+ SDLPango_SetDefaultColor(pangocontext,
MATRIX_TRANSPARENT_BACK_WHITE_LETTER);
+ SDLPango_SetMinimumSize(pangocontext, 0, 0);
+
/* Register callback for additional events (used for multimedia keys)*/
SDL_EventState(SDL_SYSWMEVENT,SDL_ENABLE);
SDL_SetEventFilter(filter_events);
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins