more
This commit is contained in:
parent
6589824a8f
commit
983b087020
|
@ -55,26 +55,33 @@ let colour_op_stroke = function
|
|||
| Grey g -> Pdfops.Op_G g
|
||||
| CYMK (c, y, m, k) -> Pdfops.Op_K (c, y, m, k)
|
||||
|
||||
let ops longest_w x y rotate hoffset voffset outline linewidth unique_fontname unique_extgstatename colour fontsize text =
|
||||
String.iter (fun x -> Hashtbl.replace used x ()) text;
|
||||
[Pdfops.Op_q;
|
||||
Pdfops.Op_BMC "/CPDFSTAMP";
|
||||
Pdfops.Op_cm
|
||||
(Pdftransform.matrix_of_transform
|
||||
[Pdftransform.Translate (x -. hoffset, y -. voffset);
|
||||
Pdftransform.Rotate ((0., 0.), rotate)]);
|
||||
Pdfops.Op_BT;
|
||||
] @
|
||||
(if outline then [Pdfops.Op_w linewidth; Pdfops.Op_Tr 1] else [Pdfops.Op_Tr 0]) @
|
||||
[colour_op colour; colour_op_stroke colour]
|
||||
@
|
||||
(match unique_extgstatename with None -> [] | Some n -> [Pdfops.Op_gs n])
|
||||
@
|
||||
[Pdfops.Op_Tf (unique_fontname, fontsize);
|
||||
Pdfops.Op_Tj text;
|
||||
Pdfops.Op_ET;
|
||||
Pdfops.Op_EMC;
|
||||
Pdfops.Op_Q]
|
||||
let ops fontname longest_w x y rotate hoffset voffset outline linewidth unique_fontname unique_extgstatename colour fontsize text =
|
||||
begin match Hashtbl.find used fontname with
|
||||
| exception Not_found ->
|
||||
let thisused = null_hash () in
|
||||
String.iter (fun x -> Hashtbl.replace thisused x ()) text;
|
||||
Hashtbl.add used fontname thisused
|
||||
| thisused ->
|
||||
String.iter (fun x -> Hashtbl.replace thisused x ()) text;
|
||||
end;
|
||||
[Pdfops.Op_q;
|
||||
Pdfops.Op_BMC "/CPDFSTAMP";
|
||||
Pdfops.Op_cm
|
||||
(Pdftransform.matrix_of_transform
|
||||
[Pdftransform.Translate (x -. hoffset, y -. voffset);
|
||||
Pdftransform.Rotate ((0., 0.), rotate)]);
|
||||
Pdfops.Op_BT;
|
||||
] @
|
||||
(if outline then [Pdfops.Op_w linewidth; Pdfops.Op_Tr 1] else [Pdfops.Op_Tr 0]) @
|
||||
[colour_op colour; colour_op_stroke colour]
|
||||
@
|
||||
(match unique_extgstatename with None -> [] | Some n -> [Pdfops.Op_gs n])
|
||||
@
|
||||
[Pdfops.Op_Tf (unique_fontname, fontsize);
|
||||
Pdfops.Op_Tj text;
|
||||
Pdfops.Op_ET;
|
||||
Pdfops.Op_EMC;
|
||||
Pdfops.Op_Q]
|
||||
|
||||
type justification = LeftJustify | CentreJustify | RightJustify
|
||||
|
||||
|
@ -417,11 +424,11 @@ let addtext
|
|||
in
|
||||
match font with
|
||||
| Some f ->
|
||||
ops longest_w (x +. shift_x) (y +. shift_y) rotate (hoffset +. joffset) voffset outline linewidth
|
||||
ops fontname longest_w (x +. shift_x) (y +. shift_y) rotate (hoffset +. joffset) voffset outline linewidth
|
||||
unique_fontname unique_extgstatename colour fontsize text,
|
||||
urls, x, y, hoffset, voffset, text, joffset
|
||||
| None ->
|
||||
ops longest_w (x +. shift_x) (y +. shift_y) rotate (hoffset +. joffset) voffset outline linewidth
|
||||
ops fontname longest_w (x +. shift_x) (y +. shift_y) rotate (hoffset +. joffset) voffset outline linewidth
|
||||
fontname None colour fontsize text,
|
||||
urls, x, y, hoffset, voffset, text, joffset
|
||||
in
|
||||
|
@ -611,7 +618,11 @@ let
|
|||
begin match embedinfo with
|
||||
| None -> ()
|
||||
| Some (_, fontfile, fontname, encoding) ->
|
||||
let charcodes = map fst (list_of_hashtbl used) in
|
||||
let charcodes =
|
||||
match Hashtbl.find used fontname with
|
||||
| exception Not_found -> []
|
||||
| thisused -> map fst (list_of_hashtbl thisused)
|
||||
in
|
||||
let encoding_table = Pdftext.table_of_encoding encoding in
|
||||
let glyphlist_table = Pdfglyphlist.glyph_hashes () in
|
||||
let codepoints =
|
||||
|
|
Loading…
Reference in New Issue