1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Generic model of font sources.
use std::path::Path;
use fontdrasil::coords::NormalizedLocation;
use crate::{
error::Error,
orchestration::{Flags, IrWork},
};
/// A source of data from which one could compile a font.
///
/// Expected to be implemented once per font format, e.g. one for .glyphs, one for ufo+ds, etc.
pub trait Source {
/// path is to the root entry, e.g. .glyphs file, .designspace, etc
fn new(root: &Path) -> Result<Self, Error>
where
Self: Sized;
/// Create a function that could be called to generate [crate::ir::StaticMetadata].
///
/// When run work should update [crate::orchestration::Context] with new [crate::ir::StaticMetadata].
fn create_static_metadata_work(&self) -> Result<Box<IrWork>, Error>;
/// Create a function that could be called to generate [crate::ir::StaticMetadata].
///
/// When run work should update[crate::orchestration::Context] with new [crate::ir::GlobalMetrics].
fn create_global_metric_work(&self) -> Result<Box<IrWork>, Error>;
/// Create a function that could be called to generate IR for glyphs.
///
/// Batched because some formats require IO to figure out the work.
/// Expected to return a Vec aligned with the glyph_names input. That is,
/// result vec nth entry is the work for the nth glyph name.
///
/// When run work should update [crate::orchestration::Context] with [crate::ir::Glyph] and [crate::ir::Anchor]
/// for the glyph name.
fn create_glyph_ir_work(&self) -> Result<Vec<Box<IrWork>>, Error>;
/// Create a function that could be called to generate or identify fea file(s).
///
/// When run work should update [crate::orchestration::Context] with [crate::ir::FeaturesSource].
fn create_feature_ir_work(&self) -> Result<Box<IrWork>, Error>;
/// Create a function that could be called to produce kerning groups.
///
/// When run work should update [crate::orchestration::Context] with [crate::ir::KerningGroups].
fn create_kerning_group_ir_work(&self) -> Result<Box<IrWork>, Error>;
/// Create a function that could be called to generate or identify kerning for a location.
///
/// When run work should update [crate::orchestration::Context] with [crate::ir::KerningInstance].
fn create_kerning_instance_ir_work(&self, at: NormalizedLocation)
-> Result<Box<IrWork>, Error>;
/// Create a function that could be called to generate [crate::ir::ColorPalettes].
///
/// When run work should update [crate::orchestration::Context] with new [crate::ir::ColorPalettes].
fn create_color_palette_work(&self) -> Result<Box<IrWork>, Error>;
/// Create a function that could be called to generate [crate::ir::ColorGlyphs].
///
/// When run work should update [crate::orchestration::Context] with new [crate::ir::ColorGlyphs].
fn create_color_glyphs_work(&self) -> Result<Box<IrWork>, Error>;
/// Returns compilation flags derived from source file settings.
///
/// CLI flags will be combined with these using bitwise OR.
/// See <https://github.com/googlefonts/fontc/issues/1701>
fn compilation_flags(&self) -> Flags {
Flags::empty() // default: no flags from source
}
}