ruhi mehta
ruhi mehta

Reputation: 103

Pharo Smalltalk customizing font sizes, styles and backgrounds

Basically I am having 2 problems, I am trying to code a simple GUI using Pharo 4.0 Smalltalk. I am not able to change font size/style in pharo for my labels or text areas/button. I am also not able to change their background colors and border widths. I have tried all ways:

font1 := (TextFontReference toFont: 
                (StrikeFont familyName: 'Atlanta' size: 22)).
TextMorph  new contents: ('test' asText addAttribute: font1); 
color: Color blue; 
autoFit: true; 
borderColor: Color green; 
borderWidth: 2.

SimpleButtonMorph new target: self;
label: 'test1';
actionSelector: #test1click; 
basicBorderColor: Color green; 
basicBorderWidth: 2; 
highlightColor: Color green.

TextMorph  new contents: 'test2'; 
color: Color blue; 
autoFit: true; 
borderColor: Color green; 
borderWidth: 2; 
font:'Atlanta' / fontName: 'Atlanta' pointSize: 22 / fontName: 'Arial' size: 32.

None of the above options work. basically I need to customize my fonts and backgrounds for buttons and labels. How should I go about this?

Upvotes: 3

Views: 1664

Answers (2)

z--
z--

Reputation: 2236

As for the background colors and border widths it works fine is you add openInWorld .

SimpleButtonMorph new target: self;
label: 'test1';
actionSelector: #test1click; 
basicBorderColor: Color green; 
basicBorderWidth: 2; 
highlightColor: Color green;
openInWorld 

enter image description here

Upvotes: 1

Stephan Eggermont
Stephan Eggermont

Reputation: 15917

The color should be a text attribute (TextColor) in a TextMorph, a font is not a text attribute (see class side of Text). Is Atlanta a StrikeFont or a truetype? StrikeFonts are the old bitmap fonts. For some simple code showing custom colors, fonts and borders, you might want to load CardsMorphic from the Configuration Browser

Upvotes: 0

Related Questions