Skip to content

Commit

Permalink
feat: dropAllBlur
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed May 15, 2023
1 parent 41d6304 commit cf44af6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/jassub.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export default class JASSUB extends EventTarget {
debug: this.debug,
targetFps: options.targetFps || 24,
dropAllAnimations: options.dropAllAnimations,
dropAllBlur: options.dropAllBlur,
libassMemoryLimit: options.libassMemoryLimit || 0,
libassGlyphLimit: options.libassGlyphLimit || 0,
useLocalFonts: ('queryLocalFonts' in self) && (options.useLocalFonts ?? true)
Expand Down
10 changes: 10 additions & 0 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ self.setTrack = ({ content }) => {
// Make sure that the fonts are loaded
processAvailableFonts(content)

if (dropAllBlur) content = dropBlur(content)
// Tell libass to render the new track
jassubObj.createTrackMem(content)

Expand Down Expand Up @@ -391,6 +392,12 @@ const parseAss = content => {
return sections
}

const blurRegex = /\\blur(?:[0-9]+\.)?[0-9]+/gm

const dropBlur = subContent => {
return subContent.replace(blurRegex, '')
}

const requestAnimationFrame = (() => {
// similar to Browser.requestAnimationFrame
let nextRAF = 0
Expand Down Expand Up @@ -422,6 +429,7 @@ let bufferCanvas
let bufferCtx
let jassubObj
let subtitleColorSpace
let dropAllBlur

self.init = data => {
self.width = data.width
Expand All @@ -440,6 +448,7 @@ self.init = data => {
debug = data.debug
targetFps = data.targetFps || targetFps
useLocalFonts = data.useLocalFonts
dropAllBlur = data.dropAllBlur

const fallbackFont = data.fallbackFont.toLowerCase()
jassubObj = new Module.JASSUB(self.width, self.height, fallbackFont || null, debug)
Expand All @@ -450,6 +459,7 @@ self.init = data => {
if (!subContent) subContent = read_(data.subUrl)

processAvailableFonts(subContent)
if (dropAllBlur) subContent = dropBlur(subContent)

for (const font of data.fonts || []) asyncWrite(font)

Expand Down

0 comments on commit cf44af6

Please sign in to comment.