* 0x00495685 * * @param buffer @ * @return width @ */
| 1640 | * @return width @<cx> |
| 1641 | */ |
| 1642 | static uint16_t getStringWidth(Font font, const char* str) |
| 1643 | { |
| 1644 | uint16_t width = 0; |
| 1645 | while (*str != '\0') |
| 1646 | { |
| 1647 | const auto chr = static_cast<uint8_t>(*str); |
| 1648 | str++; |
| 1649 | |
| 1650 | if (chr >= 32) |
| 1651 | { |
| 1652 | width += Gfx::getCharacterWidth(font, chr); |
| 1653 | continue; |
| 1654 | } |
| 1655 | |
| 1656 | switch (chr) |
| 1657 | { |
| 1658 | case ControlCodes::moveX: |
| 1659 | width = *str; |
| 1660 | str++; |
| 1661 | break; |
| 1662 | |
| 1663 | case ControlCodes::adjustPalette: |
| 1664 | case 3: |
| 1665 | case 4: |
| 1666 | str++; |
| 1667 | break; |
| 1668 | |
| 1669 | case ControlCodes::newline: |
| 1670 | case ControlCodes::newlineSmaller: |
| 1671 | break; |
| 1672 | |
| 1673 | case ControlCodes::Font::small: |
| 1674 | font = Font::small; |
| 1675 | break; |
| 1676 | |
| 1677 | case ControlCodes::Font::large: |
| 1678 | font = Font::large; |
| 1679 | break; |
| 1680 | |
| 1681 | case ControlCodes::Font::bold: |
| 1682 | font = Font::medium_bold; |
| 1683 | break; |
| 1684 | |
| 1685 | case ControlCodes::Font::regular: |
| 1686 | font = Font::medium_normal; |
| 1687 | break; |
| 1688 | |
| 1689 | case ControlCodes::Font::outline: |
| 1690 | case ControlCodes::Font::outlineOff: |
| 1691 | case ControlCodes::windowColour1: |
| 1692 | case ControlCodes::windowColour2: |
| 1693 | case ControlCodes::windowColour3: |
| 1694 | case ControlCodes::windowColour4: |
| 1695 | break; |
| 1696 | |
| 1697 | case ControlCodes::newlineXY: |
| 1698 | width = *str++; |
| 1699 | str++; |
no test coverage detected