From 5369bf85bb710054576b51caae1ddd8cf3633a9a Mon Sep 17 00:00:00 2001 From: ecc521 <42424091+ecc521@users.noreply.github.com> Date: Tue, 18 Apr 2023 08:46:21 -0400 Subject: [PATCH] Add fontSize option for title --- README.md | 1 + sources/fabric/fabricFrameSources.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9ce0522e..5b48e18e 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,7 @@ See also [Ken Burns parameters](#ken-burns-parameters). #### Layer type 'title' - `fontPath` - See `defaults.layer.fontPath` - `text` - Title text to show, keep it short +- `fontSize` - Size for font relative to smaller of width/height (default 0.1) - `textColor` - default `#ffffff` - `position` - See [Position parameter](#position-parameter) diff --git a/sources/fabric/fabricFrameSources.js b/sources/fabric/fabricFrameSources.js index f40c3a36..72295e21 100644 --- a/sources/fabric/fabricFrameSources.js +++ b/sources/fabric/fabricFrameSources.js @@ -263,14 +263,14 @@ export async function imageOverlayFrameSource({ params, width, height }) { } export async function titleFrameSource({ width, height, params }) { - const { text, textColor = '#ffffff', fontFamily = defaultFontFamily, position = 'center', zoomDirection = 'in', zoomAmount = 0.2 } = params; + const { text, textColor = '#ffffff', fontFamily = defaultFontFamily, position = 'center', zoomDirection = 'in', zoomAmount = 0.2, fontSize = 0.1 } = params; async function onRender(progress, canvas) { // console.log('progress', progress); const min = Math.min(width, height); - const fontSize = Math.round(min * 0.1); + const pixelFontSize = Math.round(min * fontSize); //Scale fontSize to smaller of width / height. const scaleFactor = getZoomParams({ progress, zoomDirection, zoomAmount }); @@ -279,7 +279,7 @@ export async function titleFrameSource({ width, height, params }) { const textBox = new fabric.Textbox(text, { fill: textColor, fontFamily, - fontSize, + fontSize: pixelFontSize, textAlign: 'center', width: width * 0.8, });