<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_draw_text(...) not accurate</title>
		<link>http://www.allegro.cc/forums/view/611363</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 01 Nov 2012 13:53:30 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The problem I&#39;m having is... Well, here&#39;s the code:
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><a href="http://www.allegro.cc/manual/ALLEGRO_FONT"><span class="a">ALLEGRO_FONT</span></a> <span class="k3">*</span><a href="http://www.allegro.cc/manual/font"><span class="a">font</span></a> <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_load_ttf_font"><span class="a">al_load_ttf_font</span></a><span class="k2">(</span><span class="s">"octovill.ttf"</span>,<span class="n">30</span>,<span class="n">0</span> <span class="k2">)</span><span class="k2">;</span>
<span class="number">  2</span><span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/font"><span class="a">font</span></a><span class="k2">)</span><span class="k2">{</span>
<span class="number">  3</span>   LOG<span class="k2">(</span><span class="s">"...could not load 'octovill.ttf'.\nEnd Program."</span>, <span class="k1">true</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span>   kill_allegro<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  5</span>   <span class="k1">return</span> <span class="k3">-</span><span class="n">1</span><span class="k2">;</span>
<span class="number">  6</span><span class="k2">}</span>
<span class="number">  7</span><span class="k1">int</span> txtx, txty, txtw, txth<span class="k2">;</span>
<span class="number">  8</span><a href="http://www.allegro.cc/manual/al_get_text_dimensions"><span class="a">al_get_text_dimensions</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/font"><span class="a">font</span></a>, <span class="s">"Press ESC to exit program."</span>, <span class="k3">&amp;</span>txtx, <span class="k3">&amp;</span>txty, <span class="k3">&amp;</span>txtw, <span class="k3">&amp;</span>txth<span class="k2">)</span><span class="k2">;</span>
<span class="number">  9</span><a href="http://www.allegro.cc/manual/al_draw_text"><span class="a">al_draw_text</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/font"><span class="a">font</span></a>, <a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a><span class="k2">(</span><span class="n">190</span>,<span class="n">225</span>,<span class="n">190</span><span class="k2">)</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="s">"Press ESC to exit program."</span><span class="k2">)</span><span class="k2">;</span>
</div></div><p>
The text should appear at 0,0 at the top-left of screen. It does. Its x-position is accurate, but its y-position is +2 in error.</p><p>Additionally, al_get_text_dimensions(...) returns an erroneous y offset and a height that&#39;s greater than what it should be. The width and x offset it returns are accurate.</p><p>The reason I have to come here and ask is because if I don&#39;t figure out why it does this then I&#39;ll have to write some code to examine the font myself and get the correct x/y offset/width/height for each font type.</p><p>If that wasn&#39;t enough, I also have to report that when I use ALLEGRO_ALIGN_CENTRE in al_draw_text(...) it centers correctly horizontally but not vertically. In fact, I don&#39;t think it even tries to center vertically.</p><p>So there appears to be some screwy vertical/y-axis bugs.</p><p>On the plus-side, if I can&#39;t fix this then I can just convert some win32 code I wrote over to allegro - all i gotta do is replace gdi calls with allegro. (I was loading my fonts from bitmap files.)</p><p>I&#39;m using Allegro 5.0.7 binaries.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (fallenlight12)</author>
		<pubDate>Thu, 01 Nov 2012 06:48:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t know about the y offset. Perhaps it is part of the font?</p><p>ALLEGRO_ALIGN_LEFT/CENTRE/RIGHT only align horizontally.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Thu, 01 Nov 2012 07:43:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Most TTF fonts are not pixel-perfect. You&#39;ll almost certainly have to adjust your coordinates to take into account the nuances of each font you use. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Thu, 01 Nov 2012 08:26:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you have a screenshot and is that .ttf available somewhere?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Thu, 01 Nov 2012 13:53:30 +0000</pubDate>
	</item>
</rss>
