Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 5th, 2005, 09:06 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old August 8th, 2005, 08:55 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
Reply With Quote
  #3 (permalink)  
Old August 8th, 2005, 08:59 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Ingenious!! I'll give it a whirl.

Thanks

Mike

Mike
EchoVue.com
Reply With Quote
  #4 (permalink)  
Old August 8th, 2005, 01:37 PM
Authorized User
 
Join Date: Jun 2004
Location: , , USA.
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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"
Reply With Quote
  #5 (permalink)  
Old August 8th, 2005, 01:40 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
Reply With Quote
  #6 (permalink)  
Old August 8th, 2005, 01:43 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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
Reply With Quote
  #7 (permalink)  
Old February 13th, 2010, 05:49 AM
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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);
Reply With Quote
  #8 (permalink)  
Old February 13th, 2010, 10:55 AM
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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,
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DetailsView and Column Widths AspNetGuy ASP.NET 3.5 Basics 1 June 7th, 2008 04:34 PM
character entity into numeric character entity srkumar XSLT 1 November 22nd, 2007 04:53 AM
margin:auto, IE vs. Images + widths, vert. placmnt mishagos BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 5 July 16th, 2006 05:32 PM
Calculate ivangr Visual Basic 2005 Basics 0 April 9th, 2006 04:39 AM
Help me How to calculate minhtri VB How-To 4 June 8th, 2004 04:06 PM



All times are GMT -4. The time now is 09:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.