* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* each value, earlier values are more significant than
* later values
*/
-static FcMatcher _FcMatchers [] = {
+static const FcMatcher _FcMatchers [] = {
{ FC_FOUNDRY_OBJECT, FcCompareString, 0, 0 },
#define MATCH_FOUNDRY 0
#define MATCH_FOUNDRY_INDEX 0
return new;
}
-FcPattern *
-FcFontSetMatch (FcConfig *config,
- FcFontSet **sets,
- int nsets,
- FcPattern *p,
- FcResult *result)
+static FcPattern *
+FcFontSetMatchInternal (FcConfig *config,
+ FcFontSet **sets,
+ int nsets,
+ FcPattern *p,
+ FcResult *result)
{
double score[NUM_MATCH_VALUES], bestscore[NUM_MATCH_VALUES];
int f;
printf ("Match ");
FcPatternPrint (p);
}
- if (!config)
- {
- config = FcConfigGetCurrent ();
- if (!config)
- return 0;
- }
for (set = 0; set < nsets; set++)
{
s = sets[set];
*result = FcResultNoMatch;
return 0;
}
- return FcFontRenderPrepare (config, p, best);
+ return best;
+}
+
+FcPattern *
+FcFontSetMatch (FcConfig *config,
+ FcFontSet **sets,
+ int nsets,
+ FcPattern *p,
+ FcResult *result)
+{
+ FcPattern *best;
+
+ if (!config)
+ {
+ config = FcConfigGetCurrent ();
+ if (!config)
+ return 0;
+ }
+ best = FcFontSetMatchInternal (config, sets, nsets, p, result);
+ if (best)
+ return FcFontRenderPrepare (config, p, best);
+ else
+ return NULL;
}
FcPattern *
{
FcFontSet *sets[2];
int nsets;
+ FcPattern *best;
if (!config)
{
sets[nsets++] = config->fonts[FcSetSystem];
if (config->fonts[FcSetApplication])
sets[nsets++] = config->fonts[FcSetApplication];
- return FcFontSetMatch (config, sets, nsets, p, result);
+
+ best = FcFontSetMatchInternal (config, sets, nsets, p, result);
+ if (best)
+ return FcFontRenderPrepare (config, p, best);
+ else
+ return NULL;
}
typedef struct _FcSortNode {
}
static FcBool
-FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool trim, FcBool build_cs)
+FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **csp, FcBool trim)
{
- FcCharSet *ncs;
- FcSortNode *node;
+ FcBool ret = FcFalse;
+ FcCharSet *cs;
+
+ cs = 0;
+ if (trim || csp)
+ {
+ cs = FcCharSetCreate ();
+ if (cs == NULL)
+ goto bail;
+ }
while (nnode--)
{
- node = *n++;
+ FcSortNode *node = *n++;
+ FcBool adds_chars = FcFalse;
/*
* Only fetch node charset if we'd need it
*/
- if (trim || build_cs)
+ if (cs)
{
+ FcCharSet *ncs;
+
if (FcPatternGetCharSet (node->pattern, FC_CHARSET, 0, &ncs) !=
FcResultMatch)
continue;
+
+ if (!FcCharSetMerge (cs, ncs, &adds_chars))
+ goto bail;
}
/*
* If this font isn't a subset of the previous fonts,
* add it to the list
*/
- if (!trim || !*cs || !FcCharSetIsSubset (ncs, *cs))
+ if (!trim || adds_chars)
{
- if (trim || build_cs)
- {
- *cs = FcCharSetMerge (*cs, ncs);
- if (*cs == NULL)
- return FcFalse;
- }
-
FcPatternReference (node->pattern);
if (FcDebug () & FC_DBG_MATCHV)
{
if (!FcFontSetAdd (fs, node->pattern))
{
FcPatternDestroy (node->pattern);
- return FcFalse;
+ goto bail;
}
}
}
- return FcTrue;
+ if (csp)
+ {
+ *csp = cs;
+ cs = 0;
+ }
+
+ ret = FcTrue;
+
+bail:
+ if (cs)
+ FcCharSetDestroy (cs);
+
+ return ret;
}
void
FcSortNode **nodeps, **nodep;
int nnodes;
FcSortNode *new;
- FcCharSet *cs;
int set;
int f;
int i;
if (!ret)
goto bail1;
- cs = 0;
-
- if (!FcSortWalk (nodeps, nnodes, ret, &cs, trim, (csp!=0)))
+ if (!FcSortWalk (nodeps, nnodes, ret, csp, trim))
goto bail2;
- if (csp)
- *csp = cs;
- else
- {
- if (cs)
- FcCharSetDestroy (cs);
- }
-
free (nodes);
if (FcDebug() & FC_DBG_MATCH)
return ret;
bail2:
- if (cs)
- FcCharSetDestroy (cs);
FcFontSetDestroy (ret);
bail1:
free (nodes);