Pharo Smalltalk customizes font sizes, styles and backgrounds

Basically I have 2 problems, I am trying to code a simple GUI using Pharo 4.0 Smalltalk. I cannot change the font size / style in pharo for my labels or textareas /. I also cannot change their background colors and border widths. I've tried everything:

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 do it?

+3


source to share


2 answers


The color must be a text attribute (TextColor) in TextMorph, the font is not a text attribute (see the class in the text). Is Atlanta StrikeFont or truetype? StrikeFonts are old bitmap fonts. For some simple code showing custom colors, fonts and borders, you can download CardMorphic from the config browser



0


source


As for the background colors and border widths, it works great, you add openInWorld

.

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

      



enter image description here

0


source







All Articles