H3D API
2.4.1
|
The FontStyle node defines the size, family, and style used for Text nodes, as well as the direction of the text strings and any language-specific rendering techniques used for non-English text. More...
#include <H3D/FontStyle.h>
Classes | |
class | InvalidFontStyleJustify |
Thrown when the strings in the justify field are invalid values. More... | |
class | InvalidFontStyleRenderType |
Thrown when the strings in the renderType field are invalid values. More... | |
class | InvalidFontStyleStyle |
Thrown when the string in the style field is an invalid value. More... | |
Public Member Functions | |
FontStyle (Inst< SFNode > _metadata=0, Inst< MFString > _family=0, Inst< SFBool > _horizontal=0, Inst< MFString > _justify=0, Inst< SFString > _language=0, Inst< SFBool > _leftToRight=0, Inst< SFFloat > _size=0, Inst< SFFloat > _spacing=0, Inst< SFString > _style=0, Inst< SFBool > _topToBottom=0, Inst< SFString > _renderType=0, Inst< SFInt32 > _faceSize=0) | |
Constructor. | |
virtual void | buildFonts () |
Build Character instances for all characters that will be allowed for use by this font node. More... | |
virtual bool | isTopToBottom () |
Returns true if the text should be rendered from top to bottom, false otherwise. | |
virtual bool | isLeftToRight () |
Returns true if the text should be rendered from left to right, false otherwise. | |
virtual H3DFloat | getSpacing () |
Returns the spacing between lines of text. More... | |
virtual Alignment | getAlignment () |
Gets the alignment of the text. | |
virtual void | renderChar (unsigned char c) |
Render the character. | |
virtual void | renderHorizontalLine (const std::string &c) |
Render the given string with this font from left to right horizontally. | |
virtual H3DFloat | ascender () |
Returns how many metres in the the positive y-direction from the origin the characters of this font use. More... | |
virtual H3DFloat | descender () |
Returns how many metres in the the negative y-direction from the origin the characters of this font use. More... | |
virtual Vec3f | charDimensions (unsigned char c) |
Get the bounding box dimensions of the 3d-representation of the given character. | |
virtual Justification | getMajorJustification () |
Gets the justification of the text in the major alignment direction. | |
virtual Justification | getMinorJustification () |
Gets the justification of the text in the minor alignment direction. | |
![]() | |
X3DFontStyleNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
bool | fontsBuilt () |
Returns true if buildFonts has been called, false otherwise. | |
Vec3f | stringDimensions (const std::string &text, Alignment alignment) |
Given a text string and an alignment of the text the function returns the dimensions of the bounding box of the 3d representation of the text using this font. | |
Vec3f | stringDimensions (const std::vector< std::string > &text, Alignment alignment, const std::vector< H3DFloat > &length=std::vector< H3DFloat >()) |
Given a vector of text string and an alignment of the text the function returns the dimensions of the bounding box of the 3d representation of the text using this font. More... | |
virtual std::string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL) |
Returns a new instance of this node type with the same state as this one. More... | |
virtual | ~Node () |
Destructor. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More... | |
void | setProtoInstanceParent (X3DPrototypeInstance *p) |
Set the X3DPrototypeInstance this node is the the root node if applicaple. | |
virtual void | render () |
the render() function is used for the depth-first rendering traversal of the scene-graph. More... | |
virtual void | traverseSG (TraverseInfo &ti) |
traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More... | |
virtual bool | lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result) |
Detect intersection between a line segment and the Node. More... | |
virtual void | closestPoint (const Vec3f &p, NodeIntersectResult &result) |
Find closest point on Node to p. More... | |
virtual bool | movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result) |
Detect collision between a moving sphere and the Node. More... | |
virtual Field * | getField (const string &_name) const |
return a pointer to the field specified by name within this instance | |
int | addDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
int | removeDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
Public Attributes | |
H3DUniquePtr< MFString > | family |
The family field contains a case-sensitive MFString value that specifies a sequence of font family names in preference order. More... | |
H3DUniquePtr< SFBool > | horizontal |
The horizontal field indicates whether the text advances horizontally in its major direction (horizontal = TRUE, the default) or vertically in its major direction (horizontal = FALSE). More... | |
H3DUniquePtr< MFString > | justify |
The justify field determines alignment of the above text layout relative to the origin of the object coordinate system. More... | |
H3DUniquePtr< SFString > | language |
The language field specifies the context of the language for the text string in the form of a language and a country in which that language is used. More... | |
H3DUniquePtr< SFBool > | leftToRight |
The leftToRight field indicate direction of text advance in the major (characters within a single string) or minor (successive strings) axes of layout depending on the value of the horizontal field. More... | |
H3DUniquePtr< SFFloat > | size |
The size field specifies the nominal height, in the local coordinate system of the Text node, of glyphs rendered and determines the spacing of adjacent lines of text. More... | |
H3DUniquePtr< SFFloat > | spacing |
The spacing field determines the line spacing between adjacent lines of text. More... | |
H3DUniquePtr< SFString > | style |
The style field specifies a case-sensitive SFString value that may be "PLAIN" (the default) for default plain type; "BOLD" for boldface type; "ITALIC" for italic type; or "BOLDITALIC" for bold and italic type. More... | |
H3DUniquePtr< SFBool > | topToBottom |
The topToBottom field indicate direction of text advance in the major (characters within a single string) or minor (successive strings) axes of layout depending on the value of the horizontal field. More... | |
H3DUniquePtr< SFString > | renderType |
The renderType field is H3D API specific and specifies which way the font will be rendered. More... | |
H3DUniquePtr< SFInt32 > | faceSize |
The faceSize field specifies the size of character faces in points, where each point is 1/72 of an inch. More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Protected Attributes | |
FTFont * | font |
FTGL container class for all glyphs in the current font, used to measure bounding boxes, render, advance, etc. | |
![]() | |
bool | fonts_built |
True if buildFonts has been called. | |
Additional Inherited Members | |
![]() | |
enum | Alignment |
Enumeration of the alignments allowed for text. | |
enum | Justification |
Enumeration for the different justification values allowed. | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
static unsigned int | nrNodesAlive () |
Returns the nr of nodes currently alive, i.e. nodes created but not destructed. | |
static int | nrNodesCreated () |
Returns the number of nodes created in total since the start of the program. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
The FontStyle node defines the size, family, and style used for Text nodes, as well as the direction of the text strings and any language-specific rendering techniques used for non-English text.
See Text for a description of the Text node.
The size field specifies the nominal height, in the local coordinate system of the Text node, of glyphs rendered and determines the spacing of adjacent lines of text. Values of the size field shall be greater than zero.
The spacing field determines the line spacing between adjacent lines of text. The distance between the baseline of each line of text is (spacing × size) in the appropriate direction (depending on other fields described below).
The family field contains a case-sensitive MFString value that specifies a sequence of font family names in preference order. The MFString value is searched for the first font family name matching a supported font family. If none of the string values matches a supported font family, the default font family "SERIF" shall be used. "SERIF" (the default) for a serif font such as Times Roman; "SANS" for a sans-serif font such as Helvetica; and "TYPEWRITER" for a fixed-pitch font such as Courier. An empty family value is identical to ["SERIF"]. Any font family may be specified as shown in the following example of the specification of a font family:
In this example, the browser would first look for the font family "Lucida Sans Typewriter" on the system on which the browser is operating. If that is not available, the browser looks for "Lucida Sans". If that is not available, the browser looks for "Helvetica". If that is not available, the browser looks for any sans-serif font. If there are not sans-serif fonts installed, the browser will use any serif font (the default). It is the responsibility of the author that a suitable list of font families be specified so that the desired appearance is achieved in most operating environments. However, the author should always be willing to accept that the requested font families may not be available resulting in the use of a browser-selected "SERIF" font being used.
The style field specifies a case-sensitive SFString value that may be "PLAIN" (the default) for default plain type; "BOLD" for boldface type; "ITALIC" for italic type; or "BOLDITALIC" for bold and italic type. An empty style value ("") is identical to "PLAIN".
The horizontal, leftToRight, and topToBottom fields indicate the direction of the text. The horizontal field indicates whether the text advances horizontally in its major direction (horizontal = TRUE, the default) or vertically in its major direction (horizontal = FALSE). The leftToRight and topToBottom fields indicate direction of text advance in the major (characters within a single string) and minor (successive strings) axes of layout. Which field is used for the major direction and which is used for the minor direction is determined by the horizontal field. Note that the direction specification overrides any modes inherent in a particular language.
For horizontal text (horizontal = TRUE), characters on each line of text advance in the positive X direction if leftToRight is TRUE or in the negative X direction if leftToRight is FALSE. Characters are advanced according to their natural advance width. Each line of characters is advanced in the negative Y direction if topToBottom is TRUE or in the positive Y direction if topToBottom is FALSE. Lines are advanced by the amount of size × spacing.
For vertical text (horizontal = FALSE), characters on each line of text advance in the negative Y direction if topToBottom is TRUE or in the positive Y direction if topToBottom is FALSE. Characters are advanced according to their natural advance height. Each line of characters is advanced in the positive X direction if leftToRight is TRUE or in the negative X direction if leftToRight is FALSE. Lines are advanced by the amount of size × spacing.
The justify field determines alignment of the above text layout relative to the origin of the object coordinate system. The justify field is an MFString which can contain 2 values. The first value specifies alignment along the major axis and the second value specifies alignment along the minor axis, as determined by the horizontal field. An empty justify value ("") is equivalent to the default value. If the second string, minor alignment, is not specified, minor alignment defaults to the value "FIRST". Thus, justify values of "", "BEGIN", and ["BEGIN" "FIRST"] are equivalent.
The major alignment is along the X-axis when horizontal is TRUE and along the Y-axis when horizontal is FALSE. The minor alignment is along the Y-axis when horizontal is TRUE and along the X-axis when horizontal is FALSE. The possible values for each enumerant of the justify field are "FIRST", "BEGIN", "MIDDLE", and "END". For major alignment, each line of text is positioned individually according to the major alignment enumerant. For minor alignment, the block of text representing all lines together is positioned according to the minor alignment enumerant. The default minor alignment is "FIRST". This is a special case of minor alignment when horizontal is TRUE. Text starts at the baseline at the Y-axis. In all other cases, "FIRST" is identical to "BEGIN".
The language field specifies the context of the language for the text string in the form of a language and a country in which that language is used. This field is not used by H3DApi.
The renderType field is H3D API specific and specifies which way the font will be rendered. Possible values are "TEXTURE", "POLYGON" and "OUTLINE". "TEXTURE" will use texture maps to render the font, "POLYGON" will create a polygon model for each character and render it and "OUTLINE" will render the outlines for each character.
Examples:
|
virtual |
Returns how many metres in the the positive y-direction from the origin the characters of this font use.
Reimplemented from H3D::X3DFontStyleNode.
|
virtual |
Build Character instances for all characters that will be allowed for use by this font node.
For Windows wglUseFontOutlines will be used to generate polygon versions of the characters of the font.
Reimplemented from H3D::X3DFontStyleNode.
References faceSize, and H3D::X3DFontStyleNode::fonts_built.
|
virtual |
Returns how many metres in the the negative y-direction from the origin the characters of this font use.
Reimplemented from H3D::X3DFontStyleNode.
|
inlinevirtual |
Returns the spacing between lines of text.
See FontStyle for more details.
Reimplemented from H3D::X3DFontStyleNode.
H3DUniquePtr< SFInt32 > H3D::FontStyle::faceSize |
The faceSize field specifies the size of character faces in points, where each point is 1/72 of an inch.
The input will be clamped to be within the valid range Access type: initializeOnly
Default value: 72
Value range: [4-72]
Referenced by buildFonts(), and FontStyle().
H3DUniquePtr< MFString > H3D::FontStyle::family |
The family field contains a case-sensitive MFString value that specifies a sequence of font family names in preference order.
See the detailed desription for details.
Access type: initializeOnly
Default value: ["SERIF"]
Referenced by FontStyle().
H3DUniquePtr< SFBool > H3D::FontStyle::horizontal |
The horizontal field indicates whether the text advances horizontally in its major direction (horizontal = TRUE, the default) or vertically in its major direction (horizontal = FALSE).
Access type: initializeOnly
Default value: TRUE
Referenced by FontStyle().
H3DUniquePtr< MFString > H3D::FontStyle::justify |
The justify field determines alignment of the above text layout relative to the origin of the object coordinate system.
See the detailed desription for details.
Access type: initializeOnly
Default value: ["BEGIN"]
Value range: "BEGIN", "FIRST", "MIDDLE" or "END"
Referenced by FontStyle(), getMajorJustification(), and getMinorJustification().
H3DUniquePtr< SFString > H3D::FontStyle::language |
The language field specifies the context of the language for the text string in the form of a language and a country in which that language is used.
This field is not used by H3DApi.
Access type: initializeOnly
H3DUniquePtr< SFBool > H3D::FontStyle::leftToRight |
The leftToRight field indicate direction of text advance in the major (characters within a single string) or minor (successive strings) axes of layout depending on the value of the horizontal field.
See detailed description for details.
Access type: initializeOnly
Default value: TRUE
Referenced by FontStyle().
H3DUniquePtr< SFString > H3D::FontStyle::renderType |
The renderType field is H3D API specific and specifies which way the font will be rendered.
Possible values are "TEXTURE", "POLYGON" and "OUTLINE". "TEXTURE" will use texture maps to render the font, "POLYGON" will create a polygon model for each character and render it and "OUTLINE" will render the outlines for each character. Access type: initializeOnly
Default value: "TEXTURE"
Value range: "TEXTURE", "POLYGON" or "OUTLINE"
Referenced by FontStyle(), and renderChar().
H3DUniquePtr< SFFloat > H3D::FontStyle::size |
The size field specifies the nominal height, in the local coordinate system of the Text node, of glyphs rendered and determines the spacing of adjacent lines of text.
Access type: initializeOnly
Default value: 1
Value range: >0
Referenced by ascender(), charDimensions(), descender(), FontStyle(), and renderChar().
H3DUniquePtr< SFFloat > H3D::FontStyle::spacing |
The spacing field determines the line spacing between adjacent lines of text.
The distance between the baseline of each line of text is (spacing × size) in the appropriate direction.
Access type: initializeOnly
Default value: 1
Value range: >0
Referenced by FontStyle().
H3DUniquePtr< SFString > H3D::FontStyle::style |
The style field specifies a case-sensitive SFString value that may be "PLAIN" (the default) for default plain type; "BOLD" for boldface type; "ITALIC" for italic type; or "BOLDITALIC" for bold and italic type.
An empty style value ("") is identical to "PLAIN".
Access type: initializeOnly
Default value: "PLAIN"
Value range: "PLAIN", "BOLD", "ITALIC" or "BOLDITALIC"
Referenced by FontStyle().
H3DUniquePtr< SFBool > H3D::FontStyle::topToBottom |
The topToBottom field indicate direction of text advance in the major (characters within a single string) or minor (successive strings) axes of layout depending on the value of the horizontal field.
See detailed description for details.
Access type: initializeOnly
Default value: TRUE
Referenced by FontStyle().