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:
erick-alcachofa 2025-04-26 22:39:08 -06:00
parent cae76380fa
commit bd1f097e1b
Signed by: me
GPG Key ID: 6FA5F8643444BAFA

View File

@ -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;