Problem with SDL_ttf on Android

Hi,
I have very strange issue with SDL_ttf on android (SDL 1.3). TTF_OpenFont
can’t open any font file and returns ‘java.io.FileNotFound Exception’. I
tried to specify full path in this function or change current path with
chdir("/sdcard") but no result . My font file (arial.ttf) located in the
sdcard root folder.

My code:

#ifdef ANDROID
chdir("/sdcard");
#endif

TTF_font* font;
if(TTF_Init()==-1)
{
return -1;
}

if(font=TTF_OpenFont(“arial.ttf”, 16)==NULL)
{
Logger::WriteLog(“TTF open font failed: %s”, TTF_GetError()); //
java.io.FileNotFound Exception here
return -1;
}

TTF_Quit();

Any ideas?

P.S. I’m reading any files from sdcard by C++ streams in my code without any
troubles.
P.P.S. This code works fine in windows.

2012/1/8 Matveev Dmitry <matveev_dmitry at list.ru>

Hi,
I have very strange issue with SDL_ttf on android (SDL 1.3). TTF_OpenFont
can’t open any font file and returns ‘java.io.FileNotFound Exception’. I
tried to specify full path in this function or change current path with
chdir("/sdcard") but no result . My font file (arial.ttf) located in the
sdcard root folder.

I don’t know what’s the problem with your code, but I can offer a
workaround… put the font file inside /assets in your Android project, and
load it from your code without a path and without changing directories
(that is, dont load “/assets/arial.ttf” but rather just “arial.ttf”) . The
RWOps magic inside the SDL will handle everything for you and also your
font will ship with the package so you don’t have to manually upload it.–
Gabriel.

Thank you. I’ll try.----- Original Message -----
From: Gabriel Jacobo
To: SDL Development List
Sent: Sunday, January 08, 2012 6:06 PM
Subject: Re: [SDL] Problem with SDL_ttf on Android

2012/1/8 Matveev Dmitry <@Matveev_Dmitry>

Hi,
I have very strange issue with SDL_ttf on android (SDL 1.3). TTF_OpenFont can't open any font file and returns 'java.io.FileNotFound Exception'. I tried to specify full path in this function or change current path with chdir("/sdcard") but no result . My font file (arial.ttf) located in the sdcard root folder.

I don’t know what’s the problem with your code, but I can offer a workaround… put the font file inside /assets in your Android project, and load it from your code without a path and without changing directories (that is, dont load “/assets/arial.ttf” but rather just “arial.ttf”) . The RWOps magic inside the SDL will handle everything for you and also your font will ship with the package so you don’t have to manually upload it.


Gabriel.



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hm, this works :).
But why I can’t load font with specified path?----- Original Message -----
From: Matveev Dmitry
To: SDL Development List
Sent: Sunday, January 08, 2012 6:15 PM
Subject: Re: [SDL] Problem with SDL_ttf on Android

Thank you. I’ll try.
----- Original Message -----
From: Gabriel Jacobo
To: SDL Development List
Sent: Sunday, January 08, 2012 6:06 PM
Subject: Re: [SDL] Problem with SDL_ttf on Android

2012/1/8 Matveev Dmitry <@Matveev_Dmitry>

  Hi,
  I have very strange issue with SDL_ttf on android (SDL 1.3). TTF_OpenFont can't open any font file and returns 'java.io.FileNotFound Exception'. I tried to specify full path in this function or change current path with chdir("/sdcard") but no result . My font file (arial.ttf) located in the sdcard root folder.




I don't know what's the problem with your code, but I can offer a workaround... put the font file inside /assets in your Android project, and load it from your code without a path and without changing directories (that is, dont load "/assets/arial.ttf" but rather just "arial.ttf") . The RWOps magic inside the SDL will handle everything for you and also your font will ship with the package so you don't have to manually upload it.


-- 
Gabriel.

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org