Changeset 3041
- Timestamp:
- 03/08/03 14:38:30 (6 years ago)
- Files:
-
- work/cvs2svn/src/mw32font.c (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
work/cvs2svn/src/mw32font.c
r3014 r3041 44 44 Lisp_Object Qany, Qstrict_spec; 45 45 Lisp_Object Qoverhang, Qrelative_compose, Qdefault_ascent; 46 Lisp_Object Qencoding_type, Qencoder; 47 Lisp_Object Qspacing, Qdim, Qcentering; 46 Lisp_Object Qencoding, Qfont_unit_byte; 47 Lisp_Object Q1_byte_set_msb, Q2_byte_set_msb, Qunicode, Qshift_jis; 48 Lisp_Object Qspacing, Qcentering; 48 49 49 50 Lisp_Object Qbase, Qweight, Qfixed, Qitalic; … … 75 76 76 77 static Lisp_Object mw32_get_font_request_parameter(Lisp_Object, Lisp_Object); 78 79 static int mw32_valid_encoding_p (Lisp_Object encoding); 80 static void mw32_set_encoding_to_lf (MW32LogicalFont *plf, Lisp_Object encoding); 81 static void mw32_set_encoding_byte_from_charset (MW32LogicalFont *plf, int c); 77 82 78 83 … … 122 127 Lisp_Object slot, obj; 123 128 124 /* default value. */125 plf->dim = 1;126 plf->encoding_type = 0;127 INITIALIZE_CCL_ID(plf->ccl_method);128 129 129 /* Don't know such charset!. */ 130 130 if ((charset > 255) … … 132 132 return; 133 133 134 if (NILP(slot)) return ; 135 136 obj = AREF(slot, 0); 137 if (INTEGERP(obj) 138 && (XFASTINT(obj) > 0) 139 && (XFASTINT(obj) <= 2)) 140 plf->dim = XFASTINT(obj); 141 142 obj = AREF(slot, 1); 143 if (INTEGERP(obj) 144 && ((XFASTINT(obj) == ENCODING_DIMENSION) 145 || (XFASTINT(obj) == ENCODING_BYTE1MSB1) 146 || (XFASTINT(obj) == ENCODING_BYTE2MSB1) 147 || (XFASTINT(obj) == ENCODING_BYTE2LSB1) 148 || (XFASTINT(obj) == ENCODING_SHIFTJIS) 149 || (XFASTINT(obj) == ENCODING_UNICODE))) 150 plf->encoding_type = XFASTINT(obj); 151 152 obj = AREF(slot, 2); 153 if (!NILP (obj) && (SYMBOLP(obj))) 154 plf->ccl_method = mw32_get_ccl_id(obj); 134 if (NILP (slot)) return; 135 136 if (!mw32_valid_encoding_p (slot)) return; 137 mw32_set_encoding_to_lf (plf, slot); 155 138 } 156 139 … … 200 183 } 201 184 #endif 202 if (plf-> dim== 1)185 if (plf->encoding.font_unit_byte == 1) 203 186 { 204 187 if (cp > 255) … … 261 244 SelectObject(hdc, hold); 262 245 } 263 if (plf-> dim== 1)246 if (plf->encoding.font_unit_byte == 1) 264 247 pwf->cmcache[cp] = pwf->cur_cm; 265 248 … … 468 451 DeleteObject(bk); 469 452 } 470 mw32_BDF_TextOut(pbf, hdc, x, ybase, text, plf->dim, bytes, 0, 453 mw32_BDF_TextOut(pbf, hdc, x, ybase, text, 454 plf->encoding.font_unit_byte, bytes, 0, 471 455 getDeviceWidth(hdc, plf->character_spacing)); 472 456 } … … 550 534 plf->character_spacing = 0; 551 535 plf->fixed_pitch = TRUE; 552 plf->dim = 1;553 plf->encoding_type = 0;554 536 plf->centering = 0; 555 INITIALIZE_CCL_ID(plf->ccl_method);556 537 } 557 538 else … … 593 574 594 575 static int 595 set_ccl_method (ccl_id_type cclid, struct ccl_program *encoder)576 set_ccl_method (ccl_id_type cclid, struct ccl_program *encoder) 596 577 { 597 578 extern Lisp_Object Vccl_program_table; … … 623 604 } 624 605 #else 625 if (SYMBOLP (encoding) &&606 if (SYMBOLP (encoding) && 626 607 (SYMBOLP (encoding = Fget (encoding, Qccl_program))) && 627 608 (setup_ccl_program(encoder, encoding) >= 0)) … … 675 656 { 676 657 int i; 677 struct ccl_program ccl_prog;678 658 679 659 fontp->charset = CHAR_CHARSET(c); 680 if (!set_ccl_method (plf->ccl_method, &ccl_prog)) 681 fontp->font_encoder = NULL;682 else660 661 fontp->font_encoder = NULL; 662 if (plf->encoding.type == ENCODING_EXTERNAL) 683 663 { 684 fontp->font_encoder 685 = (struct ccl_program *) xmalloc (sizeof (struct ccl_program)); 686 *(fontp->font_encoder) = ccl_prog; 664 struct ccl_program ccl_prog; 665 if (set_ccl_method (plf->encoding.e.ccl_method, &ccl_prog)) 666 { 667 fontp->font_encoder 668 = (struct ccl_program *) xmalloc (sizeof (struct ccl_program)); 669 *(fontp->font_encoder) = ccl_prog; 670 } 687 671 } 688 fontp->encoding[0] = fontp->encoding[1] = plf->encoding _type;672 fontp->encoding[0] = fontp->encoding[1] = plf->encoding.type; 689 673 for (i = MIN_CHARSET_OFFICIAL_DIMENSION1; i <= MAX_CHARSET; i++) 690 fontp->encoding[i] = plf->encoding _type;674 fontp->encoding[i] = plf->encoding.type; 691 675 } 692 676 else 693 677 { 694 678 fontp->charset = CHARSET_ASCII; 695 fontp->encoding[1] = plf->encoding _type;679 fontp->encoding[1] = plf->encoding.type; 696 680 } 697 681 if (plf->centering … … 700 684 (Vvertical_centering_font_regexp, fontp->full_name) >= 0))) 701 685 fontp->vertical_centering = 1; 702 }703 704 static void705 free_font_info(MW32LogicalFont *plf)706 {707 struct font_info *fontp;708 fontp = plf->fontip;709 710 xfree(fontp->name);711 xfree(fontp->full_name);712 if ((plf->ccl_method.data) && (fontp->font_encoder))713 {714 /* Caution!!!! */715 if (!set_ccl_method(plf->ccl_method, fontp->font_encoder))716 {717 xfree(fontp->font_encoder);718 fontp->font_encoder = NULL;719 }720 }721 686 } 722 687 … … 771 736 { 772 737 MW32LogicalFont *plf; 773 Lisp_Object encoding;774 struct ccl_program ccl_prog;775 738 776 739 plf = (MW32LogicalFont*) fontp->font; 777 740 if (!plf) return; 778 741 779 if (!set_ccl_method (plf->ccl_method, &ccl_prog)) 780 fontp->font_encoder = NULL; 781 else 782 { 783 fontp->font_encoder 784 = (struct ccl_program *) xmalloc (sizeof (struct ccl_program)); 785 *(fontp->font_encoder) = ccl_prog; 786 } 742 fontp->font_encoder = NULL; 743 if (plf->encoding.type == ENCODING_EXTERNAL) 744 { 745 struct ccl_program ccl_prog; 746 if (set_ccl_method (plf->encoding.e.ccl_method, &ccl_prog)) 747 { 748 fontp->font_encoder 749 = (struct ccl_program *) xmalloc (sizeof (struct ccl_program)); 750 *(fontp->font_encoder) = ccl_prog; 751 } 752 } 753 787 754 return; 788 755 } … … 1053 1020 } 1054 1021 1055 ccl_id_type 1056 mw32_get_ccl_id (Lisp_Object encode) 1057 { 1058 ccl_id_type cclid; 1059 1060 if (NILP(encode)) 1061 { 1062 INITIALIZE_CCL_ID(cclid); 1063 } 1022 /* encoding in Meadow font system has one of the following value. 1023 o ... nil (default) 1024 o ... 1-byte-set-msb 1025 o ... 2-byte-set-msb 1026 o ... shift_jis 1027 o ... unicode 1028 o ... <encoder> registered by (w32-regist-font-encoder). 1029 */ 1030 static int 1031 mw32_valid_encoding_p (Lisp_Object encoding) 1032 { 1033 if (NILP (encoding)) return 1; 1034 if (EQ (encoding, Q1_byte_set_msb)) return 1; 1035 if (EQ (encoding, Q2_byte_set_msb)) return 1; 1036 if (EQ (encoding, Qshift_jis)) return 1; 1037 if (EQ (encoding, Qunicode)) return 1; 1038 if (!SYMBOLP (encoding)) return 0; 1039 if (ENCODING_METHOD_P (encoding)) return 1; 1040 1041 return 0; 1042 } 1043 1044 static void 1045 mw32_set_encoding_to_lf (MW32LogicalFont *plf, Lisp_Object encoding) 1046 { 1047 if (NILP (encoding)) 1048 { 1049 /* Actually, need not set 1050 because all members must have been cleared. */ 1051 plf->encoding.type = ENCODING_DIMENSION; 1052 } 1053 else if (EQ (encoding, Q1_byte_set_msb)) 1054 { 1055 plf->encoding.type = ENCODING_BYTE1MSB1; 1056 plf->encoding.font_unit_byte = 1; 1057 } 1058 else if (EQ (encoding, Q2_byte_set_msb)) 1059 { 1060 plf->encoding.type = ENCODING_BYTE2MSB1; 1061 plf->encoding.font_unit_byte = 2; 1062 } 1063 else if (EQ (encoding, Qshift_jis)) 1064 { 1065 plf->encoding.type = ENCODING_SHIFTJIS; 1066 } 1067 else if (EQ (encoding, Qunicode)) 1068 { 1069 plf->encoding.type = ENCODING_UNICODE; 1070 plf->encoding.font_unit_byte = 2; 1071 } 1072 else if (ENCODING_METHOD_P (encoding)) 1073 { 1074 Lisp_Object symname, byte; 1075 char *data; 1076 int size; 1077 1078 plf->encoding.type = ENCODING_EXTERNAL; 1079 if (plf->encoding.e.ccl_method.data) 1080 xfree (plf->encoding.e.ccl_method.data); 1081 1082 symname = Fsymbol_name (encoding); 1083 size = LISPY_STRING_BYTES (symname); 1084 data = (char*) xmalloc (size); 1085 plf->encoding.e.ccl_method.size = size; 1086 plf->encoding.e.ccl_method.data = data; 1087 memcpy (data, XSTRING(symname)->data, size); 1088 1089 byte = Fget (encoding, Qfont_unit_byte); 1090 if (NUMBERP (byte) && (XINT (byte) > 0)) 1091 { 1092 plf->encoding.font_unit_byte = XFASTINT (byte); 1093 } 1094 } 1064 1095 else 1065 1096 { 1066 Lisp_Object symname; 1067 1068 symname = Fsymbol_name(encode); 1069 cclid.size = LISPY_STRING_BYTES(symname); 1070 cclid.data = (char*)xmalloc(cclid.size); 1071 memcpy(cclid.data, XSTRING(symname)->data, cclid.size); 1072 } 1073 1074 return cclid; 1097 abort(); 1098 } 1099 } 1100 1101 static void 1102 mw32_set_encoding_byte_from_charset (MW32LogicalFont *plf, int c) 1103 { 1104 if (plf->encoding.font_unit_byte == 0) { 1105 Lisp_Object charset = CHAR_CHARSET (c); 1106 if (NILP (charset)) 1107 plf->encoding.font_unit_byte = 1; 1108 else 1109 plf->encoding.font_unit_byte = CHARSET_DIMENSION (charset); 1110 } 1075 1111 } 1076 1112 … … 1287 1323 hashval = (hashval << 3) ^ plf->descent; 1288 1324 hashval = (hashval << 2) ^ plf->overhang; 1289 hashval = (hashval << 1) ^ plf->encoding_type; 1325 /* TODO */ 1326 hashval = (hashval << 2) ^ plf->encoding.type; 1290 1327 hashval = (hashval << 2) ^ plf->relative_compose; 1291 1328 hashval = (hashval << 2) ^ plf->character_spacing; 1292 1329 hashval = (hashval << 2) ^ plf->default_ascent; 1293 1330 hashval = (hashval << 1) ^ plf->fixed_pitch; 1294 hashval = (hashval << 1) ^ plf->dim;1295 1331 hashval = (hashval << 1) ^ plf->centering; 1296 1332 if (hashval > HASHMAXVAL) hashval %= HASHMAXVAL; 1297 hashval = hashval ^ mw32_hash_ccl_method(plf->ccl_method);1298 1333 hashval = hashval ^ ((int)plf->hash); 1299 1334 hashval = hashval ^ ((int)plf->textout); … … 1323 1358 && LF_EQUAL_ELEM (descent) 1324 1359 && LF_EQUAL_ELEM (overhang) 1325 && LF_EQUAL_ELEM (encoding_type) 1360 /* TODO */ 1361 && LF_EQUAL_ELEM (encoding.type) 1326 1362 && LF_EQUAL_ELEM (relative_compose) 1327 1363 && LF_EQUAL_ELEM (character_spacing) 1328 1364 && LF_EQUAL_ELEM (default_ascent) 1329 1365 && LF_EQUAL_ELEM (fixed_pitch) 1330 && LF_EQUAL_ELEM (dim)1331 1366 && LF_EQUAL_ELEM (centering) 1332 1367 && LF_EQUAL_ELEM (hash) … … 1335 1370 && LF_EQUAL_ELEM (set_layout) 1336 1371 && LF_EQUAL_ELEM (free) 1337 && LF_EQUAL_ELEM (pfr) 1338 && mw32_ccl_method_equal (plf1->ccl_method, plf2->ccl_method)); 1372 && LF_EQUAL_ELEM (pfr)); 1339 1373 #undef LF_EQUAL_ELEM 1340 1374 } … … 1414 1448 { 1415 1449 plf = (*proc)(pfr, f, face, c); 1416 if (plf) return plf; 1450 if (plf) 1451 { 1452 mw32_set_encoding_byte_from_charset (plf, c); 1453 return plf; 1454 } 1417 1455 } 1418 1456 } 1457 1419 1458 return NULL; 1420 1459 } … … 1557 1596 pfr = plf->pfr; 1558 1597 1598 if (plf->encoding.e.ccl_method.data) 1599 xfree (plf->encoding.e.ccl_method.data); 1600 1559 1601 for (i = 0;i < pfr->loaded_LF_num;i++) 1560 1602 { … … 1580 1622 Lisp_Object val; 1581 1623 1582 val = mw32_get_font_request_parameter (Qencoding_type, option); 1583 if (INTEGERP (val)) plf->encoding_type = XINT (val); 1584 val = mw32_get_font_request_parameter (Qencoder, option); 1585 if (SYMBOLP (val)) plf->ccl_method = mw32_get_ccl_id (val); 1624 val = mw32_get_font_request_parameter (Qencoding, option); 1625 if (!NILP (val)) mw32_set_encoding_to_lf (plf, val); 1586 1626 val = mw32_get_font_request_parameter (Qrelative_compose, option); 1587 1627 if (INTEGERP (val)) plf->relative_compose = XINT (val); … … 1590 1630 val = mw32_get_font_request_parameter (Qspacing, option); 1591 1631 if (INTEGERP (val)) plf->character_spacing = XINT (val); 1592 val = mw32_get_font_request_parameter (Qdim, option);1593 if (INTEGERP (val)) plf->dim = XINT (val);1594 1632 val = mw32_get_font_request_parameter (Qcentering, option); 1595 1633 if (!NILP (val)) plf->centering = 1; … … 2124 2162 mw32_check_font_request_alist(Lisp_Object alist) 2125 2163 { 2126 Lisp_Object width, height, base, overhang, encoding _type;2164 Lisp_Object width, height, base, overhang, encoding; 2127 2165 Lisp_Object relative_compose, default_ascent, encoder; 2128 2166 Lisp_Object spacing, dim, centering; 2129 2167 2130 width = mw32_get_font_request_parameter(Qwidth, alist); 2131 height = mw32_get_font_request_parameter(Qheight, alist); 2132 base = mw32_get_font_request_parameter(Qbase, alist); 2133 overhang = mw32_get_font_request_parameter(Qoverhang, alist); 2134 encoding_type = mw32_get_font_request_parameter(Qencoding_type, alist); 2135 relative_compose = mw32_get_font_request_parameter(Qrelative_compose, alist); 2136 default_ascent = mw32_get_font_request_parameter(Qdefault_ascent, alist); 2137 encoder = mw32_get_font_request_parameter(Qencoder, alist); 2138 spacing = mw32_get_font_request_parameter(Qspacing, alist); 2139 dim = mw32_get_font_request_parameter(Qdim, alist); 2140 centering = mw32_get_font_request_parameter(Qcentering, alist); 2141 2142 if (!NILP(width)) CHECK_NUMBER(width, 2); 2143 if (!NILP(height)) CHECK_NUMBER(height, 3); 2144 if (!NILP(base)) CHECK_NUMBER(base, 4); 2145 if (!NILP(overhang)) CHECK_NUMBER(overhang, 5); 2146 if (!NILP(encoding_type)) CHECK_NUMBER(encoding_type, 6); 2147 if (!NILP(relative_compose)) CHECK_NUMBER(relative_compose, 7); 2148 if (!NILP(default_ascent)) CHECK_NUMBER(default_ascent, 8); 2149 if (!NILP(encoder) 2150 && !ENCODING_METHOD_P(encoder)) 2151 error("This encode is NOT valid!"); 2152 if (!NILP(spacing)) CHECK_NUMBER(spacing, 9); 2153 if (!NILP(dim)) CHECK_NUMBER(dim, 10); 2154 if (!NILP(centering))CHECK_SYMBOL(dim, 11); 2168 width = mw32_get_font_request_parameter (Qwidth, alist); 2169 height = mw32_get_font_request_parameter (Qheight, alist); 2170 base = mw32_get_font_request_parameter (Qbase, alist); 2171 overhang = mw32_get_font_request_parameter (Qoverhang, alist); 2172 encoding = mw32_get_font_request_parameter (Qencoding, alist); 2173 relative_compose = mw32_get_font_request_parameter (Qrelative_compose, alist); 2174 default_ascent = mw32_get_font_request_parameter (Qdefault_ascent, alist); 2175 spacing = mw32_get_font_request_parameter (Qspacing, alist); 2176 centering = mw32_get_font_request_parameter (Qcentering, alist); 2177 2178 if (!NILP(width)) CHECK_NUMBER (width, 2); 2179 if (!NILP(height)) CHECK_NUMBER (height, 3); 2180 if (!NILP(base)) CHECK_NUMBER (base, 4); 2181 if (!NILP(overhang)) CHECK_NUMBER (overhang, 5); 2182 if (!NILP(encoding) && (!mw32_valid_encoding_p (encoding))) 2183 error("Encoding:%S is not valid.", encoding); 2184 if (!NILP(relative_compose)) CHECK_NUMBER (relative_compose, 7); 2185 if (!NILP(default_ascent)) CHECK_NUMBER (default_ascent, 8); 2186 if (!NILP(spacing)) CHECK_NUMBER (spacing, 9); 2187 if (!NILP(centering)) CHECK_SYMBOL (centering, 10); 2155 2188 } 2156 2189 … … 2623 2656 staticpro (&Qscalable); 2624 2657 2625 Qencoding_type = intern ("encoding-type"); 2626 staticpro (&Qencoding_type); 2627 Qencoder = intern ("encoder"); 2628 staticpro (&Qencoder); 2658 Qencoding = intern ("encoding"); 2659 staticpro (&Qencoding); 2660 Qfont_unit_byte = intern ("font-unit-byte"); 2661 staticpro (&Qfont_unit_byte); 2662 2663 Q1_byte_set_msb = intern ("1-byte-set-msb"); 2664 staticpro (&Q1_byte_set_msb); 2665 Q2_byte_set_msb = intern ("2-byte-set-msb"); 2666 staticpro (&Q2_byte_set_msb); 2667 Qunicode = intern ("unicode"); 2668 staticpro (&Qunicode); 2669 Qshift_jis = intern ("shift_jis"); 2670 staticpro (&Qshift_jis); 2629 2671 2630 2672 Qrelative_compose = intern ("relative-compose"); … … 2634 2676 Qspacing = intern ("spacing"); 2635 2677 staticpro (&Qspacing); 2636 Qdim = intern ("dim");2637 staticpro (&Qdim);2638 2678 Qcentering = intern ("centering"); 2639 2679 staticpro (&Qcentering); … … 2652 2692 &Vmw32_charset_windows_font_info_alist, 2653 2693 "It holds correspondences between Mule's charset and Windows logfont info.\n\ 2654 Each slot consists of <charset>, <charset-num>, <encoding -type>,\n\2694 Each slot consists of <charset>, <charset-num>, <encoding>,\n\ 2655 2695 and <option-alist>."); 2656 2696 Vmw32_charset_windows_font_info_alist = Qunbound; … … 2659 2699 &Vmw32_windows_font_charset_database, 2660 2700 "Windows font charset database.\n\ 2661 This is 256-length vector.\n\ 2662 Each slot is a 3-length vector that consists of\n\ 2663 <dimension>, <encoding-type>, and <ccl-method>."); 2701 This is a 256-length vector, and each slot must be a nil or <encoding>."); 2664 2702 Vmw32_windows_font_charset_database = Fmake_vector (make_number(256), Qnil); 2665 2703
