From 7d6609a771a2cb69d5315fe70bb561802adacc80 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Fri, 22 Jun 2012 14:47:07 +0200 Subject: [PATCH] changed text scaling method from iteration to calculation (faster) --- Vocaluxe/Menu/CText.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Vocaluxe/Menu/CText.cs b/Vocaluxe/Menu/CText.cs index c44b68e3..012709dc 100644 --- a/Vocaluxe/Menu/CText.cs +++ b/Vocaluxe/Menu/CText.cs @@ -688,26 +688,27 @@ namespace Vocaluxe.Menu RectangleF bounds = CDraw.GetTextBounds(this); - while (bounds.Width > Bounds.W) + if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f) { - h -= 0.2f; - + float factor = Bounds.W / bounds.Width; + float step = h * (1 - factor); + h *= factor; switch (HAlign) { case EHAlignment.Top: - y += 0.05f; + y += step * 0.25f; break; case EHAlignment.Center: - y += 0.1f; + y += step * 0.50f; break; case EHAlignment.Bottom: - y += 0.15f; + y += step * 0.75f; break; default: break; } - - bounds = CDraw.GetTextBounds(this, h); + + bounds = CFonts.GetTextBounds(this, h); } switch (Align) @@ -792,19 +793,21 @@ namespace Vocaluxe.Menu float y = Y; RectangleF bounds = CFonts.GetTextBounds(this); - while (bounds.Width > Bounds.W) + if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f) { - h -= 0.2f; + float factor = Bounds.W / bounds.Width; + float step = h * (1 - factor); + h *= factor ; switch (HAlign) { case EHAlignment.Top: - y += 0.05f; + y += step * 0.25f; break; case EHAlignment.Center: - y += 0.1f; + y += step * 0.50f; break; case EHAlignment.Bottom: - y += 0.15f; + y += step * 0.75f; break; default: break;