back: c89 compat.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@32882 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2011-04-17 23:08:30 +00:00
parent 2c49f918f2
commit 575901b00d
2 changed files with 49 additions and 37 deletions

View file

@ -1,3 +1,8 @@
2011-04-17 Eric Wasylishen <ewasylishen@gmail.com>
* Source/cairo/CairoFontEnumerator.m: Remove declarations after
statements for c89 compatability
2011-04-17 Eric Wasylishen <ewasylishen@gmail.com> 2011-04-17 Eric Wasylishen <ewasylishen@gmail.com>
* Source/cairo/CairoFontEnumerator.m: Replace * Source/cairo/CairoFontEnumerator.m: Replace

View file

@ -263,8 +263,9 @@ static NSArray *faFromFc(FcPattern *pat)
} }
else else
{ {
FcFontSet *fontSet;
result = FcResultMatch; result = FcResultMatch;
FcFontSet *fontSet = FcFontSort(NULL, matchedpat, FcFalse, NULL, &result); fontSet = FcFontSort(NULL, matchedpat, FcFalse, NULL, &result);
if (result == FcResultMatch) if (result == FcResultMatch)
{ {
int i; int i;
@ -403,12 +404,12 @@ static NSArray *faFromFc(FcPattern *pat)
} }
if (symTraits & NSFontMonoSpaceTrait) if (symTraits & NSFontMonoSpaceTrait)
{ {
FcValue value;
// If you run "fc-match :spacing=100", you get "DejaVu Sans" even though you would // If you run "fc-match :spacing=100", you get "DejaVu Sans" even though you would
// expect to get "DejaVu Sans Mono". So, we also add "monospace" as a weak family // expect to get "DejaVu Sans Mono". So, we also add "monospace" as a weak family
// name to fix the problem. // name to fix the problem.
FcPatternAddInteger(_pat, FC_SPACING, FC_MONO); FcPatternAddInteger(_pat, FC_SPACING, FC_MONO);
FcValue value;
value.type = FcTypeString; value.type = FcTypeString;
value.u.s = (FcChar8*)"monospace"; value.u.s = (FcChar8*)"monospace";
FcPatternAddWeak(_pat, FC_FAMILY, value, FcTrue); FcPatternAddWeak(_pat, FC_FAMILY, value, FcTrue);
@ -422,6 +423,7 @@ static NSArray *faFromFc(FcPattern *pat)
// NOTE: Fontconfig can't express this // NOTE: Fontconfig can't express this
} }
{
NSFontFamilyClass class = symTraits & NSFontFamilyClassMask; NSFontFamilyClass class = symTraits & NSFontFamilyClassMask;
char *addWeakFamilyName = NULL; char *addWeakFamilyName = NULL;
switch (class) switch (class)
@ -453,6 +455,7 @@ static NSArray *faFromFc(FcPattern *pat)
FcPatternAddWeak(_pat, FC_FAMILY, value, FcTrue); FcPatternAddWeak(_pat, FC_FAMILY, value, FcTrue);
} }
} }
}
if ([traits objectForKey: NSFontWeightTrait]) if ([traits objectForKey: NSFontWeightTrait])
{ {
@ -460,8 +463,9 @@ static NSArray *faFromFc(FcPattern *pat)
* Scale: -1 is thinnest, 0 is normal, 1 is heaviest * Scale: -1 is thinnest, 0 is normal, 1 is heaviest
*/ */
double weight = [[traits objectForKey: NSFontWeightTrait] doubleValue]; double weight = [[traits objectForKey: NSFontWeightTrait] doubleValue];
weight = MAX(-1, MIN(1, weight));
int fcWeight; int fcWeight;
weight = MAX(-1, MIN(1, weight));
if (weight <= 0) if (weight <= 0)
{ {
fcWeight = FC_WEIGHT_THIN + ((weight + 1.0) * (FC_WEIGHT_NORMAL - FC_WEIGHT_THIN)); fcWeight = FC_WEIGHT_THIN + ((weight + 1.0) * (FC_WEIGHT_NORMAL - FC_WEIGHT_THIN));
@ -479,8 +483,9 @@ static NSArray *faFromFc(FcPattern *pat)
* Scale: -1 is most condensed, 0 is normal, 1 is most spread apart * Scale: -1 is most condensed, 0 is normal, 1 is most spread apart
*/ */
double width = [[traits objectForKey: NSFontWidthTrait] doubleValue]; double width = [[traits objectForKey: NSFontWidthTrait] doubleValue];
width = MAX(-1, MIN(1, width));
int fcWidth; int fcWidth;
width = MAX(-1, MIN(1, width));
if (width <= 0) if (width <= 0)
{ {
fcWidth = FC_WIDTH_ULTRACONDENSED + ((width + 1.0) * (FC_WIDTH_NORMAL - FC_WIDTH_ULTRACONDENSED)); fcWidth = FC_WIDTH_ULTRACONDENSED + ((width + 1.0) * (FC_WIDTH_NORMAL - FC_WIDTH_ULTRACONDENSED));
@ -672,12 +677,13 @@ static NSArray *faFromFc(FcPattern *pat)
} }
if (FcResultMatch == FcPatternGetInteger(pat, FC_WEIGHT, 0, &value)) if (FcResultMatch == FcPatternGetInteger(pat, FC_WEIGHT, 0, &value))
{ {
double weight;
if (value >= FC_WEIGHT_BOLD) if (value >= FC_WEIGHT_BOLD)
{ {
symTraits |= NSFontBoldTrait; symTraits |= NSFontBoldTrait;
} }
double weight;
if (value <= FC_WEIGHT_NORMAL) if (value <= FC_WEIGHT_NORMAL)
{ {
weight = ((value - FC_WEIGHT_THIN) / (double)(FC_WEIGHT_NORMAL - FC_WEIGHT_THIN)) - 1.0; weight = ((value - FC_WEIGHT_THIN) / (double)(FC_WEIGHT_NORMAL - FC_WEIGHT_THIN)) - 1.0;
@ -692,6 +698,8 @@ static NSArray *faFromFc(FcPattern *pat)
} }
if (FcResultMatch == FcPatternGetInteger(pat, FC_WIDTH, 0, &value)) if (FcResultMatch == FcPatternGetInteger(pat, FC_WIDTH, 0, &value))
{ {
double width;
if (value >= FC_WIDTH_EXPANDED) if (value >= FC_WIDTH_EXPANDED)
{ {
symTraits |= NSFontExpandedTrait; symTraits |= NSFontExpandedTrait;
@ -701,7 +709,6 @@ static NSArray *faFromFc(FcPattern *pat)
symTraits |= NSFontCondensedTrait; symTraits |= NSFontCondensedTrait;
} }
double width;
if (value <= FC_WIDTH_NORMAL) if (value <= FC_WIDTH_NORMAL)
{ {
width = ((value - FC_WIDTH_ULTRACONDENSED) / (double)(FC_WIDTH_NORMAL - FC_WIDTH_ULTRACONDENSED)) - 1.0; width = ((value - FC_WIDTH_ULTRACONDENSED) / (double)(FC_WIDTH_NORMAL - FC_WIDTH_ULTRACONDENSED)) - 1.0;