MapModes and TextOut functions

I want print correct scaled truetype text onto a Canvas or DC while mapmode "MM_ISOTROPIC" is active (need
this for scaling documents for screens and printers).
Setting MapMode and textout is not enought, Windows
seems to scale the text not correct (logical widths of one
string differ irregular up to 10 %). Knows somebody a method to adjust this ?
garibaldiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

javiertbCommented:
Here you have what Borland Development Support Team says about it:

While it is possible to scale drawing coordinates accuratly,
the Windows font mapper seems not to. A good example is when
scaling the playout of a Metafile. Often, character strings
do not align, and in some cases, the font mapper will substitute
an entirly different font at some scaling factors. An example
pragram proved this, where at 100% the Truetype was accuratly
displayed, but at some scaling factors, Wingdings appeared.
Leading to more confusion, the Windows FontMapper changed between
Windows 3.0, 3.1, 95 and NT. The only way to achieve the results you desire is to get the actual outlines of the characters in Vector format,then scale and image them yourelf.


0
StevenBCommented:
 This problem has been the bane of my life for the past six months. In essence I don't believe it can be solved by windows, therefore you're going to have to do it yourself. This is how I've got round the problem:
  Basically the problem is that single characters do not have a fixed, absolute, width. As you scale them their widths vary and as such the overall length of a string varies. What I've done therefore is set up an array of character widths for every font at a given font size and scaling factor. This is actually done dynamically, as different fonts are selected by the user their character width array is calculated.
  The next task is to write a routine to paint a string to a DC. The important thing is that the characters in the string are painted one at a time, and that the position of each character is calculated based on the absolute character widths from the array, scaled for zoom and font size. Because the widths of each character are constant, the spacing of the characters will be constant for any zoom or font size.
  This is the only way which I've found to get arround the font mapping problems inherrent in Windows. It can be made to work fairly quickly and has sufficed for my needs. The only problem is that occasionally the spacing of characters on the screen can look a little odd, (because they are being spaced correctly by the above method, but the font sizes are not scaled corretly by Windows). The output on a printer is always perfect however, due to the higher DPI.

  Hope this helps, If its a little confusing then I'll happily clarify any points,

  Steven.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garibaldiAuthor Commented:
At the moment I store logical character widths for each string,
but this is very hard to manage for dozens up to hundreds of
strings on an editable document page. There should be another
solution for this problem (big applications like ms word
do this perfect and fast).
0
StevenBCommented:
 If you have an array, for each font that is used, of character widths at a given size and zoom (I use 50pt. font at 100% zoom) then you can extrapolate out what the widths would be at other font sizes and zooms. This can all be incorporated into a function that can be used to return absolute font widths for any situation. There should be no need to store too many values.
  I don't know what MS Word does in this respect, but I know that if you look around you'll find a lot of app's that don't scale their fonts well (Including Microsoft Excell). The reason that I had to solve the problem is that my app has a dynamic zoom scroll bar and the screen display did not represent what the printout would actually look like. With applications which don't support correct font scaling, you'll often find that the zoom facilities are pretty limited. (Ecxell is rubbish at certain zooms).
  Your right, I also feel there should be another solution to the problem, but after several months of experimentation, I've found this to be the best solution.

  Steven.
 

0
StevenBCommented:
LATEST UPDATE!!!!!!!

Metafiles scale their fonts correctly when stretchdrawn to a canvas!!!!!

If your still receiving notice on this question then this is a phenomenon well worth investigating. Draw text to the TMetafileCanvas of a TMetafile as you might ordinarilly draw it to a TCanvas. The metafile can then be stretchdrawn to another canvas and the fonts scale correctly. Not ideal for all situations, but handy in some.

Steven.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.