| 339 | } |
| 340 | |
| 341 | void TextPainter::applyCommands(StringView unsplitCommands) { |
| 342 | unsplitCommands.forEachSplitView(",", [&](StringView command, size_t, size_t) { |
| 343 | try { |
| 344 | if (command == "reset") { |
| 345 | m_renderSettings = m_savedRenderSettings; |
| 346 | m_fontTextureGroup.switchFont(m_renderSettings.font); |
| 347 | } else if (command == "set") { |
| 348 | m_savedRenderSettings = m_renderSettings; |
| 349 | } else if (command.beginsWith("shadow")) { |
| 350 | if (command.utf8Size() == 6) |
| 351 | m_renderSettings.shadow = Color::Black.toRgba(); |
| 352 | else if (command.utf8()[6] == '=') |
| 353 | m_renderSettings.shadow = Color(command.substr(7)).toRgba(); |
| 354 | } else if (command == "noshadow") { |
| 355 | m_renderSettings.shadow = Color::Clear.toRgba(); |
| 356 | } else if (command.beginsWith("font=")) { |
| 357 | setFont(m_renderSettings.font = command.substr(5)); |
| 358 | } else if (command.beginsWith("directives=")) { |
| 359 | setProcessingDirectives(command.substr(11)); |
| 360 | } else if (command.beginsWith("backdirectives=")) { |
| 361 | setProcessingDirectives(command.substr(15), true); |
| 362 | } else { |
| 363 | // expects both #... sequences and plain old color names. |
| 364 | Color c = Color(command); |
| 365 | c.setAlphaF(c.alphaF() * ((float)m_savedRenderSettings.color[3]) / 255); |
| 366 | m_renderSettings.color = c.toRgba(); |
| 367 | } |
| 368 | } catch (JsonException&) { |
| 369 | } catch (ColorException&) { |
| 370 | } |
| 371 | }); |
| 372 | } |
| 373 | |
| 374 | void TextPainter::modifyDirectives(Directives& directives) { |
| 375 | if (directives) { |
nothing calls this directly
no test coverage detected