lock xft, plugin index builder lock, clear clip thumbnails, clear vwin clock, setpoin...
authorGood Guy <good1.2guy@gmail.com>
Tue, 17 Jul 2018 22:26:22 +0000 (16:26 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 17 Jul 2018 22:26:22 +0000 (16:26 -0600)
18 files changed:
cinelerra-5.1/cinelerra/deleteallindexes.C
cinelerra-5.1/cinelerra/deleteallindexes.h
cinelerra-5.1/cinelerra/interfaceprefs.C
cinelerra-5.1/cinelerra/interfaceprefs.h
cinelerra-5.1/cinelerra/mainclock.C
cinelerra-5.1/cinelerra/mainclock.h
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/mwindow.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/pluginaclientlad.C
cinelerra-5.1/cinelerra/vwindow.C
cinelerra-5.1/guicast/bcpixmap.C
cinelerra-5.1/guicast/bcresources.C
cinelerra-5.1/guicast/bcwindowbase.C
cinelerra-5.1/guicast/bcwindowdraw.C
cinelerra-5.1/guicast/workarounds.C
cinelerra-5.1/guicast/workarounds.h
cinelerra-5.1/plugins/titler/titler.C

index 485f00c855db2efed77bbaeff20bd2b070f3f844..15aa857e9e57a9f1a3dc8efad0101a3f5159c246 100644 (file)
 #define gettext_noop(String) String
 #define N_(String) gettext_noop (String)
 
-DeleteAllIndexes::DeleteAllIndexes(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y)
- : BC_GenericButton(x, y, _("Delete existing indexes")), Thread()
+DeleteAllIndexes::DeleteAllIndexes(MWindow *mwindow, PreferencesWindow *pwindow,
+       int x, int y, const char *text, const char *filter)
+ : BC_GenericButton(x, y, text), Thread()
 {
        this->mwindow = mwindow;
        this->pwindow = pwindow;
+       this->filter = filter;
 }
 
 DeleteAllIndexes::~DeleteAllIndexes()
@@ -51,52 +53,23 @@ int DeleteAllIndexes::handle_event()
        return 1;
 }
 
-static int test_filter(const char *string, const char *filter)
-{
-       return (strlen(string) > strlen(filter) &&
-                       !strcmp(string + strlen(string) - strlen(filter), filter));
-}
-
 void DeleteAllIndexes::run()
 {
-       char string[BCTEXTLEN], string1[BCTEXTLEN], string2[BCTEXTLEN];
-// prepare directory
+       char string1[BCTEXTLEN], string2[BCTEXTLEN];
        strcpy(string1, pwindow->thread->preferences->index_directory);
        FileSystem dir;
        dir.update(pwindow->thread->preferences->index_directory);
        dir.complete_path(string1);
-// prepare filter
-       const char *filter1 = ".idx";
-       const char *filter2 = ".toc";
-       const char *filter3 = ".mkr";
-
-//     pwindow->disable_window();
-       sprintf(string, _("Delete all indexes in %s?"), string1);
-//     QuestionWindow confirm(mwindow);
-//     confirm.create_objects(string, 0);
-
-//     int result = confirm.run_window();
-
-       int result = 0;
-       if(!result)
-       {
-               for(int i = 0; i < dir.dir_list.total; i++)
-               {
-                       result = 1;
-                       sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
-// test filter
-                       if(test_filter(string2, filter1) ||
-                               test_filter(string2, filter2) ||
-                               test_filter(string2, filter3))
-                       {
-                               remove(string2);
+
+       for( int i=0; i<dir.dir_list.total; ++i ) {
+               const char *fn = dir.dir_list.values[i]->name;
+               if( FileSystem::test_filter(fn, filter) ) continue;
+               sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
+               remove(string2);
 printf("DeleteAllIndexes::run %s\n", string2);
-                       }
-               }
        }
 
        pwindow->thread->redraw_indexes = 1;
-//     pwindow->enable_window();
 }
 
 
index f4da546eda741a5d99e16f72771a7cca99fb752e..f882b3abf82ae4533c68184a3307658970f2090e 100644 (file)
 class DeleteAllIndexes : public BC_GenericButton, public Thread
 {
 public:
-       DeleteAllIndexes(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y);
+       DeleteAllIndexes(MWindow *mwindow, PreferencesWindow *pwindow,
+               int x, int y, const char *text, const char *filter);
        ~DeleteAllIndexes();
 
        void run();
        int handle_event();
        PreferencesWindow *pwindow;
        MWindow *mwindow;
+       const char *filter;
 };
 
 class ConfirmDeleteAllIndexes : public BC_Window
index 5142b3b6799bf3a672396a4d7706b071cba49dcc..9c0b51dd2e5bed868856c75a71f07766172323ea 100644 (file)
@@ -226,10 +226,12 @@ void InterfacePrefs::create_objects()
                MEDIUMFONT, resources->text_default));
        sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
        add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
-       add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 400, y));
+       add_subwindow(del_indexes = new DeleteAllIndexes(mwindow, pwindow, 400, y,
+               _("Delete existing indexes"), "[*.idx][*.toc][*.mkr]"));
        y += 30;
        add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
-       y += 35;
+       add_subwindow(del_clipngs = new DeleteAllIndexes(mwindow, pwindow, 400, y,
+               _("Delete clip thumbnails"), "clip_*.png"));
 }
 
 const char* InterfacePrefs::behavior_to_text(int mode)
index 1a912d3715d6217ea877c3e05dc5b587d9c62e7d..1d1844c1e38fefda744460553cb3b991475f94ab 100644 (file)
@@ -48,7 +48,8 @@ public:
        IndexSize *isize;
        IndexCount *icount;
        IndexPathText *ipathtext;
-       DeleteAllIndexes *deleteall;
+       DeleteAllIndexes *del_indexes;
+       DeleteAllIndexes *del_clipngs;
        IndexFFMPEGMarkerFiles *ffmpeg_marker_files;
 
        ViewBehaviourText *button1, *button2, *button3;
index 3fbbc5761ba228c3662b29025d4d0747f9c459dd..ddee51a23634249d8a28b7f1328f4a6a8230934b 100644 (file)
@@ -58,7 +58,10 @@ void MainClock::update(double position)
        unlock_window();
 }
 
-
-
-
+void MainClock::clear()
+{
+       lock_window("MainClock::clear");
+       BC_Title::update("");
+       unlock_window();
+}
 
index dbfcb2bf0c75f56412a1c24c64fb696b53252a19..b876bfd1540ae4454e8e14bee39e150be735c4a8 100644 (file)
@@ -34,6 +34,7 @@ public:
 
        void set_position_offset(double value);
        void update(double position);
+       void clear();
 
        MWindow *mwindow;
        double position_offset;
index 2e590c668f376c244c2d46fd6af4f7693962888c..e81b4574387016109e21385ac5fd73b8b2a9b796 100644 (file)
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/mman.h>
+#include <sys/file.h>
 #include <limits.h>
 #include <errno.h>
 
@@ -523,12 +524,11 @@ void MWindow::get_plugin_path(char *path, const char *plug_dir, const char *fs_p
        delete [] base_path;
 }
 
-int MWindow::load_plugin_index(MWindow *mwindow, const char *index_path, const char *plugin_dir)
+int MWindow::load_plugin_index(MWindow *mwindow, FILE *fp, const char *plugin_dir)
 {
-// load index
-       FILE *fp = fopen(index_path, "r");
        if( !fp ) return -1;
-
+// load index
+       fseek(fp, 0, SEEK_SET);
        int ret = 0;
        char index_line[BCTEXTLEN];
        int index_version = -1, len = strlen(plugin_dir);
@@ -576,7 +576,6 @@ int MWindow::load_plugin_index(MWindow *mwindow, const char *index_path, const c
                        ret = 1;  continue;
                }
        }
-       fclose(fp);
 
        if( !ret )
                ret = check_plugin_index(plugins, plugin_dir, ".");
@@ -623,21 +622,36 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
        create_defaults_path(index_path, PLUGIN_FILE);
        char *plugin_dir = FileSystem::basepath(preferences->plugin_dir);
        strcpy(plugin_path, plugin_dir);  delete [] plugin_dir;
-       if( !load_plugin_index(mwindow, index_path, plugin_path) ) return 1;
-       printf("init plugin index: %s\n", plugin_path);
-       FILE *fp = fopen(index_path,"w");
+       FILE *fp = fopen(index_path,"a+");
        if( !fp ) {
                fprintf(stderr,_("MWindow::init_plugins: "
-                       "can't create plugin index: %s\n"), index_path);
-               return 1;
+                       "can't open plugin index: %s\n"), index_path);
+               return -1;
+       }
+       int fd = fileno(fp), ret = -1;
+       if( !flock(fd, LOCK_EX) ) {
+               fseek(fp, 0, SEEK_SET);
+               ret = load_plugin_index(mwindow, fp, plugin_path);
+       }
+       if( ret > 0 ) {
+               ftruncate(fd, 0);
+               fseek(fp, 0, SEEK_SET);
+               printf("init plugin index: %s\n", plugin_path);
+               fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
+               fprintf(fp, "%s\n", plugin_path);
+               init_plugin_index(mwindow, preferences, fp, plugin_path);
+               init_ffmpeg_index(mwindow, preferences, fp);
+               init_lv2_index(mwindow, preferences, fp);
+               fseek(fp, 0, SEEK_SET);
+               ret = load_plugin_index(mwindow, fp, plugin_path);
+       }
+       if( ret ) {
+               fprintf(stderr,_("MWindow::init_plugins: "
+                       "can't %s plugin index: %s\n"),
+                       ret>0 ? _("create") : _("lock"), index_path);
        }
-       fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
-       fprintf(fp, "%s\n", plugin_path);
-       init_plugin_index(mwindow, preferences, fp, plugin_path);
-       init_ffmpeg_index(mwindow, preferences, fp);
-       init_lv2_index(mwindow, preferences, fp);
        fclose(fp);
-       return load_plugin_index(mwindow, index_path, plugin_path);
+       return ret;
 }
 
 int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
@@ -661,9 +675,30 @@ int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
                for( char *bp=plugin_path; *bp!=0; ++bp )
                        *cp++ = *bp=='/' ? '_' : *bp;
                *cp = 0;
