--- mstools/samples/fontview/display.c 2018/08/09 18:21:53 1.1.1.3 +++ mstools/samples/fontview/display.c 2018/08/09 18:24:01 1.1.1.4 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + #include #include #include @@ -13,6 +24,7 @@ void DrawAscii (HDC hdc, RECT *pRect, WO void DrawGlyph (HDC hdc, RECT *pRect, BYTE glyph, HFONT hfont); BYTE FindChar (HDC hdc, RECT *pRect, int x, int y); +#pragma warning(4 : 4309) // A data structure that DrawAscii will use: char ascii[]= { @@ -56,6 +68,7 @@ char ascii[]= // End of the list: 000, 000}; +#pragma warning(3 : 4309) /* A function that the CharSet window will use to display the text */ void DrawAscii (HDC hdc, RECT *pRect, WORD direction) @@ -197,14 +210,14 @@ BOOL CircleBlt (HDC hdcDest, int xDst, i double Radian(double ang) { - return ang * (double)3.1415926535 / (double)180.0; + return ang * (double)3.1415926535 / (double)180.0; } void CalcRot (double x, double y, double ang, double* x1, double* y1) { - ang = Radian(-ang); - *x1 = (x * cos(ang)) - (y * sin(ang)); - *y1 = (x * sin(ang)) + (y * cos(ang)); + ang = Radian(-ang); + *x1 = (x * cos(ang)) - (y * sin(ang)); + *y1 = (x * sin(ang)) + (y * cos(ang)); } void DrawGlyph (HDC hdc, RECT *pRect, BYTE glyph, HFONT hfont) @@ -236,14 +249,14 @@ void DrawGlyph (HDC hdc, RECT *pRect, BY // rotatable fonts. bRotateable = FALSE; #if defined (TMPF_VECTOR) - bRotateable = (tm.tmPitchAndFamily & TMPF_VECTOR); + bRotateable = (tm.tmPitchAndFamily & TMPF_VECTOR); #endif #if defined (TMPF_TRUETYPE) - bRotateable |= (tm.tmPitchAndFamily & TMPF_TRUETYPE); + bRotateable |= (tm.tmPitchAndFamily & TMPF_TRUETYPE); #endif - if (!bRotateable) { - lf.lfEscapement = 0; - } + if (!bRotateable) { + lf.lfEscapement = 0; + } SelectObject (hdc, hfontTmp); GetCharWidth (hdc, glyph, glyph, &cWidth); @@ -264,20 +277,20 @@ void DrawGlyph (HDC hdc, RECT *pRect, BY #if defined(TT_AVAILABLE) if (GetCharABCWidths (hdc, (UINT)glyph, (UINT)glyph, &abc)) { - wChar = abc.abcA + abc.abcB + abc.abcC; - wChar = max(abc.abcA,0) + max (abc.abcB,0) + max (abc.abcC,0); + wChar = abc.abcA + abc.abcB + abc.abcC; + wChar = max(abc.abcA,0) + max (abc.abcB,0) + max (abc.abcC,0); } else { - abc.abcA = 0; - abc.abcB = wChar; - abc.abcC = 0; + abc.abcA = 0; + abc.abcB = wChar; + abc.abcC = 0; } #endif // **** - // Lets figure out how large of a bitmap we need to draw this character into. - // This will take lfEscapement into account. + // Lets figure out how large of a bitmap we need to draw this character into. + // This will take lfEscapement into account. - // Turn the 'escapement' value into a valid angle + // Turn the 'escapement' value into a valid angle fAng = 90.0 - ((double)lf.lfEscapement/10.0); // We now need to calculate two values for height and width. These @@ -328,15 +341,15 @@ void DrawGlyph (HDC hdc, RECT *pRect, BY // Calculate the points of the 'character cell'. This will take full // rotation into consideration. - CalcRot (0, 0, (double)lf.lfEscapement/10.0, &xTL, &yTL); - CalcRot ((double)cExtentW, 0, (double)lf.lfEscapement/10.0, &xTR, &yTR); - CalcRot (0, (double)cExtentH, (double)lf.lfEscapement/10.0, &xBL, &yBL); - CalcRot ((double)cExtentW, (double)cExtentH, (double)lf.lfEscapement/10.0, &xBR, &yBR); - CalcRot (0, (double)tm.tmAscent, (double)lf.lfEscapement/10.0, &xML, &yML); - CalcRot ((double)cExtentW, (double)tm.tmAscent, (double)lf.lfEscapement/10.0, &xMR, &yMR); + CalcRot (0, 0, (double)lf.lfEscapement/10.0, &xTL, &yTL); + CalcRot ((double)cExtentW, 0, (double)lf.lfEscapement/10.0, &xTR, &yTR); + CalcRot (0, (double)cExtentH, (double)lf.lfEscapement/10.0, &xBL, &yBL); + CalcRot ((double)cExtentW, (double)cExtentH, (double)lf.lfEscapement/10.0, &xBR, &yBR); + CalcRot (0, (double)tm.tmAscent, (double)lf.lfEscapement/10.0, &xML, &yML); + CalcRot ((double)cExtentW, (double)tm.tmAscent, (double)lf.lfEscapement/10.0, &xMR, &yMR); - fxOff = min(xTL, min(xTR, min(xBL, xBR))); - fyOff = min(yTL, min(yTR, min(yBL, yBR))); + fxOff = min(xTL, min(xTR, min(xBL, xBR))); + fyOff = min(yTL, min(yTR, min(yBL, yBR))); // Draw a rectangle around the drawing limits of the character. _MoveTo (hdc, (int)((xTL-fxOff)*(double)unit), (int)((yTL-fyOff)*(double)unit)); @@ -361,15 +374,15 @@ void DrawGlyph (HDC hdc, RECT *pRect, BY if (TextOut (hdcMem, (int)(xML-fxOff), (int)(yML-fyOff), (LPSTR)&glyph, 1)) { - /* + /* // Just for debugging, lets mark some special pixels - SetPixel (hdcMem, (int)(xML-fxOff), (int)(yML-fyOff), 0x808080); // Base Lft - SetPixel (hdcMem, (int)(xTL-fxOff), (int)(yTL-fyOff), 0x808080); // Top Left - SetPixel (hdcMem, (int)(xTR-fxOff), (int)(yTR-fyOff), 0x808080); // Top Right - SetPixel (hdcMem, (int)(xBL-fxOff), (int)(yBL-fyOff), 0x808080); // Btm Left - SetPixel (hdcMem, (int)(xBR-fxOff), (int)(yBR-fyOff), 0x808080); // Btm Right - SetPixel (hdcMem, (int)(xML-fxOff), (int)(yML-fyOff), 0x808080); // Base Lft - SetPixel (hdcMem, (int)(xMR-fxOff), (int)(yMR-fyOff), 0x808080); // Base Rt + SetPixel (hdcMem, (int)(xML-fxOff), (int)(yML-fyOff), 0x808080); // Base Lft + SetPixel (hdcMem, (int)(xTL-fxOff), (int)(yTL-fyOff), 0x808080); // Top Left + SetPixel (hdcMem, (int)(xTR-fxOff), (int)(yTR-fyOff), 0x808080); // Top Right + SetPixel (hdcMem, (int)(xBL-fxOff), (int)(yBL-fyOff), 0x808080); // Btm Left + SetPixel (hdcMem, (int)(xBR-fxOff), (int)(yBR-fyOff), 0x808080); // Btm Right + SetPixel (hdcMem, (int)(xML-fxOff), (int)(yML-fyOff), 0x808080); // Base Lft + SetPixel (hdcMem, (int)(xMR-fxOff), (int)(yMR-fyOff), 0x808080); // Base Rt */ CircleBlt(hdc, margin, margin, @@ -378,7 +391,7 @@ void DrawGlyph (HDC hdc, RECT *pRect, BY } else { MessageBox (GetFocus(), - "Unable to perform TextOut", "DisplayGlyph", MB_OK); + "Unable to perform TextOut", "DisplayGlyph", MB_OK); } SelectObject (hdcMem, hbitmapOld); SelectObject (hdcMem, hfontOld); @@ -408,9 +421,9 @@ void DrawGlyph (HDC hdc, RECT *pRect, BY wsprintf (szText, "CharWidth = %i", cWidth); TextOut (hdc, x, y, szText, lstrlen(szText)); - // ABC Width - Eventually, I want to 'draw' this into the character - // cell, but for now, this at least makes the information easily - // available: + // ABC Width - Eventually, I want to 'draw' this into the character + // cell, but for now, this at least makes the information easily + // available: #if defined (TT_AVAILABLE) y += tm.tmHeight + tm.tmExternalLeading; wsprintf (szText, "A|B|C = %i | %u | %i", abc.abcA, abc.abcB, abc.abcC); @@ -425,8 +438,8 @@ void DrawGlyph (HDC hdc, RECT *pRect, BY wsprintf (szText, "CharExtentH = %i", cExtentH); TextOut (hdc, x, y, szText, lstrlen(szText)); - // These are for some values I was using to debug the character - // cell rotation calculation: + // These are for some values I was using to debug the character + // cell rotation calculation: //y += tm.tmHeight + tm.tmExternalLeading; //wsprintf (szText, "(%i,%i) : (%i,%i) [%i]", (int)xTL, (int)yTL, (int)xTR, (int)yTR,(int)(((double)lf.lfEscapement/10.0)*10));