]> git.imager.perl.org - imager.git/blobdiff - T1/imt1.c
[rt #69879] various T1 improvments
[imager.git] / T1 / imt1.c
index 1c4a1a7b9507c8f9a8cf6ec3064bf7912c47f0fb..3027e424373c3aef7405d51c30ef58acad9b5095 100644 (file)
--- a/T1/imt1.c
+++ b/T1/imt1.c
@@ -34,6 +34,7 @@ i_init_t1(int t1log) {
 
   if (t1_initialized) {
     T1_CloseLib();
+    t1_initialized = 0;
   }
   
   if (t1log)
@@ -92,6 +93,7 @@ i_t1_new(char *pfb,char *afm) {
   font_id = T1_AddFont(pfb);
   if (font_id<0) {
     mm_log((1,"i_t1_new: Failed to load pfb file '%s' - return code %d.\n",pfb,font_id));
+    t1_push_error();
     return font_id;
   }
   
@@ -100,8 +102,18 @@ i_t1_new(char *pfb,char *afm) {
     if (T1_SetAfmFileName(font_id,afm)<0) mm_log((1,"i_t1_new: afm loading of '%s' failed.\n",afm));
   }
 
+  if (T1_LoadFont(font_id)) {
+    mm_log((1, "i_t1_new() -> -1 - T1_LoadFont failed (%d)\n", T1_errno));
+    t1_push_error();
+    i_push_error(0, "loading font");
+    T1_DeleteFont(font_id);
+    return -1;
+  }
+
   ++t1_active_fonts;
 
+  mm_log((1, "i_t1_new() -> %d\n", font_id));
+
   return font_id;
 }
 
@@ -571,6 +583,10 @@ i_t1_glyph_name(int font_num, unsigned long ch, char *name_buf,
 
 static void
 t1_push_error(void) {
+#if T1LIB_VERSION > 5 || T1LIB_VERSION == 5 && T1LIB_VERSION >= 1
+  /* I don't know when T1_StrError() was introduced, be conservative */
+  i_push_error(T1_errno, T1_StrError(T1_errno));
+#else
   switch (T1_errno) {
   case 0: 
     i_push_error(0, "No error"); 
@@ -681,5 +697,6 @@ t1_push_error(void) {
   default:
     i_push_errorf(T1_errno, "unknown error %d", (int)T1_errno);
   }
+#endif
 }