* \param bufsize out: file size
* \return pointer to file contents. Caller is responsible for its deallocation.
*/
-static char *read_file(ASS_Library *library, char *fname, size_t *bufsize)
+char *read_file(ASS_Library *library, char *fname, size_t *bufsize)
{
int res;
long sz;
#include <sys/types.h>
#include <sys/stat.h>
#include <inttypes.h>
+#include <limits.h>
#include <ft2build.h>
+#include <sys/types.h>
+#include <dirent.h>
#include FT_FREETYPE_H
#include FT_SFNT_NAMES_H
#include FT_TRUETYPE_IDS_H
NULL
};
+static void load_fonts_from_dir(ASS_Library *library, const char *dir)
+{
+ DIR *d = opendir(dir);
+ if (!d)
+ return;
+ while (1) {
+ struct dirent *entry = readdir(d);
+ if (!entry)
+ break;
+ char fullname[PATH_MAX];
+ snprintf(fullname, sizeof(fullname), "%s/%s", dir, entry->d_name);
+ size_t bufsize = 0;
+ ass_msg(library, MSGL_WARN, "Loading font file '%s'", fullname);
+ void *data = read_file(library, fullname, &bufsize);
+ if (data) {
+ ass_add_font(library, entry->d_name, data, bufsize);
+ free(data);
+ }
+ }
+ closedir(d);
+}
+
/**
* \brief Create a bare font provider.
* \param selector parent selector. The provider will be attached to it.
if (priv == NULL)
return NULL;
+ if (lib->fonts_dir && lib->fonts_dir[0]) {
+ load_fonts_from_dir(lib, lib->fonts_dir);
+ }
+
for (i = 0; i < lib->num_fontdata; ++i)
process_fontdata(priv, lib, ftlib, i);