I have an application that provides a preview of the RTF files it generates. The preview renders each page using combinations of the Times Roman and Courier New fonts with a size of 8 points.
Problem:
The size of the Courier New text is rendered larger than the Times Roman text which results in the text exceeding the page rectangle.
If I render everything in Times Roman at 8 point it matches the output from Word (My Output Reference) within a mm or so over the page length. If I render the data using Courier New I exceed the page length by 8 lines on the display.
Printing also produces a variation in text length but due to the higher printer resolution it is not as great.
I have looked at the values of the screen resolution using GetDeviceCaps(LOGPIXELSY) which returns the default 96 pixels per inch.
Using the GetDeviceCaps(VERTRES) and (VERTSIZE) I get a resolution of 91 or 76 depending on the display.
Using these resolutions improves reduces the height of the text but still not enough to achieve the required representation.
I've also tried CreateFontIndirect and CreatePointFont to see if this makes a difference which unfortunately it hasn't.
Can anyone provide some insight into a reliable method to correctly display Courier New fonts with the same accuracy as the other true type fonts.
Please advise of solution it makes it easier to find an answer.
The first image contains the lower portion of two printed versions. The Top most is the output generated using Word. Whilst the lower most is the same page printed fropm my application. The bottom of the columns with repect to the footer (Issue xx...) shows the variation in text sizes between the two.
The second image shows the same page rendered by my application with the colum data extending below the page and over writing the footer.
As detailed in many references and guides, "the majority of time you will spend formating output when utilising the MFC SDI/MDI printing interfaces." For this project they sure have this right.
Please advise of solution it makes it easier to find an answer.
Can you post/email code you are using in GEtDeviceCaps() and CreateFont()...
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
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.
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.
Last edited by sma; February 15th, 2011 at 05:04 PM.
Please advise of solution it makes it easier to find an answer.
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Quite possible they only use TWIPS....I only use MM_HIENGLISH in my programs and all looks the same if printed directly or to a PDF...
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
I think Microsoft may not be using the same techniques to scal the fonts in word as available via VC++.
Are you thinking that M$ might be holding back some functionality for their own use that is not available to Developers...would they do that ?? LOL
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
I just did a test which printed the same 15 lines of 10 point Courier New from both Word and directly to the printer from my app.
Overall Word Heght = 56mm, My App = 53.5 meaning and additional
3.5mm/14 = 0.25mm in line height.
Over 61 lines Word = 240.5, My App = 225mm -> 15.5/60 = 0.258mm
Given 1 point = 25.4/72 -> 0.352mm it is clear that some further manipulation of fon sizes is occuring.
Also noted that the Word rendering of a page on the same display at a scale of 100% shows a with variation of 4mm, Word = 234 my app shows 230 when the LOGPIXELSX is used to for all size conversions.
The line height in Word on the display is also larger than that printed so it is clear that some other scaling is occurring.
Please advise of solution it makes it easier to find an answer.
So it is actually changing the font size and not the line spacing ?
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Overlaying the two printouts it appears that the individual characters are slightly larger when printed from Word. So I would say that the font size has been manipulated in some way.
This does prevent the printouts from matching exactly however the issue is with the screen representation and the inability to render all of the page data within the required area.
I was considering creating a DC of the resolution of the connected printer (600 x 600) representing the page, rendering the page and then using StrBlt to reduce this to the page area drawn on the screen.
My concern with this approach would be the clarity of the resultant text and what would I do if the end user had no printer connected?
Please advise of solution it makes it easier to find an answer.
Let me do some testing on my system using Courier New...
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Ok, thanks for your help I hope you come to the same conclusions.
Well actually I came up with 2 printouts that are exactly the same...I printed Courier New 10pt from within Word (2001 Small Business) and a MFC App of mine (code posted above)...I then measured the height of a "I" (upper case "i")...both were .0845in or 2.15mm in height.
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.