Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MapModes and TextOut functions

Posted on 1997-05-09
5
Medium Priority
?
776 Views
Last Modified: 2010-04-03
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 ?
0
Comment
Question by:garibaldi
  • 3
5 Comments
 
LVL 2

Expert Comment

by:javiertb
ID: 1336065
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
 
LVL 4

Accepted Solution

by:
StevenB earned 180 total points
ID: 1336066
 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
 

Author Comment

by:garibaldi
ID: 1336067
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
 
LVL 4

Expert Comment

by:StevenB
ID: 1336068
 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
 
LVL 4

Expert Comment

by:StevenB
ID: 1336069
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question