QImage PyramidThumbnailGenerator::generate( const QString &filename ) const
{
    QImage image = DynamicTexture( filename ).getRootImage();
    if( !image.isNull( ))
    {
        image = image.scaled( size_, aspectRatioMode_ );
        addMetadataToImage( image, filename );
        return image;
    }
    else
    {
        put_flog( LOG_ERROR, "could not open pyramid file: '%s'",
                  filename.toLatin1().constData( ));
        return createErrorImage( "pyramid" );
    }
}
예제 #2
0
	bool FontData::render(const String& codePoints)
	{
		if (!m_faceText)
		{
			return false;
		}

		bool hasDirty = false;

		for (const auto& codePoint : codePoints)
		{
			if (m_glyphIndexTable.find(codePoint) != m_glyphIndexTable.end())
			{
				continue;
			}

			const FT_UInt glyphIndexText = ::FT_Get_Char_Index(m_faceText.face, codePoint);
			const FT_UInt glyphIndexEmoji = (glyphIndexText != 0) ? 0 : m_faceEmoji ? ::FT_Get_Char_Index(m_faceEmoji.face, codePoint) : 0;

			if (glyphIndexText == 0 && glyphIndexEmoji == 0)
			{
				if (!m_tofuIndex)
				{
					if (!renderGlyph(m_faceText.face, 0))
					{
						continue;
					}

					hasDirty = true;

					m_tofuIndex = static_cast<CommonGlyphIndex>(m_glyphs.size() - 1);
				}

				m_glyphIndexTable.emplace(codePoint, m_tofuIndex.value());
			}
			else
			{
				const FT_Face face = (glyphIndexText != 0) ? m_faceText.face : m_faceEmoji.face;
				const FT_UInt glyphIndex = (glyphIndexText != 0) ? glyphIndexText : glyphIndexEmoji;

				renderGlyph(face, glyphIndex);

				hasDirty = true;

				m_glyphIndexTable.emplace(codePoint, static_cast<uint32>(m_glyphs.size() - 1));
			}
		}

		if (hasDirty)
		{
			if (m_image.size() == m_texture.size())
			{
				m_texture.fill(m_image);
			}
			else
			{
				const bool hasTexture = !!m_texture;
				const Size previousSize = m_texture.size();
				const Size newSize = m_image.size();

				m_texture = DynamicTexture(m_image);

				if (hasTexture)
				{
					LOG_DEBUG(U"ℹ️ Font texture resized ({0}x{1} -> {2}x{3})"_fmt(previousSize.x, previousSize.y, newSize.x, newSize.y));
				}
				else
				{
					LOG_DEBUG(U"ℹ️ Created font texture (size: {0}x{1})"_fmt(newSize.x, newSize.y));
				}
			}
		}

		return true;
	}