2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / src / fonts.h
blobd951811754c68a806e9ef2cde220f45be3ac680f
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 bool gapless;
32 int n_faces;
33 double size;
34 int master;
36 GlyphInfo glyphs[GLYPH_CACHE_SIZE];
37 int n_glyphs;
39 TextFont (FontFace **faces, int n_faces, int master, bool gapless, double size);
41 GlyphInfo *GetGlyphInfo (FontFace *face, gunichar unichar, guint32 index);
42 void UpdateFaceExtents ();
43 void ClearGlyphCache ();
45 public:
46 ~TextFont ();
48 static TextFont *Load (const char *resource, int index, double size, StyleSimulations simulate);
49 static TextFont *Load (const TextFontDescription *desc);
51 bool SetStyleSimulations (StyleSimulations simulate);
52 StyleSimulations GetStyleSimulations () const;
54 bool SetSize (double size);
55 double GetSize () const;
57 GlyphInfo *GetGlyphInfo (gunichar unichar);
58 GlyphInfo *GetGlyphInfoByIndex (guint32 index);
60 double Kerning (GlyphInfo *left, GlyphInfo *right);
61 double Descender () const;
62 double Ascender () const;
63 double Height () const;
65 double UnderlinePosition () const;
66 double UnderlineThickness () const;
68 void Path (cairo_t *cr, GlyphInfo *glyph, double x, double y);
69 void Path (cairo_t *cr, gunichar unichar, double x, double y);
71 void AppendPath (moon_path *path, GlyphInfo *glyph, double x, double y);
72 void AppendPath (moon_path *path, gunichar unichar, double x, double y);
76 class TextFontDescription {
77 TextFont *font;
78 bool changed;
80 char *source;
81 char *family;
82 char *language;
83 FontStretches stretch;
84 FontWeights weight;
85 FontStyles style;
86 double size;
88 public:
89 TextFontDescription ();
90 ~TextFontDescription ();
92 TextFont *GetFont ();
93 void Reload ();
95 bool SetSource (const char *source);
96 const char *GetSource () const;
98 bool SetFamily (const char *family);
99 const char *GetFamily () const;
100 char **GetFamilies () const;
102 bool SetLanguage (const char *lang);
103 const char *GetLanguage () const;
105 bool SetStretch (FontStretches stretch);
106 FontStretches GetStretch () const;
108 bool SetWeight (FontWeights weight);
109 FontWeights GetWeight () const;
111 bool SetStyle (FontStyles style);
112 FontStyles GetStyle () const;
114 bool SetSize (double size);
115 double GetSize () const;
118 #endif /* __FONTS_H__ */