Preview with fixed Fonts

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Preview with fixed Fonts

Postby Frigyes » Fri Nov 30, 2007 2:55 pm

Hi!

VPE 4.0

My output is with fixed fonts only (for example Courier) like a line printer

if the preview is with 100% or 50% everyting fine, but with other zoom-factor (e.g. 66%) the preview is not so pretty (like a document with no fixed fonts) can I do anything or it's a known problem with scaling.

tia
frigyes

PS:
the output to printer or pdf perfect (also the pdf preview scaling with Acrobat)
Frigyes
 
Posts: 26
Joined: Thu Jun 29, 2006 12:09 pm

Postby IDEAL Software Support » Fri Nov 30, 2007 9:54 pm

Are you using "Courier" or "Courier New"? Courier is a bitmap font, not a True-Type font and can not be scaled precisely. Bitmap fonts should not be used with VPE and are not supported.

If it is "Courier New", please send a sample VPE document file to our support e-mail address (keyword "VPE" in the subject), we would like to take a look at it.

Regards
Thorsten Radde
IDEAL Software GmbH
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Postby Frigyes » Mon Dec 03, 2007 10:09 am

It's "Courier New",

I sent the sample

TIA
Frigyes
 
Posts: 26
Joined: Thu Jun 29, 2006 12:09 pm

Postby IDEAL Software Support » Mon Dec 03, 2007 2:19 pm

Ok, we looked at the file and here is the result:

You are trying to create a table like:

Code: Select all
xxxxx     xxx          xxxxx
xxx       xxx          xxx


You output each line as a single string, e.g.
Code: Select all
VPE.Write(1, 1, VFREE, VFREE, "xxxxx     xxx          xxxxx");
VPE.Write(1, 2, VFREE, VFREE, "xxx       xxx          xxx");

If you would be using a proportional font (like Arial or Times New Roman), the columns wouldn't be vertically aligned due to different text widths.

You would get something like:
xxxxx xxx xxxxx
xxx xxx xxx

Therefore you are using the monospaced font Courier New, which has fixed widths for each character. This looks fine in the preview for a zoom factor of 100% and higher, also for 75% and 50%, but not for 33% and 66%. Using such zoom factors, the columns are misaligned by 1 or 2 pixels, so they are not displayed vertically aligned.

As you mentioned, the problem only affects the preview on the screen, not printing or export to PDF.

The reason is how VPE renders text. Without going too much into detail, VPE does not compute the position of each single character, it uses a different technique to gain very high performance. But the screen has a very low resolution of about 96 DPI. When using a zoom factor of 66% or 33% this equals 63.36 DPI and 31.68 DPI. This is a very poor resolution and here some round off errors occur. However, you will notice that the endings of all lines of text are aligned correctly.

The solution for your problem is as follows: do not output each line of text as a single string as a whole. Instead output each column separately with aligned coordinates (i.e. like a cell of a spreadsheet).

Example:
Code: Select all
// First Line
VPE.Write(1, 1, VFREE, VFREE, "xxxxx");
VPE.Write(5, 1, VFREE, VFREE, "xxx");
VPE.Write(10, 1, VFREE, VFREE, "xxxxx");

// Second Line
VPE.Write(1, 2, VFREE, VFREE, "xxxxx");
VPE.Write(5, 2, VFREE, VFREE, "xxx");
VPE.Write(10, 2, VFREE, VFREE, "xxxxx");


When doing so, you can easily align numbers by using right aligned text for such columns (digits are always monospaced, even when using proportional fonts).

This also enables you to use proportional fonts instead of Courier New (which produces the output of an old-style line printer - but we have the 21st century, not 1985).

Hope this helps.

Regards
Thorsten Radde
IDEAL Software GmbH
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 13 guests

cron