Getting closer to first truetype fix

This commit is contained in:
John Whitington 2023-06-16 16:11:06 +01:00
parent 9f5e672317
commit b56b147541
1 changed files with 16 additions and 11 deletions

View File

@ -325,14 +325,14 @@ let calculate_widths unitsPerEm encoding firstchar lastchar subset cmapdata hmtx
let calculate_width_higher unitsPerEm firstchar lastchar subset cmapdata hmtxdata = let calculate_width_higher unitsPerEm firstchar lastchar subset cmapdata hmtxdata =
let subset = Array.of_list subset in let subset = Array.of_list subset in
Array.init Array.init
(lastchar - firstchar + 1) (lastchar - firstchar + 1)
(fun pos -> (fun pos ->
let glyphnum = Hashtbl.find cmapdata subset.(pos) in let glyphnum = Hashtbl.find cmapdata subset.(pos) in
if !dbg then Printf.printf "glyph number %i --> " glyphnum; if !dbg then Printf.printf "glyph number %i --> " glyphnum;
let width = hmtxdata.(glyphnum) in let width = hmtxdata.(glyphnum) in
if !dbg then Printf.printf "width %i\n" width; if !dbg then Printf.printf "width %i\n" width;
pdf_unit unitsPerEm width) pdf_unit unitsPerEm width)
let calculate_maxwidth unitsPerEm hmtxdata = let calculate_maxwidth unitsPerEm hmtxdata =
pdf_unit unitsPerEm (hd (sort (fun a b -> compare b a) (Array.to_list hmtxdata))) pdf_unit unitsPerEm (hd (sort (fun a b -> compare b a) (Array.to_list hmtxdata)))
@ -624,9 +624,14 @@ let parse ?(subset=[]) data encoding =
let second_tounicode = let second_tounicode =
if subset = [] then None else if subset = [] then None else
let h = null_hash () in let h = null_hash () in
let s = (implode (tl (tl (explode (Pdftext.utf16be_of_codepoints (tl subset)))))) in (*let s = (implode (tl (tl (explode (Pdftext.utf16be_of_codepoints (tl subset)))))) in*)
Printf.printf "String for tounicode = %S\n" s; (*Printf.printf "String for tounicode = %S\n" s;*)
Hashtbl.add h 0 s; List.iter2
(fun n u ->
let s = implode (tl (tl (explode (Pdftext.utf16be_of_codepoints [u])))) in
Hashtbl.add h n s)
(indx subset_2)
subset_2;
Some h Some h
in in
Printf.printf "returning the fonts. Job done.\n"; Printf.printf "returning the fonts. Job done.\n";