<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: &#39;courier new&#39;, monospace; ">// All captions should be the same size </span></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">cairo_lock_font_space(cr);</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, 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="&#39;courier new&#39;, monospace">cairo_save(cr);</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, 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="&#39;courier new&#39;, monospace">my_draw_widget(cr);</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">cairo_show_text (cr, &quot;My Tall Widget&quot;);</font></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">cairo_restore(cr);</font></div>
</div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">// draw as narrow widget at [100,0] and add a caption</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">cairo_save(cr);</font></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">cairo_translate(100, 0);</font></div>
</div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">cairo_scale(0.5, 2);</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">my_draw_widget(cr);</font></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; ">cairo_show_text (cr, &quot;My Narrow Widget&quot;);</span></div><div><div></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, 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: &#39;courier new&#39;, monospace; ">my_draw_widget()</span> to scale? How would that work?</div>
<div><br></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">void my_draw_widget(cr)</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">{</font></div><div>
<font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    // draw a /!\ symbol </font></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    cairo_save(cr);</font></div>
<div></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, 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="&#39;courier new&#39;, monospace">    cairo_translate(25, 40);</font></div></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, 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: &#39;courier new&#39;, monospace; ">    cairo_show_text (cr, &quot;!&quot;);</span></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>
<div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    cairo_restore(cr);</font></div></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; ">}</span></div>
</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>I think I&#39;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="&#39;courier new&#39;, monospace">my_label_font_space = cairo_save_font_space(cr);</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">void my_draw_label(cr, text)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">{</font></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    cairo_save(cr);</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    </font><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, 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="&#39;courier new&#39;, monospace">    cairo_show_text (cr, text);</font></div>
<div></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; ">    cairo_restore(cr);</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, 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">&lt;<a href="mailto:behdad@behdad.org">behdad@behdad.org</a>&gt;</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&#39;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>