Poor quality font rendering
Phil Race
philip.race at oracle.com
Wed Aug 28 16:57:15 PDT 2013
If you let Label choose the colours, they are different, but your eye
has to be pretty good.
The foreground colour of the label text is not exactly black even though
you think it is.
You'll need to force it.
Also the background fill chosen by the layout managers seems to be "not
quite white" either.
So the end result is poorer contrast than straight black on white.
In this code below, I've forced a white background and a black
foreground and
the results are identical on my Win7 x64 box.
I've got a VBox as parent of both Label and Text but in your app its
possible
that you 'happen' to have pure white for Text already, which makes the
comparison against the UI control more apparent.
I do not know where/why the f/g and the b/g are 'tweaked' but they
look superficially like black & white so people who want those think
they have nothing to do, yet its not exactly so.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.*;
import javafx.scene.text.Font;
import javafx.scene.text.FontSmoothingType;
import javafx.scene.text.*;
import javafx.scene.text.Text;
import javafx.scene.Node;
import javafx.scene.layout.VBox;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class TextComp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage) {
String str = "Hello World";
Text t = new Text(10, 150, str);
t.setFontSmoothingType(FontSmoothingType.LCD);
Label l = new Label(str);
l.setTextFill(Color.BLACK);
VBox vb = new VBox();
BackgroundFill bgFill = new BackgroundFill(Color.WHITE, null,
null);
Background bg = new Background(bgFill);
vb.setBackground(bg);
Scene s = new Scene(vb);
stage.setScene(s);
vb.getChildren().add(t);
vb.getChildren().add(l);
stage.show();
}
}
-phil.
On 8/28/2013 3:48 PM, John C. Turnbull wrote:
> Hi Danno,
>
>
>
> I am comparing Text with LCD smoothing and Label (untouched) so shouldn't
> they both be using LCD smoothing and look the same? They actually look
> quite different.
>
>
>
> -jct
>
>
>
> From: Danno Ferrin [mailto:danno.ferrin at shemnon.com]
> Sent: Thursday, 29 August 2013 01:28
> To: Scott Palmer
> Cc: John C. Turnbull; openjfx-dev at openjdk.java.net Mailing
> Subject: Re: Poor quality font rendering
>
>
>
> Are you seeing the different defaults for LCD smoothing? The Text default
> is Grey and the Control default (which Label inherits) is LCD.
>
>
>
> On Wed, Aug 28, 2013 at 5:23 AM, Scott Palmer <swpalmer at gmail.com
> <mailto:swpalmer at gmail.com> > wrote:
>
> >From what I have observed, Text and Label appear to have different defaults
> for when antialiasing is applied. Text will do it always, Label only when
> the font is greater than a certain size.
>
> Scott
>
>
> On 2013-08-28, at 5:26 AM, "John C. Turnbull" <ozemale at ozemail.com.au
> <mailto:ozemale at ozemail.com.au> > wrote:
>
>> Hi Felipe,
>>
>> Thanks for the info.
>>
>> Is kerning planned for a Java 8 update or will it have to wait for 9? Or
>> 10?
>>
>> One more thing I have just noticed is that the way the text is rendered in
> a
>> Text object with LCD font smoothing is quite different from a Label (with
>> the Text object looking better and closer to native text).
>>
>> While I concede that the "better" font rendering I thought I observed in
>> WebView is probably an illusion, there is definitely a difference between
>> Text and Label (at least on this machine).
>>
>> Why would that be? Are they rendered differently?
>>
>> Thanks,
>>
>> -jct
>
>
More information about the openjfx-dev
mailing list