 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 5th, 2005, 09:06 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Calculate Character Widths
OK - Since my other question seems to be drawing a blank...
Does anyone know how to calculate the widths of characters in non-fixed width fonts?
If I can figure out the widths, I can figure out how many lines my label will have and somehow figure out from that where to place my graphic.
Mike
EchoVue.com
__________________
Mike
EchoVue.com
|
|

August 8th, 2005, 08:55 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
What you want to find out is the characters per inch or per centimeter for a particular font. For that, you'll have to do a Google search for someone who has done that for popular fonts (e.g. Time New Roman, Arial). If not, you'll have to do some experimentation yourself.
You'd pick a font size. That determines height. For font sizes, 72 points = 1 inch in height. Once you pick a font type and size (say Times New Roman 12-point) then you'll have to print out a page of A through Z, a through z, 0 through 9, and some symbols to see how many print horizontally per inch. For example.
AAAAAAAAAAA
BBBBBBBBBBB
CCCCCCCCCCC
Etc. Then you'll see for the A's, how many characters per inch (CPI) print. For the B's, C's, etc. Once you have the CPIs calculated and stored in a table, you can then predict how wide a label will be by calculating its width using the MID function.
Dim bytWidth as Byte, bytCount as Byte
bytWidth = 0
For bytCount = 1 to Len(Me.lblMyLabel.Caption)
bytWidth = bytWidth + Nz(DLookUp("[bytCPI]", _
"tblCPI", "[strChar] = '" & _
Mid(Me.lblMyLabel.Caption, i) & "'"), 0)
Next bytCount
Where lblMyLabel is the caption in your report (use your real name instead).
You'd need a table called tblCPI with two fields: strChar (holds the character, e.g. "A", "B", etc.) and bytCPI (holds the characters per inch value for that character).
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

August 8th, 2005, 08:59 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Ingenious!! I'll give it a whirl.
Thanks
Mike
Mike
EchoVue.com
|
|

August 8th, 2005, 01:37 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sounds to me like you'd need to store Inches per Character instead of Characters per Inch in order for bytWidth to give you an actual length. What do you think?
"Life is a Database"
|
|

August 8th, 2005, 01:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Yes, you're right... inches per character (IPC) is what you want. When I think too fast, I often get things backwards. D'oh! Sorry about that. Thanks for catching that.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

August 8th, 2005, 01:43 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
True - I realize this when the program told me that my two lines were several hundred inch's long!! The basic idea however was dead on. Once I got a few of the bugs worked out, it worked perfectly. I am sure that my measurements weren't exact, so I could probably revisit them again in the future, and I did run into a problem trying to figure out the space taken by a space, but I put the space value into the Nz function default, and it picked it right up.
Thanks to Greg I have a whole bunch of happy users now!!
Mike
Mike
EchoVue.com
|
|

February 13th, 2010, 05:49 AM
|
|
Registered User
|
|
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Arial Width Table
%widths = (' ' => 200, '!' => 254, '"' => 444, '#' => 644, '$' => 536, '%' => 719, '&' => 796, ''' => 235, '(' => 304, ')' => 304, '*' => 416, '+' => 533, ',' => 217, '-' => 294, '.' => 216, '/' => 273,
'0' => 533, '1' => 533, '2' => 533, '3' => 533, '4' => 533, '5' => 533, '6' => 533, '7' => 533, '8' => 533, '9' => 533,
':' => 216, ';' => 217, '<' => 533, '=' => 533, '>' => 533, '?' => 361, '@' => 757,
'A' => 724, 'B' => 598, 'C' => 640, 'D' => 750, 'E' => 549, 'F' => 484, 'G' => 720, 'H' => 742, 'I' => 326, 'J' => 315, 'K' => 678, 'L' => 522, 'M' => 835,
'N' => 699, 'O' => 779, 'P' => 532, 'Q' => 779, 'R' => 675, 'S' => 536, 'T' => 596, 'U' => 722, 'V' => 661, 'W' => 975, 'X' => 641, 'Y' => 641, 'Z' => 684,
'[' => 342, '\' => 273, ']' => 342, '^' => 247, '_' => 475, '`' => 247,
'a' => 441, 'b' => 540, 'c' => 448, 'd' => 542, 'e' => 466, 'f' => 321, 'g' => 479, 'h' => 551, 'i' => 278, 'j' => 268, 'k' => 530, 'l' => 269, 'm' => 833,
'n' => 560, 'o' => 554, 'p' => 549, 'q' => 534, 'r' => 398, 's' => 397, 't' => 340, 'u' => 542, 'v' => 535, 'w' => 818, 'x' => 527, 'y' => 535, 'z' => 503,
'{' => 380, '|' => 265, '}' => 380, '~' => 533, 'â¬' => 533, 'â' => 235, 'â' => 444, 'â¦' => 950, 'â ' => 536, 'â¡' => 536, 'â°' => 1096, 'â¹' => 256, 'Ś' => 964,
'Ź' => 536, 'â' => 235, 'â' => 235, 'â' => 444, 'â' => 444, 'â¢' => 536, 'â' => 475, 'â' => 950, 'âº' => 256, 'ś' => 813, 'ź' => 641, 'Ł' => 536, 'Ą' => 536,
'§' => 536, '«' => 399, '¬' => 521, 'Â' => 294, 'Ż' => 533, '°' => 294, '±' => 533, 'ł' => 380, '´' => 247, 'µ' => 524, 'ą' => 380, '»' => 399, '˝' => 760,
'ż' => 361, 'Ć' => 941, 'Ę' => 549, 'Ń' => 699, 'Ã' => 779, 'ć' => 703, 'ę' => 466, 'ń' => 560, 'ó' => 554, '÷' => 533);
|
|

February 13th, 2010, 10:55 AM
|
|
Registered User
|
|
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Arial 10 character width table
This is relational character table specially for font: Arial 10pt.
'.' => 1, 'a' => 1.73, 'b' => 1.8, 'c' => 1.51, 'd' => 1.8, 'e' => 1.73, 'f' => 1.05, 'g' => 1.8, 'h' => 1.82, 'i' => 0.78, 'j' => 0.93, 'k' => 1.64, 'l' => 0.78,
'ł' => 0.93, 'm' => 2.73, 'n' => 1.82, 'o' => 1.78, 'p' => 1.8, 'r' => 1.2, 's' => 1.45, 't' => 1.11, 'u' => 1.82, 'w' => 2.91, 'x' => 1.62, 'y' => 1.64, 'z' => 1.45,
'0' => 1.78, '1' => 1.78, '2' => 1.78, '3' => 1.78, '4' => 1.78, '5' => 1.78, '6' => 1.78, '7' => 1.78, '8' => 1.78, '9' => 1.78, 'A' => 1.96, 'B' => 1.91, 'C' => 1.96,
'D' => 2.2, 'E' => 1.84, 'F' => 1.71, 'G' => 2.18, 'H' => 2.2, 'I' => 1.22, 'J' => 1.36, 'Ł' => 1.69, 'K' => 1.91, 'L' => 1.63, 'M' => 2.51, 'N' => 2.16, 'O' => 2.31,
'P' => 1.8, 'R' => 2.02, 'S' => 1.82, 'T' => 2.09, 'U' => 2.15, 'W' => 2.93, 'X' => 1.91, 'Y' => 1.89, 'Z' => 1.82, '(' => 1.2, ')' => 1.2, '-' => 1.2, 'â' => 1.8,
'â' => 2.93, 'nbsp' => 1.11,
|
|
 |