I wrote a simple clock program that worked fine under winxp. When run under linux it behaves weirdly. The program draws a label with the text set to "00:00", and then updates it once per second with the same text.
To run the program I specify a font size in the command line. If I set it really small (200.0 and lower for my screen, it may be different to yours) it works fine. If I set it too big and the text doesn't fit the screen (500.0 in my case), it works fine as well. However when I pick the size in the middle (say, 300.0 or 400.0) it displays "00:00", however once updateClock sets the text it becomes " :00" on the screen (it's not shifted to the left, just the two leading zeroes are replaced with empty space)
Here is the simplified code that demonstrates the problem:
import System.Environment
import System.Time
import System.Locale
import Data.Time
import Graphics.Rendering.Cairo
import Graphics.UI.Gtk hiding (fill)
import Graphics.UI.Gtk.Gdk.EventM
parseArgs [str] = case reads str::[(Double, String)] of
[(number, "")] -> Just number
_ -> Nothing
parseArgs _ = Nothing
updateClock labl = do
labelSetText labl "00:00"
return True
main = do
args <- getArgs
case (parseArgs args) of
Just size ->
showGui size
_ -> putStrLn "\nUsage: test fontSize"
where
showGui size = do
initGUI
window <- windowNew
onDestroy window mainQuit
window `on` keyPressEvent $ tryEvent $ do
"Escape" <- eventKeyName
liftIO mainQuit
labl <- labelNew Nothing
fd <- fontDescriptionNew
containerAdd window labl
windowFullscreen window
fontDescriptionSetSize fd size
widgetModifyFont labl $ Just fd
timeoutAdd (updateClock labl >> return True) 1000
widgetShowAll window
mainGUI
I use libghc-gtk-dev 0.12.4-3,
ghc 7.6.3
and libgtk2.0-0 2.24.23-0ubuntu1.2.
I compile with ghc --make --threaded
I'm having trouble figuring out what's going on here. I would appreciate any help