mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-26 00:46:38 +00:00
MiRCART.py:MiRCART._parseAsChar(): derive rectangle & line coordinates and outCur{X,Y} offset from outImgFontSize[{0,1}].
MiRCART.py:MiRCART.__init__(): initialise outImgFontSize and add underline area offset. MiRCART.py:MiRCART.__init__(): derive outCurY offset from outImgFontSize[1].
This commit is contained in:
parent
e182f0ffa9
commit
523d91ff89
19
MiRCART.py
19
MiRCART.py
@ -132,10 +132,10 @@ class MiRCART:
|
|||||||
colourBg = self._ColourMapBold[self.outCurColourBg]
|
colourBg = self._ColourMapBold[self.outCurColourBg]
|
||||||
else:
|
else:
|
||||||
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
||||||
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=colourBg)
|
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + self.outImgFontSize[0], self.outCurY + self.outImgFontSize[1])), fill=colourBg)
|
||||||
if self.inCurUnderline:
|
if self.inCurUnderline:
|
||||||
self.outImgDraw.line((self.outCurX, self.outCurY + 11, self.outCurX + 7, self.outCurY + 11), fill=colourFg)
|
self.outImgDraw.line((self.outCurX, self.outCurY + (self.outImgFontSize[1] - 2), self.outCurX + self.outImgFontSize[0], self.outCurY + (self.outImgFontSize[1] - 2)), fill=colourFg)
|
||||||
self.outCurX += 7; self.inCurCol += 1;
|
self.outCurX += self.outImgFontSize[0]; self.inCurCol += 1;
|
||||||
else:
|
else:
|
||||||
if self.inCurBold:
|
if self.inCurBold:
|
||||||
colourBg = self._ColourMapBold[self.outCurColourBg]
|
colourBg = self._ColourMapBold[self.outCurColourBg]
|
||||||
@ -143,12 +143,12 @@ class MiRCART:
|
|||||||
else:
|
else:
|
||||||
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
colourBg = self._ColourMapNormal[self.outCurColourBg]
|
||||||
colourFg = self._ColourMapNormal[self.outCurColourFg]
|
colourFg = self._ColourMapNormal[self.outCurColourFg]
|
||||||
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + 7, self.outCurY + 14)), fill=colourBg)
|
self.outImgDraw.rectangle(((self.outCurX, self.outCurY), (self.outCurX + self.outImgFontSize[0], self.outCurY + self.outImgFontSize[1])), fill=colourBg)
|
||||||
# XXX implement italic
|
# XXX implement italic
|
||||||
self.outImgDraw.text((self.outCurX, self.outCurY), char, colourFg, self.outImgFont)
|
self.outImgDraw.text((self.outCurX, self.outCurY), char, colourFg, self.outImgFont)
|
||||||
if self.inCurUnderline:
|
if self.inCurUnderline:
|
||||||
self.outImgDraw.line((self.outCurX, self.outCurY + 11, self.outCurX + 7, self.outCurY + 11), fill=colourFg)
|
self.outImgDraw.line((self.outCurX, self.outCurY + (self.outImgFontSize[1] - 2), self.outCurX + self.outImgFontSize[0], self.outCurY + (self.outImgFontSize[1] - 2)), fill=colourFg)
|
||||||
self.outCurX += 7; self.inCurCol += 1;
|
self.outCurX += self.outImgFontSize[0]; self.inCurCol += 1;
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _parseAsColourSpec(): Parse single character as mIRC colour control code sequence and mutate state
|
# {{{ _parseAsColourSpec(): Parse single character as mIRC colour control code sequence and mutate state
|
||||||
def _parseAsColourSpec(self, char):
|
def _parseAsColourSpec(self, char):
|
||||||
@ -174,9 +174,10 @@ class MiRCART:
|
|||||||
self.inColsMax = self._getMaxCols(self.inLines)
|
self.inColsMax = self._getMaxCols(self.inLines)
|
||||||
self.inRows = len(self.inLines)
|
self.inRows = len(self.inLines)
|
||||||
self.outFontFilePath = fontFilePath; self.outFontSize = int(fontSize);
|
self.outFontFilePath = fontFilePath; self.outFontSize = int(fontSize);
|
||||||
self.outImg = Image.new("RGBA", (self.inColsMax * 7, self.inRows * 14), self._ColourMapNormal[1])
|
|
||||||
self.outImgDraw = ImageDraw.Draw(self.outImg)
|
|
||||||
self.outImgFont = ImageFont.truetype(self.outFontFilePath, self.outFontSize)
|
self.outImgFont = ImageFont.truetype(self.outFontFilePath, self.outFontSize)
|
||||||
|
self.outImgFontSize = list(self.outImgFont.getsize(" ")); self.outImgFontSize[1] += 3;
|
||||||
|
self.outImg = Image.new("RGBA", (self.inColsMax * self.outImgFontSize[0], self.inRows * self.outImgFontSize[1]), self._ColourMapNormal[1])
|
||||||
|
self.outImgDraw = ImageDraw.Draw(self.outImg)
|
||||||
self.outCurColourBg = 1; self.outCurColourFg = 15;
|
self.outCurColourBg = 1; self.outCurColourFg = 15;
|
||||||
self.outCurX = 0; self.outCurY = 0;
|
self.outCurX = 0; self.outCurY = 0;
|
||||||
for inCurRow in range(0, len(self.inLines)):
|
for inCurRow in range(0, len(self.inLines)):
|
||||||
@ -188,7 +189,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 += 13;
|
self.outCurX = 0; self.outCurY += self.outImgFontSize[1];
|
||||||
self.inFile.close();
|
self.inFile.close();
|
||||||
self.outImg.save(imgFilePath);
|
self.outImg.save(imgFilePath);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user