Page 1 of 1

Measuring the length of proportional font text

Posted: Sun Oct 18, 2009 8:11 am
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

Posted: Sun Oct 18, 2009 12:48 pm
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

Posted: Sun Oct 18, 2009 2:54 pm
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

Posted: Sun Oct 18, 2009 4:55 pm
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