Allows fonts to be loaded by URL. 更多...
import 语句: | import QtQuick 2.2 |
The FontLoader type is used to load fonts by URL.
status indicates when the font has been loaded, which is useful for fonts loaded from remote sources.
例如:
import QtQuick 2.0 Column { FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" } Text { text: "Fancy font"; font: webFont.font } }
另请参阅 Qt Quick Examples - Text Fonts .
[since 6.0] font : font |
This property holds a default query for the loaded font.
You can use this to select the font if other properties than just the family name are needed to disambiguate. You can either specify the font using individual properties:
Item { width: 200; height: 50 FontLoader { id: webFont source: "http://www.mysite.com/myfont.ttf" } Text { text: "Fancy font" font.family: webFont.font.family font.weight: webFont.font.weight font.style: webFont.font.style font.pixelSize: 24 } }
Or you can set the full font query directly:
Item { width: 200; height: 50 FontLoader { id: webFont source: "http://www.mysite.com/myfont.ttf" } Text { text: "Fancy font" font: webFont.font } }
In this case, the default font query will be used with no modifications (so font size, for instance, will be the system default).
This property was introduced in Qt 6.0.
[read-only] name : string |
This property holds the name of the font family. It is set automatically when a font is loaded using the source 特性。
This is equivalent to the family property of the FontLoader 's font 特性。
Use this to set the
font.family
property of a
文本
项。
范例:
Item { width: 200; height: 50 FontLoader { id: webFont source: "http://www.mysite.com/myfont.ttf" } Text { text: "Fancy font" font.family: webFont.name } }
source : url |
The URL of the font to load.
status : enumeration |
This property holds the status of font loading. It can be one of:
Use this status to provide an update or respond to the status change in some way. For example, you could:
State { name: 'loaded'; when: loader.status == FontLoader.Ready }
onStatusChanged
signal handler:
FontLoader { id : loader onStatusChanged : if ( loader . status == FontLoader . Ready ) console . log ( 'Loaded' ) }
Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' }