diff options
author | jelemux <jeremias.weber@protonmail.com> | 2020-10-20 01:09:47 +0200 |
---|---|---|
committer | jelemux <jeremias.weber@protonmail.com> | 2020-10-20 01:09:47 +0200 |
commit | f267433455dbc69e771b06dd7c433c90ad978d33 (patch) | |
tree | 1ff4a90bec2dd80f7115ce2317d093efad404db4 /src/pdfgen.rs | |
parent | 3a0a55362fd98c74bfb14df320bcacafd0c57835 (diff) | |
download | wasm-card-f267433455dbc69e771b06dd7c433c90ad978d33.tar.gz wasm-card-f267433455dbc69e771b06dd7c433c90ad978d33.tar.bz2 |
made it work
Diffstat (limited to 'src/pdfgen.rs')
-rw-r--r-- | src/pdfgen.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/pdfgen.rs b/src/pdfgen.rs index 410bb99..0bca467 100644 --- a/src/pdfgen.rs +++ b/src/pdfgen.rs @@ -2,19 +2,24 @@ use genpdf::Element as _; use genpdf::{elements, style, fonts}; pub fn genpdf() -> Vec<u8> { - let regular_bytes = include_bytes!("../fonts/fira-sans.regular.ttf"); - let regular_font_data = fonts::FontData::new(regular_bytes.to_vec(), None).expect("font data should be correct"); + let regular_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-Regular.ttf"); + let regular_font_data = fonts::FontData::new(regular_bytes.to_vec(), Some(printpdf::BuiltinFont::Helvetica)).expect("font data should be correct"); - let bold_bytes = include_bytes!("../fonts/fira-sans.bold.ttf"); - let bold_font_data = fonts::FontData::new(bold_bytes.to_vec(), None).expect("font data should be correct"); + let bold_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-Bold.ttf"); + let bold_font_data = fonts::FontData::new(bold_bytes.to_vec(), Some(printpdf::BuiltinFont::HelveticaBold)).expect("font data should be correct"); - let italic_bytes = include_bytes!("../fonts/fira-sans.italic.ttf"); - let italic_font_data = fonts::FontData::new(italic_bytes.to_vec(), None).expect("font data should be correct"); + let italic_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-Italic.ttf"); + let italic_font_data = fonts::FontData::new(italic_bytes.to_vec(), Some(printpdf::BuiltinFont::HelveticaOblique)).expect("font data should be correct"); - let bold_italic_bytes = include_bytes!("../fonts/fira-sans.bold-italic.ttf"); - let bold_italic_font_data = fonts::FontData::new(bold_italic_bytes.to_vec(), None).expect("font data should be correct"); + let bold_italic_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf"); + let bold_italic_font_data = fonts::FontData::new(bold_italic_bytes.to_vec(), Some(printpdf::BuiltinFont::HelveticaBoldOblique)).expect("font data should be correct"); - let font_family = fonts::FontFamily{ regular: regular_font_data, bold: bold_font_data, italic: italic_font_data, bold_italic: bold_italic_font_data }; + let font_family = fonts::FontFamily{ + regular: regular_font_data, + bold: bold_font_data, + italic: italic_font_data, + bold_italic: bold_italic_font_data + }; let mut doc = genpdf::Document::new(font_family); |