comparison Core/Images/Font.cpp @ 2901:93c65e3a6bb1

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Oct 2018 16:12:59 +0200
parents 668d5ad73c74
children 058851941abe
comparison
equal deleted inserted replaced
2900:668d5ad73c74 2901:93c65e3a6bb1
352 std::string s = Toolbox::ConvertToAscii(utf8); 352 std::string s = Toolbox::ConvertToAscii(utf8);
353 #endif 353 #endif
354 354
355 // Compute the text extent 355 // Compute the text extent
356 unsigned int x = 0; 356 unsigned int x = 0;
357 unsigned int countLines = 0; 357 unsigned int y = 0;
358 358
359 for (size_t i = 0; i < s.size(); i++) 359 for (size_t i = 0; i < s.size(); i++)
360 { 360 {
361 if (s[i] == '\n') 361 if (s[i] == '\n')
362 { 362 {
363 // Go to the next line 363 // Go to the next line
364 x = 0; 364 x = 0;
365 365 y += (maxHeight_ + 1);
366 countLines ++;
367 } 366 }
368 else 367 else
369 { 368 {
370 Characters::const_iterator c = characters_.find(s[i]); 369 Characters::const_iterator c = characters_.find(s[i]);
371 if (c != characters_.end()) 370 if (c != characters_.end())
372 { 371 {
373 x += c->second->advance_; 372 x += c->second->advance_;
374 373
375 if (countLines == 0) 374 unsigned int bottom = y + c->second->top_ + c->second->height_;
375 if (bottom > height)
376 { 376 {
377 countLines = 1; 377 height = bottom;
378 } 378 }
379 379
380 if (x > width) 380 if (x > width)
381 { 381 {
382 width = x; 382 width = x;
383 } 383 }
384 } 384 }
385 } 385 }
386 } 386 }
387
388 height = countLines * (maxHeight_ + 1);
389 } 387 }
390 388
391 389
392 ImageAccessor* Font::Render(const std::string& utf8, 390 ImageAccessor* Font::Render(const std::string& utf8,
393 PixelFormat format, 391 PixelFormat format,