Skip navigation.
 
mlRe: Why are Monaco, Courier not showing up as fixed pitch?
FROM : John DeSoi
DATE : Sun Dec 19 19:04:38 2004

On Dec 16, 2004, at 12:39 PM, Dan Wood - Discussion Lists wrote:

> Not fixed pitch?  What's going on?  I'm pretty sure this call used to
> work, maybe pre-Panther.  Maybe it's the mysterious "NSCGSFont" that
> is the actual runtime class of the NSFont created.  Any explanations?



I ran into this in working with the Macintosh version of LispWorks
(explanation from LispWorks tech support below). Apparently, not all
glyphs are the same size in Courier. And there does seem to be a bug in
10.3 that some fonts don't return the correct value for isFixedPitch
(Monaco).

Best,

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


====

It looks like there are a number of non-standard width glyphs in
Courier (on a 10.2 system here). You can check this by:

(defun print-not-fixed (name size &optional (char #\l))
  (loop with nsfont = (objc:invoke "NSFont"
                                    "fontWithName:size:"
                                    name
                                    (coerce size 'single-float))
        with base-width = (objc:invoke nsfont "widthOfString:"
                                        (string char))
        initially (format t "base width is ~D~%" base-width)
        for code from 32 below char-code-limit
        for width = (objc:invoke nsfont "widthOfString:"
                                  (string (code-char code)))
        unless (eql base-width width)
        do (format t "~D is ~D~%" code width base-width)))

In contrast, Courier New is fixed pitch according to this test and
CAPI:PROMPT-FOR-FONT agrees.


Just for completeness, let me mention that on Mac OS X 10.3, the Cocoa
API "isFixedPitch" returns null for some fixed pitch fonts and so
LispWorks has the variable GP::*COCOA-FONT-FIXED-PITCH-FAMILIES* and a
heuristic algorithm to detect fixed-pitchness as a workaround for that
problem. GP::*COCOA-FONT-FIXED-PITCH-FAMILIES* can be altered to
affect the GP:FONT object returned by CAPI:PROMPT-FOR-FONT, and so
force Courier to appear to be fixed pitch to the CAPI. But given what
we've just learned about Courier I don't think that's a good idea.

Related mailsAuthorDate
mlWhy are Monaco, Courier not showing up as fixed pitch? Dan Wood - Discuss… Dec 16, 18:39
mlRe: Why are Monaco, Courier not showing up as fixed pitch? John DeSoi Dec 19, 19:04