mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
remove widest_number definition and usage, add Font::getMaxDigitWidth() method instead
Signed-off-by: M. Liebmann <tuxcode.bbg@gmail.com>
This commit is contained in:
@@ -230,6 +230,8 @@ Font::Font(FBFontRenderClass *render, FTC_FaceID faceid, const int isize, const
|
|||||||
//font.image_type |= ftc_image_flag_autohinted;
|
//font.image_type |= ftc_image_flag_autohinted;
|
||||||
font.flags = FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT;
|
font.flags = FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT;
|
||||||
|
|
||||||
|
maxdigitwidth = 0;
|
||||||
|
|
||||||
scaler.face_id = font.face_id;
|
scaler.face_id = font.face_id;
|
||||||
scaler.width = isize * 64;
|
scaler.width = isize * 64;
|
||||||
scaler.height = isize * 64;
|
scaler.height = isize * 64;
|
||||||
@@ -318,6 +320,21 @@ int Font::getDigitOffset(void)
|
|||||||
return DigitOffset;
|
return DigitOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Font::getMaxDigitWidth(void)
|
||||||
|
{
|
||||||
|
if (maxdigitwidth < 1) {
|
||||||
|
char b[2];
|
||||||
|
b[1] = 0;
|
||||||
|
for (char c = '0'; c <= '9'; c++) {
|
||||||
|
*b = c;
|
||||||
|
int w = getRenderWidth(b, true);
|
||||||
|
if (w > maxdigitwidth)
|
||||||
|
maxdigitwidth = w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxdigitwidth;
|
||||||
|
}
|
||||||
|
|
||||||
int UTF8ToUnicode(const char * &text, const bool utf8_encoded) // returns -1 on error
|
int UTF8ToUnicode(const char * &text, const bool utf8_encoded) // returns -1 on error
|
||||||
{
|
{
|
||||||
int unicode_value;
|
int unicode_value;
|
||||||
|
@@ -53,6 +53,7 @@ class Font
|
|||||||
// these are HACKED values, because the font metrics were unusable.
|
// these are HACKED values, because the font metrics were unusable.
|
||||||
int height,DigitHeight,DigitOffset,ascender,descender,upper,lower;
|
int height,DigitHeight,DigitOffset,ascender,descender,upper,lower;
|
||||||
int fontwidth;
|
int fontwidth;
|
||||||
|
int maxdigitwidth;
|
||||||
|
|
||||||
inline void paintFontPixel(fb_pixel_t *td, uint8_t fg_trans, uint8_t fg_red, uint8_t fg_green, uint8_t fg_blue, fb_pixel_t bg_col, int faktor, uint8_t index);
|
inline void paintFontPixel(fb_pixel_t *td, uint8_t fg_trans, uint8_t fg_red, uint8_t fg_green, uint8_t fg_blue, fb_pixel_t bg_col, int faktor, uint8_t index);
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ class Font
|
|||||||
int getRenderWidth(const std::string & text, const bool utf8_encoded = false);
|
int getRenderWidth(const std::string & text, const bool utf8_encoded = false);
|
||||||
int getHeight(void);
|
int getHeight(void);
|
||||||
int getDigitHeight(void);
|
int getDigitHeight(void);
|
||||||
|
int getMaxDigitWidth(void);
|
||||||
int getDigitOffset(void);
|
int getDigitOffset(void);
|
||||||
int getWidth(void);
|
int getWidth(void);
|
||||||
int getSize(){return font.width;}
|
int getSize(){return font.width;}
|
||||||
|
@@ -1376,7 +1376,7 @@ int CChannelList::numericZap(int key)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
size_t maxchansize = MaxChanNr().size();
|
size_t maxchansize = MaxChanNr().size();
|
||||||
int fw = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(widest_number);
|
int fw = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getMaxDigitWidth();
|
||||||
int sx = maxchansize * fw + (fw/2);
|
int sx = maxchansize * fw + (fw/2);
|
||||||
int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6;
|
int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6;
|
||||||
|
|
||||||
|
@@ -151,15 +151,7 @@ void CComponentsFrmClock::initCCLockItems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int minNumWidth = 0, w_tmp;
|
int w_tmp;
|
||||||
char b[2];
|
|
||||||
b[1] = 0;
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
b[0] = '0' + i;
|
|
||||||
w_tmp = (*getClockFont())->getRenderWidth(b, true);
|
|
||||||
if (w_tmp > minNumWidth)
|
|
||||||
minNumWidth = w_tmp;
|
|
||||||
}
|
|
||||||
int minSepWidth = (*getClockFont())->getRenderWidth(":", true);
|
int minSepWidth = (*getClockFont())->getRenderWidth(":", true);
|
||||||
w_tmp = (*getClockFont())->getRenderWidth(".", true);
|
w_tmp = (*getClockFont())->getRenderWidth(".", true);
|
||||||
if (w_tmp > minSepWidth)
|
if (w_tmp > minSepWidth)
|
||||||
@@ -189,14 +181,13 @@ void CComponentsFrmClock::initCCLockItems()
|
|||||||
char c = stmp.at(0);
|
char c = stmp.at(0);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '0' ... '9':
|
case '0' ... '9':
|
||||||
wtmp = minNumWidth;
|
wtmp = (*getClockFont())->getMaxDigitWidth();
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
case ':':
|
case ':':
|
||||||
wtmp = minSepWidth;
|
wtmp = minSepWidth;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
b[0] = c;
|
|
||||||
wtmp = (*getClockFont())->getRenderWidth(stmp, true);
|
wtmp = (*getClockFont())->getRenderWidth(stmp, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -356,7 +356,7 @@ void CComponentsItemBox::calSizeOfElements()
|
|||||||
digit_h = font_text->getDigitHeight();
|
digit_h = font_text->getDigitHeight();
|
||||||
digit_offset = font_text->getDigitOffset();
|
digit_offset = font_text->getDigitOffset();
|
||||||
v_element_data[i].height = digit_h + (int)((float)digit_offset*1.5);
|
v_element_data[i].height = digit_h + (int)((float)digit_offset*1.5);
|
||||||
// v_element_data[i].width = font_text->getRenderWidth(widest_number)*4 + font->getRenderWidth(":");
|
// v_element_data[i].width = font_text->getMaxDigitWidth() + font->getRenderWidth(":");
|
||||||
v_element_data[i].width = font_text->getRenderWidth(timestr);
|
v_element_data[i].width = font_text->getRenderWidth(timestr);
|
||||||
v_element_data[i].element = timestr;
|
v_element_data[i].element = timestr;
|
||||||
}
|
}
|
||||||
|
@@ -194,7 +194,7 @@ void CInfoViewer::start ()
|
|||||||
|
|
||||||
if ( g_settings.infobar_show_channellogo != 3 && g_settings.infobar_show_channellogo != 5 && g_settings.infobar_show_channellogo != 6) /* 3 & 5 & 6 is "default" with sigscales etc. */
|
if ( g_settings.infobar_show_channellogo != 3 && g_settings.infobar_show_channellogo != 5 && g_settings.infobar_show_channellogo != 6) /* 3 & 5 & 6 is "default" with sigscales etc. */
|
||||||
{
|
{
|
||||||
ChanWidth = 4 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getRenderWidth(widest_number) + 10;
|
ChanWidth = 4 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getMaxDigitWidth() + 10;
|
||||||
ChanHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getHeight() * 9 / 8;
|
ChanHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getHeight() * 9 / 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -74,7 +74,7 @@ void CTimeOSD::GetDimensions()
|
|||||||
m_height = 10;
|
m_height = 10;
|
||||||
m_y = frameBuffer->getScreenY();
|
m_y = frameBuffer->getScreenY();
|
||||||
m_width = g_Font[TIMEOSD_FONT]->getRenderWidth("00:00:00");
|
m_width = g_Font[TIMEOSD_FONT]->getRenderWidth("00:00:00");
|
||||||
t1 = g_Font[TIMEOSD_FONT]->getRenderWidth(widest_number);
|
t1 = g_Font[TIMEOSD_FONT]->getMaxDigitWidth();
|
||||||
m_width += t1;
|
m_width += t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -295,7 +295,7 @@ void CVolumeHelper::initInfoClock(Font** font)
|
|||||||
}
|
}
|
||||||
digit_offset = (*clock_font)->getDigitOffset();
|
digit_offset = (*clock_font)->getDigitOffset();
|
||||||
digit_h = (*clock_font)->getDigitHeight();
|
digit_h = (*clock_font)->getDigitHeight();
|
||||||
int t1 = (*clock_font)->getRenderWidth(widest_number);
|
int t1 = (*clock_font)->getMaxDigitWidth();
|
||||||
int t2 = (*clock_font)->getRenderWidth(":");
|
int t2 = (*clock_font)->getRenderWidth(":");
|
||||||
clock_dy = digit_h + (int)((float)digit_offset * 1.3);
|
clock_dy = digit_h + (int)((float)digit_offset * 1.3);
|
||||||
clock_dx = t1*7 + t2*2;
|
clock_dx = t1*7 + t2*2;
|
||||||
|
@@ -1213,15 +1213,29 @@ int CMenuOptionNumberChooser::getWidth(void)
|
|||||||
const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName);
|
const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName);
|
||||||
int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_optionName, true);
|
int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_optionName, true);
|
||||||
|
|
||||||
char tmp[20], *t;
|
int _lower_bound = lower_bound;
|
||||||
|
int _upper_bound = upper_bound;
|
||||||
|
int m = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth();
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "%d", lower_bound);
|
int w1 = 0;
|
||||||
for(t = tmp; *t; t++) if (isdigit((int)*t)) *t = *widest_number;
|
if (_lower_bound < 0) {
|
||||||
int w1 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true);
|
w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true);
|
||||||
|
lower_bound *= -1;
|
||||||
|
}
|
||||||
|
while (_lower_bound > 0) {
|
||||||
|
w1 += m;
|
||||||
|
_lower_bound /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "%d", upper_bound);
|
int w2 = 0;
|
||||||
for(t = tmp; *t; t++) if (isdigit((int)*t)) *t = *widest_number;
|
if (_upper_bound < 0) {
|
||||||
int w2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true);
|
w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true);
|
||||||
|
_upper_bound *= -1;
|
||||||
|
}
|
||||||
|
while (_upper_bound > 0) {
|
||||||
|
w1 += m;
|
||||||
|
_upper_bound /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
width += (w1 > w2) ? w1 : w2;
|
width += (w1 > w2) ? w1 : w2;
|
||||||
|
|
||||||
|
@@ -49,8 +49,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define widest_number "2"
|
|
||||||
|
|
||||||
#define ANNOUNCETIME (1 * 60)
|
#define ANNOUNCETIME (1 * 60)
|
||||||
|
|
||||||
/**************************************************************************************
|
/**************************************************************************************
|
||||||
|
Reference in New Issue
Block a user