Programmer's Reference

Obtaining the current font from a graphics context

You can determine the font currently set in a graphics context using the getGCValues: method. In the following example, the GCFont valuemask is used to retrieve the current font. The information is returned in a new CgGCValues object. You can retrieve the CgFontStruct information by sending a queryFont message to the CgFont. You then obtain the actual string name of the font from the CgFontStruct.

| values font fontStruct fontName |
CgGC default
    getGCValues: GCFont
    valuesReturn: (values := CgGCValues new).
font := values font.
fontStruct := font queryFont.
fontName := fontStruct name.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]