@@ -2055,8 +2055,20 @@ protected float textWidthImpl(char[] buffer, int start, int stop) {
2055
2055
protected void textLineImpl (char [] buffer , int start , int stop ,
2056
2056
float x , float y ) {
2057
2057
Font font = (Font ) textFont .getNative ();
2058
- // if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) {
2059
2058
if (font != null ) {
2059
+ // If using the default font, warn the user when their code calls
2060
+ // text() called with unavailable characters. Not done with all
2061
+ // fonts because it would be too slow, but useful/acceptable for
2062
+ // the default case because it will hit beginners/casual use.
2063
+ if (textFont .getName ().equals (defaultFontName )) {
2064
+ if (font .canDisplayUpTo (buffer , start , stop ) != -1 ) {
2065
+ final String msg =
2066
+ "Some characters not available in the current font, " +
2067
+ "use createFont() to specify a typeface the includes them." ;
2068
+ showWarning (msg );
2069
+ }
2070
+ }
2071
+
2060
2072
/*
2061
2073
// save the current setting for text smoothing. note that this is
2062
2074
// different from the smooth() function, because the font smoothing
@@ -2109,7 +2121,7 @@ protected void textLineImpl(char[] buffer, int start, int stop,
2109
2121
//g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, textAntialias);
2110
2122
g2 .setRenderingHint (RenderingHints .KEY_ANTIALIASING , antialias );
2111
2123
2112
- } else { // otherwise just do the default
2124
+ } else { // otherwise, just do the default
2113
2125
super .textLineImpl (buffer , start , stop , x , y );
2114
2126
}
2115
2127
}
0 commit comments