<div>Help me try to understand this please.</div><div><br></div><div>A use case for cairo_lock_font_space() is to draw text of the same size while using a different transform:</div><div><br></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">// All captions should be the same size </span></div>
<div><font class="Apple-style-span" face="'courier new', monospace">cairo_lock_font_space(cr);</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">// draw as tall widget at [0,0] and add a caption</font></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="'courier new', monospace">cairo_save(cr);</font></div><div><font class="Apple-style-span" face="'courier new', monospace">cairo_scale(cr, 2, 0.5);</font></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="'courier new', monospace">my_draw_widget(cr);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">cairo_show_text (cr, "My Tall Widget");</font></div><div><div><font class="Apple-style-span" face="'courier new', monospace">cairo_restore(cr);</font></div>
</div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><div><font class="Apple-style-span" face="'courier new', monospace">// draw as narrow widget at [100,0] and add a caption</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">cairo_save(cr);</font></div><div><div><font class="Apple-style-span" face="'courier new', monospace">cairo_translate(100, 0);</font></div>
</div><div><font class="Apple-style-span" face="'courier new', monospace">cairo_scale(0.5, 2);</font></div><div><font class="Apple-style-span" face="'courier new', monospace">my_draw_widget(cr);</font></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">cairo_show_text (cr, "My Narrow Widget");</span></div><div><div></div><div><font class="Apple-style-span" face="'courier new', monospace">cairo_restore(cr);</font></div>
</div><div><br></div></div><div>Right?</div><div><br></div><div>Now what if I want the text in <span class="Apple-style-span" style="font-family: 'courier new', monospace; ">my_draw_widget()</span> to scale? How would that work?</div>
<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">void my_draw_widget(cr)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">{</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace"> // draw a /!\ symbol </font></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="'courier new', monospace"> cairo_save(cr);</font></div>
<div></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> my_draw_triangle(30,0, 60,50, 0,50);</span></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>
<div><font class="Apple-style-span" face="'courier new', monospace"> cairo_translate(25, 40);</font></div></div><div><font class="Apple-style-span" face="'courier new', monospace"> </font><span class="Apple-style-span" style="font-family: monospace; font-size: medium; white-space: pre; ">cairo_set_font_size(cr, 30);</span></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> cairo_show_text (cr, "!");</span></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>
<div><div><font class="Apple-style-span" face="'courier new', monospace"> cairo_restore(cr);</font></div></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">}</span></div>
</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>I think I'd rather save the font space in a variable and restore it when needed:</div><div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">my_label_font_space = cairo_save_font_space(cr);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="'courier new', monospace">void my_draw_label(cr, text)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">{</font></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="'courier new', monospace"> cairo_save(cr);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> </font><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">cairo_restore_font_space(cr, my_label_font_space);</span></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="'courier new', monospace"> cairo_show_text (cr, text);</font></div>
<div></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> cairo_restore(cr);</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">}</span></div>
<div><br></div><div>Groeten, Arjen</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div class="gmail_quote">On Fri, Aug 27, 2010 at 9:45 PM, Behdad Esfahbod <span dir="ltr"><<a href="mailto:behdad@behdad.org">behdad@behdad.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">It occured to me last night that instead of changing the behavior of font /<br>
pen space locking at the they are set, we can add two new calls:<br>
<br>
cairo_lock_font_space()<br>
cairo_lock_pen_space()<br>
<br>
These two will record the ctm at the time of the call to be used for text /<br>
stroke until the font-space / pen-space is set again (perhaps implicitly by<br>
cairo_restore()).<br>
<br>
May want to add the unlock() versions too. I don't like the fact that the<br>
unlock is not mandatory, but I think I can live with this API and have more<br>
confidence in it than I have in changing the semantics of existing API.<br>
<font color="#888888"><br>
behdad<br>
</font><div><div></div><div class="h5">--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</div></div></blockquote></div><br>