Lisp HUG Maillist Archive

hard-copy fonts change their shape

Unable to parse email body. Email id is 10121

Re: hard-copy fonts change their shape

Hello Nick,

What OS are you running? I do this myself, but mostly in OS X, and there I'm creating a PDF image of the layout, which, I presume, prints as a graphic image -- as opposed to being reconstructed in the printer port. But when reconstructing, instead of image printing, doesn't this depend on the capabilities of the printer?

- DM

On Mar 28, 2010, at 09:12 AM, Nick Levine wrote:

> 
> I'm trying to print a pinboard-layout. There are several carefully
> positioned boxes, and there's text that fits nicely into the boxes. In
> the printout, the text is typically too long for the boxes and the
> whole thing looks terrible.
> 
> You can get a similar effect by comparing the port-string-width and
> -height of a string in an output-pane and a printer-port. The heights
> and widths can differ by as much as 5%. The proportions by which they
> vary differ, so I can't fix this by scaling the printer-port.
> 
> Has anybody met this before? Can anybody explain it? Or better still,
> fix the problem so that a printer font has the same shape (width to
> height ratio) as an output-pane font?
> 
> Thanks,
> 
> - nick
> 
> (defun simple-test (&key (family "Verdana") (size 10.0) (text "Hello, World"))
>  (when-let (printer (capi:print-dialog))
>    (let* ((pane (capi:contain (make-instance 'capi:output-pane)
>                               :display-state :hidden))
>           (font-description (gp:make-font-description :family family
>                                                       :size size))
>            pane-string-width pane-string-height
>            printer-string-width printer-string-height)
>      (gp:with-graphics-state (pane :font (gp:find-best-font pane font-description))
>        (setf pane-string-width (gp:port-string-width pane text)
>              pane-string-height (gp:port-string-height pane text)))
>      (capi:destroy (capi:element-interface pane))
>      (capi:with-print-job (printer-port :printer printer)
>        (gp:with-graphics-state (printer-port :font (gp:find-best-font printer-port font-description))
>          (setf printer-string-width (gp:port-string-width printer-port text)
>                printer-string-height (gp:port-string-height printer-port text))))
>      (values pane-string-width pane-string-height printer-string-width printer-string-height))))
> 
> CL-USER 1 > (simple-test :text (make-string 50 :initial-element #\W))
> 650
> 16
> 680
> 16
> 
> CL-USER 2 > (simple-test :text (make-string 50 :initial-element #\.))
> 250
> 16
> 248
> 16
> 
> CL-USER 3 > (simple-test :text (make-string 50 :initial-element #\W) :family "Arial")
> 650
> 16
> 640
> 15
> 
> CL-USER 4 > 
> 
> 

Dr. David McClain
dbm@refined-audiometrics.com




Re: hard-copy fonts change their shape

You are running into the difference between "screen metrics" and  
"print metrics".

If print quality isn't as important as print layout, I'd suggest  
turning the text into a bitmap (programatically or staticly, depending  
on your app) and printing the resulting bitmap.

--Jim

On Mar 28, 2010, at 12:14 PM, "Nick Levine" <ndl@ravenbrook.com> wrote:

>
> I'm trying to print a pinboard-layout. There are several carefully
> positioned boxes, and there's text that fits nicely into the boxes. In
> the printout, the text is typically too long for the boxes and the
> whole thing looks terrible.
>
> You can get a similar effect by comparing the port-string-width and
> -height of a string in an output-pane and a printer-port. The heights
> and widths can differ by as much as 5%. The proportions by which they
> vary differ, so I can't fix this by scaling the printer-port.
>
> Has anybody met this before? Can anybody explain it? Or better still,
> fix the problem so that a printer font has the same shape (width to
> height ratio) as an output-pane font?
>
> Thanks,
>
> - nick
>
> (defun simple-test (&key (family "Verdana") (size 10.0) (text  
> "Hello, World"))
>  (when-let (printer (capi:print-dialog))
>    (let* ((pane (capi:contain (make-instance 'capi:output-pane)
>                               :display-state :hidden))
>           (font-description (gp:make-font-description :family family
>                                                       :size size))
>            pane-string-width pane-string-height
>            printer-string-width printer-string-height)
>      (gp:with-graphics-state (pane :font (gp:find-best-font pane  
> font-description))
>        (setf pane-string-width (gp:port-string-width pane text)
>              pane-string-height (gp:port-string-height pane text)))
>      (capi:destroy (capi:element-interface pane))
>      (capi:with-print-job (printer-port :printer printer)
>        (gp:with-graphics-state (printer-port :font (gp:find-best- 
> font printer-port font-description))
>          (setf printer-string-width (gp:port-string-width printer- 
> port text)
>                printer-string-height (gp:port-string-height printer- 
> port text))))
>      (values pane-string-width pane-string-height printer-string- 
> width printer-string-height))))
>
> CL-USER 1 > (simple-test :text (make-string 50 :initial-element #\W))
> 650
> 16
> 680
> 16
>
> CL-USER 2 > (simple-test :text (make-string 50 :initial-element #\.))
> 250
> 16
> 248
> 16
>
> CL-USER 3 > (simple-test :text (make-string 50 :initial-element # 
> \W) :family "Arial")
> 650
> 16
> 640
> 15
>
> CL-USER 4 >
>


Updated at: 2020-12-10 08:39 UTC