Monospaced Fonts

Hi
I have read: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Font.html
Logical fonts are the five font families defined by the Java platform which must be supported by any Java runtime environment: Serif, SansSerif, Monospaced, Dialog, and DialogInput. These logical fonts are not actual font libraries. Instead, the logical font names are mapped to physical fonts by the Java runtime environment. The mapping is implementation and usually locale dependent, so the look and the metrics provided by them vary. Typically, each logical font name maps to several physical fonts in order to cover a large range of characters.
I can obtain all the fonts that are in a particular system, but now need to go though them to see if they are Monospaced.
This is what I have done so far:
String[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
ArrayList<String> monoFonts = new ArrayList();
for(int i=0;i<allFonts.length; i++)
  if (f.getFamily().toString().equals("Monospaced"))
    monoFonts.add(allFonts);
Thanks!
Sam                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

ArrayList<String> monoFonts = new ArrayList();You need to specify <String> when you use new.
if (f.getFamily().toString()getFamilty() returns a String, so the toString() isn't needed. More of a problem is that you haven't declared or initialised f. I guess it's a Font. Initialise it using the 3 argument Font constructor.
http://java.sun.com/javase/6/docs/api/java/awt/Font.html#Font(java.lang.String, int, int)
.equals("Monospaced")There's a problem here. This will be true when you have a font family whose name is "Monospaced", not a family whose fonts are monospaced. For instance my computer has a family "Courier 10 Pitch" which is monospaced and a bunch of others with "Mono" in their names. The Font class singles out one of these - identified as Font.MONOSPACED - but they are all monospaced.
I don't know if there is any easy way of determining whether a font is monospaced. One way might be to obtain an array of all the available fonts with the GraphicsEnvironment method getAllFonts() and then check the widths of various characters to see if they are equal. The FontMetrics method getWidths() returns the first 256 such widths.
http://java.sun.com/javase/6/docs/api/java/awt/GraphicsEnvironment.html#getAllFonts()
http://java.sun.com/javase/6/docs/api/java/awt/FontMetrics.html#getWidths()

Similar Messages

  • Monospace Font question

    I am somewhat new to Oracle forms, i am using 10G so don't shoot me if these are dumb questions.
    I want to left align my Prompts on my form but using Tahoma or Verdana the alignment is always off. I fixed it by using a monospace font like Courier but is there a way to get these other more standard fonts to left align properly? (i don't want to right align them)
    Courier is not very readable and for the internet most people use Verdana, Arial, Helvetica, sans-serif.
    My other question is that if i use a font that is listed in the Oracle Forms Developer will it automatically download them to clients that don't have that font? How does Oracle handle this?

    No question is a dumb question. :-)
    To left align prompts, you go to the canvas and select the several that you want to align. Then all you do is click the 'Align Left' icon on the editing toolbar at the top of the canvas (or use pull-down Arange, Align Objects, Horizontally-Align Left). If the web display is not left-aligned, you may also need to open the property palette on the items with the prompts, and set the Prompt Alignment property to Start. You should NOT need to fuss with a monospaced font once you do this.
    I don't think Forms downloads fonts. Instead there is a font translation process where a font that is similar is selected.
    Just a note... I don't use Forms 9i or 10g, only 6i (both c/s and web), so my answer may not be right on.

  • How to monospace fonts in Illustrator?

    I can't seem to find this feature - is it possible to do this in Illustrator?
    Thanks in advance!

    Good responses here, but I just wanted to add in one other solution. This is painstaking but I'm having to do it for a project. I literally need a grid of text. I'd much rather just have a monospace font. Illustrator, if you're listening, a "Force Monospace" option would be excellent for UI designers, puzzle designers, and a lot of other people. People go to illustrator to do the odd jobs that other programs can't do. This feature would be at home here.
    The basic idea is to use linked text boxes and flowing text. This will be much easier to do in InDesign, since that program was born to flow text. I find it hard to click the flow button in CS5 and you can't hold option to continue the linkage process like you can in InDesign.
    Anyways, details on how to do this below. If you absolutely need a monospace layout of text glyphs, and don't have a monospace font to work with, and need to work in illustrator, this should work. I'm not saying that it will look good or be legible, and I guarantee you'll curse Illustrator because this would be very easy for them to add in as a feature.
    1) Click and drag out a rectangular text box. Don't just click and start typing, you need an actual type box.
    2) Enter your text and style your text how you want it.  Use the increased tracking method, posted above, if you want to see  roughly what it will look like.
    3) Decrease the tracking so it's 0 after you have everything styled.
    4) Add an uppercase M to the beginning of your text. That's typically (no pun intended) the widest character in most fonts.
    5) Resize the text box width so all you can see is that first M. You can make it a little wider just to be safe.
    6) Drag out a copy of that text box, and delete the text from the new one.
    7) Drag out copies of this empty text box. They should "flow" from left to right for English or other left-to-right languages. You should have as many boxes as you have letter in your final text.
    8) Link the text boxes: first click on your text box that has your placeholder text. You should see a red overflow [+] sign on the right side of the box. Click that.
    9) Click the edges of the next text box and you should see text flow from one box to the next.
    10) Rinse and repeat until all your boxes are filled. As you're doing this, you'll have multiple smaller letters filling up smaller boxes. There are two way to solve this:
    11A) Hit enter after each character to force the text to the next text box. This is cumbersome.
    11B) Increase tracking to a very high number or something that will prohibit two characters from occupying the same box. This is good if you are going to want to edit the type after the fact.
    12) Horizontally align your boxes, center your text, and you're done.

  • Reading email in a monospaced font, is that possible?

    Hello all,
    I would like to be able to read formatted text, like small tables, on my iPhone... Of course I will need a monospaced font to do so... Is there a way to change the current font into Monaco or Courier?
    Kind regards,
    Adam

    Thanks Kevin,
    Of course it's not 'my email' but the sender's email that needed to be sent in rich text, courier new 8-)
    Will try to get that arranged...
    Thanks for your reply! Still hope 'plain text' will be possible some day...
    Kind regards,
    Adam

  • [solved] "monospace" font displayed as some other font

    For some reason (that I am unable to figure out for myself), the "monospace" font on my system is not displayed as such, but replaced by some other font, presumably* by the last one installed to the system. See this screenshot of uzbl-browser as an example; leafpad's font-selection dialog would be another.
    * A while back (don't remember when) "monospace" started being displayed as some pleasant sans-serif font, which I did not investigate. When I installed some blackletter fonts (ttf-unifraktur) recently, it started being displayed as one of them, which is more of a nuisance, see screenshot.)
    What could be going on here? What is the "monospace" font anyway?
    Last edited by Franek (2014-02-27 20:54:20)

    First: I probably should have mentioned that I am using the infinality-bundle and infinality-bundle-fonts repositories.
    (Re-)Installing ttf-dejavu instantly made uzbl pretty again. But actually, I did not have ttf-dejavu installed in the first place, but t1-dejavu-ib from the infinality-bundle-fonts repository. When I change back to t1-dejavu-ib, Monospace is displayed as a blackletter font again.
    Here is the output of "fc-match monospace" with ttf-dejavu installed:
    $ fc-match monospace
    DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
    And here it is with t1-dejavu-ib:
    $ fc-match monospace
    sawarabi-gothic-medium.ttf: "Sawarabi Gothic" "Medium"
    About this font (which is certainly not the blackletter font I am seeing in uzbl):
    $ pacman -Qs sawarabi
    local/ttf-sawarabi-ib 0.0045-2 (infinality-bundle-fonts)
    Sawarabi font family for Japanese script.
    I have nothing in ~/.config/fontconfig, whereas /etc/fonts/conf.d/ is filled with several symlinks, most of which belong to the fontconfig-infinality-ultimate package. They all look alright to me, or rather: I trust that the infinality-bundle(-fonts) packages are doing the right thing. (Should I ask bohoomil about this?) Here is a list:
    $ pacman -Qo /etc/fonts/conf.d/*
    /etc/fonts/conf.d/10-base-rendering.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/10-scale-bitmap-fonts.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/30-metric-aliases.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/31-fix-cantarell.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/35-repl-custom.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/40-non-latin.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/42-luxi-mono.conf is owned by font-bh-ttf 1.0.3-1
    /etc/fonts/conf.d/45-latin.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/49-sansserif.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/50-user.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/51-local.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/65-ttf-noto-sans-ui.conf is owned by ttf-noto-sans-multilang-ib 1.04-2
    /etc/fonts/conf.d/65-ttf-noto-sans.conf is owned by ttf-noto-sans-multilang-ib 1.04-2
    /etc/fonts/conf.d/65-ttf-noto-serif.conf is owned by ttf-noto-serif-multilang-ib 1.04-2
    /etc/fonts/conf.d/68-override.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/82-no-embedded-bitmaps.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/82-no-force-autohint.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/82-no-ttf-as-bitmap.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/83-yes-bitmaps.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/83-yes-postscript.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/88-forced-synthetic.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/90-dejavu-t1.conf is owned by t1-dejavu-ib 2.34-4
    /etc/fonts/conf.d/90-non-tt-fonts.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/90-opensans-t1.conf is owned by t1-opensans-ib 1.2-7
    /etc/fonts/conf.d/90-tt-fonts.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/92-selective-rendering.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/93-final-rendering.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/94-no-synthetic.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/95-reject.conf is owned by fontconfig-infinality-ultimate 2.11.0-15
    /etc/fonts/conf.d/99pdftoopvp.conf is owned by cups-filters 1.0.46-1
    /etc/fonts/conf.d/README is owned by fontconfig-infinality-ultimate 2.11.0-15

  • Why are all of my monospaced fonts suddenly so thin?

    Yesterday I noticed that suddenly all of my monospaced fonts are completely messed up. Here's a about week old screenshot for comparison
    This is how it looked before
    And now
    These are both from TextMate using Monaco 14, but the same issue happens with Menlo. I also tried to download Bistream Vera Sans Mono and it also looks pretty ugly.
    This started happening to me yesterday and I actually reformatted the whole drive (not because of this), reinstalled Snow Leopard, upgraded back to Lion, didn't restore any backups and the fonts still look ugly.
    I would understand if this started happening only after the reinstall, because that would mean I had some specific settings. But it started happening out of nowhere and persisted after clean reinstall of OS X Lion.
    At one point I actually had some applications displaying the font correctly until I restarted them.
    These examples are before I reinstalled Lion.
    This is Xcode after restarting it
    and the same code from terminal VIM, which I haven't turned off yet
    these two were actually taken at the same time, both using the same font. But once I restarted the terminal, it started displaying it in the same messed up way.
    Some people suggested the font smoothing in System Preferences, but I have that turned on

    I managed to solve this with
    defaults -currentHost write -globalDomain AppleFontSmoothing -int 2
    more specific information can be found here

  • Issue about monospace font in Chromium

    I don't know why some of the monospace font in Chromium show strangely.
    But most of the font is OK. I have tried to modify some configuration in /etc/font/conf.d/*
    I failed because I am not familiar with the font configuration. Is there anyone
    can give me some advice on the font config? This troubles me a lot and
    I have spent so much time to resolve it. Thank you!
    I know why... From the CSS of this field, I see this:
    .wp-editor-area {
        font-family: Consolas,Monaco,monospace;
    And I delete Consolas, nothing happened with the font. But I delete Monaco, it look fine.
    The font appears like the monospace I set before. It seems that the ttf-monaco affects
    this font. How can I configure ttf-monaco? Or I can only remove ttf-monaco to solve the problem.
    Last edited by mssun (2013-04-06 14:36:35)

    I have read this wiki, but no matter what I modified. It seems that it only affected other fonts except some certain web pages. I don't know why.
    I have suspected whether 53-monospace-lcd-filter.conf make it. But I modified this file, nothing happened. That's why I come here to find help.
    [EDIT] I tried to change the fixed-width font in chromium, but nothing happened with the font in that field.
    Last edited by mssun (2013-04-06 14:27:23)

  • [SOLVED] Bold monospace fonts and rendering

    Hi everybody,
    I chose to use the Inconsolata font (http://www.levien.com/type/myfonts/inconsolata.html) everywhere I need a monospace font.
    However I have an issue with this setup. Since Inconsolata font doesn't have a bold variant, when "bolding" it, it gets rendered with a different width (it's not monospace anymore)
    This happens, for example, inside an Eclipse editor or even in gEdit.
    I've also noticed that in some applications (e.g., gnome-terminal or x-chat), bold is correctly displayed using the same width of the normal variant.
    I've read the https://wiki.archlinux.org/index.php/Font_Configuration page and, in particular, the "disable autohinter for bold fonts". I actually don't use the auto-hinter so I tried different configuration but without luck.
    Does anyone have an hint for solving this inconsistency?
    Thanks.
    P.S.: To better understand what I am talking about you can have a look at this image: http://imageshack.us/photo/my-images/85 … olata.png/
    Last edited by fm (2012-01-14 21:41:36)

    brebs wrote:
    fm wrote:I actually don't use the auto-hinter so I tried different configuration but without luck.
    If the app doesn't use fontconfig, then changing fontconfig settings won't help
    That's clear. But gnome-terminal and gEdit aren't they supposed to use the same backend, i.e., fontconfig?
    Because gnome-terminal works fine. gEdit doesn't.
    Thanks.

  • Nokia support for MONOSPACE font

    Nokia support for MONOSPACE font
    hi,
    Perhaps Im going mad but my Nokia 60series emulator and 7650 device doesnt seem to support a font with face: MONOSPACE.
    setting a font to MONOSPACE in the default WTK emulator correctly spaces all characters equally. However when I run my code on a Nokia emulator or device, the spaces of characters are unequal and their widths remain unchanged from the SYSTEM face settings.
    If anyone can help with a solution or explanation, pleeezzzz
    thanks in advance,
    Larry

    Not every device has every type of font. When you ask for a specific font, and the font doesn't exist then the system will find the best match for it.
    The only way to be sure you have a monospace font on every device is that you include that font yourself, and draw your own characters using drawImage() with that font.
    shmoove

  • Monospace font on XFCE 4.10

    Friends:
    I am using XFCE4.10 on Arch Linux.  It works well and I use it mainly for java development.
    I would request your kind help on the following.
    The Monospace font is Courier and it at size 10 (I think).  It is not bold either.  So the font looks very pale on my box.
    I have installed the AUR package mswindows-------
    I am not very comfortable with the the fontconfig stuff.
    What do I need to do ? I would like to make monospace to be Courier New 12 Bold ?
    Any suggestions or links would be helpful ?
    Regards,
    -Narahari

    @savithari, you have not given important information.
    Is the font problem visible only in one application or with all apps?
    What is  the application in the screen shot?
    How are you selecting the font: a menu option, a resource file, or some other setting?
    Is the problem due to the color scheme or due to fuzziness or distortions?
    You posted a jpeg image and asked people to look for details.  Repost with a png image.
    And please, read How To Ask Questions The Smart Way, http://www.catb.org/esr/faqs/smart-questions.html

  • Identify Monospaced Fonts

    Hello sir, friends, madam,
    I want to identify System fonts which are monospaced. I then have to display the names of such fonts in combo box. I got the list of all system fonts installed on machine using the folloing code.
    java.awt.GraphicsEnvironment.getAvailableFontFamilyNames() java.awt.GraphicsEnvironment.getAllFonts()
    Now I need to check which of them are monospaced. For this I tried doing the following Font.getAttributes(). This method returns a Map contains TextAttributes as key. So I used TextAttribute.FAMILY as a key to retrive the value from the map. But then I am getting other fonts as well, apart from monospaced fonts.
    Can anybody suggests whether I am on right track or can anyone provide some alternative to that I can reach the solution ?
    Waiting for your replies.
    Thanks and Regards
    Rohit.

    I've never heard of a good way to do this. There don't seem to be any relevant attributes or flags embedded in the fonts themselves, which seems strange, considering how important that property is. The only sure way that I can see would be to create a Font object for each installed font and compare the width of the letter 'i' to that of the the letter 'W' (or equivalents for whatever language you're targetting). You could cache the results, so you wouldn't have to do that every time the font dialog is displayed, but it's still pretty ugly.
    Here's a more hackish, but faster approach I found in the l2fprod commons project protected boolean isMonospaced(String fontFamily) {
        String lower = fontFamily.toLowerCase();
        return lower.indexOf("fixed") >= 0 || lower.indexOf("monospaced") >= 0
          || lower.indexOf("profont") >= 0 || lower.indexOf("console") >= 0
          || lower.indexOf("typewriter") >= 0;
      }The method can stand a lot of improvement (as written, it fails to spot these fonts from my system: "Andale Mono", "Bitstream Vera Sans Mono", "Courier", "Courier New", "DejaVu Sans Mono", "Monaco", and "Monospace 821"), and it would need to be updated every time a new monospaced font comes out, but it still seems like the less painful option to me.

  • N97 browser: no monospace fonts. Is it feature or ...

    I'm trying to browse web page with monospace "pre" tagged parts. I get normal arial type output i.e. no monospaced text. Is this a feature or bug?
    I really need it so hopefully it is a bug and fixed in the next firmware update.
    Nokia faitful: 6110, 3650, 7610, 6680, N95, N97, N900, ...

    I'm trying to browse web page with monospace "pre" tagged parts. I get normal arial type output i.e. no monospaced text. Is this a feature or bug?
    I really need it so hopefully it is a bug and fixed in the next firmware update.
    Nokia faitful: 6110, 3650, 7610, 6680, N95, N97, N900, ...

  • Fonts gone monospaced

    Hi there,
    Well it has happened again, certain fonts displayed in Firefox have gone from normal (I believe its Arial/Times/Helvetica) to looking like monospaced fonts. I'm not sure what is causing this to happen. Its not happening in Safari, but it is in Firefox which I use most of the time for my course work. Can anyone help me out please?? Thank you in advance!

    Deleted duplicates

  • Which fonts are monospaced?

    I have a nice list of font names returned from GraphicsEnvironment's getAvailableFontFamilyNames() method.
    I want to allow my app's user to pick their favorite, but the app needs a monospaced font so I only want to present those which are monospaced. How do I tell which ones are monospaced? I can guess those ending "mono" but it's not very scientific and I'd miss Courier New.

    http://en.wikipedia.org/wiki/Monospace_font

  • Not able to change font

    Hi ,
    We need to print some text data in printer. As we print a report, with numbers, and columns, we need font widht to be constant for all the charecters for producing properly aligned reports. [ like in courier or monospace fonts]. In the code below, I am not able to set the font for my printer. In the print() method, I tried to set font as monospace for the graphics object, but it did not have any effect. It looks like it always print with Ariel font. For displaying in layouts, it works find. But not with printer. Please help.
    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import java.text.*;
    * The PrintText application expands on the
    * PrintExample application in that it images
    * text on to the single page printed.
    public class PrintText implements Printable {
    * The text to be printed.
    private static final String mText = "this is the string to be printed";
    * Our text in a form for which we can obtain a
    * AttributedCharacterIterator.
    private static final AttributedString mStyledText = new AttributedString(mText);
    * Print a single page containing some sample text.
    static public void doPrint() {
    /* Get the representation of the current printer and
    * the current print job.
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    /* Build a book containing pairs of page painters (Printables)
    * and PageFormats. This example has a single page containing
    * text.
    Book book = new Book();
    book.append(new PrintText(), new PageFormat());
    /* Set the object to be printed (the Book) into the PrinterJob.
    * Doing this before bringing up the print dialog allows the
    * print dialog to correctly display the page range to be printed
    * and to dissallow any print settings not appropriate for the
    * pages to be printed.
    printerJob.setPageable(book);
    /* Show the print dialog to the user. This is an optional step
    * and need not be done if the application wants to perform
    * 'quiet' printing. If the user cancels the print dialog then false
    * is returned. If true is returned we go ahead and print.
    boolean doPrint = printerJob.printDialog();
    if (doPrint) {
    try {
    printerJob.print();
    System.out.println("successfully Printed");
    } catch (PrinterException exception) {
    System.err.println("Printing error: " + exception);
    * Print a page of text.
    public int print(Graphics g, PageFormat format, int pageIndex) {
    /* We'll assume that Jav2D is available.
    Graphics2D g2d = (Graphics2D) g;
    /* Move the origin from the corner of the Paper to the corner
    * of the imageable area.
    g2d.translate(format.getImageableX(), format.getImageableY());
    /* Set the text color.
    g2d.setPaint(Color.black);
    /* Use a LineBreakMeasurer instance to break our text into
    * lines that fit the imageable area of the page.
    Point2D.Float pen = new Point2D.Float();
    AttributedCharacterIterator charIterator = mStyledText.getIterator();
    int tabCount=100;
    int[] tabLocations = new int[tabCount+1];
    int i = 0;
    for (char c = charIterator.first(); c != charIterator.DONE; c = charIterator.next()) {
    if (c == '\n') {
    tabLocations[i] = charIterator.getIndex();
    System.out.println("found newline at tabLocations[" + i + "] = "+ tabLocations[i] );
    i++;
    tabCount=i;
    tabLocations[tabCount] = charIterator.getEndIndex() - 1 ;
    int currentTab = 0;
    float verticalPos = 20;
    charIterator = mStyledText.getIterator();
    LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator, g2d.getFontRenderContext());
    TextLayout layout;
    float wrappingWidth = (float) format.getImageableWidth();
    while (measurer.getPosition() < charIterator.getEndIndex()) {
    if (currentTab < tabCount )
    layout = measurer.nextLayout(wrappingWidth,tabLocations[currentTab]+1,true);
    if (measurer.getPosition() == tabLocations[currentTab]+1) {
    currentTab++;
    else
    layout = measurer.nextLayout(wrappingWidth);
    pen.y += layout.getAscent();
    float dx = layout.isLeftToRight()? 0 : (wrappingWidth - layout.getAdvance());
    layout.draw(g2d, pen.x + dx, pen.y);
    pen.y += layout.getDescent() + layout.getLeading();
    System.out.println("Print result : "+ Printable.PAGE_EXISTS);
    return Printable.PAGE_EXISTS;
    }

    I don't see how it would have worked on the screen. Is that what you meant by "For displaying in layouts, it works find."? You never called setFont(...) on the Graphics or Graphics2D object in your paint method. Use g2d.setFont(new Font("Monospaced", Font.PLAIN, size)) and you should be fine.
    Jeff

Maybe you are looking for