Changeset 7757 in orxonox.OLD for trunk/src/lib/graphics/text_engine
- Timestamp:
- May 21, 2006, 11:07:48 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/text_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/multi_line_text.cc
r7756 r7757 26 26 * @param type The renderType to display this font in 27 27 */ 28 MultiLineText::MultiLineText(const std::string& fontFile, unsigned int textSize, unsigned int lineWidth)28 MultiLineText::MultiLineText(const std::string& fontFile, unsigned int textSize, float lineWidth) 29 29 : Text(fontFile, textSize) 30 30 { 31 31 this->setClassID(CL_MULTI_LINE_TEXT, "MultiLineText"); 32 32 33 this->lineSpacing = 1.0 f;33 this->lineSpacing = 1.0; 34 34 this->lineCount = 0; 35 35 this->setLineWidth(lineWidth); … … 93 93 for (unsigned int i = 0; i < this->getText().size(); ++i) 94 94 { 95 if (unlikely( !this->lineEnds.empty()&& i == this->lineEnds[lineNumber]))95 if (unlikely(this->lineEnds.size() > lineNumber && i == this->lineEnds[lineNumber])) 96 96 { 97 97 // go to the next Line. 98 98 ++lineNumber; 99 posX = 0.0f;99 posX = 10.0f; 100 100 posY += this->lineSpacing + this->getSize(); //this->getFont()->getMaxHeight(); 101 101 } … … 149 149 width += this->getFont()->getGlyphArray()[this->getText()[i]]->advance; 150 150 } 151 152 this->lineCount = lineEnds.size()+1; 151 this->lineCount = lineEnds.size() + 1; 153 152 this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->getFont()->getMaxHeight())); 154 153 } 154 155 void MultiLineText::debug() const 156 { 157 printf("Debug %s::%s: %d lines\n", this->getClassName(), this->getName(), this->getLineCount()); 158 159 std::string tmpText = this->getText(); 160 std::vector<unsigned int> ends = this->lineEnds; 161 ends.push_back(tmpText.size()); 162 163 unsigned int prev = 0; 164 for (unsigned int i = 0; i < ends.size(); i++) 165 { 166 printf("Line %d: %s\n", i, tmpText.substr(prev, ends[i] - prev).c_str()); 167 prev = ends[i]; 168 } 169 } -
trunk/src/lib/graphics/text_engine/multi_line_text.h
r7754 r7757 15 15 { 16 16 public: 17 MultiLineText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE, unsigned int lineWidth = 100.0);17 MultiLineText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE, float lineWidth = 100.0); 18 18 19 19 // Setup: … … 30 30 virtual void draw() const; 31 31 32 void debug() const; 33 32 34 protected: 33 35 virtual void setupTextWidth();
Note: See TracChangeset
for help on using the changeset viewer.