The Pedigree Project  0.1
Font.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef FONT_H
21 #define FONT_H
22 
23 #include "environment.h"
24 #include <stdint.h>
25 #include <stdlib.h>
26 
27 #include "pedigree/native/graphics/Graphics.h"
28 
29 #include <map>
30 
31 #include <cairo/cairo.h>
32 
33 class Font
34 {
35  public:
36  Font(
37  cairo_t *pCairo, size_t requestedSize, const char *pFilename,
38  bool bCache, size_t nWidth);
39  virtual ~Font();
40 
41  virtual size_t render(
42  PedigreeGraphics::Framebuffer *pFb, uint32_t c, size_t x, size_t y,
43  uint32_t f, uint32_t b, bool bBack = true, bool bBold = false,
44  bool bItalic = false, bool bUnderline = false);
45 
46  virtual size_t render(
47  const char *s, size_t x, size_t y, uint32_t f, uint32_t b,
48  bool bBack = true, bool bBold = false, bool bItalic = false,
49  bool bUnderline = false);
50 
51  size_t getWidth()
52  {
53  return m_CellWidth;
54  }
55  size_t getHeight()
56  {
57  return m_CellHeight;
58  }
59  size_t getBaseline()
60  {
61  return m_Baseline;
62  }
63 
64  const char *precache(uint32_t c);
65 
66  void updateCairo(cairo_t *pCairo);
67 
68  private:
69  Font(const Font &);
70  Font &operator=(const Font &);
71 
72  size_t m_CellWidth;
73  size_t m_CellHeight;
74  size_t m_Baseline;
75 
76  std::map<uint32_t, char *> m_ConversionCache;
77 
78  // opaque pointer that allows the .cc files to refer to pango etc without
79  // requiring clients to also see the headers
80  struct FontLibraries *m_FontLibraries;
81 };
82 
83 #endif
Font(cairo_t *pCairo, size_t requestedSize, const char *pFilename, bool bCache, size_t nWidth)
Definition: Font.cc:48
Definition: Font.h:33