Solved

MapModes and TextOut functions

Posted on 1997-05-09
5
765 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 90 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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