Mercurial > hg > octave-nkf
diff libinterp/corefcn/graphics.cc @ 19239:1288a2f27769
Handle non "points" fontunits properties (bug # 40158)
* graphics.in.h (axes and text properties): new hidden, read-only properties "fontsize_points"
* graphics.in.h (text properties): declare custom set/update methods for "fontunits" property
* graphics.cc (text::properties::set_fontunits, text::properties::update_fontunits): new methods borrowed from axes::properties
* graphics.cc (text::properties::update_font, axes::properties::update_font): use new property "fontsize_points"
* gl-render.cc (opengl_renderer::set_font): use new property "fontsize_points"
* gl-render.cc (opengl_renderer::draw_text): call set_font
* gl2ps-renderer.cc (glps_renderer::set_font): use new property "fontsize_points"
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sun, 11 May 2014 22:24:50 +0200 |
parents | 4c59f69fa52c |
children | f984fc55a825 |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc +++ b/libinterp/corefcn/graphics.cc @@ -6197,7 +6197,7 @@ text_renderer.set_font (get ("fontname").string_value (), get ("fontweight").string_value (), get ("fontangle").string_value (), - get ("fontsize").double_value ()); + get ("fontsize_points").double_value ()); #endif #endif } @@ -7816,6 +7816,40 @@ } void +text::properties::set_fontunits (const octave_value& v) +{ + if (! error_state) + { + caseless_str old_fontunits = get_fontunits (); + if (fontunits.set (v, true)) + { + update_fontunits (old_fontunits); + mark_modified (); + } + } +} + +void +text::properties::update_fontunits (const caseless_str& old_units) +{ + caseless_str new_units = get_fontunits (); + double parent_height = 0; + double fsz = get_fontsize (); + + if (new_units == "normalized") + { + graphics_object go (gh_manager::get_object (get___myhandle__ ())); + graphics_object ax (go.get_ancestor ("axes")); + + parent_height = ax.get_properties ().get_boundingbox (true).elem (3); + } + + fsz = convert_font_size (fsz, old_units, new_units, parent_height); + + set_fontsize (octave_value (fsz)); +} + +void text::properties::update_font (void) { #ifdef HAVE_FREETYPE @@ -7823,7 +7857,7 @@ renderer.set_font (get ("fontname").string_value (), get ("fontweight").string_value (), get ("fontangle").string_value (), - get ("fontsize").double_value ()); + get ("fontsize_points").double_value ()); #endif renderer.set_color (get_color_rgb ()); #endif