<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro.pas - Problems with Using a Bitmap Font</title>
		<link>http://www.allegro.cc/forums/view/605972</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 08 Jan 2011 02:00:31 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi there,<br />I&#39;ve just recently started programming a game in Allegro.pas (I chose the Pascal version because Pascal is the only programming language I&#39;m familiar with so far). Right now I&#39;m working on setting up all the mandatory stuff (Allegro initilization, config file etc.). Here I&#39;m have encountered a problem with using a Bitmap Font, which I can&#39;t solve. First of all the font itself (created with an Allegro font editor):</p><p><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/c/e/cecef110a9a3c1633e04821d9994cca3.png" alt="rpghackerfontrmg2000.png" width="113" height="79" /></p><p>The pink part is color 0, the yellow part color 255 and it&#39;s saved as 256-color-BMP-image (even though ImageShack seems to automatically convert it to PNG when uploading). At first I tried the &quot;simple&quot; version:</p><p>FUNCTION al_load_bitmap_font (filename: STRING; palette: AL_PALETTEptr; p: POINTER): POINTER;</p><p>Here I had the problem that I didn&#39;t even know what the pointer p is supposed to be. It&#39;s not mentioned in the documentation. Additionally it crashed (I just tried to use &quot;nil&quot; for p). Next I tried the method with first loading a bmp and then grabbing a font from it.</p><p>FUNCTION al_load_bmp (filename: STRING; palette: AL_PALETTEptr): AL_BITMAPptr; CDECL; EXTERNAL ALLEGRO_SHARED_LIBRARY_NAME NAME &#39;load_bmp&#39;;<br />FUNCTION al_grab_font_from_bitmap (bmp: AL_BITMAPptr): AL_FONTptr; CDECL; EXTERNAL ALLEGRO_SHARED_LIBRARY_NAME NAME &#39;grab_font_from_bitmap&#39;;</p><p>Loading the BMP file works just fine. Even displaying it using the al_blit function works as expected. However, whenever my program gets to the grab_font part of my code it crashes, displaying random errors messages I don&#39;t understand. I&#39;ve read the according entries in the documentation over and over again, but I just couldn&#39;t find the mistake. Can someone help out? Here are the portions of my code that (I think) matter.</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>program RPGHacker_LPYGEntry<span class="k2">;</span>
<span class="number">  2</span>
<span class="number">  3</span>uses
<span class="number">  4</span>  sysutils,
<span class="number">  5</span>  allegro,
<span class="number">  6</span>  alfile<span class="k2">;</span>
<span class="number">  7</span>
<span class="number">  8</span>var
<span class="number">  9</span>  FontRMG2000 <span class="k2">:</span> AL_FONTptr<span class="k2">;</span>
<span class="number"> 10</span>
<span class="number"> 11</span>
<span class="number"> 12</span>
<span class="number"> 13</span>function GameInit <span class="k2">:</span> boolean<span class="k2">;</span>       <span class="k2">{</span>Game initilization function<span class="k2">}</span>
<span class="number"> 14</span>  var <span class="k2">[</span>...<span class="k2">]</span>
<span class="number"> 15</span>    BitmapPtr <span class="k2">:</span> AL_BITMAPptr<span class="k2">;</span>
<span class="number"> 16</span>
<span class="number"> 17</span>begin
<span class="number"> 18</span>  <span class="k2">[</span>Allegro initilization routines, including al_set_gfx_mode, go here<span class="k2">]</span>
<span class="number"> 19</span>  <span class="k2">[</span>...<span class="k2">]</span>
<span class="number"> 20</span>
<span class="number"> 21</span>  Path <span class="k2">:</span><span class="k3">=</span> ExtractFilePath<span class="k2">(</span>ParamStr<span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">)</span> <span class="k3">+</span> <span class="s">'\bitmap\RPG_Hacker-Font_RMG2000.bmp'</span><span class="k2">;</span>
<span class="number"> 22</span>  BitmapPtr <span class="k2">:</span><span class="k3">=</span> al_load_bmp<span class="k2">(</span>Path,@al_default_palette<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span><span class="k2">(</span><span class="k3">*</span> This here is where the crash occures <span class="k3">*</span><span class="k2">)</span>
<span class="number"> 24</span>  FontRMG2000 <span class="k2">:</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_grab_font_from_bitmap"><span class="a">al_grab_font_from_bitmap</span></a><span class="k2">(</span>BitmapPtr<span class="k2">)</span><span class="k2">;</span>  
<span class="number"> 25</span>end<span class="k2">;</span>
<span class="number"> 26</span>
<span class="number"> 27</span><span class="k2">[</span>...<span class="k2">]</span>
</div></div><p>

<b>EDIT:</b><br />The error says &quot;Project [Projectname].exe raised exception class &#39;External: SIGSEGV&#39;.&quot; This seems to be the default error I get whenever something goes wrong.</p><p><b>EDIT:</b><br />Problem solved. Turned out from some color editing in an external program the format of my font changed to a format unreadable by Allegro. Can&#39;t really explain this, but oh well. At least it works now!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Wed, 05 Jan 2011 19:13:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>SIGSEGV isn&#39;t the default error. It is a very common one. It means that you&#39;ve tried to access something you shouldn&#39;t. Like going out of bounds in an array.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (J-Gamer)</author>
		<pubDate>Fri, 07 Jan 2011 23:51:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I forgot to add &quot;The default error I get&quot;. What I meant is that this always seems to be the cause when something goes wrong for me. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>Anyways, as mentioned in the EDIT, the problem is fixed now. After exporting the font with the font editor, editing it with any graphics editor seems to break it for Allegro. However, I&#39;ve found out that increasing the color depth of the image to 24-Bit fixes it again.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Sat, 08 Jan 2011 02:00:31 +0000</pubDate>
	</item>
</rss>
