From 66e352aa64d795f1965c0e593b6db75e0889f580 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 18 Jun 2015 14:30:37 -0600 Subject: [PATCH] title keyframe fix and font lookup fixes --- cinelerra-5.0/cinelerra/filexml.C | 10 ++- cinelerra-5.0/cinelerra/filexml.h | 3 +- cinelerra-5.0/cinelerra/keyframe.C | 23 +------ cinelerra-5.0/guicast/bcresources.C | 100 +++++++++++++++++++--------- cinelerra-5.0/guicast/bcresources.h | 1 + 5 files changed, 84 insertions(+), 53 deletions(-) diff --git a/cinelerra-5.0/cinelerra/filexml.C b/cinelerra-5.0/cinelerra/filexml.C index 6d591f24..aa80ae8d 100644 --- a/cinelerra-5.0/cinelerra/filexml.C +++ b/cinelerra-5.0/cinelerra/filexml.C @@ -395,7 +395,15 @@ int FileXML::append_tag() int FileXML::append_text(const char *text) { - append_text(text, strlen(text)); + if( text != 0 ) + append_text(text, strlen(text)); + return 0; +} + +int FileXML::append_data(const char *text) +{ + if( text != 0 ) + append_data(text, strlen(text)); return 0; } diff --git a/cinelerra-5.0/cinelerra/filexml.h b/cinelerra-5.0/cinelerra/filexml.h index 155c595d..d41d081c 100644 --- a/cinelerra-5.0/cinelerra/filexml.h +++ b/cinelerra-5.0/cinelerra/filexml.h @@ -127,8 +127,9 @@ public: int append_newline(); int append_tag(); int append_text(const char *text); - int append_data(const char *text, long len); int append_text(const char *text, long len); + int append_data(const char *text); + int append_data(const char *text, long len); char* read_text(); int read_data_until(const char *tag_end, char *out, int len); diff --git a/cinelerra-5.0/cinelerra/keyframe.C b/cinelerra-5.0/cinelerra/keyframe.C index b1155700..68eed16b 100644 --- a/cinelerra-5.0/cinelerra/keyframe.C +++ b/cinelerra-5.0/cinelerra/keyframe.C @@ -231,31 +231,12 @@ void KeyFrame::update_parameter(BC_Hash *params, } } - - // Append parameters to output output.append_tag(); - // Write anonymous text & duplicate the rest - if(text) - { - output.append_text(text); - } - else - { - output.append_text(this_text); - } - + output.append_text(text ? text : this_text); // Append remaining previous data - if(extra) - { - output.append_text(extra); - } - else - { - output.append_text(this_extra); - } - + output.append_data(extra ? extra : this_extra); // Move output to input output.terminate_string(); strcpy(this->data, output.string()); diff --git a/cinelerra-5.0/guicast/bcresources.C b/cinelerra-5.0/guicast/bcresources.C index ef777523..c93732ab 100644 --- a/cinelerra-5.0/guicast/bcresources.C +++ b/cinelerra-5.0/guicast/bcresources.C @@ -954,12 +954,51 @@ int BC_Resources::init_fontconfig(const char *search_path) sprintf(line, "%s (%s)", entry->family, entry->foundry); entry->displayname = cstrdup(line); - if(!strcasecmp(entry->weight, "demibold") || - !strcasecmp(entry->weight, "bold")) + if(!strcasecmp(entry->weight, "demibold")) { entry->fixed_style |= BC_FONT_BOLD; - if(!strcasecmp(entry->slant, "i") || - !strcasecmp(entry->slant, "o")) + entry->style |= FL_WEIGHT_DEMIBOLD; + } + else if(!strcasecmp(entry->weight, "bold")) { + entry->fixed_style |= BC_FONT_BOLD; + entry->style |= FL_WEIGHT_BOLD; + } + else { + entry->style |= FL_WEIGHT_NORMAL; + } + + if(!strcasecmp(entry->slant, "r")) { + entry->style |= FL_SLANT_ROMAN; + } + else if(!strcasecmp(entry->slant, "i")) { + entry->style |= FL_SLANT_ITALIC; + entry->fixed_style |= BC_FONT_ITALIC; + } + else if(!strcasecmp(entry->slant, "o")) { + entry->style |= FL_SLANT_OBLIQUE; entry->fixed_style |= BC_FONT_ITALIC; + } + + if(!strcasecmp(entry->swidth, "normal")) + entry->style = FL_WIDTH_NORMAL; + else if(!strcasecmp(entry->swidth, "ultracondensed")) + entry->style = FL_WIDTH_ULTRACONDENSED; + else if(!strcasecmp(entry->swidth, "extracondensed")) + entry->style = FL_WIDTH_EXTRACONDENSED; + else if(!strcasecmp(entry->swidth, "condensed")) + entry->style = FL_WIDTH_CONDENSED; + else if(!strcasecmp(entry->swidth, "semicondensed")) + entry->style = FL_WIDTH_SEMICONDENSED; + else if(!strcasecmp(entry->swidth, "semiexpanded")) + entry->style = FL_WIDTH_SEMIEXPANDED; + else if(!strcasecmp(entry->swidth, "expanded")) + entry->style = FL_WIDTH_EXPANDED; + else if(!strcasecmp(entry->swidth, "extraexpanded")) + entry->style = FL_WIDTH_EXTRAEXPANDED; + else if(!strcasecmp(entry->swidth, "ultraexpanded")) + entry->style = FL_WIDTH_ULTRAEXPANDED; + else + entry->style = FL_WIDTH_NORMAL; + fontlist->append(entry); // printf("TitleMain::build_fonts %s: success\n", entry->path); //printf("TitleMain::build_fonts 2\n"); @@ -1065,13 +1104,16 @@ int BC_Resources::init_fontconfig(const char *search_path) case FC_SLANT_ROMAN: default: entry->slant = cstrdup("r"); + entry->style |= FL_SLANT_ROMAN; break; case FC_SLANT_ITALIC: entry->slant = cstrdup("i"); + entry->style |= FL_SLANT_ITALIC; entry->fixed_style |= BC_FONT_ITALIC; break; case FC_SLANT_OBLIQUE: entry->slant = cstrdup("o"); + entry->style |= FL_SLANT_OBLIQUE; entry->fixed_style |= BC_FONT_ITALIC; break; } @@ -1250,25 +1292,6 @@ int BC_Resources::init_fontconfig(const char *search_path) } } - if(FcPatternGetInteger(font, FC_SLANT, 0, &intvalue) == FcResultMatch) - { - switch(intvalue) - { - case FC_SLANT_ROMAN: - default: - entry->style |= FL_SLANT_ROMAN; - break; - - case FC_SLANT_ITALIC: - entry->style |= FL_SLANT_ITALIC; - break; - - case FC_SLANT_OBLIQUE: - entry->style |= FL_SLANT_OBLIQUE; - break; - } - } - if(FcPatternGetInteger(font, FC_WEIGHT, 0, &intvalue) == FcResultMatch) { switch(intvalue) @@ -1404,7 +1427,7 @@ int BC_Resources::init_fontconfig(const char *search_path) BC_FontEntry *BC_Resources::find_fontentry(const char *displayname, int style, int mask) { - BC_FontEntry *entry, *style_match; + BC_FontEntry *entry, *style_match, *displayname_match; if(!fontlist) return 0; @@ -1423,22 +1446,27 @@ BC_FontEntry *BC_Resources::find_fontentry(const char *displayname, int style, i // No exact match - assume normal width font style |= FL_WIDTH_NORMAL; mask |= FL_WIDTH_MASK; - style_match = 0; + style_match = 0; displayname_match = 0; for(int i = 0; i < fontlist->total; i++) { entry = fontlist->values[i]; + if(!strncasecmp(displayname, entry->family, + strlen(entry->family))) + { + if((entry->style & mask) == style) + return entry; + if(!displayname_match) + displayname_match = entry; + } + if((entry->style & mask) == style) { if(!style_match) style_match = entry; - - if(!strncasecmp(displayname, entry->family, - strlen(entry->family))) - return entry; } } - return style_match; + return displayname_match ? displayname_match : style_match; } size_t BC_Resources::encode(const char *from_enc, const char *to_enc, @@ -1569,3 +1597,15 @@ FcPattern* BC_Resources::find_similar_font(FT_ULong char_code, FcPattern *oldfon return pat; } +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); + } +} + diff --git a/cinelerra-5.0/guicast/bcresources.h b/cinelerra-5.0/guicast/bcresources.h index 4476e4a7..a86fd560 100644 --- a/cinelerra-5.0/guicast/bcresources.h +++ b/cinelerra-5.0/guicast/bcresources.h @@ -355,6 +355,7 @@ public: static size_t encode(const char *from_enc, const char *to_enc, char *input, int input_length, char *output, int output_length); static int find_font_by_char(FT_ULong char_code, char *path_new, const FT_Face oldface); + static void dump_fonts(FILE *fp = stdout); // Make VFrame use shm int vframe_shm; -- 2.26.2