mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Saw unifontsel_draw_preview_text() in half.
Now it's got an inner half that does actual drawing given a draw context, and an outer half that sets up and tears down the draw context. Sooner or later the inner half will need calling independently of the outer, because GTK3's draw event will provide a ready-made cairo_t.
This commit is contained in:
parent
828ad5d6d4
commit
066bce3d19
@ -2285,7 +2285,8 @@ static void unifontsel_set_filter_buttons(unifontsel_internal *fs)
|
||||
}
|
||||
}
|
||||
|
||||
static void unifontsel_draw_preview_text(unifontsel_internal *fs)
|
||||
static void unifontsel_draw_preview_text_inner(unifont_drawctx *dctx,
|
||||
unifontsel_internal *fs)
|
||||
{
|
||||
unifont *font;
|
||||
char *sizename = NULL;
|
||||
@ -2300,35 +2301,29 @@ static void unifontsel_draw_preview_text(unifontsel_internal *fs)
|
||||
} else
|
||||
font = NULL;
|
||||
|
||||
if (fs->preview_pixmap) {
|
||||
unifont_drawctx dctx;
|
||||
dctx.type = DRAWTYPE_DEFAULT;
|
||||
if (font) {
|
||||
#ifdef DRAW_TEXT_GDK
|
||||
if (dctx.type == DRAWTYPE_GDK) {
|
||||
dctx.u.gdk.target = fs->preview_pixmap;
|
||||
dctx.u.gdk.gc = gdk_gc_new(fs->preview_pixmap);
|
||||
gdk_gc_set_foreground(dctx.u.gdk.gc, &fs->preview_bg);
|
||||
gdk_draw_rectangle(fs->preview_pixmap, dctx.u.gdk.gc, 1, 0, 0,
|
||||
if (dctx->type == DRAWTYPE_GDK) {
|
||||
gdk_gc_set_foreground(dctx->u.gdk.gc, &fs->preview_bg);
|
||||
gdk_draw_rectangle(dctx->u.gdk.target, dctx->u.gdk.gc, 1, 0, 0,
|
||||
fs->preview_width, fs->preview_height);
|
||||
gdk_gc_set_foreground(dctx.u.gdk.gc, &fs->preview_fg);
|
||||
gdk_gc_set_foreground(dctx->u.gdk.gc, &fs->preview_fg);
|
||||
}
|
||||
#endif
|
||||
#ifdef DRAW_TEXT_CAIRO
|
||||
if (dctx.type == DRAWTYPE_CAIRO) {
|
||||
dctx.u.cairo.widget = GTK_WIDGET(fs->preview_area);
|
||||
dctx.u.cairo.cr = gdk_cairo_create(fs->preview_pixmap);
|
||||
cairo_set_source_rgb(dctx.u.cairo.cr,
|
||||
if (dctx->type == DRAWTYPE_CAIRO) {
|
||||
cairo_set_source_rgb(dctx->u.cairo.cr,
|
||||
fs->preview_bg.red / 65535.0,
|
||||
fs->preview_bg.green / 65535.0,
|
||||
fs->preview_bg.blue / 65535.0);
|
||||
cairo_paint(dctx.u.cairo.cr);
|
||||
cairo_set_source_rgb(dctx.u.cairo.cr,
|
||||
cairo_paint(dctx->u.cairo.cr);
|
||||
cairo_set_source_rgb(dctx->u.cairo.cr,
|
||||
fs->preview_fg.red / 65535.0,
|
||||
fs->preview_fg.green / 65535.0,
|
||||
fs->preview_fg.blue / 65535.0);
|
||||
}
|
||||
#endif
|
||||
if (font) {
|
||||
|
||||
/*
|
||||
* The pangram used here is rather carefully
|
||||
* constructed: it contains a sequence of very narrow
|
||||
@ -2350,11 +2345,11 @@ static void unifontsel_draw_preview_text(unifontsel_internal *fs)
|
||||
* that they go to the effort of selecting their font
|
||||
* and _then_ realise it was a mistake.
|
||||
*/
|
||||
info->fontclass->draw_text(&dctx, font,
|
||||
info->fontclass->draw_text(dctx, font,
|
||||
0, font->ascent,
|
||||
L"bankrupt jilted showmen quiz convex fogey",
|
||||
41, FALSE, FALSE, font->width);
|
||||
info->fontclass->draw_text(&dctx, font,
|
||||
info->fontclass->draw_text(dctx, font,
|
||||
0, font->ascent + font->height,
|
||||
L"BANKRUPT JILTED SHOWMEN QUIZ CONVEX FOGEY",
|
||||
41, FALSE, FALSE, font->width);
|
||||
@ -2370,12 +2365,40 @@ static void unifontsel_draw_preview_text(unifontsel_internal *fs)
|
||||
* alphabetic character (since that's how it's often
|
||||
* used in practice, at least by programmers).
|
||||
*/
|
||||
info->fontclass->draw_text(&dctx, font,
|
||||
info->fontclass->draw_text(dctx, font,
|
||||
0, font->ascent + font->height * 2,
|
||||
L"0123456789!?,.:;<>()[]{}\\/`'\"+*-=~#_@|%&^$",
|
||||
42, FALSE, FALSE, font->width);
|
||||
|
||||
info->fontclass->destroy(font);
|
||||
}
|
||||
|
||||
sfree(sizename);
|
||||
}
|
||||
|
||||
static void unifontsel_draw_preview_text(unifontsel_internal *fs)
|
||||
{
|
||||
unifont_drawctx dctx;
|
||||
|
||||
if (!fs->preview_pixmap)
|
||||
return;
|
||||
|
||||
dctx.type = DRAWTYPE_DEFAULT;
|
||||
#ifdef DRAW_TEXT_GDK
|
||||
if (dctx.type == DRAWTYPE_GDK) {
|
||||
dctx.u.gdk.target = fs->preview_pixmap;
|
||||
dctx.u.gdk.gc = gdk_gc_new(fs->preview_pixmap);
|
||||
}
|
||||
#endif
|
||||
#ifdef DRAW_TEXT_CAIRO
|
||||
if (dctx.type == DRAWTYPE_CAIRO) {
|
||||
dctx.u.cairo.widget = GTK_WIDGET(fs->preview_area);
|
||||
dctx.u.cairo.cr = gdk_cairo_create(fs->preview_pixmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
unifontsel_draw_preview_text_inner(&dctx, fs);
|
||||
|
||||
#ifdef DRAW_TEXT_GDK
|
||||
if (dctx.type == DRAWTYPE_GDK) {
|
||||
gdk_gc_unref(dctx.u.gdk.gc);
|
||||
@ -2390,11 +2413,6 @@ static void unifontsel_draw_preview_text(unifontsel_internal *fs)
|
||||
gdk_window_invalidate_rect(gtk_widget_get_window(fs->preview_area),
|
||||
NULL, FALSE);
|
||||
}
|
||||
if (font)
|
||||
info->fontclass->destroy(font);
|
||||
|
||||
sfree(sizename);
|
||||
}
|
||||
|
||||
static void unifontsel_select_font(unifontsel_internal *fs,
|
||||
fontinfo *info, int size, int leftlist,
|
||||
|
Loading…
Reference in New Issue
Block a user