1 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil c-basic-offset: 3 -*- */
2 // vim:cindent:ts=3:sw=3:et:tw=80:sta:
3 /*************************************************************** gltext-cpr beg
4  *
5  * GLText - OpenGL TrueType Font Renderer
6  * GLText is (C) Copyright 2002 by Ben Scott
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  * -----------------------------------------------------------------
24  * File:          $RCSfile: PixmapRenderer.cpp,v $
25  * Date modified: $Date: 2003/03/15 06:19:00 $
26  * Version:       $Revision: 1.6 $
27  * -----------------------------------------------------------------
28  *
29  ************************************************************ gltext-cpr-end */
30 #include "PixmapRenderer.h"
31 #include "GLPixelGlyph.h"
32 #include "OpenGL.h"
33 
34 namespace gltext
35 {
create(Font * font)36    PixmapRenderer* PixmapRenderer::create(Font* font)
37    {
38       return new PixmapRenderer(font);
39    }
40 
PixmapRenderer(Font * font)41    PixmapRenderer::PixmapRenderer(Font* font)
42       : AbstractRenderer(font)
43    {
44    }
45 
46    GLGlyph*
makeGlyph(Glyph * glyph)47    PixmapRenderer::makeGlyph(Glyph* glyph)
48    {
49       const int width  = glyph->getWidth();
50       const int height = glyph->getHeight();
51       const int offX   = glyph->getXOffset();
52       const int offY   = glyph->getYOffset();
53       u8* pixels = new u8[width * height];
54       glyph->render(pixels);
55 
56       return new GLPixelGlyph(offX, offY + getFont()->getAscent(),
57                               width, height, pixels);
58    }
59 }
60