forked from mirror/presenterm
feat: added quick dirty workaround to customize export font
Added a quick dirty workaround that uses environment variable `PRESENTERM_EXPORT_FONT` to set the a custom font when exporting to pdf
This commit is contained in:
parent
cae76380fa
commit
bd1f097e1b
@ -18,7 +18,7 @@ use crate::{
|
||||
};
|
||||
use image::{ImageEncoder, codecs::png::PngEncoder};
|
||||
use std::{
|
||||
fs, io,
|
||||
fs, io,env,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
@ -165,6 +165,12 @@ impl PdfRender {
|
||||
let width = (self.dimensions.columns as f64 * FONT_SIZE as f64 * FONT_SIZE_WIDTH).ceil();
|
||||
let height = self.dimensions.rows * LINE_HEIGHT;
|
||||
let background_color = self.background_color.unwrap_or_else(|| "black".into());
|
||||
|
||||
let font_family = match env::var("PRESENTERM_EXPORT_FONT") {
|
||||
Ok(val) => format!(r"font-family: {val} !important;"),
|
||||
Err(_) => format!(r""),
|
||||
};
|
||||
|
||||
let css = format!(
|
||||
r"
|
||||
pre {{
|
||||
@ -184,6 +190,10 @@ impl PdfRender {
|
||||
width: {width}px;
|
||||
}}
|
||||
|
||||
body * {{
|
||||
{font_family}
|
||||
}}
|
||||
|
||||
.content-line {{
|
||||
line-height: {LINE_HEIGHT}px;
|
||||
height: {LINE_HEIGHT}px;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user