Remove dependency fontconfig, efl. 46/141446/8
authorjinwang.an <jinwang.an@samsung.com>
Mon, 31 Jul 2017 11:30:39 +0000 (20:30 +0900)
committerjinwang.an <jinwang.an@samsung.com>
Fri, 12 Jan 2018 09:27:49 +0000 (18:27 +0900)
Change-Id: Ibacaac7e3010c26fe95ac8a6bbc7dc637d9356d9
Signed-off-by: jinwang.an <jinwang.an@samsung.com>
doc/system_settings_doc.h
include/system_settings_private.h
src/system_setting_platform.c
src/system_settings.c
system-settings-util/include/system_settings_font.h [new file with mode: 0644]
system-settings-util/include/system_settings_util.h
system-settings-util/src/system_settings_util.c

index 6fe81cd..99b2cf8 100644 (file)
@@ -37,6 +37,7 @@
 *  - http://tizen.org/feature/systemsetting.lock_screen
 *  - http://tizen.org/feature/systemsetting.incoming_call
 *  - http://tizen.org/feature/systemsetting.notification_email
+*  - http://tizen.org/feature/systemsetting.font
 *  - http://tizen.org/feature/network.wifi
 *  - http://tizen.org/feature/network.telephony
 *
@@ -57,6 +58,9 @@
 * <tr> <td rowspan=2> http://tizen.org/feature/systemsetting.incoming_call </td> <td>   #SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE </td></tr>
 * <tr> <td>   #SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION </td> </tr>
 * <tr> <td> http://tizen.org/feature/systemsetting.notification_email </td> <td>   #SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE </td> </tr>
+* <tr> <td rowspan=3> http://tizen.org/feature/systemsetting.font</td> <td>   #SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE </td> </tr>
+* <tr> <td>   #SYSTEM_SETTINGS_KEY_FONT_TYPE </td>  </tr>
+* <tr> <td>   #SYSTEM_SETTINGS_KEY_FONT_SIZE </td>  </tr>
 * <tr> <td> http://tizen.org/feature/network.wifi </td> <td>   #SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION </td> </tr>
 * <tr> <td rowspan=2> http://tizen.org/feature/network.telephony </td> <td>   #SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE </td> </tr>
 * <tr> <td>   #SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST </td>  </tr>
index 12b3e17..e1283f8 100644 (file)
@@ -69,6 +69,7 @@ extern "C"
 #define SETTING_LOCK_SCREEN_PATH "tizen.org/feature/systemsetting.lock_screen"
 #define SETTING_NOTIFICATION_EMAIL_PATH "tizen.org/feature/systemsetting.notification_email"
 #define SETTING_WIFI_PATH "tizen.org/feature/network.wifi"
+#define SETTING_FONT_PATH "tizen.org/feature/systemsetting.font"
 #define SETTING_TELEPHONY_PATH "tizen.org/feature/network.telephony"
 
 /**
@@ -1585,6 +1586,17 @@ int system_setting_feature_check_wifi(void * value);
  * @retval     #SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED Not support system-settings API
  */
 int system_setting_feature_check_telephony(void *value);
+
+
+/**
+ * @internal
+ * @since_tizen 4.0
+ * @return     0 on success, otherwise a negative error value
+ * @retval     #SYSTEM_SETTINGS_ERROR_NONE Successful
+ * @retval     #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
+ * @retval     #SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED Not support system-settings API
+ */
+int system_setting_feature_check_font(void *value);
 /*// */
 
 
index 2c7ea35..c077c1d 100644 (file)
@@ -2236,6 +2236,19 @@ int system_setting_feature_check_telephony(void * value)
        return ret;
 }
 
