June 15, 2012

Sypter Sypter
Lab Rat
8 posts

FontLoader: Load Entire Family Font Files

 

How can i load 4 font files with the same font type name?
I have trebuchet.ttf, trebucheti.ttf, trebuchetb.ttf and trebuchetbi.ttf and all of them have “Trebuchet MS” as their font type name.
When i use FontLoader i initially test if the font has been loaded before so it doesn’t end up failing:

  1. FontLoader{
  2.     id: trebuchet
  3. }
  4.  
  5. Component.onCompleted:{
  6.     var families = Qt.fontFamilies().toString();
  7.     if (families.match(/Trebuchet MS/i)) {
  8.        trebuchet.name = "Trebuchet MS";
  9.     } else {
  10.         trebuchet.source = "fonts/trebuchet.ttf";
  11.     }
  12. }

The problem is that they all use “Trebuchet MS” as their font type name, and that will end up making all fontloaders pointing to the default Trebuchet MS.

0 replies

 
  ‹‹ qsTr() and non-ASCII characters      [SOLVED] Are you able to extend QML via C++ with MSVC2010 ? ››

You must log in to post a reply. Not a member yet? Register here!