Commits

Akira TAGOH  committed 0ad57bf

Fix the unexpected error when a font has a family name in the native language at first place

  • Participants
  • Parent commits ba06d20

Comments (0)

Files changed (1)

File libeasyfc/ezfc-font.c

 	}
 	if ((match = FcFontMatch(NULL, pat, &result))) {
 		FcChar8 *v1, *v2;
+		int i;
 
 		if (FcPatternGetString(pat, FC_FAMILY, 0, &v1) != FcResultMatch) {
 			g_set_error(&err, EZFC_ERROR, EZFC_ERR_NO_FAMILY,
 			retval = FALSE;
 			goto bail1;
 		}
-		if (FcPatternGetString(match, FC_FAMILY, 0, &v2) != FcResultMatch) {
-			g_set_error(&err, EZFC_ERROR, EZFC_ERR_NO_FAMILY,
-				    "Pattern doesn't contain any family name");
-			retval = FALSE;
-			goto bail1;
-		}
-		if (FcStrCmpIgnoreCase(v1, v2) == 0) {
-			retval = ezfc_font_set_pattern(font, pat, &err);
-		} else {
-			g_set_error(&err, EZFC_ERROR, EZFC_ERR_NO_VALID_FONT,
-				    "No such fonts available: %s",
-				    font_name);
-			retval = FALSE;
-			goto bail1;
+		/* may need to check all of values assigned to the specific object
+		 * because it might contains multiple values. e.g. family name in
+		 * different language.
+		 */
+		for (i = 0; ; i++) {
+			if (FcPatternGetString(match, FC_FAMILY, i, &v2) != FcResultMatch) {
+				if (i == 0)
+					g_set_error(&err, EZFC_ERROR, EZFC_ERR_NO_FAMILY,
+						    "Pattern doesn't contain any family name");
+				else
+					g_set_error(&err, EZFC_ERROR, EZFC_ERR_NO_VALID_FONT,
+						    "No such fonts available: %s",
+						    font_name);
+				retval = FALSE;
+				goto bail1;
+			}
+			if (FcStrCmpIgnoreCase(v1, v2) == 0) {
+				retval = ezfc_font_set_pattern(font, pat, &err);
+				break;
+			}
 		}
 	  bail1:
 		FcPatternDestroy(match);