close

q:
C++筆記 - MFC LOGFONT lfEscapement (vertical) not working,字型無法垂直顯示

sol:

改變字體:


    curLogFont.lfEscapement = 900; // rotate 90 degree
    strcpy(curLogFont.lfFaceName, "Arial");//set font as Arial fixed vertical problem, 
    CFont    newFont;
    newFont.CreateFontIndirect(&curLogFont);
    
    CFont* pOldFont = pdc->SelectObject(&newFont);

 

試過以下都無效
https://social.msdn.microsoft.com/Forums/en-US/46930bf1-a886-4b05-9a8c-29063b2e9ece/how-to-rotate-a-text-or-number-90-in-windows-forms-c?forum=vcgeneral
CFont fonts[num];

pDC->SetBkMode(TRANSPARENT);
for (int i=0; i<num; i++) {
    fonts[i].CreateFont(10, 0, 2700, 0, i*100, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, OUT_CHARACTER_PRECIS, PROOF_QUALITY, FF_MODERN, L"Courier New");
    pDC->SelectObject(fonts+i);
    pDC->TextOut(20+i*14, 20, L"This is some text");
}

https://stackoverflow.com/questions/2397005/vertical-text-wont-be-bold-in-win32-gdi-c

 

CFont font;
 LOGFONT lf;
 memset(&lf, 0, sizeof(LOGFONT));       // zero out structure
 lf.lfEscapement = 2700;
 lf.lfHeight = 12;                      // request a 12-pixel-height font
 _tcsncpy_s(lf.lfFaceName, LF_FACESIZE,
    _T("Arial"), 5);                    // request a face name "Arial"
 VERIFY(font.CreateFontIndirect(&lf));  // create the font

 // Do something with the font just created...
 CClientDC dc(this);
 CFont* def_font = dc.SelectObject(&font);
 dc.TextOut(100, 5, _T("Hello"), 5);
 dc.SelectObject(def_font);

 // Done with the font. Delete the font object.
 font.DeleteObject();

 

 

https://social.msdn.microsoft.com/Forums/vstudio/en-US/2103e308-65c3-49d6-b3e3-9e35bc0fa019/logfont-lfescapement-vertical-not-working-on-windows-7?forum=vcgeneral

 

void MyListControl::SetFontSize(int pixelHeight)
{
    // from http://support.microsoft.com/kb/85518
    LOGFONT lf;                        // Used to create the CFont.

    CFont *currentFont = GetFont();
    currentFont->GetLogFont(&lf);
    lf.lfHeight = pixelHeight;
    font_.DeleteObject();
    font_.CreateFontIndirect(&lf);    // Create the font.

    // Use the font to paint a control.
    SetFont(&font_);
}

 

https://stackoverflow.com/questions/7617199/mfc-dynamically-change-control-font-size

 
 
 
 
 

試過:

 

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 天才R 的頭像
    天才R

    做 個 有 趣 的 人

    天才R 發表在 痞客邦 留言(0) 人氣()