#define SETTING_FONT_DOWNLOADED_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
#define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
-#define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
+
+#define SETTING_FONT_TIZEN_FONT_ALIAS "Tizen"
+#define SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS "TizenDefaultFont"
static int __font_size_get();
+/* Returned family name should be free'd manually. */
+char *__get_main_font_family_name_by_alias(char *alias)
+{
+ SETTING_TRACE_BEGIN;
+ FcFontSet *set = NULL;
+ FcPattern *pat = NULL;
+ FcConfig *font_config = NULL;
+ FcChar8 *family = NULL;
+ char *ret = NULL;
+ FcResult res = 0;
+
+ font_config = FcInitLoadConfigAndFonts();
+
+ pat = FcPatternBuild(0, FC_FAMILY, FcTypeString, alias, (char *)0);
+ FcConfigSubstitute(font_config, pat, FcMatchPattern);
+ FcDefaultSubstitute(pat);
+
+ /* do matching */
+ set = FcFontSort(font_config, pat, FcTrue, NULL, &res);
+
+ if (set && (set->nfont > 0)) {
+ FcPatternGetString(set->fonts[0], FC_FAMILY, 0, &family);
+ ret = g_strdup((char *)family);
+
+ FcFontSetDestroy(set);
+ set = NULL;
+ }
+
+ if (pat) {
+ FcPatternDestroy(pat);
+ pat = NULL;
+ }
+
+ FcConfigDestroy(font_config);
+ font_config = NULL;
+
+ return ret;
+}
+
/* LCOV_EXCL_START */
bool __is_supported_image_type_load(char *path)
{
char *_get_cur_font()
{
- SETTING_TRACE_BEGIN;
- xmlDocPtr doc = NULL;
- xmlNodePtr cur = NULL;
- xmlNodePtr cur2 = NULL;
- xmlNodePtr cur3 = NULL;
- xmlChar *key = NULL;
-
- char *font_name = NULL;
-
- doc = xmlParseFile(SETTING_FONT_CONF_FILE);
-
- cur = xmlDocGetRootElement(doc);
-
- if (cur == NULL) {
- xmlFreeDoc(doc);
- doc = NULL;
- return NULL;
- }
-
- if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
- xmlFreeDoc(doc);
- doc = NULL;
- return NULL;
- }
-
- cur = cur->xmlChildrenNode;
-
- while (cur != NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
- cur2 = cur->xmlChildrenNode;
- while (cur2 != NULL) {
- if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
- cur3 = cur2->xmlChildrenNode;
- while (cur3 != NULL) {
- if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
- key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
-
- font_name = g_strdup((char *)key);
- xmlFree(key);
- key = NULL;
- xmlFreeDoc(doc);
- doc = NULL;
- return font_name;
- }
- cur3 = cur3->next;
- }
- }
- cur2 = cur2->next;
- }
- }
- cur = cur->next;
- }
-
- xmlFreeDoc(doc);
- doc = NULL;
- return NULL;
+ return __get_main_font_family_name_by_alias(SETTING_FONT_TIZEN_FONT_ALIAS);
}
/* LCOV_EXCL_START */
char *_get_default_font()
{
- SETTING_TRACE_BEGIN;
- xmlDocPtr doc = NULL;
- xmlNodePtr cur = NULL;
- xmlNodePtr cur2 = NULL;
- xmlNodePtr cur3 = NULL;
- xmlChar *key = NULL;
- struct _xmlAttr *properties = NULL;
- char *default_font_name = NULL;
-
- doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
-
- cur = xmlDocGetRootElement(doc);
-
- if (cur == NULL) {
- xmlFreeDoc(doc);
- doc = NULL;
- return NULL;
- }
-
- if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
- xmlFreeDoc(doc);
- doc = NULL;
- return NULL;
- }
-
- cur = cur->xmlChildrenNode;
-
- while (cur != NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
- cur2 = cur->xmlChildrenNode;
- while (cur2 != NULL) {
- if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
- properties = cur2->properties;
- /*find the "name" property*/
- while (NULL != properties) {
- if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
- break;
- }
- properties = properties->next;
- }
-
- /*If the value of "name" property is "family", then get the child node string,
- it shall be the default font type*/
- if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
- cur3 = cur2->xmlChildrenNode;
- while (cur3 != NULL) {
- if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
- key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
- default_font_name = g_strdup((char *)key);
- xmlFree(key);
- key = NULL;
- xmlFreeDoc(doc);
- doc = NULL;
- return default_font_name;
- }
- cur3 = cur3->next;
- }
- }
- }
- cur2 = cur2->next;
- }
- }
- cur = cur->next;
- }
-
- xmlFreeDoc(doc);
- doc = NULL;
- return NULL;
+ return __get_main_font_family_name_by_alias(SETTING_FONT_TIZEN_DEFAULT_FONT_ALIAS);
}
/* LCOV_EXCL_START */