diff --git a/src/ui/graphics.cpp b/src/ui/graphics.cpp index e27043da1..220618302 100644 --- a/src/ui/graphics.cpp +++ b/src/ui/graphics.cpp @@ -28,6 +28,7 @@ #include "text/font.h" #include "text/font_metrics.h" #include "text/shaper_features.h" +#include "text/text_blob.h" #include "ui/display.h" #include "ui/scale.h" #include "ui/theme.h" @@ -356,6 +357,25 @@ void Graphics::drawText(const std::string& str, dirty(gfx::Rect(pt.x, pt.y, textBounds.w, textBounds.h)); } +void Graphics::drawTextBlob(const text::TextBlobRef& textBlob, + const gfx::PointF& pt0, + const Paint& paint) +{ + ASSERT(m_font); + if (!textBlob) + return; + + gfx::PointF pt(m_dx+pt0.x, m_dy+pt0.y); + + os::SurfaceLock lock(m_surface.get()); + gfx::RectF textBounds = textBlob->bounds(); + + text::draw_text(m_surface.get(), textBlob, pt, &paint); + + textBounds.offset(pt); + dirty(textBounds); +} + namespace { class DrawUITextDelegate : public text::DrawTextDelegate { diff --git a/src/ui/graphics.h b/src/ui/graphics.h index 80a589f40..8b6832604 100644 --- a/src/ui/graphics.h +++ b/src/ui/graphics.h @@ -111,6 +111,10 @@ namespace ui { text::DrawTextDelegate* delegate = nullptr, text::ShaperFeatures features = {}); + void drawTextBlob(const text::TextBlobRef& textBlob, + const gfx::PointF& pt, + const Paint& paint); + void drawUIText(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Point& pt, const int mnemonic); void drawAlignedUIText(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, const int align);