"Stephen J. Turnbull" <turnbull(a)sk.tsukuba.ac.jp> writes:
> >>>>> "Hrvoje" == Hrvoje Niksic <hniksic(a)iskon.hr> writes:
>
> Hrvoje> I liked the new FSF model a lot.
>
> Where can I read about this?
>From Emacs 21.0 NEWS:
** New face implementation.
Emacs faces have been reimplemented from scratch. They don't use XLFD
font names anymore and face merging now works as expected.
+++
*** New faces.
Each face can specify the following display attributes:
1. Font family or fontset alias name.
2. Relative proportionate width, aka character set width or set
width (swidth), e.g. `semi-compressed'.
3. Font height in 1/10pt
4. Font weight, e.g. `bold'.
5. Font slant, e.g. `italic'.
6. Foreground color.
7. Background color.
8. Whether or not characters should be underlined, and in what color.
9. Whether or not characters should be displayed in inverse video.
10. A background stipple, a bitmap.
11. Whether or not characters should be overlined, and in what color.
12. Whether or not characters should be strike-through, and in what
color.
13. Whether or not a box should be drawn around characters, its
color, the width of the box lines, and 3D appearance.
Faces are frame-local by nature because Emacs allows to define the
same named face (face names are symbols) differently for different
frames. Each frame has an alist of face definitions for all named
faces. The value of a named face in such an alist is a Lisp vector
with the symbol `face' in slot 0, and a slot for each each of the face
attributes mentioned above.
There is also a global face alist `face-new-frame-defaults'. Face
definitions from this list are used to initialize faces of newly
created frames.
A face doesn't have to specify all attributes. Those not specified
have a nil value. Faces specifying all attributes are called
`fully-specified'.
+++
*** Face merging.
The display style of a given character in the text is determined by
combining several faces. This process is called `face merging'. Any
aspect of the display style that isn't specified by overlays or text
properties is taken from the `default' face. Since it is made sure
that the default face is always fully-specified, face merging always
results in a fully-specified face.
+++
*** Face realization.
After all face attributes for a character have been determined by
merging faces of that character, that face is `realized'. The
realization process maps face attributes to what is physically
available on the system where Emacs runs. The result is a `realized
face' in form of an internal structure which is stored in the face
cache of the frame on which it was realized.
Face realization is done in the context of the charset of the
character to display because different fonts and encodings are used
for different charsets. In other words, for characters of different
charsets, different realized faces are needed to display them.
Except for composite characters, faces are always realized for a
specific character set and contain a specific font, even if the face
being realized specifies a fontset. The reason is that the result of
the new font selection stage is better than what can be done with
statically defined font name patterns in fontsets.
In unibyte text, Emacs' charsets aren't applicable; function
`char-charset' reports ASCII for all characters, including those >
0x7f. The X registry and encoding of fonts to use is determined from
the variable `face-default-registry' in this case. The variable is
initialized at Emacs startup time from the font the user specified for
Emacs.
Currently all unibyte text, i.e. all buffers with
`enable-multibyte-characters' nil are displayed with fonts of the same
registry and encoding `face-default-registry'. This is consistent
with the fact that languages can also be set globally, only.
++++
**** Clearing face caches.
The Lisp function `clear-face-cache' can be called to clear face caches
on all frames. If called with a non-nil argument, it will also unload
unused fonts.
+++
*** Font selection.
Font selection tries to find the best available matching font for a
given (charset, face) combination. This is done slightly differently
for faces specifying a fontset, or a font family name.
If the face specifies a fontset name, that fontset determines a
pattern for fonts of the given charset. If the face specifies a font
family, a font pattern is constructed. Charset symbols have a
property `x-charset-registry' for that purpose that maps a charset to
an XLFD registry and encoding in the font pattern constructed.
Available fonts on the system on which Emacs runs are then matched
against the font pattern. The result of font selection is the best
match for the given face attributes in this font list.
Font selection can be influenced by the user.
The user can specify the relative importance he gives the face
attributes width, height, weight, and slant by setting
face-font-selection-order (faces.el) to a list of face attribute
names. The default is (:width :height :weight :slant), and means
that font selection first tries to find a good match for the font
width specified by a face, then---within fonts with that width---tries
to find a best match for the specified font height, etc.
Setting `face-alternative-font-family-alist' allows the user to
specify alternative font families to try if a family specified by a
face doesn't exist.
+++
**** Scalable fonts
Emacs can make use of scalable fonts but doesn't do so by default,
since the use of too many or too big scalable fonts may crash XFree86
servers.
To enable scalable font use, set the variable
`scalable-fonts-allowed'. A value of nil, the default, means never use
scalable fonts. A value of t means any scalable font may be used.
Otherwise, the value must be a list of regular expressions. A
scalable font may then be used if it matches a regular expression from
that list. Example:
(setq scalable-fonts-allowed '("muleindian-2$"))
allows the use of scalable fonts with registry `muleindian-2'.
+++
*** Functions and variables related to font selection.
- Function: x-family-fonts &optional FAMILY FRAME
Return a list of available fonts of family FAMILY on FRAME. If FAMILY
is omitted or nil, list all families. Otherwise, FAMILY must be a
string, possibly containing wildcards `?' and `*'.
If FRAME is omitted or nil, use the selected frame. Each element of
the result is a vector [FAMILY WIDTH POINT-SIZE WEIGHT SLANT FIXED-P
FULL REGISTRY-AND-ENCODING]. FAMILY is the font family name.
POINT-SIZE is the size of the font in 1/10 pt. WIDTH, WEIGHT, and
SLANT are symbols describing the width, weight and slant of the font.
These symbols are the same as for face attributes. FIXED-P is non-nil
if the font is fixed-pitch. FULL is the full name of the font, and
REGISTRY-AND-ENCODING is a string giving the registry and encoding of
the font. The result list is sorted according to the current setting
of the face font sort order.
- Function: x-font-family-list
Return a list of available font families on FRAME. If FRAME is
omitted or nil, use the selected frame. Value is a list of conses
(FAMILY . FIXED-P) where FAMILY is a font family, and FIXED-P is
non-nil if fonts of that family are fixed-pitch.
- Variable: font-list-limit
Limit for font matching. If an integer > 0, font matching functions
won't load more than that number of fonts when searching for a
matching font. The default is currently 100.
+++
*** Setting face attributes.
For the most part, the new face implementation is interface-compatible
with the old one. Old face attribute related functions are now
implemented in terms of the new functions `set-face-attribute' and
`face-attribute'.
Face attributes are identified by their names which are keyword
symbols. All attributes can be set to `unspecified'.
The following attributes are recognized:
`:family'
VALUE must be a string specifying the font family, e.g. ``courier'',
or a fontset alias name. If a font family is specified, wild-cards `*'
and `?' are allowed.
`:width'
VALUE specifies the relative proportionate width of the font to use.
It must be one of the symbols `ultra-condensed', `extra-condensed',
`condensed', `semi-condensed', `normal', `semi-expanded', `expanded',
`extra-expanded', or `ultra-expanded'.
`:height'
VALUE must be an integer specifying the height of the font to use in
1/10 pt.
`:weight'
VALUE specifies the weight of the font to use. It must be one of the
symbols `ultra-bold', `extra-bold', `bold', `semi-bold', `normal',
`semi-light', `light', `extra-light', `ultra-light'.
`:slant'
VALUE specifies the slant of the font to use. It must be one of the
symbols `italic', `oblique', `normal', `reverse-italic', or
`reverse-oblique'.
`:foreground', `:background'
VALUE must be a color name, a string.
`:underline'
VALUE specifies whether characters in FACE should be underlined. If
VALUE is t, underline with foreground color of the face. If VALUE is
a string, underline with that color. If VALUE is nil, explicitly
don't underline.
`:overline'
VALUE specifies whether characters in FACE should be overlined. If
VALUE is t, overline with foreground color of the face. If VALUE is a
string, overline with that color. If VALUE is nil, explicitly don't
overline.
`:strike-through'
VALUE specifies whether characters in FACE should be drawn with a line
striking through them. If VALUE is t, use the foreground color of the
face. If VALUE is a string, strike-through with that color. If VALUE
is nil, explicitly don't strike through.
`:box'
VALUE specifies whether characters in FACE should have a box drawn
around them. If VALUE is nil, explicitly don't draw boxes. If
VALUE is t, draw a box with lines of width 1 in the foreground color
of the face. If VALUE is a string, the string must be a color name,
and the box is drawn in that color with a line width of 1. Otherwise,
VALUE must be a property list of the form `(:line-width WIDTH
:color COLOR :style STYLE)'. If a keyword/value pair is missing from
the property list, a default value will be used for the value, as
specified below. WIDTH specifies the width of the lines to draw; it
defaults to 1. COLOR is the name of the color to draw in, default is
the foreground color of the face for simple boxes, and the background
color of the face for 3D boxes. STYLE specifies whether a 3D box
should be draw. If STYLE is `released-button', draw a box looking
like a released 3D button. If STYLE is `pressed-button' draw a box
that appears like a pressed button. If STYLE is nil, the default if
the property list doesn't contain a style specification, draw a 2D
box.
`:inverse-video'
VALUE specifies whether characters in FACE should be displayed in
inverse video. VALUE must be one of t or nil.
`:stipple'
If VALUE is a string, it must be the name of a file of pixmap data.
The directories listed in the `x-bitmap-file-path' variable are
searched. Alternatively, VALUE may be a list of the form (WIDTH
HEIGHT DATA) where WIDTH and HEIGHT are the size in pixels, and DATA
is a string containing the raw bits of the bitmap. VALUE nil means
explicitly don't use a stipple pattern.
For convenience, attributes `:family', `:width', `:height', `:weight',
and `:slant' may also be set in one step from an X font name:
`:font'
Set font-related face attributes from VALUE. VALUE must be a valid
XLFD font name. If it is a font name pattern, the first matching font
is used--this is for compatibility with the behavior of previous
versions of Emacs.
For compatibility with Emacs 20, keywords `:bold' and `:italic' can
be used to specify that a bold or italic font should be used. VALUE
must be t or nil in that case. A value of `unspecified' is not allowed."
Please see also the documentation of `set-face-attribute' and
`defface'.
*** Face attributes and X resources
The following X resource names can be used to set face attributes
from X resources:
Face attribute X resource class
-----------------------------------------------------------------------
:family attributeFamily . Face.AttributeFamily
:width attributeWidth Face.AttributeWidth
:height attributeHeight Face.AttributeHeight
:weight attributeWeight Face.AttributeWeight
:slant attributeSlant Face.AttributeSlant
foreground attributeForeground Face.AttributeForeground
:background attributeBackground . Face.AttributeBackground
:overline attributeOverline Face.AttributeOverline
:strike-through attributeStrikeThrough Face.AttributeStrikeThrough
:box attributeBox Face.AttributeBox
:underline attributeUnderline Face.AttributeUnderline
:inverse-video attributeInverse Face.AttributeInverse
:stipple attributeStipple Face.AttributeStipple
or attributeBackgroundPixmap
Face.AttributeBackgroundPixmap
:font attributeFont Face.AttributeFont
:bold attributeBold Face.AttributeBold
:italic attributeItalic . Face.AttributeItalic
:font attributeFont Face.AttributeFont
+++
*** Text property `face'.
The value of the `face' text property can now be a single face
specification or a list of such specifications. Each face
specification can be
1. A symbol or string naming a Lisp face.
2. A property list of the form (KEYWORD VALUE ...) where each
KEYWORD is a face attribute name, and VALUE is an appropriate value
for that attribute. Please see the doc string of `set-face-attribute'
for face attribute names.
3. Conses of the form (FOREGROUND-COLOR . COLOR) or
(BACKGROUND-COLOR . COLOR) where COLOR is a color name. This is
for compatibility with previous Emacs versions.
+++