Important: Please read the Qt Code of Conduct -

Set Canvas Context2D font from local font

  • Hello, I have a set of fonts that are installed locally to my development machine. They are included within my qml.qrc file. My application is a QML app that will be deployed to an embedded device that doesn't have my specific TTF font intstalled. Within my application, I have a Canvas object with a 2D context, and I'd like to apply my font there. However, when I try to use

    context.font = "18px fontName";


    context.font = "18px qrc:/fonts/fontName.TTF"

    Neither appear to work on the target machine.

    I can get the font to work on the target machine with Text and FontLoader. But how can I load the font into a Canvas context?

Log in to reply