Expand -thinlines to allow thinning as well of thickening

This commit is contained in:
John Whitington
2025-03-31 16:03:44 +01:00
parent f4550b50c1
commit 776578f526
2 changed files with 5 additions and 3 deletions

View File

@ -1,3 +1,4 @@
%Document negative widths in -thinlines
%\DocumentMetadata{lang=en, pdfversion=2.0, pdfstandard=ua-2, pdfstandard=a-4f, testphase={phase-III, title, table, math, firstaid}} %\DocumentMetadata{lang=en, pdfversion=2.0, pdfstandard=ua-2, pdfstandard=a-4f, testphase={phase-III, title, table, math, firstaid}}
\documentclass{book} \documentclass{book}
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf, % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf,

View File

@ -146,7 +146,8 @@ let blackfills c range pdf =
(* Set a minimum line width to avoid dropout *) (* Set a minimum line width to avoid dropout *)
let thinlines range width pdf = let thinlines range width pdf =
let thinpage _ page = let comparison, width = if width < 0. then ( <= ), ~-.width else ( >= ), width in
let thinpage _ page =
let operators = let operators =
Pdfops.parse_operators pdf page.Pdfpage.resources page.Pdfpage.content Pdfops.parse_operators pdf page.Pdfpage.resources page.Pdfpage.content
in in
@ -165,7 +166,7 @@ let thinlines range width pdf =
(* Alter width. *) (* Alter width. *)
let width' = width /. scaleof_ctm () in let width' = width /. scaleof_ctm () in
let w' = let w' =
if w >= width' then Pdfops.Op_w w else Pdfops.Op_w width' if comparison w width' then Pdfops.Op_w w else Pdfops.Op_w width'
in in
replace_operators (w'::prev) more replace_operators (w'::prev) more
| (Pdfops.Op_cm m)::more -> | (Pdfops.Op_cm m)::more ->
@ -212,7 +213,7 @@ let thinlines range width pdf =
let operators = replace_operators [] operators in let operators = replace_operators [] operators in
(* 2. Add an initial 'w' if width more than default width *) (* 2. Add an initial 'w' if width more than default width *)
let operators = let operators =
if width > 1. then (Pdfops.Op_w width)::operators else operators if width > 1. || width < 1. then (Pdfops.Op_w width)::operators else operators
in in
let content' = [Pdfops.stream_of_ops operators] in let content' = [Pdfops.stream_of_ops operators] in
{page with Pdfpage.content = content'} {page with Pdfpage.content = content'}