Solved

MapModes and TextOut functions

Posted on 1997-05-09
5
771 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 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