| 462 | } |
| 463 | |
| 464 | void preProcessGlyph(const sf::Text::ShapedGlyph& shapedGlyph, |
| 465 | std::uint32_t& style, |
| 466 | sf::Color& fillColor, |
| 467 | sf::Color& outlineColor, |
| 468 | float& outlineThickness) |
| 469 | { |
| 470 | switch (preProcessingMode) |
| 471 | { |
| 472 | case PreProcessingMode::None: |
| 473 | break; |
| 474 | case PreProcessingMode::Color: |
| 475 | if (colorDirection) |
| 476 | { |
| 477 | // Color based on shaped glyph direction |
| 478 | fillColor = (shapedGlyph.textDirection == sf::Text::TextDirection::RightToLeft) |
| 479 | ? sf::Color(127, 255, 127) |
| 480 | : sf::Color(255, 255, 127); |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | // Color each word a different color |
| 485 | fillColor = effectData[shapedGlyph.cluster].color; |
| 486 | } |
| 487 | break; |
| 488 | case PreProcessingMode::Outline: |
| 489 | // Outline alternating words |
| 490 | if (effectData[shapedGlyph.cluster].outline) |
| 491 | { |
| 492 | outlineColor = sf::Color::Magenta; |
| 493 | outlineThickness = 1.0f; |
| 494 | } |
| 495 | break; |
| 496 | case PreProcessingMode::Italicize: |
| 497 | // Italicize alternating sentences |
| 498 | if (effectData[shapedGlyph.cluster].italicize) |
| 499 | style |= sf::Text::Italic; |
| 500 | break; |
| 501 | case PreProcessingMode::Embolden: |
| 502 | // Embolden alternating sentences |
| 503 | if (effectData[shapedGlyph.cluster].embolden) |
| 504 | style |= sf::Text::Bold; |
| 505 | break; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | void cyclePreProcessing() |
| 510 | { |