{"id":10478,"date":"2022-07-21T22:59:11","date_gmt":"2022-07-21T14:59:11","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10478"},"modified":"2022-07-21T22:59:54","modified_gmt":"2022-07-21T14:59:54","slug":"css-font-palette","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2022\/07\/css-font-palette\/","title":{"rendered":"\u8d85\u9177\uff01CSS font-palette\u4e0e\u5f69\u8272\u5b57\u4f53\u663e\u793a"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10478\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10478<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202207-font-palette.png';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/color-font-cover.png\" width=\"480\" height=\"309\" alt=\"\u5c01\u9762\u56fe\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u4e86\u89e3\u5f69\u8272\u5b57\u4f53<\/h3>\n<p>\u6240\u8c13\u5f69\u8272\u5b57\u4f53\uff0c\u6307\u7684\u662f\u90a3\u4e9b\u5185\u90e8\u81ea\u5e26\u5f69\u8272\u5b57\u5f62\u7684\u5b57\u4f53\uff0c\u4f8b\u5982 <a href=\"https:\/\/fonts.adobe.com\/fonts\/gilbert\" target=\"_adobe\" rel=\"nofollow noopener\">Adobe \u51fa\u54c1\u7684 Gilbert \u5b57\u4f53\u3002<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202003\/emoji-colorful-6.png\" width=\"627\" height=\"119\" alt=\"\u5f69\u8272\u5b57\u4f53\u6587\u5b57\" class=\"alignnone size-medium\"><\/p>\n<p>\u6211\u731c\u6709\u4e9b\u4eba\u53ef\u80fd\u4f1a\u6709\u8fd9\u6837\u7684\u60f3\u6cd5\uff1a\u5594\u5662\uff0c\u597d\u9177\u597d\u5389\u5bb3\uff0c\u6d4f\u89c8\u5668\u4ec0\u4e48\u65f6\u5019\u652f\u6301\u554a\uff1f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_140339.png\" width=\"180\" height=\"134\" alt=\"\u773c\u775b\u653e\u5149\u8868\u60c5\u5305\"><\/p>\n<p>\u7ed3\u679c\u4e00\u5b9a\u8ba9\u5927\u5bb6\u5927\u5403\u4e00\u60ca\uff01<\/p>\n<p>\u5f69\u8272\u5b57\u4f53\u5b9e\u9645\u4e0a\u6d4f\u89c8\u5668\u5f88\u65e9\u5c31\u652f\u6301\u4e86\uff0c\u5982\u679c\u5f53\u524d\u5b57\u4f53\u91c7\u7528\u7684\u662f COLR\/CPAL(v0) \u6807\u51c6\u5236\u4f5c\u7684\uff0c\u5219\u5305\u62ec IE9\uff08\u9700\u8981 Windows 8.1+\uff09 \u5728\u5185\u7684\u6d4f\u89c8\u5668\u5747\u662f\u652f\u6301\u7684\u3002<\/p>\n<p>\u5176<a href=\"https:\/\/caniuse.com\/colr\" target=\"_caniuse\">\u517c\u5bb9\u6027<\/a>\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_112057.png\" width=\"657\" height=\"384\" alt=\"COLR\/CPAL(v0)\u5b57\u4f53\u683c\u5f0f\u7684\u517c\u5bb9\u6027\"><\/p>\n<p>\u76ee\u524d\u5f69\u8272\u5b57\u4f53\u7684\u6807\u51c6\u6709\u56db\u4e2a\uff0cCOLR\/CPAL\u6807\u51c6\u662f\u5176\u4e2d\u4e4b\u4e00\uff0c\u5404\u4e2a\u6807\u51c6\u548c\u517c\u5bb9\u6027\u89c1\u4e0b\u8868\uff08\u6e90\u81ea\u6211\u4e24\u5e74\u524d\u5c31\u7814\u7a76\u5e76\u4ecb\u7ecd\u8fc7\u7684\u6587\u7ae0 &#8211; \u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2020\/03\/css-emoji-opentype-svg-fonts\/\">\u5173\u4e8eCSS emoji\u5b57\u4f53\u548cOpenType-SVG\u6211\u6240\u77e5\u9053\u7684\u4e00\u4e9b\u4e8b<\/a>\u201d\uff09\uff1a<\/p>\n<table style=\"text-align: center;\" class=\"params_table\">\n<tbody>\n<tr>\n<td><\/td>\n<th scope=\"col\">Chrome<\/th>\n<th scope=\"col\">Safari<\/th>\n<th scope=\"col\">Edge<\/th>\n<th scope=\"col\">Firefox<\/th>\n<\/tr>\n<tr>\n<th scope=\"row\">SVG-in-Opentype<\/th>\n<td>\u274c<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<th scope=\"row\">COLR\/CPAL<\/th>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<th scope=\"row\">SBIX<\/th>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<\/tr>\n<tr>\n<th scope=\"row\">CBDT\/CBLC<\/th>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5176\u4e2d\uff0c\u867d\u7136\u6709\u5f88\u591a\u5b57\u4f53\u91c7\u7528SVG-in-Opentype\u8fd9\u4e2a\u6807\u51c6\uff0c\u4f46\u662f Chrome \u660e\u786e\u5c06\u5176\u4ed6\u4eba\u63d0\u4ea4\u7684\u201c\u652f\u6301 SVG Opentype bug\u201d<a href=\"https:\/\/bugs.chromium.org\/p\/chromium\/issues\/detail?id=306078#c62\" target=\"_blank\" rel=\"nofollow noopener\">\u6807\u8bb0\u4e3a\u201c\u4e0d\u4f1a\u4fee\u590d\u201d<\/a>\uff0c\u56e0\u6b64\u53ef\u4ee5\u9884\u671f\uff0c\u518d\u5f88\u957f\u4e00\u6bb5\u65f6\u95f4\uff0c\u751a\u81f3\u662f\u6c38\u8fdc\uff0cChrome \u5e76\u4e0d\u4f1a\u652f\u6301SVG-in-Opentype\u6807\u51c6\u3002<\/p>\n<p>\u800c\u81f3\u4e8eSBIX \u548c CBDT\/CBLC \u6807\u51c6\u867d\u7136 Chrome \u6d4f\u89c8\u5668\u652f\u6301\uff0c\u4f46\u662f\u6b64\u6807\u51c6\u4e0b\u5b9e\u73b0\u7684\u5b57\u4f53\u4f53\u79ef\u592a\u5927\u4e86\uff0c\u4e0d\u592a\u9002\u5408\u7528\u5728 Web \u4e2d\uff0c\u56e0\u6b64\uff0c\u51e0\u4e4e\u53ef\u4ee5\u786e\u8ba4\uff0c\u672a\u6765\u5728 Web \u9886\u57df\uff0c\u8131\u9896\u800c\u51fa\u7684\u6807\u51c6\u4e00\u5b9a\u662f COLR\/CPAL \u6807\u51c6\u3002<\/p>\n<h4>COLR\/CPAL(v1) \u6807\u51c6<\/h4>\n<p>\u76ee\u524d\u7684 COLR \u6807\u51c6\u5df2\u7ecf\u662f v1 \u7248\u672c\uff0c\u5c5e\u4e8e <a href=\"https:\/\/docs.microsoft.com\/en-us\/typography\/opentype\/spec\/\" target=\"_blank\" rel=\"nofollow noopener\">OpenType 1.9 \u6807\u51c6<\/a>\u7684\u4e00\u90e8\u5206\u3002<\/p>\n<p>\u76f8\u6bd4 v0 \u7248\u672c\uff0cv1 \u7248\u672c\u8981\u5f3a\u5927\u7684\u591a\uff0c\u4e0d\u4ec5\u652f\u6301\u7eaf\u8272\uff0c\u8fd8\u652f\u6301\u5404\u79cd\u6e10\u53d8\uff08\u7ebf\u6027\u3001\u5f84\u5411\u548c\u9525\u5f62\uff09\uff0c\u751a\u81f3\u652f\u6301\u6df7\u5408\u6a21\u5f0f\u3002<\/p>\n<p>\u4e0b\u9762\u7684\u89c6\u9891\u5c31\u662f\u540d\u4e3a <a href=\"https:\/\/underware.nl\/fonts\/plakato\/features\/color\/#feature_info\" target=\"_blank\" rel=\"nofollow noopener\">Plakato Color \u7684\u6e10\u53d8\u5b57\u4f53<\/a>\u8bbe\u7f6e\u8272\u5f69\u53d8\u5316\u7684\u6548\u679c\u5f55\u5236\uff08\u4e0d\u52a8\u70b9\u51fb\u64ad\u653e\uff09\uff1a<\/p>\n<p><video src='\/\/image.zhangxinxu.com\/video\/blog\/202207\/plakato-color.mp4' type=\"video\/mp4\" width=\"666\" height=\"462\" preload=\"auto\" muted autoplay autobuffer loop x-webkit-airplay=\"allow\" x5-video-player-type=\"h5\" x5-video-player-fullscreen=\"true\" x5-video-orientation=\"portraint\" webkit-playsinline=\"true\" playsinline=\"true\" \u200b\u200b\u200b\u200bposter=\"\/\/image.zhangxinxu.com\/image\/blog\/201806\/poster.png\"><\/video><\/p>\n<p>\u540c\u65f6\uff0c\u76f8\u6bd4 OpenType-SVG \u683c\u5f0f\u8981\u66f4\u7b80\u5355\u66f4\u9ad8\u6548\uff0c\u56e0\u4e3a\u662f\u6309\u7167\u56fe\u5c42\u7ed8\u5236\u7684\u3002<\/p>\n<p>\u8fd9\u4e48\u8bf4\u5427\uff0cCOLR\/CPAL(v0) \u548c OpenType-SVG \u76f8\u6bd4\u5c31\u662f\u4e2a\u5f1f\u5f1f\uff0c\u4f46\u662f COLR\/CPAL(v1) \u548c OpenType-SVG \u76f8\u6bd4\u5c31\u8981\u5f3a\u4e00\u4e2a\u5934\u3002<\/p>\n<p>OpenType-SVG \u591a\u534a\u8981\u9010\u6e10\u5728 Web \u4e2d\u843d\u5bde\u4e86\u3002<\/p>\n<h3>\u4e8c\u3001font-palette \u4e0e\u5b57\u4f53\u989c\u8272<\/h3>\n<p>\u597d\uff0c\u5173\u4e8e\u5f69\u8272\u5b57\u4f53\u7684\u57fa\u7840\u77e5\u8bc6\u4ecb\u7ecd\u5b8c\u4e86\uff0c\u4e0b\u9762\u53ef\u4ee5\u8bb2\u8bb2\u672c\u6587\u7684\u91cd\u70b9\uff0c\u4e5f\u5c31\u662f\u5f69\u8272\u5b57\u4f53\u7684\u8fd9\u4e2a\u201c\u5f69\u8272\u201d\u7684\u989c\u8272\u63a7\u5236\u4e86\u3002<\/p>\n<p>\u5728\u8fc7\u53bb\uff0c\u65e0\u8bba\u662f\u666e\u901a\u5b57\u4f53\u8fd8\u662f\u5f69\u8272\u5b57\u4f53\uff0c\u5982\u679c\u60f3\u8981\u8868\u73b0\u51fa\u4e0d\u4e00\u6837\u7684\u989c\u8272\u6216\u8005\u7eb9\u7406\uff0c\u5f80\u5f80\u9700\u8981\u4f7f\u7528 <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2017\/11\/css-css3-mask-masks\/\">mask \u906e\u7f69<\/a>\uff0c\u6216\u8005 <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=1601\">background-clip:text \u65b9\u6cd5<\/a> \u8fdb\u884c\u6a21\u62df\uff0c\u6216\u8005\u4f7f\u7528 <code>filter<\/code> \u6ee4\u955c\u6216\u8005 <code>mix-blend-mode<\/code> \u6df7\u5408\u6a21\u5f0f\uff08\u8fd9\u4e24\u4e2a\u5c5e\u6027\u5b66\u4e60\u89c1\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2019\/06\/fdcon2019-css-share\/\">FDCon2019\u5927\u4f1a\u5206\u4eab\u4e4b\u6ee4\u955c\u4e0e\u6df7\u5408\u6a21\u5f0f\u5b9e\u5f55<\/a>\u201d\u4e00\u6587\uff09\u8fdb\u884c\u53d8\u8272\u3002<\/p>\n<p>\u4f46\u662f\u4e0a\u9762\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u5c5e\u4e8e\u66f2\u7ebf\u6551\u56fd\uff0c\u5f80\u5f80\u4f1a\u4e22\u5931\u5f88\u591a\u7ec6\u8282\uff0c\u6548\u679c\u5e76\u4e0d\u5982\u4eba\u610f\u3002<\/p>\n<p>\u800c <code>font-palette<\/code> \u5c5e\u6027\u4e13\u95e8\u7528\u6765\u6539\u53d8\u5f69\u8272\u5b57\u4f53\u4e2d\u7684\u5b57\u5f62\u989c\u8272\u7684\uff0c\u914d\u5408 <code>@font-palette-values<\/code> \u89c4\u5219\uff0c\u53ef\u4ee5\u8ba9 CSS \u5bf9\u5b57\u7b26\u8272\u5f69\u7684\u63a7\u5236\u8fbe\u5230\u4e00\u4e2a\u5168\u65b0\u7684\u9ad8\u5ea6\u3002<\/p>\n<h4>\u6d4f\u89c8\u5668\u5df2\u7ecf\u652f\u6301\u4e86\uff0c\u5b66\u8d77\u6765<\/h4>\n<p>\u6700\u8fd1\u51e0\u4e2a\u7248\u672c\u7684 Chrome \u548c Safari \u6d4f\u89c8\u5668\u5747\u5df2\u7ecf\u652f\u6301\u5f69\u8272\u5b57\u4f53\u7684\u663e\u793a\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/a6cdd09c6e4.png\" width=\"664\" height=\"402\" alt=\"font-palette\u517c\u5bb9\u6027\"><\/p>\n<p>\u4ee5\u73b0\u5728\u6d4f\u89c8\u5668\u66f4\u65b0\u6362\u4ee3\u7684\u901f\u5ea6\uff0c\u4e0d\u51fa\u4e00\u5e74\uff0c\u5176\u5b9e\u5c31\u53ef\u4ee5\u5728\u751f\u4ea7\u73af\u5883\u4f7f\u7528\u5bf9\u5e94\u7684\u6280\u672f\u4e86\u3002<\/p>\n<p>\u51b5\u4e14\uff0c\u6b64\u7279\u6027\u5c5e\u4e8e\u6e10\u8fdb\u589e\u5f3a\u7684\u7279\u6027\uff0c\u5c31\u7b97\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\uff0c\u4e5f\u4e0d\u5f71\u54cd\u521d\u59cb\u7684\u80fd\u529b\uff0c\u56e0\u6b64\uff0c\u5b66\u8d77\u6765\uff0c\u4e0d\u8981\u72b9\u8c6b\u3002<\/p>\n<h3>\u4e09\u3001\u5982\u4f55\u8bbe\u7f6e\u5b57\u4f53\u7684\u8c03\u8272\uff1f<\/h3>\n<p>\u5f69\u8272\u5b57\u4f53\u4e2d\u6709\u4e2a\u8c03\u8272\u677f\u7684\u6982\u5ff5\uff0c\u662f\u5b57\u4f53\u5728\u5236\u4f5c\u7684\u65f6\u5019\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u7684\u989c\u8272\u7ec4\u5408\u3002<\/p>\n<p><code>font-palette<\/code> \u5c5e\u6027\u7684\u4f5c\u7528\u5c31\u662f\u8c03\u7528\u5176\u4e2d\u6307\u5b9a\u7684\u8c03\u8272\u677f\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u4f7f\u7528\u8fc7\u7a0b\u5927\u81f4\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u8fd9\u4e09\u5757\uff1a<\/p>\n<ol>\n<li>\u81ea\u5b9a\u4e49\u5b57\u4f53\uff1b<\/li>\n<li>\u81ea\u5b9a\u4e49\u5b57\u4f53\u4e2d\u7684\u8c03\u8272\u677f\uff1b<\/li>\n<li>\u8c03\u7528\u8c03\u8272\u677f\u3002<\/li>\n<\/ol>\n<h4>1. \u81ea\u5b9a\u4e49\u5b57\u4f53<\/h4>\n<p>\u81ea\u5b9a\u4e49\u5b57\u4f53\u4f7f\u7528 @font-face \u89c4\u5219\uff0c\u8fd9\u91cc\uff0c\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u540d\u4e3a <a href=\"https:\/\/www.harbortype.com\/fonts\/rocher-color\/\" rel=\"noopener\" target=\"_blank\">Rocher Color<\/a> \u7684\u591a\u5f69\u5b57\u4f53\u8fdb\u884c\u793a\u610f\uff0c\u5047\u8bbe\u6b64\u5b57\u4f53\u6587\u4ef6\u540d\u662f RocherColorGX.woff2\u3002<\/p>\n<p>\u5219\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a <code>'Rocher'<\/code> \u7684\u81ea\u5b9a\u4e49\u5b57\u4f53\uff0c\u8fd9\u4e2a\u5b57\u4f53\u4f7f\u7528\u7684\u5c31\u662f\u591a\u8272\u5b57\u4f53\u6587\u4ef6\u3002<\/p>\n<pre>@font-face {\r\n    font-family: 'Rocher';\r\n    src: url(.\/RocherColorGX.woff2);\r\n}<\/pre>\n<h4>2. \u81ea\u5b9a\u4e49\u8c03\u8272\u677f<\/h4>\n<p>2. \u81f3\u4e8e\u5b57\u4f53\u4e2d\u7684\u8c03\u8272\u677f\u5b9a\u4e49\uff0c\u8fd9\u4e2a\u9700\u8981\u501f\u52a9 <code>@font-palette-values<\/code> \u89c4\u5219\uff0c\u5927\u5bb6\u53ef\u4ee5\u770b\u4e0b\u4e0b\u9762\u7684 CSS \u4ee3\u7801\uff1a<\/p>\n<pre>@font-palette-values --Zhangxinxu {\r\n    font-family: Rocher;\r\n    base-palette: 9;\r\n}<\/pre>\n<p>\u8868\u793a\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a &#8211;Zhangxinxu \u7684\u8c03\u8272\u677f\uff0c\u8fd9\u4e2a\u8c03\u8272\u677f\u4f7f\u7528\u7684\u662f\u7b2c9\u53f7\u57fa\u7840\u8272\u677f\u3002<\/p>\n<p>\u6240\u8c13\u7684\u201c\u57fa\u7840\u8272\u677f\u201d\uff0c\u6307\u7684\u662f\u5b57\u4f53\u5236\u4f5c\u65f6\u5019\u5185\u7f6e\u7684\u4e00\u7cfb\u5217\u8c03\u8272\u677f\uff0c\u4f7f\u7528 CSS <code>base-palette<\/code> \u5c5e\u6027\u8fdb\u884c\u8c03\u7528\u3002<\/p>\n<p>\u73b0\u5728\u95ee\u9898\u6765\u4e86\uff0c\u6211\u5982\u4f55\u77e5\u9053\u5b57\u4f53\u4e2d\u6709\u54ea\u4e9b\u8272\u677f\u5462\uff1f<code>base-palette<\/code> \u5c5e\u6027\u540e\u9762\u7684\u5e8f\u53f7\u53c8\u662f\u4ec0\u4e48\u610f\u601d\u5462\uff1f<\/p>\n<h4>3. \u8c03\u8272\u677f\u7684\u83b7\u53d6\u548c\u89c4\u5219<\/h4>\n<p>\u6709\u4e2a\u540d\u53eb <a href=\"https:\/\/wakamaifondue.com\/\" target=\"_blank\" rel=\"noopener\">Wakamai Fondue<\/a> \u7684\u5728\u7ebf\u7f51\u7ad9\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u5b57\u4f53\u4e2d\u7684\u989c\u8272\u8272\u677f\u3002<\/p>\n<p>\u70b9\u51fb\u9875\u9762\u4e2d\u95f4\u7684\u5708\u5708\u5c31\u53ef\u4ee5\u4e0a\u4f20\u5b57\u4f53\u8fdb\u884c\u8bc6\u522b\u4e86\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_184137.jpg\" width=\"285\" height=\"273\" alt=\"\u5b57\u4f53\u4fe1\u606f\u8bc6\u522b\"><\/p>\n<p>\u6b64\u5de5\u5177\u5f88\u5f3a\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u8bc6\u522b\u8272\u677f\uff0c\u5b57\u4f53\u7279\u5f81\uff08\u8fde\u5b57\u3001\u5b57\u8ddd\u3001\u4e0a\u4e0b\u9519\u843d\u7b49\uff09\uff0c\u53ef\u53d8\u7279\u6027\uff08\u5185\u8f6e\u5ed3\u3001\u5916\u9634\u5f71\u3001\u8f6e\u5ed3\u7b49\uff09\u7b49\u90fd\u53ef\u4ee5\u8bc6\u522b\uff0c\u5927\u5bb6\u53ef\u4ee5\u6536\u85cf\u5907\u5fd8\u4e0b\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u8fd9\u91cc\u53ef\u4ee5\u8bc6\u522b RocherColorGX.woff2 \u5b57\u4f53\u5171\u6709 11 \u4e2a 4 \u8272\u8c03\u8272\u677f\uff0c\u5176\u4e2d\uff0c\u7b2c\u4e00\u4e2a\u8272\u677f\u662f\u9ed8\u8ba4\u7684\u914d\u8272\uff08\u6d4f\u89c8\u5668\u4e0d\u652f\u6301 font-palette \u5c5e\u6027\u663e\u793a\u7684\u989c\u8272\uff09\uff0c\u5e8f\u53f7\u662f 0\uff0c\u7136\u540e\u5f80\u4e0b\u4f9d\u6b21\u662f 1-9.<\/p>\n<p>\u4e5f\u5c31\u662f <code>base-palette:0<\/code> \u8868\u793a\u4f7f\u7528\u7684\u662f\u9ed8\u8ba4\u8272\u677f\uff0c<code>base-palette:1<\/code>\u4f7f\u7528\u7684\u662f\u7b2c2\u4e2a\u8272\u677f\uff0c\u4f9d\u6b21\u7c7b\u63a8\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_184609.png\" width=\"384\" height=\"696\" alt=\"\u8c03\u8272\u677f\u4e0ebase-palette\u503c\u7684\u5173\u7cfb\"><\/p>\n<h4>4. \u8c03\u7528\u8c03\u8272\u677f<\/h4>\n<p>\u6709\u4e86\u81ea\u5b9a\u4e49\u7684\u8c03\u8272\u677f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528 <code>font-palette<\/code> \u5c5e\u6027\u8c03\u7528\u4e86\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>.text {\r\n    font-palette: --Zhangxinxu;\r\n}<\/pre>\n<p>\u6b64\u65f6 <code>.text<\/code> \u9009\u62e9\u5668\u5bf9\u5e94\u7684\u5143\u7d20\u4e2d\u7684\u5b57\u7b26\u5c31\u4f1a\u8c03\u7528\u8c03\u8272\u677f\u5e8f\u53f7\u4e3a 9 \u7684\u8272\u503c\u663e\u793a\uff0c\u662f\u6709\u70b9\u7070\u7070\u7684\u989c\u8272\u6548\u679c\uff0c\u5982\u4e0b\u622a\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_185128.png\" width=\"314\" height=\"60\" alt=\"\u8c03\u8272\u677f\u7070\u8272\u503c\u6548\u679c\"><\/p>\n<h4>5. \u5b8c\u6574\u4ee3\u7801\u4e0e\u6548\u679c<\/h4>\n<p>\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u6574\u5408\u4e00\u4e0b\uff0c\u5c31\u6709\u4e86\u5b8c\u6574\u7684\u591a\u5f69\u5b57\u4f53\u989c\u8272\u8bbe\u7f6e\u7684\u5b9e\u73b0\u4e86\u3002<\/p>\n<p>\u5047\u8bbe\u6709\u5982\u4e0b\u7684 HTML \u5143\u7d20\uff1a<\/p>\n<pre>&lt;h4 class=\"grays\"&gt;Color fonts&lt;\/h4&gt;\r\n&lt;h4 class=\"purples\"&gt;Color fonts&lt;\/h4&gt;\r\n&lt;h4 class=\"mint\"&gt;Color fonts&lt;\/h4&gt;<\/pre>\n<p>\u5219\u4e0b\u9762\u7684 CSS \u53ef\u4ee5\u8ba9\u8fd9\u4e09\u6bb5\u6587\u5b57\u5206\u522b\u663e\u793a\u4e0d\u540c\u7684\u8272\u677f\u8272\u503c\uff1a<\/p>\n<pre>\/* \u81ea\u5b9a\u4e49\u5b57\u4f53 *\/\r\n@font-face {\r\n  font-family: 'Rocher';\r\n  src: url(.\/RocherColorGX.woff2);\r\n}\r\nh4 {\r\n  font-family: 'Rocher';\r\n  font-size: 50px;\r\n}\r\n\/* \u81ea\u5b9a\u4e49\u8c03\u8272\u677f *\/\r\n@font-palette-values --Grays {\r\n  font-family: Rocher;\r\n  base-palette: 9;\r\n}\r\n@font-palette-values --Purples {\r\n  font-family: Rocher;\r\n  base-palette: 6;\r\n}\r\n@font-palette-values --Mint {\r\n  font-family: Rocher;\r\n  base-palette: 7;\r\n}\r\n\/* \u8c03\u7528\u8c03\u8272\u677f *\/\r\n.grays {\r\n  font-palette: --Grays;\r\n}\r\n.purples {\r\n  font-palette: --Purples;\r\n}\r\n.mint {\r\n  font-palette: --Mint;\r\n}<\/pre>\n<p>\u6700\u7ec8\u7684\u6e32\u67d3\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff08\u5982\u679c\u6d4f\u89c8\u5668\u652f\u6301 font-palette \u5c5e\u6027\uff09\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_185643.png\" width=\"325\" height=\"234\" alt=\"\u4e0d\u540c\u989c\u8272\u5b57\u4f53\u663e\u793a\"><\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202207\/css-font-palette-values-demo.php\" rel=\"noopener\" target=\"_blank\">@font-palette-values\u4f7f\u7528\u6f14\u793ademo<\/a><\/p>\n<p>\u5982\u679c\u60a8\u7684\u6d4f\u89c8\u5668\u7248\u672c\u8fd8\u4e0d\u8db3\uff0c\u5219\u663e\u793a\u7684\u6548\u679c\u4f1a\u662f\u9ed8\u8ba4\u7684\u8272\u677f\u989c\u8272\uff0c\u4e5f\u5c31\u662f\u68d5\u9ec4\u8272\u8272\u677f\u7684\u6548\u679c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_185816.png\" width=\"315\" height=\"245\" alt=\"\u9ed8\u8ba4\u8c03\u8272\u677f\u989c\u8272\u6548\u679c\"><\/p>\n<h3>\u56db\u3001override-colors \u91cd\u7f6e\u8c03\u8272\u677f\u989c\u8272<\/h3>\n<p>\u9664\u4e86\u4f7f\u7528\u9ed8\u8ba4\u7684\u8c03\u8272\u677f\u8272\u503c\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528 CSS <code>override-colors<\/code> \u5c5e\u6027\u91cd\u7f6e\u8c03\u8272\u677f\u4e2d\u7684\u989c\u8272\u3002<\/p>\n<p><code>override-colors<\/code> \u5c5e\u6027\u540c\u6837\u53ea\u5728 <code>@font-palette-values<\/code> \u89c4\u5219\u4e2d\u4f7f\u7528\u624d\u6709\u6548\u3002<\/p>\n<p>\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>override-colors:\r\n    0 &lt;color&gt;,\r\n    1 &lt;color&gt;,\r\n    2 &lt;color&gt;,\r\n    ...;\r\n<\/pre>\n<p>\u81f3\u4e8e\u989c\u8272\u7684\u6570\u91cf\u7684\u591a\u5c11\u662f\u6709\u5b57\u4f53\u51b3\u5b9a\u7684\uff0c\u4f8b\u5982 <a href=\"https:\/\/www.harbortype.com\/fonts\/rocher-color\/\" rel=\"noopener\" target=\"_blank\">Rocher Color<\/a> \u8fd9\u4e2a\u5b57\u4f53\u7684\u6bcf\u4e2a\u8272\u677f\u662f 4 \u4e2a\u989c\u8272\uff0c\u5219\u8fd9\u91cc\u7684 <code>override-colors<\/code> \u5c31\u53ef\u4ee5\u91cd\u7f6e 4 \u4e2a\u989c\u8272\u503c\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5177\u4f53\u54ea\u4e2a\u5e8f\u53f7\u5bf9\u4e8e\u90a3\u5757\u7684\u8272\u503c\u662f\u65e0\u6cd5\u5224\u65ad\u7684\uff0c\u9700\u8981\u81ea\u5df1\u4ee3\u7801\u8c03\u8bd5\u624d\u77e5\u9053\u3002<\/p>\n<p>\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f7f\u7528\u6848\u4f8b\uff0c\u5355\u72ec\u4f7f\u7528 <code>override-colors<\/code> \u5c5e\u6027\uff0c\u5219\u8868\u793a\u5728\u9ed8\u8ba4\u7684\u8c03\u8272\u677f\u4e0a\u91cd\u7f6e\u67d0\u4e9b\u989c\u8272\u503c\u3002<\/p>\n<pre>@font-palette-values --Default {\r\n  font-family: Rocher;\r\n  override-colors:\r\n    0 #2a80eb,\r\n    1 #eb4646,\r\n    2 #f59b00,\r\n    3 #1cad70;\r\n}\r\n\r\n.default {\r\n  font-palette: --Default;\r\n}<\/pre>\n<p>\u610f\u601d\u662f\u81ea\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a &#8211;Default \u7684\u8c03\u8272\u677f\uff0c\u91cc\u9762\u7684\u989c\u8272\u5c06\u9ed8\u8ba4\u8c03\u8272\u677f\u7684 4 \u4e2a\u989c\u8272\u5168\u90e8\u8986\u76d6\u4e86\u4e2a\u904d\u3002<\/p>\n<p>\u6b64\u65f6\u8bbe\u7f6e\u4e86\u7c7b\u540d <code>default<\/code> \u7684\u5143\u7d20\u7684\u82f1\u6587\u5b57\u7b26\u6e32\u67d3\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_224707.png\" width=\"334\" height=\"71\" alt=\"\u9ed8\u8ba4\u8272\u677f\u989c\u8272\u53d8\u8eab\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u5982\u679c\u6211\u4eec\u53ea\u5e0c\u671b\u91cd\u7f6e\u67d0\u4e2a\u8c03\u8272\u677f\u4e2d\u7684\u5177\u4f53\u7684\u4e00\u4e24\u4e2a\u8272\u503c\uff0c\u800c\u4e0d\u662f\u5168\u90e8\uff0c\u5219\u6b64\u65f6\u53ef\u4ee5\u548c <code>base-palette<\/code> \u5c5e\u6027\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<pre>@font-palette-values --Palette6 {\r\n  font-family: Rocher;\r\n  base-palette: 6;\r\n  override-colors: 2 #f59b00;\r\n}<\/pre>\n<p>\u6b64\u65f6\u8c03\u8272\u677f &#8211;Palette6 \u4e2d\u53ea\u6709\u4e00\u4e2a\u989c\u8272\u8986\u76d6\u6210\u4e86\u6a59\u8272\uff0c\u622a\u56fe\u6548\u679c\u89c1\u4e0b\u9762\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_224716.png\" width=\"328\" height=\"66\" alt=\"\u5b57\u4f53\u989c\u8272\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e0a\u8ff0\u6548\u679c\u6709\u5bf9\u5e94\u7684\u6f14\u793a\u9875\u9762\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202207\/css-override-colors-demo.php\" rel=\"noopener\" target=\"_blank\">override-colors\u8986\u76d6\u6587\u5b57\u8c03\u8272\u677f\u989c\u8272demo<\/a><\/p>\n<h4>\u5176\u4ed6\u6709\u8da3\u7684\u5c55\u793a<\/h4>\n<p>\u8fd9\u91cc\u8fd8\u6709\u4e2a\u6f14\u793a\u9875\u9762\uff0c\u5229\u7528 <code>override-colors<\/code> \u5c5e\u6027\u81ea\u5b9a\u4e49 emoji \u8868\u60c5\u5404\u4e2a\u90e8\u4f4d\u7684\u989c\u8272\uff0c\u539f\u59cb\u5730\u5740\u662f<a href=\"https:\/\/rsheeter.github.io\/recolor\/\" rel=\"noopener\" target=\"_blank\">\u8fd9\u91cc<\/a>\uff0c\u5982\u679c\u65e0\u6cd5\u8bbf\u95ee\u4e86\uff0c\u4e5f\u53ef\u4ee5<a href=\"https:\/\/www.zhangxinxu.com\/study\/202207\/emoji-color.html\" rel=\"noopener\" target=\"_blank\">\u70b9\u51fb\u8fd9\u91cc<\/a>\u4f53\u9a8c\u6548\u679c\u3002<\/p>\n<p>\u5f53\u6539\u53d8\u4e86\u51e0\u4e2a\u989c\u8272\u503c\u540e\uff0c\u6b64\u65f6\u76f8\u5173\u7684 CSS \u4ee3\u7801\u5982\u4e0b\u622a\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_224148.png\" width=\"621\" height=\"568\" alt=\"emoji\u989c\u8272\u53d8\u5316\u65f6\u5019\u7684override-colors\u4ee3\u7801\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u56db\u3001\u5176\u4ed6\u8bf4\u660e\u3001\u7ed3\u8bed\u7b49<\/h3>\n<p>\u5bf9\u4e8e\u4e2d\u6587\u73af\u5883\uff0c\u53d7\u5236\u4e8e\u5b57\u4f53\u6587\u4ef6\u8fc7\u5927\uff0c\u4ee5\u53ca\u7f3a\u5c11\u5bf9\u5e94\u7684\u5b57\u4f53\uff0c\u56e0\u6b64\uff0c\u591a\u8272\u5b57\u4f53\u6280\u672f\u7684\u5b9e\u9645\u5e94\u7528\u4e0d\u662f\u4e2d\u6587\u7684\u5904\u7406\uff0c\u66f4\u591a\u7684\u662f\u82f1\u6587\u6570\u5b57\uff0c\u6216\u8005\u662f\u67d0\u4e9b\u5f69\u8272\u7684\u77e2\u91cf\u56fe\u6807\u3002<\/p>\n<p>\u867d\u7136\u76ee\u524d\u4e5f\u6709\u5f69\u8272 icon \u56fe\u6807\uff0c\u4f46\u4e00\u822c\u90fd\u662f SVG \u7ed8\u5236\u7684\uff0c\u989c\u8272\u7684\u63a7\u5236\u5e76\u4e0d\u65b9\u4fbf\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/2022-07-21_194742.png\" width=\"279\" height=\"192\" alt=\"\u5f69\u8272\u56fe\u6807\"><\/p>\n<p>\u5982\u679c\u5c06\u5176\u8f6c\u6362\u6210\u5f69\u8272\u5b57\u4f53\uff0c\u518d\u914d\u5408 <code>font-palette<\/code> \u5c5e\u6027\u8fdb\u884c\u63a7\u5236\uff0c\u90a3\u5c31\u65b9\u4fbf\u591a\u4e86\u3002<\/p>\n<p>\u4e0d\u77e5\u9053\u6709\u6ca1\u6709\u81ea\u52a8\u8f6c\u6362\u7684\u5de5\u5177\uff0c\u7406\u8bba\u4e0a\u5e94\u8be5\u662f\u53ef\u4ee5\u652f\u6301\u7684\uff0c\u4e0d\u8fc7\u6211\u6ca1\u627e\u5230\uff0c\u5982\u679c\u5df2\u7ecf\u6709\u4e86\uff0c\u6b22\u8fce\u5927\u5bb6\u8fdb\u884c\u53cd\u9988\uff0c\u6211\u66f4\u65b0\u5230\u6587\u7ae0\u4e2d\u3002<\/p>\n<p>\u8d8a\u6765\u8d8a\u671f\u5f85\u4ee5\u540e\u7684 Web \u4ea7\u54c1\u6837\u5f0f\u4e0e\u5f62\u6001\u4e86\u3002<\/p>\n<h4>\u53c2\u8003\u6587\u7ae0<\/h4>\n<ul>\n<li><a href=\"https:\/\/css-tricks.com\/colrv1-and-css-font-palette-web-typography\/\" target=\"_csstrick\">COLRv1 and CSS font-palette: Web Typography Gets Colorful<\/a><\/li>\n<\/ul>\n<p>\u884c\u4e3a\u4e0d\u6613\uff0c\u5982\u679c\u4f60\u89c9\u5f97\u5185\u5bb9\u8fd8\u4e0d\u9519\uff0c\u6b22\u8fce<button onclick=\"shareWeixin.click()\" class=\"entry-share-btn\">\u5206\u4eab<\/button>\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/2764.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10478\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10478<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202207\/color-font-cover.png\" width=\"160\" height=\"103\" alt=\"\u5c01\u9762\u56fe\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u5173\u4e8e\u591a\u5f69\u5b57\u4f53\u7684\u77e5\u8bc6\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528 font-palette \u7b49CSS\u5c5e\u6027\u8bbe\u7f6e\u5b57\u4f53\u7684\u4e0d\u540c\u8272\u8c03\uff0c\u56fd\u5185\u9996\u53d1\uff0c\u7a00\u7f3a\u5e72\u8d27\u77e5\u8bc6\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1842,1843,655,417,1841,1844],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10478"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10478"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10478\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}