Behdad Esfahbod
2010-Sep-21 17:19 UTC
[Fontconfig] fontconfig: Branch ''master'' - 3 commits
doc/fccharset.fncs | 11 +++++++++++ fc-lang/fc-lang.c | 35 +++++++++++++++++++++++++---------- fc-lang/ne.orth | 1 + fontconfig/fontconfig.h | 3 +++ src/fccharset.c | 17 +++++++++++++++++ 5 files changed, 57 insertions(+), 10 deletions(-) New commits: commit caa4bec9459af0779d1d16ba66964593e5748e3c Author: Behdad Esfahbod <behdad at behdad.org> Date: Tue Sep 21 13:18:05 2010 -0400 Bug 24729 - [ne_NP] Fix ortho file Exclude three characters (U+090C..090E) from Nepalese. diff --git a/fc-lang/ne.orth b/fc-lang/ne.orth index 18cf011..8aad4e2 100644 --- a/fc-lang/ne.orth +++ b/fc-lang/ne.orth @@ -23,3 +23,4 @@ # # Nepali (Devanagari script) (NE) include hi.orth +-090C-090E # See bug 30685 commit 0a023b24daa683d9c0be4e2ef6d50040c1c52316 Author: Behdad Esfahbod <behdad at behdad.org> Date: Tue Sep 21 13:14:55 2010 -0400 [fc-lang] Support excluding characters By prefixing a line by a hyphen/minus sign. Useful when including other orth files. diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c index c01fe68..26f1454 100644 --- a/fc-lang/fc-lang.c +++ b/fc-lang/fc-lang.c @@ -76,10 +76,14 @@ fatal (const char *file, int lineno, const char *msg) } static char * -get_line (FILE *f, char *line, int *lineno) +get_line (FILE *f, char *buf, int *lineno) { char *hash; + char *line; int end; + +next: + line = buf; if (!fgets (line, 1024, f)) return 0; ++(*lineno); @@ -87,12 +91,15 @@ get_line (FILE *f, char *line, int *lineno) if (hash) *hash = ''\0''; + while (line[0] && isspace (line[0])) + line++; end = strlen (line); while (end > 0 && isspace (line[end-1])) line[--end] = ''\0''; - if (line[0] == ''\0'' || line[0] == ''\n'' || line[0] == ''\032'' || line[0] == ''\r'') - return get_line (f, line, lineno); + if (line[0] == ''\0'' || line[0] == ''\n'' || line[0] == ''\r'') + goto next; + return line; } @@ -125,16 +132,18 @@ scanopen (char *file) * Comments begin with ''#'' */ -static const FcCharSet * +static FcCharSet * scan (FILE *f, char *file, FcCharSetFreezer *freezer) { FcCharSet *c = 0; FcCharSet *n; + FcBool del; int start, end, ucs4; - char line[1024]; + char buf[1024]; + char *line; int lineno = 0; - while (get_line (f, line, &lineno)) + while ((line = get_line (f, buf, &lineno))) { if (!strncmp (line, "include", 7)) { @@ -158,6 +167,12 @@ scan (FILE *f, char *file, FcCharSetFreezer *freezer) FcCharSetDestroy (n); continue; } + del = FcFalse; + if (line[0] == ''-'') + { + del = FcTrue; + line++; + } if (strchr (line, ''-'')) { if (sscanf (line, "%x-%x", &start, &end) != 2) @@ -173,7 +188,7 @@ scan (FILE *f, char *file, FcCharSetFreezer *freezer) c = FcCharSetCreate (); for (ucs4 = start; ucs4 <= end; ucs4++) { - if (!FcCharSetAddChar (c, ucs4)) + if (!((del ? FcCharSetDelChar : FcCharSetAddChar) (c, ucs4))) fatal (file, lineno, "out of memory"); } } @@ -231,8 +246,8 @@ typedef struct _Entry { static int compare (const void *a, const void *b) { - const Entry const *as = a, *bs = b; - return FcStrCmpIgnoreCase (as->file, bs->file); + const Entry *as = a, *bs = b; + return FcStrCmpIgnoreCase ((const FcChar8 *) as->file, (const FcChar8 *) bs->file); } #define MAX_LANG 1024 @@ -245,7 +260,7 @@ int main (int argc, char **argv) { static Entry entries[MAX_LANG]; - static const FcCharSet *sets[MAX_LANG]; + static FcCharSet *sets[MAX_LANG]; static int duplicate[MAX_LANG]; static int country[MAX_LANG]; static char *names[MAX_LANG]; commit 52960d05ebb8af34a302e3959978d2930a39fb39 Author: Behdad Esfahbod <behdad at behdad.org> Date: Tue Sep 21 13:14:41 2010 -0400 Add new public API: FcCharSetDelChar() diff --git a/doc/fccharset.fncs b/doc/fccharset.fncs index b12064a..004fdc3 100644 --- a/doc/fccharset.fncs +++ b/doc/fccharset.fncs @@ -51,6 +51,17 @@ returning FcFalse on failure, either as a result of a constant set or from running out of memory. @@ + at RET@ FcBool + at FUNC@ FcCharSetDelChar + at TYPE1@ FcCharSet * @ARG1@ fcs + at TYPE2@ FcChar32% @ARG2@ ucs4 + at PURPOSE@ Add a character to a charset + at DESC@ +<function>FcCharSetDelChar</function> deletes a single unicode char from the set, +returning FcFalse on failure, either as a result of a constant set or from +running out of memory. +@@ + @RET@ FcCharSet * @FUNC@ FcCharSetCopy @TYPE1@ FcCharSet * @ARG1@ src diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index c9f20cc..6a6d511 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -423,6 +423,9 @@ FcCharSetDestroy (FcCharSet *fcs); FcPublic FcBool FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4); +FcPublic FcBool +FcCharSetDelChar (FcCharSet *fcs, FcChar32 ucs4); + FcPublic FcCharSet* FcCharSetCopy (FcCharSet *src); diff --git a/src/fccharset.c b/src/fccharset.c index 9228b09..14e4c3c 100644 --- a/src/fccharset.c +++ b/src/fccharset.c @@ -262,6 +262,23 @@ FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4) return FcTrue; } +FcBool +FcCharSetDelChar (FcCharSet *fcs, FcChar32 ucs4) +{ + FcCharLeaf *leaf; + FcChar32 *b; + + if (fcs->ref == FC_REF_CONSTANT) + return FcFalse; + leaf = FcCharSetFindLeaf (fcs, ucs4); + if (!leaf) + return FcTrue; + b = &leaf->map[(ucs4 & 0xff) >> 5]; + *b &= ~(1 << (ucs4 & 0x1f)); + /* We don''t bother removing the leaf if it''s empty */ + return FcTrue; +} + /* * An iterator for the leaves of a charset */