mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
fix remtext rendering
This commit is contained in:
parent
670f0034af
commit
9521b71be9
1 changed files with 45 additions and 48 deletions
|
@ -251,7 +251,7 @@ layout_for_ht( GtkDrawCtx* dctx, XP_U16 ht )
|
|||
GList* gl = g_list_find_custom( dctx->fontsPerSize, &fps,
|
||||
compForHt );
|
||||
if ( NULL != gl ) {
|
||||
layout = ((FontPerSize*)gl->data)->layout;
|
||||
layout = g_object_ref(((FontPerSize*)gl->data)->layout);
|
||||
}
|
||||
|
||||
if ( NULL == layout ) {
|
||||
|
@ -264,7 +264,7 @@ layout_for_ht( GtkDrawCtx* dctx, XP_U16 ht )
|
|||
layout = pango_layout_new( dctx->pangoContext );
|
||||
fps->fontdesc = pango_font_description_from_string( font );
|
||||
pango_layout_set_font_description( layout, fps->fontdesc );
|
||||
fps->layout = layout;
|
||||
fps->layout = g_object_ref( layout );
|
||||
|
||||
/* This only happens first time??? */
|
||||
pango_layout_set_alignment( layout, PANGO_ALIGN_CENTER );
|
||||
|
@ -281,27 +281,23 @@ draw_string_at( GtkDrawCtx* dctx, PangoLayout* layout,
|
|||
const GdkRGBA* frground,
|
||||
const GdkRGBA* bkgrnd )
|
||||
{
|
||||
// XP_LOGF( "%s(%s)", __func__, str );
|
||||
// XP_LOGF( "%s(%s, %d, %d)", __func__, str, where->left, where->top );
|
||||
gint xx = where->left;
|
||||
gint yy = where->top;
|
||||
#ifdef USE_CAIRO
|
||||
cairo_t* cr = getCairo( dctx );
|
||||
#endif
|
||||
|
||||
gdk_cairo_set_source_rgba( cr, frground );
|
||||
if ( !!layout ) {
|
||||
g_object_ref( layout );
|
||||
} else {
|
||||
#ifdef USE_CAIRO
|
||||
gdk_cairo_set_source_rgba( cr, frground );
|
||||
layout = pango_cairo_create_layout( cr );
|
||||
gchar buf[32];
|
||||
sprintf( buf, "Sans Bold %d", (fontHt * 2) / 3 );
|
||||
PangoFontDescription* desc = pango_font_description_from_string( buf );
|
||||
pango_layout_set_font_description( layout, desc );
|
||||
pango_font_description_free( desc );
|
||||
#else
|
||||
layout = layout_for_ht( dctx, fontHt );
|
||||
#endif
|
||||
}
|
||||
|
||||
pango_layout_set_text( layout, (char*)str, XP_STRLEN(str) );
|
||||
|
@ -914,6 +910,7 @@ getLayoutToFitRect( GtkDrawCtx* dctx, const XP_UCHAR* str, const XP_Rect* rect,
|
|||
layout = layout_for_ht( dctx, 24 );
|
||||
pango_layout_set_text( layout, (char*)str, len );
|
||||
pango_layout_get_pixel_size( layout, &width, &height );
|
||||
g_object_unref( layout );
|
||||
|
||||
/* Figure the ratio of is to should-be. The smaller of these is the one
|
||||
we must use. */
|
||||
|
@ -941,10 +938,8 @@ gtkDrawDrawRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
|
|||
{
|
||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||
XP_UCHAR buf[10];
|
||||
PangoLayout* layout;
|
||||
|
||||
XP_SNPRINTF( buf, sizeof(buf), "rem:%d", nTilesLeft );
|
||||
layout = getLayoutToFitRect( dctx, buf, rect, NULL );
|
||||
PangoLayout* layout = getLayoutToFitRect( dctx, buf, rect, NULL );
|
||||
|
||||
if ( !!widthP ) {
|
||||
int width, height;
|
||||
|
@ -957,6 +952,7 @@ gtkDrawDrawRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
|
|||
}
|
||||
*widthP = width;
|
||||
*heightP = height;
|
||||
XP_LOGF( "%s(): setting width: %d, height: %d", __func__, width, height );
|
||||
} else {
|
||||
const GdkRGBA* cursor = NULL;
|
||||
if ( focussed ) {
|
||||
|
@ -965,8 +961,9 @@ gtkDrawDrawRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
|
|||
}
|
||||
draw_string_at( dctx, layout, buf, rect->height,
|
||||
rect, XP_GTK_JUST_TOPLEFT,
|
||||
&dctx->black, cursor );
|
||||
&dctx->black, NULL );
|
||||
}
|
||||
g_object_unref( layout );
|
||||
} /* gtkDrawDrawRemText */
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue