@@ -20,12 +20,6 @@ function shadeColor2(color, percent) {
20
20
return "#" + ( 0x1000000 + ( Math . round ( ( t - R ) * p ) + R ) * 0x10000 + ( Math . round ( ( t - G ) * p ) + G ) * 0x100 + ( Math . round ( ( t - B ) * p ) + B ) ) . toString ( 16 ) . slice ( 1 ) ;
21
21
}
22
22
23
- //function trimArray(arr) {
24
- // for(let i=0; i < arr.length; i++)
25
- // arr[i] = arr[i].trim();
26
- // return arr;
27
- //}
28
-
29
23
30
24
let Printer = {
31
25
init : ( db ) => {
@@ -54,8 +48,6 @@ let Printer = {
54
48
Printer . printBackgrounds ( dd )
55
49
}
56
50
57
- console . log ( dd )
58
-
59
51
pdfMake . createPdf ( dd ) . open ( )
60
52
61
53
} ,
@@ -445,15 +437,14 @@ let Printer = {
445
437
context . textBaseline = 'middle' ;
446
438
447
439
let _width = context . measureText ( str ) . width
448
- console . log ( _width )
449
440
450
441
if ( _width > ( 225 - ( style . margins * 2 ) ) ) {
451
442
var _splitPoint = 0
452
443
let _words = str . split ( " " )
453
444
454
445
// if we're breaking strings, look for a natural breaking point
455
446
if ( str . indexOf ( '(' ) > - 1 ) {
456
- const chrToLookFor = ( str . startsWith ( '(' ) ? ')' : '(' )
447
+ const chrToLookFor = ( str . startsWith ( '(' ) || str . slice ( 1 , 2 ) === '(' ? ')' : '(' )
457
448
for ( let i = 0 ; i < _words . length ; i ++ ) {
458
449
if ( _words [ i ] . indexOf ( chrToLookFor ) > - 1 ) {
459
450
_splitPoint = i
@@ -516,13 +507,13 @@ let Printer = {
516
507
517
508
//copy the style definitions from either the default or the override
518
509
if ( Object . keys ( title ) . includes ( 'styleOverride' ) ) {
519
- for ( let key of [ 'style' , 'primaryColor' , 'titleFillColor ' , 'artistFillColor ' ] ) {
510
+ for ( let key of [ 'style' , 'primaryColor' , 'shadeTitle ' , 'shadeArtist ' ] ) {
520
511
formattedTitle [ key ] = title . styleOverride [ key ]
521
512
}
522
513
font = StyleDefines . fonts [ title . styleOverride . font ]
523
514
style = StyleDefines . styles [ title . styleOverride . style ]
524
515
} else {
525
- for ( let key of [ 'style' , 'primaryColor' , 'titleFillColor ' , 'artistFillColor ' ] ) {
516
+ for ( let key of [ 'style' , 'primaryColor' , 'shadeTitle ' , 'shadeArtist ' ] ) {
526
517
formattedTitle [ key ] = jsmeta . options [ key ]
527
518
}
528
519
font = StyleDefines . fonts [ jsmeta . options . font ]
@@ -541,13 +532,13 @@ let Printer = {
541
532
542
533
//provide the correct shades for fills
543
534
544
- if ( formattedTitle . titleFillColor === true ) {
535
+ if ( formattedTitle . shadeTitle === true ) {
545
536
formattedTitle . titleTint = shadeColor2 ( StyleDefines . colors [ formattedTitle . primaryColor ] . primary , 0.8 )
546
537
} else {
547
538
formattedTitle . titleTint = '#ffffff'
548
539
}
549
540
550
- if ( formattedTitle . artistFillColor === true ) {
541
+ if ( formattedTitle . shadeArtist === true ) {
551
542
formattedTitle . artistTint = shadeColor2 ( StyleDefines . colors [ formattedTitle . primaryColor ] . primary , 0.8 )
552
543
} else {
553
544
formattedTitle . artistTint = '#ffffff'
@@ -561,141 +552,13 @@ let Printer = {
561
552
bside : font . margins . bside [ ( ( formattedTitle . bwrap ) ?0 :1 ) ]
562
553
}
563
554
564
- console . log ( formattedTitle )
565
555
//add the title to
566
556
formattedTitles . push ( formattedTitle )
567
557
}
568
558
569
559
//return the formatted titles
570
560
return formattedTitles
571
561
572
- /*
573
- 'primaryColor','font','allCaps','quotes','titleFillColor','artistFillColor'
574
- */
575
-
576
- /*
577
- var textSizer=document.body.appendChild(crel('span'));//,{'style':'font-family:Arial;font-size:10.5pt;font-weight:bold','id':'text-sizer'}));
578
- var toArray=false;
579
- if(!Array.isArray(titles)) {
580
- titles=[titles];
581
- toArray=true;
582
- }
583
- titles.forEach(function(e){
584
- e.style=Printer.getStyle(((e.style)?e.style:false));
585
-
586
- let k=['primaryColor','font','allCaps','quotes','titleFillColor','artistFillColor'];
587
- let ek = Object.keys(e)
588
- k.forEach(function(key){
589
- if(ek.includes(key)) {
590
- e.style[key]=e[key];
591
- }
592
- delete(e[key]);
593
- });
594
- e.style.font=titleCreator.getFont(((e.font)?e.font:database.options.get('font')));
595
-
596
- if (e.style.titleFillColor === true) {
597
- e.style.titleTint=shadeColor2(e.style.primaryColor, 0.8)
598
- } else {
599
- e.style.titleTint='#ffffff'
600
- }
601
-
602
- if (e.style.artistFillColor === true) {
603
- e.style.artistTint=shadeColor2(e.style.primaryColor, 0.8)
604
- } else {
605
- e.style.artistTint='#ffffff'
606
- }
607
-
608
- var awrap=false,bwrap=false;
609
- if(e.allCaps || (e.allCaps==null && e.style.allCaps)) {
610
- e.aside=e.aside.toUpperCase();
611
- e.bside=e.bside.toUpperCase();
612
- e.artist=e.artist.toUpperCase();
613
- e.artistb=e.artistb.toUpperCase();
614
- }
615
- textSizer.style.fontFamily=e.style.font.name;
616
-
617
- var sq=((e.quotes || (e.quotes==null && e.style.quotes))?true:false);
618
-
619
- //if there's no "/" and there are parethases that are not at the start and end of the entire string
620
- if(e.aside.indexOf('/')==-1 && (e.aside.indexOf('(')>=0 || e.aside.indexOf(')')>=0) && !(e.aside.indexOf('(')==0 && e.aside.indexOf(')')==e.aside.length-1)) {
621
- //split based on the parenthases
622
- var x;
623
- if(e.aside.indexOf(')')==e.aside.length-1) {
624
- x=trimArray(e.aside.split("("));
625
- if(sq)
626
- x[0]='"'+x[0]+'"';
627
- x=x.join("\n(");
628
- } else {
629
- x=trimArray(e.aside.split(")"));
630
- if(sq)
631
- x[1]='"'+x[1]+'"';
632
- x=x.join(")\n");
633
- }
634
- textSizer.innerHTML=x.replace('\n','<br>');
635
- let w = textSizer.offsetWidth;
636
- if(w <= e.style.maxwidth) //if the name is too long (with the break around parenthases) then ignore the break (best chance of getting it in two lines)
637
- e.aside = x;
638
- awrap=true;
639
- } else {
640
- //if there's a "/""
641
- if(e.aside.indexOf('/')>=1) {
642
- var xa = trimArray(e.aside.split('/'));
643
- if(sq)
644
- for(let i=0; i < xa.length; i++) xa[i]='"'+xa[i]+'"';
645
- e.aside=xa.join("\n");
646
- awrap=true;
647
- } else {
648
- //just a single line of text
649
-
650
- textSizer.innerHTML=e.aside;
651
- let w = textSizer.offsetWidth;
652
- if(w > e.style.maxwidth) awrap = true;
653
- if(sq) e.aside='"'+e.aside+'"';
654
- }
655
- }
656
-
657
- if(e.bside.indexOf('/')==-1 && (e.bside.indexOf('(')>=0 || e.bside.indexOf(')')>=0) && !(e.bside.indexOf('(')==0 && e.bside.indexOf(')')==e.bside.length-1)) {
658
- var xb;
659
- if(e.bside.indexOf(')')==e.bside.length-1) {
660
- xb = trimArray(e.bside.split("("));
661
- if(sq)
662
- xb[0]='"'+xb[0]+'"';
663
- xb=xb.join("\n(");
664
- } else {
665
- xb=trimArray(e.bside.split(")"));
666
- if(sq)
667
- xb[1]='"'+xb[1]+'"';
668
- xb=xb.join(")\n");
669
- }
670
- textSizer.innerHTML=xb.replace('\n','<br>');
671
- let w = textSizer.offsetWidth;
672
- if(w <= e.style.maxwidth) //if the name is too long (with the break around parenthases) then ignore the break (best chance of getting it in two lines)
673
- e.bside = xb;
674
- bwrap = true;
675
- } else {
676
- if(e.bside.indexOf('/')>=1) {
677
- var xc = trimArray(e.bside.split('/'));
678
- if(sq)
679
- for(let i=0; i < xc.length; i++) xc[i]='"'+xc[i]+'"';
680
- e.bside=xc.join("\n");
681
- bwrap = true;
682
- } else {
683
- textSizer.innerText = e.bside;
684
- let w = textSizer.offsetWidth;
685
- if(w > e.style.maxwidth) bwrap = true;
686
- if(sq) e.bside = '"' + e.bside + '"';
687
- }
688
- }
689
- e.style.font.margins={
690
- aside:e.style.font.margins.aside[((awrap)?0:1)],
691
- artist:e.style.font.margins.artist[0],
692
- bside:e.style.font.margins.bside[((bwrap)?0:1)]
693
- }
694
- });
695
- textSizer.parentNode.removeChild(textSizer);
696
-
697
- if(toArray) titles=titles[0];
698
- */
699
562
}
700
563
}
701
564
0 commit comments