[筆記] 分割字型為子集

方便轉換的腳本:

echo "使用辦法: ttf2subset [input file name - 輸入檔名] [input file name suffix - 輸入副檔名] [outputformat(woff or woff2)] [output file name (No suffix) - 輸
出檔名(不含附檔名)]"
echo "此腳本仰賴 fonttools 的 pyftsubset."
echo "Unicode Range: exclude CJK Glyph"
pyftsubset "$1.$2" --unicodes=U+0-33FF,U+4DC0-4DFF,U+A000-FFFF,U+10000-1FBFF --layout-features='*' --flavor="$3" --output-file="$4-cjkui-outside.$3"
echo "Unicode Range: CJK Unified Ideographs Extension A"
pyftsubset "$1.$2" --unicodes=U+3400-4DBF --layout-features='*' --flavor="$3" --output-file="$4-cjkui-ext-a.$3"
echo "Unicode Range: CJK Unified Ideographs Part 1"
pyftsubset "$1.$2" --unicodes=U+4E00-62FF --layout-features='*' --flavor="$3" --output-file="$4-cjkui-part-1.$3"
echo "Unicode Range: CJK Unified Ideographs Part 2"
pyftsubset "$1.$2" --unicodes=U+6300-77FF --layout-features='*' --flavor="$3" --output-file="$4-cjkui-part-2.$3"
echo "Unicode Range: CJK Unified Ideographs Part 3"
pyftsubset "$1.$2" --unicodes=U+7800-8CFF --layout-features='*' --flavor="$3" --output-file="$4-cjkui-part-3.$3"
echo "Unicode Range: CJK Unified Ideographs Part 4"
pyftsubset "$1.$2" --unicodes=U+8D00-9FFF --layout-features='*' --flavor="$3" --output-file="$4-cjkui-part-4.$3"
echo "Unicode Range: CJK Unified Ideographs Ext.B-G"
pyftsubset "$1.$2" --unicodes=U+20000-3134F --layout-features='*' --flavor="$3" --output-file="$4-cjkui-ext-b-g.$3"
/home/root/ttf2subset.sh (END)

css 參考:

/* GenYoGothic */
/* Regular */
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-R-cjkui-outside.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-R-cjkui-ext-a.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-R-cjkui-part-1.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-R-cjkui-part-2.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-R-cjkui-part-3.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-R-cjkui-part-4.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-R-cjkui-ext-b-g.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* Bold */
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-B-cjkui-outside.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-B-cjkui-ext-a.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-B-cjkui-part-1.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-B-cjkui-part-2.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-B-cjkui-part-3.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-B-cjkui-part-4.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-B-cjkui-ext-b-g.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* Heavy */
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-H-cjkui-outside.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-H-cjkui-ext-a.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-H-cjkui-part-1.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-H-cjkui-part-2.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-H-cjkui-part-3.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-H-cjkui-part-4.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenYoGothic TW";
  src: url(/wp-content/uploads/GenYoGothicTW-H-cjkui-ext-b-g.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* ---------------------------------------- */
/* GenYoMin */
/* Regular */
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-R-cjkui-outside.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-R-cjkui-ext-a.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-R-cjkui-part-1.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-R-cjkui-part-2.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-R-cjkui-part-3.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-R-cjkui-part-4.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-R-cjkui-ext-b-g.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* Bold */
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-B-cjkui-outside.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-B-cjkui-ext-a.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-B-cjkui-part-1.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-B-cjkui-part-2.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-B-cjkui-part-3.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-B-cjkui-part-4.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-B-cjkui-ext-b-g.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* Heavy */
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-H-cjkui-outside.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-H-cjkui-ext-a.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-H-cjkui-part-1.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-H-cjkui-part-2.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-H-cjkui-part-3.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-H-cjkui-part-4.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenYoMin TW";
  src: url(/wp-content/uploads/GenYoMinTW-H-cjkui-ext-b-g.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* ---------------------------------------- */
/* GenSenRounded */
/* Regular */
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-R-cjkui-outside.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-R-cjkui-ext-a.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-R-cjkui-part-1.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-R-cjkui-part-2.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-R-cjkui-part-3.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-R-cjkui-part-4.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-R-cjkui-ext-b-g.woff2);
  font-weight: 400;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* Bold */
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-B-cjkui-outside.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-B-cjkui-ext-a.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-B-cjkui-part-1.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-B-cjkui-part-2.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-B-cjkui-part-3.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-B-cjkui-part-4.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-B-cjkui-ext-b-g.woff2);
  font-weight: 700;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
/* Heavy */
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-H-cjkui-outside.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+0-33FF, U+4DC0-4DFF, U+A000-FFFF ,U+10000-1FBFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-H-cjkui-ext-a.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+3400-4DBF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-H-cjkui-part-1.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+4E00-62FF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-H-cjkui-part-2.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+6300-77FF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-H-cjkui-part-3.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+7800-8CFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-H-cjkui-part-4.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+8D00-9FFF;
}
@font-face {
  font-family: "GenSenRounded TW";
  src: url(/wp-content/uploads/GenSenRoundedTW-H-cjkui-ext-b-g.woff2);
  font-weight: 900;
  font-display: swap;
  unicode-range: U+20000-3134F;
}
預設圖片
Huán-Hsüān Lín (WordPressLocal)
文章: 18