GF_Font *gf_compositor_svg_set_font(GF_FontManager *fm, char *a_font, u32 styles, Bool check_only) { GF_Font *font = NULL; char *fonts[50]; u32 nb_fonts = 0; while (a_font) { char *sep; while (strchr("\t\r\n ", a_font[0])) a_font++; sep = strchr(a_font, ','); if (sep) sep[0] = 0; if (a_font[0] == '\'') { char *sep_end = strchr(a_font+1, '\''); if (sep_end) sep_end[0] = 0; a_font++; fonts[nb_fonts] = gf_strdup(a_font); nb_fonts++; if (sep_end) sep_end[0] = '\''; } else { u32 skip = 0; size_t len = strlen(a_font)-1; while (a_font[len-skip] == ' ') skip++; if (skip) a_font[len-skip+1] = 0; fonts[nb_fonts] = gf_strdup(a_font); nb_fonts++; if (skip) a_font[len-skip] = ' '; } if (sep) { sep[0] = ','; a_font = sep+1; } else { a_font = NULL; } if (nb_fonts==50) break; } font = gf_font_manager_set_font_ex(fm, fonts, nb_fonts, styles, check_only); while (nb_fonts) { gf_free(fonts[nb_fonts-1]); nb_fonts--; } return font; }
Bool compositor_svg_evaluate_conditional(GF_Compositor *compositor, SVGAllAttributes *atts) { u32 i, count; Bool found; const char *lang_3cc, *lang_2cc; /*process required features*/ count = atts->requiredFeatures ? gf_list_count(*atts->requiredFeatures) : 0; for (i=0; i<count; i++) { char *feat = NULL; XMLRI *iri = gf_list_get(*atts->requiredFeatures, i); if (!iri->string) continue; if (!strnicmp(iri->string, "org.w3c.svg", 11)) { feat = iri->string+12; if (feat) { if (!stricmp(feat, "animation")) {} else if (!stricmp(feat, "dynamic")) {} /*no support for filters, clipping & co - SVG 1.0 featureStrings are badly designed*/ else return 0; } } else if (!strnicmp(iri->string, "http://www.w3.org/TR/SVG11/feature", 34)) { feat = iri->string+35; if (feat) { Bool found = 0; u32 j, nbf; nbf = sizeof(svg11_features) / sizeof(struct svg_11_feature); for (j=0; j<nbf; j++) { if (!strcmp(svg11_features[j].name, feat)) { found = 1; if (!svg11_features[j].supported) return 0; break; } } if (!found) return 0; } } else if (!strnicmp(iri->string, "http://www.w3.org/Graphics/SVG/feature/1.2/", 43)) { feat = iri->string+44; if (feat) { Bool found = 0; u32 j, nbf; nbf = sizeof(svg12_features) / sizeof(struct svg_12_feature); for (j=0; j<nbf; j++) { if (!strcmp(svg12_features[j].name, feat)) { found = 1; if (!svg12_features[j].supported) return 0; break; } } if (!found) return 0; } } /*unrecognized feature*/ else { return 0; } } /*process required extensions*/ count = atts->requiredExtensions ? gf_list_count(*atts->requiredExtensions) : 0; if (count) return 0; /*process system language*/ count = atts->systemLanguage ? gf_list_count(*atts->systemLanguage) : 0; if (count) { found = 0; lang_3cc = gf_cfg_get_key(compositor->user->config, "Systems", "Language3CC"); if (!lang_3cc) lang_3cc = "und"; lang_2cc = gf_cfg_get_key(compositor->user->config, "Systems", "Language2CC"); if (!lang_2cc) lang_2cc = "un"; } else { lang_3cc = "und"; lang_2cc = "un"; found = 1; } for (i=0; i<count; i++) { char *lang = gf_list_get(*atts->systemLanguage, i); /*3 char-code*/ if (strlen(lang)==3) { if (!stricmp(lang, lang_3cc)) { found = 1; break; } } /*2 char-code, only check first 2 chars - TODO FIXME*/ else if (!strnicmp(lang, lang_2cc, 2)) { found = 1; break; } } if (!found) return 0; /*process required formats*/ count = atts->requiredFormats ? gf_list_count(*atts->requiredFormats) : 0; if (count) { for (i=0; i<count; i++) { const char *opt; char *mime = gf_list_get(*atts->requiredFormats, i); char *sep = strchr(mime, ';'); if (sep) sep[0] = 0; opt = gf_cfg_get_key(compositor->user->config, "MimeTypes", mime); if (sep) sep[0] = ';'; if (!opt) return 0; } } /*process required fonts*/ count = atts->requiredFonts ? gf_list_count(*atts->requiredFonts) : 0; if (count) { for (i=0; i<count; i++) { char *font = gf_list_get(*atts->requiredFonts, i); if (gf_font_manager_set_font_ex(compositor->font_manager, &font, 1, 0, 1)==NULL) return 0; } } /*OK, we can render this one*/ return 1; }