MeasureChar.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:6k
- '"
- '" Copyright (c) 1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: MeasureChar.3,v 1.4 1999/12/21 23:54:17 hobbs Exp $
- '"
- .so man.macros
- .TH Tk_MeasureChars 3 8.1 Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_MeasureChars, Tk_TextWidth, Tk_DrawChars, Tk_UnderlineChars - routines to measure and display simple single-line strings.
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- int
- fBTk_MeasureChars(fItkfont, string, numBytes, maxPixels, flags, lengthPtrfB)fR
- .sp
- int
- fBTk_TextWidth(fItkfont, string, numBytesfB)fR
- .sp
- void
- fBTk_DrawChars(fIdisplay, drawable, gc, tkfont, string, numBytes, x, yfB)fR
- .sp
- void
- fBTk_UnderlineChars(fIdisplay, drawable, gc, tkfont, string, x, y, firstByte, lastBytefB)fR
- .sp
- .SH ARGUMENTS
- .AS "const char" firstChar
- .AP Tk_Font tkfont in
- Token for font in which text is to be drawn or measured. Must have been
- returned by a previous call to fBTk_GetFontfR.
- .AP "const char" *string in
- Text to be measured or displayed. Need not be null terminated. Any
- non-printing meta-characters in the string (such as tabs, newlines, and
- other control characters) will be measured or displayed in a
- platform-dependent manner.
- .VS 8.1
- .AP int numBytes in
- The maximum number of bytes to consider when measuring or drawing
- fIstringfR. Must be greater than or equal to 0.
- .VE 8.1
- .AP int maxPixels in
- If fImaxPixelsfR is >= 0, it specifies the longest permissible
- line length in pixels. Characters from fIstringfR are processed only
- until this many pixels have been covered. If fImaxPixelsfR is < 0, then
- the line length is unbounded and the fIflagsfR argument is ignored.
- .AP int flags in
- Various flag bits OR-ed together: TK_PARTIAL_OK means include a character
- as long as any part of it fits in the length given by fImaxPixelsfR;
- otherwise, a character must fit completely to be considered.
- TK_WHOLE_WORDS means stop on a word boundary, if possible. If
- TK_AT_LEAST_ONE is set, it means return at least one character even if no
- characters could fit in the length given by fImaxPixelsfR. If
- TK_AT_LEAST_ONE is set and TK_WHOLE_WORDS is also set, it means that if
- not even one word fits on the line, return the first few letters of the
- word that did fit; if not even one letter of the word fit, then the first
- letter will still be returned.
- .AP int *lengthPtr out
- Filled with the number of pixels occupied by the number of characters
- returned as the result of fBTk_MeasureCharsfR.
- .AP Display *display in
- Display on which to draw.
- .AP Drawable drawable in
- Window or pixmap in which to draw.
- .AP GC gc in
- Graphics context for drawing characters. The font selected into this GC
- must be the same as the fItkfontfR.
- .AP int "x, y" in
- Coordinates at which to place the left edge of the baseline when displaying
- fIstringfR.
- .VS 8.1
- .AP int firstByte in
- The index of the first byte of the first character to underline in the
- fIstringfR. Underlining begins at the left edge of this character.
- .AP int lastByte in
- The index of the first byte of the last character up to which the
- underline will be drawn. The character specified by fIlastBytefR
- will not itself be underlined.
- .VE 8.1
- .BE
- .SH DESCRIPTION
- .PP
- These routines are for measuring and displaying simple single-font,
- single-line, strings. To measure and display single-font, multi-line,
- justified text, refer to the documentation for fBTk_ComputeTextLayoutfR.
- There is no programming interface in the core of Tk that supports
- multi-font, multi-line text; support for that behavior must be built on
- top of simpler layers.
- .VS 8.1
- Note that the interfaces described here are
- byte-oriented not character-oriented, so index values coming from Tcl
- scripts need to be converted to byte offsets using the
- fBTcl_UtfAtIndexfR and related routines.
- .VE 8.1
- .PP
- A glyph is the displayable picture of a letter, number, or some other
- symbol. Not all character codes in a given font have a glyph.
- Characters such as tabs, newlines/returns, and control characters that
- have no glyph are measured and displayed by these procedures in a
- platform-dependent manner; under X, they are replaced with backslashed
- escape sequences, while under Windows and Macintosh hollow or solid boxes
- may be substituted. Refer to the documentation for
- fBTk_ComputeTextLayoutfR for a programming interface that supports the
- platform-independent expansion of tab characters into columns and
- newlines/returns into multi-line text.
- .PP
- fBTk_MeasureCharsfR is used both to compute the length of a given
- string and to compute how many characters from a string fit in a given
- amount of space. The return value is the number of bytes from
- fIstringfR that fit in the space specified by fImaxPixelsfR subject to
- the conditions described by fIflagsfR. If all characters fit, the return
- value will be fInumBytesfR. fI*lengthPtrfR is filled with the computed
- width, in pixels, of the portion of the string that was measured. For
- example, if the return value is 5, then fI*lengthPtrfR is filled with the
- distance between the left edge of fIstringfR[0] and the right edge of
- fIstringfR[4].
- .PP
- fBTk_TextWidthfR is a wrapper function that provides a simpler interface
- to the fBTk_MeasureCharsfR function. The return value is how much
- space in pixels the given fIstringfR needs.
- .PP
- fBTk_DrawCharsfR draws the fIstringfR at the given location in the
- given fIdrawablefR.
- .PP
- fBTk_UnderlineCharsfR underlines the given range of characters in the
- given fIstringfR. It doesn't draw the characters (which are assumed to
- have been displayed previously by fBTk_DrawCharsfR); it just draws the
- underline. This procedure is used to underline a few characters without
- having to construct an underlined font. To produce natively underlined
- text, the appropriate underlined font should be constructed and used.
- .SH KEYWORDS
- font