Measuring the length of proportional font text

Discussion about printing issues and techniques.

Moderators: Susan Smith, admin, Gabriel

Post Reply
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Measuring the length of proportional font text

Post by Susan Smith »

Hi all,

Is there a way to measure the length of a string that is going to print in a proportional font in NWP?

I am printing a string onto a check in the memo section. If the string will fit there, I want to print it in a [MEDIUM] sized Arial font, just like the rest of the check. If it won't fit there, I will shrink the font of just that one string. This was easy in non-proportional fonts because you could just compare string lengths. But it's trickier in proportional fonts.

Since you can line up decimals and do other justification of proportional fonts, I thought there may some way to measure a string as well.

-- Susan
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

Each character, upper and lower case has it's own width and I believe that this is imbedded in the font itsself.. However, from a practical point of view, without going into the operating system to look these up and calculate you may want to do the following within BR:

Select the font you are interested in

Do a for next loop to print each character 20 times on a piece of paper

Overlay the paper with a grid (you could use the FNPRINT_GRID in FNSNAP or simply draw three or four veritcal lines over the lines of text

Assign a value of 1 2 or 3 to each letter depending on the width of the printed line (1 for i ans 3 for W)

Enter these numbers into a table

Before you print the line do a for next (or loop while) loop to sum the values of the letters. If the sum exceeds some number that you determine then shrink the font, or as John Bowman has suggested earlier, make the description into two lines breaking it at a space.

George
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

Post by Susan Smith »

This is a VERY interesting idea, George! I never would have come up with that. But I think it will get me close enough to my target, so that's what I'll do. And in your honor, I'll put it in a function ;)

-- Susan
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

For the sake of brevity you may want to have your function only list those items that are 1's or 3's and if the letter is not in the table then give it a 2.

I'll add your function to FNSNAP when you're done.

FNGeorge
Post Reply