Saturday Oct 31, 2009

Embedded fonts in JavaFX

I wanted to embed a font in my JavaFX application. Sure enough, the first Google result led to the answer (http://forums.sun.com/thread.jspa?threadID=5353505). But the result is not something that I liked. It worked programmatically, but visually I was disappointed:


Here is the same text using the same font in Photoshop.

I like the second one. The JavaFX rendering does not stay true to the intended look of the font, and for my eyes, has a smudgy look to it (then again, I am no fonts expert). If you are using such a font in many places in your application, this difference between the photoshop mockup and the actual application starts getting to your eyes.

Maybe I am missing some trick or maybe the font rendering is indeed like this on JavaFX. But if this is the way JavaFX renders fonts, I am a tad disappointed for now. Maybe things will improve in upcoming versions.

Saturday Jul 25, 2009

How to display the NetBeans font chooser.

Since I have been going after some low hanging fruits in fixing some Python support related issues in NetBeans, strictly over weekends (without the knowledge of my wife who prefers my MacBook Pro being 2000 miles away from me on weekends), I ran into an interesting issue where I had to display the NetBeans font chooser instead of a custom font chooser being used in the code. Unable to find the proper API (perhaps I am dumb), I waded into the NetBeans sources, and found the way out. Blogging about this here to save some poor soul some time when the need arises.

PropertyEditor pe = PropertyEditorManager.findEditor (Font.class);
DialogDescriptor dd = new DialogDescriptor (
    pe.getCustomEditor(),
    "Some Title"  // NOI18N
);

DialogDisplayer.getDefault ().createDialog (dd).setVisible (true);
if (dd.getValue () == DialogDescriptor.OK_OPTION) {
    font = (Font) pe.getValue ();
}

It just boils down to getting a property editor for Font and then wrapping the panel inside a dialog box using the NetBeans DialogDisplayer API.


Tuesday Jun 24, 2008

A better look

I am a big Ubuntu fan, and always feel a bit sad when I have to upload my new and noteworthy screenshots next to the swanky and sleek screenshots of people on a Mac on the NetBeans wiki (look at the Spring framwork support section here).

However after some digging around I finally got a font combination that looks pretty neat to my eyes. Here's a screenshot with the default font in NetBeans 6.1 running on Ubuntu 8.04:

And here's after I changed the font to Bitstream Vera Sans Mono 12 pt:

The second one is much better for my eyes (atleast). Any other good combinations out there folks?

Font Settings:


About

Rohan Ranade's musings on anything and everything.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today