-               if( !load_plugin_index(mwindow, index_path, plugin_path) ) continue;
-               if( init_ladspa_index(mwindow, preferences, index_path, plugin_path) ) continue;
-               load_plugin_index(mwindow, index_path, plugin_path);
+               FILE *fp = fopen(index_path,"a+");
+               if( !fp ) {
+                       fprintf(stderr,_("MWindow::init_ladspa_plugins: "
+                               "can't open ladspa plugin index: %s\n"), index_path);
+                       continue;
+               }
+               int fd = fileno(fp), ret = -1;
+               if( !flock(fd, LOCK_EX) ) {
+                       fseek(fp, 0, SEEK_SET);
+                       ret = load_plugin_index(mwindow, fp, plugin_path);
+               }
+               if( ret > 0 ) {
+                       ftruncate(fd, 0);
+                       fseek(fp, 0, SEEK_SET);
+                       init_ladspa_index(mwindow, preferences, fp, plugin_path);
+                       fseek(fp, 0, SEEK_SET);
+                       ret = load_plugin_index(mwindow, fp, plugin_path);
+               }
+               if( ret ) {
+                       fprintf(stderr,_("MWindow::init_ladspa_plugins: "
+                               "can't %s ladspa plugin index: %s\n"),
+                               ret>0 ? _("create") : _("lock"), index_path);
+               }
+               fclose(fp);
        }
        return 1;
 }
index b974486145b5667148ee6521b37f69c6e09f47cc..2ec3068359830bff038cce0efe932f07e647bc25 100644 (file)
@@ -683,13 +683,12 @@ public:
        static void init_plugin_index(MWindow *mwindow, Preferences *preferences,
                FILE *fp, const char *plugin_dir);
        static int init_ladspa_index(MWindow *mwindow, Preferences *preferences,
-               const char *index_path, const char *plugin_dir);
+               FILE *fp, const char *plugin_dir);
        static void scan_plugin_index(MWindow *mwindow, Preferences *preferences,
                FILE *fp, const char *plug_dir, const char *plug_path, int &idx);
        static void init_ffmpeg();
        static void init_ffmpeg_index(MWindow *mwindow, Preferences *preferences, FILE *fp);
-       static int load_plugin_index(MWindow *mwindow, const char *index_path,
-               const char *plugin_dir);
+       static int load_plugin_index(MWindow *mwindow, FILE *fp, const char *plugin_dir);
        static PluginServer *new_ffmpeg_server(MWindow *mwindow, const char *name);
        static int init_lv2_index(MWindow *mwindow, Preferences *preferences, FILE *fp);
        static PluginServer *new_lv2_server(MWindow *mwindow, const char *name);
index e2f552042cf5b6f2a97645de05da41f25765dd9b..306975c202090a344f787ecc1ff5e8b17a9fd64f 100644 (file)
@@ -2248,6 +2248,11 @@ void MWindow::delete_folder(char *folder)
 
 void MWindow::select_point(double position)
 {
+       gui->unlock_window();
+       gui->stop_drawing();
+       cwindow->stop_playback(0);
+       gui->lock_window("MWindow::select_point");
+
        edl->local_session->set_selectionstart(position);
        edl->local_session->set_selectionend(position);
 
index 403ec7a874b0766935bd50a94b0287de3059dc50..f1cbb45a317fa4dd82fa4fdb1cb655484878aa19 100644 (file)
@@ -655,21 +655,14 @@ int PluginAClientLAD::process_realtime(int64_t size,
 }
 
 int MWindow::init_ladspa_index(MWindow *mwindow, Preferences *preferences,
-       const char *index_path, const char *plugin_dir)
+       FILE *fp, const char *plugin_dir)
 {
        char plugin_path[BCTEXTLEN], *path = FileSystem::basepath(plugin_dir);
        strcpy(plugin_path, path);  delete [] path;
        printf("init ladspa index: %s\n", plugin_dir);
-       FILE *fp = fopen(index_path,"w");
-       if( !fp ) {
-               fprintf(stderr,_("MWindow::init_ladspa_index: "
-                       "can't create plugin index: %s\n"), index_path);
-               return 1;
-       }
        fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
        fprintf(fp, "%s\n", plugin_dir);
        init_plugin_index(mwindow, preferences, fp, plugin_path);
-       fclose(fp);
        return 0;
 }
 
index 98858289849a63660bd850ae3388a57057613851..5a63955aed36777230843c54bbadbc19e33d8952 100644 (file)
@@ -77,26 +77,20 @@ void VWindow::delete_source(int do_main_edl, int update_gui)
 //printf("VWindow::delete_source %d %d %p %p\n", __LINE__, gui->get_window_lock(), edl, indexable);
        if(do_main_edl) mwindow->edl->remove_vwindow_edl(get_edl());
 
-       if(edl)
-       {
+       if( edl ) {
                edl->Garbage::remove_user();
-//printf("VWindow::delete_source %d\n", __LINE__);
                edl = 0;
        }
 
-//     if(mwindow->edl->vwindow_edl && !mwindow->edl->vwindow_edl_shared)
-//     {
-//             mwindow->edl->vwindow_edl->Garbage::remove_user();
-//             mwindow->edl->vwindow_edl = 0;
-//             mwindow->edl->vwindow_edl_shared = 0;
-//     }
-
-//printf("VWindow::delete_source %d\n", __LINE__);
-       if(indexable) indexable->Garbage::remove_user();
-       indexable = 0;
+       if( indexable ) {
+               indexable->Garbage::remove_user();
+               indexable = 0;
+       }
 
-       if(update_gui) gui->change_source(0, _("Viewer"));
-//printf("VWindow::delete_source %d\n", __LINE__);
+       if( update_gui ) {
+               gui->change_source(0, _("Viewer"));
+               gui->clock->clear();
+       }
 }
 
 
index dad466496992b139bb38e39f8fa05e614312787d..1489f5bed9543f72270f4fa0ff21dca1780215a0 100644 (file)
@@ -26,7 +26,7 @@
 #include "bcsynchronous.h"
 #include "bcwindowbase.h"
 #include "vframe.h"
-
+#include "workarounds.h"
 
 #include <unistd.h>
 
@@ -126,7 +126,7 @@ BC_Pixmap::~BC_Pixmap()
        {
 #ifdef HAVE_XFT
                if(opaque_xft_draw)
-                       XftDrawDestroy((XftDraw*)opaque_xft_draw);
+                       xftDrawDestroy((XftDraw*)opaque_xft_draw);
 #endif
                XFreePixmap(top_level->display, opaque_pixmap);
        }
@@ -136,7 +136,7 @@ BC_Pixmap::~BC_Pixmap()
                XFreeGC(top_level->display, alpha_gc);
 #ifdef HAVE_XFT
                if(alpha_xft_draw)
-                       XftDrawDestroy((XftDraw*)alpha_xft_draw);
+                       xftDrawDestroy((XftDraw*)alpha_xft_draw);
 #endif
                XFreePixmap(top_level->display, alpha_pixmap);
        }
