title keyframe fix and font lookup fixes
authorGood Guy <[email protected]>
Thu, 18 Jun 2015 20:30:37 +0000 (14:30 -0600)
committerGood Guy <[email protected]>
Thu, 18 Jun 2015 20:30:37 +0000 (14:30 -0600)
cinelerra-5.0/cinelerra/filexml.C
cinelerra-5.0/cinelerra/filexml.h
cinelerra-5.0/cinelerra/keyframe.C
cinelerra-5.0/guicast/bcresources.C
cinelerra-5.0/guicast/bcresources.h

index 6d591f246bc04a36c35d3186e9930e8fd4f49b4b..aa80ae8d8ba674e7f64cac109aa565b716a5e2c6 100644 (file)
@@ -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;
 }
 
index 155c595d52cdb602ab2f1c9bb86d2511e72a0c75..d41d081c57d20da5db075e2f9afed4affcd81a8c 100644 (file)
@@ -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);
index b115570058ef738dc38739e0982e741188bb335a..68eed16b038e751388b74d7245444d79d5d93a1f 100644 (file)
@@ -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());
index ef77752355491a20c1aaf6f3877e692d77b7a703..c93732ab84cec683fdfedc0c306d227ea20f675d 100644 (file)
@@ -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; i<fontlist->total; ++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);
+       }
+}
+
index 4476e4a72ca61c7c8ad394aa1585df4bc3adab58..a86fd5600ed67c2be3c977d8e01407bb027d2d7c 100644 (file)
@@ -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;