Custom fonts php-font-lib AdobeFontMetrics issue - wants to save files, no write access
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 11.2k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
So... after moving to a strictly-controlled host (there's no write access anywhere except /tmp and a local /log), I get this fatal error.
The fonts look all wonky, too. Looks like it's being rendered from UTF8 by a non-UTF-aware program, every letter is rendered k i n d a l i k e t h i s.
It looks like it's trying to write to some file (as evidenced by fwrite), but there will be no write permissions for PHP into the code directory, that's out of the question.
Ideas?
Stack trace:
PHP Fatal error: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in /var/www/api/vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php:191
Stack trace:
#0 /var/www/api/vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php(191): fwrite()
#1 /var/www/api/vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php(211): FontLib\\AdobeFontMetrics->addLine()
#2 /var/www/api/vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php(49): FontLib\\AdobeFontMetrics->startSection()
#3 /var/www/api/vendor/phenx/php-font-lib/src/FontLib/TrueType/File.php(361): FontLib\\AdobeFontMetrics->write()
#4 /var/www/api/vendor/dompdf/dompdf/src/FontMetrics.php(245): FontLib\\TrueType\\File->saveAdobeFontMetrics()
#5 /var/www/api/vendor/dompdf/dompdf/src/Css/Stylesheet.php(1511): Dompdf\\FontMetrics->registerFont()
#6 /var/www/api/vendor/dompdf/dompdf/src/Css/Stylesheet.php(1368): Dompdf\\Css\\Stylesheet->_parse_font_face()
#7 /var/www/api/vendor/dompdf/dompdf/src/Css/Stylesheet.php(302): Dompdf\\Css\\Stylesheet->_parse_css()
#8 /var/www/api/vendor/dompdf/dompdf/src/Dompdf.php(617): Dompdf\\Css\\Stylesheet->load_css()
#9 /var/www/api/vendor/dompdf/dompdf/src/Dompdf.php(695): Dompdf\\Dompdf->processHtml()
#10 /var/www/api/api-modules/func.pdf.php(294): Dompdf\\Dompdf->render()
#11 /var/www/api/api-modules/v1/rejestracja.php(131): generateAndReturnWarrantiesPDF()
#12 /var/www/api/api.php(245): include_once('...')
#13 /var/www/public/api.php(11): require('...')
#14 {main}
thrown in /var/www/api/vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php on line 191
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php at line 191 and trace the call from dompdf/src/FontMetrics.php:245 through CSS font registration. Reproduce the failure on a host where only /tmp is writable, then determine the expected writable location and font-encoding behavior. Done requires a confirmed handling path and regression coverage, but the issue does not specify the intended fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100