AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
Font typedict
 
A Font is an object that Yoix programs use to identify the shapes that built-ins (e.g., drawString or show) use when they draw characters in images or on your screen. A font is usually created by a simple declaration that has its name field set to an appropriate value, but fonts also include built-ins that create new fonts by applying transformations to existing fonts. The fields in a Font are:
advance A read-only double that represents the maximum distance the current point moves for any character in this font, in units of 72 dots per inch. advance is not used much and is really only interesting when all character in the font are designed to have the same width.
ascent A read-only double that represents the maximum distance from the baseline to the top of most alphanumeric characters, in units of 72 dots per inch. ascent is usually positive, but the value is adjusted when transformations, like translatefont, are applied, so any value is possible. Subtracting ascent from the y-coordinate of the baseline results in a y-coordinate that lies above the top of most alphanumeric characters.
descent A read-only double that represents the maximum distance from the baseline to the bottom of most alphanumeric characters, in units of 72 dots per inch. descent is usually positive, but the value is adjusted when transformations, like translatefont, are applied, so any value is possible. Adding descent to the y-coordinate of the baseline results in a y-coordinate that lies below the bottom of most alphanumeric characters.
family A read-only String that represents the font family that is encoded in the font's name.
fontfacename A read-only String that is the name of the font face.
height A read-only double that represents the recommended distance between baselines for this font, in units of 72 dots per inch. height is a positive number that is usually close to the value obtained by adding ascent, descent, and leading.
leading A read-only double that represents the recommended interline spacing for this font, in units of 72 dots per inch.
matrix A read-only Matrix that describes the transformation from the font's internal coordinate system to user space.
name A String that identifies the font. The actual interpretation of name depends of the value assigned to type, but since 0 is currently the only supported type, name should be given in standard Java notation that allows dash separated style and size strings to be appended to one of the available font names. The font names that Java supports on your platform can be obtained using the getFontList built-in. name can only be defined in the font's declaration; changing it at any other time will result in an invalidaccess error.
pointsize A read-only double that represents that actual point size of this font. The value is adjusted when transformations, like scalefont, are applied to this font and it also depends on whether your program has asked for special adjustments by setting VM.fontmagnification or VM.fixfonts, so pointsize will not always match the size encoded in name, which is available as size.
psname A read-only String that is the PostScript name of this font.
rotatefont A Builtin that creates a new font by rotating the characters in this font.
scalefont A Builtin that creates a new font by scaling the characters in this font.
shearfont A Builtin that creates a new font by shearing the characters in this font.
size A read-only int that represents the size that is encoded in the font's name, which may not match pointsize.
stringbounds A Builtin that returns a Rectangle that covers a string if it were drawn at the origin.
stringfit A Builtin that can be used to fit a string, printed in this font, to a width.
stringsize A Builtin that returns a Dimension that can cover a string.
stringwidth A Builtin that calculates how far the current point would move horizontally after a string is drawn.
style A read-only String that represents the style of the font as one of plain, bold, or bolditalic.
transformfont A Builtin that creates a new font by applying an affine transformation to the characters in this font.
translatefont A Builtin that creates a new font by translating the characters in this font.
type An int that identifies what kind of font this is to the internal font machinery supported by the Yoix interpreter. Setting type to 0, which is currently the only supported value, means this font represents one of the fonts supported by Java. type can only be defined in the font's declaration; changing it at any other time will result in an invalidaccess error.
Several permanent fields have not been documented and should not be used in Yoix applications.
 
 Example:   The program,
import yoix.*.*;

Array names = getFontList();
Array fonts[names@sizeof];
int   n;

for (n = 0; n < names@sizeof; n++) {
    fonts[n] = new Font {
        String name = names[n] + "-bold-10";
    };
}

for (n = 0; n < fonts@sizeof; n++)
    printf("fonts[%d].name=%s\n", n, fonts[n].name);
makes a bold font in point size 10 for every available font on your system and then prints something like,
fonts[0].name=Courier-bold-10
fonts[1].name=Default-bold-10
fonts[2].name=Dialog-bold-10
fonts[3].name=DialogInput-bold-10
fonts[4].name=Helvetica-bold-10
fonts[5].name=ItcZapfDingbats-bold-10
fonts[6].name=Lucida Bright-bold-10
fonts[7].name=Lucida Sans-bold-10
fonts[8].name=Lucida Sans Typewriter-bold-10
fonts[9].name=Monospaced-bold-10
fonts[10].name=SansSerif-bold-10
fonts[11].name=Serif-bold-10
fonts[12].name=Symbol-bold-10
fonts[13].name=Times-bold-10
fonts[14].name=Utopia-bold-10
on standard output.
 
 See Also:   drawString, Graphics, Matrix, getFontList, stringWidth

 

Yoix is a registered trademark of AT&T Inc.