From fc8d119347508de9bfab72edd783f83179d6fdce Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 2 Jul 2024 18:17:00 +0100 Subject: [PATCH] Fix missing_fonts for Type3 --- cpdffont.ml | 21 ++++++++++++--------- cpdfua.ml | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cpdffont.ml b/cpdffont.ml index 7c75d3d..a6f72bc 100644 --- a/cpdffont.ml +++ b/cpdffont.ml @@ -84,18 +84,21 @@ let copy_font frompdf fontname fontpage range pdf = (* Missing Fonts *) let is_missing pdf dict = - match Pdf.lookup_direct pdf "/FontDescriptor" dict with - | None -> true - | Some d -> - match Pdf.lookup_direct pdf "/FontFile" d with - | Some _ -> false - | None -> - match Pdf.lookup_direct pdf "/FontFile2" d with + match Pdf.lookup_direct pdf "/Subtype" dict with + | Some (Pdf.Name "/Type3") -> false + | _ -> + match Pdf.lookup_direct pdf "/FontDescriptor" dict with + | None -> true + | Some d -> + match Pdf.lookup_direct pdf "/FontFile" d with | Some _ -> false | None -> - match Pdf.lookup_direct pdf "/FontFile3" d with + match Pdf.lookup_direct pdf "/FontFile2" d with | Some _ -> false - | None -> true + | None -> + match Pdf.lookup_direct pdf "/FontFile3" d with + | Some _ -> false + | None -> true let missing_font ?l pdf page (name, dict) = if is_missing pdf dict then diff --git a/cpdfua.ml b/cpdfua.ml index 1cec903..809394c 100644 --- a/cpdfua.ml +++ b/cpdfua.ml @@ -977,7 +977,6 @@ let matterhorn_31_008 _ _ pdf = (* NB This, for now, reports all unembedded fonts, save for Type 3 ones... *) let matterhorn_31_009 _ _ pdf = let l = Cpdffont.missing_fonts_return pdf (ilist 1 (Pdfpage.endpage pdf)) in - let l = lose (function (_, _, "/Type3", _, _) -> true | _ -> false) l in if l <> [] then raise (MatterhornError (`List (map (fun (a, b, c, d, e) -> `String (Printf.sprintf "%i %s %s %s %s" a b c d e)) l)))