evas: add pattern "style" when evas query fonts via fontconfig
authorYoungbok Shin <youngb.shin@samsung.com>
Tue, 28 Jun 2016 01:49:37 +0000 (10:49 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 28 Jun 2016 04:32:49 +0000 (13:32 +0900)
Summary:
Some fonts can have weird style and weight value.
If a font has a style name as "medium" and a weight value as "semi-bold",
Evas can't load the font using "font=Somefont:style=Medium".
It only can be load with "font=Somefont:style=SemiBold" or
"font=Somefont:weight=SemiBold".
On the other hand, it could be loaded when I tested the following commands.
fc-match -s ":family=Somefont:style=Medium" or
fc-match -s ":family=Somefont:weight=SemiBold"

Evas also should load font based on font's style name.
@fix

Test Plan: N/A

Reviewers: tasn, herdsman, cedric, woohyun, raster

Reviewed By: raster

Subscribers: Blackmole, z-wony, jpeg

Differential Revision: https://phab.enlightenment.org/D4108

src/lib/evas/canvas/evas_font_dir.c
src/lib/evas/include/evas_private.h

index 75546eb..1369dfe 100644 (file)
@@ -420,6 +420,7 @@ evas_font_desc_unref(Evas_Font_Description *fdesc)
    if (--(fdesc->ref) == 0)
      {
         eina_stringshare_del(fdesc->name);
+        eina_stringshare_del(fdesc->style);
         eina_stringshare_del(fdesc->fallbacks);
         eina_stringshare_del(fdesc->lang);
         free(fdesc);
@@ -506,6 +507,7 @@ evas_font_name_parse(Evas_Font_Description *fdesc, const char *name)
 #define _SET_STYLE(x, len) \
              fdesc->x = _evas_font_style_find_internal(name + len, tend, \
                    _style_##x##_map, _STYLE_MAP_LEN(_style_##x##_map));
+             eina_stringshare_replace_length(&(fdesc->style), name + 7, tend - (name + 7));
              _SET_STYLE(slant, 7);
              _SET_STYLE(weight, 7);
              _SET_STYLE(width, 7);
@@ -804,6 +806,9 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
               NULL);
         FcPatternAddString (p_nm, FC_FAMILY, (FcChar8*) fdesc->name);
 
+        if (fdesc->style)
+          FcPatternAddString (p_nm, FC_STYLE, (FcChar8*) fdesc->style);
+
         /* Handle font fallbacks */
         if (fdesc->fallbacks)
           {
index f8d3e9b..394fa58 100644 (file)
@@ -1211,6 +1211,7 @@ struct _Evas_Font_Description
    const char *name;
    const char *fallbacks;
    const char *lang;
+   const char *style;
 
    Evas_Font_Slant slant;
    Evas_Font_Weight weight;