-
Bug
-
Resolution: Fixed
-
P3
-
2.0
-
None
-
b33
-
generic
-
generic
-
Verified
According to the spec of TextAttribute, TextAttribute.FONT is "A way for users to override the resolution of font attributes into a Font, or force use of a particular Font instance".
Constructor Font(Map) ignores this attribute. See example below:
========================= Test57.java =========================
import java.awt.*;
import java.util.*;
import java.awt.font.*;
public class Test57 {
public static void main(String[] args) {
Test57 test = new Test57();
test.go();
}
public void go() {
Font font = new Font("SomeName", Font.BOLD, 24);
Hashtable hash = new Hashtable(1);
hash.put(TextAttribute.FONT, font);
font = new Font((Map) hash);
if (!font.getName().equalsIgnoreCase("SomeName")) {
System.out.println("getName returned \"" + font.getName() + "\" when \"SomeName\" " +
" expected");
}
if (font.getStyle() != Font.BOLD) {
System.out.println("getStyle returned " + font.getStyle() + " when " +
Font.BOLD + " expected");
}
if (font.getSize() != 24) {
System.out.println("getSize returned " + font.getSize() + " when 24 " +
" expected");
}
System.out.println("Done");
}
}
======================= output ====================================
getName returned "Dialog" when "SomeName" expected
getStyle returned 0 when 1 expected
getSize returned 12 when 24 expected
Done
====================================================================
###@###.### 10/25/04 16:13 GMT
Constructor Font(Map) ignores this attribute. See example below:
========================= Test57.java =========================
import java.awt.*;
import java.util.*;
import java.awt.font.*;
public class Test57 {
public static void main(String[] args) {
Test57 test = new Test57();
test.go();
}
public void go() {
Font font = new Font("SomeName", Font.BOLD, 24);
Hashtable hash = new Hashtable(1);
hash.put(TextAttribute.FONT, font);
font = new Font((Map) hash);
if (!font.getName().equalsIgnoreCase("SomeName")) {
System.out.println("getName returned \"" + font.getName() + "\" when \"SomeName\" " +
" expected");
}
if (font.getStyle() != Font.BOLD) {
System.out.println("getStyle returned " + font.getStyle() + " when " +
Font.BOLD + " expected");
}
if (font.getSize() != 24) {
System.out.println("getSize returned " + font.getSize() + " when 24 " +
" expected");
}
System.out.println("Done");
}
}
======================= output ====================================
getName returned "Dialog" when "SomeName" expected
getStyle returned 0 when 1 expected
getSize returned 12 when 24 expected
Done
====================================================================
###@###.### 10/25/04 16:13 GMT
- relates to
-
JDK-5102276 Ambigious specs for attributed text drawing
- Resolved
-
JDK-6184555 Font(Map)/getFont(Map): behavior with useless TextAttributes should be clarified
- Closed