<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Font Dealing 2</title>
		<link>http://www.allegro.cc/forums/view/585843</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 11 Jun 2006 21:02:55 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>hi again<br />as i remember we had a settextjustify function in Turbo c but i dont know its equal<br />function in allegro .<br />corresponding function.<br />thanks alot.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (hossein)</author>
		<pubDate>Sat, 10 Jun 2006 16:27:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">man textprintf_ex said:</div><div class="quote"><p>

SEE ALSO<br />       font(3),            textout_ex(3),             <b>textprintf_centre_ex(3)</b>,<br />       <b>textprintf_right_ex(3)</b>,    <b>textprintf_justify_ex(3)</b>,    text_height(3),<br />       text_length(3), uszprintf(3)
</p></div></div><p>
Emphasis mine.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 10 Jun 2006 16:32:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there a reason you can&#39;t reply in the first thread?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 10 Jun 2006 16:39:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>hi evert<br />i tried what you said but didnt got desired goal.<br />main problem was that i coudlnt justify text as horizontal or vertical.<br />please help me to solve that .<br />i am asking miran too because it seems so professional in this field.<br />help me miran,evert,or my friends.<br />bye.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (hossein)</author>
		<pubDate>Sat, 10 Jun 2006 17:42:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Is there a reason you can&#39;t reply in the first thread?
</p></div></div><p>
Saw this one first?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
main problem was that i coudlnt justify text as horizontal or vertical.
</p></div></div><p>
What do you mean by justify horizontal or vertical?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 10 Jun 2006 20:18:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Saw this one first?
</p></div></div><p>
Sorry, I was talking to the OP. He started a thread with an almost identical question before, I gave him an answer (although not as detailed as yours), after which he proceeded to start this one.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 10 Jun 2006 20:32:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, ok.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 10 Jun 2006 20:46:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
hi evert<br />i tried what you said but didnt got desired goal.<br />main problem was that i coudlnt justify text as horizontal or vertical.<br />please help me to solve that .<br />i am asking miran too because it seems so professional in this field.<br />help me miran,evert,or my friends.<br />bye.
</p></div></div><p>
If you mean rendering text top-down instead of left-right: You can&#39;t, really. This would involve rotating characters, something which is not implemented in allegro&#39;s text api.<br />To achieve vertical text output, here&#39;s what you can do. First, you use text_length() and text_height() to find the text&#39;s size in pixels. Create a memory bitmap of that same size, and fill it with the transparent color (magic pink / #0; bitmap_mask_color() will give you the correct value). Render the text normally onto the memory bitmap. Then use pivot_sprite() to draw the text wherever you want it. Remember that draw_sprite() expects angles in fixed-point, 256-degrees format, so to rotate the text by 90 degrees, you need to use itofix(64) as the angle. Finally, don&#39;t forget to clean up the temporary bitmap.<br />So:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> textout_vertical<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> bmp, <span class="k1">const</span> <a href="http://www.allegro.cc/manual/FONT" target="_blank"><span class="a">FONT</span></a><span class="k3">*</span> <a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>, <span class="k1">const</span> <span class="k1">char</span><span class="k3">*</span> str, <span class="k1">int</span> x, <span class="k1">int</span> y, <span class="k1">int</span> fg, <span class="k1">int</span> bg<span class="k2">)</span> <span class="k2">{</span>
  <span class="k1">int</span> w <span class="k3">=</span> <a href="http://www.allegro.cc/manual/text_length" target="_blank"><span class="a">text_length</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>, str<span class="k2">)</span><span class="k2">;</span>
  <span class="k1">int</span> h <span class="k3">=</span> <a href="http://www.allegro.cc/manual/text_height" target="_blank"><span class="a">text_height</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> buf <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span>w, h<span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/clear_to_color" target="_blank"><span class="a">clear_to_color</span></a><span class="k2">(</span>buf, <a href="http://www.allegro.cc/manual/bitmap_mask_color" target="_blank"><span class="a">bitmap_mask_color</span></a><span class="k2">(</span>buf<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/textout_ex" target="_blank"><span class="a">textout_ex</span></a><span class="k2">(</span>buf, <a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>, str, <span class="n">0</span>, <span class="n">0</span>, fg, bg<span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/pivot_sprite" target="_blank"><span class="a">pivot_sprite</span></a><span class="k2">(</span>bmp, buf, x, y, <span class="n">0</span>, h, <a href="http://www.allegro.cc/manual/itofix" target="_blank"><span class="a">itofix</span></a><span class="k2">(</span><span class="n">64</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>buf<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
This should do the trick.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Sun, 11 Jun 2006 21:02:55 +0000</pubDate>
	</item>
</rss>
