Tk_MeasureChars
NAMESYNOPSIS
ARGUMENTS
DESCRIPTION
SEE ALSO
KEYWORDS
___________________________
NAME
Tk_MeasureChars, Tk_TextWidth, Tk_DrawChars, Tk_UnderlineChars − routines to measure and display simple single-line strings.
SYNOPSIS
#include <tk.h>
int
Tk_MeasureChars(tkfont, string, numBytes, maxPixels,
flags, lengthPtr)
int
Tk_TextWidth(tkfont, string, numBytes)
Tk_DrawChars(display, drawable, gc, tkfont, string, numBytes, x, y)
Tk_UnderlineChars(display, drawable, gc, tkfont, string, x, y, firstByte, lastByte)
ARGUMENTS
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 Tk_GetFont. | ||
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. | ||
int numBytes (in) |
The maximum number of bytes to consider when measuring or drawing string. Must be greater than or equal to 0. | ||
int maxPixels (in) |
If maxPixels is >= 0, it specifies the longest permissible line length in pixels. Characters from string are processed only until this many pixels have been covered. If maxPixels is < 0, then the line length is unbounded and the flags argument is ignored. | ||
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 maxPixels; 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 maxPixels. 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. | ||
int *lengthPtr (out) |
Filled with the number of pixels occupied by the number of characters returned as the result of Tk_MeasureChars. | ||
Display *display (in) |
Display on which to draw. | ||
Drawable drawable (in) |
Window or pixmap in which to draw. | ||
GC gc (in) |
Graphics context for drawing characters. The font selected into this GC must be the same as the tkfont. | ||
int x, y (in) |
Coordinates at which to place the left edge of the baseline when displaying string. | ||
int firstByte (in) |
The index of the first byte of the first character to underline in the string. Underlining begins at the left edge of this character. | ||
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 lastByte will not itself be underlined. |
______________
DESCRIPTION
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 Tk_ComputeTextLayout. 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. 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 Tcl_UtfAtIndex and related routines.
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 Tk_ComputeTextLayout for a programming interface that supports the platform-independent expansion of tab characters into columns and newlines/returns into multi-line text.
Tk_MeasureChars 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 string that fit in the space specified by maxPixels subject to the conditions described by flags. If all characters fit, the return value will be numBytes. *lengthPtr 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 *lengthPtr is filled with the distance between the left edge of string[0] and the right edge of string[4].
Tk_TextWidth is a wrapper function that provides a simpler interface to the Tk_MeasureChars function. The return value is how much space in pixels the given string needs.
Tk_DrawChars draws the string at the given location in the given drawable.
Tk_UnderlineChars underlines the given range of characters in the given string. It does not draw the characters (which are assumed to have been displayed previously by Tk_DrawChars); 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.
SEE ALSO
font(n), FontId(3)
KEYWORDS
font, measurement
More Linux Commands
manpages/baudrate.3ncurses.html
baudrate(3ncurses) - curses environment query routines......
The baudrate routine returns the output speed of the terminal. The number returned is in bits per second, for example 9600, and is an integer. The erasechar rou
manpages/vdir.1.html
vdir(1) - list directory contents - Linux manual page.......
vdir.1 - List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandator
manpages/bytes.3pm.html
bytes(3pm) - Perl pragma to force byte semantics rather than
The use bytes pragma disables character semantics for the rest of the lexical scope in which it appears. no bytes can be used to reverse the effect of use bytes
manpages/Tk_HandleEvent.3.html
Tk_HandleEvent(3) - invoke event handlers for window system
Tk_HandleEvent is a lower-level procedure that deals with window events. It is called by Tcl_ServiceEvent (and indirectly by Tcl_DoOneEvent), and in a few other
manpages/auparse_first_record.3.html
auparse_first_record(3) - reposition record cursor (ManPage)
auparse_first_record repositions the internal cursors of the parsing library to point to the first record in the current event. RETURN VALUE Returns -1 if an er
manpages/lndir.1.html
lndir(1) - create a shadow directory of symbolic links to an
The lndir program makes a shadow copy todir of a directory tree fromdir, except that the shadow is not populated with real files but instead with symbolic links
manpages/sivtest.1.html
sivtest(1) - interactive MANAGESIEVE test program (ManPage)
sivtest is a utility that allows you to authenticate to a MANAGESIEVE server and interactively issue commands to it. Once authenticated you may issue any MANAGE
manpages/pselect6.2.html
pselect6(2) - synchronous I/O multiplexing - Linux man page
select() and pselect() allow a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become ready for some class of I/
manpages/XML::DOM::PerlSAX.3pm.html
XML::DOM::PerlSAX(3pm) - Old name of XML::Handler::BuildDOM
XML::DOM::PerlSAX was renamed to XML::Handler::BuildDOM to comply with naming conventions for PerlSAX filters/handlers. For backward compatibility, this package
manpages/XtAppMainLoop.3.html
XtAppMainLoop(3) - query and process events and input.......
If the X event queue is empty, XtAppNextEvent flushes the X output buffers of each Display in the application context and waits for an event while looking at th
manpages/Tcl_SetCommandInfo.3.html
Tcl_SetCommandInfo(3) - implement new commands in C.........
Tcl_CreateObjCommand defines a new command in interp and associates it with procedure proc such that whenever name is invoked as a Tcl command (e.g., via a call
manpages/mono-service.1.html
mono-service(1) - Mono ServiceProcess host - Linux man page
The mono-service is a host to run services built with the ServiceProcess assembly. Use mono-service to run services that use the 1.0 assemblies and use mono-ser
