summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2006-12-01 20:14:22 (GMT)
committerKevin B Kenny <kennykb@acm.org>2006-12-01 20:14:22 (GMT)
commit96dd14f8a93c3f9dbccdc44cfaac782b612a6eed (patch)
tree489ea29c16233aae8944a6e2c553d6f40503fc20 /win
parent24d0506cfd0c1ab9b1867e9276ca7b0b4ccadb95 (diff)
downloadtk-96dd14f8a93c3f9dbccdc44cfaac782b612a6eed.zip
tk-96dd14f8a93c3f9dbccdc44cfaac782b612a6eed.tar.gz
tk-96dd14f8a93c3f9dbccdc44cfaac782b612a6eed.tar.bz2
TIP 300 IMPLEMENTATION
Diffstat (limited to 'win')
-rw-r--r--win/tkWinFont.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index bddaed9..564471d 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.27 2006/03/22 00:21:20 das Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.28 2006/12/01 20:14:24 kennykb Exp $
*/
#include "tkWinInt.h"
@@ -561,6 +561,62 @@ TkpGetSubFonts(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkpGetFontAttrsForChar --
+ *
+ * Retrieve the font attributes of the actual font used to render
+ * a given character.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The font attributes are stored in *faPtr.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpGetFontAttrsForChar(
+ Tk_Window tkwin, /* Window on the font's display */
+ Tk_Font tkfont, /* Font to query */
+ Tcl_UniChar c, /* Character of interest */
+ TkFontAttributes* faPtr) /* Output: Font attributes */
+{
+ WinFont *fontPtr = (WinFont *) tkfont;
+ /* Structure describing the logical font */
+ HDC hdc = GetDC(fontPtr->hwnd);
+ /* GDI device context */
+ SubFont *lastSubFontPtr = &fontPtr->subFontArray[0];
+ /* Pointer to subfont array in case
+ * FindSubFontForChar needs to fix up
+ * the memory allocation */
+ SubFont *thisSubFontPtr = FindSubFontForChar(fontPtr, c,
+ &lastSubFontPtr);
+ /* Pointer to the subfont to use for
+ * the given character */
+ FontFamily *familyPtr = thisSubFontPtr->familyPtr;
+ HFONT oldfont; /* Saved font from the device context */
+ TEXTMETRIC tm; /* Font metrics of the selected subfont */
+
+
+ /* Get the font attributes */
+
+ oldfont = SelectObject(hdc, thisSubFontPtr->hFont);
+ GetTextMetrics(hdc, &tm);
+ SelectObject(hdc, oldfont);
+ ReleaseDC(fontPtr->hwnd, hdc);
+ faPtr->family = familyPtr->faceName;
+ faPtr->size = TkFontGetPoints(tkwin,
+ 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);
+ faPtr->overstrike = fontPtr->font.fa.overstrike;
+}
+
+/*
*---------------------------------------------------------------------------
*
* Tk_MeasureChars --