summaryrefslogtreecommitdiffstats
path: root/generic/tkFont.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkFont.c')
-rw-r--r--generic/tkFont.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 31d94e5..5c7341c 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.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: tkFont.c,v 1.19 2002/08/05 04:30:38 dgp Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.20 2002/08/31 06:12:20 das Exp $
*/
#include "tkPort.h"
@@ -3713,3 +3713,47 @@ TkDebugFont(tkwin, name)
}
return resultPtr;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkFontGetFirstTextLayout --
+ *
+ * This procedure returns the first chunk of a Tk_TextLayout,
+ * i.e. until the first font change on the first line (or the
+ * whole first line if there is no such font change).
+ *
+ * Results:
+ * The return value is the byte length of the chunk, the chunk
+ * itself is copied into dst and its Tk_Font into font.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkFontGetFirstTextLayout(
+ Tk_TextLayout layout, /* Layout information, from a previous call
+ * to Tk_ComputeTextLayout(). */
+ Tk_Font * font,
+ char * dst)
+{
+ TextLayout *layoutPtr;
+ LayoutChunk *chunkPtr;
+ int numBytesInChunk;
+
+ layoutPtr = (TextLayout *)layout;
+ if ((layoutPtr==NULL)
+ || (layoutPtr->numChunks==0)
+ || (layoutPtr->chunks->numDisplayChars <= 0)) {
+ dst[0] = '\0';
+ return 0;
+ }
+ chunkPtr = layoutPtr->chunks;
+ numBytesInChunk = chunkPtr->numBytes;
+ strncpy(dst, chunkPtr->start, numBytesInChunk);
+ *font = layoutPtr->tkfont;
+ return numBytesInChunk;
+}