Skip to content
Snippets Groups Projects
Commit 94762ad3 authored by Odilitime's avatar Odilitime
Browse files

size() call

parent a807fae0
No related branches found
No related tags found
No related merge requests found
......@@ -285,3 +285,16 @@ void TextComponent::sanitize(std::string &str) {
found++;
}
}
std::unique_ptr<std::pair<int, int>> TextComponent::size() const {
const std::shared_ptr<TextRasterizer> textRasterizer=rasterizerCache->loadFont(fontSize, bold);
rasterizationRequest request;
request.text = text;
// startX needs to be relative to the parent x
request.startX = x;
request.availableWidth = windowWidth;
request.sourceStartX = rasterStartX;
request.sourceStartY = rasterStartY;
request.noWrap = noWrap;
return textRasterizer->size(request);
}
......@@ -30,6 +30,7 @@ public:
void resize(const int passedWindowWidth, const int passedWindowHeight); // compatible adapter
void resize(const int passedWindowWidth, const int passedWindowHeight, const int passedAvailableWidth); // more detailed control
void sanitize(std::string &str);
std::unique_ptr<std::pair<int, int>> size() const;
// input needed stuff
int rasterStartX = 0; // start reading text source at and place at destination 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment