@@ -7,7 +7,7 @@ pub use error::OgImageError;
77
88use crate :: formatting:: { serialize_bytes, serialize_number, serialize_optional_number} ;
99use bytes:: Bytes ;
10- use crates_io_env_vars:: var ;
10+ use crates_io_env_vars:: var_parsed ;
1111use serde:: Serialize ;
1212use std:: collections:: HashMap ;
1313use std:: path:: PathBuf ;
@@ -109,19 +109,28 @@ impl OgImageGenerator {
109109 /// # Ok::<(), crates_io_og_image::OgImageError>(())
110110 /// ```
111111 pub fn from_environment ( ) -> Result < Self , OgImageError > {
112- let typst_path = var ( "TYPST_PATH" ) . map_err ( OgImageError :: EnvVarError ) ?;
113- let font_path = var ( "TYPST_FONT_PATH" ) . map_err ( OgImageError :: EnvVarError ) ?;
114-
115- let mut generator = if let Some ( path) = typst_path {
116- Self :: new ( PathBuf :: from ( path) )
112+ let typst_path = var_parsed :: < PathBuf > ( "TYPST_PATH" ) ;
113+ let typst_path = typst_path. map_err ( OgImageError :: EnvVarError ) ?;
114+ let font_path = var_parsed :: < PathBuf > ( "TYPST_FONT_PATH" ) ;
115+ let font_path = font_path. map_err ( OgImageError :: EnvVarError ) ?;
116+
117+ let mut generator = if let Some ( typst_path) = typst_path {
118+ println ! ( "Using TYPST_PATH: {}" , typst_path. display( ) ) ;
119+ Self :: new ( typst_path)
117120 } else {
121+ println ! ( "TYPST_PATH not set, using default 'typst' binary in PATH" ) ;
118122 Self :: default ( )
119123 } ;
120124
121125 if let Some ( font_path) = font_path {
126+ println ! ( "Using TYPST_FONT_PATH: {}" , font_path. display( ) ) ;
122127 let current_dir = std:: env:: current_dir ( ) ?;
128+ dbg ! ( & current_dir) ;
123129 let font_path = current_dir. join ( font_path) . canonicalize ( ) ?;
130+ dbg ! ( & font_path) ;
124131 generator = generator. with_font_path ( font_path) ;
132+ } else {
133+ println ! ( "TYPST_FONT_PATH not set, using default font discovery" ) ;
125134 }
126135
127136 Ok ( generator)
@@ -325,6 +334,8 @@ impl Default for OgImageGenerator {
325334#[ cfg( test) ]
326335mod tests {
327336 use super :: * ;
337+ use tracing:: subscriber;
338+ use tracing_subscriber:: fmt;
328339
329340 const fn author ( name : & str ) -> OgImageAuthorData < ' _ > {
330341 OgImageAuthorData :: new ( name, None )
@@ -451,6 +462,8 @@ mod tests {
451462
452463 #[ tokio:: test]
453464 async fn test_generate_og_image_snapshot ( ) {
465+ let _guard = subscriber:: set_default ( fmt ( ) . compact ( ) . with_test_writer ( ) . finish ( ) ) ;
466+
454467 let data = create_simple_test_data ( ) ;
455468
456469 if let Some ( image_data) = generate_image ( data) . await {
@@ -460,6 +473,8 @@ mod tests {
460473
461474 #[ tokio:: test]
462475 async fn test_generate_og_image_overflow_snapshot ( ) {
476+ let _guard = subscriber:: set_default ( fmt ( ) . compact ( ) . with_test_writer ( ) . finish ( ) ) ;
477+
463478 let data = create_overflow_test_data ( ) ;
464479
465480 if let Some ( image_data) = generate_image ( data) . await {
@@ -469,6 +484,8 @@ mod tests {
469484
470485 #[ tokio:: test]
471486 async fn test_generate_og_image_minimal_snapshot ( ) {
487+ let _guard = subscriber:: set_default ( fmt ( ) . compact ( ) . with_test_writer ( ) . finish ( ) ) ;
488+
472489 let data = create_minimal_test_data ( ) ;
473490
474491 if let Some ( image_data) = generate_image ( data) . await {
@@ -478,6 +495,8 @@ mod tests {
478495
479496 #[ tokio:: test]
480497 async fn test_generate_og_image_escaping_snapshot ( ) {
498+ let _guard = subscriber:: set_default ( fmt ( ) . compact ( ) . with_test_writer ( ) . finish ( ) ) ;
499+
481500 let data = create_escaping_test_data ( ) ;
482501
483502 if let Some ( image_data) = generate_image ( data) . await {
0 commit comments