Finalmente encontré la manera de resolver este problema. Establecí una Variable de entorno FONTCONFIG_FILE y FONTCONFIG_PATH que definen las ubicaciones del archivo fonts.conf y la ruta anterior a /etc/fonts. Así que puedo agregar el directorio fonts al proyecto y definir la ruta @runtime.
Las variables de entorno deben establecerse en su código antes de llamar a un método que necesita una funcionalidad de FontConfig. Lo configuro después de iniciar mi aplicación en AppDelegate.
Este es el código añadí:
//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);
En una segunda etapa, que tenía entonces a modificar mi archivo fonts.conf. Agregué el directorio de fuentes a FC/fonts y el directorio de caché a FC/caché de mi proyecto y ajusté el archivo fonts.conf en dos partes.
I cambió la primera parte:
<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>~/.fonts</dir>
a:
<!-- Font directory list -->
<dir>FC/fonts</dir>
y la segunda parte:
<!-- Font cache directory list -->
<cachedir>/opt/local/fc1407cd/var/cache/fontconfig</cachedir>
<cachedir>~/.fontconfig</cachedir>
a:
<!-- Font cache directory list -->
<cachedir>FC/cache</cachedir>
Luego ya no se colgó.
¿Cómo pudiste compilar fontConfig. ¿Podrías compartir la biblioteca? –
No lo compilé yo solo. Lo tomé de otro proyecto. Puede encontrar el fontConfig compilado en este proyecto github: https://github.com/xil3f/podofo_iOS_sample –