6#include <private/qfontengine_p.h>
7#include <private/qrawfont_p.h>
34 m_referenceFont =
font;
37 m_font = vgCreateFont(0);
42 if (m_font != VG_INVALID_HANDLE)
43 vgDestroyFont(m_font);
54 qWarning(
"Warning: glyph is not available with index %d", glyphIndex);
58 referencedGlyphs.
insert(glyphIndex);
61 if (!m_glyphReferences.
contains(glyphIndex)) {
62 newGlyphs.
insert(glyphIndex);
66 referenceGlyphs(referencedGlyphs);
68 requestGlyphs(newGlyphs);
77 unusedGlyphs.
insert(glyphIndex);
79 releaseGlyphs(unusedGlyphs);
82void QSGOpenVGFontGlyphCache::requestGlyphs(
const QSet<quint32> &glyphs)
85 VGfloat escapement[2];
88 for (
auto glyph : glyphs) {
92 if (!
path.isEmpty()) {
96 vgPath = VG_INVALID_HANDLE;
102 vgSetGlyphToPath(m_font, glyph, vgPath, VG_FALSE, origin, escapement);
103 vgDestroyPath(vgPath);
108void QSGOpenVGFontGlyphCache::referenceGlyphs(
const QSet<quint32> &glyphs)
110 for (
auto glyph : glyphs) {
111 if (m_glyphReferences.
contains(glyph))
112 m_glyphReferences[glyph] += 1;
114 m_glyphReferences.
insert(glyph, 1);
118void QSGOpenVGFontGlyphCache::releaseGlyphs(
const QSet<quint32> &glyphs)
120 for (
auto glyph : glyphs) {
121 int references = m_glyphReferences[glyph] -= 1;
122 if (references == 0) {
123 vgClearGlyph(m_font, glyph);
124 m_glyphReferences.
remove(glyph);
virtual int glyphCount() const
bool remove(const Key &key)
Removes the item that has the key from the hash.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
static QRawFontPrivate * get(const QRawFont &font)
The QRawFont class provides access to a single physical instance of a font.
QPainterPath pathForGlyph(quint32 glyphIndex) const
This function returns the shape of the glyph at a given glyphIndex in the underlying font if the QRaw...
QSGOpenVGFontGlyphCache * cache(const QRawFont &font)
QSGOpenVGFontGlyphCacheManager()
void insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache)
~QSGOpenVGFontGlyphCacheManager()
void populate(const QVector< quint32 > &glyphs)
void release(const QVector< quint32 > &glyphs)
QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font)
~QSGOpenVGFontGlyphCache()
iterator insert(const T &value)
qDeleteAll(list.begin(), list.end())
QCache< int, Employee > cache
[0]
VGPath qPainterPathToVGPath(const QPainterPath &path)
Combined button and popup list for selecting options.
GLenum GLenum GLsizei count
GLsizei const GLchar *const * path
QNetworkAccessManager manager