summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixRFont.c
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 /unix/tkUnixRFont.c
parent24d0506cfd0c1ab9b1867e9276ca7b0b4ccadb95 (diff)
downloadtk-96dd14f8a93c3f9dbccdc44cfaac782b612a6eed.zip
tk-96dd14f8a93c3f9dbccdc44cfaac782b612a6eed.tar.gz
tk-96dd14f8a93c3f9dbccdc44cfaac782b612a6eed.tar.bz2
TIP 300 IMPLEMENTATION
Diffstat (limited to 'unix/tkUnixRFont.c')
-rw-r--r--unix/tkUnixRFont.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 407bcf6..285ac8e 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixRFont.c,v 1.13 2006/03/23 22:08:51 rmax Exp $
+ * RCS: @(#) $Id: tkUnixRFont.c,v 1.14 2006/12/01 20:14:23 kennykb Exp $
*/
#include "tkUnixInt.h"
@@ -469,6 +469,66 @@ TkpGetSubFonts(
Tcl_SetObjResult(interp, resultPtr);
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * 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 */
+{
+ UnixFtFont *fontPtr = (UnixFtFont*) tkfont;
+ /* Structure describing the logical font */
+ FcChar32 ucs4 = (FcChar32) c;
+ /* UCS-4 character to map */
+ XftFont *xftFontPtr = GetFont(fontPtr, ucs4);
+ /* Actual font used to render the character */
+ const char* family; /* Font family name */
+ double size; /* Font size */
+ int weight; /* Font weight */
+ int slant; /* Font slant */
+
+ if (XftPatternGetString(xftFontPtr->pattern, XFT_FAMILY, 0,
+ &family) != XftResultMatch) {
+ family = "Unknown";
+ }
+ if (XftPatternGetDouble(xftFontPtr->pattern, XFT_SIZE, 0,
+ &size) != XftResultMatch) {
+ size = 12.0;
+ }
+ if (XftPatternGetInteger(xftFontPtr->pattern, XFT_WEIGHT, 0,
+ &weight) != XftResultMatch) {
+ weight = XFT_WEIGHT_MEDIUM;
+ }
+ if (XftPatternGetInteger(xftFontPtr->pattern, XFT_SLANT, 0,
+ &slant) != XftResultMatch) {
+ slant = XFT_SLANT_ROMAN;
+ }
+ faPtr->family = Tk_GetUid(family);
+ faPtr->size = (int) size;
+ faPtr->weight = (weight > XFT_WEIGHT_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL;
+ faPtr->slant = (slant > XFT_SLANT_ROMAN) ? TK_FS_ITALIC : TK_FS_ROMAN;
+ faPtr->underline = fontPtr->font.fa.underline;
+ faPtr->overstrike = fontPtr->font.fa.overstrike;
+
+}
+
int
Tk_MeasureChars(
Tk_Font tkfont, /* Font in which characters will be drawn. */