mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
Add ui::Graphics::drawTextBlob() function
This commit is contained in:
parent
1e56e7da5a
commit
c586ac5b14
@ -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 {
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user