## Tcl9.0.3/Tk9.0.3 Documentation > Tk C API > FontId

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

  NAME
    Tk_FontId, Tk_GetFontMetrics, Tk_PostscriptFontName — tHgׂ̗̈p@\@ accessor functions for fonts
  SYNOPSIS
    #include <tk.h>
    Font
    Tk_FontId(tkfont)
    Tk_GetFontMetrics(tkfont, fmPtr)
    int
    Tk_PostscriptFontName(tkfont, dsPtr)
  ø ARGUMENTS
    Tk_Font tkfont (üÍin)
    Tk_FontMetrics *fmPtr (oÍout)
    Tcl_DString *dsPtr (oÍout)
  à¾ DESCRIPTION
  f[^\¢ DATA STRUCTURES
  SEE ALSO
  KEYWORDS

### NAME

Tk_FontId, Tk_GetFontMetrics, Tk_PostscriptFontName — tHgׂ̗̈p@\@ accessor functions for fonts

### SYNOPSIS

#include <tk.h>
Font
Tk_FontId(tkfont)
Tk_GetFontMetrics(tkfont, fmPtr)
int
Tk_PostscriptFontName(tkfont, dsPtr)

### ø ARGUMENTS

Tk_Font tkfont (üÍin)
  ⍇³êĂ¢és¾ĂȃtHg塎OÌ Tk_GetFont ւ̌ďoµɂæèԂ³êĂ¢Ȃ¯ê΂ȂçȂ¢¡@ Opaque font token being queried. Must have been returned by a previous call to Tk_GetFont.

Tk_FontMetrics *fmPtr (oÍout)
  tkfont ׂ̈̃tHg¡@î񂪕ۑ¶³êĂ¢é\¢ւ̎w¦q¡ڍׂ͉ºÌ DATA STRUCTURES ðQƂ³ꂽ¢¡@ Pointer to structure in which the font metrics for \fItkfont\fR will be stored. See \fBDATA STRUCTURES\fR below for details.

Tcl_DString *dsPtr (oÍout)
  tkfont ɑ·é|XgXNvgê̖¼OªǋL³ê邱ƂɂȂ鏉ú»³ꂽ Tcl_DString ւ̎w¦q¡@ Pointer to an initialized Tcl_DString to which the name of the Postscript font that corresponds to tkfont will be appended.

### à¾ DESCRIPTION

Tk_FontId Í tkfont ð^¦çꎚåðԂ·¤»ê͎w肳ꂽ¶`óŕ¶ð`悷éׂɎgíêé摜󋵂ð\¬·éׂÉ XGCValues \¢ɑIð·ׂ«ł é¡ Given a \fItkfont\fR, \fBTk_FontId\fR returns the token that should be selected into an XGCValues structure in order to construct a graphics context that can be used to draw text in the specified font.

Tk_GetFontMetrics Í tkfont ̕¶³¤[³¤sԋ£¤ðæfPʂŌvZµ»êç̒lð fmPtr ɂæèw³êé\¢à̒lɕۑ¶·顂±êç̒lͤ½s̕¶̋æԤقȂ镶`ó̕¶̊ü̐®ñ¤^¦çꂽ̈æà̕¶̏cûü̑µ¦̗lȌvZɎg¤±Ƃªł«顕¶`󑪒èàɎgíê镶³¤¶[³¤sԋ£̗pê̒è`ɏA¢Ă͎戵à¾Ì \fBfont\fR ½߂ðQƂ³ꂽ¢¡ \fBTk_GetFontMetrics\fR computes the ascent, descent, and linespace of the \fItkfont\fR in pixels and stores those values in the structure pointer to by \fIfmPtr\fR. These values can be used in computations such as to space multiple lines of text, to align the baselines of text in different fonts, and to vertically align text in a given region. See the documentation for the \fBfont\fR command for definitions of the terms ascent, descent, and linespace, used in font metrics.

Tk_PostscriptFontName Í tkfont 𤑊µĂ¢éóüɎgíêéׂ«|XgXNvg¶`ó̖¼OɑΉt¯·顕ԂèlÍ tkfont ̃|CgPʂ̑傫³ł 褃|XgXNvg¶`󖼂ª dsPtr ɒǋL³êé¡ dsPtr ͏ú»³ꂽ Tcl_DString ðQƂµȂ¯ê΂ȂçȂ¢¡gIȁh|XgXNvgóü@ð^¦çꤎ̉æʕ¶`óꑰ͐³µóü³êéł 낤: Tk_PostscriptFontName maps a tkfont to the corresponding Postscript font name that should be used when printing. The return value is the size in points of the tkfont and the Postscript font name is appended to dsPtr. DsPtr must refer to an initialized Tcl_DString. Given a “reasonable” Postscript printer, the following screen font families should print correctly:

  Avant Garde, Arial, Bookman, Courier, Courier New, Geneva, Helvetica, Monaco, New Century Schoolbook, New York, Palatino, Symbol, Times, Times New Roman, Zapf Chancery, and Zapf Dingbats.

»̑¼̂ǂ̕¶`óꑰà³µóü³êȂ¢©àµêȂ¢¤R͌vZ³ꂽ|XgXNvg¶`󖼑O͐³µȂ¢©óü@ãɎÀ݂µȂ¢¡ Any other font families may not print correctly because the computed Postscript font name may be incorrect or not exist on the printer.

### f[^\¢ DATA STRUCTURES

Tk_FontMetrics f[^\¢Í Tk_GetFontMetrics ɂæÁĕ¶`óɊւ·éîñðԂ·½߂Ɏgíꤎ̗lɒè`³êé: The \fBTk_FontMetrics\fR data structure is used by \fBTk_GetFontMetrics\fR to return information about a font and is defined as follows:

    typedef struct {
        int ascent;
        int descent;
        int linespace;
    } Tk_FontMetrics;

ascent ͤü©çłàw̍¢¶ªãɐLãÁ½æfPʂ̗ʂɕ¶`󒘎҂ɂæÁĒǉÁ³ꂽ]ª̋󔒂ðÁ¦½ʂł é¡ The ascent field is the amount in pixels that the tallest letter sticks up above the baseline, plus any extra blank space added by the designer of the font.

descent ͤü©çǂ̕¶łàºɉºª肫Á½æfPʂ̗ʂɕ¶`󒘎҂ɂæÁĒǉÁ³ꂽ]ª̋󔒂ðÁ¦½ʂł é¡ The descent is the largest amount in pixels that any letter sticks below the baseline, plus any extra blank space added by the designer of the font.

linespace ͤ¶³ƕ¶[³̍vł 顕¶̓¯¶¶`ó̓ñ̍sªǂꂾ¯£êĔzu³êêΈê̍ŝǂ̕¶àʂ̍ŝǂ̕¶ɂà©³ȂçȂ¢©ł é¡ The linespace is the sum of the ascent and descent. How far apart two lines of text in the same font should be placed so that none of the characters in one line overlap any of the characters in the other line.

### SEE ALSO

font, MeasureChar

### KEYWORDS

font, measurement, Postscript
Copyright © 1996 Sun Microsystems, Inc.