-
Notifications
You must be signed in to change notification settings - Fork 0
Sketchbook
rmhdev edited this page Mar 23, 2013
·
4 revisions
Calculate font size
Aproximations (1:1 images):
- 50x50: 12pt
- 100x100: 18pt
- 200x200: 36pt
- 500x500: 90pt
Aproximations (rectangular images)
- 50x100: 12pt
- 100x50: 18pt
rectangular images: font size related to width?
- 20x100: < 5 pt (taking width as reference)
- 20x100: < 18 pt (taking height as reference)
Practical example:
In an image of 100 px, text should be 80 px length (aproximately)
the length of the text is: strlen("100x100")
We are searching for 18pt (aproximately).
(100*0.80) / 7 = 11.43
(100*0.80)*1.25 / 7 = 14.28
(100*0.80)*2 / 7 = 22.86
(100*0.80)*1.5 / 7 = 17.14
(100*0.80)*1.618 / 7 = 18.49 (ceil is 18) (1.618 = Golden ratio)
using 1.618 (Golden ratio) :
50x50: (50*0.80)*1.618 / 5 = 12.94 (floor is 12)
200x200: (200*0.80)*1.618 / 7 = 36.98 (floor is 36)
500x500: (500*0.80)*1.618 / 7 = 92.46 (floor is 92)
The formula (1st version):
fontSize = imageWidth*0.80*1.618 / length("WIDTHxHEIGHT")
For rectangular images:
100x50: (100*0.80)*1.618 / 6 = 21.57 (floor is 21)
Uhmmm... with width = 100, the fot size should be 18. Let`s change the "factor"
100x50: (100*0.80)*1.618 / 7 = 18.49 (floor is 18)
So the length must be calculated using the width (strlen("100x100") = 7) The formula (2nd version):
fontSize = imageWidth*0.80*1.618 / length("WIDTHxWIDTH")