1use fret_assets::AssetBundleId;
2
3pub use fret_fonts::{BundledFontFaceSpec, BundledFontProfile, BundledFontRole};
4
5#[cfg(any(test, feature = "test-support"))]
6pub mod test_support {
7 use fret_fonts::BundledFontFaceSpec;
8
9 pub fn face_blobs<'a, I>(faces: I) -> impl Iterator<Item = Vec<u8>> + 'a
10 where
11 I: IntoIterator<Item = &'a BundledFontFaceSpec>,
12 I::IntoIter: 'a,
13 {
14 faces.into_iter().map(|face| face.bytes.to_vec())
15 }
16}
17
18#[cfg(test)]
19mod tests;
20
21const FONT_OTF_MEDIA_TYPE: &str = "font/otf";
22const ROLE_CJK: &[BundledFontRole] = &[BundledFontRole::CjkFallback];
23
24const NOTO_SANS_CJK_SC_LITE_SUBSET: &[u8] =
25 include_bytes!("../assets/NotoSansCJKsc-Regular-cjk-lite-subset.otf");
26const NOTO_SANS_CJK_SC_LITE_ASSET_KEY: &str = "fonts/NotoSansCJKsc-Regular-cjk-lite-subset.otf";
27
28const CJK_LITE_FACE: BundledFontFaceSpec = BundledFontFaceSpec {
29 bundle_name: env!("CARGO_PKG_NAME"),
30 family: "Noto Sans CJK SC",
31 roles: ROLE_CJK,
32 asset_key: NOTO_SANS_CJK_SC_LITE_ASSET_KEY,
33 media_type: FONT_OTF_MEDIA_TYPE,
34 bytes: NOTO_SANS_CJK_SC_LITE_SUBSET,
35};
36
37const CJK_LITE_PROFILE: BundledFontProfile = BundledFontProfile {
38 name: "cjk-lite",
39 faces: &[CJK_LITE_FACE],
40 provided_roles: &[BundledFontRole::CjkFallback],
41 expected_family_names: &["Noto Sans CJK SC"],
42 guaranteed_generic_families: &[],
43 ui_sans_families: &[],
44 ui_serif_families: &[],
45 ui_mono_families: &[],
46 common_fallback_families: &["Noto Sans CJK SC"],
47};
48
49pub fn bundled_asset_bundle() -> AssetBundleId {
50 AssetBundleId::package(env!("CARGO_PKG_NAME"))
51}
52
53pub fn default_profile() -> &'static BundledFontProfile {
54 &CJK_LITE_PROFILE
55}