Mapping Modes, and Font Size
-
I am trying to create an app that, among other things, uses an MFC Doc/View architecture to display RTF files. I have the editing and display and all the standard stuff from a library (LED) that does an excellent job. Now I have to have a second window open, that shows a portion of the text from another view (lets for argument say the top two lines) blown up (or zoomed in) large. However, I have to have the resolution higher, not just StretchBlt the smaller image up and get a pixelated image. I have a mechanizm to open a separate Frame Window and View, and to transfer the selected text to it. I thought I could manimpulate the Mapping Mode along with the Viewport and Window Extents to in effect change the DPI of a memory mapped DC. Then, just like when you print, in my OnDraw routine, I pass the DC to my view, let it render to the DC, and then Blit it over to my window. When I set up my DC, and change it's mapping mode to MM_ANISOTROPIC, and then modify the Extents, everything seems fine when I create a font and call GetOutputTextExtent(), I get a value, and when I double the ratio of the Window to the Viewport Extents, GetOutputTextExtent() reports a value that is double. HOWEVER, when I then use TextOut, the text is the same size, unaffected by the extents. How can GetOutputTextExtent()report a different value than TextOut produces? Below is some sample code, note the second and third lines from the bottom get the size and create the text, but they do not match:
CDC cdcScreen; cdcScreen.CreateDC("DISPLAY", NULL, NULL, NULL); ResizeableDC = new CDC; ResizeableDC->CreateCompatibleDC(&cdcScreen); int mode = ResizeableDC->SetMapMode(MM_ANISOTROPIC); ASSERT(mode == MM_TEXT); // the next line can be changed to *40, and the GetOutputTextExtent() will vary appropriatly ResizeableDC->SetWindowExt(1024*20, 768*20); ResizeableDC->SetViewportExt(1024, 768); CFont font; { LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); // zero out structure lf.lfHeight = -MulDiv(12, ResizeableDC->GetDeviceCaps(LOGPIXELSY), 72); strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial" VERIFY(font.CreateFontIndirect(&lf)); // create the font } CFont* def_font = ResizeableDC->SelectObject(&font); CSize Size = ResizeableDC->GetOutputTextExtent("Now is the time for all good men"); ResizeableDC->TextOut(Size.cx, Size.cy, "Now is the time for all good men"); ResizeableDC->SelectObject(def_font);
Any other ideas on how to get the results