X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcresources.C;h=2ab104e094b78244b1c586b7c6a1de38a8c1eff0;hb=0ac6a1397cf8ee19cf75f3fe893c27e9f4fc0ea5;hp=e3769675d030ed9eb8f7b113de99c73f2f6d9e9f;hpb=b5c58822be78c8820692c916e296a2230bb2b9e2;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C index e3769675..2ab104e0 100644 --- a/cinelerra-5.1/guicast/bcresources.C +++ b/cinelerra-5.1/guicast/bcresources.C @@ -27,7 +27,7 @@ #include "bcsignals.h" #include "bcsynchronous.h" #include "bcwindowbase.h" -#include "colors.h" +#include "bccolors.h" #include "bccmodels.h" #include "cstrdup.h" #include "fonts.h" @@ -59,6 +59,7 @@ char BC_Resources::region[LEN_LANG] = {0}; char BC_Resources::encoding[LEN_ENCOD] = {0}; const char *BC_Resources::wide_encoding = 0; ArrayList *BC_Resources::fontlist = 0; +int BC_Resources::font_debug = 0; const char *BC_Resources::fc_properties[] = { FC_SLANT, FC_WEIGHT, FC_WIDTH }; #define LEN_FCPROP (sizeof(BC_Resources::fc_properties) / sizeof(const char*)) @@ -72,10 +73,14 @@ static const char *def_big_font = "-*-bitstream charter-bold-r-normal-*-*-0-%d-%d-p-0-iso8859-1"; // 160 static const char *def_big_font2 = "-*-nimbus sans l-bold-r-normal-*-*-0-%d-%d-p-0-iso8859-1"; // 160 +static const char *def_clock_font = "-*-helvetica-bold-r-normal-*-%d-*"; // 16 +static const char *def_clock_font2 = "-*-helvetica-bold-r-normal-*-%d-*"; // 18 static const char *def_small_fontset = "-*-helvetica-medium-r-normal-*-%d-*";// 10 static const char *def_medium_fontset = "-*-helvetica-bold-r-normal-*-%d-*"; // 14 static const char *def_large_fontset = "-*-helvetica-bold-r-normal-*-%d-*"; // 18 static const char *def_big_fontset = "-*-helvetica-bold-r-normal-*-%d-*"; // 24 +static const char *def_clock_fontset = "-*-helvetica-bold-r-normal-*-%d-*"; // 16 + static const char *def_small_font_xft = "Sans:pixelsize=%.4f"; // 10.6667 static const char *def_small_b_font_xft = "Sans:bold:pixelsize=%.4f"; // 10.6667 static const char *def_medium_font_xft = "Sans:pixelsize=%.4f"; // 13.3333 @@ -84,6 +89,7 @@ static const char *def_large_font_xft = "Sans:pixelsize=%.4f"; // 21.3 static const char *def_large_b_font_xft = "Sans:bold:pixelsize=%.4f"; // 21.3333 static const char *def_big_font_xft = "Sans:pixelsize=37.3333"; // 37.3333 static const char *def_big_b_font_xft = "Sans:bold:pixelsize=37.33333"; // 37.3333 +static const char *def_clock_font_xft = "Sans:pixelsize=%.4f"; // 16 #define default_font_xft2 "-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*" @@ -95,10 +101,13 @@ const char* BC_Resources::large_font = 0; const char* BC_Resources::large_font2 = 0; const char* BC_Resources::big_font = 0; const char* BC_Resources::big_font2 = 0; +const char* BC_Resources::clock_font = 0; +const char* BC_Resources::clock_font2 = 0; const char* BC_Resources::small_fontset = 0; const char* BC_Resources::medium_fontset = 0; const char* BC_Resources::large_fontset = 0; const char* BC_Resources::big_fontset = 0; +const char* BC_Resources::clock_fontset = 0; const char* BC_Resources::small_font_xft = 0; const char* BC_Resources::small_font_xft2 = 0; const char* BC_Resources::small_b_font_xft = 0; @@ -111,6 +120,8 @@ const char* BC_Resources::large_b_font_xft = 0; const char* BC_Resources::big_font_xft = 0; const char* BC_Resources::big_font_xft2 = 0; const char* BC_Resources::big_b_font_xft = 0; +const char* BC_Resources::clock_font_xft = 0; +const char* BC_Resources::clock_font_xft2 = 0; #define def_font(v, s...) do { sprintf(string,def_##v,s); v = cstrdup(string); } while(0) #define set_font(v, s) do { sprintf(string, "%s", s); v = cstrdup(string); } while(0) @@ -125,11 +136,14 @@ void BC_Resources::init_font_defs(double scale) def_font(large_font, iround(scale*18)); def_font(large_font2, iround(scale*20)); def_font(big_font, iround(scale*160), iround(scale*160)); - def_font(big_font2, iround(scale*160), iround(scale*160)); + def_font(big_font2, iround(scale*16), iround(scale*16)); + def_font(clock_font, iround(scale*16)); + def_font(clock_font2, iround(scale*18)); def_font(small_fontset, iround(scale*10)); def_font(medium_fontset, iround(scale*14)); def_font(large_fontset, iround(scale*18)); def_font(big_fontset, iround(scale*24)); + def_font(clock_fontset, iround(scale*16)); def_font(small_font_xft, (scale*10.6667)); def_font(small_b_font_xft, (scale*10.6667)); def_font(medium_font_xft, (scale*13.3333)); @@ -138,11 +152,13 @@ void BC_Resources::init_font_defs(double scale) def_font(large_b_font_xft, (scale*21.3333)); def_font(big_font_xft, (scale*37.3333)); def_font(big_b_font_xft, (scale*37.3333)); + def_font(clock_font_xft, (scale*16.)); set_font(small_font_xft2, default_font_xft2); set_font(medium_font_xft2, default_font_xft2); set_font(large_font_xft2, default_font_xft2); set_font(big_font_xft2, default_font_xft2); + set_font(clock_font_xft2, default_font_xft2); } void BC_Resources::finit_font_defs() { @@ -154,10 +170,13 @@ void BC_Resources::finit_font_defs() delete [] large_font2; delete [] big_font; delete [] big_font2; + delete [] clock_font; + delete [] clock_font2; delete [] small_fontset; delete [] medium_fontset; delete [] large_fontset; delete [] big_fontset; + delete [] clock_fontset; delete [] small_font_xft; delete [] small_b_font_xft; delete [] medium_font_xft; @@ -166,26 +185,73 @@ void BC_Resources::finit_font_defs() delete [] large_b_font_xft; delete [] big_font_xft; delete [] big_b_font_xft; + delete [] clock_font_xft; delete [] small_font_xft2; delete [] medium_font_xft2; delete [] large_font_xft2; delete [] big_font_xft2; + delete [] clock_font_xft2; } + suffix_to_type_t BC_Resources::suffix_to_type[] = { - { "m2v", ICON_FILM }, - { "mov", ICON_FILM }, - { "mp2", ICON_SOUND }, - { "mp3", ICON_SOUND }, - { "ac3", ICON_SOUND }, - { "mpg", ICON_FILM }, - { "vob", ICON_FILM }, - { "ifo", ICON_FILM }, - { "ts", ICON_FILM }, - { "vts", ICON_FILM }, - { "wav", ICON_SOUND } + { "aac", ICON_SOUND }, + { "ac3", ICON_SOUND }, + { "dts", ICON_SOUND }, + { "flac", ICON_SOUND }, + { "mp2", ICON_SOUND }, + { "mp3", ICON_SOUND }, + { "wav", ICON_SOUND }, + { "wma", ICON_SOUND }, + { "wmv", ICON_SOUND }, + { "avi", ICON_FILM }, + { "bmp", ICON_FILM }, + { "cr2", ICON_FILM }, + { "dnxhd", ICON_FILM }, + { "dvd", ICON_FILM }, + { "dv", ICON_FILM }, + { "f4v", ICON_FILM }, + { "flv", ICON_FILM }, + { "gif", ICON_FILM }, + { "gxf", ICON_FILM }, + { "h264", ICON_FILM }, + { "h265", ICON_FILM }, + { "hevc", ICON_FILM }, + { "ifo", ICON_FILM }, + { "jpeg", ICON_FILM }, + { "jpg", ICON_FILM }, + { "m2t", ICON_FILM }, + { "m2ts", ICON_FILM }, + { "m2v", ICON_FILM }, + { "m4v", ICON_FILM }, + { "mkv", ICON_FILM }, + { "mov", ICON_FILM }, + { "mp4", ICON_FILM }, + { "mpeg", ICON_FILM }, + { "mpg", ICON_FILM }, + { "mts", ICON_FILM }, + { "mxf", ICON_FILM }, + { "ogg", ICON_FILM }, + { "ogv", ICON_FILM }, + { "pcm", ICON_FILM }, + { "pgm", ICON_FILM }, + { "png", ICON_FILM }, + { "ppm", ICON_FILM }, + { "qt", ICON_FILM }, + { "rm", ICON_FILM }, + { "swf", ICON_FILM }, + { "tiff", ICON_FILM }, + { "tif", ICON_FILM }, + { "ts", ICON_FILM }, + { "vob", ICON_FILM }, + { "vts", ICON_FILM }, + { "webm", ICON_FILM }, + { "webp", ICON_FILM }, + { "xml", ICON_FILM }, + { "y4m", ICON_FILM }, + { 0, 0 }, }; BC_Signals* BC_Resources::signal_handler = 0; @@ -279,7 +345,9 @@ BC_Resources::BC_Resources() synchronous = 0; vframe_shm = 0; double default_scale = 1.0; // display_size/1000.; - char *env = getenv("BC_FONT_SCALE"); + char *env = getenv("BC_FONT_DEBUG"); + font_debug = env ? atoi(env) : 0; + env = getenv("BC_FONT_SCALE"); font_scale = env ? atof(env) : default_scale; if( font_scale <= 0 ) font_scale = 1; init_font_defs(font_scale); @@ -901,17 +969,23 @@ int BC_Resources::init_fontconfig(const char *search_path) char find_command[BCTEXTLEN]; char *fp = find_command, *ep = fp+sizeof(find_command)-1; - fp += snprintf(fp, ep-fp, "find '%s'", search_path); + fp += snprintf(fp, ep-fp, "%s", "find"); const char *bc_font_path = getenv("BC_FONT_PATH"); +// if BC_FONT_PATH starts with ':', omit default path + if( !(bc_font_path && bc_font_path[0] == ':') ) + fp += snprintf(fp, ep-fp, " '%s'", search_path); if( bc_font_path ) { const char *path = bc_font_path; - for( int len=0; *path; path+=len ) { - const char *cp = strchr(path,':'); - len = !cp ? strlen(path) : cp-path; + while( *path ) { char font_path[BCTEXTLEN]; - memcpy(font_path, path, len); font_path[len] = 0; - if( cp ) ++len; - fp += snprintf(fp, ep-fp, " '%s'", font_path); + const char *cp = strchr(path,':'); + int len = !cp ? strlen(path) : cp-path; + if( len > 0 ) { + memcpy(font_path, path, len); + font_path[len] = 0; path += len; + fp += snprintf(fp, ep-fp, " '%s'", font_path); + } + if( cp ) ++path; } } fp += snprintf(fp, ep-fp, " -name 'fonts.scale' -print -exec cat {} \\;"); @@ -1058,11 +1132,16 @@ int BC_Resources::init_fontconfig(const char *search_path) entry->style |= FL_WIDTH_NORMAL; fontlist->append(entry); + if( font_debug ) + dump_font_entry(stdout, "font 0: ", entry); + // printf("TitleMain::build_fonts %s: success\n", entry->path); //printf("TitleMain::build_fonts 2\n"); } pclose(in); + if( bc_font_path && bc_font_path[0] == ':' ) + return 0; // Load all the fonts from fontconfig FcPattern *pat; @@ -1270,6 +1349,8 @@ int BC_Resources::init_fontconfig(const char *search_path) } fontlist->append(entry); + if( font_debug ) + dump_font_entry(stdout, "font 1: ", entry); } FcFontSetDestroy(fs); @@ -1479,6 +1560,8 @@ int BC_Resources::init_fontconfig(const char *search_path) strcpy(entry->displayname, entry->family); } fontlist->append(entry); + if( font_debug ) + dump_font_entry(stdout, "font 2: ", entry); } FcFontSetDestroy(fs); return 0; @@ -1688,13 +1771,16 @@ FcPattern* BC_Resources::find_similar_font(FT_ULong char_code, FcPattern *oldfon void BC_Resources::dump_fonts(FILE *fp) { - for( int i=0; itotal; ++i ) { - BC_FontEntry *ep = fontlist->values[i]; - fprintf(fp,"%s = %s\n",ep->displayname,ep->path); - fprintf(fp," %s:%s:%s:%s:%s:%s:%d:%d:%d:%d:%d:%s:%d:%s:%s:%d\n", - ep->foundry, ep->family, ep->weight, ep->slant, ep->swidth, ep->adstyle, - ep->pixelsize, ep->pointsize, ep->xres, ep->yres, ep->style, ep->spacing, - ep->avg_width, ep->registry, ep->encoding, ep->fixed_style); - } + for( int i=0; itotal; ++i ) + dump_font_entry(fp, "", fontlist->values[i]); +} + +void BC_Resources::dump_font_entry(FILE *fp, const char *cp, BC_FontEntry *ep) +{ + fprintf(fp,"%s%s = %s\n",cp,ep->displayname,ep->path); + fprintf(fp," %s:%s:%s:%s:%s:%s:%d:%d:%d:%d:%d:%s:%d:%s:%s:%d\n", + ep->foundry, ep->family, ep->weight, ep->slant, ep->swidth, ep->adstyle, + ep->pixelsize, ep->pointsize, ep->xres, ep->yres, ep->style, ep->spacing, + ep->avg_width, ep->registry, ep->encoding, ep->fixed_style); }