6#include "QskGlyphGraphicProvider.h"
8#include "QskGlyphTable.h"
12#include <qpainterpath.h>
14class QskGlyphGraphicProvider::PrivateData
20QskGlyphGraphicProvider::QskGlyphGraphicProvider( QObject* parent )
22 , m_data( new PrivateData )
26QskGlyphGraphicProvider::~QskGlyphGraphicProvider()
30void QskGlyphGraphicProvider::setIconFont(
const QRawFont& font )
32 m_data->glyphTable.setIconFont( font );
35QRawFont QskGlyphGraphicProvider::iconFont()
const
37 return m_data->glyphTable.iconFont();
40QskGraphic QskGlyphGraphicProvider::glyphGraphic( uint index )
const
42 return m_data->glyphTable.glyphGraphic( index );
45const QskGraphic* QskGlyphGraphicProvider::loadGraphic(
const QString& key )
const
47 if (
const auto index = glyphIndex( key ) )
49 const auto graphic = glyphGraphic( index );
50 if ( !graphic.isNull() )
57uint QskGlyphGraphicProvider::glyphIndex(
const QString& key )
const
59 const auto& table = m_data->glyphTable;
61 if ( ( table.glyphCount() > 0 ) && !key.isEmpty() )
63 if ( key.startsWith(
'#' ) )
66 const auto glyphIndex = key.toUInt( &ok );
70 else if ( key.startsWith(
"U+" ) )
73 const char32_t code = key.mid( 2 ).toUInt( &ok, 16 );
75 return table.codeToIndex( code );
79 return table.nameToIndex( key );
A paint device for scalable graphics.