--- /dev/null
+/* * 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);
+
+
+
+
#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)
{
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;
}
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) {
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 */
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;
}
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);
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;
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;
}
}
}
}
}
- FcFontSetDestroy(fs);
+ d_FcFontSetDestroy(fs);
fs = NULL;
}
- FcConfigDestroy(font_config);
+ d_FcConfigDestroy(font_config);
font_config = NULL;
return ret;
}