home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / lisp / mcl / 1864 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  3.3 KB

  1. Path: sparky!uunet!stanford.edu!apple!cambridge.apple.com!lynch@ils.nwu.edu
  2. From: lynch@ils.nwu.edu
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: view-font/set-view-font
  5. Message-ID: <9212220055.AB16498@aristotle.ils.nwu.edu>
  6. Date: 22 Dec 92 00:55:53 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 81
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10.  
  11. I've been having trouble with fonts.
  12.  
  13. I have some fancy windows that have 2 different fonts mixed.
  14.  
  15. set-view-font seems to be additive, rather than wholesale font-setting as
  16. the docs seem to indicate.  This seems kind of goofy, but I can almost see
  17. a logic to it.  Unfortunately, it's not at all indicated in the manual, and
  18. mixing :plain with :bold to change :italic to :bold was sheer inspiration
  19. on my part, since I'm used to the convention that :plain doesn't mix with
  20. anything; it gets rid of everything.  ['Least, that's how the various
  21. applications that have a style menu do it.]
  22.  
  23. All that said, I am still at a loss to explain how :italic creeps in and
  24. stays there in the following code:
  25.  
  26. (defclass sample (dialog)
  27.   ()
  28.   (:default-initargs
  29.     :view-font '("Helvetica" 30 :plain :bold)
  30.     :view-size #@(600 400)
  31. ) )
  32.  
  33. (defmethod view-draw-contents :after ((view sample))
  34.   (print (view-font view))
  35.   (let ((font '("Helvetica" 18 :italic))
  36.         (old-font (view-font view))
  37.        )
  38.     (set-view-font view font)
  39.     (print (view-font view))
  40.     (with-pstrs ((str (format nil "~A" font)))
  41.       (#_MoveTo 4 50)
  42.       (#_DrawString str))
  43.     (set-view-font view old-font))
  44.   (let ((old-font (view-font view)))
  45.     (with-pstrs ((str (format nil "~A" '("New York" 18 :bold))))
  46.       (set-view-font view '("New York" 18 :bold))
  47.       (print (view-font view))
  48.       (#_MoveTo 4 100)
  49.       (#_DrawString str)
  50.       (set-view-font view old-font)))
  51.   (let ((old-font (view-font view)))
  52.     (with-pstrs ((str (format nil "~A" '("New York" 18 :plain :bold))))
  53.       (set-view-font view '("New York" 18 :plain :bold))
  54.       (print (view-font view))
  55.       (#_MoveTo 4 150)
  56.       (#_DrawString str)
  57.       (set-view-font view old-font)))
  58.   (with-pstrs ((str (format nil "~A" (view-font view))))
  59.     (print (view-font view))
  60.     (#_MoveTo 4 200)
  61.     (#_DrawString str)))
  62.  
  63. (make-instance 'sample)
  64.  
  65. Note that the only time '("Helvetica" 30 :plain :bold) is achieved is
  66. before anything is drawn:  Once drawing has occurred, it remains :italic
  67. and :bold.
  68.  
  69. The only fix I could find was to ignore the original view-font and simply
  70. hard-wire each font I wanted at any given time, using :plain mixed with
  71. :bold or :italic to cancel the unwanted styles.  I had hoped that the
  72. windows could have *one* font that I could change in only *one* place to
  73. alter all the windows, but even that modicum of modularity proved
  74. impossible.
  75.  
  76. btw, I thought about using set-font-codes just because the docs say: "You
  77. should not write methods for this function; use set-view-font-codes
  78. instead", but:
  79.  
  80. A:  There's no chart in the MCL manual [that I could find] for what codes
  81. mean what.  Probably in some Inside Mac volume, but those are locked up
  82. right now.  Oh well.
  83.  
  84. B:  I really don't think it's good style [pun intended] to have code that
  85. goes:
  86. (set-view-font-codes view XXXX XXXX XXXX XXXX) when
  87. (set-view-font view '("Helvetica" 30 :bold)) is an option that should work.
  88. Any idiot can read and maintain the latter; the former is gibberish.
  89. -- 
  90. --
  91. -- "TANSTAAFL" Rich lynch@ils.nwu.edu
  92.