Widest Character and Height of the character
-
I want to know the widest character and height of "MS Sans Sarif" Font Type. The Characters = {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ},font size may be in between 8 to 50.
Try it :) :
CSize GetMaxCharSize(CDC* pcDC, CFont* pcFont)
{
CSize csizeResult(0, 0);
if (pcDC && pcFont) {
CGdiObject* pcOldFont = pcDC->SelectObject(pcFont);
TEXTMETRIC tm = {0};
pDC->GetTextMetrics(&tm);
csizeResult.cx = tm.tmMaxCharWidth;
csizeResult.cy = tm.tmHeight;
pcDC->SelectObject(pcOldFont);
}
return csizeResult;
}virtual void BeHappy() = 0;
-
Try it :) :
CSize GetMaxCharSize(CDC* pcDC, CFont* pcFont)
{
CSize csizeResult(0, 0);
if (pcDC && pcFont) {
CGdiObject* pcOldFont = pcDC->SelectObject(pcFont);
TEXTMETRIC tm = {0};
pDC->GetTextMetrics(&tm);
csizeResult.cx = tm.tmMaxCharWidth;
csizeResult.cy = tm.tmHeight;
pcDC->SelectObject(pcOldFont);
}
return csizeResult;
}virtual void BeHappy() = 0;
I support the above. :)
Величие не Бога может быть недооценена.
-
Try it :) :
CSize GetMaxCharSize(CDC* pcDC, CFont* pcFont)
{
CSize csizeResult(0, 0);
if (pcDC && pcFont) {
CGdiObject* pcOldFont = pcDC->SelectObject(pcFont);
TEXTMETRIC tm = {0};
pDC->GetTextMetrics(&tm);
csizeResult.cx = tm.tmMaxCharWidth;
csizeResult.cy = tm.tmHeight;
pcDC->SelectObject(pcOldFont);
}
return csizeResult;
}virtual void BeHappy() = 0;
-
It could be something like this :) :
/*virtual*/ void CYourView::OnInitialUpdate()
{
CBaseOfYourView::OnInitialUpdate();/*CFont*/ m_cFont.CreatePointFont(120, _T("Arial")); // 12pts * 10
...
}/*virtual*/ void CYourView::OnDraw(CDC* pDC)
{
CSize cMaxCharSize(GetMaxCharSize(pDC, &m_cFont));
CRect cMaxCharRect(CPoint(100, 100), cMaxCharSize);
pDC->FillSolidRect(cMaxCharRect, RGB(0, 128, 200));
...
}virtual void BeHappy() = 0;
-
It could be something like this :) :
/*virtual*/ void CYourView::OnInitialUpdate()
{
CBaseOfYourView::OnInitialUpdate();/*CFont*/ m_cFont.CreatePointFont(120, _T("Arial")); // 12pts * 10
...
}/*virtual*/ void CYourView::OnDraw(CDC* pDC)
{
CSize cMaxCharSize(GetMaxCharSize(pDC, &m_cFont));
CRect cMaxCharRect(CPoint(100, 100), cMaxCharSize);
pDC->FillSolidRect(cMaxCharRect, RGB(0, 128, 200));
...
}virtual void BeHappy() = 0;
-
I want to know the widest character and height of "MS Sans Sarif" Font Type. The Characters = {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ},font size may be in between 8 to 50.
http://msdn.microsoft.com/en-us/library/xwf9s90b(VS.71).aspx[^] In Western European fonts, the widest character is usually capital letter M (that's why typesetters refer to em-height and em-width). Most fonts will contain a character call em_space, which is a space that is exactly as wide as the widest character in the font.
-
http://msdn.microsoft.com/en-us/library/xwf9s90b(VS.71).aspx[^] In Western European fonts, the widest character is usually capital letter M (that's why typesetters refer to em-height and em-width). Most fonts will contain a character call em_space, which is a space that is exactly as wide as the widest character in the font.
Please compare them :) : - W - M
virtual void BeHappy() = 0;
-
Please compare them :) : - W - M
virtual void BeHappy() = 0;
That's why I said 'usually' ;-) em-space (or em_dash) should still be valid, though... http://en.wikipedia.org/wiki/Em_(typography)[^]
-
Please compare them :) : - W - M
virtual void BeHappy() = 0;