if (--(fdesc->ref) == 0)
{
eina_stringshare_del(fdesc->name);
+ eina_stringshare_del(fdesc->fallbacks);
free(fdesc);
}
}
FC_WIDTH, FcTypeInteger, _fc_width_map[fdesc->width],
#endif
NULL);
- /* FIXME: Handle font fallbacks!!! */
FcPatternAddString (p_nm, FC_FAMILY, (FcChar8*) fdesc->name);
+ /* Handle font fallbacks */
+ if (fdesc->fallbacks)
+ {
+ while (1)
+ {
+ const char *start, *end;
+ start = fdesc->fallbacks;
+ end = strchr(start, ',');
+ if (end)
+ {
+ char *tmp;
+ tmp = strndup(start, end - start);
+ FcPatternAddString (p_nm, FC_FAMILY, (FcChar8*) start);
+ free(tmp);
+ }
+ else
+ {
+ FcPatternAddString (p_nm, FC_FAMILY, (FcChar8*) start);
+ break;
+ }
+ }
+ }
+
FcConfigSubstitute(NULL, p_nm, FcMatchPattern);
FcDefaultSubstitute(p_nm);
struct {
Evas_Font_Description *fdesc;
const char *source;
- const char *fallbacks;
Evas_Font_Set *font;
Evas_Font_Size size;
} font;
fmt->ref--;
if (fmt->ref > 0) return;
if (fmt->font.fdesc) evas_font_desc_unref(fmt->font.fdesc);
- if (fmt->font.fallbacks) eina_stringshare_del(fmt->font.fallbacks);
if (fmt->font.source) eina_stringshare_del(fmt->font.source);
evas_font_free(obj->layer->evas, fmt->font.font);
free(fmt);
/* If we are changing the font, create the fdesc. */
if ((cmd == font_weightstr) || (cmd == font_widthstr) ||
- (cmd == font_stylestr) || (cmd == fontstr))
+ (cmd == font_stylestr) ||
+ (cmd == fontstr) || (cmd == font_fallbacksstr))
{
if (!fmt->font.fdesc)
{
}
else if (cmd == font_fallbacksstr)
{
- if ((!fmt->font.fallbacks) ||
- ((fmt->font.fallbacks) && (strcmp(fmt->font.fallbacks, tmp_param))))
- {
- /* policy - when we say "fallbacks" do we prepend and use prior
- * fallbacks... or should we replace. for now we replace
- */
- if (fmt->font.fallbacks) eina_stringshare_del(fmt->font.fallbacks);
- fmt->font.fallbacks = eina_stringshare_add(tmp_param);
- }
+ eina_stringshare_replace(&(fmt->font.fdesc->fallbacks), tmp_param);
}
else if (cmd == font_sizestr)
{
_format_dup(Evas_Object *obj, const Evas_Object_Textblock_Format *fmt)
{
Evas_Object_Textblock_Format *fmt2;
- char *buf = NULL;
fmt2 = calloc(1, sizeof(Evas_Object_Textblock_Format));
memcpy(fmt2, fmt, sizeof(Evas_Object_Textblock_Format));
fmt2->ref = 1;
fmt2->font.fdesc = evas_font_desc_ref(fmt->font.fdesc);
- if (fmt->font.fallbacks) fmt2->font.fallbacks = eina_stringshare_add(fmt->font.fallbacks);
if (fmt->font.source) fmt2->font.source = eina_stringshare_add(fmt->font.source);
/* FIXME: just ref the font here... */
fmt2->font.font = evas_font_load(obj->layer->evas, fmt2->font.fdesc,
fmt2->font.source, (int)(((double) fmt2->font.size) * obj->cur.scale));
- if (buf) free(buf);
return fmt2;
}