Giter Club home page Giter Club logo

Comments (2)

rfindler avatar rfindler commented on July 19, 2024

Below is some code that demonstrates the issue just at the level of pict and racket/gui.

I see that changing the weight does change the output of the pict in the REPL but not in the PDF file so I wonder if the recent changes to racket/draw need more changes?

That is, replacing the definition of p with this:

(define p (text "READ WRITE" (cons (cons 'weight 'heavy) "Source Code Pro")))

exaggerates the difference between the PDF version and the repl version.

#lang racket
(require pict racket/gui/base)

(define p (text "READ WRITE" "Source Code Pro"))
p

(define ps-setup (make-object ps-setup%))
(send ps-setup copy-from (current-ps-setup))
(send ps-setup set-file "commonlang.pdf")
(send ps-setup set-mode 'file)
(define ps/pdf-dc
  (parameterize ([current-ps-setup ps-setup])
    (make-object pdf-dc% #f #f)))
(parameterize ([dc-for-text-size ps/pdf-dc])
  (send ps/pdf-dc start-doc "x")
  (send ps/pdf-dc start-page)
  (draw-pict p ps/pdf-dc 0 0)
  (send ps/pdf-dc end-page)
  (send ps/pdf-dc end-doc))

from redex.

rfindler avatar rfindler commented on July 19, 2024

Here's a version that eliminates the pict library from the dependencies.

#lang racket
(require racket/gui/base)

;; changing this doesn't seem to affect the PDF output
;; but it does affect the window output
(define weight 500)

(define (write-it f)
  (define ps-setup (make-object ps-setup%))
  (send ps-setup copy-from (current-ps-setup))
  (send ps-setup set-file "commonlang.pdf")
  (send ps-setup set-mode 'file)
  (define ps/pdf-dc
    (parameterize ([current-ps-setup ps-setup])
      (make-object pdf-dc% #f #f)))
  (send ps/pdf-dc start-doc "x")
  (send ps/pdf-dc start-page)
  (f ps/pdf-dc)
  (send ps/pdf-dc end-page)
  (send ps/pdf-dc end-doc))

(define (draw dc)
  (define font (send dc get-font))
  (send dc set-font
        (send the-font-list find-or-create-font 12 "Source Code Pro"
              'default 'normal weight
              #f 'default #t 'unaligned))
  (send dc draw-text "READ WRITE" 10 10)
  (send dc set-font font))
(write-it draw)

(define f (new frame% [label ""] [width 200] [height 200]))
(define c (new canvas% [parent f] [paint-callback (λ (c dc) (draw dc))]))
(send f show #t)

from redex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.