mirc2png.py:parseAsChar(): implement underline (^_.)

mirc2png.py:__init__(): increment self.outCurY by correct row height.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-01-02 16:54:39 +01:00
parent 2ea89a0559
commit abaa92b53d

View File

@ -129,19 +129,25 @@ class MiRCART:
self.inCurCol += 1; self.inCurUnderline = 0 if self.inCurUnderline else 1; self.inCurCol += 1; self.inCurUnderline = 0 if self.inCurUnderline else 1;
elif char == " ": elif char == " ":
if self.inCurBold: if self.inCurBold:
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=self.ColourMapBold[self.outCurColourBg]) colourBg = self.ColourMapBold[self.outCurColourBg]
else: else:
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=self.ColourMapNormal[self.outCurColourBg]) colourBg = self.ColourMapNormal[self.outCurColourBg]
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=colourBg)
if self.inCurUnderline:
self.outImgDraw.line((self.outCurX, self.outCurY + 11, self.outCurX + 7, self.outCurY + 11), fill=colourFg)
self.outCurX += 7; self.inCurCol += 1; self.outCurX += 7; self.inCurCol += 1;
else: else:
if self.inCurBold: if self.inCurBold:
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=self.ColourMapBold[self.outCurColourBg]) colourBg = self.ColourMapBold[self.outCurColourBg]
# XXX implement italic, reverse, underline colourFg = self.ColourMapBold[self.outCurColourFg]
self.outImgDraw.text((self.outCurX, self.outCurY), char, self.ColourMapBold[self.outCurColourFg], self.outImgFont)
else: else:
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=self.ColourMapNormal[self.outCurColourBg]) colourBg = self.ColourMapNormal[self.outCurColourBg]
# XXX implement italic, reverse, underline colourFg = self.ColourMapNormal[self.outCurColourFg]
self.outImgDraw.text((self.outCurX, self.outCurY), char, self.ColourMapNormal[self.outCurColourFg], self.outImgFont) self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=colourBg)
# XXX implement italic, reverse
self.outImgDraw.text((self.outCurX, self.outCurY), char, colourFg, self.outImgFont)
if self.inCurUnderline:
self.outImgDraw.line((self.outCurX, self.outCurY + 11, self.outCurX + 7, self.outCurY + 11), fill=colourFg)
self.outCurX += 7; self.inCurCol += 1; self.outCurX += 7; self.inCurCol += 1;
# }}} # }}}
# {{{ Parse single character as mIRC colour control code sequence and mutate state # {{{ Parse single character as mIRC colour control code sequence and mutate state
@ -182,7 +188,7 @@ class MiRCART:
self.parseAsChar(self.inLines[inCurRow][self.inCurCol]) self.parseAsChar(self.inLines[inCurRow][self.inCurCol])
elif self.state == self.State.STATE_COLOUR_SPEC: elif self.state == self.State.STATE_COLOUR_SPEC:
self.parseAsColourSpec(self.inLines[inCurRow][self.inCurCol]) self.parseAsColourSpec(self.inLines[inCurRow][self.inCurCol])
self.outCurX = 0; self.outCurY += 14; self.outCurX = 0; self.outCurY += 13;
self.inFile.close(); self.inFile.close();
self.outImg.save(imgFilePath); self.outImg.save(imgFilePath);