From ed14f07e4c8df4e6dd5f835a42f4c87f706b9dd6 Mon Sep 17 00:00:00 2001 From: koldo Date: Thu, 15 Aug 2019 18:13:00 +0000 Subject: [PATCH] *ScatterDraw: Included Maginor fix from https://www.ultimatepp.org/forums/index.php?t=msg&th=10759&start=0& git-svn-id: svn://ultimatepp.org/upp/trunk@13550 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ScatterDraw/Legend.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/uppsrc/ScatterDraw/Legend.cpp b/uppsrc/ScatterDraw/Legend.cpp index 7a77142f7..17fd16517 100644 --- a/uppsrc/ScatterDraw/Legend.cpp +++ b/uppsrc/ScatterDraw/Legend.cpp @@ -21,7 +21,12 @@ void ScatterDraw::DrawLegend(Draw& w) const { int rowHeight = int(textScale*scaledFont.GetHeight()); int rowAscent = int(textScale*scaledFont.GetAscent()); scaledFont.Height(rowHeight); - int xWidth = scaledFont.GetWidth('X'); + + Upp::Font boldFont = scaledFont; + boldFont.Bold(); + Upp::Font italic = scaledFont; + italic.Italic(); + int xWidth = boldFont.GetWidth('X'); int lineLen = 4*xWidth; Vector legends; @@ -32,7 +37,7 @@ void ScatterDraw::DrawLegend(Draw& w) const { if (legend.Find('[') < 0 && !series[i].unitsY.IsEmpty()) legend += " [" + series[i].unitsY + "]"; legends.Add(legend); - legendWidth = max(legendWidth, GetTextSizeSpace(legend, scaledFont).cx); + legendWidth = max(legendWidth, GetTextSizeSpace(legend, boldFont).cx); } } legendWidth += lineLen + 3*xWidth; @@ -98,9 +103,6 @@ void ScatterDraw::DrawLegend(Draw& w) const { if (!IsNull(legendBorderColor)) DrawRectangle(w, rect, textScale, 1, legendBorderColor); } - Upp::Font italic = scaledFont; - italic.Italic(); - scaledFont.Bold(); for(int row = 0, start = 0, i = 0, ireal = 0; row <= nrows; row++) { for(; ireal < min(start + nlr, nlab); i++) { if (series[i].showLegend) { @@ -117,7 +119,7 @@ void ScatterDraw::DrawLegend(Draw& w) const { if (series[i].markWidth >= 1 && series[i].markPlot) series[i].markPlot->Paint(w, plotScaleAvg, mark_p, series[i].markWidth, series[i].markColor, series[i].markBorderWidth, series[i].markBorderColor); - Upp::Font &font = series[i].primaryY ? scaledFont : italic; + Upp::Font &font = series[i].primaryY ? boldFont : italic; DrawText(w, lx + lineLen + xWidth, ly - int((2*rowAscent)/3), 0, legends[ireal], font, series[i].color); ireal++; }