Towards -font-ttf

This commit is contained in:
John Whitington 2023-06-13 20:52:17 +01:00
parent 1fbda88348
commit 411aaa6a71
1 changed files with 5 additions and 4 deletions

View File

@ -314,15 +314,15 @@ let calculate_widths unitsPerEm encoding firstchar lastchar subset cmapdata hmtx
(lastchar - firstchar + 1) (lastchar - firstchar + 1)
(fun pos -> (fun pos ->
let code = pos + firstchar in let code = pos + firstchar in
(*if !dbg then Printf.printf "code %i --> " code;*) (*if !dbg then*) Printf.printf "code %i --> " code;
let code = unicode_codepoint_of_pdfcode encoding_table glyphlist_table code in let code = unicode_codepoint_of_pdfcode encoding_table glyphlist_table code in
(*if !dbg then Printf.printf "unicode %i --> " code;*) (*if !dbg then*) Printf.printf "unicode %i --> " code;
if subset <> [] && not (mem code subset) then 0 else if subset <> [] && not (mem code subset) then 0 else
try try
let glyphnum = Hashtbl.find cmapdata code in let glyphnum = Hashtbl.find cmapdata code 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
with e -> if !dbg then Printf.printf "no width for %i\n" code; 0) with e -> if !dbg then Printf.printf "no width for %i\n" code; 0)
@ -581,6 +581,7 @@ let parse ?(subset=[]) data encoding =
in in
Printf.printf "firstchar_1, lastchar_1, firstchar_2, lastchar_2 = %i, %i, %i%, %i\n" firstchar_1 lastchar_1 firstchar_2 lastchar_2; Printf.printf "firstchar_1, lastchar_1, firstchar_2, lastchar_2 = %i, %i, %i%, %i\n" firstchar_1 lastchar_1 firstchar_2 lastchar_2;
let widths_1 = calculate_widths unitsPerEm encoding firstchar_1 lastchar_1 subset_1 !glyphcodes hmtxdata in let widths_1 = calculate_widths unitsPerEm encoding firstchar_1 lastchar_1 subset_1 !glyphcodes hmtxdata in
(* FIXME: Encoding here is wrong, we must build it directly like the /ToUnicode *)
let widths_2 = calculate_widths unitsPerEm encoding firstchar_2 lastchar_2 subset_2 !glyphcodes hmtxdata in let widths_2 = calculate_widths unitsPerEm encoding firstchar_2 lastchar_2 subset_2 !glyphcodes hmtxdata in
let maxwidth = calculate_maxwidth unitsPerEm hmtxdata in let maxwidth = calculate_maxwidth unitsPerEm hmtxdata in
let stemv = calculate_stemv () in let stemv = calculate_stemv () in