mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Gfx: Minor tweaks
This commit is contained in:
		@@ -84,18 +84,21 @@ void TextFormatD2D::CreateLayout(
 | 
			
		||||
				textLayout1->SetCharacterSpacing(emOffset, emOffset, 0.0f, range);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// If only one line is visible, disable wrapping so that as much text as possible is shown
 | 
			
		||||
			// after trimming.
 | 
			
		||||
			// TODO: Fix this for when more than one line is visible.
 | 
			
		||||
			UINT32 lineCount = 0;
 | 
			
		||||
			DWRITE_LINE_METRICS lineMetrics[2];
 | 
			
		||||
			HRESULT hr = m_TextLayout->GetLineMetrics(lineMetrics, _countof(lineMetrics), &lineCount);
 | 
			
		||||
			if (SUCCEEDED(hr) &&
 | 
			
		||||
				lineMetrics[0].isTrimmed &&
 | 
			
		||||
				lineMetrics[1].isTrimmed &&
 | 
			
		||||
				lineMetrics[1].height == 0.0f)
 | 
			
		||||
			if (SUCCEEDED(hr))
 | 
			
		||||
			{
 | 
			
		||||
				m_TextLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
 | 
			
		||||
				// If only one line is visible, disable wrapping so that as much text as possible is shown
 | 
			
		||||
				// after trimming.
 | 
			
		||||
				// TODO: Fix this for when more than one line is visible.
 | 
			
		||||
				if (lineCount >= 2 &&
 | 
			
		||||
					lineMetrics[0].isTrimmed &&
 | 
			
		||||
					lineMetrics[1].isTrimmed &&
 | 
			
		||||
					lineMetrics[1].height == 0.0f)
 | 
			
		||||
				{
 | 
			
		||||
					m_TextLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,9 @@ public:
 | 
			
		||||
		std::unique_ptr<TextFormatD2D> textFormat((TextFormatD2D*)m_D2D->CreateTextFormat());
 | 
			
		||||
		textFormat->SetProperties(L"Arial", 10, false, false, nullptr);
 | 
			
		||||
 | 
			
		||||
		DWRITE_TEXT_METRICS metrics = textFormat->GetMetrics(L"test", 4, true);
 | 
			
		||||
		DWRITE_TEXT_METRICS metrics;
 | 
			
		||||
 | 
			
		||||
		metrics = textFormat->GetMetrics(L"test", 4, true);
 | 
			
		||||
		Assert::AreEqual(26, (int)metrics.width);
 | 
			
		||||
		Assert::AreEqual(16, (int)metrics.height);
 | 
			
		||||
 | 
			
		||||
@@ -59,14 +61,22 @@ public:
 | 
			
		||||
		std::unique_ptr<TextFormatD2D> textFormat((TextFormatD2D*)m_D2D->CreateTextFormat());
 | 
			
		||||
		textFormat->SetProperties(L"Arial", 10, false, false, nullptr);
 | 
			
		||||
 | 
			
		||||
		DWRITE_TEXT_METRICS metrics = textFormat->GetMetrics(L"test\n", 5, false);
 | 
			
		||||
		DWRITE_TEXT_METRICS metrics;
 | 
			
		||||
		
 | 
			
		||||
		metrics = textFormat->GetMetrics(L"test\n", 5, false);
 | 
			
		||||
		Assert::AreEqual(15, (int)metrics.height);
 | 
			
		||||
		metrics = textFormat->GetMetrics(L"test\r\n", 6, false);
 | 
			
		||||
		Assert::AreEqual(15, (int)metrics.height);
 | 
			
		||||
 | 
			
		||||
		metrics = textFormat->GetMetrics(L"test\n ", 6, false);
 | 
			
		||||
		Assert::AreEqual(30, (int)metrics.height);
 | 
			
		||||
		metrics = textFormat->GetMetrics(L"test\r\n ", 7, false);
 | 
			
		||||
		Assert::AreEqual(30, (int)metrics.height);
 | 
			
		||||
 | 
			
		||||
		metrics = textFormat->GetMetrics(L"test\n\n", 6, false);
 | 
			
		||||
		Assert::AreEqual(30, (int)metrics.height);
 | 
			
		||||
		metrics = textFormat->GetMetrics(L"test\r\n\r\n", 8, false);
 | 
			
		||||
		Assert::AreEqual(30, (int)metrics.height);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user