📄 cjkfont.java
字号:
/** Metrics for the font HYSMyeongJo-Medium with the encoding UniKS-UCS2-H */
private static final int HYSMyeongJo_Medium_UniKS_UCS2_H[] = {
32,333,33,416,34,416,35,833,36,625,37,916,38,833,39,250,40,500,41,500,42,500,43,833,44,291,45,833,46,291,47,375,
48,625,49,625,50,625,51,625,52,625,53,625,54,625,55,625,56,625,57,625,58,333,59,333,60,833,61,833,62,916,63,500,
65,791,66,708,67,708,68,750,69,708,70,666,71,750,72,791,73,375,74,500,75,791,76,666,77,916,78,791,79,750,80,666,
81,750,82,708,83,666,84,791,85,791,86,750,88,708,89,708,90,666,91,500,92,375,93,500,94,500,95,500,96,333,97,541,
98,583,99,541,100,583,101,583,102,375,103,583,104,583,105,291,106,333,107,583,108,291,109,875,110,583,111,583,112,583,113,583,
114,458,115,541,116,375,117,583,118,583,119,833,120,625,121,625,122,500,123,583,124,583,125,583,126,750
};
/** Array of font/encoding combinations allowed and information to build the font descriptors */
private static final Object cjk[] =
{
new Object[]{
"STSong-Light", //font name
new int[]{880,880,-120,6,-25,-254,1000,880,0,93,2}, //font descriptor (Ascent,CapHeight,Descent,Flags,FontBBox,ItalicAngle,StemV,Supplement
//font descriptor registry, ordering, W
new String[]{"Adobe", "GB1", "[1[207 270 342 467 462 797 710 239]9 10 374 11[423 605 238 375 238 334]17 26 462 27 28 238 29 31 605 32[344 748 684 560 695 739 563 511 729 793 318 312 666 526 896 758 772 544 772 628 465 607 753 711 972 647 620 607 374 333 374 606 500 239 417 503 427 529 415 264 444 518 241 230 495 228 793 527]80 81 524 82[504 338 336 277 517 450 652 466 452 407 370 258 370 605]814 939 500 7712[517 684 723 1000 500]]"},
new byte[]{1,5,2,2,4,0,0,0,0,0,0,0}, //panose
new String[]{"UniGB-UCS2-H","UniGB-UCS2-V"}, // allowed cmaps
new int[][]{STSong_Light_UniGB_UCS2_H, null, STSong_Light_UniGB_UCS2_H, null} //metrics (two for each cmap, search first then second}
},
new Object[]{
"MHei-Medium", //font name
new int[]{880,880,-120,4,-45,-250,1015,887,0,93,0}, //font descriptor (Ascent,CapHeight,Descent,Flags,FontBBox,ItalicAngle,StemV,Supplement
//font descriptor registry, ordering, W
new String[]{"Adobe", "CNS1", "[1 2 278 3[355]4 5 556 6[889 667 222]9 10 333 11[389 584 278 333]15 16 278 17 26 556 27 28 278 29 31 584 32[556 1015]34 35 667 36 37 722 38[667 611 778 722 278 500 667 556 833 722 778 667 778 722 667 611 722 667 944]57 58 667 59[611]60 62 278 63[469 556 222]66 67 556 68[500]69 70 556 71[278]72 73 556 74 75 222 76[500 222 833]79 82 556 83[333 500 278 556 500 722]89 91 500 92[334 260 334 584 737]13648 13742 500]"},
new byte[]{8,1,2,11,6,0,0,0,0,0,0,0}, //panose
new String[]{"UniCNS-UCS2-H","UniCNS-UCS2-V"}, // allowed cmaps
new int[][]{MHei_Medium_UniCNS_UCS2_H, null, MHei_Medium_UniCNS_UCS2_H, null} //metrics (two for each cmap, search first then second}
},
new Object[]{
"MSung-Light", //font name
new int[]{880,880,-120,6,-160,-249,1015,888,0,93,0}, //font descriptor (Ascent,CapHeight,Descent,Flags,FontBBox,ItalicAngle,StemV,Supplement
//font descriptor registry, ordering, W
new String[]{"Adobe", "CNS1", "[1 2 250 3[408 668 490 875 698 250]9 10 240 11[417 667 250 313 250 520]17 26 500 27 28 250 29 31 667 32[396 921 677 615 719 760 625 552 771 802]42 43 354 44[781 604 927 750 823 563 823 729 542 698 771 729 948 771 677 635 344 520 344 469 500 250 469 521 427 521 438 271 469 531]74 75 250 76[458 240 802 531 500]81 82 521 83[365 333 292 521 458 677 479 458 427 480 496 480 667 760 980]13648 13742 500]"},
new byte[]{1,5,2,2,4,0,0,0,0,0,0,0}, //panose
new String[]{"UniCNS-UCS2-H","UniCNS-UCS2-V"}, // allowed cmaps
new int[][]{MSung_Light_UniCNS_UCS2_H, null, MSung_Light_UniCNS_UCS2_H, null} //metrics (two for each cmap, search first then second}
},
new Object[]{
"HeiseiKakuGo-W5", //font name
new int[]{875,718,-125,4,-92,-250,1010,922,0,93,2}, //font descriptor (Ascent,CapHeight,Descent,Flags,FontBBox,ItalicAngle,StemV,Supplement
//font descriptor registry, ordering, W
new String[]{"Adobe", "Japan1", "[1 2 278 3[355]4 5 556 6[889 667 191]9 10 333 11[389 584 278 333]15 16 278 17 26 556 27 28 278 29 31 584 32[556 1015]34 35 667 36 37 722 38[667 611 778 722 278 500 667 556 833 722 778 667 778 722 667 611 722 667 944]57 58 667 59[611 278 556 278 469 556 333]66 67 556 68[500]69 70 556 71[278]72 73 556 74 75 222 76[500 222 833]79 82 556 83[333 500 278 556 500 722]89 91 500 92[334 260 334 333 222 278 222 260 584 333]102 103 556 104[167]105 107 556 108[333 556]110 111 333 112 113 500 114 116 556 117[278 537 350 222]121 122 333 123[556]126[611]127 137 333 140[370 556 778 1000 365 889 278 222 611 944 611 584 737 584 737 400 584]157 158 333 159[556 333]161 163 834 164 169 667 170[722]171 174 667 175 178 278 179 180 722 181 185 778 186[584]187 190 722 191 192 667 193 198 556 199[500]200 203 556 204 207 278 208 214 556 215[584]216 219 556 220[500 556 500]223 224 667 225[611 556 500 1000 500 556]231 632 500 8718[500]]"},
new byte[]{8,1,2,11,6,0,0,0,0,0,0,0}, //panose
new String[]{"UniJIS-UCS2-H","UniJIS-UCS2-V","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V"}, // allowed cmaps
new int[][]{HeiseiKakuGo_W5_UniJIS_UCS2_H, null, HeiseiKakuGo_W5_UniJIS_UCS2_H, null, HeiseiKakuGo_W5_UniJIS_UCS2_HW_H, HeiseiKakuGo_W5_UniJIS_UCS2_H,
HeiseiKakuGo_W5_UniJIS_UCS2_HW_V, HeiseiKakuGo_W5_UniJIS_UCS2_H} //metrics (two for each cmap, search first then second}
},
new Object[]{
"HeiseiMin-W3", //font name
new int[]{857,718,-143,6,-123,-257,1001,910,0,93,2}, //font descriptor (Ascent,CapHeight,Descent,Flags,FontBBox,ItalicAngle,StemV,Supplement
//font descriptor registry, ordering, W
new String[]{"Adobe", "Japan1", "[1[250 333 408]4 5 500 6[833 778 180]9 10 333 11[500 564 250 333 250 278]17 26 500 27 28 278 29 31 564 32[444 921 722]35 36 667 37[722 611 556]40 41 722 42[333 389 722 611 889]47 48 722 49[556 722 667 556 611]54 55 722 56[944]57 58 722 59[611 333 500 333 469 500 333 444 500 444 500 444 333]72 73 500 74 75 278 76[500 278 778]79 82 500 83[333 389 278]86 87 500 88[722]89 90 500 91[444 480 200 480]95 96 333 97[278 333 200 541 333]102 103 500 104[167]105 107 500 108[444 500]110 111 333 112 113 556 114 116 500 117[250 453 350 333]121 122 444 123[500]126[444]127 137 333 138[1000 889 276 611 722 889 310 667]146 147 278 148[500 722 500 564 760 564 760 400 564]157 158 300 159[500 300]161 163 750 164 169 722 170[667]171 174 611 175 178 333 179 185 722 186[564]187 191 722 192[556]193 203 444 204 207 278 208 214 500 215[564]216 222 500 223[556 722 611 500 389 980 444]230 632 500 8718[500]]"},
new byte[]{1,5,2,2,4,0,0,0,0,0,0,0}, //panose
new String[]{"UniJIS-UCS2-H","UniJIS-UCS2-V","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V"}, // allowed cmaps
new int[][]{HeiseiMin_W3_UniJIS_UCS2_H, null, HeiseiMin_W3_UniJIS_UCS2_H, null, HeiseiMin_W3_UniJIS_UCS2_HW_H, HeiseiMin_W3_UniJIS_UCS2_H,
HeiseiMin_W3_UniJIS_UCS2_HW_V, HeiseiMin_W3_UniJIS_UCS2_H} //metrics (two for each cmap, search first then second}
},
new Object[]{
"HYGoThic-Medium", //font name
new int[]{880,880,-120,4,-6,-145,1003,880,0,93,1}, //font descriptor (Ascent,CapHeight,Descent,Flags,FontBBox,ItalicAngle,StemV,Supplement
//font descriptor registry, ordering, W
new String[]{"Adobe", "Korea1", "[1[333]2 3 416 4[833 666 916 750 250]9 10 416 11[583 833 375 833]15 16 375 17 26 583 27 28 416 29 31 833 32[583 1000 666 708]36 37 750 38[666 625 833 750 291 541 708 583 875 750 791 666 791 708 666 583 750 625 916]57 59 625 60[416 375 416]63 65 500 66[583 625 583 625 583 375 625 583]74 75 250 76[541 250 916]79 82 625 83[333 541 333 583 500 750]89 94 500 95[750 958 500 881 963]8094 8190 500]"},
new byte[]{8,1,2,11,6,0,0,0,0,0,0,0}, //panose
new String[]{"UniKS-UCS2-H","UniKS-UCS2-V"}, // allowed cmaps
new int[][]{HYGoThic_Medium_UniKS_UCS2_H, null, HYGoThic_Medium_UniKS_UCS2_H, null} //metrics (two for each cmap, search first then second}
},
new Object[]{
"HYSMyeongJo-Medium", //font name
new int[]{880,880,-120,6,0,-148,1001,880,0,93,1}, //font descriptor (Ascent,CapHeight,Descent,Flags,FontBBox,ItalicAngle,StemV,Supplement
//font descriptor registry, ordering, W
new String[]{"Adobe", "Korea1", "[1[333]2 3 416 4[833 625 916 833 250]9 11 500 12[833 291 833 291 375]17 26 625 27 28 333 29 30 833 31[916 500 1000 791]35 36 708 37[750 708 666 750 791 375 500 791 666 916 791 750 666 750 708 666]53 54 791 55[750 1000]57 58 708 59[666 500 375]62 64 500 65[333 541 583 541]69 70 583 71[375]72 73 583 74[291 333 583 291 875]79 82 583 83[458 541 375]86 87 583 88[833]89 90 625 91[500]92 94 583 95[750 1000 500]8094 8190 500]"},
new byte[]{1,5,2,2,4,0,0,0,0,0,0,0}, //panose
new String[]{"UniKS-UCS2-H","UniKS-UCS2-V"}, // allowed cmaps
new int[][]{HYSMyeongJo_Medium_UniKS_UCS2_H, null, HYSMyeongJo_Medium_UniKS_UCS2_H, null} //metrics (two for each cmap, search first then second}
}
};
/** The font name */
private String fontName;
/** The style modifier */
private String style = "";
/** The CMap associated with this font */
private String CMap;
/** The descriptor information of type <CODE>int</Code> */
private int fdescInt[];
/** The descriptor information of type <CODE>String</Code> */
private String fdescStr[];
/** The panose information */
private byte panose[];
/** The first metric array to search */
private int metrics1[];
/** The second metric array to search if the search failled on the first */
private int metrics2[];
/** Creates a CJK font.
* @param fontName the name of the font
* @param enc the encoding of the font
* @param emb always <CODE>false</CODE>. CJK font and not embedded
* @throws DocumentException on error
* @throws IOException on error
*/
CJKFont(String fontName, String enc, boolean emb) throws DocumentException, IOException
{
fontType = FONT_TYPE_CJK;
String nameBase = getBaseName(fontName);
if (!isCJKFont(nameBase, enc))
throw new DocumentException("Font '" + fontName + "' with '" + enc + "' encoding is not a CJK font.");
if (nameBase.length() < fontName.length()) {
style = fontName.substring(nameBase.length());
fontName = nameBase;
}
encoding = CJK_ENCODING;
for (int k = 0; k < cjk.length; ++k) {
Object obj[] = (Object[])cjk[k];
String name = (String)obj[0];
if (name.equals(fontName)) {
String tenc[] = (String[])obj[4];
for (int j = 0; j < tenc.length; ++j) {
if (enc.equals(tenc[j])) {
this.fontName = fontName;
CMap = enc;
fdescInt = (int[])obj[1];
fdescStr = (String[])obj[2];
int met[][] = (int[][])obj[5];
metrics1 = met[j << 1];
metrics2 = met[(j << 1) + 1];
panose = (byte[])obj[3];
return;
}
}
}
}
}
/** Checks if its a valid CJK font.
* @param fontName the font name
* @param enc the encoding
* @return <CODE>true</CODE> if it is CJK font
*/
public static boolean isCJKFont(String fontName, String enc)
{
for (int k = 0; k < cjk.length; ++k) {
Object obj[] = (Object[])cjk[k];
String name = (String)obj[0];
if (name.equals(fontName)) {
String tenc[] = (String[])obj[4];
for (int j = 0; j < tenc.length; ++j) {
if (enc.equals(tenc[j]))
return true;
}
return false;
}
}
return false;
}
public static boolean isCJKEncoding(String enc)
{
for (int k = 0; k < cjk.length; ++k) {
Object obj[] = (Object[])cjk[k];
String tenc[] = (String[])obj[4];
for (int j = 0; j < tenc.length; ++j) {
if (enc.equals(tenc[j]))
return true;
}
}
return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -