79 * it was not used for a while but we do not want to be too aggressive on
80 * this (and this is probably more important for Type1 fonts).
81 */
82 public abstract class FontScaler implements DisposerRecord {
83
84 private static FontScaler nullScaler = null;
85 private static Constructor<? extends FontScaler> scalerConstructor = null;
86
87 //Find preferred font scaler
88 //
89 //NB: we can allow property based preferences
90 // (theoretically logic can be font type specific)
91 static {
92 Class<? extends FontScaler> scalerClass = null;
93 Class<?>[] arglst = new Class<?>[] {Font2D.class, int.class,
94 boolean.class, int.class};
95
96 try {
97 @SuppressWarnings("unchecked")
98 Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
99 (FontUtilities.isOpenJDK ?
100 Class.forName("sun.font.FreetypeFontScaler") :
101 Class.forName("sun.font.T2KFontScaler"));
102 scalerClass = tmp;
103 } catch (ClassNotFoundException e) {
104 scalerClass = NullFontScaler.class;
105 }
106
107 //NB: rewrite using factory? constructor is ugly way
108 try {
109 scalerConstructor = scalerClass.getConstructor(arglst);
110 } catch (NoSuchMethodException e) {
111 //should not happen
112 }
113 }
114
115 /* This is the only place to instantiate new FontScaler.
116 * Therefore this is very convinient place to register
117 * scaler with Disposer as well as trigger deregistring bad font
118 * in case when scaler reports this.
119 */
|
79 * it was not used for a while but we do not want to be too aggressive on
80 * this (and this is probably more important for Type1 fonts).
81 */
82 public abstract class FontScaler implements DisposerRecord {
83
84 private static FontScaler nullScaler = null;
85 private static Constructor<? extends FontScaler> scalerConstructor = null;
86
87 //Find preferred font scaler
88 //
89 //NB: we can allow property based preferences
90 // (theoretically logic can be font type specific)
91 static {
92 Class<? extends FontScaler> scalerClass = null;
93 Class<?>[] arglst = new Class<?>[] {Font2D.class, int.class,
94 boolean.class, int.class};
95
96 try {
97 @SuppressWarnings("unchecked")
98 Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
99 (!FontUtilities.useT2K ?
100 Class.forName("sun.font.FreetypeFontScaler") :
101 Class.forName("sun.font.T2KFontScaler"));
102 scalerClass = tmp;
103 } catch (ClassNotFoundException e) {
104 scalerClass = NullFontScaler.class;
105 }
106
107 //NB: rewrite using factory? constructor is ugly way
108 try {
109 scalerConstructor = scalerClass.getConstructor(arglst);
110 } catch (NoSuchMethodException e) {
111 //should not happen
112 }
113 }
114
115 /* This is the only place to instantiate new FontScaler.
116 * Therefore this is very convinient place to register
117 * scaler with Disposer as well as trigger deregistring bad font
118 * in case when scaler reports this.
119 */
|