C++: fix font positioning

backup
Christian Seiler 2 weeks ago
parent 02b4b8b4cc
commit 7cbac666b8
  1. 12
      cpp/src/monoformat_parseonly.cpp
  2. 12
      cpp/src/monoformat_structured.cpp

@ -1109,7 +1109,7 @@ std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& bu
ClippedImage target{screen, *x, *y, *width, *height};
auto renderer = FontRenderer{fontData}.withIgnoreUnknownChars(true);
renderer.render(text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
return {};
}
@ -1206,7 +1206,7 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu
}
ClippedImage target{screen, *x, *y, *width, *height};
auto renderer = FontRenderer{fontData}.withIgnoreUnknownChars(true);
auto dimensions = renderer.getRenderedDimensions(text, {0, static_cast<std::int32_t>(renderer.lineHeight() - 1)});
auto dimensions = renderer.getRenderedDimensions(text, {0, static_cast<std::int32_t>(renderer.lineHeight() - 2)});
if (!dimensions || !dimensions->boundingBox) {
return {};
}
@ -1230,7 +1230,7 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu
if (!padBefore && !padAfter && contentWidth < *width) {
std::uint16_t offset = invert ? (*width - contentWidth) : 0;
renderer.render(text, Point{offset, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(text, Point{offset, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
return {};
}
@ -1267,7 +1267,7 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu
}
partOffset += *width;
}
renderer.render(text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
partOffset += contentWidth;
if (padAfter) {
if (bgColor) {
@ -1298,7 +1298,7 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu
}
partOffset += *width;
}
renderer.render(text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
}
return {};
@ -1429,7 +1429,7 @@ std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& bu
return {};
}
renderer.render(text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
return {};
}

@ -1466,7 +1466,7 @@ void ClippedTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
bool fgColor = !m_textFlags.dark;
auto renderer = FontRenderer{fontData}.withIgnoreUnknownChars(true);
renderer.render(m_text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(m_text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
}
std::expected<std::unique_ptr<ClippedTextElement>, ParseError> ClippedTextElement::parse(std::span<std::byte const>& buffer, std::uint32_t formatVersion) {
@ -1664,7 +1664,7 @@ void HScrollTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
}
auto renderer = FontRenderer{fontData}.withIgnoreUnknownChars(true);
auto dimensions = renderer.getRenderedDimensions(m_text, {0, static_cast<std::int32_t>(renderer.lineHeight() - 1)});
auto dimensions = renderer.getRenderedDimensions(m_text, {0, static_cast<std::int32_t>(renderer.lineHeight() - 2)});
if (!dimensions || !dimensions->boundingBox) {
return;
}
@ -1688,7 +1688,7 @@ void HScrollTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
if (!padBefore && !padAfter && contentWidth < m_width) {
std::uint16_t offset = invert ? (m_width - contentWidth) : 0;
renderer.render(m_text, Point{offset, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(m_text, Point{offset, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
return;
}
@ -1725,7 +1725,7 @@ void HScrollTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
}
partOffset += m_width;
}
renderer.render(m_text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(m_text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
partOffset += contentWidth;
if (padAfter) {
if (bgColor) {
@ -1756,7 +1756,7 @@ void HScrollTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
}
partOffset += m_width;
}
renderer.render(m_text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(m_text, Point{partOffset - offset, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
}
}
@ -2003,7 +2003,7 @@ void CurrentTimeElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
return;
}
renderer.render(text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 1)}, target, fgColor, bgColor);
renderer.render(text, Point{0, static_cast<std::int32_t>(renderer.lineHeight() - 2)}, target, fgColor, bgColor);
}
std::expected<std::unique_ptr<CurrentTimeElement>, ParseError> CurrentTimeElement::parse(std::span<std::byte const>& buffer, std::uint32_t formatVersion) {

Loading…
Cancel
Save