Exemplo n.º 1
0
    void CanvasTextFormat::SetShadowPropertiesFromDWrite()
    {
        assert(m_format);

        ThrowIfFailed(m_format->GetFontCollection(&m_fontCollection));

        m_flowDirection      = ToCanvasTextDirection(m_format->GetFlowDirection());
        m_fontFamilyName     = GetFontFamilyName(m_format.Get());
        m_fontSize           = m_format->GetFontSize();
        m_fontStretch        = ToWindowsFontStretch(m_format->GetFontStretch());
        m_fontStyle          = ToWindowsFontStyle(m_format->GetFontStyle());
        m_fontWeight         = ToWindowsFontWeight(m_format->GetFontWeight());
        m_incrementalTabStop = m_format->GetIncrementalTabStop();
        m_localeName         = GetLocaleName(m_format.Get());
        m_verticalAlignment  = ToCanvasVerticalAlignment(m_format->GetParagraphAlignment());
        m_paragraphAlignment = ToWindowsParagraphAlignment(m_format->GetTextAlignment());
        m_readingDirection   = ToCanvasTextDirection(m_format->GetReadingDirection());
        m_wordWrapping       = ToCanvasWordWrapping(m_format->GetWordWrapping());
        m_drawTextOptions    = CanvasDrawTextOptions::Default;

        DWRITE_LINE_SPACING_METHOD method{};
        ThrowIfFailed(m_format->GetLineSpacing(&method, &m_lineSpacing, &m_lineSpacingBaseline));
        m_lineSpacingMethod = ToCanvasLineSpacingMethod(method);

        DWRITE_TRIMMING trimmingOptions{};
        ComPtr<IDWriteInlineObject> inlineObject;
        ThrowIfFailed(m_format->GetTrimming(
            &trimmingOptions,
            &inlineObject));

        m_trimmingGranularity = ToCanvasTextTrimmingGranularity(trimmingOptions.granularity);
        m_trimmingDelimiter = ToCanvasTrimmingDelimiter(trimmingOptions.delimiter);
        m_trimmingDelimiterCount = trimmingOptions.delimiterCount;
    }
Exemplo n.º 2
0
 IFACEMETHODIMP CanvasTextFormat::get_LocaleName(HSTRING* value)
 {
     return PropertyGet(
         value,
         m_localeName,
         [&]
         {
             return GetLocaleName(m_format.Get());
         });
 }
Exemplo n.º 3
0
QTranslator* LeechCraft::Util::InstallTranslator (const QString& baseName,
		const QString& prefix,
		const QString& appName)
{
	const auto& localeName = GetLocaleName ();
	if (auto transl = LoadTranslator (baseName, localeName, prefix, appName))
	{
		qApp->installTranslator (transl);
		return transl;
	}

	qWarning () << Q_FUNC_INFO
			<< "could not load translation file for locale"
			<< localeName
			<< baseName
			<< prefix
			<< appName;
	return nullptr;
}
Exemplo n.º 4
0
QTranslator* LeechCraft::Util::InstallTranslator (const QString& baseName,
		const QString& prefix,
		const QString& appName)
{
	QString localeName = GetLocaleName ();
	QString filename = prefix;
	filename.append ("_");
	if (!baseName.isEmpty ())
		filename.append (baseName).append ("_");
	filename.append (localeName);

	QTranslator *transl = new QTranslator;
#ifdef Q_WS_WIN
	if (transl->load (filename, ":/") ||
			transl->load (filename,
					QCoreApplication::applicationDirPath () + "/translations"))
#elif defined (Q_WS_MAC)
	if (transl->load (filename, ":/") ||
			transl->load (filename,
					QCoreApplication::applicationDirPath () + "/../Resources/translations"))
#else
	if (transl->load (filename, ":/") ||
			transl->load (filename,
					QString ("/usr/local/share/%1/translations").arg (appName)) ||
			transl->load (filename,
					QString ("/usr/share/%1/translations").arg (appName)))
#endif
	{
		qApp->installTranslator (transl);
		return transl;
	}
	delete transl;

	qWarning () << Q_FUNC_INFO
		<< "could not load translation file for locale"
		<< localeName
		<< filename;
	return 0;
}
Exemplo n.º 5
0
QString LeechCraft::Util::GetLanguage ()
{
	return GetLocaleName ().left (2);
}