Below is the code used to determine the resolution of the Device used within my app.
Code:int CalculateYPixels(CDC* DeviceContext) { int VertRes = DeviceContext->GetDeviceCaps(VERTRES); int Height = DeviceContext->GetDeviceCaps(VERTSIZE); float PixelsInch = (((float)VertRes / (float)Height) * 25.4) + 0.5; if(PixelsInch > 300) PixelsInch = DeviceContext->GetDeviceCaps(LOGPIXELSY); return (int) PixelsInch; }
The following is an extract of my code that shows how each font is created.
CellParaFont font is a CString which represents the font face name of either "Times Roman New" or "Courier New" and the size of the font as defined in the RTF V1.6 spec. Each of the routines using this data returns the correct values.Code:memset(&WorkingLogFont, 0, sizeof(LOGFONT)); DeviceContext->GetCurrentFont()->GetLogFont(&WorkingLogFont); WorkingLogFont.lfWidth = 0; WorkingLogFont.lfWeight = FW_NORMAL; WorkingLogFont.lfCharSet = ANSI_CHARSET; WorkingLogFont.lfOutPrecision = OUT_DEFAULT_PRECIS; WorkingLogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; WorkingLogFont.lfPitchAndFamily = FIXED_PITCH; lstrcpy(WorkingLogFont.lfFaceName, GetFontName(CellParaFont)); WorkingLogFont.lfHeight = -MulDiv(GetFontSize(CellParaFont), PixelsInch, 72); if(WorkingFont->CreateFontIndirect(&WorkingLogFont)) { OldFont = DeviceContext->SelectObject(WorkingFont); }
Stepping trough the code shows that all elements of the LogFont have been initialised with the expected values and the CreateFont indirect function return true indicating successful completion.
Using the GetTextFace funct shows that the Courier New font is being used with the TextOut function used to generate the text.




Please advise of solution it makes it easier to find an answer.
Reply With Quote