From 4bb1c18835e8472aa6b3120fc8edf94db913e42f Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Fri, 4 Jan 2008 15:47:03 +0800 Subject: [PATCH] gdi32: Remove redundant indentation levels in CreateFontIndirectA and CreateFontIndirectW. --- dlls/gdi32/font.c | 111 ++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 59 deletions(-) diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 152f150c7ee..1c8f7da2bc8 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -432,12 +432,10 @@ HFONT WINAPI CreateFontIndirectA( const LOGFONTA *plfA ) { LOGFONTW lfW; - if (plfA) { - FONT_LogFontAToW( plfA, &lfW ); - return CreateFontIndirectW( &lfW ); - } else - return CreateFontIndirectW( NULL ); + if (!plfA) return 0; + FONT_LogFontAToW( plfA, &lfW ); + return CreateFontIndirectW( &lfW ); } /*********************************************************************** @@ -445,64 +443,59 @@ HFONT WINAPI CreateFontIndirectA( const LOGFONTA *plfA ) */ HFONT WINAPI CreateFontIndirectW( const LOGFONTW *plf ) { - HFONT hFont = 0; + static const WCHAR ItalicW[] = {' ','I','t','a','l','i','c','\0'}; + static const WCHAR BoldW[] = {' ','B','o','l','d','\0'}; + WCHAR *pFaceNameItalicSuffix, *pFaceNameBoldSuffix; + WCHAR *pFaceNameSuffix = NULL; + HFONT hFont; + FONTOBJ *fontPtr; - if (plf) + if (!plf) return 0; + + if (!(fontPtr = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC, (HGDIOBJ *)&hFont, + &font_funcs ))) return 0; + + memcpy( &fontPtr->logfont, plf, sizeof(LOGFONTW) ); + + TRACE("(%d %d %d %d %x %d %x %d %d) %s %s %s %s => %p\n", + plf->lfHeight, plf->lfWidth, + plf->lfEscapement, plf->lfOrientation, + plf->lfPitchAndFamily, + plf->lfOutPrecision, plf->lfClipPrecision, + plf->lfQuality, plf->lfCharSet, + debugstr_w(plf->lfFaceName), + plf->lfWeight > 400 ? "Bold" : "", + plf->lfItalic ? "Italic" : "", + plf->lfUnderline ? "Underline" : "", hFont); + + if (plf->lfEscapement != plf->lfOrientation) { - FONTOBJ* fontPtr; - if ((fontPtr = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC, - (HGDIOBJ *)&hFont, &font_funcs ))) - { - static const WCHAR ItalicW[] = {' ','I','t','a','l','i','c','\0'}; - static const WCHAR BoldW[] = {' ','B','o','l','d','\0'}; - WCHAR *pFaceNameItalicSuffix, *pFaceNameBoldSuffix; - WCHAR* pFaceNameSuffix = NULL; - - memcpy( &fontPtr->logfont, plf, sizeof(LOGFONTW) ); - - TRACE("(%d %d %d %d %x %d %x %d %d) %s %s %s %s => %p\n", - plf->lfHeight, plf->lfWidth, - plf->lfEscapement, plf->lfOrientation, - plf->lfPitchAndFamily, - plf->lfOutPrecision, plf->lfClipPrecision, - plf->lfQuality, plf->lfCharSet, - debugstr_w(plf->lfFaceName), - plf->lfWeight > 400 ? "Bold" : "", - plf->lfItalic ? "Italic" : "", - plf->lfUnderline ? "Underline" : "", hFont); - - if (plf->lfEscapement != plf->lfOrientation) { - /* this should really depend on whether GM_ADVANCED is set */ - fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement; - WARN("orientation angle %f set to " - "escapement angle %f for new font %p\n", - plf->lfOrientation/10., plf->lfEscapement/10., hFont); - } - - pFaceNameItalicSuffix = strstrW(fontPtr->logfont.lfFaceName, ItalicW); - if (pFaceNameItalicSuffix) { - fontPtr->logfont.lfItalic = TRUE; - pFaceNameSuffix = pFaceNameItalicSuffix; - } - - pFaceNameBoldSuffix = strstrW(fontPtr->logfont.lfFaceName, BoldW); - if (pFaceNameBoldSuffix) { - if (fontPtr->logfont.lfWeight < FW_BOLD) { - fontPtr->logfont.lfWeight = FW_BOLD; - } - if (!pFaceNameSuffix || - (pFaceNameBoldSuffix < pFaceNameSuffix)) { - pFaceNameSuffix = pFaceNameBoldSuffix; - } - } - - if (pFaceNameSuffix) *pFaceNameSuffix = 0; - - GDI_ReleaseObj( hFont ); - } + /* this should really depend on whether GM_ADVANCED is set */ + fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement; + WARN("orientation angle %f set to " + "escapement angle %f for new font %p\n", + plf->lfOrientation/10., plf->lfEscapement/10., hFont); } - else WARN("(NULL) => NULL\n"); + pFaceNameItalicSuffix = strstrW(fontPtr->logfont.lfFaceName, ItalicW); + if (pFaceNameItalicSuffix) + { + fontPtr->logfont.lfItalic = TRUE; + pFaceNameSuffix = pFaceNameItalicSuffix; + } + + pFaceNameBoldSuffix = strstrW(fontPtr->logfont.lfFaceName, BoldW); + if (pFaceNameBoldSuffix) + { + if (fontPtr->logfont.lfWeight < FW_BOLD) + fontPtr->logfont.lfWeight = FW_BOLD; + if (!pFaceNameSuffix || (pFaceNameBoldSuffix < pFaceNameSuffix)) + pFaceNameSuffix = pFaceNameBoldSuffix; + } + + if (pFaceNameSuffix) *pFaceNameSuffix = 0; + + GDI_ReleaseObj( hFont ); return hFont; }