From 52c41ff5afbc3476aed32da3e088e71b2ee3ca39 Mon Sep 17 00:00:00 2001 From: kamel5 Date: Sat, 25 Jul 2020 13:35:03 +0200 Subject: [PATCH] Fixed display groupname in cChannelGroupGrid::DrawHorizontal --- channelgroup.c | 15 +++++++-------- tools.c | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/channelgroup.c b/channelgroup.c index 99420d6..de143a2 100644 --- a/channelgroup.c +++ b/channelgroup.c @@ -68,29 +68,28 @@ void cChannelGroupGrid::Draw(void) { void cChannelGroupGrid::DrawVertical(tColor colorText, tColor colorTextBack) { int textY = (Height() - fontManager.FontChannelGroups->Height()) / 2; - cString text = CutText(name, Width() - 4, fontManager.FontChannelGroups).c_str(); + cString text = cString::sprintf("%s", CutText(name, Width() - 4, fontManager.FontChannelGroups).c_str()); int textWidth = fontManager.FontChannelGroups->Width(*text); int x = (Width() - textWidth) / 2; pixmap->DrawText(cPoint(x, textY), *text, colorText, colorTextBack, fontManager.FontChannelGroups); } void cChannelGroupGrid::DrawHorizontal(tColor colorText, tColor colorTextBack) { - std::string nameUpper = name; - std::transform(nameUpper.begin(), nameUpper.end(),nameUpper.begin(), ::toupper); - int numChars = nameUpper.length(); + std::string groupName = name; + int numChars = groupName.length(); int charHeight = fontManager.FontChannelGroupsHorizontal->Height(); int textHeight = numChars * charHeight; int y = 5; - if ((textHeight +5) < Height()) { + if ((textHeight + 5) < Height()) { y = (Height() - textHeight) / 2; } - for (int i=0; i < numChars; i++) { - if (((y + 2*charHeight) > Height()) && ((i+1) Height()) && ((i + 1) < numChars)) { int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width("...")) / 2; pixmap->DrawText(cPoint(x, y), "...", colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); break; } - cString currentChar = cString::sprintf("%c", nameUpper.at(i)); + cString currentChar = cString::sprintf("%s", utf8_substr(groupName.c_str(), i, 1).c_str()); int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width(*currentChar)) / 2; pixmap->DrawText(cPoint(x, y), *currentChar, colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); y += fontManager.FontChannelGroupsHorizontal->Height(); diff --git a/tools.c b/tools.c index 866929b..63b4d01 100644 --- a/tools.c +++ b/tools.c @@ -10,7 +10,6 @@ #include #include #include "services/epgsearch.h" - #include "tools.h" cPlugin *GetScraperPlugin(void) { @@ -42,7 +41,7 @@ std::string utf8_substr(const std::string& str, unsigned int start, long unsigne } if (q<=start+leng || leng==std::string::npos){ max=i; } if (min==std::string::npos || max==std::string::npos) { return ""; } - return str.substr(min,max); + return str.substr(min,max-min); } std::string CutText(std::string text, int width, const cFont *font) {