Class SoTextProperty
- All Implemented Interfaces:
SafeDisposable
The application can specify text alignment and orientation using the alignmentH
, alignmentV
, and orientation
fields.
Note:
Horizontal alignment can also be specified in some text nodes, for example SoText2
and SoText3
, using the
justification field. The value in the text node's field is used unless that field is explicitly set to INHERIT. To allow SoTextProperty
to control horizontal justification, set the text node's justification field to INHERITED.
The application can also request use of font kerning using the kerning
field. Kerning consists of modifying the spacing between two successive glyphs according to their outlines. For examples, a "T" and a "y" can be moved closer together as the top of the "y" fits nicely under the upper right bar of the "T". Kerning depends on the specific font being used.
Different text rendering styles such as underline, strikethrough and background rectangle can be specified using the style
field. A color can be specified for each style using the styleColors
field. The current material does not affect the color of a text rendering style unless the corresponding value in the styleColorsUseCurrentMaterial
field is set to true. Text rendering styles apply to the entire string.
Text rendering effects |
![]() |
- Underline/overline/strike always has the same position relative to the text string, regardless of the vertical justification setting.
- The underline/overline/strike position is determined by the font and the results should be similar to what you see in other applications using the same font (e.g. MS-Word on Windows). For some fonts the underline will intersect character descenders, for example on the lower case 'g'. For some fonts the overline will intersect the top portion of some characters.
- When using BACK_FRAME and BACK_FRAME_LINE you will usually want to set the margin field to a small value, for example 0.05.
- Color can be specified separately for each style. However underline and overline are often intended to be the same color as the text. It can be convenient to set the styleColorsUseCurrentMaterial field so that the current
SoMaterial
controls both the text and the lines. - Note that the color for each style is an RGBA value, allowing transparency to be applied. This is particularly useful for the BACK_FRAME attribute so the text background rectangle can be semi-transparent.
- As backFrameLineWidth is increased, the width of the line expands outward, away from the string (the backframe box stays the same size).
- Be sure to use the values in the StyleColor enum to set colors and inheritance flags, not the values in the Style enum. For example, use UNDERLINE_COLOR, not UNDERLINE. Open Inventor will not report an error, but the desired effect will not occur.
File format/default:
TextProperty {
aliasingFactor | 1.0 |
alignmentH | LEFT |
alignmentV | BASE |
backFrameLineWidth | 0.0 |
kerning | false |
margin | 0.0 |
orientation | LEFT_TO_RIGHT |
textureQualityRange | 150 300 |
style | NONE |
styleColors | 0.8 0.8 0.8 1 |
styleColorsUseCurrentMaterial | false |
Action behavior:
Sets: SoTextAlignmentHElement
, SoTextAlignmentVElement
, SoTextBackFrameLineWidthElement
, SoTextOrientationElement
, SoTextKerningElement
, SoTextMarginElement
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Possible horizontal alignment values.static enum
Possible vertical alignment values.static enum
Possible text orientation values.static enum
Index values for setting colors in thestyleColors
field.static enum
TextProperty style values.Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal SoSFFloat
Defines the anti-aliasing factor to apply to the textured text rendering.Indicates horizontal placement and alignment of strings.Indicates vertical placement and alignment of strings.final SoSFFloat
Defines the width of the line when BACK_FRAME_LINE has been enabled for the current style.final SoSFFloat
This field specifies the spacing between individual characters.final SoSFBool
Set this field to true to apply kerning on text rendering.final SoSFFloat
Set a margin (extra space) to apply around the text string for the BACK_FRAME and BACK_FRAME_LINE styles.Specifies the text rendering orientation.final SoSFBitMask
<SoTextProperty.Styles> Specifies zero or more styles to be applied to text.final SoMFColorRGBA
Specifies the color to use for each style.final SoMFBool
This field allows to use the currentSoMaterial
instead of the value specified bystyleColors
for each available style (default gray).final SoSFVec2i32
Defines a quality range of values taken into account during textured text texture computation.Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
Field Details
-
aliasingFactor
Defines the anti-aliasing factor to apply to the textured text rendering. Default is 1.0. Default value can be changed using the environment variable OIV_TEXT_ALIASING_FACTOR.The anti-aliasing applied transfer functions are:
- if aliasingFactor <= 1.0 => Max( (v + f - 1) / f , 0.0)
- if aliasingFactor > 1.0 => Min( (v * f) , 1.0)
A value of 0 essentially turns off antialiasing. Only pixels that are full opacity will be rendered. Value 1 is the native antialiasing provided by the FreeType library. Values < 1 scale down the opacity of semi-transparent pixels, so lower opacity pixels become completely transparent, effectively making the character glyphs sharper but narrower. Values > 1 scale up the opacity of semi-transparent pixels, effectively making the characters sharper but wider. Values greater than 5 have little additional visual effect.
-
alignmentH
Indicates horizontal placement and alignment of strings. Use theAlignmentH
enum. Default value is LEFT. With LEFT alignment, the left edge of the first line is at the (transformed) origin, and all left edges are aligned. RIGHT alignment is similar. CENTER alignment places the center of the first string at the (transformed) origin, with the centers of all remaining strings aligned under it. Default value can be changed using the environment variable OIV_TEXT_ALIGNMENTH.Note: This field is only effective when the justification field of a text node is set to INHERITED. When orientation is vertical, horizontal alignment is only applied on the first line.
-
alignmentV
Indicates vertical placement and alignment of strings. Use theAlignmentV
enum. Default is BASE. With TOP alignment, the top edge of the first line is at the (transformed) origin, and all top edges are aligned. BOTTOM alignment is similar. HALF alignment places the center of the first string at the (transformed) origin, with the centers of all remaining strings aligned under it. Default value can be changed using the environment variable OIV_TEXT_ALIGNMENTV. When orientation is horizontal, vertical alignment is only applied on the first line. -
backFrameLineWidth
Defines the width of the line when BACK_FRAME_LINE has been enabled for the current style. The backFrameLineWidth value is pixel size forSoText2
text, and is a 1/40 of the current font size forSoText3
text. Default value is 1.0 Default value can be changed using the environment variable OIV_TEXT_BACKFRAMELINE_WIDTH.- Since:
- Open Inventor 9.2
-
kerning
Set this field to true to apply kerning on text rendering. For more information about kerning, refer to the FreeType documentation located at http://freetype.org/freetype2/docs/glyphs/glyphs-4.html Default value is false. -
orientation
Specifies the text rendering orientation. Use theOrientation
enum. Default is LEFT_TO_RIGHT. Default value can be changed using the environment variable OIV_TEXT_ORIENTATION. -
textureQualityRange
Defines a quality range of values taken into account during textured text texture computation. The size of the generated textures depends on this range, expressed in terms of DPI, and depends on theSoComplexity.value
. Default is 150 to 300. Default range values can be changed using the environment variables OIV_MIN_TEXTURED_FONT_RES and OIV_MAX_TEXTURED_FONT_RES.- Since:
- Open Inventor 8.1
-
style
Specifies zero or more styles to be applied to text. Use theStyle
enum. Default is NONE.Note: UNDERLINE, STRIKETHROUGH and DOUBLE_STRIKETHROUGH are not implemented for vertical oriented text ( ie:
Orientation
set to TOP_TO_BOTTOM or BOTTOM_TO_TOP).- Since:
- Open Inventor 8.1
-
styleColors
Specifies the color to use for each style.
Use the index values defined in theStyleColor
enum (NOT theStyle
enum) to assign the color to the desired style. For example, assign opaque red to the underline color.// Note the set1Value method expects an "int" as its first parameter SoTextProperty node = new SoTextProperty(); node.styleColors.set1Value( SoTextProperty.StyleColorType.UNDERLINE_COLOR.getValue(), new SbColorRGBA(1, 0, 0, 1) ); - Since:
- Open Inventor 8.1
-
margin
Set a margin (extra space) to apply around the text string for the BACK_FRAME and BACK_FRAME_LINE styles. The margin value is specified as a fraction of the font size. Default value is 0.0. Default value can be changed using the environment variable OIV_TEXT_MARGIN.- Since:
- Open Inventor 8.1
-
styleColorsUseCurrentMaterial
This field allows to use the currentSoMaterial
instead of the value specified bystyleColors
for each available style (default gray). For example, if the entry corresponding to UNDERLINE_COLOR is set to true, underline will be rendered using the color inherited fromSoMaterial
. This is convenient if (as usual) the underline should be the same color as the text. Use the index values defined in theStyleColor
enum (NOT theStyle
enum) to set the value for the desired style (see example code forstyleColors
field).- Since:
- Open Inventor 9.4
-
characterSpacing
This field specifies the spacing between individual characters. The value is in font size units for 2D text (SoText2
) and 3D text (SoText3
). Default is 0.- 0 means no extra space with respect to the standard spacing defined in the font.
- A positive value is added to the default spacing (it is not relative or proportional).
- Negative values are ignored.
-
-
Constructor Details
-
SoTextProperty
public SoTextProperty()Text property constructor.
-