changeset 26710:605722f2c1b6

When building font pattern, treat both ' ' and '-' as word separators.
author eugeni
date Sun, 11 May 2008 20:17:21 +0000
parents 38d1fdb388f9
children 4be576db89df
files libass/ass_fontconfig.c
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_fontconfig.c	Sun May 11 19:49:57 2008 +0000
+++ b/libass/ass_fontconfig.c	Sun May 11 20:17:21 2008 +0000
@@ -105,13 +105,15 @@
 	// An alternative approach could be to reimplement FcFontSort
 	// using FC_FULLNAME instead of FC_FAMILY.
 	family_cnt = 1;
-	if (strchr(family, ' ')) {
-		char *p, *s = strdup(family);
-		while (p = strrchr(s, ' ')) {
-			*p = '\0';
-			FcPatternAddString(pat, FC_FAMILY, (const FcChar8*)s);
-			++ family_cnt;
-		}
+	{
+		char* s = strdup(family);
+		char* p = s + strlen(s);
+		while (--p > s)
+			if (*p == ' ' || *p == '-') {
+				*p = '\0';
+				FcPatternAddString(pat, FC_FAMILY, (const FcChar8*)s);
+				++ family_cnt;
+			}
 		free(s);
 	}
 	FcPatternAddBool(pat, FC_OUTLINE, FcTrue);