H3D API  2.4.1
FontStyle.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __FONTSTYLE_H__
30 #define __FONTSTYLE_H__
31 
32 #include <H3D/X3DFontStyleNode.h>
33 #include <H3D/SFString.h>
34 #include <H3D/MFString.h>
35 #include <H3D/SFBool.h>
36 #include <H3D/SFFloat.h>
37 #include <H3D/SFInt32.h>
38 
39 // forward declaration
40 class FTFont;
41 
42 namespace H3D {
43 
157  class H3DAPI_API FontStyle : public X3DFontStyleNode {
158  public:
165 
167  FontStyle( Inst< SFNode > _metadata = 0,
168  Inst< MFString > _family = 0,
169  Inst< SFBool > _horizontal = 0,
170  Inst< MFString > _justify = 0,
171  Inst< SFString > _language = 0,
172  Inst< SFBool > _leftToRight = 0,
173  Inst< SFFloat > _size = 0,
174  Inst< SFFloat > _spacing = 0,
175  Inst< SFString > _style = 0,
176  Inst< SFBool > _topToBottom = 0,
177  Inst< SFString > _renderType = 0,
178  Inst< SFInt32 > _faceSize = 0);
179 #if defined( HAVE_FREETYPE ) && defined( HAVE_FTGL )
183  virtual void buildFonts();
184 
187  virtual bool isTopToBottom() {
188  return topToBottom->getValue();
189  }
190 
193  virtual bool isLeftToRight() {
194  return leftToRight->getValue();
195  }
196 
199  virtual H3DFloat getSpacing() {
200  return spacing->getValue();
201  }
202 
205  if( horizontal->getValue() )
206  return HORIZONTAL;
207  else
208  return VERTICAL;
209  }
210 
212  virtual void renderChar( unsigned char c );
213 
215  virtual void renderHorizontalLine( const std::string& c );
216 
219  virtual H3DFloat ascender();
220 
223  virtual H3DFloat descender();
224 
227  virtual Vec3f charDimensions( unsigned char c );
228 
230  virtual Justification getMajorJustification();
231 
233  virtual Justification getMinorJustification();
234 
235 #endif
244  H3DUniquePtr< MFString > family;
245 
253  H3DUniquePtr< SFBool > horizontal;
254 
263  H3DUniquePtr< MFString > justify;
264 
270  H3DUniquePtr< SFString > language;
271 
281  H3DUniquePtr< SFBool > leftToRight;
282 
290  H3DUniquePtr< SFFloat > size;
291 
299  H3DUniquePtr< SFFloat > spacing;
300 
310  H3DUniquePtr< SFString > style;
311 
321  H3DUniquePtr< SFBool > topToBottom;
322 
331  H3DUniquePtr< SFString > renderType;
332 
339  H3DUniquePtr< SFInt32 > faceSize;
340 
343  protected:
344 #if defined( HAVE_FREETYPE ) && defined( HAVE_FTGL )
347  FTFont* font;
348 #endif
349  };
350 }
351 
352 #endif
Contains the MFString field class.
Contains the SFBool field class.
Contains the SFFloat field class.
Contains the SFInt32 field class.
Contains the SFString field class.
Header file for X3DFontStyleNode, X3D scene-graph node.
Thrown when the strings in the justify field are invalid values.
Definition: FontStyle.h:162
Thrown when the strings in the renderType field are invalid values.
Definition: FontStyle.h:164
Thrown when the string in the style field is an invalid value.
Definition: FontStyle.h:160
The FontStyle node defines the size, family, and style used for Text nodes, as well as the direction ...
Definition: FontStyle.h:157
H3DUniquePtr< SFFloat > size
The size field specifies the nominal height, in the local coordinate system of the Text node,...
Definition: FontStyle.h:290
H3DUniquePtr< SFString > renderType
The renderType field is H3D API specific and specifies which way the font will be rendered.
Definition: FontStyle.h:331
H3DUniquePtr< SFString > language
The language field specifies the context of the language for the text string in the form of a languag...
Definition: FontStyle.h:270
H3DUniquePtr< SFBool > topToBottom
The topToBottom field indicate direction of text advance in the major (characters within a single str...
Definition: FontStyle.h:321
FTFont * font
FTGL container class for all glyphs in the current font, used to measure bounding boxes,...
Definition: FontStyle.h:347
H3DUniquePtr< SFBool > horizontal
The horizontal field indicates whether the text advances horizontally in its major direction (horizon...
Definition: FontStyle.h:253
virtual bool isTopToBottom()
Returns true if the text should be rendered from top to bottom, false otherwise.
Definition: FontStyle.h:187
H3DUniquePtr< SFString > style
The style field specifies a case-sensitive SFString value that may be "PLAIN" (the default) for defau...
Definition: FontStyle.h:310
H3DUniquePtr< SFBool > leftToRight
The leftToRight field indicate direction of text advance in the major (characters within a single str...
Definition: FontStyle.h:281
virtual bool isLeftToRight()
Returns true if the text should be rendered from left to right, false otherwise.
Definition: FontStyle.h:193
H3DUniquePtr< MFString > family
The family field contains a case-sensitive MFString value that specifies a sequence of font family na...
Definition: FontStyle.h:244
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: FontStyle.h:342
H3DUniquePtr< SFInt32 > faceSize
The faceSize field specifies the size of character faces in points, where each point is 1/72 of an in...
Definition: FontStyle.h:339
virtual H3DFloat getSpacing()
Returns the spacing between lines of text.
Definition: FontStyle.h:199
H3DUniquePtr< SFFloat > spacing
The spacing field determines the line spacing between adjacent lines of text.
Definition: FontStyle.h:299
virtual Alignment getAlignment()
Gets the alignment of the text.
Definition: FontStyle.h:204
H3DUniquePtr< MFString > justify
The justify field determines alignment of the above text layout relative to the origin of the object ...
Definition: FontStyle.h:263
This abstract node type is the base node type for all FontStyle nodes.
Definition: X3DFontStyleNode.h:41
Alignment
Enumeration of the alignments allowed for text.
Definition: X3DFontStyleNode.h:45
float H3DFloat
H3D_VALUE_EXCEPTION(string, InvalidType)
An exception thrown when a field is of the wrong type when it is checked.
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194