Jaeyo / lanterna

Automatically exported from code.google.com/p/lanterna
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Lanterna doesn't find Monospaced font on Ubuntu #120

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
My Ubuntu system doesn't have a font named Monospace. Can you search for Ubuntu 
Mono, FreeMono DejaVu San Mono and Liberation Mono? Linux systems should have 
one of those.

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.googlecode.lanterna.terminal.DefaultTerminalFactory.<init>(DefaultTerminalFactory.java:83)
    at com.googlecode.lanterna.terminal.DefaultTerminalFactory.<init>(DefaultTerminalFactory.java:62)
    at com.jacobwabrams.lanterna.Main.main(Main.java:15)
Caused by: java.lang.IllegalArgumentException: Font 
java.awt.Font[family=Monospaced,name=Monospaced,style=plain,size=14] isn't 
monospaced!
    at com.googlecode.lanterna.terminal.swing.SwingTerminalFontConfiguration.<init>(SwingTerminalFontConfiguration.java:77)
    at com.googlecode.lanterna.terminal.swing.SwingTerminalFontConfiguration.newInstance(SwingTerminalFontConfiguration.java:56)
    at com.googlecode.lanterna.terminal.swing.SwingTerminalFontConfiguration.<clinit>(SwingTerminalFontConfiguration.java:39)
    ... 3 more

java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)

Linux version 3.13.0-43-generic (buildd@tipua) (gcc version 4.8.2 (Ubuntu 
4.8.2-19ubuntu1) ) #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014

Original issue reported on code.google.com by satur9n...@gmail.com on 26 Dec 2014 at 5:14

GoogleCodeExporter commented 9 years ago
Another problem is that I don't see a possible workaround if I run this on a 
system without a font it can find because this happens in the clinit. Perhaps 
in that case the DEFAULT should be null?

Original comment by satur9n...@gmail.com on 26 Dec 2014 at 5:30

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I see now that the documentation specifies that "Monospaced" should correspond 
to some monospaced font on the system, unfortunately it's not working.

I think as a backup perhaps you will need to search the installed font families 
to find a monospaced font. Also it would be better to do this lazily in case 
the app is being run on a terminal and doesn't need to find it's own fonts. 
Currently because it is initialized during class loading it happens even when 
the DefaultTerminalFactory ends up choosing UnixTerminal.

Original comment by satur9n...@gmail.com on 28 Dec 2014 at 11:59

GoogleCodeExporter commented 9 years ago
Actually, the problem above isn't that there isn't a Monospaced font on your 
system, it's that the actual font behind the "Monospaced" alias wasn't actually 
mono-spaced. The code will measure the width of 'i' and 'W' and if they're not 
the same then the font isn't considered valid monospaced.

So your Ubuntu installation seems to have a Monospaced font which isn't 
monospaced... I suppose we could add something that scans the font-list a bit 
more carefully instead of throwing an exception like that.

Original comment by mab...@gmail.com on 11 Jan 2015 at 11:05