Clean up ps font weight matching and check for NULL
This commit is contained in:
parent
2ae95e77f7
commit
52253696cd
|
@ -634,34 +634,37 @@ FcFreeTypeQuery (const FcChar8 *file,
|
||||||
|
|
||||||
if (FT_Get_PS_Font_Info(face, &psfontinfo) == 0)
|
if (FT_Get_PS_Font_Info(face, &psfontinfo) == 0)
|
||||||
{
|
{
|
||||||
if (FcStrCmpIgnoreCase((FcChar8 *)"thin", (FcChar8 *) psfontinfo.weight) == 0)
|
if (psfontinfo.weight)
|
||||||
weight = FC_WEIGHT_THIN;
|
{
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"extralight", (FcChar8 *) psfontinfo.weight) == 0)
|
static struct {
|
||||||
weight = FC_WEIGHT_EXTRALIGHT;
|
char *name;
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"ultralight", (FcChar8 *) psfontinfo.weight) == 0)
|
int value;
|
||||||
weight = FC_WEIGHT_ULTRALIGHT;
|
} ps_weights[] = {
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"light", (FcChar8 *) psfontinfo.weight) == 0)
|
{ "thin", FC_WEIGHT_THIN },
|
||||||
weight = FC_WEIGHT_LIGHT;
|
{ "extralight", FC_WEIGHT_EXTRALIGHT },
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"regular", (FcChar8 *) psfontinfo.weight) == 0)
|
{ "ultralight", FC_WEIGHT_ULTRALIGHT },
|
||||||
weight = FC_WEIGHT_REGULAR;
|
{ "light", FC_WEIGHT_LIGHT },
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"normal", (FcChar8 *) psfontinfo.weight) == 0)
|
{ "regular", FC_WEIGHT_REGULAR },
|
||||||
weight = FC_WEIGHT_NORMAL;
|
{ "normal", FC_WEIGHT_NORMAL },
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"medium", (FcChar8 *) psfontinfo.weight) == 0)
|
{ "medium", FC_WEIGHT_MEDIUM },
|
||||||
weight = FC_WEIGHT_MEDIUM;
|
{ "demibold", FC_WEIGHT_DEMIBOLD },
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"demibold", (FcChar8 *) psfontinfo.weight) == 0)
|
{ "semibold", FC_WEIGHT_SEMIBOLD },
|
||||||
weight = FC_WEIGHT_DEMIBOLD;
|
{ "bold", FC_WEIGHT_BOLD },
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"semibold", (FcChar8 *) psfontinfo.weight) == 0)
|
{ "extrabold", FC_WEIGHT_EXTRABOLD },
|
||||||
weight = FC_WEIGHT_SEMIBOLD;
|
{ "ultrabold", FC_WEIGHT_ULTRABOLD },
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"extrabold", (FcChar8 *) psfontinfo.weight) == 0)
|
{ "black", FC_WEIGHT_BLACK },
|
||||||
weight = FC_WEIGHT_EXTRABOLD;
|
{ "heavy", FC_WEIGHT_HEAVY },
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"ultrabold", (FcChar8 *) psfontinfo.weight) == 0)
|
};
|
||||||
weight = FC_WEIGHT_EXTRABOLD;
|
#define NUM_PS_WEIGHTS (sizeof (ps_weights) / sizeof (ps_weights[0]))
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"bold", (FcChar8 *) psfontinfo.weight) == 0)
|
int w;
|
||||||
weight = FC_WEIGHT_BOLD;
|
for (w = 0; w < NUM_PS_WEIGHTS; w++)
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"black", (FcChar8 *) psfontinfo.weight) == 0)
|
if (!FcStrCmpIgnoreCase ((FcChar8 *) ps_weights[w].name,
|
||||||
weight = FC_WEIGHT_BLACK;
|
(FcChar8 *) psfontinfo.weight))
|
||||||
else if (FcStrCmpIgnoreCase((FcChar8 *)"heavy", (FcChar8 *) psfontinfo.weight) == 0)
|
{
|
||||||
weight = FC_WEIGHT_BLACK;
|
weight = ps_weights[w].value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (psfontinfo.italic_angle < 0)
|
if (psfontinfo.italic_angle < 0)
|
||||||
slant = FC_SLANT_ITALIC;
|
slant = FC_SLANT_ITALIC;
|
||||||
|
|
Loading…
Reference in New Issue