<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Android: how to open an assets file?</title>
		<link>http://www.allegro.cc/forums/view/611868</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 22 Jan 2013 21:42:48 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Should be easy, but does not work:</p><div class="source-code snippet"><div class="inner"><pre>al_android_set_apk_file_interface<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_FILE"><span class="a">ALLEGRO_FILE</span></a> <span class="k3">*</span>f<span class="k3">=</span><a href="http://www.allegro.cc/manual/al_fopen"><span class="a">al_fopen</span></a><span class="k2">(</span><span class="s">"myFile"</span>,<span class="s">"rb"</span><span class="k2">)</span><span class="k2">;</span>
<span class="k1">int</span> fsize<span class="k3">=</span><a href="http://www.allegro.cc/manual/al_fsize"><span class="a">al_fsize</span></a><span class="k2">(</span>f<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

The result: f is not 0, but it shows no content either. The value of fsize = 0. What&#39;s wrong?</p><p>PS<br />Maybe this is a wrong question. The &quot;myFile&quot; actually was a .ttf fontfile. I saw in the allegro source code that allegro tries to classify files by means of their extension. Maybe a .ttf file is refused because in case of Android there is no handler for it? Anyhow, I tried to do the same with a normal text file and that worked perfectly. Anybody any idea?</p><p>PS2<br />I also tried a build-in font:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_FILE"><span class="a">ALLEGRO_FILE</span></a> <span class="k3">*</span>ttf_file<span class="k3">=</span><a href="http://www.allegro.cc/manual/al_fopen"><span class="a">al_fopen</span></a><span class="k2">(</span><span class="s">"/system/fonts/DroidSans.ttf"</span>,<span class="s">"rb"</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Same result: the file could be opened, but its size was zero.</p><p>PS3<br />Using FILE instead of ALLEGRO_FILE works. I&#39;ll submit a bug.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (weeboe)</author>
		<pubDate>Tue, 22 Jan 2013 21:42:48 +0000</pubDate>
	</item>
</rss>
