1448
This commit is contained in:
1 parent
7093f80296
commit
2fbf2e3d82
14 files changed
+5
-85
No files matched your search
@@ -72,7 +72,6 @@ def subset_font(font_path, output_path, codepoints):
|
||||
|
||||
options = Options()
|
||||
options.flavor = 'woff2'
|
||||
options.desubroutinize = True
|
||||
|
||||
subsetter = Subsetter(options=options)
|
||||
subsetter.populate(unicodes=codepoints)
|
||||
@@ -81,7 +80,7 @@ def subset_font(font_path, output_path, codepoints):
|
||||
font.save(output_path)
|
||||
font.close()
|
||||
|
||||
def generate_css(slices_info, font_dir_rel='../font/slices'):
|
||||
def generate_css(slices_info, font_dir_rel='/font/slices'):
|
||||
"""生成 CSS 文件"""
|
||||
css_parts = []
|
||||
|
||||
@@ -92,7 +91,7 @@ def generate_css(slices_info, font_dir_rel='../font/slices'):
|
||||
*/
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('../font/zql-v2.woff2') format('woff2');
|
||||
src: url('/font/zql-v2.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+0000-00FF, U+2000-206F, U+3000-303F, U+FF00-FFEF;
|
||||
}
|
||||
|
||||
@@ -1,85 +1,6 @@
|
||||
/**
|
||||
* 字体分片 - 按需加载
|
||||
* 浏览器会根据页面实际使用的字符自动加载对应的分片
|
||||
* 首屏通常只需要加载 ASCII + 1-3 个常用字分片(约 100-200KB)
|
||||
*/
|
||||
|
||||
/* ASCII + 常用标点(基础,总是加载) */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/zql-v2.woff2') format('woff2');
|
||||
src: url('/font/zql-v2-subset.woff2') format('woff2'),
|
||||
url('/font/zql-v2-subset.woff') format('woff');
|
||||
font-display: swap;
|
||||
unicode-range: U+0000-00FF, U+2000-206F, U+3000-303F, U+FF00-FFEF;
|
||||
}
|
||||
|
||||
/* 常用字分片 01: U+4E00-U+56FF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-common-01.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+4E00-56FF;
|
||||
}
|
||||
|
||||
/* 常用字分片 02: U+5700-U+5FFF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-common-02.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+5700-5FFF;
|
||||
}
|
||||
|
||||
/* 常用字分片 03: U+6000-U+68FF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-common-03.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+6000-68FF;
|
||||
}
|
||||
|
||||
/* 常用字分片 04: U+6900-U+71FF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-common-04.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+6900-71FF;
|
||||
}
|
||||
|
||||
/* 常用字分片 05: U+7200-U+7AFF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-common-05.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+7200-7AFF;
|
||||
}
|
||||
|
||||
/* 常用字分片 06: U+7B00-U+83FF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-common-06.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+7B00-83FF;
|
||||
}
|
||||
|
||||
/* 常用字分片 07: U+8400-U+8CFF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-common-07.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+8400-8CFF;
|
||||
}
|
||||
|
||||
/* 生僻字分片 01: U+8D00-U+95FF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-rare-01.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+8D00-95FF;
|
||||
}
|
||||
|
||||
/* 生僻字分片 02: U+9600-U+9FFF */
|
||||
@font-face {
|
||||
font-family: 'zql';
|
||||
src: url('/font/slices/zql-rare-02.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
unicode-range: U+9600-9FFF;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user