@@ -187,7 +187,7 @@ int BC_Pixmap::initialize(BC_WindowBase *parent_window, int w, int h, int mode)
 #ifdef HAVE_XFT
                if(BC_WindowBase::get_resources()->use_xft)
                {
-                       opaque_xft_draw = XftDrawCreate(top_level->display,
+                       opaque_xft_draw = xftDrawCreate(top_level->display,
                           opaque_pixmap,
                           top_level->vis,
                           top_level->cmap);
@@ -226,7 +226,7 @@ int BC_Pixmap::initialize(BC_WindowBase *parent_window, int w, int h, int mode)
 #ifdef HAVE_XFT
                if(BC_WindowBase::get_resources()->use_xft)
                {
-                       alpha_xft_draw = XftDrawCreateBitmap(top_level->display,
+                       alpha_xft_draw = xftDrawCreateBitmap(top_level->display,
                                alpha_pixmap);
                }
 #endif
@@ -253,7 +253,7 @@ void BC_Pixmap::resize(int w, int h)
 #ifdef HAVE_XFT
        XftDraw *new_xft_draw = 0;
        if(BC_WindowBase::get_resources()->use_xft) {
-               new_xft_draw = XftDrawCreate(top_level->display,
+               new_xft_draw = xftDrawCreate(top_level->display,
                       new_pixmap,
                       top_level->vis,
                       top_level->cmap);
@@ -277,7 +277,7 @@ void BC_Pixmap::resize(int w, int h)
        this->h = h;
 #ifdef HAVE_XFT
        if(BC_WindowBase::get_resources()->use_xft)
-               XftDrawDestroy((XftDraw*)opaque_xft_draw);
+               xftDrawDestroy((XftDraw*)opaque_xft_draw);
 #endif
        XFreePixmap(top_level->display, opaque_pixmap);
 
index 1e92730379e96aae5b810ab70134a23607208bac..43343ca27a6fd81551e8cc0b3765269cb8bde4d5 100644 (file)
@@ -33,6 +33,7 @@
 #include "fonts.h"
 #include "language.h"
 #include "vframe.h"
+#include "workarounds.h"
 
 #include <string.h>
 #include <iconv.h>
@@ -382,7 +383,7 @@ BC_Resources::BC_Resources()
                filebox_history[i].path[0] = 0;
 
 #ifdef HAVE_XFT
-       XftInitFtLibrary();
+       xftInitFtLibrary();
 #endif
 
        little_endian = (*(const u_int32_t*)"\01\0\0\0") & 1;
@@ -1041,7 +1042,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
 
        FT_Library freetype_library = 0;
 //     FT_Face freetype_face = 0;
-//     FT_Init_FreeType(&freetype_library);
+//     ft_Init_FreeType(&freetype_library);
 
        char line[BCTEXTLEN], current_dir[BCTEXTLEN];
        current_dir[0] = 0;
@@ -1203,15 +1204,15 @@ int BC_Resources::init_fontconfig(const char *search_path)
        FcConfig *config;
        int i;
        char tmpstring[BCTEXTLEN];
-       if(!FcInit())
+       if(!fcInit())
                return 1;
-       config = FcConfigGetCurrent();
-       FcConfigSetRescanInterval(config, 0);
+       config = fcConfigGetCurrent();
+       fcConfigSetRescanInterval(config, 0);
 
-       pat = FcPatternCreate();
-       os = FcObjectSetBuild ( FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT,
+       pat = fcPatternCreate();
+       os = fcObjectSetBuild( FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT,
                FC_WIDTH, FC_SLANT, FC_FONTFORMAT, FC_SPACING, FC_STYLE, (char *) 0);
-       FcPatternAddBool(pat, FC_SCALABLE, true);
+       fcPatternAddBool(pat, FC_SCALABLE, true);
 
        if(language[0]) {
                char langstr[LEN_LANG * 3];
@@ -1222,35 +1223,35 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        strcat(langstr, region);
                }
 
-               FcLangSet *ls =  FcLangSetCreate();
-               if(FcLangSetAdd(ls, (const FcChar8*)langstr))
-               if(FcPatternAddLangSet(pat, FC_LANG, ls))
-               FcLangSetDestroy(ls);
+               FcLangSet *ls =  fcLangSetCreate();
+               if(fcLangSetAdd(ls, (const FcChar8*)langstr))
+               if(fcPatternAddLangSet(pat, FC_LANG, ls))
+               fcLangSetDestroy(ls);
        }
 
-       fs = FcFontList(config, pat, os);
-       FcPatternDestroy(pat);
-       FcObjectSetDestroy(os);
+       fs = fcFontList(config, pat, os);
+       fcPatternDestroy(pat);
+       fcObjectSetDestroy(os);
 
        for (i = 0; fs && i < fs->nfont; i++) {
                FcPattern *font = fs->fonts[i];
                force_style = 0;
-               FcPatternGetString(font, FC_FONTFORMAT, 0, &format);
+               fcPatternGetString(font, FC_FONTFORMAT, 0, &format);
                //on this point you can limit font search
                if(limit_to_trutype && strcmp((char *)format, "TrueType"))
                        continue;
 
                sprintf(tmpstring, "%s", format);
                BC_FontEntry *entry = new BC_FontEntry;
-               if(FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
+               if(fcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
                        entry->path = cstrdup((char*)file);
                }
 
-               if(FcPatternGetString(font, FC_FOUNDRY, 0, &foundry) == FcResultMatch) {
+               if(fcPatternGetString(font, FC_FOUNDRY, 0, &foundry) == FcResultMatch) {
                        entry->foundry = cstrdup((char*)foundry);
                }
 
-               if(FcPatternGetInteger(font, FC_WEIGHT, 0, &weight) == FcResultMatch) {
+               if(fcPatternGetInteger(font, FC_WEIGHT, 0, &weight) == FcResultMatch) {
                        switch(weight) {
                        case FC_WEIGHT_THIN:
                        case FC_WEIGHT_EXTRALIGHT:
@@ -1282,10 +1283,10 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        }
                }
 
-               if(FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch)
+               if(fcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch)
                        entry->family = cstrdup((char*)family);
 
-               if(FcPatternGetInteger(font, FC_SLANT, 0, &slant) == FcResultMatch) {
+               if(fcPatternGetInteger(font, FC_SLANT, 0, &slant) == FcResultMatch) {
                        switch(slant) {
                        case FC_SLANT_ROMAN:
                        default:
@@ -1305,7 +1306,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        }
                }
 
-               if(FcPatternGetInteger(font, FC_WIDTH, 0, &width) == FcResultMatch) {
+               if(fcPatternGetInteger(font, FC_WIDTH, 0, &width) == FcResultMatch) {
                        switch(width) {
                        case FC_WIDTH_ULTRACONDENSED:
                                entry->swidth = cstrdup("ultracondensed");
@@ -1345,7 +1346,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        }
                }
 
-               if(FcPatternGetInteger(font, FC_SPACING, 0, &spacing) == FcResultMatch) {
+               if(fcPatternGetInteger(font, FC_SPACING, 0, &spacing) == FcResultMatch) {
                        switch(spacing) {
                        case 0:
                        default:
@@ -1376,7 +1377,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
                entry->registry = cstrdup("utf");
                entry->encoding = cstrdup("8");
 
-               if( FcPatternGetString(font, FC_STYLE, 0, &style) != FcResultMatch )
+               if( fcPatternGetString(font, FC_STYLE, 0, &style) != FcResultMatch )
                        force_style = 0;
 
                // If font has a style unmanaged by titler plugin, force style to be displayed on name
@@ -1401,19 +1402,19 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        dump_font_entry(stdout, "font 1: ", entry);
        }
 
-       FcFontSetDestroy(fs);
+       fcFontSetDestroy(fs);
        if(freetype_library)
-               FT_Done_FreeType(freetype_library);
+               ft_Done_FreeType(freetype_library);
 // for(int i = 0; i < fonts->total; i++)
 //     fonts->values[i]->dump();
 
-       FcConfigAppFontAddDir(0, (const FcChar8*)search_path);
-       FcConfigSetRescanInterval(0, 0);
+       fcConfigAppFontAddDir(0, (const FcChar8*)search_path);
+       fcConfigSetRescanInterval(0, 0);
 
-       os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT,
+       os = fcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT,
                FC_WIDTH, FC_SLANT, FC_SPACING, FC_STYLE, (char *)0);
-       pat = FcPatternCreate();
-       FcPatternAddBool(pat, FC_SCALABLE, true);
+       pat = fcPatternCreate();
+       fcPatternAddBool(pat, FC_SCALABLE, true);
 
        if(language[0])
        {
@@ -1426,15 +1427,15 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        strcat(langstr, region);
                }
 
-               FcLangSet *ls =  FcLangSetCreate();
-               if(FcLangSetAdd(ls, (const FcChar8*)langstr))
-                       if(FcPatternAddLangSet(pat, FC_LANG, ls))
-               FcLangSetDestroy(ls);
+               FcLangSet *ls =  fcLangSetCreate();
+               if(fcLangSetAdd(ls, (const FcChar8*)langstr))
+                       if(fcPatternAddLangSet(pat, FC_LANG, ls))
+               fcLangSetDestroy(ls);
        }
 
-       fs = FcFontList(0, pat, os);
-       FcPatternDestroy(pat);
-       FcObjectSetDestroy(os);
+       fs = fcFontList(0, pat, os);
+       fcPatternDestroy(pat);
+       fcObjectSetDestroy(os);
 
        for(int i = 0; i < fs->nfont; i++)
        {
@@ -1442,26 +1443,26 @@ int BC_Resources::init_fontconfig(const char *search_path)
                BC_FontEntry *entry = new BC_FontEntry;
 
                FcChar8 *strvalue;
-               if(FcPatternGetString(font, FC_FILE, 0, &strvalue) == FcResultMatch)
+               if(fcPatternGetString(font, FC_FILE, 0, &strvalue) == FcResultMatch)
                {
                        entry->path = new char[strlen((char*)strvalue) + 1];
                        strcpy(entry->path, (char*)strvalue);
                }
 
-               if(FcPatternGetString(font, FC_FOUNDRY, 0, &strvalue) == FcResultMatch)
+               if(fcPatternGetString(font, FC_FOUNDRY, 0, &strvalue) == FcResultMatch)
                {
                        entry->foundry = new char[strlen((char*)strvalue) + 1];
                        strcpy(entry->foundry, (char *)strvalue);
                }
 
-               if(FcPatternGetString(font, FC_FAMILY, 0, &strvalue) == FcResultMatch)
+               if(fcPatternGetString(font, FC_FAMILY, 0, &strvalue) == FcResultMatch)
                {
                        entry->family = new char[strlen((char*)strvalue) + 2];
                        strcpy(entry->family, (char*)strvalue);
                }
 
                int intvalue;
-               if(FcPatternGetInteger(font, FC_SLANT, 0, &intvalue) == FcResultMatch)
+               if(fcPatternGetInteger(font, FC_SLANT, 0, &intvalue) == FcResultMatch)
                {
                        switch(intvalue)
                        {
@@ -1480,7 +1481,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        }
                }
 
-               if(FcPatternGetInteger(font, FC_WEIGHT, 0, &intvalue) == FcResultMatch)
+               if(fcPatternGetInteger(font, FC_WEIGHT, 0, &intvalue) == FcResultMatch)
                {
                        switch(intvalue)
                        {
@@ -1531,7 +1532,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
                        }
                }
 
-               if(FcPatternGetInteger(font, FC_WIDTH, 0, &intvalue) == FcResultMatch)
+               if(fcPatternGetInteger(font, FC_WIDTH, 0, &intvalue) == FcResultMatch)
                {
                        switch(intvalue)
                        {
@@ -1573,7 +1574,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
                                break;
                        }
                }
-               if(FcPatternGetInteger(font, FC_SPACING, 0, &intvalue) == FcResultMatch)
+               if(fcPatternGetInteger(font, FC_SPACING, 0, &intvalue) == FcResultMatch)
                {
                        switch(intvalue)
                        {
@@ -1611,7 +1612,7 @@ int BC_Resources::init_fontconfig(const char *search_path)
                if( font_debug )
                        dump_font_entry(stdout, "font 2: ", entry);
        }
-       FcFontSetDestroy(fs);
+       fcFontSetDestroy(fs);
        return 0;
 }
 
@@ -1837,15 +1838,15 @@ int BC_Resources::find_font_by_char(FT_ULong char_code, char *path_new, const FT
        if(char_code < ' ')
                return 0;
 
-       if( (ofont = FcFreeTypeQueryFace(oldface, (const FcChar8*)"", 4097, 0)) != 0 ) {
+       if( (ofont = fcFreeTypeQueryFace(oldface, (const FcChar8*)"", 4097, 0)) != 0 ) {
                if( (font = find_similar_font(char_code, ofont)) != 0 ) {
-                       if(FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
+                       if(fcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
                                strcpy(path_new, (char*)file);
                                result = 1;
                        }
-                       FcPatternDestroy(font);
+                       fcPatternDestroy(font);
                }
-               FcPatternDestroy(ofont);
+               fcPatternDestroy(ofont);
        }
        return result;
 }
@@ -1863,43 +1864,43 @@ FcPattern* BC_Resources::find_similar_font(FT_ULong char_code, FcPattern *oldfon
                return 0;
 
        fontconfig_lock.lock("BC_Resources::find_similar_font");
-       pat = FcPatternCreate();
-       os = FcObjectSetBuild(FC_FILE, FC_CHARSET, FC_SCALABLE, FC_FAMILY,
+       pat = fcPatternCreate();
+       os = fcObjectSetBuild(FC_FILE, FC_CHARSET, FC_SCALABLE, FC_FAMILY,
                FC_SLANT, FC_WEIGHT, FC_WIDTH, (char *)0);
 
-       FcPatternAddBool(pat, FC_SCALABLE, true);
-       fcs = FcCharSetCreate();
-       if(FcCharSetAddChar(fcs, char_code))
-               FcPatternAddCharSet(pat, FC_CHARSET, fcs);
-       FcCharSetDestroy(fcs);
+       fcPatternAddBool(pat, FC_SCALABLE, true);
+       fcs = fcCharSetCreate();
+       if(fcCharSetAddChar(fcs, char_code))
+               fcPatternAddCharSet(pat, FC_CHARSET, fcs);
+       fcCharSetDestroy(fcs);
        for( int i=0; i<(int)LEN_FCPROP; ++i ) {
-               if(FcPatternGetInteger(oldfont, fc_properties[i], 0, &ival) == FcResultMatch)
-                       FcPatternAddInteger(pat, fc_properties[i], ival);
+               if(fcPatternGetInteger(oldfont, fc_properties[i], 0, &ival) == FcResultMatch)
+                       fcPatternAddInteger(pat, fc_properties[i], ival);
        }
-       fs = FcFontList(0, pat, os);
+       fs = fcFontList(0, pat, os);
        for( int i=LEN_FCPROP; --i>=0 && !fs->nfont; ) {
-               FcFontSetDestroy(fs);
-               FcPatternDel(pat, fc_properties[i]);
-               fs = FcFontList(0, pat, os);
+               fcFontSetDestroy(fs);
+               fcPatternDel(pat, fc_properties[i]);
+               fs = fcFontList(0, pat, os);
        }
-       FcPatternDestroy(pat);
-       FcObjectSetDestroy(os);
+       fcPatternDestroy(pat);
+       fcObjectSetDestroy(os);
 
        pat = 0;
 
        for (int i = 0; i < fs->nfont; i++)
        {
                font = fs->fonts[i];
-               if(FcPatternGetCharSet(font, FC_CHARSET, 0, &fcs) == FcResultMatch)
+               if(fcPatternGetCharSet(font, FC_CHARSET, 0, &fcs) == FcResultMatch)
                {
-                       if(FcCharSetHasChar(fcs, char_code))
+                       if(fcCharSetHasChar(fcs, char_code))
                        {
-                               pat =  FcPatternDuplicate(font);
+                               pat =  fcPatternDuplicate(font);
                                break;
                        }
                }
        }
-       FcFontSetDestroy(fs);
+       fcFontSetDestroy(fs);
        fontconfig_lock.unlock();
 
        return pat;
index a14c2eef960b4582b9e3836681c9f0b4e2020965..24dc5872e0e3ee426b504bffd009a9c305ede949 100644 (file)
@@ -46,6 +46,7 @@
 #include "mutex.h"
 #include "sizes.h"
 #include "vframe.h"
+#include "workarounds.h"
 
 #ifdef HAVE_GL
 #include <GL/gl.h>
@@ -197,7 +198,7 @@ BC_WindowBase::~BC_WindowBase()
                };
                for( int i=sizeof(xft_font)/sizeof(xft_font[0]); --i>=0; ) {
                        XftFont *xft = (XftFont *)(this->*xft_font[i]);
-                       if( xft ) XftFontClose (display, xft);
+                       if( xft ) xftFontClose (display, xft);
                }
 #endif
                finit_im();
@@ -2365,54 +2366,54 @@ static Mutex xft_init_lock("BC_WindowBase::xft_init_lock", 0);
 xft_init_lock.lock("BC_WindowBase::init_xft");
        if(!(smallfont_xft =
                (resources.small_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.small_font_xft) :
-                       XftFontOpenName(display, screen, resources.small_font_xft))) )
+                       xftFontOpenXlfd(display, screen, resources.small_font_xft) :
+                       xftFontOpenName(display, screen, resources.small_font_xft))) )
                if(!(smallfont_xft =
-                       XftFontOpenXlfd(display, screen, resources.small_font_xft2)))
-                       smallfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.small_font_xft2)))
+                       smallfont_xft = xftFontOpenXlfd(display, screen, "fixed");
        if(!(mediumfont_xft =
                (resources.medium_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.medium_font_xft) :
-                       XftFontOpenName(display, screen, resources.medium_font_xft))) )
+                       xftFontOpenXlfd(display, screen, resources.medium_font_xft) :
+                       xftFontOpenName(display, screen, resources.medium_font_xft))) )
                if(!(mediumfont_xft =
-                       XftFontOpenXlfd(display, screen, resources.medium_font_xft2)))
-                       mediumfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.medium_font_xft2)))
+                       mediumfont_xft = xftFontOpenXlfd(display, screen, "fixed");
        if(!(largefont_xft =
                (resources.large_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.large_font_xft) :
-                       XftFontOpenName(display, screen, resources.large_font_xft))) )
+                       xftFontOpenXlfd(display, screen, resources.large_font_xft) :
+                       xftFontOpenName(display, screen, resources.large_font_xft))) )
                if(!(largefont_xft =
-                       XftFontOpenXlfd(display, screen, resources.large_font_xft2)))
-                       largefont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.large_font_xft2)))
+                       largefont_xft = xftFontOpenXlfd(display, screen, "fixed");
        if(!(bigfont_xft =
                (resources.big_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.big_font_xft) :
-                       XftFontOpenName(display, screen, resources.big_font_xft))) )
+                       xftFontOpenXlfd(display, screen, resources.big_font_xft) :
+                       xftFontOpenName(display, screen, resources.big_font_xft))) )
                if(!(bigfont_xft =
-                       XftFontOpenXlfd(display, screen, resources.big_font_xft2)))
-                       bigfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.big_font_xft2)))
+                       bigfont_xft = xftFontOpenXlfd(display, screen, "fixed");
        if(!(clockfont_xft =
                (resources.clock_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.clock_font_xft) :
-                       XftFontOpenName(display, screen, resources.clock_font_xft))) )
-               clockfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.clock_font_xft) :
+                       xftFontOpenName(display, screen, resources.clock_font_xft))) )
+               clockfont_xft = xftFontOpenXlfd(display, screen, "fixed");
 
 
        if(!(bold_smallfont_xft =
                (resources.small_b_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.small_b_font_xft) :
-                       XftFontOpenName(display, screen, resources.small_b_font_xft))) )
-               bold_smallfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.small_b_font_xft) :
+                       xftFontOpenName(display, screen, resources.small_b_font_xft))) )
+               bold_smallfont_xft = xftFontOpenXlfd(display, screen, "fixed");
        if(!(bold_mediumfont_xft =
                (resources.medium_b_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.medium_b_font_xft) :
-                       XftFontOpenName(display, screen, resources.medium_b_font_xft))) )
-               bold_mediumfont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.medium_b_font_xft) :
+                       xftFontOpenName(display, screen, resources.medium_b_font_xft))) )
+               bold_mediumfont_xft = xftFontOpenXlfd(display, screen, "fixed");
        if(!(bold_largefont_xft =
                (resources.large_b_font_xft[0] == '-' ?
-                       XftFontOpenXlfd(display, screen, resources.large_b_font_xft) :
-                       XftFontOpenName(display, screen, resources.large_b_font_xft))) )
-               bold_largefont_xft = XftFontOpenXlfd(display, screen, "fixed");
+                       xftFontOpenXlfd(display, screen, resources.large_b_font_xft) :
+                       xftFontOpenName(display, screen, resources.large_b_font_xft))) )
+               bold_largefont_xft = xftFontOpenXlfd(display, screen, "fixed");
 
        if( !smallfont_xft || !mediumfont_xft || !largefont_xft || !bigfont_xft ||
            !bold_largefont_xft || !bold_mediumfont_xft || !bold_largefont_xft ||
@@ -2431,7 +2432,7 @@ xft_init_lock.lock("BC_WindowBase::init_xft");
                exit(1);
        }
 // _XftDisplayInfo needs a lock.
