Coder Social home page Coder Social logo

silicon's Introduction

Silicon

Crates.io Documentation CI License

Silicon is an alternative to Carbon implemented in Rust.

It can render your source code into a beautiful image.

Why Silicon

Carbon is a wonderful tool to create a beautiful image of your source code.

But it is a web application, which brings the following disadvantages:

  • Cannot work without Internet & browser.
  • Doesn't work well with shell. (Although there is carbon-now-cli, its experience is not very good, especially when the network is not so good.)

However, Silicon doesn't have these problems. It's is implemented in Rust and can work without browser & Internet.

Silicon can render your source code on the fly while carbon-now-cli takes several seconds on it.

Disadvantages

It's not as beautiful as Carbon...

Install

Cargo

cargo install silicon

NOTE: harfbuzz feature is enabled by default. If you are using Windows, I suggest you disable it to get it build easier.

AUR

Silicon is available in the official repository:

pacman -S silicon

Homebrew

You can install Silicon using Homebrew:

brew install silicon

Dependencies

Ubuntu

sudo apt install expat
sudo apt install libxml2-dev
sudo apt install pkg-config libasound2-dev libssl-dev cmake libfreetype6-dev libexpat1-dev libxcb-composite0-dev libharfbuzz-dev

Fedora

sudo dnf install \
  cmake \
  expat-devel fontconfig-devel libxcb-devel \
  freetype-devel libxml2-devel \
  harfbuzz

Arch Linux

sudo pacman -S --needed pkgconf freetype2 fontconfig libxcb xclip harfbuzz

Examples

Read code from file

silicon main.rs -o main.png 

Read code from clipboard, and copy the result image to clipboard

silicon --from-clipboard -l rs --to-clipboard

Specify a fallback font list and their size

silicon -o main.png -l bash -f 'Hack; SimSun=31; code2000' <<EOF
echo Hello
echo 你好
echo ∠( ᐛ 」∠)_
EOF

Highlight specified line

silicon main.rs -o main.png --highlight-lines '1; 3-4'

Custom the image

silicon ./target/test.rs -o test.png \
    --shadow-color '#555' --background '#fff' \
    --shadow-blur-radius 30 --no-window-controls

Transparent background

The color can be #RGB[A] or #RRGGBB[AA]

silicon ./target/test.rs -o test.png --background '#fff0'

Show window title

silicon ./target/test.rs -o test.png --window-title "target/test.rs"

see silicon --help for detail

Adding new syntaxes / themes

Silicon reads syntax-definition and theme cache from user's cache directory.

The steps to add new syntaxes / themes is as same as bat: sharkdp/bat#adding-new-syntaxes--language-definitions. Just replace bat cache --build to silicon --build-cache.

Configuration file

You can write some common args to silicon --config-file.

Example:

# enable shadow
--shadow-color '#555'
--background '#fff'
--shadow-blur-radius 30
--no-window-controls

Related projects

silicon's People

Contributors

aloxaf avatar aw14saurabh avatar bennypowers avatar bors[bot] avatar byteshiva avatar dependabot-preview[bot] avatar dependabot[bot] avatar dreness avatar idursun avatar joostscheffer avatar kamwithk avatar kianmeng avatar krapaince avatar lcnr avatar lhalant avatar light4 avatar mrcoalp avatar nudelmeister avatar rashil2000 avatar thecaralice avatar themushrr00m avatar thunder-coding avatar tizee avatar vladimyr avatar xdevs23 avatar yuukitoriyama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

silicon's Issues

Add to AUR

Would you care to add it to the AUR package repository?

Love the idea!

Can't compile on Ubuntu 18.04

   Compiling which v2.0.1
   Compiling structopt v0.3.14
   Compiling onig_sys v69.2.0
error: failed to compile `silicon v0.3.1`, intermediate artifacts can be found at `/tmp/cargo-installXtOQcj`

