Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Design

Font size - how to make it fit

Author Message
Mads



Joined: 08 May 2005
Posts: 13
Location: Denmark

Posted: Mon Aug 08, 2005 - 7:04 am    Post subject: Font size - how to make it fit Reply with quote

I am currently working on a widget, which need to display a different title every day, but these titles are of varying length, so I'd like to know if there was some way to make the font-size adjust to the available area.

The only thing I can think of is using an estimate based on the word length, and then abjust the font size via JS. Is there a better way?


Sincerely

Mads
View user's profile Send private message Visit poster's website Widgets
cerberus



Joined: 20 Jun 2005
Posts: 118

Posted: Mon Aug 08, 2005 - 11:18 am    Post subject: Reply with quote

I had success that way.

I used Apple's "Grapher" to help me find good values for the text scaling factor parameters really fast. ( y = mx+b)... a simple equation for a sloped line worked nicely for me.

cerberus
View user's profile Send private message Send e-mail Visit poster's website Widgets
Mads



Joined: 08 May 2005
Posts: 13
Location: Denmark

Posted: Mon Aug 08, 2005 - 3:46 pm    Post subject: Reply with quote

Unfortunately I don't know what Apples "Grapher" is, but hopefully you could tell me Smile

How would the code look if for instance I wanted to use Lucida Grande? Or does anybody know how it works with the stickies widget auto font-size?

sincerely

Mads Wink
View user's profile Send private message Visit poster's website Widgets
cerberus



Joined: 20 Jun 2005
Posts: 118

Posted: Mon Aug 08, 2005 - 7:02 pm    Post subject: Reply with quote

Mads wrote:
Unfortunately I don't know what Apples "Grapher" is, but hopefully you could tell me Smile

How would the code look if for instance I wanted to use Lucida Grande? Or does anybody know how it works with the stickies widget auto font-size?

sincerely

Mads Wink


Does the Stickies widget do that ? If I knew I would have just stolen their code, though it was fun for me to come up with a way to write this part of the code without looking at other widgets or even consulting the internet.

Grapher is Apple's replacement for Graphing Calculator. I used to not pay attention in math class and I did not do my homework. So I used Grapher to remind myself that the general equation for a line is y = (slope)x + (the value of y when x=0) . This is like basic algebra stuff.... I am sure Grapher has a higher purpose, like trigonometry or... making something with really impressive geometric scaling functions like the Bedrock Biorhythms widget.

I don't understand the question about Lucida Grande. I think all the CSS parameters can be touched by via the DOM using "getElementById" and something like "innerHTML.style" ; So you could start with any font and then change the font on the fly, or the z-index value, or the opacity, or in this example: the font size only. It doesn't matter what the other style parameters are; each can be controlled independently.

cerberus
View user's profile Send private message Send e-mail Visit poster's website Widgets
Mads



Joined: 08 May 2005
Posts: 13
Location: Denmark

Posted: Thu Aug 11, 2005 - 4:04 am    Post subject: Reply with quote

Oh.. now I get it Smile . You just took some measurements and then made an regression. I thought you had a dedicated program for it, and therefore thought you could make a formula for Lucida Grande, but as I see now I can just as easily do it myself.

However: This way of doing it is only an approximation cause different letters (like "m" and "i") have very different length. If it is the only way It'll have to do, but if anybody could figure out how it works in "Stickies" I'd be a lot better. I can't myself cause I use x.3, and I am waiting to upgrade till I buy a new Mac (waiting on an Intel iMac)
View user's profile Send private message Visit poster's website Widgets
jon50



Joined: 14 Aug 2005
Posts: 2

Posted: Sun Aug 14, 2005 - 11:09 am    Post subject: Reply with quote

grapher comes standard in tiger...just in look in applications
View user's profile Send private message Send e-mail Widgets
Mads



Joined: 08 May 2005
Posts: 13
Location: Denmark

Posted: Sun Sep 04, 2005 - 6:23 am    Post subject: Ok - thanks for the help Reply with quote

I finaly decided not to scale the text, but shorten it instead, but still using cerberus' method of a linear function (letters as a function of available width). Thanks for your help Smile
View user's profile Send private message Visit poster's website Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group