How to set a Font in a StringMorph?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set a Font in a StringMorph?

Fredrik Alink
Hi,

I got a nice way of creating button Morphs somewhere on the Web. However, for showing the button label it uses the StringMorph. In StringMorph I find the method “font: aFont”. Could I use that for setting the Font shown on the button? And what should I use as aFont? Doing “aFont := TextMorph new …..” is wrong. Are there other ways to get to an alternative of the default font through the StringMorph?

What I did so far:

My Class instance:
        labelMorph := (ButtonElementMorph “new”)
                createLabelMorph: aLabel
                withEmphasis: anEmphasis
                withFont: aFont.

What I found on the web – ButtonElementMorph Class instance:
        (StringMorph contents: aLabel)
                emphasis: anEmphasis;
                font: aFont.

StringMorph class instance:
        emphasis: anEmphasis.
        font: aFont “can I use this and what should I place here?”

Thank you in advance for giving me th right direction to find a solution!

Fredrik
jrm
Reply | Threaded
Open this post in threaded view
|

Re: How to set a Font in a StringMorph?

jrm
Fredrik,

It looks like you have not received a reply yet. Does this help?

font: ((TextStyle named: #Atlanta ) fontOfSize: 14)

jrm

On Fri, Sep 4, 2015 at 3:51 PM, Fredrik Alink <[hidden email]> wrote:
Hi,

I got a nice way of creating button Morphs somewhere on the Web. However,
for showing the button label it uses the StringMorph. In StringMorph I find
the method “font: aFont”. Could I use that for setting the Font shown on the
button? And what should I use as aFont? Doing “aFont := TextMorph new …..”
is wrong. Are there other ways to get to an alternative of the default font
through the StringMorph?

What I did so far:

*My Class instance:*
        labelMorph := (ButtonElementMorph “new”)
                createLabelMorph: aLabel
                withEmphasis: anEmphasis
                /withFont: aFont./

What I found on the web – *ButtonElementMorph Class instance:*
        (StringMorph contents: aLabel)
                emphasis: anEmphasis;
                /font: aFont./

*StringMorph class instance:*
        emphasis: anEmphasis.
        /font: aFont/ “can I use this and what should I place here?”

Thank you in advance for giving me th right direction to find a solution!

Fredrik




--
View this message in context: http://forum.world.st/How-to-set-a-Font-in-a-StringMorph-tp4848183.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to set a Font in a StringMorph?

Fredrik Alink
Ha, the server is back on-line!

Thank you very much John-Reed, that was the right place. Here's the result:


Fredrik