Using effective font name for text in a widget?
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Using effective font name for text in a widget?
How would I go about rendering text with the effective font of a widget? I want to leave the font name blank but be able to set the text size. I tried getting the font of the canvas in OnCreate() and grab the font name that way but I just got errors.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Using effective font name for text in a widget?
@trevordevore: At the moment, the answer to this question is 'with difficulty' - i.e. there isn't a way to do this.
At the moment textFont, textSize and textStyle are unreserved properties of widgets meaning you have to define them yourself but you get no inheritance.
In the short-term we could reserve them (make the engine manage them) and allow you to access the the widget's current font using 'my font'. This could go hand-in-hand with a 'OnFontChanged' event which occurs when the effective font changes.
At the moment textFont, textSize and textStyle are unreserved properties of widgets meaning you have to define them yourself but you get no inheritance.
In the short-term we could reserve them (make the engine manage them) and allow you to access the the widget's current font using 'my font'. This could go hand-in-hand with a 'OnFontChanged' event which occurs when the effective font changes.
Re: Using effective font name for text in a widget?
Something else worth noting is that the canvas only exists for the duration of the OnPaint event; it doesn't exist during any other events.
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Using effective font name for text in a widget?
@runrevmark - Personally I would prefer to have the engine reserve them and be able to access the settings. Not being able to inherit the font means extra code for looping through and setting the font on each widget.
@LCfraser - that is good to know. I wasn't aware of that.
BTW, I'm having a great time with widgets
@LCfraser - that is good to know. I wasn't aware of that.
BTW, I'm having a great time with widgets
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Using effective font name for text in a widget?
@trevordevore - glad to hear it. We're looking forward to seeing what everyone has been creating.
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Using effective font name for text in a widget?
@LCFraser - you should come to New York tomorrow then
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Using effective font name for text in a widget?
@trevordevore: Yes - I think that is the best approach for now... It should be possible to make 'inherited' properties general things including 'effective changed' type triggers. The idea is that eventually widget's will inherit from a common set of functionality which emulates the engine functionality but completely in LCB, rather than mixing the old engine logic and new widget logic. That is a little way off though
Re: Using effective font name for text in a widget?
@trevordevore: I've filed this request as : http://quality.runrev.com/show_bug.cgi?id=14898
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Using effective font name for text in a widget?
Thanks @runrevmark.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Using effective font name for text in a widget?
@trevordevore: Here's a pull request for this feature - http://quality.runrev.com/show_bug.cgi?id=14898
It adds the 'my font' syntax which returns a Canvas.Font, derived from the textFont, textSize and textStyle properties.
The textFont, textSize and textStyle properties are now reserved by the engine.
When they change you'll get an OnParentPropertyChanged event where you can take any appropriate action (such as measuring things again and such).
It adds the 'my font' syntax which returns a Canvas.Font, derived from the textFont, textSize and textStyle properties.
The textFont, textSize and textStyle properties are now reserved by the engine.
When they change you'll get an OnParentPropertyChanged event where you can take any appropriate action (such as measuring things again and such).
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Using effective font name for text in a widget?
Fantastic. Thanks Mark.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Using effective font name for text in a widget?
LCMark - Is there a way to determine which property changed in OnParentPropertyChanged? I would only want to redraw all if one of the text properties was modified. Or are those the only parent props that get inherited?
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Using effective font name for text in a widget?
@trevordevore: At the moment there is no way to do that - the engine doesn't pass that information along to any control. The engine (I believe) also does a redraw all on any widget which has its parent property changed anyway - so even if you could find out, you would still end up being redrawn. (This isn't too much of an issue though - the engine needs to repaint any children completely if a parent prop changes which isn't text related as it might affect the background behind semi-opaque widgets if it is one of the colors).
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Using effective font name for text in a widget?
Ah, I didn't realize it would be redrawn automatically. All good now.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: Using effective font name for text in a widget?
@trevordevore: I still suggest doing a redraw all when you think you need to (in parentpropchanged) just in case the engine becomes a little more discerning in the future!