| 481 | #ifndef DISABLE_TTF |
| 482 | |
| 483 | static void drawStringRawTTF(RenderTarget& rt, std::string_view text, TextDrawInfo& info) |
| 484 | { |
| 485 | if (!TTFInitialise()) |
| 486 | return; |
| 487 | |
| 488 | TTFFontDescriptor* fontDesc = TTFGetFontFromSpriteBase(info.fontStyle); |
| 489 | if (fontDesc->font == nullptr) |
| 490 | { |
| 491 | drawStringRawSprite(rt, text, info); |
| 492 | return; |
| 493 | } |
| 494 | |
| 495 | if (info.textDrawFlags.has(TextDrawFlag::noDraw)) |
| 496 | { |
| 497 | info.current.x += TTFGetWidthCacheGetOrAdd(fontDesc->font, text); |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | TTFSurface* surface = TTFSurfaceCacheGetOrAdd(fontDesc->font, text); |
| 502 | if (surface == nullptr) |
| 503 | return; |
| 504 | |
| 505 | auto drawingEngine = rt.DrawingEngine; |
| 506 | if (drawingEngine != nullptr) |
| 507 | { |
| 508 | int32_t drawX = info.current.x + fontDesc->offset_x; |
| 509 | int32_t drawY = info.current.y + fontDesc->offset_y; |
| 510 | uint8_t hintThresh = Config::Get().fonts.enableHinting ? fontDesc->hinting_threshold : 0; |
| 511 | IDrawingContext* dc = drawingEngine->GetDrawingContext(); |
| 512 | dc->DrawTTFBitmap(rt, info, surface, drawX, drawY, hintThresh); |
| 513 | } |
| 514 | info.current.x += surface->w; |
| 515 | } |
| 516 | |
| 517 | #endif // DISABLE_TTF |
| 518 |
no test coverage detected