fix for ugly pixelated drawing of node frame text.

This commit is contained in:
Campbell Barton
2012-07-09 16:06:44 +00:00
parent bfe776cd1d
commit 54ed3dee68

View File

@@ -946,8 +946,11 @@ static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode
node->totr = rect;
}
static void node_draw_frame_label(bNode *node)
static void node_draw_frame_label(View2D *v2d, bNode *node)
{
const float aspx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
const float aspy = (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin);
/* XXX font id is crap design */
const int fontid = blf_mono_font;
NodeFrame *data = (NodeFrame *)node->storage;
@@ -957,21 +960,27 @@ static void node_draw_frame_label(bNode *node)
/* XXX a bit hacky, should use separate align values for x and y */
float width, ascender;
float x, y;
const int font_size = data->label_size / aspx;
BLI_strncpy(label, nodeLabel(node), sizeof(label));
BLF_size(fontid, data->label_size, U.dpi);
BLF_enable(fontid, BLF_ASPECT);
BLF_aspect(fontid, aspx, aspy, 1.0f);
BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
/* title color */
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
width = BLF_width(fontid, label);
ascender = BLF_ascender(fontid);
ascender = BLF_ascender(fontid) * aspy;
x = 0.5f * (rct->xmin + rct->xmax) - 0.5f * width;
y = rct->ymax - NODE_DYS - ascender;
BLF_position(fontid, x, y, 0);
BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable(fontid, BLF_ASPECT);
}
static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *UNUSED(ntree), bNode *node)
@@ -1023,7 +1032,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN
}
/* label */
node_draw_frame_label(node);
node_draw_frame_label(&ar->v2d, node);
UI_ThemeClearColor(color_id);