IPhone: Fontconfig error: unable to load default configuration file

I have the following problem:

I included the old FontConfig libfontconfig.a library in my iPhone project .

The application creates, and I can run it on the device, but when I call a method that needs some functions of this library, the application crashes with the following error

Fontconfig error: unable to load default configuration file

terminate throwing an exception

I read that this error usually occurs when FontConfig cannot find the fonts.conf file, which is usually located in / etc / fonts.

But I can not move this file to this iPhone directory. Anyone have a solution? Just copying the file to the application package also did not help.

I would be grateful for any help.

+5
1

- . FONTCONFIG_FILE FONTCONFIG_PATH, fonts.conf , /etc/fonts. @runtime.

, FontConfig. AppDelegate.

, :

//Get the directory of your Application
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];

//Create a String with the location of your fonts.conf file
NSString *fontconfigFile= [bundlePath stringByAppendingString:
                             [NSString stringWithFormat:@"/fonts/fonts.conf"]];

//Create a String with the path of the FontConfig configuration path
NSString *fontconfigPath= [bundlePath stringByAppendingString:
                             [NSString stringWithFormat:@"/fonts"]];

//Set the Environment Variables
setenv("FONTCONFIG_FILE", [fontconfigFile UTF8String], 0); 
setenv("FONTCONFIG_PATH", [fontconfigPath UTF8String], 0); 

fonts.conf. FC/fonts FC/cache fonts.conf .

:

<!-- Font directory list -->

<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>~/.fonts</dir>

<!-- Font directory list -->

<dir>FC/fonts</dir>

:

<!-- Font cache directory list -->

<cachedir>/opt/local/fc1407cd/var/cache/fontconfig</cachedir>
<cachedir>~/.fontconfig</cachedir>

<!-- Font cache directory list -->

<cachedir>FC/cache</cachedir>

.

+3

All Articles