diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-09-08 16:13:45 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-09-08 16:13:45 (GMT) |
commit | 94bc46d46cbcb986f2da2451a7e557fb6cfd017b (patch) | |
tree | 5f23acee730c544b491aba77d49ce84b33d02279 /win/tkWinFont.c | |
parent | dcf3897c755ed042d4b1b5b8481d5c83c2a928b4 (diff) | |
download | tk-94bc46d46cbcb986f2da2451a7e557fb6cfd017b.zip tk-94bc46d46cbcb986f2da2451a7e557fb6cfd017b.tar.gz tk-94bc46d46cbcb986f2da2451a7e557fb6cfd017b.tar.bz2 |
Assorted minor cleanups.
Diffstat (limited to 'win/tkWinFont.c')
-rw-r--r-- | win/tkWinFont.c | 145 |
1 files changed, 71 insertions, 74 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 5021955..69ae9f9 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinFont.c,v 1.32 2007/05/04 21:29:22 patthoyts Exp $ + * RCS: @(#) $Id: tkWinFont.c,v 1.33 2007/09/08 16:13:45 dkf Exp $ */ #include "tkWinInt.h" @@ -279,7 +279,6 @@ TkpFontPkgInit( * Map a platform-specific native font name to a TkFont. * * Results: - * The return value is a pointer to a TkFont that represents the native * font. If a native font by the given name could not be found, the * return value is NULL. @@ -500,10 +499,10 @@ TkpGetFontFromAttributes( char ***fontFallbacks; Tk_Uid faceName, fallback, actualName; - tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr; - window = Tk_WindowId(tkwin); - hwnd = (window == None) ? NULL : TkWinGetHWND(window); - hdc = GetDC(hwnd); + tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr; + window = Tk_WindowId(tkwin); + hwnd = (window == None) ? NULL : TkWinGetHWND(window); + hdc = GetDC(hwnd); /* * Algorithm to get the closest font name to the one requested. @@ -613,9 +612,9 @@ TkpGetFontFamilies( HWND hwnd; Window window; - window = Tk_WindowId(tkwin); - hwnd = (window == None) ? NULL : TkWinGetHWND(window); - hdc = GetDC(hwnd); + window = Tk_WindowId(tkwin); + hwnd = (window == None) ? NULL : TkWinGetHWND(window); + hdc = GetDC(hwnd); /* * On any version NT, there may fonts with international names. Use the @@ -706,8 +705,8 @@ TkpGetSubFonts( * * TkpGetFontAttrsForChar -- * - * Retrieve the font attributes of the actual font used to render - * a given character. + * Retrieve the font attributes of the actual font used to render a given + * character. * * Results: * None. @@ -741,8 +740,9 @@ TkpGetFontAttrsForChar( HFONT oldfont; /* Saved font from the device context */ TEXTMETRIC tm; /* Font metrics of the selected subfont */ - - /* Get the font attributes */ + /* + * Get the font attributes. + */ oldfont = SelectObject(hdc, thisSubFontPtr->hFont); GetTextMetrics(hdc, &tm); @@ -750,7 +750,7 @@ TkpGetFontAttrsForChar( ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; faPtr->size = TkFontGetPoints(tkwin, - tm.tmInternalLeading - tm.tmHeight); + tm.tmInternalLeading - tm.tmHeight); faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = tm.tmItalic ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = (tm.tmUnderlined != 0); @@ -805,14 +805,12 @@ Tk_MeasureChars( HDC hdc; HFONT oldFont; WinFont *fontPtr; - int curX; + int curX, moretomeasure; Tcl_UniChar ch; SIZE size; - int moretomeasure; FontFamily *familyPtr; Tcl_DString runString; - SubFont *thisSubFontPtr; - SubFont *lastSubFontPtr; + SubFont *thisSubFontPtr, *lastSubFontPtr; CONST char *p, *end, *next = NULL, *start; if (numBytes == 0) { @@ -987,19 +985,18 @@ Tk_MeasureChars( * TkpMeasureCharsInContext -- * * Determine the number of bytes from the string that will fit in the - * given horizontal span. The measurement is done under the assumption + * given horizontal span. The measurement is done under the assumption * that TkpDrawCharsInContext() will be used to actually display the * characters. * * This one is almost the same as Tk_MeasureChars(), but with access to - * all the characters on the line for context. On Windows this context + * all the characters on the line for context. On Windows this context * isn't consulted, so we just call Tk_MeasureChars(). * * Results: - * The return value is the number of bytes from source that - * fit into the span that extends from 0 to maxLength. *lengthPtr is - * filled with the x-coordinate of the right edge of the last - * character that did fit. + * The return value is the number of bytes from source that fit into the + * span that extends from 0 to maxLength. *lengthPtr is filled with the + * x-coordinate of the right edge of the last character that did fit. * * Side effects: * None. @@ -1009,30 +1006,30 @@ Tk_MeasureChars( int TkpMeasureCharsInContext( - Tk_Font tkfont, /* Font in which characters will be drawn. */ - CONST char * source, /* UTF-8 string to be displayed. Need not be - * '\0' terminated. */ - int numBytes, /* Maximum number of bytes to consider from - * source string in all. */ - int rangeStart, /* Index of first byte to measure. */ - int rangeLength, /* Length of range to measure in bytes. */ - int maxLength, /* If >= 0, maxLength specifies the longest - * permissible line length; don't consider any - * character that would cross this x-position. - * If < 0, then line length is unbounded and the - * flags argument is ignored. */ - int flags, /* Various flag bits OR-ed together: - * TK_PARTIAL_OK means include the last char - * which only partially fit on this line. - * TK_WHOLE_WORDS means stop on a word boundary, - * if possible. TK_AT_LEAST_ONE means return at - * least one character even if no characters fit. - * TK_ISOLATE_END means that the last character - * should not be considered in context with the - * rest of the string (used for breaking - * lines). */ - int * lengthPtr) /* Filled with x-location just after the - * terminating character. */ + Tk_Font tkfont, /* Font in which characters will be drawn. */ + CONST char *source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. */ + int numBytes, /* Maximum number of bytes to consider from + * source string in all. */ + int rangeStart, /* Index of first byte to measure. */ + int rangeLength, /* Length of range to measure in bytes. */ + int maxLength, /* If >= 0, maxLength specifies the longest + * permissible line length; don't consider any + * character that would cross this x-position. + * If < 0, then line length is unbounded and + * the flags argument is ignored. */ + int flags, /* Various flag bits OR-ed together: + * TK_PARTIAL_OK means include the last char + * which only partially fit on this line. + * TK_WHOLE_WORDS means stop on a word + * boundary, if possible. TK_AT_LEAST_ONE + * means return at least one character even if + * no characters fit. TK_ISOLATE_END means + * that the last character should not be + * considered in context with the rest of the + * string (used for breaking lines). */ + int *lengthPtr) /* Filled with x-location just after the + * terminating character. */ { (void) numBytes; /*unused*/ return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength, @@ -1207,8 +1204,8 @@ Tk_DrawChars( * TkpDrawCharsInContext -- * * Draw a string of characters on the screen like Tk_DrawChars(), but - * with access to all the characters on the line for context. On - * Windows this context isn't consulted, so we just call Tk_DrawChars(). + * with access to all the characters on the line for context. On Windows + * this context isn't consulted, so we just call Tk_DrawChars(). * * Results: * None. @@ -1221,24 +1218,24 @@ Tk_DrawChars( void TkpDrawCharsInContext( - Display * display, /* Display on which to draw. */ - Drawable drawable, /* Window or pixmap in which to draw. */ - GC gc, /* Graphics context for drawing characters. */ - Tk_Font tkfont, /* Font in which characters will be drawn; must - * be the same as font used in GC. */ - CONST char * source, /* UTF-8 string to be displayed. Need not be - * '\0' terminated. All Tk meta-characters - * (tabs, control characters, and newlines) - * should be stripped out of the string that is - * passed to this function. If they are not - * stripped out, they will be displayed as - * regular printing characters. */ - int numBytes, /* Number of bytes in string. */ - int rangeStart, /* Index of first byte to draw. */ - int rangeLength, /* Length of range to draw in bytes. */ - int x, int y) /* Coordinates at which to place origin of the - * whole (not just the range) string when - * drawing. */ + Display *display, /* Display on which to draw. */ + Drawable drawable, /* Window or pixmap in which to draw. */ + GC gc, /* Graphics context for drawing characters. */ + Tk_Font tkfont, /* Font in which characters will be drawn; + * must be the same as font used in GC. */ + CONST char *source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. All Tk meta-characters + * (tabs, control characters, and newlines) + * should be stripped out of the string that + * is passed to this function. If they are not + * stripped out, they will be displayed as + * regular printing characters. */ + int numBytes, /* Number of bytes in string. */ + int rangeStart, /* Index of first byte to draw. */ + int rangeLength, /* Length of range to draw in bytes. */ + int x, int y) /* Coordinates at which to place origin of the + * whole (not just the range) string when + * drawing. */ { (void) numBytes; /*unused*/ Tk_DrawChars(display, drawable, gc, tkfont, @@ -1371,9 +1368,9 @@ InitFont( TkFontAttributes *faPtr; char buf[LF_FACESIZE * sizeof(WCHAR)]; - window = Tk_WindowId(tkwin); - hwnd = (window == None) ? NULL : TkWinGetHWND(window); - hdc = GetDC(hwnd); + window = Tk_WindowId(tkwin); + hwnd = (window == None) ? NULL : TkWinGetHWND(window); + hdc = GetDC(hwnd); oldFont = SelectObject(hdc, hFont); GetTextMetrics(hdc, &tm); @@ -1530,9 +1527,9 @@ ReleaseSubFont( * * AllocFontFamily -- * - * Find the FontFamily structure associated with the given font name. - * The information should be stored by the caller in a SubFont and used - * when determining if that SubFont supports a character. + * Find the FontFamily structure associated with the given font name. The + * information should be stored by the caller in a SubFont and used when + * determining if that SubFont supports a character. * * Cannot use the string name used to construct the font as the key, * because the capitalization may not be canonical. Therefore use the |