+
+int system_setting_feature_check_font(void * value)
+{
+       static bool first_query = true;
+       static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
+
+       if (first_query == true) {
+               ret = system_settings_feature_check_bool(SETTING_FONT_PATH);
+               first_query = false;
+       }
+
+       return ret;
+}
 /*  LCOV_EXCL_START */
 int system_setting_get_uds_state(system_settings_key_e key, void **value)
 {
index 1ce015a..46b05fe 100644 (file)
@@ -95,7 +95,7 @@ system_setting_s system_setting_table[] = {
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
-               NULL,           /* feature check */
+               system_setting_feature_check_font,              /* feature check */
                { NULL, 0 }, /* changed callabck list */
                NULL,           /* user data */
        },
@@ -111,7 +111,7 @@ system_setting_s system_setting_table[] = {
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
-               NULL,           /* feature check */
+               system_setting_feature_check_font,              /* feature check */
                { NULL, 0 }, /* changed callabck list */
                NULL,           /* user data */
        },
@@ -203,7 +203,7 @@ system_setting_s system_setting_table[] = {
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
-               NULL,           /* feature check */
+               system_setting_feature_check_font,              /* feature check */
                { NULL, 0 }, /* changed callabck list */
                NULL,           /* user data */
        },
diff --git a/system-settings-util/include/system_settings_font.h b/system-settings-util/include/system_settings_font.h
new file mode 100644 (file)
index 0000000..1b14575
--- /dev/null
@@ -0,0 +1,92 @@
+/* * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <fontconfig/fontconfig.h>
+#include <dlfcn.h>
+
+FcConfig *
+(*d_FcInitLoadConfigAndFonts) (void);
+
+FcPattern *
+(*d_FcPatternBuild) (FcPattern *p, ...);
+
+void
+(*d_FcConfigDestroy) (FcConfig *config);
+
+FcBool
+(*d_FcConfigSubstitute) (FcConfig      *config,
+                   FcPattern   *p,
+                   FcMatchKind kind);
+
+void
+(*d_FcDefaultSubstitute) (FcPattern *pattern);
+
+FcFontSet *
+(*d_FcFontSort) (FcConfig       *config,
+           FcPattern    *p,
+           FcBool       trim,
+           FcCharSet    **csp,
+           FcResult     *result);
+
+FcResult
+(*d_FcPatternGetString) (const FcPattern *p, const char *object, int n, FcChar8 ** s);
+
+void
+(*d_FcFontSetDestroy) (FcFontSet *s);
+
+void
+(*d_FcPatternDestroy) (FcPattern *p);
+
+FcPattern *
+(*d_FcPatternCreate) (void);
+
+FcObjectSet *
+(*d_FcObjectSetBuild) (const char *first, ...);
+
+FcFontSet *
+(*d_FcFontList) (FcConfig      *config,
+           FcPattern   *p,
+           FcObjectSet *os);
+
+void
+(*d_FcObjectSetDestroy) (FcObjectSet *os);
+
+int
+(*d_evas_init) (void);
+
+Ecore_Evas *
+(*d_ecore_evas_new) (const char *engine_name, int x, int y, int w, int h, const char *extra_options);
+
+Evas *
+(*d_ecore_evas_get) (const Ecore_Evas *ee);
+
+Evas_Object *
+(*d_evas_object_image_add) (Evas *eo_e);
+
+void
+(*d_evas_object_image_file_set) (Eo *obj, const char *file, const char *key);
+
+Evas_Load_Error
+(*d_evas_object_image_load_error_get) (const Evas_Object *obj);
+
+void
+(*d_ecore_evas_free) (Ecore_Evas *ee);
+
+int
+(*d_evas_shutdown) (void);
+
+
+
+
index 6d0c7c1..4df2829 100644 (file)
@@ -1,3 +1,18 @@
+/* * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 bool font_config_set(char *font_name);
 int __is_available_font(char *font_name);
 char *_get_default_font();
index d942157..cc523bb 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <tzplatform_config.h>
 #include <system_settings_util.h>
+#include <system_settings_font.h>
 
 #ifdef TIZEN_WEARABLE
 #define SMALL_FONT_DPI                                         (-90)
 #define SETTING_FONT_TIZEN_FONT_ALIAS "Tizen"
 #define SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS "TizenDefaultFont"
 
+#define SETTING_FONT_CONFIG_SO_PATH "/usr/lib/libfontconfig.so.1"
+#define SETTING_ECORE_EVAS_SO_PATH "/usr/lib/libecore_evas.so.1"
+#define SETTING_EVAS_SO_PATH "/usr/lib/libevas.so.1"
+
 static int __font_size_get();
 
+void *d_font_handle = NULL;
+void *d_ecore_evas_handle = NULL;
+void *d_evas_handle = NULL;
+
+
+
+#define DYM_FUNC_LOADING(error, handle, pfunc, func_name) do { \
+               pfunc = (void*)dlsym(handle, func_name); \
+               if ((error = dlerror()) != NULL) { \
+                       SETTING_TRACE("ERROR!! canNOT find %s function at /usr/lib/libfontconfig.so.1", func_name); \
+                       if (handle) \
+                               dlclose(handle); \
+                       return false; \
+               } \
+       } while (0)
+
+int loading_dym_font()
+{
+       char *error = NULL;
+
+       if (!d_font_handle) {
+       d_font_handle = dlopen(SETTING_FONT_CONFIG_SO_PATH,  RTLD_LAZY);
+               if (!d_font_handle) {
+                       SETTING_TRACE("ERROR!! canNOT find /usr/lib/libfontconfig.so.1");
+                       return false;
+               }
+       }
+
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcInitLoadConfigAndFonts, "FcInitLoadConfigAndFonts");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcPatternBuild, "FcPatternBuild");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcConfigDestroy, "FcConfigDestroy");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcConfigSubstitute, "FcConfigSubstitute");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcDefaultSubstitute, "FcDefaultSubstitute");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcFontSort, "FcFontSort");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcPatternGetString, "FcPatternGetString");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcFontSetDestroy, "FcFontSetDestroy");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcPatternDestroy, "FcPatternDestroy");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcPatternCreate, "FcPatternCreate");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcObjectSetBuild, "FcObjectSetBuild");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcFontList, "FcFontList");
+       DYM_FUNC_LOADING(error, d_font_handle, d_FcObjectSetDestroy, "FcObjectSetDestroy");
+
+       return true;
+
+}
+
+int loading_dym_efl()
+{
+       char *error = NULL;
+
+       if (!d_ecore_evas_handle) {
+       d_ecore_evas_handle = dlopen(SETTING_ECORE_EVAS_SO_PATH,  RTLD_LAZY);
+               if (!d_ecore_evas_handle) {
+                       SETTING_TRACE("ERROR!! canNOT find /usr/lib/libecore_evas.so.1");
+                       return false;
+               }
+       }
+
+       if (!d_evas_handle) {
+       d_evas_handle = dlopen(SETTING_EVAS_SO_PATH,  RTLD_LAZY);
+               if (!d_evas_handle) {
+                       SETTING_TRACE("ERROR!! canNOT find /usr/lib/libevas.so.1");
+                       return false;
+               }
+       }
+
+       DYM_FUNC_LOADING(error, d_evas_handle, d_evas_init, "evas_init");
+       DYM_FUNC_LOADING(error, d_evas_handle, d_evas_object_image_add, "evas_object_image_add");
+       DYM_FUNC_LOADING(error, d_evas_handle, d_evas_object_image_file_set, "evas_object_image_file_set");
+       DYM_FUNC_LOADING(error, d_evas_handle, d_evas_object_image_load_error_get, "evas_object_image_load_err_get");
+       DYM_FUNC_LOADING(error, d_evas_handle, d_evas_shutdown, "evas_shutdown");
+
+       DYM_FUNC_LOADING(error, d_ecore_evas_handle, d_ecore_evas_new, "ecore_evas_new");
+       DYM_FUNC_LOADING(error, d_ecore_evas_handle, d_ecore_evas_get, "ecore_evas_get");
+       DYM_FUNC_LOADING(error, d_ecore_evas_handle, d_ecore_evas_free, "ecore_evas_free");
+
+       return true;
+}
+
+
 /* Returned family name should be free'd manually. */
 char *__get_main_font_family_name_by_alias(char *alias)
 {
@@ -75,46 +160,49 @@ char *__get_main_font_family_name_by_alias(char *alias)
        char *ret = NULL;
        FcResult res = 0;
 
-       font_config = FcInitLoadConfigAndFonts();
+       if (!loading_dym_font())
+               return NULL;
+
+       font_config = d_FcInitLoadConfigAndFonts();
        if (font_config == NULL)
                return ret;
 
-       pat = FcPatternBuild(0, FC_FAMILY, FcTypeString, alias, (char *)0);
+       pat = d_FcPatternBuild(0, FC_FAMILY, FcTypeString, alias, (char *)0);
 
        if (pat == NULL) {
                if (font_config != NULL) {
-                       FcConfigDestroy(font_config);
+                       d_FcConfigDestroy(font_config);
                        font_config = NULL;
                }
                return ret;
        }
 
-       FcConfigSubstitute(font_config, pat, FcMatchPattern);
-       FcDefaultSubstitute(pat);
+       d_FcConfigSubstitute(font_config, pat, FcMatchPattern);
+       d_FcDefaultSubstitute(pat);
 
        /* do matching */
-       set = FcFontSort(font_config, pat, FcTrue, NULL, &res);
+       set = d_FcFontSort(font_config, pat, FcTrue, NULL, &res);
 
        if (set != NULL && (set->nfont > 0)) {
-               FcPatternGetString(set->fonts[0], FC_FAMILY, 0, &family);
+               d_FcPatternGetString(set->fonts[0], FC_FAMILY, 0, &family);
                ret = g_strdup((char *)family);
 
-               FcFontSetDestroy(set);
+               d_FcFontSetDestroy(set);
                set = NULL;
        }
 
        if (set != NULL) {
-               FcFontSetDestroy(set);
+               d_FcFontSetDestroy(set);
                set = NULL;
        }
 
        if (pat != NULL) {
-               FcPatternDestroy(pat);
+               d_FcPatternDestroy(pat);
                pat = NULL;
        }
 
        if (font_config != NULL) {
-               FcConfigDestroy(font_config);
+               d_FcConfigDestroy(font_config);
                font_config = NULL;
        }
 
@@ -125,16 +213,20 @@ char *__get_main_font_family_name_by_alias(char *alias)
 bool __is_supported_image_type_load(char *path)
 {
        SETTING_TRACE_BEGIN;
-       evas_init();
+       loading_dym_efl();
+
        Ecore_Evas      *ee;
        Evas            *evas;
 
-       ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
-       evas = ecore_evas_get(ee);
+       if (!d_evas_init())
+               return false;
 
-       Evas_Object *img = evas_object_image_add(evas);
-       evas_object_image_file_set(img, path, NULL);
-       Evas_Load_Error ret = evas_object_image_load_error_get(img);
+       ee = d_ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
+       evas = d_ecore_evas_get(ee);
+
+       Evas_Object *img = d_evas_object_image_add(evas);
+       d_evas_object_image_file_set(img, path, NULL);
+       Evas_Load_Error ret = d_evas_object_image_load_error_get(img);
 
        bool result = false;
        if (ret == EVAS_LOAD_ERROR_NONE) {
@@ -144,8 +236,8 @@ bool __is_supported_image_type_load(char *path)
                SETTING_TRACE("%s - NO", path);
                result = false;
        }
-       ecore_evas_free(ee);
-       evas_shutdown();
+       d_ecore_evas_free(ee);
+       d_evas_shutdown();
        return result;
 }
 /*  LCOV_EXCL_STOP */
@@ -176,30 +268,32 @@ int __is_available_font(char *font_name)
        FcFontSet *fs = NULL;
        FcPattern *pat = NULL;
        FcConfig *font_config = NULL;
-
        int ret = 0;
 
+       if (!loading_dym_font())
+               return -1;
+
        if (font_name == NULL)
                return -1;
 
-       font_config = FcInitLoadConfigAndFonts();
+       font_config = d_FcInitLoadConfigAndFonts();
 
        /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
 
        char *locale = setlocale(0, NULL);
 
-       pat = FcPatternCreate();
+       pat = d_FcPatternCreate();
 
-       os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
+       os = d_FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
 
        if (os) {
-               fs = FcFontList(font_config, pat, os);
-               FcObjectSetDestroy(os);
+               fs = d_FcFontList(font_config, pat, os);
+               d_FcObjectSetDestroy(os);
                os = NULL;
        }
 
        if (pat) {
-               FcPatternDestroy(pat);
+               d_FcPatternDestroy(pat);
                pat = NULL;
        }
 
@@ -211,7 +305,7 @@ int __is_available_font(char *font_name)
                        FcChar8 *family = NULL;
                        FcChar8 *file = NULL;
 
-                       if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
+                       if (d_FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
                                int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
                                int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
 
@@ -220,10 +314,10 @@ int __is_available_font(char *font_name)
                                        char *family_result = NULL;
                                        FcChar8 *lang = NULL;
                                        int id = 0;
-                                       if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
+                                       if (d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
                                                break;
                                        }
-                                       if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
+                                       if (d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
                                                break;
                                        }
                                        family_result = (char *)family;
@@ -242,10 +336,10 @@ int __is_available_font(char *font_name)
                                                        family_result = (char *)family;
                                                }
                                                id++;
-                                               if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
+                                               if (d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
                                                        break;
                                                }
-                                               if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
+                                               if (d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
                                                        break;
                                                }
                                        }
@@ -260,10 +354,10 @@ int __is_available_font(char *font_name)
                                }
                        }
                }
-               FcFontSetDestroy(fs);
+               d_FcFontSetDestroy(fs);
                fs = NULL;
        }
-       FcConfigDestroy(font_config);
+       d_FcConfigDestroy(font_config);
        font_config = NULL;
        return ret;
 }