evas: add pattern "style" when evas query fonts via fontconfig 05/77205/2
authorYoungbok Shin <youngb.shin@samsung.com>
Tue, 28 Jun 2016 01:49:37 +0000 (10:49 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 30 Jun 2016 00:17:22 +0000 (17:17 -0700)
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

Change-Id: Ibd9f53cb62568e2ee6e1e627f75607936396e6ff

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

index 3e544de..cd2db5b 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);
@@ -799,6 +801,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 170caf0..e8cdb5e 100755 (executable)
@@ -1162,6 +1162,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;