Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | merge rfe-6c0d7aec67 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | androwish |
Files: | files | file ages | folders |
SHA1: |
8aa292c255b6c43f60dcd0778bff3808 |
User & Date: | jan.nijtmans 2017-05-19 13:30:20 |
Context
2017-05-23
| ||
13:15 | merge rfe-6c0d7aec67 check-in: 9849b211 user: jan.nijtmans tags: androwish | |
2017-05-19
| ||
13:30 | merge rfe-6c0d7aec67 check-in: 8aa292c2 user: jan.nijtmans tags: androwish | |
13:29 | merge core-8-6-branch check-in: da86391c user: jan.nijtmans tags: rfe-6c0d7aec67 | |
2017-05-18
| ||
13:19 | some upstream androwish changes check-in: 9b2a9573 user: jan.nijtmans tags: androwish | |
Changes
Changes to generic/tkCanvPs.c.
︙ | ︙ | |||
831 832 833 834 835 836 837 | */ Tcl_DStringInit(&ds); points = Tk_PostscriptFontName(tkfont, &ds); fontname = Tcl_DStringValue(&ds); Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp), "/%s findfont %d scalefont%s setfont\n", | | | 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | */ Tcl_DStringInit(&ds); points = Tk_PostscriptFontName(tkfont, &ds); fontname = Tcl_DStringValue(&ds); Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp), "/%s findfont %d scalefont%s setfont\n", fontname, (int)(TkFontGetPoints(psInfoPtr->tkwin, points) + 0.5), strncasecmp(fontname, "Symbol", 7) ? " ISOEncode" : ""); Tcl_CreateHashEntry(&psInfoPtr->fontTable, Tcl_DStringValue(&ds), &i); Tcl_DStringFree(&ds); return TCL_OK; } |
︙ | ︙ |
Changes to generic/tkFont.c.
︙ | ︙ | |||
1297 1298 1299 1300 1301 1302 1303 | /* * Get information used for drawing underlines in generic code on a * non-underlined font. */ descent = fontPtr->fm.descent; fontPtr->underlinePos = descent / 2; | | | 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 | /* * Get information used for drawing underlines in generic code on a * non-underlined font. */ descent = fontPtr->fm.descent; fontPtr->underlinePos = descent / 2; fontPtr->underlineHeight = (int) (TkFontGetPixels(tkwin, fontPtr->fa.size) / 10 + 0.5); if (fontPtr->underlineHeight == 0) { fontPtr->underlineHeight = 1; } if (fontPtr->underlinePos + fontPtr->underlineHeight > descent) { /* * If this set of values would cause the bottom of the underline bar * to stick below the descent of the font, jack the underline up a bit |
︙ | ︙ | |||
1869 1870 1871 1872 1873 1874 1875 | Tcl_DStringAppend(dsPtr, weightString, -1); } if (slantString != NULL) { Tcl_DStringAppend(dsPtr, slantString, -1); } } | | | 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 | Tcl_DStringAppend(dsPtr, weightString, -1); } if (slantString != NULL) { Tcl_DStringAppend(dsPtr, slantString, -1); } } return (int)(fontPtr->fa.size + 0.5); } /* *--------------------------------------------------------------------------- * * Tk_TextWidth -- * |
︙ | ︙ | |||
3478 3479 3480 3481 3482 3483 3484 | value = Tcl_GetString(valuePtr); faPtr->family = Tk_GetUid(value); break; case FONT_SIZE: if (Tcl_GetIntFromObj(interp, valuePtr, &n) != TCL_OK) { return TCL_ERROR; } | | | 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 | value = Tcl_GetString(valuePtr); faPtr->family = Tk_GetUid(value); break; case FONT_SIZE: if (Tcl_GetIntFromObj(interp, valuePtr, &n) != TCL_OK) { return TCL_ERROR; } faPtr->size = (double)n; break; case FONT_WEIGHT: n = TkFindStateNumObj(interp, optionPtr, weightMap, valuePtr); if (n == TK_FW_UNKNOWN) { return TCL_ERROR; } faPtr->weight = n; |
︙ | ︙ | |||
3569 3570 3571 3572 3573 3574 3575 | switch (i) { case FONT_FAMILY: str = faPtr->family; valuePtr = Tcl_NewStringObj(str, ((str == NULL) ? 0 : -1)); break; case FONT_SIZE: | > | > > > | 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 | switch (i) { case FONT_FAMILY: str = faPtr->family; valuePtr = Tcl_NewStringObj(str, ((str == NULL) ? 0 : -1)); break; case FONT_SIZE: if (faPtr->size >= 0.0) { valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5)); } else { valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5)); } break; case FONT_WEIGHT: str = TkFindStateString(weightMap, faPtr->weight); valuePtr = Tcl_NewStringObj(str, -1); break; |
︙ | ︙ | |||
3718 3719 3720 3721 3722 3723 3724 | } faPtr->family = Tk_GetUid(Tcl_GetString(objv[0])); if (objc > 1) { if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) { return TCL_ERROR; } | | | 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 | } faPtr->family = Tk_GetUid(Tcl_GetString(objv[0])); if (objc > 1) { if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) { return TCL_ERROR; } faPtr->size = (double)n; } i = 2; if (objc == 3) { if (Tcl_ListObjGetElements(interp, objv[2], &objc, &objv) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
3962 3963 3964 3965 3966 3967 3968 | /* XLFD_ADD_STYLE ignored. */ /* * Pointsize in tenths of a point, but treat it as tenths of a pixel for * historical compatibility. */ | | | | | | 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 | /* XLFD_ADD_STYLE ignored. */ /* * Pointsize in tenths of a point, but treat it as tenths of a pixel for * historical compatibility. */ faPtr->size = 12.0; if (FieldSpecified(field[XLFD_POINT_SIZE])) { if (field[XLFD_POINT_SIZE][0] == '[') { /* * Some X fonts have the point size specified as follows: * * [ N1 N2 N3 N4 ] * * where N1 is the point size (in points, not decipoints!), and * N2, N3, and N4 are some additional numbers that I don't know * the purpose of, so I ignore them. */ faPtr->size = atof(field[XLFD_POINT_SIZE] + 1); } else if (Tcl_GetInt(NULL, field[XLFD_POINT_SIZE], &i) == TCL_OK) { faPtr->size = i/10.0; } else { return TCL_ERROR; } } /* * Pixel height of font. If specified, overrides pointsize. |
︙ | ︙ | |||
4001 4002 4003 4004 4005 4006 4007 | * [ N1 N2 N3 N4 ] * * where N1 is the pixel size, and where N2, N3, and N4 are some * additional numbers that I don't know the purpose of, so I * ignore them. */ | | | > | 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 | * [ N1 N2 N3 N4 ] * * where N1 is the pixel size, and where N2, N3, and N4 are some * additional numbers that I don't know the purpose of, so I * ignore them. */ faPtr->size = atof(field[XLFD_PIXEL_SIZE] + 1); } else if (Tcl_GetInt(NULL, field[XLFD_PIXEL_SIZE], &i) != TCL_OK) { faPtr->size = (double)i; return TCL_ERROR; } } faPtr->size = -faPtr->size; /* XLFD_RESOLUTION_X ignored. */ |
︙ | ︙ | |||
4079 4080 4081 4082 4083 4084 4085 | * * Side effects: * None. * *--------------------------------------------------------------------------- */ | < > | | | < > | | | | 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 | * * Side effects: * None. * *--------------------------------------------------------------------------- */ double TkFontGetPixels( Tk_Window tkwin, /* For point->pixel conversion factor. */ double size) /* Font size. */ { double d; int widthM, widthS; #ifdef PLATFORM_SDL double d2; int heightM, heightS; #endif if (size <= 0.0) { return -size; } #ifdef PLATFORM_SDL heightS = HeightOfScreen(Tk_Screen(tkwin)); heightM = HeightMMOfScreen(Tk_Screen(tkwin)); d2 = size * 25.4 / 72.0; d2 *= heightS; d2 /= heightM; #endif widthS = WidthOfScreen(Tk_Screen(tkwin)); widthM = WidthMMOfScreen(Tk_Screen(tkwin)); d = size * 25.4 / 72.0; d *= widthS; d /= widthM; #ifdef PLATFORM_SDL if (d2 > d) { d = d2; } #endif return d; } /* *--------------------------------------------------------------------------- * * TkFontGetPoints -- * * Given a font size specification (as described in the TkFontAttributes * structure) return the number of points it represents. * * Results: * As above. * * Side effects: * None. * *--------------------------------------------------------------------------- */ double TkFontGetPoints( Tk_Window tkwin, /* For pixel->point conversion factor. */ double size) /* Font size. */ { double d; int widthM, widthS; #ifdef PLATFORM_SDL double d2; int heightM, heightS; #endif if (size >= 0.0) { return size; } #ifdef PLATFORM_SDL heightS = HeightOfScreen(Tk_Screen(tkwin)); heightM = HeightMMOfScreen(Tk_Screen(tkwin)); d2 = -size * 72.0 / 25.4; d2 *= heightM; d2 /= heightS; #endif widthS = WidthOfScreen(Tk_Screen(tkwin)); widthM = WidthMMOfScreen(Tk_Screen(tkwin)); d = -size * 72.0 / 25.4; d *= widthM; d /= widthS; #ifdef PLATFORM_SDL if (d2 < d) { d = d2; } #endif return d; } /* *------------------------------------------------------------------------- * * TkFontGetAliasList -- * |
︙ | ︙ |
Changes to generic/tkFont.h.
︙ | ︙ | |||
19 20 21 22 23 24 25 | * used to keep track of either the desired attributes or the actual * attributes gotten when the font was instantiated. */ struct TkFontAttributes { Tk_Uid family; /* Font family, or NULL to represent plaform- * specific default system font. */ | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | * used to keep track of either the desired attributes or the actual * attributes gotten when the font was instantiated. */ struct TkFontAttributes { Tk_Uid family; /* Font family, or NULL to represent plaform- * specific default system font. */ double size; /* Pointsize of font, 0.0 for default size, or * negative number meaning pixel size. */ int weight; /* Weight flag; see below for def'n. */ int slant; /* Slant flag; see below for def'n. */ int underline; /* Non-zero for underline font. */ int overstrike; /* Non-zero for overstrike font. */ }; |
︙ | ︙ | |||
194 195 196 197 198 199 200 | #define TkInitFontAttributes(fa) memset((fa), 0, sizeof(TkFontAttributes)); #define TkInitXLFDAttributes(xa) memset((xa), 0, sizeof(TkXLFDAttributes)); MODULE_SCOPE int TkFontParseXLFD(const char *string, TkFontAttributes *faPtr, TkXLFDAttributes *xaPtr); MODULE_SCOPE const char *const * TkFontGetAliasList(const char *faceName); MODULE_SCOPE const char *const *const * TkFontGetFallbacks(void); | | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | #define TkInitFontAttributes(fa) memset((fa), 0, sizeof(TkFontAttributes)); #define TkInitXLFDAttributes(xa) memset((xa), 0, sizeof(TkXLFDAttributes)); MODULE_SCOPE int TkFontParseXLFD(const char *string, TkFontAttributes *faPtr, TkXLFDAttributes *xaPtr); MODULE_SCOPE const char *const * TkFontGetAliasList(const char *faceName); MODULE_SCOPE const char *const *const * TkFontGetFallbacks(void); MODULE_SCOPE double TkFontGetPixels(Tk_Window tkwin, double size); MODULE_SCOPE double TkFontGetPoints(Tk_Window tkwin, double size); MODULE_SCOPE const char *const * TkFontGetGlobalClass(void); MODULE_SCOPE const char *const * TkFontGetSymbolClass(void); MODULE_SCOPE int TkCreateNamedFont(Tcl_Interp *interp, Tk_Window tkwin, const char *name, TkFontAttributes *faPtr); MODULE_SCOPE int TkDeleteNamedFont(Tcl_Interp *interp, Tk_Window tkwin, const char *name); MODULE_SCOPE int TkFontGetFirstTextLayout(Tk_TextLayout layout, |
︙ | ︙ |
Changes to generic/tkUtil.c.
︙ | ︙ | |||
1216 1217 1218 1219 1220 1221 1222 | int TkUtfToUniChar( const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Tcl_UniChar represented by * the UTF-8 string. */ { Tcl_UniChar uniChar = 0; | < > | > | 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | int TkUtfToUniChar( const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Tcl_UniChar represented by * the UTF-8 string. */ { Tcl_UniChar uniChar = 0; int len = Tcl_UtfToUniChar(src, &uniChar); if ((uniChar & 0xfc00) == 0xd800) { int high = uniChar; /* This can only happen if Tcl is compiled with TCL_UTF_MAX=4, * or when a high surrogate character is detected in UTF-8 form */ int len2 = Tcl_UtfToUniChar(src+len, &uniChar); if ((uniChar & 0xfc00) == 0xdc00) { *chPtr = (((high & 0x3ff) << 10) | (uniChar & 0x3ff)) + 0x10000; len += len2; } else { *chPtr = high; } } else { |
︙ | ︙ | |||
1253 1254 1255 1256 1257 1258 1259 | * * Side effects: * None. * *--------------------------------------------------------------------------- */ | > | > > | 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 | * * Side effects: * None. * *--------------------------------------------------------------------------- */ int TkUniCharToUtf( int ch, char *buf) { int size = Tcl_UniCharToUtf(ch, buf); if ((ch > 0xffff) && (ch <= 0x10ffff) && (size < 4)) { /* Hey, this is wrong, we must be running TCL_UTF_MAX==3 * The best thing we can do is spit out 2 surrogates */ ch -= 0x10000; size = Tcl_UniCharToUtf(((ch >> 10) | 0xd800), buf); |
︙ | ︙ | |||
1275 1276 1277 1278 1279 1280 1281 | * * TkUtfCharComplete -- * * Almost the same as Tcl_UtfCharComplete but check for surrogates if * TCL_UTF_MAX==3. So, up to 6 bytes might be required. * * Results: | | > > | > > | 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 | * * TkUtfCharComplete -- * * Almost the same as Tcl_UtfCharComplete but check for surrogates if * TCL_UTF_MAX==3. So, up to 6 bytes might be required. * * Results: * Return true if there are enough bytes in the buffer to form either * a single unicode character or a high/low surrogate pair. * * Side effects: * None. * *--------------------------------------------------------------------------- */ int TkUtfCharComplete( const char *source, int numBytes) { if (Tcl_UtfCharComplete(source, numBytes) == 0) { return 0; } /* There are enough bytes for a high surrogate. If the first * 3 bytes form a high surrogate, this function should check * whether there are enough bytes for a low surrogate too. */ if (((source[0]&0xFF) == 0xED) && ((source[1]&0xF0) == 0xA0) |
︙ | ︙ | |||
1307 1308 1309 1310 1311 1312 1313 | * * TkUtfPrev -- * * Almost the same as Tcl_UtfPrev but check for surrogates if * TCL_UTF_MAX==3. So, the pointer might move up to 6 bytes. * * Results: | | | > > > > > > | | > > > > > | 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 | * * TkUtfPrev -- * * Almost the same as Tcl_UtfPrev but check for surrogates if * TCL_UTF_MAX==3. So, the pointer might move up to 6 bytes. * * Results: * Return a pointer to the previous unicode character. * * Side effects: * None. * *--------------------------------------------------------------------------- */ const char * TkUtfPrev( const char *start, const char *source) { const char *p = Tcl_UtfPrev(start, source); if (((source[0]&0xFF) == 0xED) && ((source[1]&0xF0) == 0xB0) && ((source[2]&0xC0) == 0x80)) { /* We are pointing to a low surrogate. If the previous * codepoint is a high surrogate, we want that in stead. */ const char *q = Tcl_UtfPrev(start, p); if (((q[0]&0xFF) == 0xED) && ((q[1]&0xF0) == 0xA0) && ((q[2]&0xC0) == 0x80)) { p = q; } } return p; } /* *--------------------------------------------------------------------------- * * TkUtfNext -- * * Almost the same as Tcl_UtfNext but check for surrogates if * TCL_UTF_MAX==3. So, the pointer might move up to 6 bytes. * * Results: * Return a pointer to the next unicode character. * * Side effects: * None. * *--------------------------------------------------------------------------- */ const char * TkUtfNext( const char *source) { const char *p = Tcl_UtfNext(source); if (((source[0]&0xFF) == 0xED) && ((source[1]&0xF0) == 0xA0) && ((source[2]&0xC0) == 0x80)) { const char *q = Tcl_UtfNext(p); /* We are pointing to a high surrogate. If the next * codepoint is a low surrogate, we want that in stead. */ if (((q[0]&0xFF) == 0xED) && ((q[1]&0xF0) == 0xB0) && ((q[2]&0xC0) == 0x80)) { p = q; } } |
︙ | ︙ |
Changes to macosx/tkMacOSXFont.c.
︙ | ︙ | |||
511 512 513 514 515 516 517 | * will be released. If NULL, a new TkFont * structure is allocated. */ Tk_Window tkwin, /* For display where font will be used. */ const TkFontAttributes *faPtr) /* Set of attributes to match. */ { MacFont *fontPtr; | | | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | * will be released. If NULL, a new TkFont * structure is allocated. */ Tk_Window tkwin, /* For display where font will be used. */ const TkFontAttributes *faPtr) /* Set of attributes to match. */ { MacFont *fontPtr; int points = (int)(TkFontGetPoints(tkwin, faPtr->size) + 0.5); NSFontTraitMask traits = GetNSFontTraitsFromTkFontAttributes(faPtr); NSInteger weight = (faPtr->weight == TK_FW_BOLD ? 9 : 5); NSFont *nsFont; nsFont = FindNSFont(faPtr->family, traits, weight, points, 0); if (!nsFont) { const char *const *aliases = TkFontGetAliasList(faPtr->family); |
︙ | ︙ |
Changes to unix/tkUnixFont.c.
︙ | ︙ | |||
1527 1528 1529 1530 1531 1532 1533 | int scalable; unsigned score; if (TkFontParseXLFD(nameList[nameIdx], &got.fa, &got.xa) != TCL_OK) { continue; } IdentifySymbolEncodings(&got); | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | int scalable; unsigned score; if (TkFontParseXLFD(nameList[nameIdx], &got.fa, &got.xa) != TCL_OK) { continue; } IdentifySymbolEncodings(&got); scalable = (got.fa.size == 0.0); score = RankAttributes(&want, &got); if (score < bestScore[scalable]) { bestIdx[scalable] = nameIdx; bestScore[scalable] = score; } if (score == 0) { break; |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | fmPtr = &fontPtr->font.fm; fmPtr->ascent = fontStructPtr->ascent; fmPtr->descent = fontStructPtr->descent; fmPtr->maxWidth = fontStructPtr->max_bounds.width; fmPtr->fixed = fixed; fontPtr->display = display; | | | 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 | fmPtr = &fontPtr->font.fm; fmPtr->ascent = fontStructPtr->ascent; fmPtr->descent = fontStructPtr->descent; fmPtr->maxWidth = fontStructPtr->max_bounds.width; fmPtr->fixed = fixed; fontPtr->display = display; fontPtr->pixelSize = (int)(TkFontGetPixels(tkwin, fa.fa.size) + 0.5); fontPtr->xa = fa.xa; fontPtr->numSubFonts = 1; fontPtr->subFontArray = fontPtr->staticSubFonts; InitSubFont(display, fontStructPtr, 1, &fontPtr->subFontArray[0]); fontPtr->controlSubFont = fontPtr->subFontArray[0]; |
︙ | ︙ | |||
2445 2446 2447 2448 2449 2450 2451 | srcLen = Tcl_UniCharToUtf(ch, src); want.fa = fontPtr->font.fa; want.xa = fontPtr->xa; want.fa.family = Tk_GetUid(faceName); | | | 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 | srcLen = Tcl_UniCharToUtf(ch, src); want.fa = fontPtr->font.fa; want.xa = fontPtr->xa; want.fa.family = Tk_GetUid(faceName); want.fa.size = (double)-fontPtr->pixelSize; hateFoundry = NULL; hateCharset = NULL; numEncodings = 0; Tcl_DStringInit(&dsEncodings); charset = NULL; /* lint, since numNames must be > 0 to get here. */ |
︙ | ︙ | |||
2528 2529 2530 2531 2532 2533 2534 | goto crossout; } /* * D. Rank each name and pick the best match. */ | | | 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 | goto crossout; } /* * D. Rank each name and pick the best match. */ scalable = (got.fa.size == 0.0); score = RankAttributes(&want, &got); if (score < bestScore[scalable]) { bestIdx[scalable] = nameIdx; bestScore[scalable] = score; } if (score == 0) { break; |
︙ | ︙ | |||
2657 2658 2659 2660 2661 2662 2663 | if (gotPtr->xa.slant != wantPtr->xa.slant) { penalty += 10; } if (gotPtr->xa.setwidth != wantPtr->xa.setwidth) { penalty += 1000; } | | | | | 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 | if (gotPtr->xa.slant != wantPtr->xa.slant) { penalty += 10; } if (gotPtr->xa.setwidth != wantPtr->xa.setwidth) { penalty += 1000; } if (gotPtr->fa.size == 0.0) { /* * A scalable font is almost always acceptable, but the corresponding * bitmapped font would be better. */ penalty += 10; } else { int diff; /* * It's worse to be too large than to be too small. */ diff = (int) (150 * (-gotPtr->fa.size - -wantPtr->fa.size)); if (diff > 0) { penalty += 600; } else if (diff < 0) { penalty += 150; diff = -diff; } penalty += diff; } if (gotPtr->xa.charset != wantPtr->xa.charset) { int i; const char *gotAlias, *wantAlias; penalty += 65000; gotAlias = GetEncodingAlias(gotPtr->xa.charset); |
︙ | ︙ | |||
2765 2766 2767 2768 2769 2770 2771 | } rest = str; for (i = XLFD_PIXEL_SIZE; i < XLFD_CHARSET; i++) { rest = strchr(rest + 1, '-'); } *str = '\0'; sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]], | | | 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 | } rest = str; for (i = XLFD_PIXEL_SIZE; i < XLFD_CHARSET; i++) { rest = strchr(rest + 1, '-'); } *str = '\0'; sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]], (int)(-wantPtr->fa.size+0.5), rest); *str = '-'; fontStructPtr = XLoadQueryFont(display, buf); bestScore[1] = INT_MAX; } if (fontStructPtr == NULL) { fontStructPtr = XLoadQueryFont(display, nameList[bestIdx[0]]); if (fontStructPtr == NULL) { |
︙ | ︙ |
Changes to unix/tkUnixRFont.c.
︙ | ︙ | |||
166 167 168 169 170 171 172 | static void GetTkFontAttributes( XftFont *ftFont, TkFontAttributes *faPtr) { const char *family = "Unknown"; const char *const *familyPtr = &family; | | | | > > > | | | | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | static void GetTkFontAttributes( XftFont *ftFont, TkFontAttributes *faPtr) { const char *family = "Unknown"; const char *const *familyPtr = &family; int weight, slant, pxsize; double size, ptsize; (void) XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr); if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0, &ptsize) == XftResultMatch) { size = ptsize; } else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0, &ptsize) == XftResultMatch) { size = -ptsize; } else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0, &pxsize) == XftResultMatch) { size = (double)-pxsize; } else { size = 12.0; } if (XftPatternGetInteger(ftFont->pattern, XFT_WEIGHT, 0, &weight) != XftResultMatch) { weight = XFT_WEIGHT_MEDIUM; } if (XftPatternGetInteger(ftFont->pattern, XFT_SLANT, 0, &slant) != XftResultMatch) { slant = XFT_SLANT_ROMAN; } #if DEBUG_FONTSEL printf("family %s size %d weight %d slant %d\n", family, (int)size, weight, slant); #endif /* DEBUG_FONTSEL */ faPtr->family = Tk_GetUid(family); faPtr->size = size; faPtr->weight = (weight > XFT_WEIGHT_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = (slant > XFT_SLANT_ROMAN) ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = 0; |
︙ | ︙ | |||
437 438 439 440 441 442 443 | printf("TkpGetFontFromAttributes %s-%d %d %d\n", faPtr->family, faPtr->size, faPtr->weight, faPtr->slant); #endif /* DEBUG_FONTSEL */ pattern = XftPatternCreate(); if (faPtr->family) { XftPatternAddString(pattern, XFT_FAMILY, faPtr->family); } | | | | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | printf("TkpGetFontFromAttributes %s-%d %d %d\n", faPtr->family, faPtr->size, faPtr->weight, faPtr->slant); #endif /* DEBUG_FONTSEL */ pattern = XftPatternCreate(); if (faPtr->family) { XftPatternAddString(pattern, XFT_FAMILY, faPtr->family); } if (faPtr->size > 0.0) { XftPatternAddDouble(pattern, XFT_SIZE, faPtr->size); } else if (faPtr->size < 0.0) { XftPatternAddDouble(pattern, XFT_PIXEL_SIZE, -faPtr->size); } else { XftPatternAddDouble(pattern, XFT_SIZE, 12.0); } switch (faPtr->weight) { case TK_FW_NORMAL: default: weight = XFT_WEIGHT_MEDIUM; |
︙ | ︙ | |||
661 662 663 664 665 666 667 | char string[256]; int len = 0; #endif /* DEBUG_FONTSEL */ curX = 0; curByte = 0; sawNonSpace = 0; | | | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | char string[256]; int len = 0; #endif /* DEBUG_FONTSEL */ curX = 0; curByte = 0; sawNonSpace = 0; while (numBytes > 0 && TkUtfCharComplete(source, numBytes)) { Tcl_UniChar unichar; clen = Tcl_UtfToUniChar(source, &unichar); c = (FcChar32) unichar; source += clen; numBytes -= clen; if (c < 256 && isspace(c)) { /* I18N: ??? */ |
︙ | ︙ |
Changes to win/tkWinDialog.c.
︙ | ︙ | |||
3508 3509 3510 3511 3512 3513 3514 | fontPtr = (TkFont *) f; cf.Flags |= CF_INITTOLOGFONTSTRUCT; Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds); _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1); Tcl_DStringFree(&ds); lf.lfFaceName[LF_FACESIZE-1] = 0; | | | 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 | fontPtr = (TkFont *) f; cf.Flags |= CF_INITTOLOGFONTSTRUCT; Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds); _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1); Tcl_DStringFree(&ds); lf.lfFaceName[LF_FACESIZE-1] = 0; lf.lfHeight = -MulDiv((int)(TkFontGetPoints(tkwin, fontPtr->fa.size) + 0.5), GetDeviceCaps(hdc, LOGPIXELSY), 72); if (fontPtr->fa.weight == TK_FW_BOLD) { lf.lfWeight = FW_BOLD; } if (fontPtr->fa.slant != TK_FS_ROMAN) { lf.lfItalic = TRUE; } |
︙ | ︙ |
Changes to win/tkWinFont.c.
︙ | ︙ | |||
562 563 564 565 566 567 568 | } } found: ReleaseDC(hwnd, hdc); hFont = GetScreenFont(faPtr, faceName, | | | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | } } found: ReleaseDC(hwnd, hdc); hFont = GetScreenFont(faPtr, faceName, (int)(TkFontGetPixels(tkwin, faPtr->size) + 0.5), 0.0); if (tkFontPtr == NULL) { fontPtr = ckalloc(sizeof(WinFont)); } else { fontPtr = (WinFont *) tkFontPtr; ReleaseFont(fontPtr); } InitFont(tkwin, hFont, faPtr->overstrike, fontPtr); |
︙ | ︙ | |||
763 764 765 766 767 768 769 | oldfont = SelectObject(hdc, thisSubFontPtr->hFont0); GetTextMetrics(hdc, &tm); SelectObject(hdc, oldfont); ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; faPtr->size = TkFontGetPoints(tkwin, | | | 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | oldfont = SelectObject(hdc, thisSubFontPtr->hFont0); GetTextMetrics(hdc, &tm); SelectObject(hdc, oldfont); ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; faPtr->size = TkFontGetPoints(tkwin, (double)(tm.tmInternalLeading - tm.tmHeight)); faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = tm.tmItalic ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = (tm.tmUnderlined != 0); faPtr->overstrike = fontPtr->font.fa.overstrike; } /* |
︙ | ︙ | |||
1600 1601 1602 1603 1604 1605 1606 | fontPtr->hwnd = hwnd; fontPtr->pixelSize = tm.tmHeight - tm.tmInternalLeading; faPtr = &fontPtr->font.fa; faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString)); faPtr->size = | | | 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 | fontPtr->hwnd = hwnd; fontPtr->pixelSize = tm.tmHeight - tm.tmInternalLeading; faPtr = &fontPtr->font.fa; faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString)); faPtr->size = TkFontGetPoints(tkwin, (double)-(fontPtr->pixelSize)); faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = (tm.tmItalic != 0) ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = (tm.tmUnderlined != 0) ? 1 : 0; faPtr->overstrike = overstrike; fmPtr = &fontPtr->font.fm; |
︙ | ︙ |