summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-11-14 14:43:01 +0000
committerTim Redfern <tim@eclectronics.org>2013-11-14 14:43:01 +0000
commitaf4536d52f6d6f095c42b3caa6a49a68966c1cc1 (patch)
tree343f642b4f3cd8c2a53e2c188267952a8c9abd9c /rotord
parentac18876e19d923a52d1c738fc2f14dda20433832 (diff)
basic font choice + size
Diffstat (limited to 'rotord')
-rw-r--r--rotord/src/nodes_drawing.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h
index d5f3578..14a0dce 100644
--- a/rotord/src/nodes_drawing.h
+++ b/rotord/src/nodes_drawing.h
@@ -52,7 +52,9 @@ namespace Rotor {
description="Draws text";
create_attribute("text","Text to draw","Text","hello, world!");
create_attribute("colour","Colour to fill","Colour","FFFFFF");
+ create_attribute("font","font to use","Font","Sans",{"Sans","Sans Mono","Serif"});
create_parameter("number","number","Number to draw","Number",-99999999.0f);
+ create_parameter("size","number","Point size of font","size",50.0f);
UID="7da93b94-2d0b-11e3-8940-77bce0f9d3e8";
};
Text(map<string,string> &settings):Text() {
@@ -69,9 +71,9 @@ namespace Rotor {
else text=attributes["text"]->value;
cairo_text_extents_t te;
cairo_set_source_rgb(cr, colour.Rfloat(),colour.Gfloat(),colour.Bfloat());
- cairo_select_font_face (cr, "DejaVu",
+ cairo_select_font_face (cr, ("DejaVu "+attributes["font"]->value).c_str(),
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, 120);
+ cairo_set_font_size (cr, parameters["size"]->value*(((float)frame.w)/360.0f));
cairo_text_extents(cr, text.c_str(), &te);
cairo_move_to (cr,(frame.w-te.width)/2,frame.h*0.6);
cairo_show_text (cr, text.c_str());