[haiku-3rdparty-dev] Re: Get path to font file

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Fri, 13 Nov 2009 10:09:45 +0100

On 2009-11-13 at 08:06:45 [+0100], scott mc <scottmc2@xxxxxxxxx> wrote:
> On Fri, Nov 13, 2009 at 6:46 AM, Adrian Panasiuk <adek336@xxxxxxxxx> 
> wrote:
> > Hi ! Is it possible to get the path to a font , given the name of the 
> > font I want and whether it's bold/italic?
> > Can I at least get a path to a default font without hardcoding? Regards,
> > Adrian.
> 
> If you know the name of the font you could use find_directory() to look 
> in the font directories for it:
> B_BEOS_FONTS_DIRECTORY
> B_USER_FONTS_DIRECTORY
> B_COMMON_FONTS_DIRECTORY
> B_SYSTEM_FONTS_DIRECTORY
> 

Font files typically have a cryptic name, at least they are mostly not 
named like the family. So what you say is only possible if you indeed open 
and parse the font files in those directories with some font engine in 
order to match up the family/style name you have from a BFont.

Best regards,
-Stephan

Other related posts: