Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Font Problem

Font Problem

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pazzuzu
    wrote on last edited by
    #1

    Hi all, Iam using Keith Rule's CMemDc class & I have changed it according to my requirement.Iam posting that class also here. Now Iam zooming my View using "SetWorldTransform" call. My problem now is when I change the zoom factor to below or above 100,the Fonts are not smooth. The following are my codes: //Creating Font like this in "MyView" constructor.Don't want to use FixedFonts. m_oFont.CreatePointFont(120, _T("Courier New")); LOGFONT oLogfont; m_oFont.GetLogFont(&oLogfont); //OnPrepareDc looks like this. void MyView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { pDC->SetMapMode(MM_TEXT); SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED); pDC->SelectObject(&m_oFont); pDC->GetTextMetrics(&m_TextMetrics); XFORM xForm; xForm.eM11 = 0.01 * m_iZoomFactor; xForm.eM21 = 0; xForm.eDx = 0; xForm.eM12 = 0; xForm.eM22 = 0.01 * m_iZoomFactor; xForm.eDy = 0; pDC->GetTextMetrics(&m_textMetrics); SetWorldTransform(pDC->GetSafeHdc(), &xForm); CScrollView::OnPrepareDC(pDC, pInfo); } //My "OnDraw" looks like this. void MyView::OnDraw(CDC* pDC) { CpagesDoc* pDoc = GetDocument(); CSize sizeTotal; //default scrollsizes to 80 chars X 80 lines. sizeTotal.cx = 80; sizeTotal.cy = 80; //Client Rectangle Size. CRect rect; GetClientRect(&rect); //Creating a temporary Dc. C_TempDc tempDC(pDC,m_oFont,&rect); int pageWidth = 800; int pageHeight = 800; //int pageGap = 5; int pageNumber =3; SIZE size; size.cx = 1000; size.cy = (pageHeight*3)+100; //First Page tempDC->Rectangle(CRect(0,0,pageWidth,pageHeight)); tempDC->TextOut(5,10,"This is the first line on the FirstPage"); sizeTotal.cx *= MulDiv(m_textMetrics.tmAveCharWidth, m_iZoomFactor, 100); sizeTotal.cy *= MulDiv(m_textMetrics.tmHeight, m_iZoomFactor, 100); SetScrollSizes(MM_TEXT, sizeTotal); } //Keith Rule's Memory Buffer #ifndef C_TEMPDC_H #define C_TEMPDC_H class C_TempDc : public CDC { public: C_TempDc(CDC* pDC,CFont & font,const CRect* pRect = NULL): CDC() { ASSERT(pDC != NULL); //Initialising. m_pDC = pDC; m_oldBitmap = NULL; m_oldFont= NULL; //Getting ClipBox Rectangle. pDC->GetClipBox(&m_clipRect); //Client Rectangle. m_clientRect = *pRect; pDC->DPtoLP(&m_clientRect); // Create a Memory DC CreateCompatibleDC(pDC); //pDC->LPtoDP(&m_rect); m_bitmap.CreateCompatibleBitmap(pDC,m_clientRect.Width(),m_clientRect.Height()); pDC->LPtoDP(&m_clientRect); m_oldBitmap = SelectObject(&m_bitmap); ///Selecting the Font. m_oldFont = SelectObject(&f

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups