VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtTextLayout.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2021 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
14 #include <vrvUtil/DtUnicode.h>
15 
16 struct hb_buffer_t;
17 struct hb_font_t;
18 struct hb_glyph_position_t;
19 struct hb_glyph_info_t;
20 
21 namespace makVrv
22 {
23  class DtFreeTypeFace;
24  class DtBoundingBox;
25 
29  {
30  public:
32  {
33  public:
36 
38  virtual ~HarfBuzzShaper();
39 
41  void setFont(const DtFontSP& f);
42 
44  void layoutText(const DtUnicode& string);
45 
47  hb_glyph_position_t *getGlyphPositions(unsigned int* glyph_count) const;
48 
50  hb_glyph_info_t* getGlyphInfos(unsigned int* glyph_count) const;
51 
52  protected:
53  hb_font_t* myHarfBuzzFont;
54  hb_buffer_t *myHarfBuzzBuffer;
55  };
56 
57  public:
59  DtTextLayout();
60 
62  virtual ~DtTextLayout();
63 
66  const DtTextLayout &other) = delete;
67 
69  DtTextLayout &operator=(
70  const DtTextLayout &other) = delete;
71 
73  virtual void renderText(DtTexturedGlyphRenderer*, const DtTextProxy*, DtFontSP, const DtBoundingBox&);
74 
76  virtual DtUnicode bidiFix(const DtUnicode&) const;
77 
79  virtual Dt2dPoint calculateGlyphSize(const DtFontSP& font, const DtPen& pen,
80  const DtUnicode& string, unsigned int pos = 0, int len = -1) const;
81 
83  virtual DtBoundingBox calculateBoundingBox(const DtFontSP& font, const DtPen& pen,
84  const DtUnicode& string, unsigned int pos = 0, int len = -1) const;
85 
86  virtual bool isShaped(void) const{ return true; }
87 
88  virtual void layoutRightToLeft(const DtTextProxy*, DtFontSP, const DtBoundingBox&);
89  virtual void layoutLeftToRight(const DtTextProxy*, DtFontSP, const DtBoundingBox&);
90 
91  protected:
93  virtual bool renderCharacter(DtGlyphRenderer& renderer,
94  DtPen& pen, const DtFontSP& font, const unsigned int& character);
95 
97  virtual void renderLayout(DtTexturedGlyphRenderer*, const DtTextProxy*, DtFontSP, const DtBoundingBox&);
98 
99  protected:
101 
104  std::vector<std::string> myFontFilePaths;
105  unsigned int myPointSize;
108 
111  {
112  CharacterInformation() : advance(0.0f), offset(0.0f), glyphIndex(0), changeColor(false), glyphDefined(true)
113  {
114  color[0] = color[1] = color[2] = color[3] = 1.0;
115  };
117  advance(orig.advance), offset(orig.offset), glyphIndex(orig.glyphIndex), changeColor(orig.changeColor),
118  glyphDefined(orig.glyphDefined) { memcpy(color, orig.color, sizeof(color)); };
119 
120  float color[4];
123  unsigned short glyphIndex;
126  };
127 
131  {
132  LineInformation() : margin(0.0f), alignment(0) {}
134  margin(orig.margin), alignment(orig.alignment), characters(orig.characters) {};
135 
136  float margin;
137  unsigned int alignment;
138  std::vector<CharacterInformation> characters;
139  };
140 
141  typedef std::vector<LineInformation> Lines;
143 
144  double myLineLength;
146  };
147 }
Generic base class for text layout renderers.
Definition: DtTextLayoutInterface.h:24
virtual bool isShaped(void) const
Definition: DtTextLayout.h:86
A unicode string. DtUnicode stores a UTF-16 encoded unicode string. Code Point, a Unicode character...
Definition: DtUnicode.h:33
std::vector< std::string > myFontFilePaths
Members that are used to store information about the last font/point size used. Used for efficiency...
Definition: DtTextLayout.h:104
std::vector< LineInformation > Lines
Definition: DtTextLayout.h:141
unsigned short glyphIndex
Definition: DtTextLayout.h:123
hb_font_t * myHarfBuzzFont
Definition: DtTextLayout.h:53
A 2D point.
Definition: DtBoundingBox.h:19
Contains the makVrv::DtTextLayoutInterface class declaration.
bool glyphDefined
Definition: DtTextLayout.h:125
A glyph renderer which renders the texture associated with a glyph.
Definition: DtTexturedGlyphRenderer.h:25
A class for controlling text owned by the TextRenderer.
Definition: DtTextRenderer.h:197
Abstract class for handling glyph rendering.
Definition: DtGlyphRenderer.h:21
unsigned int alignment
Definition: DtTextLayout.h:137
bool changeColor
Definition: DtTextLayout.h:124
LineInformation()
Definition: DtTextLayout.h:132
Lines myLines
Definition: DtTextLayout.h:142
std::vector< CharacterInformation > characters
Definition: DtTextLayout.h:138
float color[4]
Definition: DtTextLayout.h:118
double myLineLength
Definition: DtTextLayout.h:144
DtUnicode myLastStringRendered
Definition: DtTextLayout.h:106
hb_buffer_t * myHarfBuzzBuffer
Definition: DtTextLayout.h:54
Dt2dPoint advance
Definition: DtTextLayout.h:121
#define DT_DLL_VRVGRAPHICS
Contains DLL export macros.
Definition: vrvGraphics.h:19
DtUnicode myRenderedText
Definition: DtTextLayout.h:107
CharacterInformation()
Definition: DtTextLayout.h:112
A class for rendering text objects using harfbuzz layout for right to left and left to right text sha...
Definition: DtTextLayout.h:28
Structure that contains information about the layout of a line of text. The margin is measure from th...
Definition: DtTextLayout.h:130
Dt2dPoint offset
Definition: DtTextLayout.h:122
HarfBuzzShaper myShaper
Definition: DtTextLayout.h:100
boost::shared_ptr< DtFont > DtFontSP
Definition: DtFontManager.h:20
A pen object with parameters on how to draw text.
Definition: DtBoundingBox.h:80
unsigned int myPointSize
Definition: DtTextLayout.h:105
bool myRightToLeftLayout
Definition: DtTextLayout.h:145
Definition: DtTextLayout.h:31
CharacterInformation(const CharacterInformation &orig)
Definition: DtTextLayout.h:116
voidpf uLong offset
Definition: ioapi.h:42
LineInformation(const LineInformation &orig)
Definition: DtTextLayout.h:133
A simple bounding box.
Definition: DtBoundingBox.h:101
Stucture that contains information about a particular character, color change or simple line/characte...
Definition: DtTextLayout.h:110

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)