|
|
|
@ -558,6 +558,7 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// FIXME: newline support
|
|
|
|
// FIXME: newline support
|
|
|
|
|
|
|
|
// also FIXME: call ensureAdvance when handling newline
|
|
|
|
if (cp == '\n') { |
|
|
|
if (cp == '\n') { |
|
|
|
cp = ' '; |
|
|
|
cp = ' '; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -570,6 +571,8 @@ public: |
|
|
|
boundingBox = combineBoundingBoxes(boundingBox, dims->boundingBox); |
|
|
|
boundingBox = combineBoundingBoxes(boundingBox, dims->boundingBox); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boundingBox = ensureAdvance(boundingBox, advance); |
|
|
|
|
|
|
|
|
|
|
|
return RenderedDimensions{advance, boundingBox}; |
|
|
|
return RenderedDimensions{advance, boundingBox}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -619,6 +622,22 @@ private: |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static std::optional<Rectangle> ensureAdvance(std::optional<Rectangle> a, Point advance) { |
|
|
|
|
|
|
|
if (!a) { |
|
|
|
|
|
|
|
return std::nullopt; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: once we support multi-line also handle y component
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto bottomRight = a->getBottomRight(); |
|
|
|
|
|
|
|
if ((bottomRight.x + 1) < advance.x) { |
|
|
|
|
|
|
|
bottomRight.x = advance.x - 1; |
|
|
|
|
|
|
|
return Rectangle::fromCorners(a->topLeft, bottomRight); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return a; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename Display> |
|
|
|
template<typename Display> |
|
|
|
static std::expected<RenderedDimensions, LookupError> renderGlyph(std::uint32_t cp, Point position, FontReader const& font, Display& display, typename Display::Color fontColor, std::optional<typename Display::Color> bgColor) { |
|
|
|
static std::expected<RenderedDimensions, LookupError> renderGlyph(std::uint32_t cp, Point position, FontReader const& font, Display& display, typename Display::Color fontColor, std::optional<typename Display::Color> bgColor) { |
|
|
|
auto glyph_ = font.tryRetrieveGlyphData(cp); |
|
|
|
auto glyph_ = font.tryRetrieveGlyphData(cp); |
|
|
|
|