add make-font' to
racket/draw'
This commit is contained in:
parent
a974dad8bf
commit
8c7f829205
|
@ -18,7 +18,7 @@
|
|||
(provide color%
|
||||
color-database<%> the-color-database
|
||||
point%
|
||||
font% font-list% the-font-list
|
||||
font% font-list% the-font-list make-font
|
||||
font-name-directory<%> the-font-name-directory
|
||||
pen% pen-list% the-pen-list
|
||||
brush% brush-list% the-brush-list
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
(provide font%
|
||||
font-list% the-font-list
|
||||
make-font
|
||||
family-symbol? style-symbol? weight-symbol? smoothing-symbol?
|
||||
get-pango-attrs
|
||||
get-face-list
|
||||
|
@ -284,3 +285,18 @@
|
|||
(filter pango_font_family_is_monospace fams)
|
||||
fams))))
|
||||
|
||||
(define (make-font #:size [size 12]
|
||||
#:face [face #f]
|
||||
#:family [family 'default]
|
||||
#:style [style 'normal]
|
||||
#:weight [weight 'normal]
|
||||
#:underlined? [underlined? #f]
|
||||
#:smoothing [smoothing 'default]
|
||||
#:size-in-pixels? [size-in-pixels? #f])
|
||||
(unless (size? size) (raise-type-error 'make-font "exact integer in [1, 255]" size))
|
||||
(unless (or (not face) (string? face)) (raise-type-error 'make-font "string or #f" face))
|
||||
(unless (family-symbol? family) (raise-type-error 'make-font "family-symbol" family))
|
||||
(unless (style-symbol? style) (raise-type-error 'make-font "style-symbol" style))
|
||||
(unless (weight-symbol? weight) (raise-type-error 'make-font "weight-symbol" weight))
|
||||
(unless (smoothing-symbol? smoothing) (raise-type-error 'make-font "smoothing-symbol" smoothing))
|
||||
(make-object font% size face family style weight underlined? smoothing size-in-pixels?))
|
||||
|
|
|
@ -21,6 +21,7 @@ Returns a list of font face names available on the current system. If
|
|||
|
||||
}
|
||||
|
||||
|
||||
@defproc[(get-family-builtin-face [family (one-of/c 'default 'decorative 'roman 'script
|
||||
'swiss 'modern 'symbol 'system)])
|
||||
string?]{
|
||||
|
@ -31,6 +32,8 @@ Returns the built-in default face mapping for a particular font
|
|||
See @scheme[font%] for information about @scheme[family].
|
||||
|
||||
}
|
||||
|
||||
|
||||
@defproc[(make-bitmap [width exact-positive-integer?]
|
||||
[height exact-positive-integer?]
|
||||
[alpha? any/c #t])
|
||||
|
@ -41,6 +44,26 @@ this procedure is preferred because it defaults @racket[alpha?] in a
|
|||
more useful way.}
|
||||
|
||||
|
||||
@defproc[(make-font [#:size size (integer-in 1 255) 12]
|
||||
[#:face face (or/c string? #f) #f]
|
||||
[#:family family (one-of/c 'default 'decorative 'roman 'script
|
||||
'swiss 'modern 'symbol 'system)
|
||||
'default]
|
||||
[#:style style (one-of/c 'normal 'italic 'slant) 'normal]
|
||||
[#:weight weight (one-of/c 'normal 'bold 'light) 'normal]
|
||||
[#:underline? underline? any/c #f]
|
||||
[#:smoothing smoothing (one-of/c 'default 'partly-smoothed
|
||||
'smoothed 'unsmoothed)
|
||||
'default]
|
||||
[#:size-in-pixels? size-in-pixels? any/c #f])
|
||||
(is-a?/c font%)]{
|
||||
|
||||
Creates a @racket[font%] instance. This procedure provides an
|
||||
equivalent but more convenient interface compared to using
|
||||
@racket[make-object] with @racket[font%].
|
||||
}
|
||||
|
||||
|
||||
@defproc[(make-monochrome-bitmap [width exact-positive-integer?]
|
||||
[height exact-positive-integer?]
|
||||
[bits (or/c bytes? #f) #f])
|
||||
|
|
|
@ -24,8 +24,15 @@ A @defterm{font} is an object which determines the appearance of text,
|
|||
@item{@indexed-scheme['swiss]}
|
||||
@item{@indexed-scheme['modern] (fixed width)}
|
||||
@item{@indexed-scheme['symbol] (Greek letters and more)}
|
||||
@item{@indexed-scheme['system] (used to draw control labels)}
|
||||
]}
|
||||
@item{@indexed-scheme['system] (similar to the font to draw control labels,
|
||||
but see @racket[normal-control-font])}
|
||||
]
|
||||
|
||||
@margin-note{The terminology ``family'' and ``face'' is mangled relative
|
||||
to its usual meaning. A @racket[font%] ``face'' is really
|
||||
a font family in the usual terminology, while a @racket[font%]
|
||||
``family'' is a kind of abstract font family that is mapped to a
|
||||
particular font family on a given platform.}}
|
||||
|
||||
@item{face --- A string face name, such as @scheme["Courier"]. The format
|
||||
and meaning of a face name is platform- and
|
||||
|
@ -107,6 +114,8 @@ When no arguments are provided, creates an instance of the default
|
|||
See @scheme[font%] for information about @scheme[family],
|
||||
@scheme[style], and @scheme[weight]. @scheme[font-name-directory<%>].
|
||||
|
||||
See also @racket[make-font].
|
||||
|
||||
}
|
||||
|
||||
@defmethod[(get-face)
|
||||
|
|
Loading…
Reference in New Issue
Block a user