Skip to content

Commit

Permalink
insert additional images automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
matiusz committed Nov 28, 2024
1 parent 7edbf88 commit 153bb1e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions songbook/src/songbookTeXmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ async def semaphoredLoadSong(dirpath, filename, sem):
return await TexSong.load(os.path.join(dirpath, filename))



def imageTex(song, songs):
songData=songs[song]
return f"""\n
\\begin{{tikzpicture}}[remember picture,overlay]
\\node[xshift={songData['xshift']}mm,yshift={songData['yshift']}mm,anchor=south] at (current page.south){{%
\\includegraphics[width={songData['width']}mm]{{{songData['imgname']}}}}};
\\end{{tikzpicture}}\n
"""


class CategoryDict(dict):
def __missing__(self, key):
res = self[key] = TexCategory(key)
Expand Down Expand Up @@ -89,12 +100,31 @@ def __init__(self, songData):
self.title = self.song.title
self.category = self.song.category


@property
def tex(self):
songStr = f"\\section*{{{self.title}}}\n\\addcontentsline{{toc}}{{section}}{{{self.title}}}\n\\columnratio{{0.78,0.22}}\n\\rmfamily\\raggedbottom"
author = self.song.author
if author:
songStr += f"\\begin{{flushright}}\n{author}\n\\end{{flushright}}"

imagedSongs = {
'Hawiarska Koliba': {
'imgname': 'ognisko-hk',
'xshift': 7.5,
'yshift': 30,
'width': 100
},
'Jeleń (on mknie)': {
'imgname': 'jeleń',
'xshift': -7.5,
'yshift': 30,
'width': 80
}
}

if self.title in imagedSongs.keys():
songStr += imageTex(self.title, imagedSongs)
for idx, chord in enumerate(self.song.special_chords):
songStr += chord.toTikz(idx)
capo = self.song.capo
Expand Down

0 comments on commit 153bb1e

Please sign in to comment.