From 932de182760fe082bc229caee510f7d74ac1a7fa Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 1 Jul 2020 00:21:45 +0200 Subject: [PATCH] glcd: improve text alignment Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/8479b7b78492cc0c62ef5fe2d0e0fbed6acd360a Author: vanhofen Date: 2020-07-01 (Wed, 01 Jul 2020) Origin message was: ------------------ - glcd: improve text alignment ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/glcd/glcd.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/driver/glcd/glcd.cpp b/src/driver/glcd/glcd.cpp index dfada1896..7a64e884a 100644 --- a/src/driver/glcd/glcd.cpp +++ b/src/driver/glcd/glcd.cpp @@ -1517,6 +1517,7 @@ bool cGLCD::imageShow(const std::string & filename, uint32_t dx, uint32_t dy, ui bool cGLCD::drawText(int x, int y, int xmax, int text_width, const std::string & text, const GLCD::cFont * font, uint32_t color1, uint32_t color2, bool proportional, int skipPixels, int align) { int z = 0; + int offset = 10; // px if (align == ALIGN_NONE) { @@ -1524,15 +1525,15 @@ bool cGLCD::drawText(int x, int y, int xmax, int text_width, const std::string & } else if (align == ALIGN_LEFT) { - z = std::max(2, (bitmap->Width() - 4 - text_width) / 24); + z = offset; } else if (align == ALIGN_CENTER) { - z = std::max(2, (bitmap->Width() - 4 - text_width) / 2); + z = std::max(offset, (bitmap->Width() - text_width) / 2); } else if (align == ALIGN_RIGHT) { - z = std::max(2, (bitmap->Width() - 4 - text_width)); + z = std::max(offset, (bitmap->Width() - text_width - offset)); } return bitmap->DrawText(z, y, xmax, text, font, color1, color2, proportional, skipPixels);