mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-26 08:56:36 +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):
|
def _parseCharAsColourSpec(self, colourSpec, curColours):
|
||||||
if len(colourSpec) > 0:
|
if len(colourSpec) > 0:
|
||||||
colourSpec = colourSpec.split(",")
|
colourSpec = colourSpec.split(",")
|
||||||
if len(colourSpec) == 2:
|
if len(colourSpec) == 2 \
|
||||||
|
and len(colourSpec[1]) > 0:
|
||||||
return (int(colourSpec[0] or curColours[0]), \
|
return (int(colourSpec[0] or curColours[0]), \
|
||||||
int(colourSpec[1]))
|
int(colourSpec[1]))
|
||||||
elif len(colourSpec) == 1:
|
elif len(colourSpec) == 1 \
|
||||||
|
or len(colourSpec[1]) == 0:
|
||||||
return (int(colourSpec[0]), curColours[1])
|
return (int(colourSpec[0]), curColours[1])
|
||||||
else:
|
else:
|
||||||
return (15, 1)
|
return (15, 1)
|
||||||
@ -108,6 +110,13 @@ class MiRCARTCanvasImportStore():
|
|||||||
or inParseState == self._ParseState.PS_COLOUR_DIGIT1:
|
or inParseState == self._ParseState.PS_COLOUR_DIGIT1:
|
||||||
if inChar == "," \
|
if inChar == "," \
|
||||||
and inParseState == self._ParseState.PS_COLOUR_DIGIT0:
|
and inParseState == self._ParseState.PS_COLOUR_DIGIT0:
|
||||||
|
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
|
inCurCol += 1
|
||||||
inCurColourDigits = 0; inCurColourSpec += inChar;
|
inCurColourDigits = 0; inCurColourSpec += inChar;
|
||||||
inParseState = self._ParseState.PS_COLOUR_DIGIT1
|
inParseState = self._ParseState.PS_COLOUR_DIGIT1
|
||||||
|
@ -71,13 +71,12 @@ class MiRCARTToPngFile:
|
|||||||
[187, 187, 187], # Light Grey
|
[187, 187, 187], # Light Grey
|
||||||
]
|
]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _drawUnderline(self, curPos, fontSize, imgDraw): XXX
|
# {{{ _drawUnderline(self, curPos, fontSize, imgDraw, fillColour): XXX
|
||||||
def _drawUnderLine(self, curPos, fontSize, imgDraw):
|
def _drawUnderLine(self, curPos, fontSize, imgDraw, fillColour):
|
||||||
imgDraw.line( \
|
imgDraw.line( \
|
||||||
(curPos[0], \
|
xy=(curPos[0], curPos[1] + (fontSize[1] - 2), \
|
||||||
curPos[1] + (fontSize[1] - 2)), \
|
curPos[0] + fontSize[0], curPos[1] + (fontSize[1] - 2)), \
|
||||||
(curPos[0] + fontSize[0], \
|
fill=fillColour)
|
||||||
curPos[1] + (fontSize[1] - 2)), fill=outColours[0])
|
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ export(self, outFilePath): XXX
|
# {{{ export(self, outFilePath): XXX
|
||||||
def export(self, outFilePath):
|
def export(self, outFilePath):
|
||||||
@ -90,15 +89,15 @@ class MiRCARTToPngFile:
|
|||||||
for inCurCol in range(len(self.inCanvasMap[inCurRow])):
|
for inCurCol in range(len(self.inCanvasMap[inCurRow])):
|
||||||
inCurCell = self.inCanvasMap[inCurRow][inCurCol]
|
inCurCell = self.inCanvasMap[inCurRow][inCurCol]
|
||||||
outColours = [0, 0]
|
outColours = [0, 0]
|
||||||
if inCurCell[1] & 0x02:
|
if inCurCell[1] & MiRCARTCanvasImportStore.MiRCARTCanvasImportStore._CellState.CS_BOLD:
|
||||||
if inCurCell[2] != " ":
|
if inCurCell[2] != " ":
|
||||||
if inCurCell[2] == "█":
|
if inCurCell[2] == "█":
|
||||||
outColours[1] = self._ColourMapBold[inCurCell[0][0]]
|
outColours[1] = self._ColourMapNormal[inCurCell[0][0]]
|
||||||
else:
|
else:
|
||||||
outColours[0] = self._ColourMapBold[inCurCell[0][0]]
|
outColours[0] = self._ColourMapBold[inCurCell[0][0]]
|
||||||
outColours[1] = self._ColourMapBold[inCurCell[0][1]]
|
outColours[1] = self._ColourMapNormal[inCurCell[0][1]]
|
||||||
else:
|
else:
|
||||||
outColours[1] = self._ColourMapBold[inCurCell[0][1]]
|
outColours[1] = self._ColourMapNormal[inCurCell[0][1]]
|
||||||
else:
|
else:
|
||||||
if inCurCell[2] != " ":
|
if inCurCell[2] != " ":
|
||||||
if inCurCell[2] == "█":
|
if inCurCell[2] == "█":
|
||||||
@ -117,8 +116,11 @@ class MiRCARTToPngFile:
|
|||||||
# XXX implement italic
|
# XXX implement italic
|
||||||
outImgDraw.text(outCurPos, \
|
outImgDraw.text(outCurPos, \
|
||||||
inCurCell[2], (*outColours[0], 255), self.outImgFont)
|
inCurCell[2], (*outColours[0], 255), self.outImgFont)
|
||||||
if inCurCell[1] & 0x1f:
|
if inCurCell[1] & MiRCARTCanvasImportStore.MiRCARTCanvasImportStore._CellState.CS_UNDERLINE:
|
||||||
self._drawUnderLine(curPos, self.outImgFontSize, outImgDraw)
|
outColours[0] = self._ColourMapNormal[inCurCell[0][0]]
|
||||||
|
self._drawUnderLine(outCurPos, \
|
||||||
|
self.outImgFontSize, \
|
||||||
|
outImgDraw, (*outColours[0], 255))
|
||||||
outCurPos[0] += self.outImgFontSize[0];
|
outCurPos[0] += self.outImgFontSize[0];
|
||||||
outCurPos[0] = 0
|
outCurPos[0] = 0
|
||||||
outCurPos[1] += self.outImgFontSize[1]
|
outCurPos[1] += self.outImgFontSize[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user