SRL Archive - RS3 Help

[LAPE] TFontStyles issue


bg5

2014-06-27 07:09:01

Hey,
I translated my old function from PS to Lape:

procedure MakeFont(FLabel,Name:string;Size:integer;Style :TFontStyles);
var f:Tfont;
begin
f.init();
f.setName(Name);
f.setSize(Size);
f.setStyle(Style);
LoadSystemFont(f,FLabel);
f.Free;
end;

begin
MakeFont('Space','Arial',18,[fsBold, fsItalic]);
end.

and got an error:

Exception in Script: Expected variable of type "(fsBold=0, fsItalic=1, fsStrikeOut=2, fsUnderline=3)", got "set of (fsBold=0, fsItalic=1, fsStrikeOut=2, fsUnderline=3)" at line 16, column 11 at line 16, column 31

So TFontStyles is not an array of styles anymore, but a single element? How can you assign more then one style to the font?

Brandon

2014-06-27 10:57:20

From: bg5

So TFontStyles is not an array of styles anymore, but a single element? How can you assign more then one style to the font?



Use the bitwise-or operator.
Style[0] OR Style[1] OR Style[2]....




var
I, Style: Integer;

//.....

Style := Styles[0];
For I := 1 To High(Styles) Do
Style := Style OR Styles[I];

Font.setStyle(Style);
//....

bg5

2014-06-27 15:51:19

From: Brandon
Use the bitwise-or operator.
Style[0] OR Style[1] OR Style[2]....


You sure? Considering
fsBold=0, fsItalic=1, fsStrikeOut=2, fsUnderline=3

(fsBold OR fsItalic) = fsItalic

(fsItalic OR fsStrikeOut) = fsUnderline

BTW

Hmm…I wonder if it's not Lape bug, as plural names of types are usually for arrays and it seems to make things overcomplicated. Anyone could confirm ?

Olly

2014-06-27 16:02:24

From: bg5
You sure? Considering
fsBold=0, fsItalic=1, fsStrikeOut=2, fsUnderline=3

(fsBold OR fsItalic) = fsItalic

(fsItalic OR fsStrikeOut) = fsUnderline

BTW

Hmm…I wonder if it's not Lape bug, as plural names of types are usually for arrays and it seems to make things overcomplicated. Anyone could confirm ?


It's a bug where it was exported to Lape… Il fix in next simba version.

Press Play

2014-07-22 02:40:27

Has this been fixed? I can't seem to assign 2 styles to a font. Using it as an array I get:
Error: Expected variable of type "(fsBold=0, fsItalic=1, fsStrikeOut=2, fsUnderline=3)", got "set of (fsBold=0, fsItalic=1, fsStrikeOut=2, fsUnderline=3)"
Using Brandon's suggestion, I get
Error: Operator "OR" not compatible with types