字形码映射是 Material Design Icons 仓库中将人类可读的图标名称与其 Unicode 字形码值连接起来的系统。本文档解释了图标名称如何映射到特定的 Unicode 字形码,使开发者能够在应用程序中通过名称引用图标,同时确保跨平台的渲染一致性。
有关图标样式和变体的信息,请参阅Material Icons 与 Material Symbols。有关字体文件结构和格式的详细信息,请参阅字体文件。
该仓库包含多个 .codepoints 文件,每个文件定义了图标名称与其分配的 Unicode 字形码之间的映射。这些文件遵循一致的格式
icon_name hexadecimal_codepoint
每行包含
home,add_circle)e88a,f1d8)Material Symbols 字形码文件示例
home e88a
add_circle e147
face f008
account_circle f20b
来源:variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints
该仓库为每个字体变体维护单独的字形码文件
位于 variablefont 目录中
MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepointsMaterialSymbolsOutlined[FILL,GRAD,opsz,wght].codepointsMaterialSymbolsSharp[FILL,GRAD,opsz,wght].codepoints位于 font 目录中
MaterialIcons-Regular.codepointsMaterialIconsRound-Regular.codepointsMaterialIconsOutlined-Regular.codepointsMaterialIconsSharp-Regular.codepoints来源:variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints,font/MaterialIcons-Regular.codepoints
Material Design Icons 使用 Unicode 私有使用区 (PUA) 作为其字形码
e000 到 f8ff同一个图标在不同的样式变体中保持一致的字形码
e88a)字形码文件中的图标名称遵循特定的模式
add_circle,arrow_forward)10k,3d_rotation)6_ft_apart,1x_mobiledata_badge)来源:variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints:1-20
下图说明了字形码映射如何连接图标名称及其视觉表示
来源:variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints,font/MaterialIcons-Regular.codepoints
对于 Material Symbols,其他 CSS 属性控制可变字体轴
Material Icons 和 Material Symbols 都使用相同的底层字形码系统,但存在一些差异
| 方面 | Material Icons | Material Symbols |
|---|---|---|
| 基础字体技术 | 固定字体 | 可变字体 |
| 字形码范围 | 主要为 e000-e999 | 扩展到包含较新的 f000-f8ff |
| 图标覆盖 | 约 1,000 个图标 | 约 2,500 个图标 |
| 更新状态 | 旧版(未更新) | 活跃(接收新图标) |
来源:font/MaterialIcons-Regular.codepoints variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints
下图说明了字形码映射如何集成到 Material Design Icons 的整体架构中
来源:variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints,font/MaterialIcons-Regular.codepoints
字体文件使用标准的 OpenType 表将字形码连接到字形
来源:variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints
在使用 Material Design 图标字形码时
字形码分配遵循一些通用模式
e000-e999 范围f000-f8ff)file_copy,file_download 等)共享相似的字形码范围来源:variablefont/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].codepoints:400-500