Set font dynamically to fit text

Sannyasin Brahmanathaswami brahma at hindu.org
Sat Oct 12 23:01:23 EDT 2019


BR: Hmm I figured that  a repeat loop would do that, but was look for a "one-off-equation" 

		According to the "laws  of math" (ha... algebra....it has been such a long time; I could be wrong) if you have single unknown variable , X, and all others are known factors, you would, in theory, be able to work out X "in one go."
		The [number of characters, in a given font size/face, that can fit on one line of the field with a given length] is, in theory,  among "what can be the known"

		These little repeat loops are costly on mobile....

Paul wrote:
	your essentially want a repeat loop where you reduce the textSize of 
char 1 to -1 of the field until the formattedHeight of the field is less 
than or equal to the height of the field

You probably will need a condition in the loop to prevent the textSize 
from going below 9

BR question
	Assuming one is not putting whole pages into small fields, does any one have an efficient run time LC algorithm that will set the font size so that the formatted text will all appear in the field without needing to scroll?

BR





More information about the use-livecode mailing list