Many thanks for the almost instant response to my previous query, but I'm
afraid that I'm still having problems with the FormattedWidth property. The
stack I'm developing needs to display a small amount of text at a large
point size - basically filling the screen with a few large characters. When
the stack is resized, I want a field to resize automatically (no problem),
then change its textSize to display its contents 'as big as possible'! I've
tried to code this behaviour by getting the formattedWidth of the field, and
comparing this to its width - and reducing the textSize if it's too big to
fit. (Obviously I need to check that the field is high enough as well, but
that isn't the problem at the moment.) Now, I seem to be getting unexpected
values of formattedWidth - particularly when the textSize is large.
I've tried to pin down an example of where things go horribly wrong, as
follows...
I made a stack with fields called demoField and resultField. I added a
button with the following script:
on mouseup
put "Demo Text" into fld "demoField"
put "" into fld "resultField"
set the textSize of cd fld "demofield" to 300
--set the dontWrap, just to be sure!
set the dontWrap of cd fld "demofield" to true
--now increase the textSize, reporting results in resultField
repeat with x = 1 to 20
set the textSize of fld "demoField" to the textSize of fld "demoField" +
5
put "Text Size: " & the textSize of fld demoField & "; FormattedWidth: "
& the formattedWidth of fld demoField & return after fld resultfield
end repeat
end mouseup
When I click on the button, I get the following results reported in
resultField:
Text Size: 305; FormattedWidth: 1376
Text Size: 310; FormattedWidth: 1398
Text Size: 315; FormattedWidth: 1428
Text Size: 320; FormattedWidth: 1454
Text Size: 325; FormattedWidth: 1480
Text Size: 330; FormattedWidth: 1506
Text Size: 335; FormattedWidth: 1535
Text Size: 340; FormattedWidth: 1560
Text Size: 345; FormattedWidth: 1587
Text Size: 350; FormattedWidth: 1612
Text Size: 355; FormattedWidth: 1637
Text Size: 360; FormattedWidth: 1665
Text Size: 365; FormattedWidth: 1437
Text Size: 370; FormattedWidth: 1462
Text Size: 375; FormattedWidth: 1489
Text Size: 380; FormattedWidth: 1516
Text Size: 385; FormattedWidth: 1542
Text Size: 390; FormattedWidth: 1570
Text Size: 395; FormattedWidth: 1594
Text Size: 400; FormattedWidth: 1364
All seems to be OK as far as a text size of 360 pts, but increasing the size
to 365 results in a decrease in the formattedWidth, from 1665 to 1437.
Things then start heading steadily upwards again until the text size hits
400, when the formattedWidth drops once more.
(The font of demoField was set to Geneva. Although the numbers vary, similar
problems arise when other fonts are used. The field was 472 wide and 504
high.)
This is with Revolution 1.0, MacOS 9.0.4.
Any ideas?
TIA,
Derek.