Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » System fonts folder

This thread is locked; no one can reply to it. rss feed Print
System fonts folder
CodeStepper
Member #14,495
August 2012
avatar

Hi!

I'm working on Windows XP, so system fonts folder is %WINDIR%/fonts
How about other systems?

I would be very grateful, if someone gave me a path, which, that returns this function:

ALLEGRO_PATH *path = al_get_standard_path( ALLEGRO_USER_HOME_PATH );
std::string home = al_path_cstr( path, ALLEGRO_NATIVE_PATH_SEP );

path = al_create_path_for_directory( home.c_str( ) );

Specifically, variable path value.
And folder with fonts

Matthew Leverton
Supreme Loser
January 1999
avatar

Allegro doesn't support font folders. Ideally there would be an API like:

q = al_create_font_query("sans-serif");
while ((font_info = al_find_font(q)))
{
  printf("Font %s lives at %s\n", font_info->name, font_info->path);
}
al_destroy_font_query(q);

along with helper functions to find or load the font that best matches the query.

Thomas Fjellstrom
Member #476
June 2000
avatar

If added as an addon I could see it having a function to return an ALLEGRO_FONT and use the system font loader as an option.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

CodeStepper
Member #14,495
August 2012
avatar

I try create this, but i need font folders :D

I need only path to system font folders, because i create function, which collect font informations and path to font ( i have an idea ) but i have font folder only for XP

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

I try create this, but i require font folders

It would have to be part of that code. It would use platform specific code internally to find the fonts and/or font folders. Ideally you wouldn't even need the font folders. You'd ask the operating system for fonts, and it would deal with finding them.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

CodeStepper
Member #14,495
August 2012
avatar

But i would only detect font installed in system...

Only DETECT ( not LOAD )

Thomas Fjellstrom
Member #476
June 2000
avatar

But i would only detect font installed in system...

Right, and the best way to do that would be to ask the OS for the font or a list of fonts, instead of looking in various font folders :)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

CodeStepper
Member #14,495
August 2012
avatar

But i think, my idea is simple...

ALLEGRO_PATH *path = al_get_standard_path( ALLEGRO_USER_HOME_PATH );
std::string home = al_path_cstr( path, ALLEGRO_NATIVE_PATH_SEP );
home.append( "..\\..\\WINDOWS\\fonts" );

path = al_create_path_for_directory( home.c_str( ) );

But this is only for xp

I missunderstand you at this moment... sorry :-/

Matthew Leverton
Supreme Loser
January 1999
avatar

Not all systems have a single font folder. For example, I have /home/matthew/.fonts and /usr/share/fonts/ (with many sub folders).

CodeStepper
Member #14,495
August 2012
avatar

this from linux?

But how implement this to detecting font folder, because i have any idea :/

Thomas Fjellstrom
Member #476
June 2000
avatar

But how implement this to detecting font folder, because i have any idea :/

Instead of detecting the font folder, just find an API (a function) from the OS that lets you get a list of fonts. Like font names and their locations. Maybe even support loading the font directly with this addon (using the OS interfaces) but thats not really all that important.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

CodeStepper
Member #14,495
August 2012
avatar

Oh, i see now :D
Thank you for help :)

Matthew Leverton
Supreme Loser
January 1999
avatar

I think you'd have to interface with the fontconfig library to do a proper job on Linux.

To write a proper Allegro add-on (or to update the current font add-on), you'd want to take a look at all of the systems Allegro supports and see if there is a common subset of functionality that could be provided across all of them.

i.e., The goal wouldn't be to expose all of the features of fontconfig, but to solve the most common use case of querying available fonts.

jmasterx
Member #11,410
October 2009

CodeStepper
Member #14,495
August 2012
avatar

Thanks

Go to: