En esta página

FontLoader QML Type

Permite cargar fuentes por URL. Más...

Import Statement: import QtQuick

Propiedades

Descripción detallada

El tipo FontLoader se utiliza para cargar fuentes por URL.

La dirección status indica cuándo se ha cargado la fuente, lo que resulta útil para fuentes cargadas desde fuentes remotas.

Por ejemplo:

import QtQuick 2.0

Column {
    FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }

    Text { text: "Fancy font"; font: webFont.font }
}

Véase también Qt Quick Ejemplos - Fuentes de texto.

Documentación de propiedades

font : font [read-only, since 6.0]

Esta propiedad contiene una consulta por defecto para la fuente cargada.

Puede utilizarla para seleccionar la fuente si se necesitan otras propiedades además del nombre de la familia para desambiguar. Puede especificar la fuente utilizando propiedades individuales:

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.styleName: webFont.font.styleName
        font.pixelSize: 24
    }
}

O puede establecer directamente la consulta de fuente completa:

Item {
    width: 200; height: 50

    FontLoader {
        id: webFont
        source: "http://www.mysite.com/myfont.ttf"
    }
    Text {
        text: "Fancy font"
        font: webFont.font
    }
}

En este caso, la consulta de fuente predeterminada se utilizará sin modificaciones (por lo que el tamaño de fuente, por ejemplo, será el predeterminado del sistema).

Esta propiedad se introdujo en Qt 6.0.

name : string [read-only]

Esta propiedad contiene el nombre de la familia de fuentes. Se establece automáticamente cuando se carga una fuente utilizando la propiedad source.

Es equivalente a la propiedad family de la propiedad font de FontLoader.

Utilícela para establecer la propiedad font.family de un elemento Text.

Ejemplo:

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

La URL de la fuente a cargar.

status : enumeration [read-only]

Esta propiedad contiene el estado de carga de la fuente. Puede ser uno de los siguientes

ConstanteDescripción
FontLoader.Nullno se ha cargado ninguna fuente
FontLoader.Readyla fuente ha sido cargada
FontLoader.Loadingse está cargando el tipo de letra
FontLoader.Errorse ha producido un error al cargar la fuente

Utilice este estado para proporcionar una actualización o responder al cambio de estado de alguna manera. Por ejemplo, podría

  • Activar un cambio de estado:
    State { name: 'loaded'; when: loader.status == FontLoader.Ready }
  • Implementar un manejador de señales onStatusChanged:
    FontLoader {
        id: loader
        onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded')
    }
  • Vincular al valor de estado:
    Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' }

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.