Closed edward-dauvergne closed 5 months ago
For the record, the Nimbus Mono L
error:
CRITICAL: FreeType returned the error 35 when calling FT_Load_Sfnt_Table for font /usr/share/fonts/default/Type1/n022003l.pfb.
can be worked around by switching to the Nimbus Mono PS
font instead.
I believe it should be safe to change
m_fontDatabase.hasFamily(family)
to
m_fontDatabase.families().contains(family)
Can you test and submit a PR?
Sure! I'm on holidays for the next 2 weeks, but after that I can give it a go.
This was correct in Qt 5:
m_fontDatabase.families().contains(family)
Please note that QFontDatabase::families() is now a static function in Qt 6 (as it should be, IMHO):
QFontDatabase::families().contains(family)
would work in Qt 6.
While investigating font issues (issue #629), I noticed that there is a difference in the result from
QFontDatabase::hasFamily()
compared to the list returned byQFontDatabase::families()
. Some background might be useful here:Nimbus Sans
orOCRA [PfEd]
.To reproduce a small test case, I created a blank PNG file with:
Then I manually created the following
test.html
file:The GUI looks like this:![Screenshot_GUI](https://github.com/manisandro/gImageReader/assets/10072253/239b711e-3825-43a8-ae40-f9f4f9703857)
Finally, I export to PDF using PoDoFo in PDF output mode, 300 dpi, grayscale. The result is: test.pdf.
Playing with the code in
qt/src/hocr/HOCRPdfExporter.cc
, I could see that theOCRA [PfEd]
font was being replaced by the default fontNimbus Roman
, asQFontDatabase::hasFamily()
was returningfalse
for this font. TheNimbus Mono L
font was also switched for the default font, but for an unrelated FreeType reason:However checking
QFontDatabase::families()
shows thatOCRA [PfEd]
is in the QFontDatabase! Therefore I tried the following change:This resulted in the
OCRA [PfEd]
font being recognised and embedded in the PDF output. Though there are still issues with the PDF: test_modified.pdf:According to the recent Qt docs for QFontDatabase, the hasFamily() function is not documented at all. Is this depreciated? Is is suffering from bit-rot? The families() function is however documented. Therefore should the code be switched to this function?
Cheers,
Edward