mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +00:00
MiRCARTCanvasImportStore.py: correctly process ^C<colour>, sequences.
MiRCARTToPngFile.py: fix {bold,underline} processing.
This commit is contained in:
parent
0cf1040614
commit
b385909b45
@ -53,10 +53,12 @@ class MiRCARTCanvasImportStore():
|
||||
def _parseCharAsColourSpec(self, colourSpec, curColours):
|
||||
if len(colourSpec) > 0:
|
||||
colourSpec = colourSpec.split(",")
|
||||
if len(colourSpec) == 2:
|
||||
if len(colourSpec) == 2 \
|
||||
and len(colourSpec[1]) > 0:
|
||||
return (int(colourSpec[0] or curColours[0]), \
|
||||
int(colourSpec[1]))
|
||||
elif len(colourSpec) == 1:
|
||||
elif len(colourSpec) == 1 \
|
||||
or len(colourSpec[1]) == 0:
|
||||
return (int(colourSpec[0]), curColours[1])
|
||||
else:
|
||||
return (15, 1)
|
||||
@ -108,9 +110,16 @@ class MiRCARTCanvasImportStore():
|
||||
or inParseState == self._ParseState.PS_COLOUR_DIGIT1:
|
||||
if inChar == "," \
|
||||
and inParseState == self._ParseState.PS_COLOUR_DIGIT0:
|
||||
inCurCol += 1
|
||||
inCurColourDigits = 0; inCurColourSpec += inChar;
|
||||
inParseState = self._ParseState.PS_COLOUR_DIGIT1
|
||||
if (inCurCol + 1) < inMaxCol \
|
||||
and not inLine[inCurCol + 1] in set("0123456789"):
|
||||
inCurColours = self._parseCharAsColourSpec( \
|
||||
inCurColourSpec, inCurColours)
|
||||
inCurColourDigits = 0; inCurColourSpec = "";
|
||||
inParseState = self._ParseState.PS_CHAR
|
||||
else:
|
||||
inCurCol += 1
|
||||
inCurColourDigits = 0; inCurColourSpec += inChar;
|
||||
inParseState = self._ParseState.PS_COLOUR_DIGIT1
|
||||
elif inChar in set("0123456789") \
|
||||
and inCurColourDigits == 0:
|
||||
inCurCol += 1
|
||||
|
@ -71,13 +71,12 @@ class MiRCARTToPngFile:
|
||||
[187, 187, 187], # Light Grey
|
||||
]
|
||||
# }}}
|
||||
# {{{ _drawUnderline(self, curPos, fontSize, imgDraw): XXX
|
||||
def _drawUnderLine(self, curPos, fontSize, imgDraw):
|
||||
imgDraw.line( \
|
||||
(curPos[0], \
|
||||
curPos[1] + (fontSize[1] - 2)), \
|
||||
(curPos[0] + fontSize[0], \
|
||||
curPos[1] + (fontSize[1] - 2)), fill=outColours[0])
|
||||
# {{{ _drawUnderline(self, curPos, fontSize, imgDraw, fillColour): XXX
|
||||
def _drawUnderLine(self, curPos, fontSize, imgDraw, fillColour):
|
||||
imgDraw.line( \
|
||||
xy=(curPos[0], curPos[1] + (fontSize[1] - 2), \
|
||||
curPos[0] + fontSize[0], curPos[1] + (fontSize[1] - 2)), \
|
||||
fill=fillColour)
|
||||
# }}}
|
||||
# {{{ export(self, outFilePath): XXX
|
||||
def export(self, outFilePath):
|
||||
@ -90,15 +89,15 @@ class MiRCARTToPngFile:
|
||||
for inCurCol in range(len(self.inCanvasMap[inCurRow])):
|
||||
inCurCell = self.inCanvasMap[inCurRow][inCurCol]
|
||||
outColours = [0, 0]
|
||||
if inCurCell[1] & 0x02:
|
||||
if inCurCell[1] & MiRCARTCanvasImportStore.MiRCARTCanvasImportStore._CellState.CS_BOLD:
|
||||
if inCurCell[2] != " ":
|
||||
if inCurCell[2] == "█":
|
||||
outColours[1] = self._ColourMapBold[inCurCell[0][0]]
|
||||
outColours[1] = self._ColourMapNormal[inCurCell[0][0]]
|
||||
else:
|
||||
outColours[0] = self._ColourMapBold[inCurCell[0][0]]
|
||||
outColours[1] = self._ColourMapBold[inCurCell[0][1]]
|
||||
outColours[1] = self._ColourMapNormal[inCurCell[0][1]]
|
||||
else:
|
||||
outColours[1] = self._ColourMapBold[inCurCell[0][1]]
|
||||
outColours[1] = self._ColourMapNormal[inCurCell[0][1]]
|
||||
else:
|
||||
if inCurCell[2] != " ":
|
||||
if inCurCell[2] == "█":
|
||||
@ -117,8 +116,11 @@ class MiRCARTToPngFile:
|
||||
# XXX implement italic
|
||||
outImgDraw.text(outCurPos, \
|
||||
inCurCell[2], (*outColours[0], 255), self.outImgFont)
|
||||
if inCurCell[1] & 0x1f:
|
||||
self._drawUnderLine(curPos, self.outImgFontSize, outImgDraw)
|
||||
if inCurCell[1] & MiRCARTCanvasImportStore.MiRCARTCanvasImportStore._CellState.CS_UNDERLINE:
|
||||
outColours[0] = self._ColourMapNormal[inCurCell[0][0]]
|
||||
self._drawUnderLine(outCurPos, \
|
||||
self.outImgFontSize, \
|
||||
outImgDraw, (*outColours[0], 255))
|
||||
outCurPos[0] += self.outImgFontSize[0];
|
||||
outCurPos[0] = 0
|
||||
outCurPos[1] += self.outImgFontSize[1]
|
||||
|
Loading…
Reference in New Issue
Block a user