gdi32: Fix logical error of italic, bold determination.

This commit is contained in:
Byeong-Sik Jeon 2006-08-29 15:21:52 +09:00 committed by Alexandre Julliard
parent 95226bf25d
commit 4d619723a1
1 changed files with 32 additions and 47 deletions

View File

@ -2242,10 +2242,11 @@ static BOOL create_child_font_list(GdiFont font)
GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
{ {
GdiFont ret; GdiFont ret;
Face *face, *best; Face *face, *best, *best_bitmap;
Family *family, *last_resort_family; Family *family, *last_resort_family;
struct list *family_elem_ptr, *face_elem_ptr; struct list *family_elem_ptr, *face_elem_ptr;
INT height, width = 0; INT height, width = 0;
unsigned int score = 0, new_score;
signed int diff = 0, newdiff; signed int diff = 0, newdiff;
BOOL bd, it, can_use_bitmap; BOOL bd, it, can_use_bitmap;
LOGFONTW lf; LOGFONTW lf;
@ -2432,57 +2433,41 @@ found:
height = GDI_ROUND( (FLOAT)lf.lfHeight * dc->xformWorld2Vport.eM22 ); height = GDI_ROUND( (FLOAT)lf.lfHeight * dc->xformWorld2Vport.eM22 );
height = lf.lfHeight < 0 ? -abs(height) : abs(height); height = lf.lfHeight < 0 ? -abs(height) : abs(height);
face = best = NULL; face = best = best_bitmap = NULL;
LIST_FOR_EACH(face_elem_ptr, &family->faces) { LIST_FOR_EACH_ENTRY(face, &family->faces, Face, entry)
face = LIST_ENTRY(face_elem_ptr, Face, entry); {
if(!(face->Italic ^ it) && !(face->Bold ^ bd) && if((csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.fsCsb[0])) || !csi.fs.fsCsb[0])
((csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.fsCsb[0])) || !csi.fs.fsCsb[0])) { {
if(face->scalable) new_score = (face->Italic ^ it) + (face->Bold ^ bd);
break; if(!best || new_score <= score)
if(height > 0) {
newdiff = height - (signed int)(face->size.height); TRACE("(it=%d, bd=%d) is selected for (it=%d, bd=%d)\n",
else face->Italic, face->Bold, it, bd);
newdiff = -height - ((signed int)(face->size.height) - face->size.internal_leading); score = new_score;
if(!best || (diff > 0 && newdiff < diff && newdiff >= 0) ||
(diff < 0 && newdiff > diff)) {
TRACE("%d is better for %d diff was %d\n", face->size.height, height, diff);
diff = newdiff;
best = face; best = face;
if(diff == 0) if(best->scalable && score == 0) break;
break; if(!best->scalable)
} {
} if(height > 0)
face = NULL; newdiff = height - (signed int)(best->size.height);
} else
if(!face && best) newdiff = -height - ((signed int)(best->size.height) - best->size.internal_leading);
face = best; if(!best_bitmap || new_score < score ||
else if(!face) { (diff > 0 && newdiff < diff && newdiff >= 0) || (diff < 0 && newdiff > diff))
best = NULL; {
LIST_FOR_EACH(face_elem_ptr, &family->faces) { TRACE("%d is better for %d diff was %d\n", best->size.height, height, diff);
face = LIST_ENTRY(face_elem_ptr, Face, entry); diff = newdiff;
if((csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.fsCsb[0])) || !csi.fs.fsCsb[0]) { best_bitmap = best;
if(face->scalable) if(score == 0 && diff == 0) break;
break; }
if(height > 0)
newdiff = height - (signed int)(face->size.height);
else
newdiff = -height - ((signed int)(face->size.height) - face->size.internal_leading);
if(!best || (diff > 0 && newdiff < diff && newdiff >= 0) ||
(diff < 0 && newdiff > diff)) {
TRACE("%d is better for %d diff was %d\n", face->size.height, height, diff);
diff = newdiff;
best = face;
if(diff == 0)
break;
} }
} }
face = NULL;
} }
if(!face && best)
face = best;
if(it && !face->Italic) ret->fake_italic = TRUE;
if(bd && !face->Bold) ret->fake_bold = TRUE;
} }
if(best)
face = best->scalable ? best : best_bitmap;
ret->fake_italic = (it && !face->Italic);
ret->fake_bold = (bd && !face->Bold);
memcpy(&ret->fs, &face->fs, sizeof(FONTSIGNATURE)); memcpy(&ret->fs, &face->fs, sizeof(FONTSIGNATURE));