Text Formatting Workarounds?

J. Landman Gay jacque at hyperactivesw.com
Wed Apr 22 15:44:55 EDT 2009


Scott Rossi wrote:

> In the past, I always thought it was a simple matter to set the font specs
> of the card or stack and have fields inherit the settings, but it seems in
> all my 3/3.5 stacks this doesn't work any more.  Rev seems to apply
> formatting based on the platform on which the stack was saved, and then
> promptly loses the specs when the stack is opened on another platform (the
> font/size properties read correctly, but the text doesn't display correctly,
> often shrinking down to some weird size/font).
> 
> Setting font specs of a field by script doesn't seem to do anything and in
> some cases compounds the problem since, for example, attempting to change
> the font or size of text will only change the textheight of field,
> positioning the text improperly in the field.

Like Jim, I meant to answer sooner too, but better late than never...

I don't think anything has changed in 3.0/3.5, but there are some 
general gotchas to be aware of when relying on font inheritance.

If you set the textfont, textstyle, or textsize of a stack (or card), 
fields will inherit those settings provided the field has no other 
formatting of its own. However, if you set the font *style* of a field 
or any text in it, the engine arbitrarily sets the textfont and textsize 
of the whole field to the currently displayed font and size. If you open 
the stack on a different platform, these text settings remain. The only 
way to ensure inheritance is not to set any textstyles on fields or 
individual text runs. (This may also apply to textsize, I can't remember.)

This didn't used to be the case, but was changed years and years ago in 
MC. When I want styled text that still uses inheritance, I save the 
styled htmlText as a custom property and load that when the field is 
displayed. This allows setting a stack-based font and size at startup, 
and the htmltext shows styled text strings without disrupting the 
inherited font.

It isn't pretty, I wish we still had the old way where fonts were not 
dependent on other text settings. One of the other repercussions of this 
is that setting a font for any object (stack, card, field) wipes out 
both the size and styling entirely. It used to be we could set the font 
independently while still retaining current size and styling, but that's 
been long-gone for a while.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list