Only replace numbers with zeros when calculating clock width.

Otherwise width of things in proportional fonts can be way out.
sf.net bug #1545066.
This commit is contained in:
simonb 2007-04-08 01:53:19 +00:00
parent b09aae8579
commit 91963544bd
2 changed files with 16 additions and 1 deletions

View file

@ -1,5 +1,10 @@
(Format: Year/Month/Day)
Changes for 1.0.0:
*07/04/08:
* Only replace numbers with zeros when calculating clock width (Simon)
Otherwise width of things in proportional fonts can be way out.
sf.net bug #1545066.
ClockTool.cc
*07/04/05:
* Adjusted detection of Caps Lock key (Mark)
FbTk/KeyUtil.cc/hh

View file

@ -220,7 +220,17 @@ void ClockTool::update(FbTk::Subject *subj) {
updateTime();
// + 2 to make the entire text fit inside
std::string text(m_button.text().size() + 2, '0');
// we only replace numbers with zeros because everything else should be
// relatively static. If we replace all text with zeros then widths of
// proportional fonts with some strftime formats will be considerably off.
std::string text(m_button.text());
int textlen = text.size();
for (int i=0; i < textlen; ++i) {
if (text[i] > '0' && text[i] <= '9') // don't bother replacing zeros
text[i] = '0';
}
text.append("00"); // pad
unsigned int new_width = m_button.width();
unsigned int new_height = m_button.height();