In this patch, I change our new LyX logo inset to look like the real thing. Georg, is there a reason why your chose not to follow this route (or only lack of time/motivation).

Also, I am not sure that the Color_special color is the best choice (try to load the Intro manual, for example). Would it be a problem to use normal color once it is clear that the logo is something special, not plain text?

JMarc

>From a2c198a561b7ee28a14bbefe0164350110f4f020 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Fri, 13 Mar 2015 12:05:15 +0100
Subject: [PATCH] Improve display of LyX logo.

---
 src/insets/InsetSpecialChar.cpp |   32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index 77792b9..bc46465 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -49,6 +49,7 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 		theFontMetrics(mi.base.font);
 	dim.asc = fm.maxAscent();
 	dim.des = fm.maxDescent();
+	dim.wid = 0;
 
 	docstring s;
 	switch (kind_) {
@@ -65,7 +66,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 			s = from_ascii(" x ");
 			break;
 		case HYPHENATION:
-			s = from_ascii("-");
+			dim.wid = fm.width(from_ascii("-"));
+			if (dim.wid > 5)
+				dim.wid -= 2; // to make it look shorter
 			break;
 		case SLASH:
 			s = from_ascii("/");
@@ -73,9 +76,13 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 		case NOBREAKDASH:
 			s = from_ascii("-");
 			break;
-		case PHRASE_LYX:
-			s = from_ascii("LyX");
+		case PHRASE_LYX: {
+			double const em = fm.width('M');
+			dim.wid = fm.width(from_ascii("L")) - 0.16667 * em
+				+ fm.width(from_ascii("Y")) - 0.125 * em
+				+ fm.width(from_ascii("X"));
 			break;
+		}
 		case PHRASE_TEX:
 			s = from_ascii("TeX");
 			break;
@@ -86,10 +93,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 			s = from_ascii("LaTeX");
 			break;
 	}
-	dim.wid = fm.width(s);
-	if (kind_ == HYPHENATION && dim.wid > 5)
-		dim.wid -= 2; // to make it look shorter
-	
+	if (dim.wid == 0)
+		dim.wid = fm.width(s);
+
 	setDimCache(mi, dim);
 }
 
@@ -156,10 +162,18 @@ void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
 		pi.pain.text(x, y, char_type('-'), font);
 		break;
 	}
-	case PHRASE_LYX:
+	case PHRASE_LYX: {
 		font.setColor(Color_special);
-		pi.pain.text(x, y, from_ascii("LyX"), font);
+		// FIXME: this definition of em is bogus, but there is a need
+		// for a big refactoring of the code around this issue anyway.
+		double const em = theFontMetrics(font).width('M');
+		x += pi.pain.text(x, y, from_ascii("L"), font);
+		x -= 0.16667 * em;
+		x += pi.pain.text(x, y + 0.25 * em, from_ascii("Y"), font);
+		x -= 0.125 * em;
+		pi.pain.text(x, y, from_ascii("X"), font);
 		break;
+	}
 	case PHRASE_TEX:
 		font.setColor(Color_special);
 		pi.pain.text(x, y, from_ascii("TeX"), font);
-- 
1.7.9.5

Reply via email to