MojoX : How to change the font?

About Monkey 2 Forums Monkey 2 Programming Help MojoX : How to change the font?

This topic contains 6 replies, has 2 voices, and was last updated by  Ratchet 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #15384

    Ratchet
    Participant

    I simply want to change the font of a TextView at runtime. But it doesn’t work.

    #15398

    nerobot
    Participant

    You didn’t assign loaded font, so it didn’t changed.

    Correct way:

    inputView.Style.Font = Font.Load("asset::calibri.ttf", 20)

    #15410

    Ratchet
    Participant

    This loads the font but it’s messed up. Also the input caret is on the wrong position. Seems like the TextView has to be updated or something…

     

    EDIT: Ok, InvalidateStyle does the trick.

    #15411

    nerobot
    Participant

    You can use theme file to setup fonts and other views related stuff in json format, similar to css, look at assets/themes/ folder of you compiled app to see what theme file is, default.json.

    But you need to create and set your own theme file based on that default given from mojox.

    Your screen looks like there are two intersected labels.

    #15412

    Ratchet
    Participant

    No, it’s really just the one TextView messed up the font. Solution in my post above.

    Btw: I just want to change the font of one TextView to a very special font. So the theme file won’t work because it changes all of them 😉

    #15413

    nerobot
    Participant

    Good.

    Also note, that all your TextView now will have such font.

    To separate them, use inputView.Style = inputView.Style.Copy().

    #15414

    Ratchet
    Participant

    Great, thanks.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.