+/*
+To support different variable product, font_scale.json is added.
+With %config option in .spec file, the font_scale.json can be
+uploaded only when there is no the font_scale.json in /etc.
+
+In font_scale.json, there are 5 grade of font size, below.
+
+$ cat /etc/font_scale.json
+{
+ "SMALL" : -80,
+ "NORMAL" : -100,
+ "LARGE" : -150,
+ "HUGE" : -190,
+ "GIANT" : -250
+}
+
+-80 means that 80% font scale of each application font size.
+Each grade is mapping, below.
+
+SYSTEM_SETTINGS_FONT_SIZE_SMALL == "SMALL" in font_scale.json value
+SYSTEM_SETTINGS_FONT_SIZE_NORMAL == "NORMAL" in font_scale.json value
+SYSTEM_SETTINGS_FONT_SIZE_LARGE == "LARGE" in font_scale.json value
+SYSTEM_SETTINGS_FONT_SIZE_HUGE == "HUGE" in font_scale.json value
+SYSTEM_SETTINGS_FONT_SIZE_GIANT == "GIANT" in font_scale.json value
+*/
+
+static int get_int_from_object(JsonObject *obj, const char *key, int *data)
+{
+ JsonNode *tmp = json_object_get_member(obj, key);
+
+ if (tmp == NULL){
+ ERR("json_object_object_get_ex(key:%s) error", key);
+ return -EINVAL;
+ }
+
+ int tmp_int = json_node_get_int(tmp);
+ if (tmp_int < 0) {
+ *data = tmp_int;
+ } else {
+ ERR("%s key Wrong value : %d ", key, tmp_int);
+ }
+
+ return 0;
+}
+
+INTERNAL_API int load_font_size_info(font_size_info *info, const gchar *path)
+{
+ GError *error = NULL;
+
+ if (info == NULL)
+ return -EINVAL;
+
+ info->small = SMALL_FONT_DPI;
+ info->normal = MIDDLE_FONT_DPI;
+ info->large = LARGE_FONT_DPI;
+ info->huge = HUGE_FONT_DPI;
+ info->giant = GIANT_FONT_DPI;
+
+ JsonParser *parser = json_parser_new();
+ json_parser_load_from_file (parser, path, &error);
+ /* Parse configuration file */
+ if (error) {
+ INFO("There is no json_object file(%s), loaded default font size values", path);
+ return 0;
+ }
+
+ JsonObject *obj = json_node_get_object(json_parser_get_root (parser));
+ INFO("json_object file(%s) OPENED! Try to load font size values from the file.", path);
+ get_int_from_object(obj, "SMALL", &info->small);
+ get_int_from_object(obj, "NORMAL", &info->normal);
+ get_int_from_object(obj, "LARGE", &info->large);
+ get_int_from_object(obj, "HUGE", &info->huge);
+ get_int_from_object(obj, "GIANT", &info->giant);
+
+ g_object_unref(parser);
+
+ return 0;
+}
+