-       XftDefaultHasRender(display);
+       xftDefaultHasRender(display);
 xft_init_lock.unlock();
 #endif // HAVE_XFT
 }
@@ -2884,7 +2885,7 @@ int BC_WindowBase::get_single_text_width(int font, const char *text, int length)
 #ifdef X_HAVE_UTF8_STRING
                if(get_resources()->locale_utf8)
                {
-                       XftTextExtentsUtf8(top_level->display,
+                       xftTextExtentsUtf8(top_level->display,
                                get_xft_struct(font),
                                (const XftChar8 *)text,
                                length,
@@ -2893,7 +2894,7 @@ int BC_WindowBase::get_single_text_width(int font, const char *text, int length)
                else
 #endif
                {
-                       XftTextExtents8(top_level->display,
+                       xftTextExtents8(top_level->display,
                                get_xft_struct(font),
                                (const XftChar8 *)text,
                                length,
index 6a8412dedc0c06c6a5afcdbdfc19b1fc02ae8ced..5f0bb48cb1a5e2b45ff1da0a40712dd861a05551 100644 (file)
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <wchar.h>
 #include <ft2build.h>
+#include "workarounds.h"
 
 void BC_WindowBase::copy_area(int x1, int y1, int x2, int y2, int w, int h, BC_Pixmap *pixmap)
 {
@@ -259,25 +260,25 @@ void BC_WindowBase::xft_draw_string(XftColor *xft_color, XftFont *xft_font,
        if( values.function != GXcopy ) {
                XSetFunction(top_level->display, top_level->gc, GXcopy);
                XGlyphInfo info;
-               XftTextExtents32(top_level->display, xft_font, fc, len, &info);
+               xftTextExtents32(top_level->display, xft_font, fc, len, &info);
                src_w = info.width;  src_h = info.height;
                draw_pixmap = XCreatePixmap(top_level->display, top_level->win,
                         src_w, src_h, top_level->default_depth);
                int color = get_color(); set_color(0);
                XFillRectangle(top_level->display, draw_pixmap, top_level->gc, 0, 0, src_w, src_h);
                set_color(color);
-               xft_draw = XftDrawCreate(top_level->display, draw_pixmap,
+               xft_draw = xftDrawCreate(top_level->display, draw_pixmap,
                            top_level->vis, top_level->cmap);
                src_x = info.x;  src_y = info.y;
        }
-       XftDrawString32(xft_draw, xft_color, xft_font, src_x, src_y, fc, len);
+       xftDrawString32(xft_draw, xft_color, xft_font, src_x, src_y, fc, len);
        if( values.function != GXcopy ) {
                XSetFunction(top_level->display, top_level->gc, values.function);
                Pixmap xpixmap = pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap;
                XCopyArea(top_level->display, draw_pixmap, xpixmap,
                         top_level->gc, 0, 0, src_w, src_h, x, y);
                XFreePixmap(top_level->display, draw_pixmap);
-               XftDrawDestroy(xft_draw);
+               xftDrawDestroy(xft_draw);
        }
 }
 
@@ -320,7 +321,7 @@ int BC_WindowBase::draw_single_text(int draw, int font,
                color.blue |= color.blue << 8;
                color.alpha = 0xffff;
 
-               XftColorAllocValue(top_level->display, top_level->vis, top_level->cmap,
+               xftColorAllocValue(top_level->display, top_level->vis, top_level->cmap,
                        &color, &xft_color);
        }
 
@@ -331,13 +332,13 @@ int BC_WindowBase::draw_single_text(int draw, int font,
 
        while( up < uep ) {
                XftFont *xft_font = 0;
-               if( XftCharExists(top_level->display, basefont, *up) )
+               if( xftCharExists(top_level->display, basefont, *up) )
                        xft_font = basefont;
                else if( altfont ) {
-                       if( XftCharExists(top_level->display, altfont, *up))
+                       if( xftCharExists(top_level->display, altfont, *up))
                                xft_font = altfont;
                        else {
-                               XftFontClose(top_level->display, altfont);
+                               xftFontClose(top_level->display, altfont);
                                altfont = 0;
                        }
                }
@@ -345,10 +346,10 @@ int BC_WindowBase::draw_single_text(int draw, int font,
                        FcPattern *pattern = BC_Resources::find_similar_font(*up, basefont->pattern);
                        if( pattern != 0 ) {
                                double psize = 0;
-                               FcPatternGetDouble(basefont->pattern, FC_PIXEL_SIZE, 0, &psize);
-                               FcPatternAddDouble(pattern, FC_PIXEL_SIZE, psize);
-                               FcPatternDel(pattern, FC_SCALABLE);
-                               xft_font = altfont = XftFontOpenPattern(top_level->display, pattern);
+                               fcPatternGetDouble(basefont->pattern, FC_PIXEL_SIZE, 0, &psize);
+                               fcPatternAddDouble(pattern, FC_PIXEL_SIZE, psize);
+                               fcPatternDel(pattern, FC_SCALABLE);
+                               xft_font = altfont = xftFontOpenPattern(top_level->display, pattern);
                        }
                }
                if( !xft_font )
@@ -360,7 +361,7 @@ int BC_WindowBase::draw_single_text(int draw, int font,
                                                (const FcChar32*)ubp, up-ubp, pixmap);
                                }
                                XGlyphInfo extents;
-                               XftTextExtents32(top_level->display, curfont,
+                               xftTextExtents32(top_level->display, curfont,
                                        (const FcChar32*)ubp, up-ubp, &extents);
                                x += extents.xOff;
                        }
@@ -375,15 +376,15 @@ int BC_WindowBase::draw_single_text(int draw, int font,
                                (const FcChar32*)ubp, up-ubp, pixmap);
                }
                XGlyphInfo extents;
-               XftTextExtents32(top_level->display, curfont,
+               xftTextExtents32(top_level->display, curfont,
                        (const FcChar32*)ubp, up-ubp, &extents);
                x += extents.xOff;
        }
 
        if( altfont )
-               XftFontClose(top_level->display, altfont);
+               xftFontClose(top_level->display, altfont);
 
-       XftColorFree(top_level->display, top_level->vis, top_level->cmap, &xft_color);
+       xftColorFree(top_level->display, top_level->vis, top_level->cmap, &xft_color);
 #endif
        return x - x0;
 }
index 0a847113f9d505798867cd9409c694805a680dcf..652cde30e34a322b8f21c806e0b87cee9ca0c453 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "clip.h"
+#include "mutex.h"
 #include <math.h>
 #include "workarounds.h"
 
@@ -72,3 +73,546 @@ float Workarounds::pow(float x, float y)
        return powf(x, y);
 }
 
+#ifdef HAVE_XFT
+// not thread safe
+static Mutex xft_lock("xft_lock");
+
+FcBool xftInitFtLibrary(void)
+{
+       xft_lock.lock("xftInitFtLibrary");
+       FcBool ret = XftInitFtLibrary();
+       xft_lock.unlock();
+       return ret;
+}
+
+Bool xftDefaultHasRender(Display *dpy)
+{
+       xft_lock.lock("xftDefaultHasRender");
+       Bool ret = XftDefaultHasRender(dpy);
+       xft_lock.unlock();
+       return ret;
+}
+
+FcBool xftCharExists(Display *dpy, XftFont *pub, FcChar32 ucs4)
+{
+       xft_lock.lock("xftCharExists");
+       FcBool ret = XftCharExists(dpy, pub, ucs4);
+       xft_lock.unlock();
+       return ret;
+}
+
+void xftTextExtents8(Display *dpy, XftFont *pub,
+               _Xconst FcChar8 *string, int len, XGlyphInfo *extents)
+{
+       xft_lock.lock("xftTextExtents8");
+       XftTextExtents8(dpy, pub, string, len, extents);
+       xft_lock.unlock();
+}
+
+void xftTextExtentsUtf8(Display *dpy, XftFont *pub,
+               _Xconst FcChar8 *string, int len, XGlyphInfo *extents)
+{
+       xft_lock.lock("xftTextExtentsUtf8");
+       XftTextExtentsUtf8(dpy, pub, string, len, extents);
+       xft_lock.unlock();
+}
+
+void xftTextExtents32(Display *dpy, XftFont *pub,
+               _Xconst FcChar32 *string, int len, XGlyphInfo *extents)
+{
+       xft_lock.lock("xftTextExtents32");
+       XftTextExtents32(dpy, pub, string, len, extents);
+       xft_lock.unlock();
+}
+
+XftDraw *xftDrawCreate(Display *dpy, Drawable drawable, Visual *visual, Colormap colormap)
+{
+       xft_lock.lock("xftDrawCreate");
+       XftDraw *ret = XftDrawCreate(dpy, drawable, visual, colormap);
+       xft_lock.unlock();
+       return ret;
+}
+
+XftDraw *xftDrawCreateBitmap(Display  *dpy, Pixmap bitmap)
+{
+       xft_lock.lock("xftDrawCreateBitmap");
+       XftDraw *ret = XftDrawCreateBitmap(dpy, bitmap);
+       xft_lock.unlock();
+       return ret;
+}
+
+void xftDrawDestroy(XftDraw *draw)
+{
+       xft_lock.lock("xftDrawDestroy");
+       XftDrawDestroy(draw);
+       xft_lock.unlock();
+}
+
+void xftDrawString32(XftDraw *draw, _Xconst XftColor *color, XftFont *pub,
+               int x, int y, _Xconst FcChar32 *string, int len)
+{
+       xft_lock.lock("xftDrawString32");
+       XftDrawString32(draw, color, pub, x, y, string, len);
+       xft_lock.unlock();
+}
+
+Bool xftColorAllocValue(Display *dpy, Visual *visual,
+               Colormap cmap, _Xconst XRenderColor *color, XftColor *result)
+{
+       xft_lock.lock("xftColorAllocValue");
+       Bool ret = XftColorAllocValue(dpy, visual, cmap, color, result);
+       xft_lock.unlock();
+       return ret;
+}
+
+void xftColorFree(Display *dpy, Visual *visual, Colormap cmap, XftColor *color)
+{
+       xft_lock.lock("xftColorFree");
+       XftColorFree(dpy, visual, cmap, color);
+       xft_lock.unlock();
+}
+
+XftFont *xftFontOpenName(Display *dpy, int screen, _Xconst char *name)
+{
+       xft_lock.lock("xftFontOpenName");
+       XftFont *ret = XftFontOpenName(dpy, screen, name);
+       xft_lock.unlock();
+       return ret;
+}
+
+XftFont *xftFontOpenXlfd(Display *dpy, int screen, _Xconst char *xlfd)
+{
+       xft_lock.lock("xftFontOpenXlfd");
+       XftFont *ret = XftFontOpenXlfd(dpy, screen, xlfd);
+       xft_lock.unlock();
+       return ret;
+}
+
+XftFont *xftFontOpenPattern(Display *dpy, FcPattern *pattern)
+{
+       xft_lock.lock("xftFontOpenPattern");
+       XftFont *ret = XftFontOpenPattern(dpy, pattern);
+       xft_lock.unlock();
+       return ret;
+}
+
+void xftFontClose(Display *dpy, XftFont *pub)
+{
+       xft_lock.lock("xftFontClose");
+       XftFontClose(dpy, pub);
+       xft_lock.unlock();
+}
+
+
+static Mutex &ft_lock = xft_lock;
+
+FT_Error ft_Done_Face(FT_Face face)
+{
+       ft_lock.lock("ft_Done_Face");
+       FT_Error ret = FT_Done_Face(face);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Done_FreeType(FT_Library library)
+{
+       ft_lock.lock("ft_Done_FreeType");
+       FT_Error ret = FT_Done_FreeType(library);
+       ft_lock.unlock();
+       return ret;
+}
+
+void ft_Done_Glyph(FT_Glyph glyph)
+{
+       ft_lock.lock("ft_Done_Glyph");
+       FT_Done_Glyph(glyph);
+       ft_lock.unlock();
+}
+
+FT_UInt ft_Get_Char_Index(FT_Face face, FT_ULong charcode)
+{
+       ft_lock.lock("ft_Get_Char_Index");
+       FT_UInt ret = FT_Get_Char_Index(face, charcode);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Get_Glyph(FT_GlyphSlot  slot, FT_Glyph *aglyph)
+{
+       ft_lock.lock("ft_Get_Glyph");
+       FT_Error ret = FT_Get_Glyph(slot, aglyph);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning)
+{
+       ft_lock.lock("ft_Get_Kerning");
+       FT_Error ret = FT_Get_Kerning(face, left_glyph, right_glyph, kern_mode, akerning);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Init_FreeType(FT_Library *alibrary)
+{
+       ft_lock.lock("ft_Init_FreeType");
+       FT_Error ret = FT_Init_FreeType(alibrary);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Load_Char(FT_Face face, FT_ULong char_code, FT_Int32 load_flags)
+{
+       ft_lock.lock("ft_Load_Char");
+       FT_Error ret = FT_Load_Char(face, char_code, load_flags);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
+{
+       ft_lock.lock("ft_Load_Glyph");
+       FT_Error ret = FT_Load_Glyph(face, glyph_index, load_flags);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_New_Face(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface)
+{
+       ft_lock.lock("ft_New_Face");
+       FT_Error ret = FT_New_Face(library, filepathname, face_index, aface);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Outline_Done(FT_Library library, FT_Outline *outline)
+{
+       ft_lock.lock("ft_Outline_Done");
+       FT_Error ret = FT_Outline_Done(library, outline);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Outline_Get_BBox(FT_Outline *outline, FT_BBox *abbox)
+{
+       ft_lock.lock("ft_Outline_Get_BBox");
+       FT_Error ret = FT_Outline_Get_BBox(outline, abbox);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap  *abitmap)
+{
+       ft_lock.lock("ft_Outline_Get_Bitmap");
+       FT_Error ret = FT_Outline_Get_Bitmap(library, outline, abitmap);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
+{
+       ft_lock.lock("ft_Outline_New");
+       FT_Error ret = FT_Outline_New(library, numPoints, numContours, anoutline);
+       ft_lock.unlock();
+       return ret;
+}
+
+void ft_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
+{
+       ft_lock.lock("ft_Outline_Translate");
+       FT_Outline_Translate(outline, xOffset, yOffset);
+       ft_lock.unlock();
+}
+
+FT_Error ft_Select_Charmap(FT_Face face, FT_Encoding encoding)
+{
+       ft_lock.lock("ft_Select_Charmap");
+       FT_Error ret = FT_Select_Charmap(face, encoding);
+       ft_lock.unlock();
+       return ret;
+}
+FT_Error ft_Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height)
+{
+       ft_lock.lock("ft_Set_Pixel_Sizes");
+       FT_Error ret = FT_Set_Pixel_Sizes(face, pixel_width, pixel_height);
+       ft_lock.unlock();
+       return ret;
+}
+
+void ft_Stroker_Done(FT_Stroker stroker)
+{
+       ft_lock.lock("ft_Stroker_Done");
+       FT_Stroker_Done(stroker);
+       ft_lock.unlock();
+}
+
+void ft_Stroker_Export(FT_Stroker stroker, FT_Outline *outline)
+{
+       ft_lock.lock("ft_Stroker_Export");
+       FT_Stroker_Export(stroker, outline);
+       ft_lock.unlock();
+}
+
+FT_Error ft_Stroker_GetCounts(FT_Stroker stroker, FT_UInt *anum_points, FT_UInt *anum_contours)
+{
+       ft_lock.lock("ft_Stroker_GetCounts");
+       FT_Error ret = FT_Stroker_GetCounts(stroker, anum_points, anum_contours);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Stroker_New(FT_Library library, FT_Stroker  *astroker)
+{
+       ft_lock.lock("ft_Stroker_New");
+       FT_Error ret = FT_Stroker_New(library, astroker);
+       ft_lock.unlock();
+       return ret;
+}
+
+FT_Error ft_Stroker_ParseOutline(FT_Stroker stroker, FT_Outline *outline, FT_Bool opened)
+{
+       ft_lock.lock("ft_Stroker_ParseOutline");
+       FT_Error ret = FT_Stroker_ParseOutline(stroker, outline, opened);
+       ft_lock.unlock();
+       return ret;
+}
+
+void ft_Stroker_Set(FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap, FT_Stroker_LineJoin line_join, FT_Fixed miter_limit)
+{
+       ft_lock.lock("ft_Stroker_Set");
+       FT_Stroker_Set(stroker, radius, line_cap, line_join, miter_limit);
+       ft_lock.unlock();
+}
+
+
+static Mutex &fc_lock = xft_lock;
+
+FcBool fcCharSetAddChar(FcCharSet *fcs, FcChar32 ucs4)
+{
+       fc_lock.lock("fcCharSetAddChar");
+       FcBool ret = FcCharSetAddChar(fcs, ucs4);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcCharSet *fcCharSetCreate(void)
+{
+       fc_lock.lock("fcCharSetCreate");
+       FcCharSet *ret = FcCharSetCreate();
+       fc_lock.unlock();
+       return ret;
+}
+void fcCharSetDestroy(FcCharSet *fcs)
+{
+       fc_lock.lock("fcCharSetDestroy");
+       FcCharSetDestroy(fcs);
+       fc_lock.unlock();
+}
+
+FcBool fcCharSetHasChar(const FcCharSet *fcs, FcChar32 ucs4)
+{
+       fc_lock.lock("fcCharSetHasChar");
+       FcBool ret = FcCharSetHasChar(fcs, ucs4);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcConfigAppFontAddDir(FcConfig *config, const FcChar8 *dir)
+{
+       fc_lock.lock("fcConfigAppFontAddDir");
+       FcBool ret = FcConfigAppFontAddDir(config, dir);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcConfig *fcConfigGetCurrent()
+{
+       fc_lock.lock("fcConfigGetCurrent");
+       FcConfig *ret = FcConfigGetCurrent();
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcConfigSetRescanInterval(FcConfig *config, int rescanInterval)
+{
+       fc_lock.lock("fcConfigSetRescanInterval");
+       FcBool ret = FcConfigSetRescanInterval(config, rescanInterval);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcFontSet *fcFontList(FcConfig *config, FcPattern *p, FcObjectSet *os)
+{
+       fc_lock.lock("fcFontList");
+       FcFontSet *ret = FcFontList(config, p, os);
+       fc_lock.unlock();
+       return ret;
+}
+
+void fcFontSetDestroy(FcFontSet *s)
+{
+       fc_lock.lock("fcFontSetDestroy");
+       FcFontSetDestroy(s);
+       fc_lock.unlock();
+}
+
+FcPattern *fcFreeTypeQueryFace(const FT_Face face, const FcChar8 *file, unsigned int id, FcBlanks *blanks)
+{
+       fc_lock.lock("fcFreeTypeQueryFace");
+       FcPattern *ret = FcFreeTypeQueryFace(face, file, id, blanks);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcInit(void)
+{
+       fc_lock.lock("fcInit");
+       FcBool ret = FcInit();
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcLangSetAdd(FcLangSet *ls, const FcChar8 *lang)
+{
+       fc_lock.lock("fcLangSetAdd");
+       FcBool ret = FcLangSetAdd(ls, lang);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcLangSet *fcLangSetCreate(void)
+{
+       fc_lock.lock("fcLangSetCreate");
+       FcLangSet *ret = FcLangSetCreate();
+       fc_lock.unlock();
+       return ret;
+}
+
+void fcLangSetDestroy(FcLangSet *ls)
+{
+       fc_lock.lock("fcLangSetDestroy");
+       FcLangSetDestroy(ls);
+       fc_lock.unlock();
+}
+
+FcObjectSet *fcObjectSetBuild(const char *first, ...)
+{
+       fc_lock.lock("fcObjectSetBuild");
+       va_list va;  va_start(va, first);
+       FcObjectSet *ret = FcObjectSetVaBuild(first, va);
+       va_end(va);
+       fc_lock.unlock();
+       return ret;
+}
+
+void fcObjectSetDestroy(FcObjectSet *os)
+{
+       fc_lock.lock("fcObjectSetDestroy");
+       FcObjectSetDestroy(os);
+       fc_lock.unlock();
+}
+
+FcBool fcPatternAddBool(FcPattern *p, const char *object, FcBool b)
+{
+       fc_lock.lock("fcPatternAddBool");
+       FcBool ret = FcPatternAddBool(p, object, b);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcPatternAddCharSet(FcPattern *p, const char *object, const FcCharSet *c)
+{
+       fc_lock.lock("fcPatternAddCharSet");
+       FcBool ret = FcPatternAddCharSet(p, object, c);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcPatternAddDouble(FcPattern *p, const char *object, double d)
+{
+       fc_lock.lock("fcPatternAddDouble");
+       FcBool ret = FcPatternAddDouble(p, object, d);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcPatternAddInteger(FcPattern *p, const char *object, int i)
+{
+       fc_lock.lock("fcPatternAddInteger");
+       FcBool ret = FcPatternAddInteger(p, object, i);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcPatternAddLangSet(FcPattern *p, const char *object, const FcLangSet *ls)
+{
+       fc_lock.lock("fcPatternAddLangSet");
+       FcBool ret = FcPatternAddLangSet(p, object, ls);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcResult fcPatternGetInteger(const FcPattern *p, const char *object, int n, int *i)
+{
+       fc_lock.lock("fcPatternGetInteger");
+       FcResult ret = FcPatternGetInteger(p, object, n, i);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcResult fcPatternGetDouble (const FcPattern *p, const char *object, int n, double *d)
+{
+       fc_lock.lock("fcPatternGetDouble");
+       FcResult ret = FcPatternGetDouble(p, object, n, d);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcResult fcPatternGetString(const FcPattern *p, const char *object, int n, FcChar8 **s)
+{
+       fc_lock.lock("fcPatternGetString");
+       FcResult ret = FcPatternGetString(p, object, n, s);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcPattern *fcPatternCreate(void)
+{
+       fc_lock.lock("fcPatternCreate");
+       FcPattern *ret = FcPatternCreate();
+       fc_lock.unlock();
+       return ret;
+}
+
+FcBool fcPatternDel(FcPattern *p, const char *object)
+{
+       fc_lock.lock("fcPatternDel");
+       FcBool ret = FcPatternDel(p, object);
+       fc_lock.unlock();
+       return ret;
+}
+
+void fcPatternDestroy(FcPattern *p)
+{
+       fc_lock.lock("fcPatternDestroy ");
+       FcPatternDestroy(p);
+       fc_lock.unlock();
+}
+
+FcPattern *fcPatternDuplicate(const FcPattern *p)
+{
+       fc_lock.lock("fcPatternDuplicate");
+       FcPattern *ret = FcPatternDuplicate(p);
+       fc_lock.unlock();
+       return ret;
+}
+
+FcResult fcPatternGetCharSet(const FcPattern *p, const char *object, int n, FcCharSet **c)
+{
+       fc_lock.lock("fcPatternGetCharSet");
+       FcResult ret = FcPatternGetCharSet(p, object, n, c);
+       fc_lock.unlock();
+       return ret;
+}
+
+#endif
index 0a666337be302d4bcac7584338fae8b32b339cd8..d3a11004a5d64b9a5d5fe0675b778def493e8dae 100644 (file)
@@ -40,4 +40,102 @@ public:
        static float pow(float x, float y);
 };
 
+#ifdef HAVE_XFT
+// not thread safe
+
+#include <X11/Xft/Xft.h>
+#include "ft2build.h"
+#include FT_GLYPH_H
+#include FT_BBOX_H
+#include FT_OUTLINE_H
+#include FT_STROKER_H
+#include <fontconfig/fontconfig.h>
+#include <fontconfig/fcfreetype.h>
+
+FcBool xftInitFtLibrary(void);
+Bool xftDefaultHasRender(Display *dpy);
+FcBool xftCharExists(Display *dpy, XftFont *pub, FcChar32 ucs4);
+void xftTextExtents8(Display *dpy, XftFont *pub,
+               _Xconst FcChar8 *string, int len, XGlyphInfo *extents);
+void xftTextExtentsUtf8(Display *dpy, XftFont *pub,
+               _Xconst FcChar8 *string, int len, XGlyphInfo *extents);
+void xftTextExtents32(Display *dpy, XftFont *pub,
+               _Xconst FcChar32 *string, int len, XGlyphInfo *extents);
+XftDraw *xftDrawCreate(Display *dpy, Drawable drawable, Visual *visual,
+               Colormap colormap);
+XftDraw *xftDrawCreateBitmap(Display *dpy, Pixmap bitmap);
+void xftDrawDestroy(XftDraw *draw);
+void xftDrawString32(XftDraw *draw, _Xconst XftColor *color, XftFont *pub,
+               int x, int y, _Xconst FcChar32 *string, int len);
+Bool xftColorAllocValue(Display *dpy, Visual *visual,
+               Colormap cmap, _Xconst XRenderColor *color, XftColor *result);
+void xftColorFree(Display *dpy, Visual *visual, Colormap cmap, XftColor *color);
+XftFont *xftFontOpenName(Display *dpy, int screen, _Xconst char *name);
+XftFont *xftFontOpenXlfd(Display *dpy, int screen, _Xconst char *xlfd);
+XftFont *xftFontOpenPattern(Display *dpy, FcPattern *pattern);
+void xftFontClose(Display *dpy, XftFont *pub);
+
+FT_Error ft_Done_Face(FT_Face face);
+FT_Error ft_Done_FreeType(FT_Library library);
+void ft_Done_Glyph(FT_Glyph glyph);
+FT_UInt ft_Get_Char_Index(FT_Face face, FT_ULong charcode);
+FT_Error ft_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph);
+FT_Error ft_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph,
+               FT_UInt kern_mode, FT_Vector *akerning);
+FT_Error ft_Init_FreeType(FT_Library *alibrary);
+FT_Error ft_Load_Char(FT_Face face, FT_ULong char_code, FT_Int32 load_flags);
+FT_Error ft_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags);
+FT_Error ft_New_Face(FT_Library library, const char *filepathname, FT_Long face_index,
+               FT_Face *aface);
+FT_Error ft_Outline_Done(FT_Library library, FT_Outline *outline);
+FT_Error ft_Outline_Get_BBox(FT_Outline *outline, FT_BBox *abbox);
+FT_Error ft_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline,
+               const FT_Bitmap *abitmap);
+FT_Error ft_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours,
+               FT_Outline *anoutline);
+void ft_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset);
+FT_Error ft_Select_Charmap(FT_Face face, FT_Encoding encoding);
+FT_Error ft_Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height);
+void ft_Stroker_Done(FT_Stroker stroker);
+void ft_Stroker_Export(FT_Stroker stroker, FT_Outline *outline);
+FT_Error ft_Stroker_GetCounts(FT_Stroker stroker, FT_UInt *anum_points,
+               FT_UInt *anum_contours);
+FT_Error ft_Stroker_New(FT_Library library, FT_Stroker *astroker);
+FT_Error ft_Stroker_ParseOutline(FT_Stroker stroker, FT_Outline *outline,
+               FT_Bool opened);
+void ft_Stroker_Set(FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap,
+               FT_Stroker_LineJoin line_join, FT_Fixed miter_limit);
+
+FcBool fcCharSetAddChar(FcCharSet *fcs, FcChar32 ucs4);
+FcCharSet *fcCharSetCreate(void);
+void fcCharSetDestroy(FcCharSet *fcs);
+FcBool fcCharSetHasChar(const FcCharSet *fcs, FcChar32 ucs4);
+FcBool fcConfigAppFontAddDir(FcConfig *config, const FcChar8 *dir);
+FcConfig *fcConfigGetCurrent();
+FcBool fcConfigSetRescanInterval(FcConfig *config, int rescanInterval);
+FcFontSet *fcFontList(FcConfig *config, FcPattern *p, FcObjectSet *os);
+void fcFontSetDestroy(FcFontSet *s);
+FcPattern *fcFreeTypeQueryFace(const FT_Face face, const FcChar8 *file, unsigned int id,
+               FcBlanks *blanks);
+FcBool fcInit(void);
+FcBool fcLangSetAdd(FcLangSet *ls, const FcChar8 *lang);
+FcLangSet *fcLangSetCreate(void);
+void fcLangSetDestroy(FcLangSet *ls);
+FcObjectSet *fcObjectSetBuild(const char *first, ...);
+void fcObjectSetDestroy(FcObjectSet *os);
+FcBool fcPatternAddBool(FcPattern *p, const char *object, FcBool b);
+FcBool fcPatternAddCharSet(FcPattern *p, const char *object, const FcCharSet *c);
+FcBool fcPatternAddDouble(FcPattern *p, const char *object, double d);
+FcBool fcPatternAddInteger(FcPattern *p, const char *object, int i);
+FcBool fcPatternAddLangSet(FcPattern *p, const char *object, const FcLangSet *ls);
+FcResult fcPatternGetInteger(const FcPattern *p, const char *object, int n, int *i);
+FcResult fcPatternGetDouble(const FcPattern *p, const char *object, int n, double *d);
+FcResult fcPatternGetString(const FcPattern *p, const char *object, int n, FcChar8 **s);
+FcPattern *fcPatternCreate(void);
+FcBool fcPatternDel(FcPattern *p, const char *object);
+void fcPatternDestroy(FcPattern *p);
+FcPattern *fcPatternDuplicate(const FcPattern *p);
+FcResult fcPatternGetCharSet(const FcPattern *p, const char *object, int n,
+               FcCharSet **c);
+#endif
 #endif
index fefbbdb119c371a3e860ee45a72382f9c0836a1d..5d9f7cf25f8412601c4f3f0718b69aa0a5c46592 100644 (file)
@@ -51,7 +51,7 @@
 #include "titlerwindow.h"
 #include "transportque.h"
 #include "vrender.h"
-
+#include "workarounds.h"
 
 #include <errno.h>
 #include <stdint.h>
@@ -286,7 +286,7 @@ GlyphUnit::GlyphUnit(TitleMain *plugin, GlyphEngine *server)
 GlyphUnit::~GlyphUnit()
 {
        if( freetype_library )
-               FT_Done_FreeType(freetype_library);
+               ft_Done_FreeType(freetype_library);
 }
 
 static inline void to_mono(VFrame *data)
@@ -316,11 +316,11 @@ void GlyphUnit::process_package(LoadPackage *package)
                result = 1;
        }
        if( !result ) {
-               int gindex = FT_Get_Char_Index(freetype_face, glyph->char_code);
+               int gindex = ft_Get_Char_Index(freetype_face, glyph->char_code);
                if( !gindex && !freetype_face->charmap && // if no default charmap
                    freetype_face->charmaps && freetype_face->charmaps[0] &&
-                   !FT_Select_Charmap(freetype_face, freetype_face->charmaps[0]->encoding) ) {
-                       gindex = FT_Get_Char_Index(freetype_face, glyph->char_code);
+                   !ft_Select_Charmap(freetype_face, freetype_face->charmaps[0]->encoding) ) {
+                       gindex = ft_Get_Char_Index(freetype_face, glyph->char_code);
                }
                if( gindex == 0 ) {
 printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
@@ -329,10 +329,10 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
                        if( resources->find_font_by_char(glyph->char_code, new_path, freetype_face) ) {
                                plugin->load_freetype_face(freetype_library,
                                        freetype_face, new_path);
-                               gindex = FT_Get_Char_Index(freetype_face, glyph->char_code);
+                               gindex = ft_Get_Char_Index(freetype_face, glyph->char_code);
                        }
                }
-               FT_Set_Pixel_Sizes(freetype_face, glyph->size, 0);
+               ft_Set_Pixel_Sizes(freetype_face, glyph->size, 0);
 
                if( gindex == 0 ) {
 // carrige return
@@ -362,9 +362,9 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
                        FT_Glyph glyph_image;
                        FT_BBox bbox;
                        FT_Bitmap bm;
-                       FT_Load_Glyph(freetype_face, gindex, FT_LOAD_DEFAULT);
-                       FT_Get_Glyph(freetype_face->glyph, &glyph_image);
-                       FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph_image)->outline, &bbox);
+                       ft_Load_Glyph(freetype_face, gindex, FT_LOAD_DEFAULT);
+                       ft_Get_Glyph(freetype_face->glyph, &glyph_image);
+                       ft_Outline_Get_BBox(&((FT_OutlineGlyph) glyph_image)->outline, &bbox);
 //                     printf("Stroke: Xmin: %ld, Xmax: %ld, Ymin: %ld, yMax: %ld\n",
 //                                     bbox.xMin,bbox.xMax, bbox.yMin, bbox.yMax);
 
@@ -385,12 +385,12 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
                        glyph->data = new VFrame(glyph->width, glyph->height, BC_A8, glyph->pitch);
                        glyph->data->clear_frame();
                        bm.buffer = glyph->data->get_data();
-                       FT_Outline_Translate(&((FT_OutlineGlyph) glyph_image)->outline,
+                       ft_Outline_Translate(&((FT_OutlineGlyph) glyph_image)->outline,
                                - bbox.xMin, - bbox.yMin);
-                       FT_Outline_Get_Bitmap( freetype_library,
+                       ft_Outline_Get_Bitmap( freetype_library,
                                &((FT_OutlineGlyph) glyph_image)->outline,
                                &bm);
-                       FT_Done_Glyph(glyph_image);
+                       ft_Done_Glyph(glyph_image);
                }
                else {
 // Outline desired and glyph found
@@ -401,14 +401,14 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
                        FT_BBox bbox;
                        FT_UInt npoints, ncontours;
 
-                       FT_Load_Glyph(freetype_face, gindex, FT_LOAD_DEFAULT);
-                       FT_Get_Glyph(freetype_face->glyph, &glyph_image);
+                       ft_Load_Glyph(freetype_face, gindex, FT_LOAD_DEFAULT);
+                       ft_Get_Glyph(freetype_face->glyph, &glyph_image);
 
 // check if the outline is ok (non-empty);
-                       FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph_image)->outline, &bbox);
+                       ft_Outline_Get_BBox(&((FT_OutlineGlyph) glyph_image)->outline, &bbox);
                        if( bbox.xMin == 0 && bbox.xMax == 0 &&
                            bbox.yMin == 0 && bbox.yMax == 0 ) {
-                               FT_Done_Glyph(glyph_image);
+                               ft_Done_Glyph(glyph_image);
                                glyph->width = 0;   glyph->height = 0;
                                glyph->left = 0;    glyph->top = 0;
                                glyph->right = 0;   glyph->bottom = 0;
@@ -422,18 +422,18 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
                                return;
                        }
 #if FREETYPE_MAJOR > 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 2)
-                       FT_Stroker_New(freetype_library, &stroker);
+                       ft_Stroker_New(freetype_library, &stroker);
 #else
-                       FT_Stroker_New(((FT_LibraryRec *)freetype_library)->memory, &stroker);
+                       ft_Stroker_New(((FT_LibraryRec *)freetype_library)->memory, &stroker);
 #endif
-                       FT_Stroker_Set(stroker, (int)(plugin->config.stroke_width * 64),
+                       ft_Stroker_Set(stroker, (int)(plugin->config.stroke_width * 64),
                                FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
-                       FT_Stroker_ParseOutline(stroker, &((FT_OutlineGlyph) glyph_image)->outline,1);
-                       FT_Stroker_GetCounts(stroker,&npoints, &ncontours);
+                       ft_Stroker_ParseOutline(stroker, &((FT_OutlineGlyph) glyph_image)->outline,1);
+                       ft_Stroker_GetCounts(stroker,&npoints, &ncontours);
                        if( npoints == 0 && ncontours == 0 ) {
 // this never happens, but FreeType has a bug regarding Linotype's Palatino font
-                               FT_Stroker_Done(stroker);
-                               FT_Done_Glyph(glyph_image);
+                               ft_Stroker_Done(stroker);
+                               ft_Done_Glyph(glyph_image);
                                glyph->width = 0;   glyph->height = 0;
                                glyph->left = 0;    glyph->top = 0;
                                glyph->right = 0;   glyph->bottom = 0;
@@ -447,13 +447,13 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
                                return;
                        };
 
-                       FT_Outline_New(freetype_library, npoints, ncontours, &outline);
+                       ft_Outline_New(freetype_library, npoints, ncontours, &outline);
                        outline.n_points=0;
                        outline.n_contours=0;
-                       FT_Stroker_Export (stroker, &outline);
-                       FT_Outline_Get_BBox(&outline, &bbox);
-                       FT_Outline_Translate(&outline, - bbox.xMin, - bbox.yMin);
-                       FT_Outline_Translate(&((FT_OutlineGlyph) glyph_image)->outline,
+                       ft_Stroker_Export(stroker, &outline);
+                       ft_Outline_Get_BBox(&outline, &bbox);
+                       ft_Outline_Translate(&outline, - bbox.xMin, - bbox.yMin);
+                       ft_Outline_Translate(&((FT_OutlineGlyph) glyph_image)->outline,
                                        - bbox.xMin,
                                        - bbox.yMin + (int)(plugin->config.stroke_width*32));
 //                     printf("Stroke: Xmin: %ld, Xmax: %ld, Ymin: %ld, yMax: %ld\n"
@@ -489,16 +489,16 @@ printf("GlyphUnit::process_package 1 glyph not found (%s) %04x, '%c'\n",
                        glyph->data_stroke->clear_frame();
 // for debugging       memset( glyph->data_stroke->get_data(), 60, glyph->pitch * glyph->height);
                        bm.buffer=glyph->data->get_data();
-                       FT_Outline_Get_Bitmap( freetype_library,
+                       ft_Outline_Get_Bitmap( freetype_library,
                                &((FT_OutlineGlyph) glyph_image)->outline,
                                &bm);
                        bm.buffer=glyph->data_stroke->get_data();
-                       FT_Outline_Get_Bitmap( freetype_library,
+                       ft_Outline_Get_Bitmap( freetype_library,
                        &outline,
                                &bm);
-                       FT_Outline_Done(freetype_library,&outline);
-                       FT_Stroker_Done(stroker);
-                       FT_Done_Glyph(glyph_image);
+                       ft_Outline_Done(freetype_library,&outline);
+                       ft_Stroker_Done(stroker);
+                       ft_Done_Glyph(glyph_image);
 
 //printf("GlyphUnit::process_package 2\n");
                }
@@ -938,9 +938,9 @@ TitleMain::~TitleMain()
        delete glyph_engine;
        delete title_engine;
        if( freetype_face )
-               FT_Done_Face(freetype_face);
+               ft_Done_Face(freetype_face);
        if( freetype_library )
-               FT_Done_FreeType(freetype_library);
+               ft_Done_FreeType(freetype_library);
        delete translate;
        delete outline_engine;
 }
@@ -1025,8 +1025,8 @@ void TitleMain::build_previews(TitleWindow *gui)
 //                                     (char *)new_path);
                                strcpy(new_path, font->path);
                                if( load_freetype_face(freetype_library, freetype_face, new_path)) continue;
-                               FT_Set_Pixel_Sizes(freetype_face, text_height, 0);
-                               if( FT_Load_Char(freetype_face, c, FT_LOAD_RENDER) ) continue;
+                               ft_Set_Pixel_Sizes(freetype_face, text_height, 0);
+                               if( ft_Load_Char(freetype_face, c, FT_LOAD_RENDER) ) continue;
                                int glyph_w = freetype_face->glyph->bitmap.width;
                                int glyph_h = freetype_face->glyph->bitmap.rows;
                                if( glyph_h > max_height ) glyph_h = max_height;
@@ -1070,7 +1070,7 @@ void TitleMain::build_previews(TitleWindow *gui)
                }
        }
 
-       if( freetype_library ) FT_Done_FreeType(freetype_library);
+       if( freetype_library ) ft_Done_FreeType(freetype_library);
 }
 
 
@@ -1086,20 +1086,20 @@ int TitleMain::check_char_code_path(FT_Library &freetype_library,
        FcConfig *config;
        FcPattern *font;
 
-       FcInit();
-       config = FcConfigGetCurrent();
-       FcConfigSetRescanInterval(config, 0);
+       fcInit();
+       config = fcConfigGetCurrent();
+       fcConfigSetRescanInterval(config, 0);
 
-       pat = FcPatternCreate();
-       os = FcObjectSetBuild ( FC_FILE, FC_FONTFORMAT, (char *) 0);
-       fs = FcFontList(config, pat, os);
+       pat = fcPatternCreate();
+       os = fcObjectSetBuild( FC_FILE, FC_FONTFORMAT, (char *) 0);
+       fs = fcFontList(config, pat, os);
        int found = 0;
        char tmpstring[BCTEXTLEN];
        int limit_to_truetype = 0; //if you want to limit search to truetype put 1
-       if( !freetype_library ) FT_Init_FreeType(&freetype_library);
-       if( !FT_New_Face(freetype_library, path_old, 0, &temp_freetype_face) ) {
-               FT_Set_Pixel_Sizes(temp_freetype_face, 128, 0);
-               int gindex = FT_Get_Char_Index(temp_freetype_face, char_code);
+       if( !freetype_library ) ft_Init_FreeType(&freetype_library);
+       if( !ft_New_Face(freetype_library, path_old, 0, &temp_freetype_face) ) {
+               ft_Set_Pixel_Sizes(temp_freetype_face, 128, 0);
+               int gindex = ft_Get_Char_Index(temp_freetype_face, char_code);
                if( gindex != 0 && char_code == 10 ) {
                        strcpy(path_new, path_old);
                        found = 1;
@@ -1109,13 +1109,13 @@ int TitleMain::check_char_code_path(FT_Library &freetype_library,
        if( !found ) {
                for( int i=0; fs && i<fs->nfont; ++i ) {
                        font = fs->fonts[i];
-                       FcPatternGetString(font, FC_FONTFORMAT, 0, &format);
+                       fcPatternGetString(font, FC_FONTFORMAT, 0, &format);
                        if( strcmp((char *)format, "TrueType") && !limit_to_truetype ) continue;
-                       if( FcPatternGetString(font, FC_FILE, 0, &file) != FcResultMatch ) continue;
+                       if( fcPatternGetString(font, FC_FILE, 0, &file) != FcResultMatch ) continue;
                        sprintf(tmpstring, "%s", file);
-                       if( !FT_New_Face(freetype_library, tmpstring, 0, &temp_freetype_face) ) continue;
-                       FT_Set_Pixel_Sizes(temp_freetype_face, 128, 0);
-                       int gindex = FT_Get_Char_Index(temp_freetype_face, char_code);
+                       if( !ft_New_Face(freetype_library, tmpstring, 0, &temp_freetype_face) ) continue;
+                       ft_Set_Pixel_Sizes(temp_freetype_face, 128, 0);
+                       int gindex = ft_Get_Char_Index(temp_freetype_face, char_code);
                        if( gindex != 0 && char_code == 10 ) {
                                sprintf(path_new, "%s", tmpstring);
                                found = 1;
@@ -1125,8 +1125,8 @@ int TitleMain::check_char_code_path(FT_Library &freetype_library,
        }
 
 done:
-       if( fs ) FcFontSetDestroy(fs);
-       if( temp_freetype_face ) FT_Done_Face(temp_freetype_face);
+       if( fs ) fcFontSetDestroy(fs);
+       if( temp_freetype_face ) ft_Done_Face(temp_freetype_face);
        temp_freetype_face = 0;
 
        if( !found ) {
@@ -1143,14 +1143,14 @@ int TitleMain::load_freetype_face(FT_Library &freetype_library,
 {
 //printf("TitleMain::load_freetype_face 1\n");
        if( !freetype_library )
-               FT_Init_FreeType(&freetype_library);
+               ft_Init_FreeType(&freetype_library);
        if( freetype_face )
-               FT_Done_Face(freetype_face);
+               ft_Done_Face(freetype_face);
        freetype_face = 0;
 //printf("TitleMain::load_freetype_face 2\n");
 
 // Use freetype's internal function for loading font
-       if( FT_New_Face(freetype_library, path, 0, &freetype_face) ) {
+       if( ft_New_Face(freetype_library, path, 0, &freetype_face) ) {
                fprintf(stderr, _("TitleMain::load_freetype_face %s failed.\n"), path);
                freetype_face = 0;
                freetype_library = 0;
@@ -1386,7 +1386,7 @@ int TitleMain::get_width(TitleGlyph *cur, TitleGlyph *nxt)
        int result = cur->advance_x;
        if( !nxt ) return result;
        FT_Vector kerning;
-       if( !FT_Get_Kerning(freetype_face,
+       if( !ft_Get_Kerning(freetype_face,
            cur->freetype_index, nxt->freetype_index,
            ft_kerning_default, &kerning) )
                result += (kerning.x >> 6);
@@ -2338,7 +2338,7 @@ void TitleMain::reset_render()
        title_glyphs.clear();
        title_images.clear();
        if( freetype_face ) {
-               FT_Done_Face(freetype_face);
+               ft_Done_Face(freetype_face);
                freetype_face = 0;
        }
 }
@@ -2346,7 +2346,7 @@ void TitleMain::reset_render()
 int TitleMain::init_freetype()
 {
        if( !freetype_library )
-               FT_Init_FreeType(&freetype_library);
+               ft_Init_FreeType(&freetype_library);
        return 0;
 }