Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font directory support #2 #97

Merged
merged 4 commits into from
Jul 25, 2021
Merged

Conversation

cweiske
Copy link
Contributor

@cweiske cweiske commented Jul 24, 2021

This is the second try to get font directory support and font family registration into cewe2pdf, after the wrong merge in #87

additional_fonts.txt may contain folders and .ttf file names now,
and the font name is not required anymore.

CEWE-provided TTF font files are automatically loaded
from cewe-folder/Resources/photofun/fonts/ now.

We also automatically register font families
(combinations of regular,bold,italic,bold+italic fonts).

This commit introduces the requirement of the "fonttools" package.

Resolves: bash0#84
@AnEnglishmanInNorway
Copy link
Collaborator

Code looks good to me, I'll take the chance and merge this "second round" to the base and then try it.

@AnEnglishmanInNorway
Copy link
Collaborator

Oops. Maybe I shouldn't have taken the chance. The unittest crashes way down in reportlab looking for a font on my Windows PC. I'll look at this myself, it can't be too difficult to locate.

error on page 6:
BodoniB
(<class 'KeyError'>, 'cewe2pdf.py', 1320)
File "D:\Users\pete\Source\GitHub\cewe2pdf\cewe2pdf.py", line 1320, in convertMcf
bg_notFoundDirList, additional_fonts)
parsing page File "D:\Users\pete\Source\GitHub\cewe2pdf\cewe2pdf.py", line 965, in parseInputPage
processElements(additional_fonts, fotobook, imagedir, keepDoublePages, mcfBaseFolder, oddpage, page, pageNumber, pagetype, pdf, ph, pw)
File "D:\Users\pete\Source\GitHub\cewe2pdf\cewe2pdf.py", line 919, in processElements
processAreaTextTag(textTag, additional_fonts, area, areaHeight, areaRot, areaWidth, pdf, transx, transy)
File "D:\Users\pete\Source\GitHub\cewe2pdf\cewe2pdf.py", line 741, in processAreaTextTag
neededTextWidth, neededTextHeight = pdf_flowableList[j].wrap(availableTextWidth, availableTextHeight)
File "d:\Users\pete\anaconda3\lib\site-packages\reportlab\platypus\paragraph.py", line 1592, in wrap
blPara = self.breakLines(self._wrapWidths)
File "d:\Users\pete\anaconda3\lib\site-packages\reportlab\platypus\paragraph.py", line 1809, in breakLines
ascent, descent = getAscentDescent(fontName,fontSize)
File "d:\Users\pete\anaconda3\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 722, in getAscentDescent
font = getFont(fontName)
File "d:\Users\pete\anaconda3\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 716, in getFont
return findFontAndRegister(fontName)
File "d:\Users\pete\anaconda3\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 698, in findFontAndRegister
face = getTypeFace(fontName)
File "d:\Users\pete\anaconda3\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 655, in getTypeFace
return _typefaces[faceName]

@cweiske
Copy link
Contributor Author

cweiske commented Jul 26, 2021

(Fix in #98).

@cweiske cweiske deleted the fontdirs branch May 5, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants