spacevil icon indicating copy to clipboard operation
spacevil copied to clipboard

TextEdit.SetFontSize() not setting font size

Open spektro37 opened this issue 5 years ago • 2 comments

Have tried to use TextEdit.SetFontSize() the same way I have used it with the Label element, but when I have looked at the Mimic example I found that SetFont() and SetSubstrateFontSize() are used instead. It is a bit unexpected that SetFontSize() is available, but has no effect. In fact, using SetFont() and SetSubstrateFontSize() also had no effect. :)

Have tried manipulating font size in the code below:

TextEdit textEdit = new TextEdit();
textEdit.SetFont(DefaultsService.GetDefaultFont(5));
textEdit.SetSubstrateText("Placeholder");
textEdit.SetSubstrateFontStyle(FontStyle.Regular);
textEdit.SetSubstrateFontSize(5);
textEdit.SetHeightPolicy(SizePolicy.Fixed);
textEdit.SetHeight(5);

Could you please let me know if I am missing something in my code?

spektro37 avatar Feb 08 '20 23:02 spektro37

Strange but your code works fine for me.

public class MyWindow : ActiveWindow
{
    public override void InitWindow()
    {
        // window parameters
        SetParameters("MyWindow", "MyWindow", 300, 300);

        TextEdit textEdit = new TextEdit();
        textEdit.SetFont(DefaultsService.GetDefaultFont(5));
        textEdit.SetSubstrateText("Placeholder");
        textEdit.SetSubstrateFontStyle(FontStyle.Regular);
        textEdit.SetSubstrateFontSize(5);
        textEdit.SetHeightPolicy(SizePolicy.Fixed);
        textEdit.SetHeight(5);
            
        AddItem(textEdit);
    }
}

Result: image

But I do not understand why do you set font size to 5?))
May be I do not understand your question... Do SetFontSize(), SetFont() and SetSubstrateFontSize() have no effect in your demo app?

spvessel avatar Feb 09 '20 08:02 spvessel

May be you are confused that I used SetFont(DefaultsService.GetDefaultFont(5)) instead of SetFontSize(5). I did that only to show that there is class-service DefaultService that could be useful.

spvessel avatar Feb 09 '20 09:02 spvessel