946 int ppemY = eblcTable.get(8+(i*48)+45) &0xff;
947 if (ppemY == ptSize) {
948 return true;
949 }
950 }
951 return false;
952 }
953
954 public String getFullName() {
955 return fullName;
956 }
957
958 /* This probably won't get called but is there to support the
959 * contract() of setStyle() defined in the superclass.
960 */
961 @Override
962 protected void setStyle() {
963 setStyle(getTableBuffer(os_2Tag));
964 }
965
966 /* TrueTypeFont can use the fsSelection fields of OS/2 table
967 * to determine the style. In the unlikely case that doesn't exist,
968 * can use macStyle in the 'head' table but simpler to
969 * fall back to super class algorithm of looking for well known string.
970 * A very few fonts don't specify this information, but I only
971 * came across one: Lucida Sans Thai Typewriter Oblique in
972 * /usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/lucidai.ttf
973 * that explicitly specified the wrong value. It says its regular.
974 * I didn't find any fonts that were inconsistent (ie regular plus some
975 * other value).
976 */
977 private static final int fsSelectionItalicBit = 0x00001;
978 private static final int fsSelectionBoldBit = 0x00020;
979 private static final int fsSelectionRegularBit = 0x00040;
980 private void setStyle(ByteBuffer os_2Table) {
981 /* fsSelection is unsigned short at buffer offset 62 */
982 if (os_2Table == null || os_2Table.capacity() < 64) {
983 super.setStyle();
984 return;
985 }
986 int fsSelection = os_2Table.getChar(62) & 0xffff;
987 int italic = fsSelection & fsSelectionItalicBit;
988 int bold = fsSelection & fsSelectionBoldBit;
989 int regular = fsSelection & fsSelectionRegularBit;
990 // System.out.println("platname="+platName+" font="+fullName+
991 // " family="+familyName+
992 // " R="+regular+" I="+italic+" B="+bold);
993 if (regular!=0 && ((italic|bold)!=0)) {
994 /* This is inconsistent. Try using the font name algorithm */
995 super.setStyle();
996 return;
997 } else if ((regular|italic|bold) == 0) {
998 /* No style specified. Try using the font name algorithm */
999 super.setStyle();
1000 return;
1001 }
1002 switch (bold|italic) {
|
946 int ppemY = eblcTable.get(8+(i*48)+45) &0xff;
947 if (ppemY == ptSize) {
948 return true;
949 }
950 }
951 return false;
952 }
953
954 public String getFullName() {
955 return fullName;
956 }
957
958 /* This probably won't get called but is there to support the
959 * contract() of setStyle() defined in the superclass.
960 */
961 @Override
962 protected void setStyle() {
963 setStyle(getTableBuffer(os_2Tag));
964 }
965
966 private int fontWidth = 0;
967 @Override
968 public int getWidth() {
969 return (fontWidth > 0) ? fontWidth : super.getWidth();
970 }
971
972 private int fontWeight = 0;
973 @Override
974 public int getWeight() {
975 return (fontWeight > 0) ? fontWeight : super.getWeight();
976 }
977
978 /* TrueTypeFont can use the fsSelection fields of OS/2 table
979 * to determine the style. In the unlikely case that doesn't exist,
980 * can use macStyle in the 'head' table but simpler to
981 * fall back to super class algorithm of looking for well known string.
982 * A very few fonts don't specify this information, but I only
983 * came across one: Lucida Sans Thai Typewriter Oblique in
984 * /usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/lucidai.ttf
985 * that explicitly specified the wrong value. It says its regular.
986 * I didn't find any fonts that were inconsistent (ie regular plus some
987 * other value).
988 */
989 private static final int fsSelectionItalicBit = 0x00001;
990 private static final int fsSelectionBoldBit = 0x00020;
991 private static final int fsSelectionRegularBit = 0x00040;
992 private void setStyle(ByteBuffer os_2Table) {
993 if (os_2Table == null) {
994 return;
995 }
996 if (os_2Table.capacity() >= 8) {
997 fontWeight = os_2Table.getChar(4) & 0xffff;
998 fontWidth = os_2Table.getChar(6) & 0xffff;
999 }
1000 /* fsSelection is unsigned short at buffer offset 62 */
1001 if (os_2Table.capacity() < 64) {
1002 super.setStyle();
1003 return;
1004 }
1005 int fsSelection = os_2Table.getChar(62) & 0xffff;
1006 int italic = fsSelection & fsSelectionItalicBit;
1007 int bold = fsSelection & fsSelectionBoldBit;
1008 int regular = fsSelection & fsSelectionRegularBit;
1009 // System.out.println("platname="+platName+" font="+fullName+
1010 // " family="+familyName+
1011 // " R="+regular+" I="+italic+" B="+bold);
1012 if (regular!=0 && ((italic|bold)!=0)) {
1013 /* This is inconsistent. Try using the font name algorithm */
1014 super.setStyle();
1015 return;
1016 } else if ((regular|italic|bold) == 0) {
1017 /* No style specified. Try using the font name algorithm */
1018 super.setStyle();
1019 return;
1020 }
1021 switch (bold|italic) {
|