===========================================================================
| 111 | |
| 112 | //=========================================================================== |
| 113 | bool _CmdConfigFont(int iFont, LPCSTR pFontName, int iPitchFamily, int nFontHeight) |
| 114 | { |
| 115 | bool bStatus = false; |
| 116 | HFONT hFont = (HFONT)0; |
| 117 | FontConfig_t* pFont = NULL; |
| 118 | |
| 119 | if (iFont < NUM_FONTS) |
| 120 | pFont = &g_aFontConfig[iFont]; |
| 121 | else |
| 122 | return bStatus; |
| 123 | |
| 124 | if (pFontName) |
| 125 | { |
| 126 | // int nFontHeight = g_nFontHeight - 1; |
| 127 | |
| 128 | int bAntiAlias = (nFontHeight < 14) ? DEFAULT_QUALITY : ANTIALIASED_QUALITY; |
| 129 | |
| 130 | // Try allow new font |
| 131 | hFont = CreateFont( |
| 132 | nFontHeight |
| 133 | , 0 // Width |
| 134 | , 0 // Escapement |
| 135 | , 0 // Orientatin |
| 136 | , FW_MEDIUM // Weight |
| 137 | , 0 // Italic |
| 138 | , 0 // Underline |
| 139 | , 0 // Strike Out |
| 140 | , DEFAULT_CHARSET // OEM_CHARSET |
| 141 | , OUT_DEFAULT_PRECIS |
| 142 | , CLIP_DEFAULT_PRECIS |
| 143 | , bAntiAlias // ANTIALIASED_QUALITY // DEFAULT_QUALITY |
| 144 | , iPitchFamily // HACK: MAGIC #: 4 |
| 145 | , pFontName); |
| 146 | |
| 147 | if (hFont) |
| 148 | { |
| 149 | if (iFont == FONT_DISASM_DEFAULT) |
| 150 | _UpdateWindowFontHeights(nFontHeight); |
| 151 | |
| 152 | strncpy(pFont->_sFontName, pFontName, MAX_FONT_NAME - 1); |
| 153 | pFont->_sFontName[MAX_FONT_NAME - 1] = 0; |
| 154 | |
| 155 | Win32Frame& win32Frame = Win32Frame::GetWin32Frame(); |
| 156 | |
| 157 | HDC hDC = win32Frame.FrameGetDC(); |
| 158 | |
| 159 | TEXTMETRIC tm; |
| 160 | GetTextMetrics(hDC, &tm); |
| 161 | |
| 162 | SIZE size; |
| 163 | char sText[] = "W"; |
| 164 | int nLen = 1; |
| 165 | |
| 166 | int nFontWidthAvg; |
| 167 | int nFontWidthMax; |
| 168 | |
| 169 | // if (! (tm.tmPitchAndFamily & TMPF_FIXED_PITCH)) // Windows has this bitflag reversed! |
| 170 | // { // Proportional font? |
no test coverage detected