From 91963544bdb919f40d4b54f7acaf665373ca5170 Mon Sep 17 00:00:00 2001 From: simonb Date: Sun, 8 Apr 2007 01:53:19 +0000 Subject: Only replace numbers with zeros when calculating clock width. Otherwise width of things in proportional fonts can be way out. sf.net bug #1545066. --- ChangeLog | 5 +++++ src/ClockTool.cc | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3bf652a..dadd00c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 6e06ed6..99cbb06 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -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(); -- cgit v0.11.2