font_vector.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 #include "../api_display.h"
00036 #include "font.h"
00037 
00038 class CL_Font_Vector_Impl;
00039 class CL_FontMetrics;
00040 class CL_VirtualDirectory;
00041 class CL_GlyphPrimitivesArrayOutline;
00042 class CL_GlyphPrimitivesArray;
00043 class CL_FontProvider_Vector;
00044 
00048 class CL_GlyphPrimitivesArray
00049 {
00051 public:
00052 
00056         CL_GlyphPrimitivesArray(int num_triangles)
00057         {
00058                 int size = num_triangles*3;
00059                 vertex.resize(size);
00060         }
00061 
00062         ~CL_GlyphPrimitivesArray()
00063         {
00064         }
00065 
00066         std::vector<CL_Vec2f> vertex;
00067 };
00068 
00072 class CL_GlyphPrimitivesArrayOutline
00073 {
00075 public:
00076 
00080         CL_GlyphPrimitivesArrayOutline(int num_lines)
00081         {
00082                 vertex.resize(1);
00083                 vertex[0].resize(num_lines+1);
00084         }
00085         
00087 public:
00088 
00092         void new_subarray(int num_lines)
00093         {
00094                 std::vector<std::vector<CL_Vec2f> >::size_type size = vertex.size();
00095                 vertex.resize(size+1);
00096 
00097                 vertex[size].resize(num_lines+1);
00098         }
00099 
00100         std::vector< std::vector<CL_Vec2f> > vertex;
00101 };
00102 
00106 class CL_API_DISPLAY CL_Font_Vector : public CL_Font
00107 {
00110 
00111 public:
00113         CL_Font_Vector();
00114 
00119         CL_Font_Vector( const CL_StringRef &typeface_name, int height);
00120 
00126         CL_Font_Vector( const CL_StringRef &typeface_name, int height, CL_IODevice &file);
00127 
00133         CL_Font_Vector( const CL_StringRef &typeface_name, int height, const CL_VirtualDirectory &directory);
00134 
00138         CL_Font_Vector( const CL_FontDescription &desc);
00139 
00144         CL_Font_Vector( const CL_FontDescription &desc, CL_IODevice &file);
00145 
00150         CL_Font_Vector( const CL_FontDescription &desc, const CL_VirtualDirectory &directory);
00151 
00152         ~CL_Font_Vector();
00153 
00157 
00158 public:
00159 
00161         CL_FontProvider_Vector *get_provider() const;
00162 
00166 
00167 public:
00169         int get_glyph_count(const CL_StringRef &text);
00170 
00172         CL_GlyphPrimitivesArrayOutline get_glyph_outline(int glyph);
00173 
00175         CL_GlyphPrimitivesArray get_glyph_triangles(int glyph);
00176 
00178         void get_glyphs(
00179                 const CL_StringRef &text,
00180                 int *out_glyphs,
00181                 float *out_interspacing_x,
00182                 float *out_interspacing_y);
00183 
00185         void draw_glyphs(
00186                 CL_GraphicContext &gc,
00187                 float x,
00188                 float y,
00189                 int *glyphs,
00190                 int length,
00191                 bool filled = true,
00192                 float *interspacing_x = 0,
00193                 float *interspacing_y = 0,
00194                 const CL_Colorf &color = CL_Colorf::white);
00195 
00202         CL_Sizef get_glyphs_size(int *glyphs, int length);
00203 
00207 
00209 };
00210