Yeah, better solution :) Le 11 avr. 2010 à 22:56, Jesse MacFadyen a écrit :
> That would work, but there are easier ways. > > See: > http://stackoverflow.com/questions/504859/how-can-you-measure-the-space-that-a-text-will-take-in-javascript > > > > Sent from my iPhone > > On 2010-04-11, at 11:29 AM, Remi Grumeau <[email protected]> wrote: > >> well... >> The idea is quite simple: 26 letters, a javascript function that contains a >> two columns array, one for the letter and the second for a pixel value/group >> value (I in group 1, ABCDE… in group 2, WMQ in group 3) >> Then just add each value to know (approximatively, i assume) if the text >> will overflow the title box size or not, and apply a 0.9em or 0.8em font >> size to the text. >> >> Note that this will certainly play with the lisibility of the text… >> >> example here: >> http://remi-grumeau.com/labs/iui/letter-count.php?text=Wazaii >> http://remi-grumeau.com/labs/iui/letter-count.php?text=WazaiiZZaiaiZ >> (letters only included in this exemple: a, A, i, I, w, W, z and Z ) >> >> Remi >> >> Le 9 avr. 2010 à 12:48, Gonso a écrit : >> >>> Thanks for the tip! >>> >>> its a pity there is no automatic way, since the length depends not >>> only on the number of letters, but on the chars use. >>> iiii >>> 0000 >>> these two strings have a length of 4, but the size of the second is >>> twice the first (on most fonts). >>> >>> On the iPhone itself (Objective C) you can do something like this: >>> >>> CGSize labelSize = [cellText sizeWithFont:cellFont >>> constrainedToSize:constraintSize >>> lineBreakMode:UILineBreakModeWordWrap]; >>> >>> to figure out the size of the text. >>> >>> I was hoping to find the web-based version of this. >>> >>> g. >>> >>> On Apr 9, 9:06 am, Bruno Alexandre <[email protected]> wrote: >>>> you can always create your own method and call it at the end of the >>>> load. >>>> >>>> just do it by calculation: >>>> >>>> function reduceFontSize() [ >>>> $("all my tags that I want to check").each( function(e) { >>>> >>>> var len = $(this).text().length; >>>> if( len > 30 ) $(this).attr("style", "font-size:12px"); >>>> if( len >= 30 && len < 40 ) $(this).attr("style", "font-size:11px"); >>>> if( len >= 40 && len < 50 ) $(this).attr("style", "font-size:10px"); >>>> >>>> }); >>>> } >>>> >>>> then apply it. >>>> >>>> reduceFontSize(); >>>> >>>> Bruno Alexandre >>>> [web]www.balexandre.com >>>> [twitter]http://twitter.com/balexandre >>>> >>>> my Widgets for iPhone Web Development >>>> [iCal widget for jQTouch]http://code.google.com/p/jqtouch-ical/ >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "iPhoneWebDev" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/iphonewebdev?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "iPhoneWebDev" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/iphonewebdev?hl=en. >> > > > -- > You received this message because you are subscribed to the Google Groups > "iPhoneWebDev" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/iphonewebdev?hl=en. -- You received this message because you are subscribed to the Google Groups "iPhoneWebDev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/iphonewebdev?hl=en.
