facing issue in “Ajantha” font on windows10 in GDIplus
-
I am facing an issue while printing some text using Ajantha Font, My observation says that after ANSI code 127 GDIPlus is not printing the correct font on windows 10 x64, where as GDI (Direct printing on DC does it correctly). CFont font; VERIFY(font.CreateFont( 40, // nHeight 20, // nWidth 0, // nEscapement 0, // nOrientation FW_DONTCARE, // nWeight FALSE, // bItalic FALSE, // bUnderline FALSE, // cStrikeOut DEFAULT_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH, // nPitchAndFamily _T("AJANTHA"))); // lpszFacename // Do something with the font just created... CClientDC cdc(this); CFont* def_font = cdc.SelectObject(&font); cdc.TextOut(11, 11, _T("€ € ~ ƒ „ …"), 11); cdc.SelectObject(def_font); Font mFont(dc.m_hDC, font); SolidBrush BlueBrush(Color(255, 0, 0, 255)); graphics.DrawString( strText, -1, &mFont, PointF(0, 150), pStringFormat, &BlueBrush); // Done with the font. Delete the font object. font.DeleteObject();
-
I am facing an issue while printing some text using Ajantha Font, My observation says that after ANSI code 127 GDIPlus is not printing the correct font on windows 10 x64, where as GDI (Direct printing on DC does it correctly). CFont font; VERIFY(font.CreateFont( 40, // nHeight 20, // nWidth 0, // nEscapement 0, // nOrientation FW_DONTCARE, // nWeight FALSE, // bItalic FALSE, // bUnderline FALSE, // cStrikeOut DEFAULT_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH, // nPitchAndFamily _T("AJANTHA"))); // lpszFacename // Do something with the font just created... CClientDC cdc(this); CFont* def_font = cdc.SelectObject(&font); cdc.TextOut(11, 11, _T("€ € ~ ƒ „ …"), 11); cdc.SelectObject(def_font); Font mFont(dc.m_hDC, font); SolidBrush BlueBrush(Color(255, 0, 0, 255)); graphics.DrawString( strText, -1, &mFont, PointF(0, 150), pStringFormat, &BlueBrush); // Done with the font. Delete the font object. font.DeleteObject();
-
I am facing an issue while printing some text using Ajantha Font, My observation says that after ANSI code 127 GDIPlus is not printing the correct font on windows 10 x64, where as GDI (Direct printing on DC does it correctly). CFont font; VERIFY(font.CreateFont( 40, // nHeight 20, // nWidth 0, // nEscapement 0, // nOrientation FW_DONTCARE, // nWeight FALSE, // bItalic FALSE, // bUnderline FALSE, // cStrikeOut DEFAULT_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH, // nPitchAndFamily _T("AJANTHA"))); // lpszFacename // Do something with the font just created... CClientDC cdc(this); CFont* def_font = cdc.SelectObject(&font); cdc.TextOut(11, 11, _T("€ € ~ ƒ „ …"), 11); cdc.SelectObject(def_font); Font mFont(dc.m_hDC, font); SolidBrush BlueBrush(Color(255, 0, 0, 255)); graphics.DrawString( strText, -1, &mFont, PointF(0, 150), pStringFormat, &BlueBrush); // Done with the font. Delete the font object. font.DeleteObject();
Adding to what has already been said ... read carefully CreateFontA function | Microsoft Docs[^] Read this bit carefully
Quote:
To ensure consistent results when creating a font, do not specify OEM_CHARSET or DEFAULT_CHARSET. If you specify a typeface name in the lpszFace parameter, make sure that the fdwCharSet value matches the character set of the typeface specified in lpszFace.
Specifically you may want to look at the GDIPLUS font class CFont Class | Microsoft Docs[^]
Quote:
The font mapper does not use the DEFAULT_CHARSET value. An application can use this value to allow the name and size of a font to fully describe the logical font. If a font with the specified name does not exist, a font from any character set can be substituted for the specified font. To avoid unexpected results, applications should use the DEFAULT_CHARSET value sparingly.
Look at the sample code on the page and what setting they use, so what you really want to do for entirely predictable results is specify ANSI_CHARSET and use UNICODE strings, anything else is hit and miss :-)
In vino veritas