Caused by:
  failed to run custom build command for `onig_sys v69.2.0`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installXtOQcj/release/build/onig_sys-3a36ce064895cea1/build-script-build` (exit code: 101)
--- stdout
cargo:warning=couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable

--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any valid shared libraries matching: [\'libclang.so\', \'libclang-*.so\', \'libclang.so.*\'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"', /home/leon/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.50.1/src/lib.rs:1711:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Failed to compile on macOS

$ cargo install --git https://github.com/Aloxaf/silicon
    Updating git repository `https://github.com/Aloxaf/silicon`
  Installing silicon v0.2.5 (https://github.com/Aloxaf/silicon#adadf550)
    Updating git repository `https://github.com/Aloxaf/fastblur`
    Updating git repository `https://github.com/pcwalton/font-kit`
    Updating git repository `https://github.com/image-rs/imageproc`
    Updating crates.io index
  Downloaded structopt v0.2.18
  Downloaded backtrace v0.3.34
  Downloaded clipboard v0.5.0
  Downloaded conv v0.3.3
  Downloaded dirs v2.0.2
  Downloaded tempfile v3.1.0
  Downloaded float-ord v0.2.0
  Downloaded lyon_path v0.14.0
  Downloaded euclid v0.20.1
  Downloaded itertools v0.7.11
  Downloaded memmap v0.7.0
  Downloaded syntect v3.2.0
  Downloaded num v0.2.0
  Downloaded num-bigint v0.2.2
  Downloaded rusttype v0.7.7
  Downloaded image v0.22.1
  Downloaded custom_derive v0.1.7
  Downloaded structopt-derive v0.2.18
  Downloaded term_size v0.3.1
  Downloaded bincode v1.1.4
  Downloaded flate2 v1.0.9
  Downloaded dirs-sys v0.3.4
  Downloaded plist v0.4.2
  Downloaded backtrace-sys v0.1.31
  Downloaded lyon_geom v0.14.0
  Downloaded rand v0.7.0
  Downloaded remove_dir_all v0.5.2
  Downloaded regex-syntax v0.6.11
  Downloaded onig v4.3.2
  Downloaded num-complex v0.2.3
  Downloaded cc v1.0.38
  Downloaded heck v0.3.1
  Downloaded line-wrap v0.1.1
  Downloaded approx v0.3.2
  Downloaded ordered-float v1.0.2
  Downloaded stb_truetype v0.2.6
  Downloaded crc32fast v1.2.0
  Downloaded unicode-segmentation v1.3.0
  Downloaded safemem v0.3.1
  Downloaded rand_chacha v0.2.1
  Downloaded rand_core v0.5.0
  Downloaded onig_sys v69.1.0
  Downloaded miniz-sys v0.1.12
  Downloaded c2-chacha v0.2.2
  Downloaded pkg-config v0.3.15
  Downloaded getrandom v0.1.8
  Downloaded ppv-lite86 v0.2.5
   Compiling semver-parser v0.7.0
   Compiling arrayvec v0.4.11
   Compiling autocfg v0.1.5
   Compiling cfg-if v0.1.9
   Compiling nodrop v0.1.13
   Compiling lazy_static v1.3.0
   Compiling libc v0.2.60
   Compiling proc-macro2 v0.4.30
   Compiling unicode-xid v0.1.0
   Compiling scopeguard v1.0.0
   Compiling core-foundation-sys v0.6.2
   Compiling bitflags v1.1.0
   Compiling pkg-config v0.3.15
   Compiling num-bigint v0.2.2
   Compiling syn v0.15.42
   Compiling cc v1.0.38
   Compiling byteorder v1.3.2
   Compiling rayon-core v1.5.0
   Compiling ppv-lite86 v0.2.5
   Compiling foreign-types-shared v0.1.1
   Compiling num-derive v0.2.5
   Compiling serde v1.0.98
   Compiling crc32fast v1.2.0
   Compiling ryu v1.0.0
   Compiling rand_core v0.4.0
   Compiling log v0.4.8
   Compiling failure_derive v0.1.5
   Compiling quick-error v1.2.2
   Compiling unicode-width v0.1.5
   Compiling safemem v0.3.1
   Compiling unicode-segmentation v1.3.0
   Compiling adler32 v1.0.3
   Compiling either v1.5.2
   Compiling lzw v0.10.0
   Compiling custom_derive v0.1.7
   Compiling itoa v0.4.4
   Compiling ansi_term v0.11.0
   Compiling rustc-demangle v0.1.15
   Compiling same-file v1.0.5
   Compiling xml-rs v0.8.0
   Compiling linked-hash-map v0.5.2
   Compiling block v0.1.6
   Compiling color_quant v1.0.1
   Compiling fnv v1.0.6
   Compiling termcolor v1.0.5
   Compiling lazycell v1.2.1
   Compiling regex-syntax v0.6.11
   Compiling scoped_threadpool v0.1.9
   Compiling remove_dir_all v0.5.2
   Compiling float-ord v0.2.0
   Compiling fastblur v0.1.0 (https://github.com/Aloxaf/fastblur?branch=rgba#454f299d)
   Compiling crossbeam-utils v0.6.6
   Compiling foreign-types v0.3.2
   Compiling num-traits v0.2.8
   Compiling num-integer v0.1.41
   Compiling num-rational v0.2.2
   Compiling num-complex v0.2.3
   Compiling rand_pcg v0.1.2
   Compiling rand_chacha v0.1.1
   Compiling num-iter v0.1.39
   Compiling rand v0.6.5
   Compiling bincode v1.1.4
   Compiling semver v0.9.0
   Compiling humantime v1.2.0
   Compiling c2-chacha v0.2.2
   Compiling line-wrap v0.1.1
   Compiling rand_core v0.3.1
   Compiling inflate v0.4.5
   Compiling conv v0.3.3
   Compiling itertools v0.7.11
   Compiling walkdir v2.2.9
   Compiling yaml-rust v0.4.3
   Compiling heck v0.3.1
   Compiling gif v0.10.2
   Compiling crossbeam-queue v0.1.2
   Compiling rand_isaac v0.1.1
   Compiling rand_xorshift v0.1.1
   Compiling rand_hc v0.1.0
   Compiling rustc_version v0.2.3
   Compiling num_cpus v1.10.1
   Compiling malloc_buf v0.0.6
   Compiling getrandom v0.1.8
   Compiling core-foundation v0.6.4
   Compiling term_size v0.3.1
   Compiling rand_jitter v0.1.4
   Compiling rand_os v0.1.3
   Compiling dirs-sys v0.3.4
   Compiling atty v0.2.13
   Compiling memmap v0.7.0
   Compiling onig_sys v69.1.0
   Compiling miniz-sys v0.1.12
   Compiling backtrace-sys v0.1.31
   Compiling stb_truetype v0.2.6
   Compiling deflate v0.7.20
   Compiling base64 v0.10.1
   Compiling objc v0.2.6
   Compiling rand_core v0.5.0
   Compiling memoffset v0.5.1
   Compiling textwrap v0.11.0
   Compiling core-graphics v0.17.3
   Compiling env_logger v0.6.2
   Compiling dirs v2.0.2
   Compiling euclid v0.20.1
   Compiling ordered-float v1.0.2
   Compiling approx v0.3.2
   Compiling quote v0.6.13
   Compiling rand_chacha v0.2.1
   Compiling objc_id v0.1.1
   Compiling clap v2.33.0
   Compiling core-text v13.3.0
   Compiling rusttype v0.7.7
   Compiling lyon_geom v0.14.0
   Compiling objc-foundation v0.1.1
   Compiling rand v0.7.0
   Compiling png v0.14.1
   Compiling flate2 v1.0.9
   Compiling crossbeam-epoch v0.7.2
   Compiling clipboard v0.5.0
   Compiling lyon_path v0.14.0
   Compiling backtrace v0.3.34
   Compiling plist v0.4.2
   Compiling serde_json v1.0.40
   Compiling tempfile v3.1.0
   Compiling crossbeam-deque v0.6.3
   Compiling font-kit v0.4.0 (https://github.com/pcwalton/font-kit#88bec698)
   Compiling onig v4.3.2
   Compiling image v0.22.1
   Compiling num v0.2.0
   Compiling rayon v1.1.0
   Compiling jpeg-decoder v0.1.15
   Compiling imageproc v0.18.0 (https://github.com/image-rs/imageproc#4cf5abb1)
   Compiling synstructure v0.10.2
   Compiling structopt-derive v0.2.18
   Compiling serde_derive v1.0.98
   Compiling structopt v0.2.18
   Compiling tiff v0.2.2
   Compiling image v0.21.2
   Compiling failure v0.1.5
   Compiling syntect v3.2.0
   Compiling silicon v0.2.5 (https://github.com/Aloxaf/silicon#adadf550)
error[E0277]: the trait bound `<I as image::image::GenericImageView>::Pixel: image::buffer::Pixel` is not satisfied
   --> /Users/rafi/.local/share/cargo/git/checkouts/silicon-43a8c749a341f4f8/adadf55/src/font.rs:283:38
    |
283 |                 let weighted_color = weighted_sum(pixel, color, 1.0 - v, v);
    |                                      ^^^^^^^^^^^^ the trait `image::buffer::Pixel` is not implemented for `<I as image::image::GenericImageView>::Pixel`
    |
    = help: consider adding a `where <I as image::image::GenericImageView>::Pixel: image::buffer::Pixel` bound
    = note: required by `imageproc::pixelops::weighted_sum`

error[E0277]: the trait bound `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>: image::image::GenericImage` is not satisfied
  --> /Users/rafi/.local/share/cargo/git/checkouts/silicon-43a8c749a341f4f8/adadf55/src/utils.rs:57:9
   |
57 |         draw_filled_circle_mut(
   |         ^^^^^^^^^^^^^^^^^^^^^^ the trait `image::image::GenericImage` is not implemented for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`
   |
   = note: required because of the requirements on the impl of `imageproc::drawing::canvas::Canvas` for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`

error[E0277]: the trait bound `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>: image::image::GenericImage` is not satisfied
  --> /Users/rafi/.local/share/cargo/git/checkouts/silicon-43a8c749a341f4f8/adadf55/src/utils.rs:63:9
   |
63 |         draw_filled_circle_mut(
   |         ^^^^^^^^^^^^^^^^^^^^^^ the trait `image::image::GenericImage` is not implemented for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`
   |
   = note: required because of the requirements on the impl of `imageproc::drawing::canvas::Canvas` for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`
   = note: required by `imageproc::drawing::conics::draw_filled_circle_mut`

error[E0277]: the trait bound `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>: image::image::GenericImage` is not satisfied
   --> /Users/rafi/.local/share/cargo/git/checkouts/silicon-43a8c749a341f4f8/adadf55/src/utils.rs:155:13
    |
155 |             draw_filled_rect_mut(&mut shadow, rect, self.shadow_color);
    |             ^^^^^^^^^^^^^^^^^^^^ the trait `image::image::GenericImage` is not implemented for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`
    |
    = note: required because of the requirements on the impl of `imageproc::drawing::canvas::Canvas` for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`

error[E0277]: the trait bound `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>: image::image::GenericImage` is not satisfied
   --> /Users/rafi/.local/share/cargo/git/checkouts/silicon-43a8c749a341f4f8/adadf55/src/utils.rs:213:5
    |
213 |     draw_filled_circle_mut(
    |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `image::image::GenericImage` is not implemented for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`
    |
    = note: required because of the requirements on the impl of `imageproc::drawing::canvas::Canvas` for `image::buffer::ImageBuffer<image::color::Rgba<u8>, std::vec::Vec<u8>>`

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0277`.
error: failed to compile `silicon v0.2.5 (https://github.com/Aloxaf/silicon#adadf550)`, intermediate artifacts can be found at `/var/folders/jn/h37jhl355zzb43hq3t509wxh0000gp/T/cargo-installhFWe7B`

Caused by:
  Could not compile `silicon`.

SVG support

Render the source code into a SVG image will be cool and useful

GUI

GUI for Silicon, either desktop or web (via WASM)

PHP Syntax Highlighting not working

The Problem

When creating a code picture for PHP code (while explicitly specifying PHP as language) there is no syntax highlighting in the resulting image

System conditions

  • OS: Windows 10
  • Silicon Version: 0.4.3
  • Installed using cargo install silicon

Steps to reproduce

  1. Copy the following sample PHP Code
function testFuntion(): string 
{
    if (!isset($_POST['PARAM']) || empty($_POST['PARAM']))
        return "";
    $PARAM = $_POST['PARAM'];
    return $PARAM;
}
  1. Run silicon --from-clipboard -l php -o code.png
  2. Inspect the resulting image.

The following image is created on my machine when following those steps:
code

Window without text on mac with some themes

on an m1 macbook pro running Monterey, some themes give me an empty window:

silicon --theme=base16 --to-clipboard /tmp/deleteme.makefile

image

While others work:

image

I wrote a script to test all the themes:

themes=("1337" "Coldark-Cold" "Coldark-Dark" "DarkNeon" "Dracula" "GitHub" "Monokai Extended" "Monokai Extended Bright" "Monokai Extended Light" "Monokai Extended Origin" "Nord" "OneHalfDark" "OneHalfLight" "Solarized (dark)" "Solarized (light)" "Sublime Snazzy" "TwoDark" "ansi-dark" "ansi-light" "base16" "base16-256" "gruvbox" "gruvbox-light" "gruvbox-white" "zenburn")

for theme in "${themes[@]}"
do
    silicon --theme="$theme" --output="/tmp/silicon-$theme.png" /tmp/deleteme.makefile
done

And the ones that fail are: ansi-dark, ansi-light, base16, and base16-256. I wasn't able to find anything that would let me get verbose information on what silicon was doing, so I don't have much more info to report.

I tested with a python file to see if the file type might be the culprit, and got the same results.

For the above test, I am using a version built with cargo. I tried this version after the one I downloaded with homebrew failed, thinking it might work, but they fail in the same way.

This may be related to #147, but I'm not sure.

If there's anything I can do to help debug, please let me know, I'd be happy to help.

`--output=~/` does not expand

--output=~/ does not seem to expand

$ echo foo | silicon --language=python --output /Users/Klas/Desktop/foo.png
$ echo foo | silicon --language=python --output=/Users/Klas/Desktop/foo.png
$ echo foo | silicon --language=python --output ~/Desktop/foo.png
$ echo foo | silicon --language=python --output=~/Desktop/foo.png
[error] Failed to save image to ~/Desktop/foo.png: No such file or directory (os error 2)

[Error] : No package 'freetype2' found

Failed to install (cargo install silicon) throws No package 'freetype2' found

$ cargo install silicon
--- stderr
configure: error: Package requirements (freetype2) were not met:

No package 'freetype2' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables FREETYPE_CFLAGS
and FREETYPE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
make: *** [makefile.cargo:83: /tmp/cargo-installKkTQ6y/release/build/servo-fontconfig-sys-0fe7df1e4d95efe8/out/Makefile] Error 1
thread 'main' panicked at 'assertion failed: Command::new("make").env("MAKEFLAGS",
                         env::var("CARGO_MAKEFLAGS").unwrap_or_default()).args(&["-R",
                                                                                 "-f",
                                                                                 "makefile.cargo"]).status().unwrap().success()', /home/xyz/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-4.0.9/build.rs:20:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `silicon v0.3.0`, intermediate artifacts can be found at `/tmp/cargo-installKkTQ6y`

Caused by:
  build failed
 uname -a
Linux  5.3.0-41-generic #33-Ubuntu SMP  x86_64 x86_64 x86_64 GNU/Linux

Fallback font support

For support of emoji and CJK characters and others

eg.

silicon --font 'Hack; SimSun; Blobmoji' test.rs -o test.png

I hate font rendering...

Support right-padding only

I needed to render some snippets with no left padding but with right padding. I hacked it together by doing some minor modifications to use 0 as the left position of the alpha and setting the horizontal padding through the CLI, but it would be cool to support this natively:

diff --git a/src/utils.rs b/src/utils.rs
...skipping...
@@ -261,7 +280,7 @@ impl ShadowAdder {
         copy_alpha(
             image.as_rgba8().unwrap(),
             &mut shadow,
-            self.pad_horiz,
+            0,
             self.pad_vert,
         );

Failes to compile on Windows

error[E0308]: mismatched types
   --> src\utils.rs:284:5
    |
283 | pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> {
    |                                                         ----------------- expected `std::result::Result<(), failure::Error>` because of return type
284 |     format_err!("This feature hasn't been implemented in your system")
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found struct `failure::Error`
    |
    = note: expected type `std::result::Result<(), failure::Error>`
               found type `failure::Error`
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `silicon`.

Can be fixed by wrapping format_err!() in an Err() like Err(format_err!("This feature hasn't been implemented in your system"))

Latest update is failing to compile

Installing through cargo install.

   Compiling pasteboard v0.1.2
error[E0308]: mismatched types
  --> /Users/augusto/.cargo/registry/src/github.com-1ecc6299db9ec823/pasteboard-0.1.2/src/lib.rs:75:12
   |
75 |         if ok {
   |            ^^ expected `bool`, found `i8`

error[E0308]: mismatched types
  --> /Users/augusto/.cargo/registry/src/github.com-1ecc6299db9ec823/pasteboard-0.1.2/src/lib.rs:82:59
   |
82 |             NSData::writeToFile_atomically_(object, path, false);
   |                                                           ^^^^^ expected `i8`, found `bool`

error: aborting due to 2 previous errors

PlatformError on Windows

Command: cargo run -- main.rs -o test.png
Output: thread 'main' panicked at '9: PlatformError', src\libcore\result.rs:1051:5
BackTrace:

stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
             at C:\Program Files\Rust\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.29\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\sys_common\backtrace.rs:47
   2: std::sys_common::backtrace::print
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\sys_common\backtrace.rs:36
   3: std::panicking::default_hook::{{closure}}
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panicking.rs:200
   4: std::panicking::default_hook
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panicking.rs:214
   5: std::panicking::rust_panic_with_hook
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panicking.rs:477
   6: std::panicking::continue_panic_fmt
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panicking.rs:384
   7: std::panicking::rust_begin_panic
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panicking.rs:311
   8: core::panicking::panic_fmt
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libcore\panicking.rs:85
   9: core::result::unwrap_failed<font_kit::error::GlyphLoadingError>
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\src\libcore\macros.rs:18
  10: core::result::Result<(), font_kit::error::GlyphLoadingError>::expect<(),font_kit::error::GlyphLoadingError>
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\src\libcore\result.rs:879
  11: silicon::font::PositionedGlyph::draw<closure>
             at .\src\font.rs:286
  12: silicon::font::FontCollection::draw_text_mut<image::dynimage::DynamicImage>
             at .\src\font.rs:253
  13: silicon::formatter::ImageFormatter::draw_line_number
             at .\src\formatter.rs:177
  14: silicon::formatter::ImageFormatter::format
             at .\src\formatter.rs:230
  15: silicon::run
             at .\src\main.rs:48
  16: silicon::main
             at .\src\main.rs:76
  17: std::rt::lang_start::{{closure}}<()>
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\src\libstd\rt.rs:64
  18: std::rt::lang_start_internal::{{closure}}
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\rt.rs:49
  19: std::panicking::try::do_call<closure,i32>
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panicking.rs:296
  20: panic_unwind::__rust_maybe_catch_panic
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libpanic_unwind\lib.rs:82
  21: std::panicking::try
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panicking.rs:275
  22: std::panic::catch_unwind
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\panic.rs:394
  23: std::rt::lang_start_internal
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\/src\libstd\rt.rs:48
  24: std::rt::lang_start<()>
             at /rustc/69656fa4cbafc378fd63f9186d93b0df3cdd9320\src\libstd\rt.rs:64
  25: main
  26: invoke_main
             at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  27: __scrt_common_main_seh
             at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  28: BaseThreadInitThunk
  29: RtlUserThreadStart
error: process didn't exit successfully: `target\debug\silicon.exe main.rs -o test.png` (exit code: 101)

After replacing all unwrap()s I identified the following in src\font.rs:286 as the problem:

self.font
            .rasterize_glyph(
                &mut canvas,
                self.id,
                self.size,
                &FontTransform::identity(),
                &origin,
                HintingOptions::None,
                RasterizationOptions::GrayscaleAa,
            )
            .expect("9");

panicked at 'assertion failed: !result.is_null()'

Hi, getting a panic irrespective of the input file I try. Only tested so far on macOS with cargo --version 1.35.0 (6f3e9c367 2019-04-04).

`
-> file test.rs
test.rs: c program text, ASCII text

-> export RUST_BACKTRACE=1 && silicon test.rs -o test.png
thread 'main' panicked at 'assertion failed: !result.is_null()', /Users/jamie/.cargo/registry/src/github.com-1ecc6299db9ec823/core-graphics-0.17.3/src/context.rs:104:13
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::panicking::default_hook::{{closure}}
2: std::panicking::rust_panic_with_hook
3: std::panicking::begin_panic
4: font_kit::loaders::core_text::Font::rasterize_glyph
5: silicon::font::FontCollection::draw_text_mut
6: silicon::formatter::ImageFormatter::format
7: silicon::main
8: std::rt::lang_start::{{closure}}
9: main
`

Add Apple Silicon Homebrew missing formula

Overview

Would it be possible to add a Homebrew formula for Apple Silcon machines?

Steps to Recreate

On a Apple Silicon machine, try running:

brew install silicon

You'll then get the following error:

Warning: Treating silicon as a formula. For the cask, use homebrew/cask/silicon
Error: silicon: no bottle available!

Desired Behavior

Would be nice to install Silicon via Homebrew without error.

Environment

macOS 11.2.1 (20D75)
MacBook Air (M1, 2020)

Build failed on Linux Mint

I'm on Linux Mint 19.3 and I got a build failed error.

$ cargo install silicon
    Updating crates.io index
  Downloaded silicon v0.3.1
  Downloaded 1 crate (1.5 MB) in 3.07s
  Installing silicon v0.3.1
  Downloaded clipboard v0.5.0
  Downloaded font-kit v0.6.0
  Downloaded syntect v4.1.1
  Downloaded env_logger v0.7.1
  Downloaded failure v0.1.8
  Downloaded pathfinder_geometry v0.5.1
  Downloaded structopt v0.3.14
  Downloaded log v0.4.8
  Downloaded image v0.23.4
  Downloaded lazy_static v1.4.0
  Downloaded conv v0.3.3
  Downloaded tempfile v3.1.0
  Downloaded pathfinder_simd v0.5.0
  Downloaded clap v2.33.1
  Downloaded plist v0.5.5
  Downloaded structopt-derive v0.4.7
  Downloaded backtrace v0.3.48
  Downloaded serde v1.0.110
  Downloaded serde_derive v1.0.110
  Downloaded termcolor v1.1.0
  Downloaded humantime v1.3.0
  Downloaded walkdir v2.3.1
  Downloaded float-ord v0.2.0
  Downloaded bincode v1.2.1
  Downloaded dirs v2.0.2
  Downloaded byteorder v1.3.4
  Downloaded serde_json v1.0.53
  Downloaded bitflags v1.2.1
  Downloaded cfg-if v0.1.10
  Downloaded atty v0.2.14
  Downloaded regex v1.3.7
  Downloaded libc v0.2.70
  Downloaded regex-syntax v0.6.17
  Downloaded fnv v1.0.7
  Downloaded flate2 v1.0.14
  Downloaded failure_derive v0.1.8
  Downloaded imageproc v0.20.0
  Downloaded onig v5.0.0
  Downloaded servo-fontconfig v0.4.0
  Downloaded lazycell v1.2.1
  Downloaded x11-clipboard v0.3.3
  Downloaded freetype v0.4.1
  Downloaded thread_local v1.0.1
  Downloaded quote v1.0.5
  Downloaded same-file v1.0.6
  Downloaded num-traits v0.2.11
  Downloaded ryu v1.0.4
  Downloaded vec_map v0.8.2
  Downloaded rand v0.7.3
  Downloaded dirs-sys v0.3.4
  Downloaded rulinalg v0.4.2
  Downloaded jpeg-decoder v0.1.19
  Downloaded xml-rs v0.8.3
  Downloaded rand_distr v0.2.2
  Downloaded itertools v0.8.2
  Downloaded onig_sys v69.5.0
  Downloaded aho-corasick v0.7.10
  Downloaded memchr v2.3.3
  Downloaded ansi_term v0.11.0
  Downloaded unicode-width v0.1.7
  Downloaded proc-macro-error v1.0.2
  Downloaded textwrap v0.11.0
  Downloaded remove_dir_all v0.5.2
  Downloaded strsim v0.8.0
  Downloaded term_size v0.3.2
  Downloaded rustc_version v0.2.3
  Downloaded syn v1.0.22
  Downloaded png v0.16.3
  Downloaded quick-error v1.2.3
  Downloaded addr2line v0.12.0
  Downloaded proc-macro2 v1.0.13
  Downloaded num-iter v0.1.40
  Downloaded itoa v0.4.5
  Downloaded miniz_oxide v0.3.6
  Downloaded object v0.19.0
  Downloaded chrono v0.4.11
  Downloaded base64 v0.10.1
  Downloaded crc32fast v1.2.0
  Downloaded heck v0.3.1
  Downloaded rusttype v0.8.3
  Downloaded num v0.2.1
  Downloaded indexmap v1.3.2
  Downloaded rustc-demangle v0.1.16
  Downloaded bytemuck v1.2.0
  Downloaded num-rational v0.2.4
  Downloaded autocfg v1.0.0
  Downloaded cc v1.0.53
  Downloaded unicode-segmentation v1.6.0
  Downloaded adler32 v1.0.4
  Downloaded either v1.5.3
  Downloaded num-bigint v0.2.6
  Downloaded rand_core v0.5.1
  Downloaded rand_chacha v0.2.2
  Downloaded num-integer v0.1.42
  Downloaded gimli v0.21.0
  Downloaded synstructure v0.12.3
  Downloaded inflate v0.4.5
  Downloaded servo-fontconfig-sys v4.0.9
  Downloaded deflate v0.8.4
  Downloaded line-wrap v0.1.1
  Downloaded matrixmultiply v0.1.15
  Downloaded custom_derive v0.1.7
  Downloaded xcb v0.8.2
  Downloaded num-complex v0.2.4
  Downloaded version_check v0.9.1
  Downloaded semver v0.9.0
  Downloaded unicode-xid v0.2.0
  Downloaded bindgen v0.53.2
  Downloaded proc-macro-error-attr v1.0.2
  Downloaded num v0.1.42
  Downloaded getrandom v0.1.14
  Downloaded ordered-float v1.0.2
  Downloaded pkg-config v0.3.17
  Downloaded approx v0.3.2
  Downloaded rayon v1.3.0
  Downloaded ppv-lite86 v0.2.8
  Downloaded safemem v0.3.3
  Downloaded shlex v0.1.1
  Downloaded rustc-hash v1.1.0
  Downloaded stb_truetype v0.3.1
  Downloaded rawpointer v0.1.0
  Downloaded cexpr v0.4.0
  Downloaded which v3.1.1
  Downloaded semver-parser v0.7.0
  Downloaded peeking_take_while v0.1.2
  Downloaded syn-mid v0.5.0
  Downloaded clang-sys v0.29.3
  Downloaded crossbeam-deque v0.7.3
  Downloaded maybe-uninit v2.0.0
  Downloaded crossbeam-utils v0.7.2
  Downloaded glob v0.3.0
  Downloaded expat-sys v2.1.6
  Downloaded servo-freetype-sys v4.0.5
  Downloaded nom v5.1.1
  Downloaded rayon-core v1.7.0
  Downloaded libloading v0.5.2
  Downloaded crossbeam-epoch v0.8.2
  Downloaded cmake v0.1.43
  Downloaded num_cpus v1.13.0
  Downloaded scopeguard v1.1.0
  Downloaded crossbeam-queue v0.2.1
  Downloaded memoffset v0.5.4
   Compiling autocfg v1.0.0
   Compiling libc v0.2.70
   Compiling cfg-if v0.1.10
   Compiling cc v1.0.53
   Compiling lazy_static v1.4.0
   Compiling proc-macro2 v1.0.13
   Compiling unicode-xid v0.2.0
   Compiling version_check v0.9.1
   Compiling pkg-config v0.3.17
   Compiling log v0.4.8
   Compiling byteorder v1.3.4
   Compiling bitflags v1.2.1
   Compiling memchr v2.3.3
   Compiling syn v1.0.22
   Compiling glob v0.3.0
   Compiling maybe-uninit v2.0.0
   Compiling unicode-width v0.1.7
   Compiling regex-syntax v0.6.17
   Compiling adler32 v1.0.4
   Compiling quick-error v1.2.3
   Compiling getrandom v0.1.14
   Compiling vec_map v0.8.2
   Compiling ansi_term v0.11.0
   Compiling strsim v0.8.0
   Compiling crc32fast v1.2.0
   Compiling termcolor v1.1.0
   Compiling bindgen v0.53.2
   Compiling scopeguard v1.1.0
   Compiling semver-parser v0.7.0
   Compiling lazycell v1.2.1
   Compiling serde v1.0.110
   Compiling peeking_take_while v0.1.2
   Compiling shlex v0.1.1
   Compiling rayon-core v1.7.0
   Compiling rustc-hash v1.1.0
   Compiling either v1.5.3
   Compiling ppv-lite86 v0.2.8
   Compiling matrixmultiply v0.1.15
   Compiling ryu v1.0.4
   Compiling same-file v1.0.6
   Compiling safemem v0.3.3
   Compiling rawpointer v0.1.0
   Compiling gimli v0.21.0
   Compiling failure_derive v0.1.8
   Compiling unicode-segmentation v1.6.0
   Compiling itoa v0.4.5
   Compiling rustc-demangle v0.1.16
   Compiling object v0.19.0
   Compiling custom_derive v0.1.7
   Compiling bytemuck v1.2.0
   Compiling xml-rs v0.8.3
   Compiling fnv v1.0.7
   Compiling remove_dir_all v0.5.2
   Compiling float-ord v0.2.0
   Compiling thread_local v1.0.1
   Compiling cmake v0.1.43
   Compiling num-traits v0.2.11
   Compiling num-integer v0.1.42
   Compiling crossbeam-utils v0.7.2
   Compiling memoffset v0.5.4
   Compiling crossbeam-epoch v0.8.2
   Compiling num-iter v0.1.40
   Compiling num-bigint v0.2.6
   Compiling num-rational v0.2.4
   Compiling num-complex v0.2.4
   Compiling indexmap v1.3.2
   Compiling nom v5.1.1
   Compiling proc-macro-error-attr v1.0.2
   Compiling proc-macro-error v1.0.2
   Compiling servo-fontconfig-sys v4.0.9
   Compiling inflate v0.4.5
   Compiling miniz_oxide v0.3.6
   Compiling humantime v1.3.0
   Compiling clang-sys v0.29.3
   Compiling libloading v0.5.2
   Compiling semver v0.9.0
   Compiling itertools v0.8.2
   Compiling walkdir v2.3.1
   Compiling line-wrap v0.1.1
   Compiling heck v0.3.1
   Compiling conv v0.3.3
   Compiling addr2line v0.12.0
   Compiling servo-freetype-sys v4.0.5
   Compiling expat-sys v2.1.6
   Compiling rustc_version v0.2.3
   Compiling quote v1.0.5
   Compiling term_size v0.3.2
   Compiling atty v0.2.14
   Compiling which v3.1.1
   Compiling num_cpus v1.13.0
   Compiling dirs-sys v0.3.4
   Compiling backtrace v0.3.48
   Compiling xcb v0.8.2
error: failed to run custom build command for `servo-freetype-sys v4.0.5`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installJTTeRJ/release/build/servo-freetype-sys-4d260bf0b0d4b432/build-script-build` (ex
it code: 101)
--- stdout
running: "cmake" "/home/nimitz/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-freetype-sys-4.0.5/freetype2" "-DWITH_BZip2=OFF" "
-DWITH_HarfBuzz=OFF" "-DWITH_PNG=OFF" "-DWITH_ZLIB=OFF" "-DCMAKE_INSTALL_PREFIX=/tmp/cargo-installJTTeRJ/release/build/servo-freetype-s
ys-0647af25cf1ab4e7/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CX
X_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -f
data-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"

--- stderr
thread 'main' panicked at '
failed to execute command: No such file or directory (os error 2)
is `cmake` not installed?

build script failed, must exit now', /home/nimitz/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.43/src/lib.rs:1104:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `silicon v0.3.1`, intermediate artifacts can be found at `/tmp/cargo-installJTTeRJ`

Caused by:
  build failed

After looking at the error message, I thought it might be because I didn't have cmake, so I ran
sudo apt install cmake then tried installing silicon again

The output log is different now but still build failed

$ cargo install silicon
    Updating crates.io index
  Installing silicon v0.3.1
   Compiling autocfg v1.0.0
   Compiling libc v0.2.70
   Compiling cfg-if v0.1.10
   Compiling cc v1.0.53
   Compiling lazy_static v1.4.0
   Compiling proc-macro2 v1.0.13
   Compiling unicode-xid v0.2.0
   Compiling version_check v0.9.1
   Compiling pkg-config v0.3.17
   Compiling bitflags v1.2.1
   Compiling log v0.4.8
   Compiling byteorder v1.3.4
   Compiling memchr v2.3.3
   Compiling syn v1.0.22
   Compiling glob v0.3.0
   Compiling maybe-uninit v2.0.0
   Compiling unicode-width v0.1.7
   Compiling getrandom v0.1.14
   Compiling strsim v0.8.0
   Compiling adler32 v1.0.4
   Compiling quick-error v1.2.3
   Compiling regex-syntax v0.6.17
   Compiling vec_map v0.8.2
   Compiling ansi_term v0.11.0
   Compiling crc32fast v1.2.0
   Compiling termcolor v1.1.0
   Compiling semver-parser v0.7.0
   Compiling bindgen v0.53.2
   Compiling scopeguard v1.1.0
   Compiling rayon-core v1.7.0
   Compiling shlex v0.1.1
   Compiling peeking_take_while v0.1.2
   Compiling lazycell v1.2.1
   Compiling serde v1.0.110
   Compiling rustc-hash v1.1.0
   Compiling ppv-lite86 v0.2.8
   Compiling either v1.5.3
   Compiling ryu v1.0.4
   Compiling matrixmultiply v0.1.15
   Compiling safemem v0.3.3
   Compiling rawpointer v0.1.0
   Compiling same-file v1.0.6
   Compiling gimli v0.21.0
   Compiling failure_derive v0.1.8
   Compiling unicode-segmentation v1.6.0
   Compiling itoa v0.4.5
   Compiling xml-rs v0.8.3
   Compiling rustc-demangle v0.1.16
   Compiling custom_derive v0.1.7
   Compiling bytemuck v1.2.0
   Compiling object v0.19.0
   Compiling fnv v1.0.7
   Compiling remove_dir_all v0.5.2
   Compiling float-ord v0.2.0
   Compiling thread_local v1.0.1
   Compiling cmake v0.1.43
   Compiling num-traits v0.2.11
   Compiling num-integer v0.1.42
   Compiling crossbeam-utils v0.7.2
   Compiling memoffset v0.5.4
   Compiling crossbeam-epoch v0.8.2
   Compiling num-iter v0.1.40
   Compiling num-bigint v0.2.6
   Compiling num-rational v0.2.4
   Compiling num-complex v0.2.4
   Compiling indexmap v1.3.2
   Compiling nom v5.1.1
   Compiling proc-macro-error-attr v1.0.2
   Compiling proc-macro-error v1.0.2
   Compiling servo-fontconfig-sys v4.0.9
   Compiling inflate v0.4.5
   Compiling miniz_oxide v0.3.6
   Compiling humantime v1.3.0
   Compiling clang-sys v0.29.3
   Compiling semver v0.9.0
   Compiling libloading v0.5.2
   Compiling itertools v0.8.2
   Compiling line-wrap v0.1.1
   Compiling walkdir v2.3.1
   Compiling heck v0.3.1
   Compiling conv v0.3.3
   Compiling addr2line v0.12.0
   Compiling servo-freetype-sys v4.0.5
   Compiling expat-sys v2.1.6
   Compiling rustc_version v0.2.3
   Compiling atty v0.2.14
   Compiling term_size v0.3.2
   Compiling which v3.1.1
   Compiling num_cpus v1.13.0
   Compiling dirs-sys v0.3.4
   Compiling backtrace v0.3.48
   Compiling quote v1.0.5
   Compiling xcb v0.8.2
   Compiling flate2 v1.0.14
   Compiling aho-corasick v0.7.10
   Compiling deflate v0.8.4
   Compiling stb_truetype v0.3.1
   Compiling base64 v0.10.1
   Compiling pathfinder_simd v0.5.0
   Compiling crossbeam-queue v0.2.1
   Compiling ordered-float v1.0.2
   Compiling approx v0.3.2
   Compiling textwrap v0.11.0
   Compiling rand_core v0.5.1
   Compiling dirs v2.0.2
   Compiling serde_json v1.0.53
   Compiling bincode v1.2.1
   Compiling regex v1.3.7
   Compiling png v0.16.3
   Compiling cexpr v0.4.0
   Compiling chrono v0.4.11
   Compiling rusttype v0.8.3
   Compiling clap v2.33.1
   Compiling rand_chacha v0.2.2
   Compiling crossbeam-deque v0.7.3
   Compiling syn-mid v0.5.0
   Compiling synstructure v0.12.3
error: failed to run custom build command for `servo-fontconfig-sys v4.0.9`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installGuA0Lu/release/build/servo-fontconfig-sys-c296d4713b958eb5/build-script-build` (
exit code: 101)
--- stdout
cd /tmp/cargo-installGuA0Lu/release/build/servo-fontconfig-sys-64aad6040608dd65/out && \
        CC="gcc" \
        AR="ar" \
        FREETYPE_CFLAGS="" \
        FREETYPE_LIBS="" \
        CFLAGS=""" -fPIC" \
        /home/nimitz/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-4.0.9/configure \
        --disable-docs \
        --disable-shared \
         \
        --host=x86_64-unknown-linux-gnu --sysconfdir=/etc --localstatedir=/var && \
        touch /home/nimitz/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-4.0.9/src/fcobjshash.h
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-unknown-linux-gnu-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for x86_64-unknown-linux-gnu-gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for x86_64-unknown-linux-gnu-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for RM macro... rm -f
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for x86_64-unknown-linux-gnu-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for x86_64-unknown-linux-gnu-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for x86_64-unknown-linux-gnu-ar... ar
checking for archiver @FILE support... @
checking for x86_64-unknown-linux-gnu-strip... strip
checking for x86_64-unknown-linux-gnu-ranlib... no
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for x86_64-unknown-linux-gnu-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... cflags:  -fPIC
cppflags:
ldflags:  -Wl,-rpath -Wl,/foo
libs:
GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... cflags:  -fPIC
cppflags:
ldflags:
libs:
none required
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking regex.h usability... yes
checking regex.h presence... yes
checking for regex.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking sys/statvfs.h usability... yes
checking sys/statvfs.h presence... yes
checking for sys/statvfs.h... yes
checking sys/vfs.h usability... yes
checking sys/vfs.h presence... yes
checking for sys/vfs.h... yes
checking sys/statfs.h usability... yes
checking sys/statfs.h presence... yes
checking for sys/statfs.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/mount.h usability... yes
checking sys/mount.h presence... yes
checking for sys/mount.h... yes
checking for stdint types... stdint.h (shortcircuit)
make use of stdint.h in src/fcstdint.h (assuming C99 compatible system)
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for flexible array members... yes
checking for pid_t... yes
checking for vprintf... cflags:  -fPIC
cppflags:
ldflags:
libs:
conftest.c:65:6: warning: conflicting types for built-in function 'vprintf' [-Wbuiltin-declaration-mismatch]
 char vprintf ();
      ^~~~~~~
yes
checking for _doprnt... cflags:  -fPIC
cppflags:
ldflags:
libs:
/tmp/ccL381YW.o: In function `main':
conftest.c:(.text+0xa): undefined reference to `_doprnt'
collect2: error: ld returned 1 exit status
no
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... (cached) yes
checking for getpagesize... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for working mmap... yes
checking for link... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for mkstemp... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for mkostemp... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for _mktemp_s... cflags:  -fPIC
cppflags:
ldflags:
libs:
/tmp/ccxy6Ros.o: In function `main':
conftest.c:(.text+0xa): undefined reference to `_mktemp_s'
collect2: error: ld returned 1 exit status
no
checking for mkdtemp... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for getopt... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for getopt_long... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for getprogname... cflags:  -fPIC
cppflags:
ldflags:
libs:
/tmp/ccvquLmG.o: In function `main':
conftest.c:(.text+0xa): undefined reference to `getprogname'
collect2: error: ld returned 1 exit status
no
checking for getexecname... cflags:  -fPIC
cppflags:
ldflags:
libs:
/tmp/ccf0bb4M.o: In function `main':
conftest.c:(.text+0xa): undefined reference to `getexecname'
collect2: error: ld returned 1 exit status
no
checking for rand... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for random... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for lrand48... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for random_r... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for rand_r... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for readlink... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for regcomp... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for regerror... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for regexec... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for regfree... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for fstatvfs... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for fstatfs... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for lstat... cflags:  -fPIC
cppflags:
ldflags:
libs:
yes
checking for posix_fadvise in fcntl.h... fcntl.h
checking for scandir... yes
checking for struct statvfs.f_basetype... no
checking for struct statvfs.f_fstypename... no
checking for struct statfs.f_flags... yes
checking for struct statfs.f_fstypename... no
checking for struct dirent.d_type... yes
checking for FREETYPE... no
makefile.cargo:83: recipe for target '/tmp/cargo-installGuA0Lu/release/build/servo-fontconfig-sys-64aad6040608dd65/out/Makefile' failed

--- stderr
configure: error: Package requirements (freetype2) were not met:

No package 'freetype2' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables FREETYPE_CFLAGS
and FREETYPE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
make: *** [/tmp/cargo-installGuA0Lu/release/build/servo-fontconfig-sys-64aad6040608dd65/out/Makefile] Error 1
thread 'main' panicked at 'assertion failed: Command::new("make").env("MAKEFLAGS",
                         env::var("CARGO_MAKEFLAGS").unwrap_or_default()).args(&["-R",
                                                                                 "-f",
                                                                                 "makefile.cargo"]).status().unwrap().success()', /home
/nimitz/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-4.0.9/build.rs:20:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `silicon v0.3.1`, intermediate artifacts can be found at `/tmp/cargo-installGuA0Lu`

Caused by:
  build failed

Silicon 0.4.0 on Big Sur generates empty window frames without text

image

I installed it using cargo install silicon after the latest pasteboard fixes were applied.

I tried adding text via clipboard contents, from file and by entering it directly from stdin. In all cases the output image seems to be sized appropriate to amount of entered text, but the text itself is not visible.

I wonder if this is a problem with fonts or themes, --list-themes as well as --list-fonts output non-empty lists. I've tried both default theme and font and custom theme (zenburn) and a fallback font (Hack).

tabs vs spaces

Hello,
awesome tool :) I did some tests with python and golang code and looks like silicon doesn't like tabs as it removes them rendering all the text aligned to the left (golang forces you to use tabs). Worked fine with python and spaces.

Regards
David

Please describe how to add support for additional languages

First, thank you so much for this, the UX is definitely better than the Carbon CLI tool.

Currently I'm missing support for WebAssembly Text format and I'm not sure how to add support for it in Silicon.

I noticed that you are pulling syntaxes and themes from the bat repository, and support hasn't been added for WebAssembly there yet. However, I was able to locally add support for it in bat following their instructions: https://github.com/sharkdp/bat#adding-new-syntaxes--language-definitions

Is there a way to make silicon use my local bat cache, or a way I can add it to the list of assets?

I thought about making a request to bat about adding support for WebAssembly, but unfortunately it seems they have a requirement of at least 10000 downloads for the syntax package, which is far from the current number of downloads.

Use MSVC toolchain for Windows release builds

The GNU toolchain binary is extremely large (15MB) when compared to MSVC binary (which is just 4.6MB).

Hopefully just changing matrix target in .github/workflows/release.yml from x86_64-pc-windows-gnu to x86_64-pc-windows-msvc should be enough.

v0.4.0 tarball for linux is not compressed by xz

Downloaded silicon-v0.4.0-x86_64-unknown-linux-gnu.tar.xz from GitHub Release, but that seems to be compressed by Gzip.

Shouldn't this file compressed by xz?

I checked by file command:

$ file silicon-v0.4.0-x86_64-unknown-linux-gnu.tar.xz
silicon-v0.4.0-x86_64-unknown-linux-gnu.tar.xz: gzip compressed data, last modified: Tue Dec  1 04:17:45 2020, from Unix, original size modulo 2^32 8755200

Can't compile on FreeBSD

Message:

error: failed to run custom build command for `servo-fontconfig-sys v4.0.7`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installNdcMYr/release/build/servo-fontconfig-sys-43a39c049132ec64/build-script-build` (exit code: 101)
--- stderr
make: illegal argument to -j -- must be positive integer!
thread 'main' panicked at 'assertion failed: Command::new("make").env("MAKEFLAGS",
                         env::var("CARGO_MAKEFLAGS").unwrap_or_default()).args(&["-R",

  "-f",

  "makefile.cargo"]).status().unwrap().success()', /home/kamron/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-4.0.7/build.rs:20:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `silicon v0.2.5`, intermediate artifacts can be found
at `/tmp/cargo-installNdcMYr`

Caused by:
  build failed

Changing the font results in a blank window.

I know that it successfullly chooses the font, because inputting an invalid font errors it out stating as such.
It successfullly makes the image, however it is as the title states.

Command used: silicon projects/github/rsmpc/src/commands/stats.rs -o a/a.png --font "Misc Fixed"

image generated

Allow zero for `--highlight-lines` value

Overview

Would it be possible to allow zero as a safe value for --highlight-lines? Example:

silicon --to-clipboard --highlight-lines 0 example.rb

Essentially, a value of zero would be like a no-op and as if the --highlight-lines option was never used. The reason why this is valuable is for wrapping in a shell script. Without this being possible, the following error happens instead:

Segmentation fault: 11

Screenshots/Screencasts

Here is an example of a shell script that sets --highlight-lines to zero as a default option which will fail with the above mentioned error. It would be nice to allow zero in this situation.

image

Steps to Recreate

touch example.rb
silicon --to-clipboard --highlight-lines 0 example.rb

Desired Behavior

Don't throw a segfault and ignore --highlight-lines instead since it's a no-op.

Highlight-lines range is not inclusive

This code:

echo "a\nb" | silicon --output foo.png --highlight-lines 1-2 --language python

generates an image with only line 1 highlighted, should it not include line 2 as well?

Silicon GUI

Is there anyone working on a gui for silicon, i would like to implement it myself but i want to know if there is someone working in it or not

Clipboard support

Paste from clipboard

  • Linux
  • Windows
  • macOS

Copy to clipboard:

  • Linux
  • Windows
  • macOS

Consider add more font examples and usage examples

Currently, none of below are working as expected. I could not understand how to use --font flag in correct way. The fonts that described in README is built-in fonts? Can not we give custom font if it already installed?

  • silicon --from-clipboard -l yaml -f "SourceCodePro"
  • silicon --from-clipboard -l yaml -f "SourceCodePro=15"
  • silicon --from-clipboard -l yaml -f "SourceCodePro:15"

Custom fonts:

  • silicon --from-clipboard -l yaml -f "./Downloads/my-custom-font.tff"

And please describe what the purpose of ; in -f flag. (i.e: -f "Hack; SourceCodePro") What Hack; means? What else can be used there? Like, -f "Nerd; JetBrainsMono=15" are correct?

You give an example in font.rs but it is not included in fonts folder. It would be great if you create a new flag called: --list-available-fonts.

Versions release

Hey!

I've just pushed an AUR package of this awesome app (https://aur.archlinux.org/packages/silicon).

During the process of building this package I had one problem - there are no tags or releases (which basically are tags) for the versions of the application. I have to find a commit which was version bump and then use it in the package build process.

Would it be possible to start using GH release feature? It will help me keeping package up-to-date in the AUR repository.

Thanks!

Failed to build on macOS Big Sur

Problem

When I executed cargo build after git clone, I failed to build this app. It would be happy if someone tells me the right way to build this app.

Environment

I'm using macOS Big Sur(ver 11.5.1) and cpu architecture is x86_64.

Error Code

$ cargo build
Compiling silicon v0.4.3 (/Users/takumi-hiraoka/Desktop/random/Rust/silicon)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "/Users/takumi-hiraoka/Desktop/random/Rust/silicon/target/debug/deps/silicon-a1e281541b9a39f5.10mc5iith8mwzgad.rcgu.o" "/Users/takumi-hiraoka/Desktop/random/Rust/silicon/target/debug/deps/silicon-a1


........


-a1e281541b9a39f5" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: Undefined symbols for architecture x86_64:
            "_hb_ft_font_create_referenced", referenced from:
                silicon::hb_wrapper::HBFont::new::h27e7d5a669e03833 in libsilicon-f6c626f48a5b9ff1.rlib(silicon-f6c626f48a5b9ff1.2vayxsm15825wt5q.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `silicon` due to previous error

Command xcode-select --install has been executed.

I will learn Rust through this software and I want to contribute this software. So I want to succeed to build.

Custom languages not detected by silicon but detected by bat

Hey there! I'm running the latest silicon version from Homebrew.

My bat config directory is:

$ bat --config-dir
/Users/jviotti/.config/bat

I placed various files inside the syntaxes directory:

$ ls /Users/jviotti/.config/bat/syntaxes
asn.sublime-syntax        capnproto.sublime-syntax  thrift.sublime-syntax

Which bat seems to detect correctly:

$ bat --list-languages
...
ASN                               asn
...
Cap'n Proto                       capnp
...
Thrift                            thrift

However silicon fails when trying to render a file with one of those languages:

$ silicon schema.thrift -o out.png --background '#ffffff' \
                --no-window-controls --no-line-number --theme GitHub --language thrift \
                --pad-horiz 20 --pad-vert 20
[error] Unsupported language: thrift

Am I missing something?

Add --select-lines option

Overview

Would it be possible to allow Silicon to specify the lines of a file to screenshot in addition to the lines highlighted? I ask because I often find I want to select a snippet of code for illustration and sharing but also highlight maybe a line or two within the selected lines.

Screenshots/Screencasts

Firefox-xdgenvironment rb at master · bkuhlmannxdg-Xkw0X6IP

Steps to Recreate

At the moment, I have to do the following:

  1. Copy Lines 11-13 to a file called snippet.rb.
  2. Run: silicon --language rb --highlight-lines 2 --to-clipboard snippet.rb
  3. Run: rm -f snippet.rb.

Example result (with a few more options thrown in not shown above):

image

Desired Behavior

It would be neat to simplify the steps presented above to a single step. Example:

  1. Run: silicon --language rb --select-lines 11-13 --highlight-lines 12 --to-clipboard lib/xdg/environment.rb

It could also be handy to have an option for --line-count-start 1 in case someone didn't want the count to start at 11 from the original source but start at 1 instead.

v0.4.0 tarball sha256 change?

I'm attempting to update Homebrew's version of Rust (Homebrew/homebrew-core#66285).

While testing the new version, CI produced the following error:

==> brew install --build-from-source silicon
==> FAILED
==> Downloading https://github.com/Aloxaf/silicon/archive/v0.4.0.tar.gz
==> Downloading from https://codeload.github.com/Aloxaf/silicon/tar.gz/v0.4.0
Error: SHA256 mismatch
Expected: 1534b7b4b5a309cf7f79132f3cd5fd7987642735ca7845efb1ec93df685a402d
  Actual: 423c03d9c92cbad8f5a136abaa680e85dfa5b5f31998aab4424c335d4d99b7ab

I can update the sha256 associated with silicon, but CI will come back to me with the following error:

silicon:
  * stable sha256 changed without the url/version also changing; please create an issue upstream to rule out malicious circumstances and to find out why the file changed.

Can I confirm that nothing is amiss here?

Wrapping long lines

Is there a way to wrap long lines? Currently, it generates a very wide image in such a case.

Add config file

I wish there was a config file that could adjust the default values of the program's arguments. like
On Linux
$XDG_CONFIG_HOME/silicon/config.toml
or
$XDG_CONFIG_HOME/silicon/settings.toml
On Windows
%APPDATA%\silicon\config.toml
or
%APPDATA%\silicon\settings.toml

Feature request: drop shadow

Not much more to say about this than the title — drop shadows can be nice.

I'd imagine the following user-facing settings may be of interest:

  • --drop-shadow-radius which would probably be an integer, disabled when 0
  • --drop-shadow-offset which probably would accept either a y-value or x,y

Thanks for the great work so far! 😃

Font ligatures

Support ligatures, like in Fira Code, JetBrains Mono, Iosevka etc.

Transparent background

Currently, all transparency are hardcoded to 0xff:

silicon/src/utils.rs

Lines 27 to 32 in c277f1a

Ok(Rgba([
((rgb >> 16) & 0xff) as u8,
((rgb >> 8) & 0xff) as u8,
(rgb & 0xff) as u8,
0xff,
]))

There should be a switch to toggle the background transparency so that the output image can be readily used without concerns of background color.

I can think of are two way to implement this:

  1. Change the RGBA parsing so that the alpha will also be parsed. This may involves extra handling of RGB string. This may allow transparent theme in the future.
  2. Create a new boolean argument so that it will override the alpha setting in Config.background. This likely will involve some processing outside of the struct declaration.

I would like to invite comments from everyone for how to proceed.

Throw err when set --font

err:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/font.rs:157:34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

config file:

--font '苹方-简'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.