2020-05-04 03:20:38 +02:00
/ * *
2020-06-28 16:36:00 +09:00
* Subtitle settings visual helper .
2020-05-04 03:20:38 +02:00
* @ module components / subtitleSettings / subtitleAppearanceHelper
* /
2020-06-28 16:36:00 +09:00
2020-05-03 20:30:35 +02:00
function getTextStyles ( settings , isCue ) {
let list = [ ] ;
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
if ( isCue ) {
switch ( settings . textSize || '' ) {
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
case 'smaller' :
list . push ( { name : 'font-size' , value : '.5em' } ) ;
break ;
case 'small' :
list . push ( { name : 'font-size' , value : '.7em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
2020-05-03 20:30:35 +02:00
case 'large' :
list . push ( { name : 'font-size' , value : '1.3em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
2020-05-03 20:30:35 +02:00
case 'larger' :
list . push ( { name : 'font-size' , value : '1.72em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
2020-05-03 20:30:35 +02:00
case 'extralarge' :
list . push ( { name : 'font-size' , value : '2em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
default :
2020-05-03 20:30:35 +02:00
case 'medium' :
2018-10-23 01:05:09 +03:00
break ;
}
2020-05-03 20:30:35 +02:00
} else {
switch ( settings . textSize || '' ) {
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
case 'smaller' :
list . push ( { name : 'font-size' , value : '.8em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
2020-05-03 20:30:35 +02:00
case 'small' :
list . push ( { name : 'font-size' , value : 'inherit' } ) ;
2018-10-23 01:05:09 +03:00
break ;
2020-05-03 20:30:35 +02:00
case 'larger' :
list . push ( { name : 'font-size' , value : '2em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
2020-05-03 20:30:35 +02:00
case 'extralarge' :
list . push ( { name : 'font-size' , value : '2.2em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
2020-05-03 20:30:35 +02:00
case 'large' :
list . push ( { name : 'font-size' , value : '1.72em' } ) ;
2018-10-23 01:05:09 +03:00
break ;
default :
2020-05-03 20:30:35 +02:00
case 'medium' :
list . push ( { name : 'font-size' , value : '1.36em' } ) ;
2019-01-10 15:39:37 +03:00
break ;
2018-10-23 01:05:09 +03:00
}
}
2020-05-03 20:30:35 +02:00
switch ( settings . dropShadow || '' ) {
case 'raised' :
list . push ( { name : 'text-shadow' , value : '-1px -1px white, 0px -1px white, -1px 0px white, 1px 1px black, 0px 1px black, 1px 0px black' } ) ;
break ;
case 'depressed' :
list . push ( { name : 'text-shadow' , value : '1px 1px white, 0px 1px white, 1px 0px white, -1px -1px black, 0px -1px black, -1px 0px black' } ) ;
break ;
case 'uniform' :
list . push ( { name : 'text-shadow' , value : '-1px 0px #000000, 0px 1px #000000, 1px 0px #000000, 0px -1px #000000' } ) ;
break ;
case 'none' :
list . push ( { name : 'text-shadow' , value : 'none' } ) ;
break ;
default :
case 'dropshadow' :
list . push ( { name : 'text-shadow' , value : '#000000 0px 0px 7px' } ) ;
break ;
}
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
const background = settings . textBackground || 'transparent' ;
if ( background ) {
list . push ( { name : 'background-color' , value : background } ) ;
2018-10-23 01:05:09 +03:00
}
2020-05-03 20:30:35 +02:00
const textColor = settings . textColor || '#ffffff' ;
if ( textColor ) {
list . push ( { name : 'color' , value : textColor } ) ;
}
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
switch ( settings . font || '' ) {
case 'typewriter' :
list . push ( { name : 'font-family' , value : '"Courier New",monospace' } ) ;
list . push ( { name : 'font-variant' , value : 'none' } ) ;
break ;
case 'print' :
list . push ( { name : 'font-family' , value : 'Georgia,Times New Roman,Arial,Helvetica,serif' } ) ;
list . push ( { name : 'font-variant' , value : 'none' } ) ;
break ;
case 'console' :
list . push ( { name : 'font-family' , value : 'Consolas,Lucida Console,Menlo,Monaco,monospace' } ) ;
list . push ( { name : 'font-variant' , value : 'none' } ) ;
break ;
case 'cursive' :
list . push ( { name : 'font-family' , value : 'Lucida Handwriting,Brush Script MT,Segoe Script,cursive,Quintessential,system-ui,-apple-system,BlinkMacSystemFont,sans-serif' } ) ;
list . push ( { name : 'font-variant' , value : 'none' } ) ;
break ;
case 'casual' :
list . push ( { name : 'font-family' , value : 'Gabriola,Segoe Print,Comic Sans MS,Chalkboard,Short Stack,system-ui,-apple-system,BlinkMacSystemFont,sans-serif' } ) ;
list . push ( { name : 'font-variant' , value : 'none' } ) ;
break ;
case 'smallcaps' :
list . push ( { name : 'font-family' , value : 'Copperplate Gothic,Copperplate Gothic Bold,Copperplate,system-ui,-apple-system,BlinkMacSystemFont,sans-serif' } ) ;
list . push ( { name : 'font-variant' , value : 'small-caps' } ) ;
break ;
default :
list . push ( { name : 'font-family' , value : 'inherit' } ) ;
list . push ( { name : 'font-variant' , value : 'none' } ) ;
break ;
2018-10-23 01:05:09 +03:00
}
2020-05-03 20:30:35 +02:00
return list ;
}
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
export function getStyles ( settings , isCue ) {
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
return {
text : getTextStyles ( settings , isCue ) ,
window : [ ]
} ;
}
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
function applyStyleList ( styles , elem ) {
2018-10-23 01:05:09 +03:00
2020-05-03 20:30:35 +02:00
for ( let i = 0 , length = styles . length ; i < length ; i ++ ) {
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
let style = styles [ i ] ;
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
elem . style [ style . name ] = style . value ;
2018-10-23 01:05:09 +03:00
}
2020-05-03 20:30:35 +02:00
}
2019-01-10 15:39:37 +03:00
2020-05-03 20:30:35 +02:00
export function applyStyles ( elements , appearanceSettings ) {
let styles = getStyles ( appearanceSettings ) ;
if ( elements . text ) {
applyStyleList ( styles . text , elements . text ) ;
}
if ( elements . window ) {
applyStyleList ( styles . window , elements . window ) ;
}
}
export default {
getStyles : getStyles ,
applyStyles : applyStyles
} ;