[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

view-font/set-view-font



I've been having trouble with fonts.

I have some fancy windows that have 2 different fonts mixed.

set-view-font seems to be additive, rather than wholesale font-setting as
the docs seem to indicate.  This seems kind of goofy, but I can almost see
a logic to it.  Unfortunately, it's not at all indicated in the manual, and
mixing :plain with :bold to change :italic to :bold was sheer inspiration
on my part, since I'm used to the convention that :plain doesn't mix with
anything; it gets rid of everything.  ['Least, that's how the various
applications that have a style menu do it.]

All that said, I am still at a loss to explain how :italic creeps in and
stays there in the following code:

(defclass sample (dialog)
  ()
  (:default-initargs
    :view-font '("Helvetica" 30 :plain :bold)
    :view-size #@(600 400)
) )

(defmethod view-draw-contents :after ((view sample))
  (print (view-font view))
  (let ((font '("Helvetica" 18 :italic))
        (old-font (view-font view))
       )
    (set-view-font view font)
    (print (view-font view))
    (with-pstrs ((str (format nil "~A" font)))
      (#_MoveTo 4 50)
      (#_DrawString str))
    (set-view-font view old-font))
  (let ((old-font (view-font view)))
    (with-pstrs ((str (format nil "~A" '("New York" 18 :bold))))
      (set-view-font view '("New York" 18 :bold))
      (print (view-font view))
      (#_MoveTo 4 100)
      (#_DrawString str)
      (set-view-font view old-font)))
  (let ((old-font (view-font view)))
    (with-pstrs ((str (format nil "~A" '("New York" 18 :plain :bold))))
      (set-view-font view '("New York" 18 :plain :bold))
      (print (view-font view))
      (#_MoveTo 4 150)
      (#_DrawString str)
      (set-view-font view old-font)))
  (with-pstrs ((str (format nil "~A" (view-font view))))
    (print (view-font view))
    (#_MoveTo 4 200)
    (#_DrawString str)))

(make-instance 'sample)

Note that the only time '("Helvetica" 30 :plain :bold) is achieved is
before anything is drawn:  Once drawing has occurred, it remains :italic
and :bold.

The only fix I could find was to ignore the original view-font and simply
hard-wire each font I wanted at any given time, using :plain mixed with
:bold or :italic to cancel the unwanted styles.  I had hoped that the
windows could have *one* font that I could change in only *one* place to
alter all the windows, but even that modicum of modularity proved
impossible.

btw, I thought about using set-font-codes just because the docs say: "You
should not write methods for this function; use set-view-font-codes
instead", but:

A:  There's no chart in the MCL manual [that I could find] for what codes
mean what.  Probably in some Inside Mac volume, but those are locked up
right now.  Oh well.

B:  I really don't think it's good style [pun intended] to have code that
goes:
(set-view-font-codes view XXXX XXXX XXXX XXXX) when
(set-view-font view '("Helvetica" 30 :bold)) is an option that should work.
Any idiot can read and maintain the latter; the former is gibberish.
-- 
--
-- "TANSTAAFL" Rich lynch@ils.nwu.edu