from report.command import FontCommand

from .._CommandProcessor import CommandProcessor


class FontCommandProcessor(CommandProcessor):
    def get_bytes(self, command):
        if not isinstance(command, FontCommand):
            return ""

        if command.font == FontCommand.Font.A.value:
            return self._set_font(n=b"\x00")

        if command.font == FontCommand.Font.B.value:
            return self._set_font(n=b"\x01")

        return ""

    @staticmethod
    def _set_font(
        n,  # type: bytes
    ):
        # type:(...) -> bytes

        esc = b"\x1b"

        return esc + b"\x4d" + n
