Upload tizen 2.0 beta source
[external/pango1.0.git] / pango / pangofc-private.h
1 /* Pango
2  * pangofc-private.h: Private routines and declarations for generic
3  *  fontconfig operation
4  *
5  * Copyright (C) 2003 Red Hat Software
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef __PANGOFC_PRIVATE_H__
24 #define __PANGOFC_PRIVATE_H__
25
26 #include <pangofc-fontmap.h>
27
28 G_BEGIN_DECLS
29
30
31 typedef struct _PangoFcMetricsInfo  PangoFcMetricsInfo;
32
33 struct _PangoFcMetricsInfo
34 {
35   const char       *sample_str;
36   PangoFontMetrics *metrics;
37 };
38
39
40 typedef struct _PangoFcCmapCacheEntry  PangoFcCmapCacheEntry;
41 typedef struct _PangoFcCmapCache       PangoFcCmapCache;
42
43 #define CMAP_CACHE_NUM_ENTRIES 256 /* should be power of two */
44 #define CMAP_CACHE_MASK (CMAP_CACHE_NUM_ENTRIES - 1)
45
46 struct _PangoFcCmapCacheEntry
47 {
48   gunichar   ch;
49   PangoGlyph glyph;
50 };
51
52 struct _PangoFcCmapCache
53 {
54   guint ref_count;
55   PangoFcCmapCacheEntry entries[CMAP_CACHE_NUM_ENTRIES];
56 };
57
58
59 #define PANGO_SCALE_26_6 (PANGO_SCALE / (1<<6))
60 #define PANGO_PIXELS_26_6(d)                            \
61   (((d) >= 0) ?                                         \
62    ((d) + PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6 :    \
63    ((d) - PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6)
64 #define PANGO_UNITS_26_6(d) (PANGO_SCALE_26_6 * (d))
65
66 void _pango_fc_font_shutdown (PangoFcFont *fcfont);
67
68 void           _pango_fc_font_map_remove          (PangoFcFontMap *fcfontmap,
69                                                    PangoFcFont    *fcfont);
70
71 PangoCoverage *_pango_fc_font_map_get_coverage    (PangoFcFontMap *fcfontmap,
72                                                    PangoFcFont    *fcfont);
73 PangoCoverage  *_pango_fc_font_map_fc_to_coverage (FcCharSet      *charset);
74
75 PangoFcCmapCache *_pango_fc_font_map_get_cmap_cache (PangoFcFontMap *fcfontmap,
76                                                      PangoFcFont    *fcfont);
77 void              _pango_fc_cmap_cache_unref (PangoFcCmapCache *cmap_cache);
78
79 PangoFcDecoder *_pango_fc_font_get_decoder       (PangoFcFont    *font);
80 void            _pango_fc_font_set_decoder       (PangoFcFont    *font,
81                                                   PangoFcDecoder *decoder);
82
83 PangoFcFontKey *_pango_fc_font_get_font_key      (PangoFcFont    *fcfont);
84 void            _pango_fc_font_set_font_key      (PangoFcFont    *fcfont,
85                                                   PangoFcFontKey *key);
86
87 void            pango_fc_font_get_raw_extents    (PangoFcFont    *font,
88                                                   FT_Int32        load_flags,
89                                                   PangoGlyph      glyph,
90                                                   PangoRectangle *ink_rect,
91                                                   PangoRectangle *logical_rect);
92
93 PangoFontMetrics *pango_fc_font_create_metrics_for_context (PangoFcFont   *font,
94                                                             PangoContext  *context);
95
96
97
98 /* To be made public at some point */
99
100 #include <math.h>
101
102 static G_GNUC_UNUSED void
103 pango_matrix_get_font_scale_factors (const PangoMatrix *matrix,
104                                      double *xscale, double *yscale)
105 {
106 /*
107  * Based on cairo-matrix.c:_cairo_matrix_compute_scale_factors()
108  *
109  * Copyright 2005, Keith Packard
110  */
111   double major = 0, minor = 0;
112
113   if (matrix) {
114     double det = matrix->xx * matrix->yy - matrix->yx * matrix->xy;
115
116     if (det)
117       {
118         double x = matrix->xx;
119         double y = matrix->yx;
120
121         major = sqrt (x*x + y*y);
122
123         /*
124          * ignore mirroring
125          */
126         if (det < 0)
127           det = - det;
128
129         if (major)
130           minor = det / major;
131       }
132   }
133
134   if (xscale)
135     *xscale = major;
136   if (yscale)
137     *yscale = minor;
138 }
139
140 G_END_DECLS
141
142 #endif /* __PANGOFC_PRIVATE_H__ */