mirror of
https://github.com/stronk-dev/Guitar-Sheet-Parser.git
synced 2025-07-05 08:25:09 +02:00
Added max pages
This commit is contained in:
parent
f26e80b245
commit
9992b7ac36
@ -54,7 +54,8 @@ def initConfig():
|
|||||||
'highestwhitespaceonwidthratioallowed': 0.40,
|
'highestwhitespaceonwidthratioallowed': 0.40,
|
||||||
'keepEmptyLines': 1,
|
'keepEmptyLines': 1,
|
||||||
'writeheaderfile': 0,
|
'writeheaderfile': 0,
|
||||||
'minPages': 2
|
'minPages': 2,
|
||||||
|
'maxPages': 4
|
||||||
}
|
}
|
||||||
# (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:
|
||||||
|
@ -239,6 +239,7 @@ class Song:
|
|||||||
self.writeMetadata = configObj['writeheaderfile'] == '1'
|
self.writeMetadata = configObj['writeheaderfile'] == '1'
|
||||||
# Don't go under this number
|
# Don't go under this number
|
||||||
self.minPages = int(configObj['minPages'])
|
self.minPages = int(configObj['minPages'])
|
||||||
|
self.maxPages = max(int(configObj['minPages']), int(configObj['maxPages']))
|
||||||
|
|
||||||
|
|
||||||
"""!@brief Calculates dimensions of metadata
|
"""!@brief Calculates dimensions of metadata
|
||||||
@ -320,10 +321,10 @@ class Song:
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
"""!@brief Checks whether we can increase the font size without creating more pages
|
"""!@brief Resizes the page to fit reminaing whitespace, and increases the number of pages to stay above the minimum amount of pages
|
||||||
@return None
|
@return None
|
||||||
"""
|
"""
|
||||||
def increaseWhileSameAmountOfPages(self):
|
def increaseToMinPages(self):
|
||||||
targetPageAmount = max(len(self.pages), self.minPages)
|
targetPageAmount = max(len(self.pages), self.minPages)
|
||||||
originalFontsize = self.fontSize
|
originalFontsize = self.fontSize
|
||||||
print("Starting font size increase with {} pages and {} font size".format(targetPageAmount, originalFontsize))
|
print("Starting font size increase with {} pages and {} font size".format(targetPageAmount, originalFontsize))
|
||||||
|
6
main.py
6
main.py
@ -75,12 +75,12 @@ def main():
|
|||||||
# Prerender: calculate Pages, and move sections into Pages
|
# Prerender: calculate Pages, and move sections into Pages
|
||||||
song.sectionsToPages()
|
song.sectionsToPages()
|
||||||
# Optimalisation: try to fill whitespace
|
# Optimalisation: try to fill whitespace
|
||||||
while song.canFillWhitespace():
|
while song.canFillWhitespace() or len(song.pages) > song.maxPages:
|
||||||
print("Resizing down to fit whitespace more efficiently")
|
print("Resizing down to fit whitespace more efficiently")
|
||||||
song.resizeAllSections(-1)
|
song.resizeAllSections(-1)
|
||||||
song.sectionsToPages()
|
song.sectionsToPages()
|
||||||
# Optimalisation: increase font size as long as the amount of pages does not increase or we cause an overflow on width
|
# Optimalisation: increase font size to fit target page amount
|
||||||
song.increaseWhileSameAmountOfPages()
|
song.increaseToMinPages()
|
||||||
# Parse as PNG a4
|
# Parse as PNG a4
|
||||||
# Create subdirectory where we will output our images
|
# Create subdirectory where we will output our images
|
||||||
targetDirectory = song.outputLocation + "-a4-png"
|
targetDirectory = song.outputLocation + "-a4-png"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user