diff --git a/Dockerfile b/Dockerfile index 31806e0..5e05894 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,9 @@ RUN apk add --no-cache \ giflib \ pixman \ vips-dev \ - pkgconfig + pkgconfig \ + ttf-dejavu \ + fontconfig # Copier les fichiers de configuration COPY package*.json ./ diff --git a/server/fonts/DejaVuSans.ttf b/server/fonts/DejaVuSans.ttf new file mode 100644 index 0000000..e5f7eec Binary files /dev/null and b/server/fonts/DejaVuSans.ttf differ diff --git a/server/services/imageProcessor.ts b/server/services/imageProcessor.ts index 05301cc..e43211f 100644 --- a/server/services/imageProcessor.ts +++ b/server/services/imageProcessor.ts @@ -21,6 +21,15 @@ const CROP_FORMATS = { instagramStory: { width: 1080, height: 1920 } as CropDimensions, }; +// Register DejaVu Sans font for proper character rendering +try { + const fontPath = path.join(process.cwd(), "server", "fonts", "DejaVuSans.ttf"); + registerFont(fontPath, { family: 'DejaVu Sans' }); + console.log('✓ Font DejaVu Sans enregistrée avec succès'); +} catch (error) { + console.error('Erreur lors de l\'enregistrement de la police:', error); +} + export class ImageProcessor { private uploadsDir: string; @@ -150,7 +159,7 @@ export class ImageProcessor { let totalTextHeight = 0; while (fontSize >= MIN_FONT_SIZE) { - ctx.font = `bold ${fontSize}px Arial, sans-serif`; + ctx.font = `bold ${fontSize}px "DejaVu Sans", Arial, sans-serif`; lines = this.wrapText(ctx, text, maxTextWidth); const lineHeight = fontSize * LINE_HEIGHT_MULTIPLIER; @@ -165,7 +174,7 @@ export class ImageProcessor { if (fontSize < MIN_FONT_SIZE) { fontSize = MIN_FONT_SIZE; - ctx.font = `bold ${fontSize}px Arial, sans-serif`; + ctx.font = `bold ${fontSize}px "DejaVu Sans", Arial, sans-serif`; lines = this.wrapText(ctx, text, maxTextWidth); const lineHeight = fontSize * LINE_HEIGHT_MULTIPLIER; totalTextHeight = lines.length * lineHeight;