spvessel / spacevil

Simple examples of SpaceVIL implementation for C# / .NET Framework, C# / .NET Core and Java.
https://spvessel.com
MIT License
56 stars 7 forks source link

TextEdit.SetFontSize() not setting font size #6

Open spektro37 opened 4 years ago

spektro37 commented 4 years ago

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?

spvessel commented 4 years ago

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 commented 4 years ago

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.