more on format 4
This commit is contained in:
parent
7a513260e9
commit
f0984ae589
|
@ -4,6 +4,8 @@ open Pdfio
|
||||||
|
|
||||||
let fontpack_experiment = false
|
let fontpack_experiment = false
|
||||||
|
|
||||||
|
let dbg = ref false
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{flags : int;
|
{flags : int;
|
||||||
minx : int;
|
minx : int;
|
||||||
|
@ -25,8 +27,6 @@ type t =
|
||||||
subset : int list;
|
subset : int list;
|
||||||
tounicode : (int, string) Hashtbl.t option}
|
tounicode : (int, string) Hashtbl.t option}
|
||||||
|
|
||||||
let dbg = ref false
|
|
||||||
|
|
||||||
let required_tables =
|
let required_tables =
|
||||||
["head"; "hhea"; "loca"; "cmap"; "maxp"; "cvt "; "glyf"; "prep"; "hmtx"; "fpgm"]
|
["head"; "hhea"; "loca"; "cmap"; "maxp"; "cvt "; "glyf"; "prep"; "hmtx"; "fpgm"]
|
||||||
|
|
||||||
|
@ -121,10 +121,13 @@ let read_format_4_encoding_table b =
|
||||||
if ro = 0 then
|
if ro = 0 then
|
||||||
Hashtbl.add t c ((c + del) mod 65536)
|
Hashtbl.add t c ((c + del) mod 65536)
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
|
flprint "format 4 magic required\n";
|
||||||
let v = read_magic_formula b.input glyphIndexArrayStart seg segCount ro c sc in
|
let v = read_magic_formula b.input glyphIndexArrayStart seg segCount ro c sc in
|
||||||
if v = 0
|
if v = 0
|
||||||
then Hashtbl.add t c ((c + del) mod 65536)
|
then Hashtbl.add t c ((c + del) mod 65536)
|
||||||
else Hashtbl.add t c ((v + del) mod 65536)
|
else Hashtbl.add t c ((v + del) mod 65536)
|
||||||
|
end
|
||||||
done
|
done
|
||||||
done;
|
done;
|
||||||
t
|
t
|
||||||
|
@ -426,9 +429,12 @@ let subset_font major minor tables indexToLocFormat subset encoding cmap loca mk
|
||||||
obs
|
obs
|
||||||
|
|
||||||
let parse ?(subset=[]) data encoding =
|
let parse ?(subset=[]) data encoding =
|
||||||
|
if !dbg then
|
||||||
|
begin
|
||||||
Printf.printf "********SUBSET is ";
|
Printf.printf "********SUBSET is ";
|
||||||
iter (Printf.printf "%i ") subset;
|
iter (Printf.printf "%i ") subset;
|
||||||
Printf.printf "\n";
|
Printf.printf "\n"
|
||||||
|
end;
|
||||||
let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in
|
let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in
|
||||||
let b = mk_b 0 in
|
let b = mk_b 0 in
|
||||||
let major, minor = read_fixed b in
|
let major, minor = read_fixed b in
|
||||||
|
@ -551,7 +557,7 @@ let parse ?(subset=[]) data encoding =
|
||||||
| (_, _, o, _)::_ -> read_hmtx_table numOfLongHorMetrics (mk_b (i32toi o))
|
| (_, _, o, _)::_ -> read_hmtx_table numOfLongHorMetrics (mk_b (i32toi o))
|
||||||
| [] -> raise (Pdf.PDFError "No hmtx table found in TrueType font")
|
| [] -> raise (Pdf.PDFError "No hmtx table found in TrueType font")
|
||||||
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
|
||||||
(*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
|
||||||
|
|
Loading…
Reference in New Issue