H3D API  2.4.1
X3DFontStyleNode.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 __X3DFONTSTYLENODE_H__
30 #define __X3DFONTSTYLENODE_H__
31 
32 #include <H3D/X3DNode.h>
33 #include "GL/glew.h"
34 
35 namespace H3D {
36 
41  class H3DAPI_API X3DFontStyleNode : public X3DNode {
42  public:
43 
45  typedef enum {
46  HORIZONTAL,
47  VERTICAL
48  } Alignment;
49 
51  typedef enum {
52  FIRST,
53  BEGIN,
54  MIDDLE,
55  END
56  } Justification;
57 
59  X3DFontStyleNode( Inst< SFNode> _metadata = 0 );
60 
65  virtual void buildFonts() {}
66 
68  inline bool fontsBuilt() {
69  return fonts_built;
70  }
71 
74  virtual bool isTopToBottom() {
75  return true;
76  }
77 
80  virtual bool isLeftToRight() {
81  return true;
82  }
83 
86  virtual H3DFloat getSpacing() {
87  return 1;
88  }
89 
91  virtual Alignment getAlignment() {
92  return HORIZONTAL;
93  }
94 
97  return BEGIN;
98  }
99 
102  return FIRST;
103  }
104 
106  virtual void renderChar( unsigned char ) {}
107 
109  virtual void renderHorizontalLine( const std::string& ) {}
110 
113  virtual Vec3f charDimensions( unsigned char ) { return Vec3f(); }
114 
117  virtual H3DFloat ascender() { return 0; }
118 
121  virtual H3DFloat descender() { return 0; }
122 
126  Vec3f stringDimensions( const std::string& text,
127  Alignment alignment );
128 
135  Vec3f stringDimensions( const std::vector< std::string >& text,
136  Alignment alignment,
137  const std::vector< H3DFloat >& length =
138  std::vector< H3DFloat >() );
139 
143  virtual std::string defaultXMLContainerField() {
144  return "fontStyle";
145  }
146 
147 protected:
150  };
151 }
152 
153 #endif
Header file for X3DNode, X3D scene-graph node.
This abstract node type is the base node type for all FontStyle nodes.
Definition: X3DFontStyleNode.h:41
virtual Justification getMinorJustification()
Gets the justification of the text in the minor alignment direction.
Definition: X3DFontStyleNode.h:101
virtual bool isTopToBottom()
Returns true if the text should be rendered from top to bottom, false otherwise.
Definition: X3DFontStyleNode.h:74
virtual H3DFloat getSpacing()
Returns the spacing between lines of text.
Definition: X3DFontStyleNode.h:86
virtual H3DFloat descender()
Returns how many metres in the the negative y-direction from the origin the characters of this font u...
Definition: X3DFontStyleNode.h:121
bool fonts_built
True if buildFonts has been called.
Definition: X3DFontStyleNode.h:149
virtual void buildFonts()
Build Character instances for all characters that will be allowed for use by this font node.
Definition: X3DFontStyleNode.h:65
virtual H3DFloat ascender()
Returns how many metres in the the positive y-direction from the origin the characters of this font u...
Definition: X3DFontStyleNode.h:117
bool fontsBuilt()
Returns true if buildFonts has been called, false otherwise.
Definition: X3DFontStyleNode.h:68
virtual bool isLeftToRight()
Returns true if the text should be rendered from left to right, false otherwise.
Definition: X3DFontStyleNode.h:80
virtual Vec3f charDimensions(unsigned char)
Get the dimensions in metres of the character given when rendered with this font.
Definition: X3DFontStyleNode.h:113
Justification
Enumeration for the different justification values allowed.
Definition: X3DFontStyleNode.h:51
virtual Justification getMajorJustification()
Gets the justification of the text in the major alignment direction.
Definition: X3DFontStyleNode.h:96
virtual Alignment getAlignment()
Gets the alignment of the text.
Definition: X3DFontStyleNode.h:91
virtual void renderChar(unsigned char)
Render the given character with this font.
Definition: X3DFontStyleNode.h:106
Alignment
Enumeration of the alignments allowed for text.
Definition: X3DFontStyleNode.h:45
virtual void renderHorizontalLine(const std::string &)
Render the given string with this font from left to right horizontally.
Definition: X3DFontStyleNode.h:109
This abstract node type is the base type for all nodes in the X3D system.
Definition: X3DNode.h:65
H3DDouble length() const
float H3DFloat
H3D API namespace.
Definition: Anchor.h:38