Video Maker: resolve the DejaVu bold font from real candidate paths (Alpine vs Debian) instead of relying on ffmpeg's fallback

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-28 08:42:33 -05:00
parent 44816571b6
commit be2d2719e5
+17 -1
View File
@@ -59,6 +59,22 @@ function dt(s) {
// Linux (no colons), required on Windows drive letters when testing locally. // Linux (no colons), required on Windows drive letters when testing locally.
function dtPath(p) { return String(p || '').replace(/\\/g, '/').replace(/:/g, '\\:'); } function dtPath(p) { return String(p || '').replace(/\\/g, '/').replace(/:/g, '\\:'); }
// Alpine puts DejaVu in /usr/share/fonts/dejavu; Debian uses truetype/dejavu.
// Pick a real file rather than trusting ffmpeg's undefined fallback.
let _font = null;
function pickFont() {
if (_font) return _font;
const cands = [
'/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf',
'/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf',
'/usr/share/fonts/dejavu/DejaVuSans.ttf',
'/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
];
for (const c of cands) { try { if (fs.existsSync(c)) { _font = c; return c; } } catch (e) {} }
_font = cands[0];
return _font;
}
function ffmpegBin() { return process.env.FFMPEG_BIN || 'ffmpeg'; } function ffmpegBin() { return process.env.FFMPEG_BIN || 'ffmpeg'; }
function render(opts) { function render(opts) {
@@ -74,7 +90,7 @@ function render(opts) {
const out = path.join(outDir(), id + '-' + angle + '.mp4'); const out = path.join(outDir(), id + '-' + angle + '.mp4');
try { writeQrPpm(link, qrFile, 10, 4); } catch (e) { return reject(new Error('Could not build your QR code.')); } try { writeQrPpm(link, qrFile, 10, 4); } catch (e) { return reject(new Error('Could not build your QR code.')); }
const font = process.env.FF_FONT || '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf'; const font = process.env.FF_FONT || pickFont();
const shortLink = link.replace(/^https?:\/\//, ''); const shortLink = link.replace(/^https?:\/\//, '');
const headline = name ? (name + ' invited you') : 'You were invited'; const headline = name ? (name + ' invited you') : 'You were invited';