This commit is contained in:
John Whitington 2023-06-07 16:35:26 +01:00
parent 77e6dcdda3
commit 65e7bbf68f
2 changed files with 9 additions and 9 deletions

View File

@ -3,7 +3,7 @@ open Pdfutil
let colours = let colours =
map map
(fun (a, b) -> (b, a)) (fun (a, b) -> (String.lowercase_ascii b, a))
[(0xF0F8FF, "AliceBlue"); [(0xF0F8FF, "AliceBlue");
(0xFAEBD7, "AntiqueWhite"); (0xFAEBD7, "AntiqueWhite");
(0x00FFFF, "Aqua"); (0x00FFFF, "Aqua");

View File

@ -1140,13 +1140,13 @@ let setaddtext s =
setop (AddText s) () setop (AddText s) ()
let parse_color s = let parse_color s =
match String.lowercase_ascii s with match lookup (String.lowercase_ascii s) Cpdfcolours.colours with
| "white" -> Cpdfaddtext.RGB (1., 1., 1.) | Some c ->
| "black" -> Cpdfaddtext.RGB (0., 0., 0.) let r = float_of_int ((c land 0xFF0000) lsr 16) /. 255. in
| "red" -> Cpdfaddtext.RGB (1., 0., 0.) let g = float_of_int ((c land 0x00FF00) lsr 8) /. 255. in
| "green" -> Cpdfaddtext.RGB (0., 1., 0.) let b = float_of_int (c land 0x0000FF) /. 255. in
| "blue" -> Cpdfaddtext.RGB (0., 0., 1.) Cpdfaddtext.RGB (r, g, b)
| _ -> | None ->
let getnum = function let getnum = function
| Pdfgenlex.LexInt i -> float i | Pdfgenlex.LexInt i -> float i
| Pdfgenlex.LexReal f -> f | Pdfgenlex.LexReal f -> f
@ -1154,7 +1154,7 @@ let parse_color s =
in in
match Pdfgenlex.lex_string s with match Pdfgenlex.lex_string s with
| [g] -> Cpdfaddtext.Grey (getnum g) | [g] -> Cpdfaddtext.Grey (getnum g)
| [r;g;b] -> Cpdfaddtext.RGB (getnum r, getnum g, getnum b) | [r; g; b] -> Cpdfaddtext.RGB (getnum r, getnum g, getnum b)
| [c; y; m; k] -> Cpdfaddtext.CYMK (getnum c, getnum y, getnum m, getnum k) | [c; y; m; k] -> Cpdfaddtext.CYMK (getnum c, getnum y, getnum m, getnum k)
| _ -> error "Bad color" | _ -> error "Bad color"