Added a right-margin propert

Overflow-X check function now takes left and right margin into account
This commit is contained in:
Marco van Dijk 2021-07-09 01:58:33 +02:00
parent 0767b7c2eb
commit 5325906c22
2 changed files with 4 additions and 2 deletions

View File

@ -42,7 +42,8 @@ def initConfig():
'fontColour': '0,0,0', 'fontColour': '0,0,0',
'metadataColour': '128,128,128', 'metadataColour': '128,128,128',
'topMargin': 10, 'topMargin': 10,
'leftMargin': 25 'leftMargin': 25,
'rightMargin': 25
} }
# (if CMD arguments: load CMD arguments to override specific settings) # (if CMD arguments: load CMD arguments to override specific settings)
with open('config.ini', 'w') as configfile: with open('config.ini', 'w') as configfile:

View File

@ -199,6 +199,7 @@ class Song:
self.imageWidth = int(configObj['imageWidth']) self.imageWidth = int(configObj['imageWidth'])
self.imageHeight = int(configObj['imageHeight']) self.imageHeight = int(configObj['imageHeight'])
self.leftMargin = int(configObj['leftMargin']) self.leftMargin = int(configObj['leftMargin'])
self.rightMargin = int(configObj['rightMargin'])
self.fontMetadata = ImageFont.truetype(configObj['metafontfamily'], int(configObj['metaFontWeight'])) self.fontMetadata = ImageFont.truetype(configObj['metafontfamily'], int(configObj['metaFontWeight']))
self.fontSize = int(configObj['songFontWeight']) self.fontSize = int(configObj['songFontWeight'])
self.fontLyrics = ImageFont.truetype(configObj['lyricfontfamily'], self.fontSize) self.fontLyrics = ImageFont.truetype(configObj['lyricfontfamily'], self.fontSize)
@ -258,7 +259,7 @@ class Song:
""" """
def checkOverflowX(self): def checkOverflowX(self):
for section in self.sections: for section in self.sections:
if section.expectedWidth > self.imageWidth: if section.expectedWidth > self.imageWidth - self.leftMargin - self.rightMargin:
return False return False
return True return True