Skip to content

Commit

Permalink
feat: add flag --list-fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloxaf committed Nov 21, 2020
1 parent c1abc51 commit a767a83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ fn run() -> Result<(), Error> {
println!("{}", i);
}
return Ok(());
} else if config.list_fonts {
let source = font_kit::source::SystemSource::new();
for font in source.all_families().unwrap_or_default() {
println!("{}", font);
}
return Ok(());
}

let (syntax, code) = config.get_source_code(&ps)?;
Expand Down
11 changes: 8 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ type Lines = Vec<u32>;
#[structopt(name = "silicon")]
pub struct Config {
/// Background image
#[structopt(long, conflicts_with = "background")]
#[structopt(long, value_name = "IMAGE", conflicts_with = "background")]
pub background_image: Option<PathBuf>,

/// Background color of the image
#[structopt(
long,
Expand All @@ -76,7 +77,7 @@ pub struct Config {
#[structopt(value_name = "FILE", parse(from_os_str))]
pub file: Option<PathBuf>,

/// The font list. eg. 'Hack; SimSun=31'
/// The fallback font list. eg. 'Hack; SimSun=31'
#[structopt(long, short, value_name = "FONT", parse(from_str = parse_font_str))]
pub font: Option<FontList>,

Expand All @@ -100,12 +101,16 @@ pub struct Config {
#[structopt(long)]
pub list_themes: bool,

/// List all available fonts in your system
#[structopt(long)]
pub list_fonts: bool,

/// Write output image to specific location instead of cwd.
#[structopt(
short,
long,
value_name = "PATH",
required_unless_one = &["list-themes", "to-clipboard"]
required_unless_one = &["list-fonts", "list-themes", "to-clipboard"]
)]
pub output: Option<PathBuf>,

Expand Down

0 comments on commit a767a83

Please sign in to comment.