From 9f4c01db4e281144574d76897eb70b556956adb9 Mon Sep 17 00:00:00 2001 From: dirk Date: Wed, 29 Jul 2015 12:10:38 +0000 Subject: [PATCH] Improved GetTypeInfoByFamily when the weight is not specified (zero). --- MagickCore/type.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/MagickCore/type.c b/MagickCore/type.c index f934e69b6..8b81c62bb 100644 --- a/MagickCore/type.c +++ b/MagickCore/type.c @@ -369,6 +369,7 @@ MagickExport const TypeInfo *GetTypeInfoByFamily(const char *family, }; size_t + font_weight, max_score, score; @@ -378,6 +379,7 @@ MagickExport const TypeInfo *GetTypeInfoByFamily(const char *family, (void) GetTypeInfo("*",exception); if (type_cache == (SplayTreeInfo *) NULL) return((TypeInfo *) NULL); + font_weight=weight == 0 ? 400 : weight; LockSemaphoreInfo(type_semaphore); ResetSplayTreeIterator(type_cache); type_info=(const TypeInfo *) NULL; @@ -415,7 +417,7 @@ MagickExport const TypeInfo *GetTypeInfoByFamily(const char *family, p=(const TypeInfo *) GetNextValueInSplayTree(type_cache); continue; } - if ((weight != 0) && (p->weight != weight)) + if (p->weight != font_weight) { p=(const TypeInfo *) GetNextValueInSplayTree(type_cache); continue; @@ -462,11 +464,8 @@ MagickExport const TypeInfo *GetTypeInfoByFamily(const char *family, if (((style == ItalicStyle) || (style == ObliqueStyle)) && ((p->style == ItalicStyle) || (p->style == ObliqueStyle))) score+=25; - if (weight == 0) - score+=16; - else - score+=(16*(800-((ssize_t) MagickMax(MagickMin(weight,900),p->weight)- - (ssize_t) MagickMin(MagickMin(weight,900),p->weight))))/800; + score+=(16*(800-((ssize_t) MagickMax(MagickMin(font_weight,900),p->weight)- + (ssize_t) MagickMin(MagickMin(font_weight,900),p->weight))))/800; if ((stretch == UndefinedStretch) || (stretch == AnyStretch)) score+=8; else -- 2.40.0