summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXFont.h
blob: 22555a5ffd657d96903bec147dcec0241aef3005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * tkMacOSXFont.h --
 *
 *      Private functions and structs exported from tkMacOSXFont.c
 *      for use in ATSU specific extensions.
 *
 * Copyright 2002-2004 Benjamin Riefenstahl, Benjamin.Riefenstahl@epost.de
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkMacOSXFont.h,v 1.4 2006/04/28 06:02:48 das Exp $
 */

#ifndef	TKMACOSXFONT_H
#define	TKMACOSXFONT_H	1

#include "tkFont.h"

#ifndef _TKMACINT
#include "tkMacOSXInt.h"
#endif

/*
 * Switches
 */

#define TK_MAC_USE_QUARZ 1

/*
 * Types
 */

/*
 * The following structure represents our Macintosh-specific implementation
 * of a font object.
 */

typedef struct {
    TkFont font;                /* Stuff used by generic font package.  Must
                                 * be first in structure. */

    /*
     * The ATSU view of the font and other text properties.  Used for drawing
     * and measuring.
     */

    ATSUFontID atsuFontId;      /* == FMFont. */
    ATSUTextLayout atsuLayout;  /* ATSU layout object, representing the whole
                                 * text that ATSU sees with some option
                                 * bits. */
    ATSUStyle atsuStyle;        /* ATSU style object, representing a run of
                                 * text with the same properties. */

    /*
     * The QuickDraw view of the font.  Used to configure controls.
     */

    FMFontFamily qdFont;        /* == FMFontFamilyId, Carbon replacement for
                                 * QD face numbers. */
    short qdSize;               /* Font size in points. */
    short qdStyle;              /* QuickDraw style bits. */
} TkMacOSXFont;


#if TK_MAC_USE_QUARZ

/*
 * To use Quarz drawing we need some additional context.  FIXME: We would
 * have liked to use the similar functions from tkMacOSXDraw.c to do this
 * (TkMacOSXSetUpCGContext(), etc), but a) those don't quite work for us
 * (e.g. we can't use a simple upside-down coordinate system transformation,
 * as we don't want upside-down characters ;-), and b) we don't have the
 * necessary context information (MacDrawable), that we need as parameter for
 * those functions.  So I just cobbled together a limited edition, getting
 * the necessary parameters from the current QD GraphPort.
 */

typedef struct {
    CGContextRef cgContext;     /* Quarz context. */
    CGrafPtr graphPort;         /* QD graph port to which this belongs.
                                 * Needed for releasing cgContext. */
    Rect portRect;              /* Cached size of port. */
} TkMacOSXFontDrawingContext;

#else /* ! TK_MAC_USE_QUARZ */

/*
 * Just a dummy, so we don't have to #ifdef the parameter lists of functions
 * that use this.
 */

typedef struct {} DrawingContext;

#endif /* ? TK_MAC_USE_QUARZ */

/*
 * Function prototypes
 */

MODULE_SCOPE void	TkMacOSXLayoutSetString(const TkMacOSXFont * fontPtr,
			    const TkMacOSXFontDrawingContext *drawingContextPtr,
			    const UniChar * uchars, int ulen);
MODULE_SCOPE void	TkMacOSXInitControlFontStyle(Tk_Font tkfont,
			    ControlFontStylePtr fsPtr);

#if TK_MAC_USE_QUARZ
MODULE_SCOPE void	TkMacOSXQuarzStartDraw(
			    TkMacOSXFontDrawingContext * contextPtr);
MODULE_SCOPE void	TkMacOSXQuarzEndDraw(
			    TkMacOSXFontDrawingContext * contextPtr);
#endif /* TK_MAC_USE_QUARZ */

#endif	/*TKMACOSXFONT_H*/