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

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
scalefont (Number sx, Number sy) typedict.Font
 
Returns a new Font that is created by applying a horizontal scaling of sx and a vertical scaling of sy to every character in this font.
 
 Example:   Here is a small program,
import yoix.*.*;

Font TEXT = {
    String name = "Lucida-plain-30";
};

Font SUP = TEXT.translatefont(0, -TEXT.ascent).scalefont(.5);
Font SUB = TEXT.translatefont(0, TEXT.descent).scalefont(4, .5);

JFrame f = {
    Color background = Color.white;

    Graphics graphics = {
        int textantialiasing = TRUE;
    };

    paint(Rectangle rect) {
        graphics {
            gsave();
            rectclip(rect);
            moveto(36, 144);
            setfont(TEXT);
            show("E = mc");
            setfont(SUP);
            show("2");
            moveto(36, 216);
            setfont(TEXT);
            show("Water = H");
            setfont(SUB);
            show("2");
            setfont(TEXT);
            show("O");
            grestore();
        }
    }
};

f.visible = TRUE;
that defines a paint function in a frame that prints text that includes superscripts and subscripts using fonts created by applying scalefont and translatefont to a base text font. See if you can improve the subscript, which is obviously too wide.
 
 Return:   Font
 
 See Also:   rotatefont, shearfont, transformfont, translatefont

 

Yoix is a registered trademark of AT&T Intellectual Property.