From 34e7226ac88e14d4cfed6bc0d63da215afe0ac88 Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Tue, 15 May 2012 13:13:44 +0200
Subject: [PATCH] STORM-276 FIXED Squiggles overflow line editor height when
 font size is set to large

- Also reduced squiggle width from 6 to 4 and prevented running past the end of a word
---
 indra/llrender/llfontgl.cpp | 10 ++++++++++
 indra/llrender/llfontgl.h   |  2 ++
 indra/llui/lllineeditor.cpp | 15 +++++++++++----
 indra/llui/lltextbase.cpp   | 11 +++++++----
 4 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index fccbf37a8dd..4dc2fcd7146 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -422,6 +422,16 @@ S32 LLFontGL::renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y
 }
 
 // font metrics - override for LLFontFreetype that returns units of virtual pixels
+F32 LLFontGL::getAscenderHeight() const
+{ 
+	return mFontFreetype->getAscenderHeight() / sScaleY;
+}
+
+F32 LLFontGL::getDescenderHeight() const
+{ 
+	return mFontFreetype->getDescenderHeight() / sScaleY;
+}
+
 S32 LLFontGL::getLineHeight() const
 { 
 	return llceil(mFontFreetype->getAscenderHeight() / sScaleY) + llceil(mFontFreetype->getDescenderHeight() / sScaleY);
diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h
index 74bdbb43e74..5ed5d2c4ebe 100644
--- a/indra/llrender/llfontgl.h
+++ b/indra/llrender/llfontgl.h
@@ -115,6 +115,8 @@ class LLFontGL
 	S32 renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style = NORMAL, ShadowType shadow = NO_SHADOW) const;
 
 	// font metrics - override for LLFontFreetype that returns units of virtual pixels
+	F32 getAscenderHeight() const;
+	F32 getDescenderHeight() const;
 	S32 getLineHeight() const;
 
 	S32 getWidth(const std::string& utf8text) const;
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index f119b0d9bcd..d87b9d930c4 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -1727,6 +1727,10 @@ void LLLineEditor::draw()
 	background.stretch( -mBorderThickness );
 
 	S32 lineeditor_v_pad = (background.getHeight() - mGLFont->getLineHeight()) / 2;
+	if (mSpellCheck)
+	{
+		lineeditor_v_pad += 1;
+	}
 
 	drawBackground();
 	
@@ -1945,12 +1949,15 @@ void LLLineEditor::draw()
 			if (pxEnd > pxWidth)
 				pxEnd = pxWidth;
 
+			S32 pxBottom = (S32)(text_bottom + mGLFont->getDescenderHeight());
+
 			gGL.color4ub(255, 0, 0, 200);
-			while (pxStart < pxEnd)
+			while (pxStart + 1 < pxEnd)
 			{
-				gl_line_2d(pxStart, (S32)text_bottom - 2, pxStart + 3, (S32)text_bottom + 1);
-				gl_line_2d(pxStart + 3, (S32)text_bottom + 1, pxStart + 6, (S32)text_bottom - 2);
-				pxStart += 6;
+				gl_line_2d(pxStart, pxBottom, pxStart + 2, pxBottom - 2);
+				if (pxStart + 3 < pxEnd)
+					gl_line_2d(pxStart + 2, pxBottom - 3, pxStart + 4, pxBottom - 1);
+				pxStart += 4;
 			}
 		}
 	}
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 990c442b739..4db1efdd20c 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -688,12 +688,15 @@ void LLTextBase::drawText()
 				squiggle_start += squiggle_end / 2 - pony * 3;
 				squiggle_end = squiggle_start + pony * 6;
 
+				S32 squiggle_bottom = text_rect.mBottom + (S32)cur_segment->getStyle()->getFont()->getDescenderHeight();
+
 				gGL.color4ub(255, 0, 0, 200);
-				while (squiggle_start < squiggle_end)
+				while (squiggle_start + 1 < squiggle_end)
 				{
-					gl_line_2d(squiggle_start, text_rect.mBottom - 2, squiggle_start + 3, text_rect.mBottom + 1);
-					gl_line_2d(squiggle_start + 3, text_rect.mBottom + 1, squiggle_start + 6, text_rect.mBottom - 2);
-					squiggle_start += 6;
+					gl_line_2d(squiggle_start, squiggle_bottom, squiggle_start + 2, squiggle_bottom - 2);
+					if (squiggle_start + 3 < squiggle_end)
+						gl_line_2d(squiggle_start + 2, squiggle_bottom - 3, squiggle_start + 4, squiggle_bottom - 1);
+					squiggle_start += 4;
 				}
 
 				if (misspell_it->second > seg_end)
-- 
GitLab