added MouseWheel event support for Silverlight 3.0
[moon.git] / src / fonts.h
blob44bace383241d717312db383cebaecb5ca0d0b7a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * fonts.h:
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2009 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
13 #ifndef __FONTS_H__
14 #define __FONTS_H__
16 #include <glib.h>
17 #include <cairo.h>
19 #include "fontmanager.h"
20 #include "enums.h"
22 #define GLYPH_CACHE_SIZE 256
24 class TextFontDescription;
26 class TextFont {
27 const TextFontDescription *desc;
28 StyleSimulations simulate;
29 FontFaceExtents extents;
30 FontFace **faces;
31 int n_faces;
32 double size;
33 int master;
35 GlyphInfo glyphs[GLYPH_CACHE_SIZE];
36 int n_glyphs;
38 TextFont (FontFace **faces, int n_faces, int master, double size);
40 GlyphInfo *GetGlyphInfo (FontFace *face, gunichar unichar, guint32 index);
41 void UpdateFaceExtents ();
42 void ClearGlyphCache ();
44 public:
45 ~TextFont ();
47 static TextFont *Load (const char *resource, int index, double size, StyleSimulations simulate);
48 static TextFont *Load (const TextFontDescription *desc);
50 bool SetStyleSimulations (StyleSimulations simulate);
51 StyleSimulations GetStyleSimulations () const;
53 bool SetSize (double size);
54 double GetSize () const;
56 GlyphInfo *GetGlyphInfo (gunichar unichar);
57 GlyphInfo *GetGlyphInfoByIndex (guint32 index);
59 double Kerning (GlyphInfo *left, GlyphInfo *right);
60 double Descender () const;
61 double Ascender () const;
62 double Height () const;
64 double UnderlinePosition () const;
65 double UnderlineThickness () const;
67 void Path (cairo_t *cr, GlyphInfo *glyph, double x, double y);
68 void Path (cairo_t *cr, gunichar unichar, double x, double y);
70 void AppendPath (moon_path *path, GlyphInfo *glyph, double x, double y);
71 void AppendPath (moon_path *path, gunichar unichar, double x, double y);
75 class TextFontDescription {
76 TextFont *font;
77 bool changed;
79 char *source;
80 char *family;
81 char *language;
82 FontStretches stretch;
83 FontWeights weight;
84 FontStyles style;
85 double size;
87 public:
88 TextFontDescription ();
89 ~TextFontDescription ();
91 TextFont *GetFont ();
92 void Reload ();
94 bool SetSource (const char *source);
95 const char *GetSource () const;
97 bool SetFamily (const char *family);
98 const char *GetFamily () const;
99 char **GetFamilies () const;
101 bool SetLanguage (const char *lang);
102 const char *GetLanguage () const;
104 bool SetStretch (FontStretches stretch);
105 FontStretches GetStretch () const;
107 bool SetWeight (FontWeights weight);
108 FontWeights GetWeight () const;
110 bool SetStyle (FontStyles style);
111 FontStyles GetStyle () const;
113 bool SetSize (double size);
114 double GetSize () const;
117 #endif /* __FONTS_H__ */