mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	D2D: More tweaks (partially reverts ccb2731)
				
					
				
			Should account for extra padding when #CRLF# is used.
This commit is contained in:
		@@ -350,8 +350,9 @@ bool CanvasD2D::MeasureTextW(const WCHAR* str, UINT strLen, const TextFormat& fo
 | 
			
		||||
		textLayout.GetAddressOf());
 | 
			
		||||
	if (SUCCEEDED(hr))
 | 
			
		||||
	{
 | 
			
		||||
		std::wstring s = str;
 | 
			
		||||
		const DWRITE_TEXT_METRICS metrics =
 | 
			
		||||
			Util::GetAdjustedDWriteTextLayoutMetrics(textLayout.Get(), !m_AccurateText);
 | 
			
		||||
			Util::GetAdjustedDWriteTextLayoutMetrics(textLayout.Get(), !m_AccurateText, s.rfind(L"\n") != std::wstring::npos);
 | 
			
		||||
		rect.Width = metrics.width;
 | 
			
		||||
		rect.Height = metrics.height;
 | 
			
		||||
		return true;
 | 
			
		||||
@@ -375,7 +376,7 @@ bool CanvasD2D::MeasureTextLinesW(const WCHAR* str, UINT strLen, const TextForma
 | 
			
		||||
	if (SUCCEEDED(hr))
 | 
			
		||||
	{
 | 
			
		||||
		const DWRITE_TEXT_METRICS metrics =
 | 
			
		||||
			Util::GetAdjustedDWriteTextLayoutMetrics(textLayout.Get(), !m_AccurateText);
 | 
			
		||||
			Util::GetAdjustedDWriteTextLayoutMetrics(textLayout.Get(), !m_AccurateText, false);
 | 
			
		||||
		rect.Width = metrics.width;
 | 
			
		||||
		lines = metrics.lineCount;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ namespace Gfx {
 | 
			
		||||
namespace Util {
 | 
			
		||||
 | 
			
		||||
DWRITE_TEXT_METRICS GetAdjustedDWriteTextLayoutMetrics(
 | 
			
		||||
	IDWriteTextLayout* textLayout, bool gdiEmulation)
 | 
			
		||||
	IDWriteTextLayout* textLayout, bool gdiEmulation, bool containsNewLine)
 | 
			
		||||
{
 | 
			
		||||
	DWRITE_TEXT_METRICS metrics;
 | 
			
		||||
	textLayout->GetMetrics(&metrics);
 | 
			
		||||
@@ -34,7 +34,13 @@ DWRITE_TEXT_METRICS GetAdjustedDWriteTextLayoutMetrics(
 | 
			
		||||
		float size = 0.0f;
 | 
			
		||||
		textLayout->GetFontSize(0, &size);
 | 
			
		||||
		metrics.width = floor(metrics.width + ((size / 6.0f) * 4.0f) + ((size * 3.0f / 4.0f) / 17.5f) + 0.255f);
 | 
			
		||||
		metrics.height = floor(metrics.height * 1.087f);
 | 
			
		||||
		
 | 
			
		||||
		if (containsNewLine)
 | 
			
		||||
		{
 | 
			
		||||
			metrics.width -= ((size * 3.0f / 4.0f) / 4.0f);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		metrics.height = floor(metrics.height + (size / 9.25f) + 0.3f); 
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return metrics;
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ namespace Util {
 | 
			
		||||
// If |gdiEmulation| is true, the returns metrics have similar characteristics to those provided
 | 
			
		||||
// by GDI+.
 | 
			
		||||
DWRITE_TEXT_METRICS GetAdjustedDWriteTextLayoutMetrics(
 | 
			
		||||
	IDWriteTextLayout* textLayout, bool gdiEmulation);
 | 
			
		||||
	IDWriteTextLayout* textLayout, bool gdiEmulation, bool containsNewLine);
 | 
			
		||||
 | 
			
		||||
// Maps the GDI family name and italic/bold flags to the DirectWrite family name, weight, style,
 | 
			
		||||
// and stretch.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user