first cut at splitting draw and gui docs

This commit is contained in:
Matthew Flatt 2010-11-05 21:53:36 -06:00
parent 59bf78b6c8
commit 694745e998
48 changed files with 275 additions and 900 deletions

View File

@ -1,4 +1,3 @@
#lang scheme/signature #lang scheme/signature
add-color<%> add-color<%>
@ -38,8 +37,6 @@ control<%>
current-eventspace current-eventspace
current-eventspace-has-menu-root? current-eventspace-has-menu-root?
current-eventspace-has-standard-menus? current-eventspace-has-standard-menus?
current-ps-afm-file-paths
current-ps-cmap-file-paths
current-ps-setup current-ps-setup
current-text-keymap-initializer current-text-keymap-initializer
cursor% cursor%

View File

@ -4,6 +4,7 @@
namespace-anchor->empty-namespace namespace-anchor->empty-namespace
make-base-empty-namespace) make-base-empty-namespace)
scheme/class scheme/class
racket/draw
mzlib/etc mzlib/etc
(prefix wx: "private/kernel.ss") (prefix wx: "private/kernel.ss")
(prefix wx: "private/wxme/style.ss") (prefix wx: "private/wxme/style.ss")
@ -101,26 +102,15 @@
add-pasteboard-keymap-functions add-pasteboard-keymap-functions
begin-busy-cursor begin-busy-cursor
bell bell
bitmap%
make-bitmap
read-bitmap
make-monochrome-bitmap
brush%
brush-list%
editor-data% editor-data%
editor-data-class% editor-data-class%
editor-data-class-list<%> editor-data-class-list<%>
check-for-break check-for-break
clipboard<%> clipboard<%>
clipboard-client% clipboard-client%
color%
color-database<%>
control-event% control-event%
current-eventspace current-eventspace
current-ps-setup
cursor% cursor%
dc<%>
dc-path%
get-display-depth get-display-depth
end-busy-cursor end-busy-cursor
event% event%
@ -128,9 +118,6 @@
eventspace? eventspace?
find-graphical-system-path find-graphical-system-path
flush-display flush-display
font%
font-list%
font-name-directory<%>
get-highlight-background-color get-highlight-background-color
get-highlight-text-color get-highlight-text-color
get-the-editor-data-class-list get-the-editor-data-class-list
@ -152,14 +139,9 @@
editor-wordbreak-map% editor-wordbreak-map%
mouse-event% mouse-event%
mult-color<%> mult-color<%>
pen%
pen-list%
point%
ps-setup%
read-editor-global-footer read-editor-global-footer
read-editor-global-header read-editor-global-header
read-editor-version read-editor-version
region%
scroll-event% scroll-event%
snip% snip%
snip-admin% snip-admin%
@ -181,14 +163,7 @@
yield yield
eventspace-shutdown? eventspace-shutdown?
get-panel-background get-panel-background
gl-context<%>
gl-config%
the-color-database
the-font-name-directory
the-font-list
the-pen-list
the-brush-list
the-style-list the-style-list
the-editor-wordbreak-map the-editor-wordbreak-map
make-screen-bitmap make-screen-bitmap
@ -197,9 +172,7 @@
(define the-clipboard (wx:get-the-clipboard)) (define the-clipboard (wx:get-the-clipboard))
(define the-x-selection-clipboard (wx:get-the-x-selection)) (define the-x-selection-clipboard (wx:get-the-x-selection))
;; Obsolete (provide (all-from racket/draw))
(define current-ps-afm-file-paths (make-parameter null))
(define current-ps-cmap-file-paths (make-parameter null))
(provide button% (provide button%
canvas% canvas%
@ -277,13 +250,10 @@
get-top-level-edit-target-window get-top-level-edit-target-window
register-collecting-blit register-collecting-blit
unregister-collecting-blit unregister-collecting-blit
bitmap-dc%
post-script-dc%
printer-dc% printer-dc%
current-text-keymap-initializer current-text-keymap-initializer
sleep/yield sleep/yield
get-window-text-extent get-window-text-extent
get-family-builtin-face
send-message-to-window send-message-to-window
the-clipboard the-clipboard
the-x-selection-clipboard the-x-selection-clipboard
@ -309,8 +279,6 @@
make-gui-namespace make-gui-namespace
make-gui-empty-namespace make-gui-empty-namespace
file-creator-and-type file-creator-and-type
current-ps-afm-file-paths
current-ps-cmap-file-paths
hide-cursor-until-moved hide-cursor-until-moved
system-position-ok-before-cancel? system-position-ok-before-cancel?
label-string? label-string?

View File

@ -39,7 +39,7 @@
(let ([s (send (send edit get-style-list) find-named-style "Standard")]) (let ([s (send (send edit get-style-list) find-named-style "Standard")])
(send s set-delta (font->delta f))))))] (send s set-delta (font->delta f))))))]
[p (make-object horizontal-pane% f)] [p (make-object horizontal-pane% f)]
[face (make-object list-box% #f (get-face-list) p refresh-sample)] [face (make-object list-box% #f (wx:get-face-list) p refresh-sample)]
[p2 (make-object vertical-pane% p)] [p2 (make-object vertical-pane% p)]
[p3 (instantiate horizontal-pane% (p2) [stretchable-width #f])] [p3 (instantiate horizontal-pane% (p2) [stretchable-width #f])]
[style (let ([pnl (instantiate group-box-panel% ("Style" p3) [stretchable-height #f] [stretchable-width #f])]) [style (let ([pnl (instantiate group-box-panel% ("Style" p3) [stretchable-height #f] [stretchable-width #f])])
@ -98,7 +98,7 @@
(lambda (font) (lambda (font)
(let* ([facen (if font (let* ([facen (if font
(send font get-face) (send font get-face)
(get-family-builtin-face 'default))] (wx:get-family-builtin-face 'default))]
[f (and facen (send face find-string facen))]) [f (and facen (send face find-string facen))])
(and f (>= f 0) (send face set-selection f))) (and f (>= f 0) (send face set-selection f)))
(when font (when font

View File

@ -13,17 +13,13 @@
(provide register-collecting-blit (provide register-collecting-blit
unregister-collecting-blit unregister-collecting-blit
bitmap-dc%
post-script-dc%
printer-dc% printer-dc%
get-window-text-extent get-window-text-extent
get-family-builtin-face
normal-control-font normal-control-font
small-control-font small-control-font
tiny-control-font tiny-control-font
view-control-font view-control-font
menu-control-font menu-control-font)
get-face-list)
(define register-collecting-blit (define register-collecting-blit
(case-lambda (case-lambda
@ -50,14 +46,6 @@
(check-instance 'unregister-collecting-blit canvas% 'canvas% #f canvas) (check-instance 'unregister-collecting-blit canvas% 'canvas% #f canvas)
(wx:unregister-collecting-blit (mred->wx canvas)))) (wx:unregister-collecting-blit (mred->wx canvas))))
(define bitmap-dc%
(class100 wx:bitmap-dc% ([bitmap #f])
(inherit set-bitmap)
(sequence
(super-init)
(when bitmap
(set-bitmap bitmap)))))
(define-syntax check-page-active (define-syntax check-page-active
(syntax-rules () (syntax-rules ()
[(_ check-page-status (id . args) ...) (begin (check-one-page-active check-page-status id args) ...)])) [(_ check-page-status (id . args) ...) (begin (check-one-page-active check-page-status id args) ...)]))
@ -167,20 +155,6 @@
(super-new))) (super-new)))
(define post-script-dc%
(class (doc+page-check-mixin wx:post-script-dc% 'post-script-dc%)
(init [interactive #t][parent #f][use-paper-bbox #f][as-eps #t])
(check-top-level-parent/false '(constructor post-script-dc) parent)
(define is-eps? (and as-eps #t))
(define/override (multiple-pages-ok?) (not is-eps?))
(as-entry
(lambda ()
(let ([p (and parent (mred->wx parent))])
(as-exit (lambda () (super-make-object interactive p use-paper-bbox as-eps))))))))
(define printer-dc% (define printer-dc%
(class100 (doc+page-check-mixin wx:printer-dc% 'printer-dc%) ([parent #f]) (class100 (doc+page-check-mixin wx:printer-dc% 'printer-dc%) ([parent #f])
(sequence (sequence
@ -200,37 +174,6 @@
(let-values ([(w h d a) (get-window-text-extent* string font combine?)]) (let-values ([(w h d a) (get-window-text-extent* string font combine?)])
(values (inexact->exact (ceiling w)) (inexact->exact (ceiling h))))])) (values (inexact->exact (ceiling w)) (inexact->exact (ceiling h))))]))
(define ugly?
(lambda (a)
(and (positive? (string-length a))
(not (or (char-alphabetic? (string-ref a 0))
(char-numeric? (string-ref a 0))
(char=? #\- (string-ref a 0)))))))
(define compare-face-names
(lambda (a b)
(let ([a-sp? (char=? #\space (string-ref a 0))]
[b-sp? (char=? #\space (string-ref b 0))]
[a-ugly? (ugly? a)]
[b-ugly? (ugly? b)])
(cond [(eq? a-sp? b-sp?)
(cond
[(eq? a-ugly? b-ugly?)
(string-locale-ci<? a b)]
[else b-ugly?])]
[else a-sp?]))))
(define get-face-list
(case-lambda
[() (get-face-list 'all)]
[(a) (sort (wx:get-face-list a) compare-face-names)]))
(define (get-family-builtin-face family)
(unless (memq family '(default decorative roman script swiss modern system symbol))
(raise-type-error 'get-family-builtin-face "family symbol" family))
(let ([id (send wx:the-font-name-directory find-family-default-font-id family)])
(send wx:the-font-name-directory get-screen-name id 'normal 'normal)))
(define small-delta (case (system-type) (define small-delta (case (system-type)
[(windows) 0] [(windows) 0]
[(macosx) 2] [(macosx) 2]

View File

@ -29,6 +29,7 @@
post-script-dc% post-script-dc%
ps-setup% current-ps-setup ps-setup% current-ps-setup
get-face-list get-face-list
get-family-builtin-face
gl-config% gl-config%
gl-context<%> gl-context<%>

View File

@ -4,7 +4,8 @@
"font-syms.rkt") "font-syms.rkt")
(provide font-name-directory<%> (provide font-name-directory<%>
the-font-name-directory) the-font-name-directory
get-family-builtin-face)
(define font-name-directory% (define font-name-directory%
(class object% (class object%
@ -103,3 +104,10 @@
(class->interface font-name-directory%)) (class->interface font-name-directory%))
(define the-font-name-directory (new font-name-directory%)) (define the-font-name-directory (new font-name-directory%))
(define (get-family-builtin-face family)
(unless (memq family '(default decorative roman script swiss modern system symbol))
(raise-type-error 'get-family-builtin-face "family symbol" family))
(let ([id (send the-font-name-directory find-family-default-font-id family)])
(send the-font-name-directory get-screen-name id 'normal 'normal)))

View File

@ -22,7 +22,7 @@
(define-values (s width height landscape?) (define-values (s width height landscape?)
(let ([su (if interactive (let ([su (if interactive
((gui-dynamic-require 'get-ps-setup-from-user)) ((gui-dynamic-require 'get-ps-setup-from-user) #f parent)
(current-ps-setup))]) (current-ps-setup))])
(cond (cond
[su [su
@ -33,7 +33,7 @@
[get-file (lambda (fn) [get-file (lambda (fn)
((gui-dynamic-require 'put-file) ((gui-dynamic-require 'put-file)
"Save PostScript As" "Save PostScript As"
#f parent
(and fn (path-only fn)) (and fn (path-only fn))
(and fn (file-name-from-path fn)) (and fn (file-name-from-path fn))
"ps"))] "ps"))]

View File

@ -210,8 +210,7 @@ For PNG loading, if @scheme[bg-color] is not @scheme[#f], then it is
@index["gamma correction"]{In} all PNG-loading modes, gamma correction @index["gamma correction"]{In} all PNG-loading modes, gamma correction
is applied when the file provides a gamma value, otherwise gamma is applied when the file provides a gamma value, otherwise gamma
correction is not applied. The current display's gamma factor is correction is not applied. The current display's gamma factor is
determined by the @ResourceFirst{gamma} (see @|mrprefsdiscuss|) if it determined by the @indexed-envvar{SCREEN_GAMMA} environment
is set, or else by the @indexed-envvar{SCREEN_GAMMA} environment
variable if it is defined. If the preference and environment variable variable if it is defined. If the preference and environment variable
are both undefined, a platform-specific default is used. are both undefined, a platform-specific default is used.

View File

@ -0,0 +1,62 @@
#readerscribble/reader
(module blurbs scheme/base
(require scribble/struct
scribble/manual
scribble/scheme
scribble/decode
(for-label racket/draw
scheme/base)
(for-syntax scheme/base))
(provide (all-defined-out))
(define (p . l)
(decode-paragraph l))
(define PrintNote
(make-splice
(list
@p{Be sure to use the following methods to start/end drawing:}
@itemize[@item{@method[dc<%> start-doc]}
@item{@method[dc<%> start-page]}
@item{@method[dc<%> end-page]}
@item{@method[dc<%> end-doc]}]
@p{Attempts to use a drawing method outside of an active page raises an exception.})))
(define reference-doc '(lib "scribblings/reference/reference.scrbl"))
(define SeeMzParam @elem{(see @secref[#:doc reference-doc "parameters"])})
(define DrawSizeNote "")
(define MismatchExn @elem{an @scheme[exn:fail:contract] exception is raised})
(define (colorName name name2 r g b)
(make-element #f
(list (make-element `(bg-color ,r ,g ,b)
(list (hspace 5)))
(hspace 1)
(bytes->string/latin-1 name))))
(define (slant . s)
(make-element "slant" (decode-content s)))
(define (res-sym s)
(string->symbol (string-append "GRacket:" s)))
(define (Resource s)
@elem{@to-element[`(quote ,(res-sym s))]
preference})
(define (ResourceFirst s) ; fixme -- add index
(let ([r (Resource s)])
(index* (list (format "~a preference" (res-sym s)))
(list r)
r)))
(define (boxisfill which what)
@elem{The @|which| box is filled with @|what|.})
(define (boxisfillnull which what)
@elem{The @|which| box is filled with @|what|, unless @|which| is @scheme[#f].})
)

View File

@ -52,34 +52,9 @@ A brush's style is one of the following:
]} ]}
@item{@indexed-scheme['hilite] --- In unsmoothed mode, existing @item{@indexed-scheme['hilite] --- Draws with black and a 30% alpha.}
destination pixels are ``highlighted'' in a platform-specific
way when the brush color is black. Under Windows and X for a
color drawing context, the inverted RGB components of
destination pixel are combined with the RGB components of the
system-wide highlight color using a bitwise ``or'', and the
combination is used. (Under X, the color is specified by the
@ResourceFirst{hiliteColor} preference; see @|mrprefsdiscuss|.)
Under Mac OS X for a color drawing context, the inverted RGB
components of the system-wide highlight color are subtracted
from the RGB components of each destination pixel, and the
difference (or 0 for a negative result) is used. For any
monochrome drawing context, @scheme['hilite] is the same as
@scheme['xor]. For PostScript output, @scheme['hilite] uses a
stipple that is an array of small dots (essentially a
halftone), otherwise @scheme['hilite] is treated like
@scheme['solid] in a smoothing mode.}
@item{@indexed-scheme['panel] --- In unsmoothed mode, draws with the @item{@indexed-scheme['panel] --- the same as @scheme['solid].}
same color and pattern as a top-level panel background, if the
brush's color is the same as the color returned by
@scheme[get-panel-background] and if the brush has no
stipple. To create a @scheme[canvas%] object that is drawn like
a control, use the @scheme['transparent] canvas style instead,
because certain kinds of nested panels have different
background colors (e.g., a @scheme[tab-panel%] under Mac OS
X). In a smoothing mode, @scheme['panel] is treated as
@scheme['solid].}
@item{The following modes correspond to built-in stipples drawn in @item{The following modes correspond to built-in stipples drawn in
@scheme['solid] mode: @scheme['solid] mode:

View File

@ -0,0 +1,25 @@
(module common racket/base
(require scribble/manual
scribble/basic
racket/class
racket/contract
"blurbs.ss"
(only-in "../reference/mz.ss" AllUnix exnraise))
(provide (all-from-out scribble/manual)
(all-from-out scribble/basic)
(all-from-out racket/class)
(all-from-out racket/contract)
(all-from-out "blurbs.ss")
(all-from-out "../reference/mz.ss"))
(require (for-label racket/draw
racket/gui/base
racket/class
racket/contract
racket/base))
(provide (for-label (all-from-out racket/draw)
(all-from-out racket/gui/base)
(all-from-out racket/class)
(all-from-out racket/contract)
(all-from-out racket/base))))

View File

@ -1,9 +1,36 @@
#lang scribble/doc #lang scribble/doc
@(require "common.ss") @(require "common.ss")
@title{Bitmaps} @title{Drawing Functions}
@local-table-of-contents[]
@defparam[current-ps-setup pss (is-a?/c ps-setup%)]{
A parameter that determines the current PostScript configuration
settings. See @scheme[post-script-dc%] and @scheme[printer-dc%].
}
@defproc[(get-face-list [family (one-of/c 'mono 'all) 'all])
(listof string?)]{
Returns a list of font face names available on the current system. If
@scheme['mono] is provided as the argument, then only faces that are
known to correspond to monospace fonts are included in the list.
}
@defproc[(get-family-builtin-face [family (one-of/c 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)])
string?]{
Returns the built-in default face mapping for a particular font
family.
See @scheme[font%] for information about @scheme[family].
}
@defproc[(make-bitmap [width exact-positive-integer?] @defproc[(make-bitmap [width exact-positive-integer?]
[height exact-positive-integer?] [height exact-positive-integer?]
[alpha? any/c #t]) [alpha? any/c #t])
@ -38,3 +65,35 @@ overloaded.}
Returns @racket[(make-object bitmap% in kind)], but this procedure is Returns @racket[(make-object bitmap% in kind)], but this procedure is
preferred because it defaults @racket[kind] in a more useful way.} preferred because it defaults @racket[kind] in a more useful way.}
@defthing[the-brush-list (is-a?/c brush-list%)]{
See @scheme[brush-list%].
}
@defthing[the-color-database (is-a?/c color-database<%>)]{
See @scheme[color-database<%>].
}
@defthing[the-font-list (is-a?/c font-list%)]{
See @scheme[font-list%].
}
@defthing[the-font-name-directory (is-a?/c font-name-directory<%>)]{
See @scheme[font-name-directory<%>].
}
@defthing[the-pen-list (is-a?/c pen-list%)]{
See @scheme[pen-list%].
}

View File

@ -0,0 +1,36 @@
#lang scribble/doc
@(require "common.ss")
@title{@bold{Draw}: Racket Drawing Toolkit}
@author["Matthew Flatt" "Robert Bruce Findler" "John Clements"]
@declare-exporting[racket/draw]
@defmodule*/no-declare[(racket/draw)]{The
@racketmodname[racket/draw] library provides all of the class,
interface, and procedure bindings defined in this manual.}
@table-of-contents[]
@;------------------------------------------------------------------------
@include-section["guide.scrbl"]
@include-section["reference.scrbl"]
@;------------------------------------------------------------------------
@(bibliography
(bib-entry #:key "Adobe99"
#:author "Adobe Systems Incorporated"
#:title "PostScript Language Reference, third edition"
#:is-book? #t
#:url "http://partners.adobe.com/public/developer/en/ps/PLRM.pdf"
#:date "1999")
)
@;------------------------------------------------------------------------
@index-section[]

View File

@ -25,17 +25,9 @@ A @defterm{font} is an object which determines the appearance of text,
@item{@indexed-scheme['modern] (fixed width)} @item{@indexed-scheme['modern] (fixed width)}
@item{@indexed-scheme['symbol] (Greek letters and more)} @item{@indexed-scheme['symbol] (Greek letters and more)}
@item{@indexed-scheme['system] (used to draw control labels)} @item{@indexed-scheme['system] (used to draw control labels)}
] ]}
The @scheme['symbol] designation is special under Mac OS X and X with @item{face --- A string face name, such as @scheme["Courier"]. The format
fontconfig/Xft; characters in the ASCII range 0-255 are converted to
Unicode characters that match Adobe symbols. For example, @litchar{a} is
converted to @litchar["\u03B1"].}
@item{face --- A string face name, such as @scheme["Courier"] (under
Windows and Mac OS X), @scheme["-*-courier"] (under
X), or @scheme[" Luxi Sans"] (under X with
fontconfig/Xft; note the leading space). The format
and meaning of a face name is platform- and and meaning of a face name is platform- and
device-specific. If a font's face name is @scheme[#f], device-specific. If a font's face name is @scheme[#f],
then the font's appearance depends only on the then the font's appearance depends only on the
@ -49,8 +41,8 @@ A @defterm{font} is an object which determines the appearance of text,
@item{style --- The slant style of the font, one of: @item{style --- The slant style of the font, one of:
@itemize[ @itemize[
@item{@indexed-scheme['normal]} @item{@indexed-scheme['normal]}
@item{@indexed-scheme['slant] (Windows, Mac OS X: same as @scheme['italic]; X: tries @scheme['italic] if @scheme['slant] font does not exist)} @item{@indexed-scheme['slant] (a.k.a ``oblique'')}
@item{@indexed-scheme['italic] (X: tries @scheme['slant] if @scheme['italic] font does not exist)} @item{@indexed-scheme['italic]}
]} ]}
@item{weight --- The weight of the font, one of: @item{weight --- The weight of the font, one of:
@ -65,17 +57,10 @@ A @defterm{font} is an object which determines the appearance of text,
@item{smoothing --- Amount of anti-alias smoothing, one of: @item{smoothing --- Amount of anti-alias smoothing, one of:
@itemize[ @itemize[
@item{@indexed-scheme['default] (platform-specific, sometimes user-configurable)} @item{@indexed-scheme['default] (platform-specific, sometimes user-configurable)}
@item{@indexed-scheme['partly-smoothed] (Windows: TrueType when available; @item{@indexed-scheme['partly-smoothed] (gray anti-aliasing)}
Mac OS X: 4-bit, pixel-aligned smoothing; @item{@indexed-scheme['smoothed] (sub-pixel anti-aliasing)}
X: fontconfig/Xft when available)}
@item{@indexed-scheme['smoothed] (Windows: ClearType when available, XP and up;
Mac OS X: Quartz smoothing;
X: fontconfig/Xft when available)}
@item{@indexed-scheme['unsmoothed]} @item{@indexed-scheme['unsmoothed]}
] ]}
Special case: @scheme['default] corresponds to
@scheme['partly-smoothed] when used with the @scheme['modern] family
and a font size between 9 and 13 (inclusive).}
@item{size-in-pixels? --- @scheme[#t] if the size of the font @item{size-in-pixels? --- @scheme[#t] if the size of the font
is in logical drawing units (i.e., pixels for an unscaled screen or is in logical drawing units (i.e., pixels for an unscaled screen or
@ -113,11 +98,7 @@ See also
When no arguments are provided, creates an instance of the default When no arguments are provided, creates an instance of the default
font. If no face name is provided, the font is created without a face font. If no face name is provided, the font is created without a face
name. Otherwise, see @scheme[font-name-directory<%>] for information name.
about the way @scheme[face] is interpreted for drawing text on
various platforms and devices; when a platform- or device-specific
interpretation of @scheme[face] is not available, the @scheme[family]
is used to draw text.
See @scheme[font%] for information about @scheme[family], See @scheme[font%] for information about @scheme[family],
@scheme[style], and @scheme[weight]. @scheme[font-name-directory<%>]. @scheme[style], and @scheme[weight]. @scheme[font-name-directory<%>].

View File

@ -5,23 +5,15 @@
@definterface/title[font-name-directory<%> ()]{ @definterface/title[font-name-directory<%> ()]{
There is one @scheme[font-name-directory<%>] object: There is one @scheme[font-name-directory<%>] object:
@scheme[the-font-name-directory]. It implements the mapping from font @scheme[the-font-name-directory]. It implements a mapping from font
specifications (face, family, style, and weight) to information for specifications (face, family, style, and weight) to information for
rendering text on a specific device. The mapping is different for rendering text on a specific device. Programmers rarely need to
each platform. For example, when drawing to a bitmap in Windows, the directly invoke methods of @scheme[the-font-name-directory]. It is
rendering information is simply the name of a Windows font. When used automatically when drawing text to a @scheme[dc<%>]
drawing to a PostScript file, the rendering information is a object. Nevertheless, @scheme[the-font-name-directory] is available
PostScript font name, which encapsulates the style and weight. When so that programmers can query or modify the mapping manually. A
drawing to a bitmap in X, the rendering information is an X font programmer may also need to understand how the face-and-family
string, which encapsulates the style and weight, parameterized over mapping works.
the size (using a ``%d'' placeholder).
Programmers rarely need to directly invoke methods of
@scheme[the-font-name-directory]. It is used automatically when
drawing text to a @scheme[dc<%>] object. Nevertheless,
@scheme[the-font-name-directory] is available so that programmers can
query or modify the mapping manually. A programmer may also need to
understand how the face-and-family mapping works.
To extract mapping information from @scheme[the-font-name-directory], To extract mapping information from @scheme[the-font-name-directory],
first obtain a @defterm{font ID}, which is an index based on a family first obtain a @defterm{font ID}, which is an index based on a family
@ -33,69 +25,13 @@ To extract mapping information from @scheme[the-font-name-directory],
@method[font-name-directory<%> get-post-script-name]. @method[font-name-directory<%> get-post-script-name].
For a family without a face string, the corresponding font ID has a For a family without a face string, the corresponding font ID has a
useful built-in mapping for every platform and device. (The built-in useful built-in mapping for every platform and device. For a family with a
mapping can be overridden through the user's preferences; see
@secref["fontresources"] for information.) For a family with a
face string, @scheme[the-font-name-directory] interprets the string face string, @scheme[the-font-name-directory] interprets the string
(in a platform-specific way) to generate a mapping for ``screen'' (in a platform-specific way) to generate a mapping for ``screen''
drawing (to a canvas's @scheme[dc<%>], a @scheme[bitmap-dc%], or a drawing (to a canvas's @scheme[dc<%>], a @scheme[bitmap-dc%], or a
@scheme[printer-dc%]). When drawing to a @scheme[post-script-dc%] @scheme[printer-dc%]). When drawing to a @scheme[post-script-dc%]
object, the face-specific mapping defaults to the family's mapping. object, the face-specific mapping defaults to the family's mapping.
Under Windows and Mac OS X, a face name is interpreted simply as a
system font name for drawing to the screen, bitmap, or printer. The
mapping succeeds if the system provides a font with the given name,
and fails otherwise. For example, under Windows, @scheme["MS Sans
Serif"] maps to the font that is typically used for button
labels. Under X, a face name has a more complex interpretation:
@itemize[
@item{If the string begins with a space, then the remainder of the
string is interpreted as a fontconfig/Xft font name, but only
if fontconfig/Xft support is enabled at compile time (which is
the default when available), and only if the RENDER extension
is available at run time. Multiple fontconfig/Xft font names
can appear after the initial space, separated by commas; the
first available font is used to draw text, and later fonts are
substituted for missing characters in earlier fonts.}
@item{If the string begins with @litchar{+}, then the remainder of the
string is interpreted as an X font name. These names are
usually long, such as
@litchar{+-b&h-lucidatypewriter-medium-r-normal-sans-24-240-75-75-m-140-iso8859-1}.
As usual for X font names, asterisks may appear in the string
as wildcards. Furthermore, the size of the font can be
parameterized by using @litchar{%d} in the place of a specific
point size; if an asterisk appears in place of the pixel size,
the asterisk and @litchar{%d} are swapped when the font size is
specified in pixels (otherwise the size is always interpreted
as points). For rotated text, @litchar{%d} will be replaced by
a transformation matrix.}
@item{A string of the form
@litchar{-}@nonterm{provider}@litchar{-}@nonterm{font} is
equivalent to
@litchar{+-}@nonterm{provider}@litchar{-}@nonterm{font}@litchar{-}@nonterm{weight}@litchar{-}@nonterm{style}@litchar{-normal-*-*-%d-*-*-*-*-*-*},
where @nonterm{weight} is either @litchar{medium},
@litchar{light}, or @litchar{bold} (depending on the requested
weight mapping) and @nonterm{style} is either @litchar{r},
@litchar{i}, or @litchar{i} (depending on the requested style
mapping).}
@item{A string of the form @litchar{-}@nonterm{font} is
equivalent to @litchar{-*-}@nonterm{font}.}
@item{A string of any other format is interpreted as an X font name,
optionally parameterized with @litchar{%d}.}
]
The mapping for face names can be overridden (on all platforms)
through the user's preferences, as described in
@secref["fontresources"].
@defmethod[(find-family-default-font-id [family (one-of/c 'default 'decorative 'roman 'script @defmethod[(find-family-default-font-id [family (one-of/c 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)]) 'swiss 'modern 'symbol 'system)])
@ -157,9 +93,7 @@ Font ID are useful only as mapping indices for
(or/c string? false/c)]{ (or/c string? false/c)]{
Gets a PostScript font name for a font ID, weight, and style Gets a PostScript font name for a font ID, weight, and style
combination. The PostScript font name is used both for the font name combination.
in PostScript output (sans character set) and as the @|AFM| file
name; see also @secref["postscriptfonts"].
See @scheme[font%] for information about @scheme[weight] and See @scheme[font%] for information about @scheme[weight] and
@scheme[style]. @scheme[style].
@ -204,10 +138,6 @@ Sets a platform-dependent screen font name (used for drawing to a
canvas's @scheme[dc<%>], a @scheme[bitmap-dc%], or a canvas's @scheme[dc<%>], a @scheme[bitmap-dc%], or a
@scheme[printer-dc%]) for a font ID, weight, and style combination. @scheme[printer-dc%]) for a font ID, weight, and style combination.
Under X, if the screen name contains @litchar{%d}, it is replaced by
the size of the font (point size times 10) to obtain the full screen
font name.
See @scheme[font%] for information about @scheme[weight] and See @scheme[font%] for information about @scheme[weight] and
@scheme[style]. @scheme[style].

View File

@ -1,28 +1,17 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/eval @(require scribble/eval
"common.ss" "common.ss")
"diagrams.ss")
@title[#:tag "drawing-overview"]{Drawing} @title[#:tag "overview"]{Overview}
Drawing in Racket requires a @deftech{device context} Drawing with @racketmodname[racket/draw] uses a @deftech{device context}
(@deftech{DC}), which is an instance of the @scheme[dc<%>] (@deftech{DC}), which is an instance of the @scheme[dc<%>]
interface. For example, the @method[canvas<%> get-dc] method of a interface. For example, the @racket[post-script-dc%] class implements
a @racket[dc<%>] for drawing to a PostScript file, while @racket[bitmap-dc%]
draws to a bitmap. When using the @racketmodname[racket/gui] library for GUIs,
the @method[canvas<%> get-dc] method of a
canvas returns a @scheme[dc<%>] instance for drawing into the canvas canvas returns a @scheme[dc<%>] instance for drawing into the canvas
window. Other kinds of DCs draw to different kinds of devices: window.
@itemize[
@item{@scheme[bitmap-dc%] --- a @deftech{bitmap DC} draws to an
offscreen bitmap.}
@item{@scheme[post-script-dc%] --- a @deftech{PostScript DC}
records drawing commands to a PostScript file.}
@item{@scheme[printer-dc%] --- a @deftech{printer DC} draws to a
platform-specific printer device (Windows, Mac OS X).}
]
Tools that are used for drawing include the following: @scheme[pen%] Tools that are used for drawing include the following: @scheme[pen%]
objects for drawing lines and shape outlines, @scheme[brush%] objects for drawing lines and shape outlines, @scheme[brush%]
@ -30,20 +19,11 @@ Tools that are used for drawing include the following: @scheme[pen%]
bitmaps, and @scheme[dc-path%] objects for describing paths to draw bitmaps, and @scheme[dc-path%] objects for describing paths to draw
and fill. and fill.
The following example creates a frame with a drawing canvas, and then The following example uses the GUI library as well as the drawing
draws a round, blue face with square, yellow eyes and a smiling, red library. It creates a frame with a drawing canvas, and then draws a
mouth: round, blue face with square, yellow eyes and a smiling, red mouth:
@schemeblock[ @schemeblock[
(code:comment @#,t{Make a 300 x 300 frame})
(define frame (new frame% [label "Drawing Example"]
[width 300]
[height 300]))
(code:comment @#,t{Make the drawing area})
(define canvas (new canvas% [parent frame]))
(code:comment @#,t{Get the canvas's drawing context})
(define dc (send canvas #,(:: canvas<%> get-dc)))
(code:comment @#,t{Make some pens and brushes}) (code:comment @#,t{Make some pens and brushes})
(define no-pen (make-object pen% "BLACK" 1 'transparent)) (define no-pen (make-object pen% "BLACK" 1 'transparent))
(define no-brush (make-object brush% "BLACK" 'transparent)) (define no-brush (make-object brush% "BLACK" 'transparent))
@ -66,44 +46,15 @@ The following example creates a frame with a drawing canvas, and then
(let ([-pi (atan 0 -1)]) (let ([-pi (atan 0 -1)])
(send dc #,(:: dc<%> draw-arc) 75 75 150 150 (* 5/4 -pi) (* 7/4 -pi)))) (send dc #,(:: dc<%> draw-arc) 75 75 150 150 (* 5/4 -pi) (* 7/4 -pi))))
(code:comment @#,t{Show the frame})
(send frame #,(:: top-level-window<%> show) #t)
(code:comment @#,t{Wait a second to let the window get ready})
(sleep/yield 1)
(code:comment @#,t{Draw the face})
(draw-face dc)
]
The @scheme[sleep/yield] call is necessary under X because
drawing to the canvas has no effect when the canvas is not
shown. Although the @scheme[(send frame #,(:: top-level-window<%> show) #t)]
expression queues a show request for the frame, the actual display of
the frame and its canvas requires handling several events. The
@scheme[sleep/yield] procedure pauses for a specified number
of seconds, handling events while it pauses.
One second is plenty of time for the frame to show itself, but a
better solution is to create a canvas with a paint callback function
(or overriding @method[canvas<%> on-paint]). Using a paint
callback function is better for all platforms; when the canvas in the
above example is resized or temporarily covered by another window,
the face disappears. To ensure that the face is redrawn whenever the
canvas itself is repainted, we provide a paint callback when creating
the canvas:
@schemeblock[
(code:comment @#,t{Make a 300 x 300 frame}) (code:comment @#,t{Make a 300 x 300 frame})
(define frame (new frame% [label "Drawing Example"] (define frame (new frame% [label "Drawing Example"]
[width 300] [width 300]
[height 300])) [height 300]))
(code:comment @#,t{Make the drawing area, and set its paint callback})
(code:comment @#,t{Make the drawing area with a paint callback}) (code:comment @#,t{to use the @racket[draw-face] function:})
(define canvas (define canvas (new canvas%
(new canvas% [parent frame] [parent frame]
[paint-callback [paint-callback (lambda (c dc) (draw-face dc))]))
(lambda (canvas dc) (draw-face dc))]))
(code:comment @#,t{... pens, brushes, and @scheme[draw-face] are the same as above ...})
(code:comment @#,t{Show the frame}) (code:comment @#,t{Show the frame})
(send frame #,(:: top-level-window<%> show) #t) (send frame #,(:: top-level-window<%> show) #t)
@ -163,7 +114,7 @@ More complex shapes are typically best implemented with
@(begin @(begin
#readerscribble/comment-reader #readerscribble/comment-reader
[schemeblock [schemeblock
(require mzlib/math) ; for @scheme[pi] (require racket/math) ; for @scheme[pi]
;; Construct paths for a 630 x 630 logo ;; Construct paths for a 630 x 630 logo

View File

@ -0,0 +1,3 @@
#lang setup/infotab
(define scribblings '(("draw.scrbl" (multi-page) (gui-library 101))))

View File

@ -1,8 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require "common.ss" @(require "common.ss")
"diagrams.ss")
@title[#:style '(toc quiet)]{Drawing Classes} @title[#:style '(toc reveal)]{Reference}
@local-table-of-contents[] @local-table-of-contents[]
@ -23,6 +22,6 @@
@include-section["pen-list-class.scrbl"] @include-section["pen-list-class.scrbl"]
@include-section["point-class.scrbl"] @include-section["point-class.scrbl"]
@include-section["post-script-dc-class.scrbl"] @include-section["post-script-dc-class.scrbl"]
@include-section["printer-dc-class.scrbl"]
@include-section["ps-setup-class.scrbl"] @include-section["ps-setup-class.scrbl"]
@include-section["region-class.scrbl"] @include-section["region-class.scrbl"]
@include-section["draw-funcs.scrbl"]

View File

@ -6,9 +6,17 @@
scribble/decode scribble/decode
(for-label scheme/gui/base (for-label scheme/gui/base
scheme/base) scheme/base)
(for-syntax scheme/base)) (for-syntax scheme/base)
(only-in scribblings/draw/blurbs
res-sym
Resource
ResourceFirst
boxisfill
boxisfillnull
MismatchExn))
(provide (except-out (all-defined-out) p define-inline)) (provide (except-out (all-defined-out) p define-inline)
(all-from-out scribblings/draw/blurbs))
(define-syntax-rule (define-inline (name) body) (define-syntax-rule (define-inline (name) body)
(define-syntax (name stx) (define-syntax (name stx)
@ -193,8 +201,6 @@ information@|details|, even if the editor currently has delayed refreshing (see
@scheme[min-width], @scheme[min-height], @scheme[stretchable-width], and @scheme[min-width], @scheme[min-height], @scheme[stretchable-width], and
@scheme[stretchable-height] arguments, see @scheme[area<%>].}) @scheme[stretchable-height] arguments, see @scheme[area<%>].})
(define MismatchExn @elem{an @scheme[exn:fail:contract] exception is raised})
(define AFM @elem{Adobe Font Metrics}) (define AFM @elem{Adobe Font Metrics})
(define (MonitorMethod what by-what method whatsit) (define (MonitorMethod what by-what method whatsit)
@ -244,18 +250,6 @@ information@|details|, even if the editor currently has delayed refreshing (see
(hspace 1) (hspace 1)
(bytes->string/latin-1 name)))) (bytes->string/latin-1 name))))
(define (res-sym s)
(string->symbol (string-append "GRacket:" s)))
(define (Resource s)
@elem{@to-element[`(quote ,(res-sym s))]
preference})
(define (ResourceFirst s) ; fixme -- add index
(let ([r (Resource s)])
(index* (list (format "~a preference" (res-sym s)))
(list r)
r)))
(define (edsnipsize a b c) (define (edsnipsize a b c)
@elem{An @scheme[editor-snip%] normally stretches to wrap around the size @elem{An @scheme[editor-snip%] normally stretches to wrap around the size
of the editor it contains. This method @|a| of the snip of the editor it contains. This method @|a| of the snip
@ -269,11 +263,6 @@ information@|details|, even if the editor currently has delayed refreshing (see
"smaller" "smaller"
@elem{the editor is @|b|-aligned in the snip})) @elem{the editor is @|b|-aligned in the snip}))
(define (boxisfill which what)
@elem{The @|which| box is filled with @|what|.})
(define (boxisfillnull which what)
@elem{The @|which| box is filled with @|what|, unless @|which| is @scheme[#f].})
(define (slant . s) (define (slant . s)
(make-element "slant" (decode-content s))) (make-element "slant" (decode-content s)))

View File

@ -1,9 +0,0 @@
#lang scribble/doc
@(require "common.ss")
@title[#:style 'toc]{Configuration}
@local-table-of-contents[]
@include-section["prefs.scrbl"]
@include-section["font-config.scrbl"]

View File

@ -1,12 +0,0 @@
#lang scribble/doc
@(require "common.ss")
@title{Drawing Functions}
@local-table-of-contents[]
@include-section["global-draw-funcs.scrbl"]
@include-section["post-script-funcs.scrbl"]
@include-section["draw-list-funcs.scrbl"]
@include-section["bitmap-funcs.scrbl"]
@include-section["font-funcs.scrbl"]

View File

@ -1,36 +0,0 @@
#lang scribble/doc
@(require "common.ss")
@title{Drawing Object Lists}
@defthing[the-brush-list (is-a?/c brush-list%)]{
See @scheme[brush-list%].
}
@defthing[the-color-database (is-a?/c color-database<%>)]{
See @scheme[color-database<%>].
}
@defthing[the-font-list (is-a?/c font-list%)]{
See @scheme[font-list%].
}
@defthing[the-font-name-directory (is-a?/c font-name-directory<%>)]{
See @scheme[font-name-directory<%>].
}
@defthing[the-pen-list (is-a?/c pen-list%)]{
See @scheme[pen-list%].
}

View File

@ -1,386 +0,0 @@
#lang scribble/doc
@(require "common.ss"
scribble/bnf)
@title[#:tag "fontresources"]{Font Configuration}
This chapter describes how to set up face mappings for screen and
PostScript fonts via preferences (see @|mrprefsdiscuss|). The
font-configuration system is overkill; it was designed to handle
especially complex X font mappings before fontconfig/Xft solved the
problem.
An implementor for a GRacket-based program may find it easier to use the
@method[font-name-directory<%> set-screen-name] and
@method[font-name-directory<%> set-post-script-name] methods
provided by @scheme[the-font-name-directory]. As a user of a
GRacket-based program, preferences provide a mechanism for setting
default mappings.
Whether a programmer or a user, see @scheme[font-name-directory<%>] for
an overview of the font mapping system.
To find a font name for a family, GRacket looks for a preference name by
concatenating @litchar{MrEd:}, a @nonterm{dest}, a @nonterm{type},
a @nonterm{weight}, and a @nonterm{style}, where
@itemize[
@item{@nonterm{dest} is either @litchar{Screen} or @litchar{PostScript}.}
@item{@nonterm{type} is either @litchar{Default}, @litchar{Decorative}, @litchar{Roman}, @litchar{Script},
@litchar{Swiss}, @litchar{Modern}, @litchar{System}, or @litchar{Symbol} for a mapping
defining the default font for a family. Otherwise, it is a
face name prefixed with @litchar["@"].}
@item{@nonterm{weight} is either @litchar{Medium}, @litchar{Bold}, or @litchar{Light}.}
@item{@nonterm{style} is either @litchar{Straight}, @litchar{Italic}, or @litchar{Slant}.}
]
Furthermore, any of the latter three parts can be wildcarded with
@litchar{_}, as described below. The concatenated string is converted
to a symbol (preserving case), and the associated preference value
must be a string.
The value of the preference is parsed as described in
@scheme[font-name-directory<%>] for parsing face names, except that
the string can contain references and other tricks described below.
@; ------------------------------------------------------------------------
@section[#:tag "exampleresources"]{Wildcards}
Building items names by concatenating @nonterm{dest}, @nonterm{type},
@nonterm{weight}, and @nonterm{style} can create a large number of preference
entries, and the @nonterm{weight} and @nonterm{style} parts are useful only
for X screen fonts. To avoid an explosion of preferences, GRacket finds
preferences via a wildcarding search.
The @nonterm{type}, @nonterm{weight}, and @nonterm{style} parts of a preference name
can be wildcarded by using @litchar{_}. Thus, to set the default font
in X for all types, weights, and styles, use the following preference
entry:
@schemeblock[
(MrEd:Screen___ "+-*-*-medium-r-normal-*-*-%d-*-*-*-*-*-*")
]
Wildcarded preference entries are used only when un-wildcarded values
cannot be found. If two preference names both match for some search,
then the one with the ``earliest'' (i.e., closest to the beginning of
the preference name) non-wildcarded part will prevail.
The default GRacket preferences for Windows uses wildcarding to specify
the basic font mapping, as if written as:
@schemeblock[
(MrEd:ScreenSystem__ "MS Sans Serif")
(MrEd:ScreenRoman__ "Times New Roman")
(MrEd:ScreenDecorative__ "Modern")
....
]
Wildcarding in the preference name naturally leads to references,
variables, and wildcarding references in the preference
value. These features are described in the following few sections.
@; ------------------------------------------------------------------------
@section{References}
Suppose we define the mapping for variants of @scheme["Default"], and
then we want @scheme["Roman"] to use this setting, too. We could copy
the preference entry, as in the following example:
@schemeblock[
(|MrEd:ScreenDefault__| "+-*-*-medium-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenRoman__| "+-*-*-medium-r-normal-*-*-%d-*-*-*-*-*-*")
]
but the GRacket font-reading system provides a better syntax for
referencing another preference entry. When a preference value contains
@litchar{${x}}, then the @litchar{${x}} fragment is replaced by the
preference value of @litchar{x}. Thus, the above can be re-written:
@schemeblock[
(|MrEd:ScreenDefault__| "+-*-*-medium-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenRoman__| "${ScreenDefault__}")
]
A mini-language of @litchar{${x}} is used within the string (instead
of an S-expression format) for historical reasons.
@; ------------------------------------------------------------------------
@section{Variables}
Variables can be used with referencing to configure default values
based on the weight and style that is needed. When a preference
value contains @litchar{$[weight]}, then @litchar{$[weight]} is
replaced with a string for the desired font weight. Similarly,
@litchar{$[style]} is replaced with the desired style. Variable
expressions can be embedded within referencing expressions, as in the
following example:
@schemeblock[
(|MrEd:ScreenDefault__|
"+-*-*-${Def$[weight]}-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:DefMedium| "medium")
(|MrEd:DefBold| "bold")
(|MrEd:DefLight| "medium")
]
Now, when the @Resource{ScreenDefault__} value is used for different
weights, it will return different values; the
@litchar{${Def$[weight]}} expression will turn into
@litchar{${DefMedium}} for a medium-weight lookup, or
@litchar{${DefBold}} for a bold-weight lookup. These references
will in turn give either @litchar{medium} or @litchar{bold}.
@; ------------------------------------------------------------------------
@section{Wildcarding References}
Consider the following preference configuration:
@schemeblock[
(|MrEd:ScreenDefault__| "+-*-*-medium-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenDefaultBold_| "+-*-*-bold-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenRoman__| "${ScreenDefault__}")
]
The effect of this statement is probably not what was intended; when a
bold version of the @litchar{Roman} font is needed, the
@Resource{ScreenRoman__} value references the
@Resource{ScreenDefault__} value, which does not specify a bold font. We
could try to remedy the situation as follows:
@schemeblock[
(|MrEd:ScreenDefault__| "+-*-*-medium-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenDefaultBold_| "+-*-*-bold-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenRoman__| "${ScreenDefault$[weight]_}")
]
but this does not work either. It works fine for bold @litchar{Roman},
now, but medium @litchar{Roman} will cause a reference to the
@Resource{ScreenDefaultMedium_}, which doesn't exist. The problem is
that our reference does not use wildcarding like the original medium
@litchar{Roman} lookup did.
Wildcarding can be specified in a reference by separating each
wildcardable field with a comma. The following preference specification
does what we want:
@schemeblock[
(|MrEd:ScreenDefault__| "+-*-*-medium-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenDefaultBold_| "+-*-*-bold-r-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenRoman__| "${ScreenDefault,$[weight],_}")
]
Since @litchar{$[weight]} is between commas, it can be wildcarded if
no name exactly matching @litchar{ScreenDefault$[weight]_} is
found. In this case @litchar{ScreenDefault} and @litchar{_} can
also be wildcarded, but this will have no effect.
The wildcarding used in references need not reflect the wildcarding
GRacket initial uses for finding fonts. In other words, a number of
comma-separated selects can appear between the curly braces.
@; ------------------------------------------------------------------------
@section{Internal Preferences}
The initial font setup is built into GRacket through a built-in preference
table. The table is shown at the end of this section. When font
information is computed, it is @italic{almost} as if this table were
installed into your preferences file; the difference is that preference
specifications in your file override specifications in the built-in
table, even when the wildcarding of your preference provides a weaker
match.
When no information is available for mapping a face name to a font,
GRacket falls back to the system described in
@scheme[font-name-directory<%>]. (Since a mapping is built into GRacket
for every family, information is always available for the default
font of a family.)
Internal preferences for all platforms:
@schemeblock[
(|MrEd:PostScriptMediumStraight| "")
(|MrEd:PostScriptMediumItalic| "-Oblique")
(|MrEd:PostScriptMediumSlant| "-Oblique")
(|MrEd:PostScriptLightStraight| "")
(|MrEd:PostScriptLightItalic| "-Oblique")
(|MrEd:PostScriptLightSlant| "-Oblique")
(|MrEd:PostScriptBoldStraight| "-Bold")
(|MrEd:PostScriptBoldItalic| "-BoldOblique")
(|MrEd:PostScriptBoldSlant| "-BoldOblique")
(|MrEd:PostScript___| "${PostScript$[family],$[weight],$[style]}")
(|MrEd:PostScriptSystem__| "${PostScriptTimes,$[weight],$[style]}")
(|MrEd:PostScriptRoman__| "${PostScriptTimes,$[weight],$[style]}")
(|MrEd:PostScriptDecorative__| "${PostScriptTimes,$[weight],$[style]}")
(|MrEd:PostScriptScript__| "ZapfChancery-MediumItalic")
(|MrEd:PostScriptTimesMedium| "")
(|MrEd:PostScriptTimesLight| "")
(|MrEd:PostScriptTimesBold| "Bold")
(|MrEd:PostScriptTimes__| "Times${PostScript$[weight]$[style]}")
(|MrEd:PostScriptTimesMediumStraight| "Times-Roman")
(|MrEd:PostScriptTimesLightStraight| "Times-Roman")
(|MrEd:PostScriptTimes_Slant|
"Times-${PostScriptTimes$[weight]}Italic")
(|MrEd:PostScriptTimes_Italic|
"Times-${PostScriptTimes$[weight]}Italic")
(|MrEd:PostScriptDefault__| "Helvetica${PostScript$[weight]$[style]}")
(|MrEd:PostScriptSwiss__| "Helvetica${PostScript$[weight]$[style]}")
(|MrEd:PostScriptModern__| "Courier${PostScript$[weight]$[style]}")
(|MrEd:PostScriptSymbol__| "Symbol")
]
Internal preferences for X with fontconfig/Xft/RENDER only:
@schemeblock[
(|MrEd:ScreenSystem__| " Sans")
(|MrEd:ScreenDefault__| " Sans")
(|MrEd:ScreenRoman__| " Serif")
(|MrEd:ScreenDecorative__| " Nimbus Sans L")
(|MrEd:ScreenModern__| " Monospace")
(|MrEd:ScreenSwiss__| " Nimbus Sans L")
(|MrEd:ScreenScript__| " URW Chancery L")
(|MrEd:ScreenSymbolBase| " Standard Symbols L,Nimbus Sans L")
]
Internal preferences for X only (except those overridden for fontconfig/Xft/RENDER):
@schemeblock[
(|MrEd:ScreenMedium| "medium")
(|MrEd:ScreenBold| "bold")
(|MrEd:ScreenLight| "light")
(|MrEd:ScreenStraight| "r")
(|MrEd:ScreenItalic| "i")
(|MrEd:ScreenSlant| "o")
(|MrEd:ScreenSystemBase| "*-lucida")
(|MrEd:ScreenDefaultBase| "*-lucida")
(|MrEd:ScreenRomanBase| "*-times")
(|MrEd:ScreenDecorativeBase| "*-helvetica")
(|MrEd:ScreenModernBase| "*-courier")
(|MrEd:ScreenSwissBase| "*-lucida")
(|MrEd:ScreenScriptBase| "*-zapfchancery")
(|MrEd:ScreenSymbolBase| "*-symbol")
(|MrEd:ScreenStdSuffix|
"-${Screen$[weight]}-${Screen$[style]}-normal-*-*-%d-*-*-*-*-*-*")
(|MrEd:ScreenSystem__| "+-${ScreenSystemBase}${ScreenStdSuffix}")
(|MrEd:ScreenDefault__| "+-${ScreenDefaultBase}${ScreenStdSuffix}")
(|MrEd:ScreenRoman__| "+-${ScreenRomanBase}${ScreenStdSuffix}")
(|MrEd:ScreenDecorative__|
"+-${ScreenDecorativeBase}${ScreenStdSuffix}")
(|MrEd:ScreenModern__| "+-${ScreenModernBase}${ScreenStdSuffix}")
(|MrEd:ScreenSwiss__| "+-${ScreenSwissBase}${ScreenStdSuffix}")
(|MrEd:ScreenScript__| "+-${ScreenScriptBase}${ScreenStdSuffix}")
(|MrEd:ScreenSymbol__|
"+-${ScreenSymbolBase}-medium-r-normal-*-*-%d-*-*-*-*-*-*")
]
Internal preferences for Windows only:
@schemeblock[
(|MrEd:ScreenSystem__| "MS Sans Serif")
(|MrEd:ScreenDefault__| "MS Sans Serif")
(|MrEd:ScreenRoman__| "Times New Roman")
(|MrEd:ScreenDecorative__| "Arial")
(|MrEd:ScreenModern__| "Courier New")
(|MrEd:ScreenSwiss__| "Arial")
(|MrEd:ScreenScript__| "Arial")
(|MrEd:ScreenSymbol__| "Symbol")
]
Internal preferences for Mac OS X only:
@schemeblock[
(|MrEd:ScreenDefault__| "Lucida Grande")
(|MrEd:ScreenSystem__| "Lucida Grande")
(|MrEd:ScreenRoman__| "Times")
(|MrEd:ScreenDecorative__| "Arial")
(|MrEd:ScreenModern__| "Courier New")
(|MrEd:ScreenSwiss__| "Helvetica")
(|MrEd:ScreenScript__| "Apple Chancery")
(|MrEd:ScreenSymbol__| "Symbol")
]
@; ------------------------------------------------------------------------
@section[#:tag "postscriptfonts"]{PostScript Fonts}
@section-index["fonts" "PostScript"]
@section-index["PostScript fonts"]
@section-index["AFM"]
@section-index["CID"]
@section-index["CMap"]
To generate PostScript output, GRacket must be able to find an @|AFM|
(AFM) file corresponding to the PostScript font. An AFM file
typically uses the suffix @indexed-file{.afm}, and several AFM files
are distributed with GRacket in the @filepath{afm} collection.
GRacket finds an AFM file by adding a @filepath{.afm} suffix to the
PostScript name of the font, and checking all directories specified
by the @scheme[current-ps-afm-file-paths] parameter. The initial
value of this parameter is determined by the
@indexed-envvar{PLTAFMPATHS} environment variable; the environment
variable's setting is parsed with
@scheme[path-list-string->path-list] using @scheme[(list
(collection-path "afm"))] as the default list.
Depending on whether the font is CID-based (typically for the Chinese,
Japanese, Korean, and Vietnamese language families, and as indicated
in the AFM file), GRacket must find additional files:
@itemize[
@item{@italic{Non-CID:} In addition to an AFM file
@filepath{@nonterm{x}.afm}, GRacket looks for a
@filepath{@nonterm{x}-glyphlist.txt} file (in the same directory as the
AFM file) to map glyph names in the AFM file to Unicode character
values. In addition to this font-specific file, GRacket looks for a
@indexed-file{glyphlist.txt} file to supply a mapping for Adobe's
standard glyph names, and this mapping is used when a font-specific
mapping is not supplied, or when the mapping does not cover a name
found in the AFM file. GRacket looks for @filepath{glyphlist.txt} in the
same place as AFM files. Since @filepath{glyphlist.txt} is large, if a
@indexed-file{glyphshortlist.txt} file is available, it is read first,
and then @filepath{glyphlist.txt} is read only if a character name must
be resolved that is not in @filepath{glyphshortlist.txt}.}
@item{@italic{CID:} In addition to an AFM file, GRacket must find and
read CMap files to convert glyph IDs for the font to Unicode
characters. The character set name is used as the name of the CMap
file to load, and GRacket checks all directories specified by the
@scheme[current-ps-cmap-file-paths] parameter. The initial value of
this parameter is determined by the @indexed-envvar{PLTCMAPPATHS}
environment variable; the environment variable's setting is parsed
with @scheme[path-list-string->path-list] using @scheme[(list
(collection-path "afm" "CMap"))] as the default list. In addition to
a CMap file for the font's character set, GRacket must find a
@indexed-file{UniCNS-UTF32-H} CMap file to complete the mapping to
Unicode. GRacket automatically adds the font's character set to the font
name when producing PostScript with a CID-based font.}
]
When drawing or measuring text using a particular PostScript font, if
the font does not contain a glyph for a character (or if a relevant
AFM file cannot be found for the font), then GRacket attempts to
substitute another PostScript font. A substitute font is selected by
checking all @filepath{.afm} files in the directories specified
by @scheme[current-ps-afm-file-paths] (in order), and choosing the
first discovered match.

View File

@ -3,28 +3,6 @@
@title{Fonts} @title{Fonts}
@defproc[(get-face-list [family (one-of/c 'mono 'all) 'all])
(listof string?)]{
Returns a list of font face names available on the current system. If
@scheme['mono] is provided as the argument, then only faces that are
known to correspond to monospace fonts are included in the list.
}
@defproc[(get-family-builtin-face [family (one-of/c 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)])
string?]{
Returns the built-in default face mapping for a particular font
family. The built-in default can be overridden via preferences, as
described in @secref["fontresources"].
See @scheme[font%] for information about @scheme[family].
}
@defthing[menu-control-font (is-a?/c font%)]{ @defthing[menu-control-font (is-a?/c font%)]{
This font is the default for @scheme[popup-menu%] objects. This font is the default for @scheme[popup-menu%] objects.

View File

@ -1,7 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require "common.ss") @(require "common.ss")
@title{@bold{GUI}: Racket Graphics Toolkit} @title{@bold{GUI}: Racket Graphical Interface Toolkit}
@author["Matthew Flatt" "Robert Bruce Findler" "John Clements"] @author["Matthew Flatt" "Robert Bruce Findler" "John Clements"]
@ -9,12 +9,13 @@
@defmodule*/no-declare[(racket/gui/base)]{The @defmodule*/no-declare[(racket/gui/base)]{The
@racketmodname[racket/gui/base] library provides all of the class, @racketmodname[racket/gui/base] library provides all of the class,
interface, and procedure bindings defined in this manual.} interface, and procedure bindings defined in this manual, in addition
to the bindings of @racketmodname[racket/draw].}
@defmodulelang*/no-declare[(racket/gui)]{The @defmodulelang*/no-declare[(racket/gui)]{The
@racketmodname[racket/gui] language combines all bindings of the @racketmodname[racket/gui] language combines all bindings of the
@racketmodname[racket] language and the @racketmodname[racket] language and the
@racketmodname[racket/gui/base] modules.} @racketmodname[racket/gui/base] and @racketmodname[racket/draw] modules.}
@table-of-contents[] @table-of-contents[]
@ -23,23 +24,9 @@ interface, and procedure bindings defined in this manual.}
@include-section["guide.scrbl"] @include-section["guide.scrbl"]
@include-section["reference.scrbl"] @include-section["reference.scrbl"]
@include-section["config.scrbl"] @include-section["prefs.scrbl"]
@include-section["dynamic.scrbl"] @include-section["dynamic.scrbl"]
@;------------------------------------------------------------------------
@(bibliography
(bib-entry #:key "Adobe99"
#:author "Adobe Systems Incorporated"
#:title "PostScript Language Reference, third edition"
#:is-book? #t
#:url "http://partners.adobe.com/public/developer/en/ps/PLRM.pdf"
#:date "1999")
)
@;------------------------------------------------------------------------ @;------------------------------------------------------------------------
@index-section[] @index-section[]

View File

@ -4,7 +4,7 @@
@title[#:style '(toc reveal)]{Overview} @title[#:style '(toc reveal)]{Overview}
For documentation purposes, the graphics toolbox is organized into For documentation purposes, the graphics toolbox is organized into
three parts: two parts:
@itemize[ @itemize[
@ -13,11 +13,6 @@ For documentation purposes, the graphics toolbox is organized into
text fields, and events. The windowing toolbox is described in text fields, and events. The windowing toolbox is described in
@secref["windowing-overview"].} @secref["windowing-overview"].}
@item{The @deftech{drawing toolbox}, for drawing pictures or
implementing dynamic GUI programs (such as a video game) using
drawing canvases, pens, and brushes. The drawing toolbox is
described in @secref["drawing-overview"].}
@item{The @deftech{editor toolbox}, for developing traditional text @item{The @deftech{editor toolbox}, for developing traditional text
editors, editors that mix text and graphics, or free-form layout editors, editors that mix text and graphics, or free-form layout
editors (such as a word processor, HTML editor, or icon-based file editors (such as a word processor, HTML editor, or icon-based file
@ -26,11 +21,8 @@ For documentation purposes, the graphics toolbox is organized into
] ]
These three parts roughly represent layers of increasing Simple GUI programs access only the windowing toolbox directly, while
sophistication. Simple GUI programs access only the windowing toolbox large-scale applications tend to use the editor toolbox as well.
directly, more complex programs use both the windowing and drawing
toolboxes, and large-scale applications rely on all three
toolboxes.
@local-table-of-contents[] @local-table-of-contents[]
@ -40,8 +32,4 @@ These three parts roughly represent layers of increasing
@;------------------------------------------------------------------------ @;------------------------------------------------------------------------
@include-section["draw-overview.scrbl"]
@;------------------------------------------------------------------------
@include-section["editor-overview.scrbl"] @include-section["editor-overview.scrbl"]

View File

@ -1,25 +0,0 @@
#lang scribble/doc
@(require "common.ss")
@title{PostScript}
@defparam[current-ps-afm-file-paths paths (listof path?)]{
A parameter determines the list of paths that is used to find AFM
files. See @secref["postscriptfonts"] for more information.
}
@defparam[current-ps-cmap-file-paths paths (listof path?)]{
A parameter that determines the list of paths that is used to find
CMap files. See @secref["postscriptfonts"] for more information.
}
@defparam[current-ps-setup pss (is-a?/c ps-setup%)]{
A parameter that determines the current PostScript configuration
settings. See @scheme[post-script-dc%] and @scheme[printer-dc%].
}

View File

@ -20,11 +20,6 @@ The following are the (case-sensitive) preference names used by GRacket:
the basic style in a style list, and thus the default font size for the basic style in a style list, and thus the default font size for
an editor.} an editor.}
@item{@ResourceFirst{controlFontSize} --- sets the font size for
control and menu labels (Windows, X); the font is the @scheme['system]
font, which can be configured as described in
@secref["fontresources"].}
@item{@ResourceFirst{defaultMenuPrefix} --- sets the prefix used by @item{@ResourceFirst{defaultMenuPrefix} --- sets the prefix used by
default for menu item shortcuts under X, one of @scheme['ctl], default for menu item shortcuts under X, one of @scheme['ctl],
@scheme['meta], or @scheme['alt]. The default is @scheme['meta], or @scheme['alt]. The default is
@ -32,25 +27,10 @@ The following are the (case-sensitive) preference names used by GRacket:
@scheme['alt], underlined mnemonics (introduced by @litchar{&} in menu @scheme['alt], underlined mnemonics (introduced by @litchar{&} in menu
labels) are suppressed.} labels) are suppressed.}
@item{@ResourceFirst{altUpSelectsMenu} --- a true value makes
pressing and releasing the Alt key select the first menu in the menu
bar under X.}
@item{@ResourceFirst{emacsUndo} --- a true value makes undo in @item{@ResourceFirst{emacsUndo} --- a true value makes undo in
editors work as in Emacs (i.e., undo operations are themselves kept editors work as in Emacs (i.e., undo operations are themselves kept
in the undo stack).} in the undo stack).}
@item{@ResourceFirst{hiliteColor} --- a string to sets the color for
highlighting text, menus, and other GUI elements under X; the
preference string should contain six hexadecimal digits, two for each
component of the color. For example, set @Resource{hiliteColor} to
@scheme["0000A0"] and set @Resource{hiliteMenuBorder} to @scheme[#t]
for a Bluecurve-like look.}
@item{@ResourceFirst{hiliteMenuBorder} --- a true value causes a menu
selection to be highlighted with a border (in addition to a color) under
X.}
@item{@ResourceFirst{wheelStep} --- sets the default mouse-wheel step @item{@ResourceFirst{wheelStep} --- sets the default mouse-wheel step
size of @scheme[editor-canvas%] objects.} size of @scheme[editor-canvas%] objects.}
@ -61,26 +41,8 @@ The following are the (case-sensitive) preference names used by GRacket:
@item{@ResourceFirst{playcmd} --- used to format a sound-playing @item{@ResourceFirst{playcmd} --- used to format a sound-playing
command; see @scheme[play-sound] for details.} command; see @scheme[play-sound] for details.}
@item{@ResourceFirst{forceFocus} --- a true value enables extra
effort in GRacket to move the focus to a top-level window that is shown
or raised.}
@item{@ResourceFirst{doubleClickTime} --- overrides the @item{@ResourceFirst{doubleClickTime} --- overrides the
platform-specific default interval (in milliseconds) for double-click platform-specific default interval (in milliseconds) for double-click
events.} events.}
@item{@ResourceFirst{gamma} --- sets the gamma value used in
gamma-correcting PNG files.}
@item{@ResourceFirst{selectionAsClipboard} --- under X, a true value
causes @scheme[the-clipboard] to be an alias to
@scheme[the-x-selection-clipboard], which means that cut and paste
operations use the X selection instead of the X clipboard. See also
@scheme[clipboard<%>].}
] ]
In addition, preference names built from font face names can provide
or override default entries for the @scheme[font-name-directory<%>];
see @secref["fontresources"] for information.

View File

@ -3,13 +3,10 @@
@defclass/title[printer-dc% object% (dc<%>)]{ @defclass/title[printer-dc% object% (dc<%>)]{
A @scheme[printer-dc%] object is a Windows or Mac OS X printer A @scheme[printer-dc%] object is a printer device context. A newly
device context. The class cannot be instantiated under X (an created @scheme[printer-dc%] object obtains orientation (portrait
@scheme[exn:misc:unsupported] exception is raised). versus landscape) and scaling information from the current
@scheme[ps-setup%] object, as determined by the
Under Mac OS X, a newly created @scheme[printer-dc%] object obtains
orientation (portrait versus landscape) and scaling information from
the current @scheme[ps-setup%] object, as determined by the
@scheme[current-ps-setup] parameter. This information can be @scheme[current-ps-setup] parameter. This information can be
configured by the user through a dialog shown by configured by the user through a dialog shown by
@scheme[get-page-setup-from-user]. @scheme[get-page-setup-from-user].

View File

@ -7,8 +7,6 @@
@include-section["win-classes.scrbl"] @include-section["win-classes.scrbl"]
@include-section["win-funcs.scrbl"] @include-section["win-funcs.scrbl"]
@include-section["draw-classes.scrbl"]
@include-section["draw-funcs.scrbl"]
@include-section["editor-classes.scrbl"] @include-section["editor-classes.scrbl"]
@include-section["editor-funcs.scrbl"] @include-section["editor-funcs.scrbl"]
@include-section["wxme.scrbl"] @include-section["wxme.scrbl"]

View File

@ -57,6 +57,7 @@ Alphabetical:
@include-section["pane-class.scrbl"] @include-section["pane-class.scrbl"]
@include-section["panel-class.scrbl"] @include-section["panel-class.scrbl"]
@include-section["popup-menu-class.scrbl"] @include-section["popup-menu-class.scrbl"]
@include-section["printer-dc-class.scrbl"]
@include-section["radio-box-class.scrbl"] @include-section["radio-box-class.scrbl"]
@include-section["selectable-menu-item-intf.scrbl"] @include-section["selectable-menu-item-intf.scrbl"]
@include-section["separator-menu-item-class.scrbl"] @include-section["separator-menu-item-class.scrbl"]

View File

@ -8,4 +8,6 @@
@include-section["dialog-funcs.scrbl"] @include-section["dialog-funcs.scrbl"]
@include-section["eventspace-funcs.scrbl"] @include-section["eventspace-funcs.scrbl"]
@include-section["system-menu-funcs.scrbl"] @include-section["system-menu-funcs.scrbl"]
@include-section["global-draw-funcs.scrbl"]
@include-section["font-funcs.scrbl"]
@include-section["miscwin-funcs.scrbl"] @include-section["miscwin-funcs.scrbl"]

View File

@ -137,3 +137,7 @@ Removed Functions
The `write-resource, `get-reource', and `send-event' functions have The `write-resource, `get-reource', and `send-event' functions have
been removed from `racket/gui/base'. If there is any demand for the been removed from `racket/gui/base'. If there is any demand for the
removed functionality, it will be implemented in a new library. removed functionality, it will be implemented in a new library.
The `current-ps-afm-file-paths' and `current-ps-cmap-file-paths'
functions have been removed, because they no longer apply. PostScript
font information is obtained through Pango.