fontstyle.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Ulrich Kuettler <ulrich.kuettler@gmx.de>
3 Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef FONTSTYLE_H
22#define FONTSTYLE_H
23
24#include <tqstring.h>
25#include <tqfont.h>
26
27#include "contextstyle.h"
28#include "kformuladefs.h"
29#include "symboltable.h"
30
31
32KFORMULA_NAMESPACE_BEGIN
33
34class Artwork;
35class SymbolTable;
36
37
41class FontStyle {
42public:
43 ~FontStyle() {}
44
49 bool init( ContextStyle* context, bool install = true );
50
52 const SymbolTable* symbolTable() const { return &m_symbolTable; }
53 SymbolTable* symbolTable() { return &m_symbolTable; }
54
55 Artwork* createArtwork(SymbolType type = EmptyBracket) const;
56
57 static TQStringList missingFonts( bool install = true );
58
59 static bool m_installed;
60
61 static void testFont( TQStringList& missing, const TQString& fontName );
62
63private:
64
65 static TQStringList missingFontsInternal();
66 static void installFonts();
67
68 SymbolTable m_symbolTable;
69
70};
71
72const TQChar spaceChar = 0x0020;
73const TQChar leftParenthesisChar = 0x0028;
74const TQChar rightParenthesisChar = 0x0029;
75const TQChar leftSquareBracketChar = 0x005B;
76const TQChar rightSquareBracketChar = 0x005D;
77const TQChar leftCurlyBracketChar = 0x007B;
78const TQChar verticalLineChar = 0x007C;
79const TQChar rightCurlyBracketChar = 0x007D;
80const TQChar leftAngleBracketChar = 0x2329;
81const TQChar rightAngleBracketChar = 0x232A;
82const TQChar slashChar = 0x002F;
83const TQChar backSlashChar = 0x005C;
84const TQChar integralChar = 0x222B;
85const TQChar summationChar = 0x2211;
86const TQChar productChar = 0x220F;
87const TQChar applyFunctionChar = 0x2061;
88const TQChar invisibleTimes = 0x2062;
89const TQChar invisibleComma = 0x2063;
90
91extern const TQChar leftRoundBracket[];
92extern const TQChar leftSquareBracket[];
93extern const TQChar leftCurlyBracket[];
94
95extern const TQChar leftLineBracket[];
96extern const TQChar rightLineBracket[];
97
98extern const TQChar rightRoundBracket[];
99extern const TQChar rightSquareBracket[];
100extern const TQChar rightCurlyBracket[];
101
102/*
103 * A piece of art that may be used by any element.
104 */
105class Artwork {
106public:
107
108 Artwork(SymbolType type = EmptyBracket);
109 virtual ~Artwork() {}
110
111 virtual void calcSizes( const ContextStyle& style,
113 double factor,
114 luPt parentSize );
115 virtual void calcSizes( const ContextStyle& style,
117 double factor );
118
119 virtual void draw( TQPainter& painter, const LuPixelRect& r,
120 const ContextStyle& context,
122 StyleAttributes& style,
123 luPt parentSize, const LuPixelPoint& origin );
124 virtual void draw( TQPainter& painter, const LuPixelRect& r,
125 const ContextStyle& context,
127 StyleAttributes& style,
128 const LuPixelPoint& parentOrigin );
129
130 luPixel getWidth() const { return size.width(); }
131 luPixel getHeight() const { return size.height(); }
132
133 void setWidth( luPixel width ) { size.setWidth(width); }
134 void setHeight( luPixel height ) { size.setHeight(height); }
135
136 luPixel getBaseline() const { return baseline; }
137 void setBaseline( luPixel line ) { baseline = line; }
138
139 luPixel getX() const { return point.x(); }
140 luPixel getY() const { return point.y(); }
141
142 void setX( luPixel x ) { point.setX( x ); }
143 void setY( luPixel y ) { point.setY( y ); }
144
145 SymbolType getType() const { return type; }
146 void setType(SymbolType t) { type = t; }
147
148 virtual bool isNormalChar() const { return getBaseline() != -1 && ( cmChar == -1 ); }
149
150 virtual double slant() const { return 0; }
151
152protected:
153
154 void calcCharSize( const ContextStyle& style, luPt height, TQChar ch );
155 void drawCharacter( TQPainter& painter, const ContextStyle& style,
156 luPixel x, luPixel y, luPt height, TQChar ch );
157
158 void calcCharSize( const ContextStyle& style, TQFont f, luPt height, TQChar c );
159 void drawCharacter( TQPainter& painter, const ContextStyle& style,
160 TQFont f,
161 luPixel x, luPixel y, luPt height, uchar c );
162
163 void calcRoundBracket( const ContextStyle& style, const TQChar chars[], luPt height, luPt charHeight );
164 void calcCurlyBracket( const ContextStyle& style, const TQChar chars[], luPt height, luPt charHeight );
165
166 void drawBigRoundBracket( TQPainter& p, const ContextStyle& style, const TQChar chars[], luPixel x, luPixel y, luPt charHeight );
167 void drawBigCurlyBracket( TQPainter& p, const ContextStyle& style, const TQChar chars[], luPixel x, luPixel y, luPt charHeight );
168
169private:
170
171 LuPixelSize size;
172 LuPixelPoint point;
173
177 luPixel baseline;
178
179 SymbolType type;
180
181 bool calcCMDelimiterSize( const ContextStyle& context, uchar c,
182 luPt fontSize, luPt parentSize );
183 void calcLargest( const ContextStyle& context, uchar c, luPt fontSize );
184 void drawCMDelimiter( TQPainter& painter, const ContextStyle& style,
185 luPixel x, luPixel y, luPt height );
186
187 short cmChar;
188};
189
190
191KFORMULA_NAMESPACE_END
192
193#endif
Contains all the style information for the formela.
TextStyle
Textstyles like in TeX.
Base class for all supported font styles.
Definition fontstyle.h:41
const SymbolTable * symbolTable() const
the table for ordinary symbols (those that have a unicode value)
Definition fontstyle.h:52
bool init(ContextStyle *context, bool install=true)
lazy init support.
Definition fontstyle.cpp:42
The symbol table.
Definition symboltable.h:77