Skip to content

Commit

Permalink
Line spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
luxluth committed Jul 10, 2023
1 parent bf96c37 commit 33b963a
Showing 1 changed file with 7 additions and 32 deletions.
39 changes: 7 additions & 32 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,6 @@ export class Renderer {
});
}

/*
type SingleStyle = {
Name: string;
Fontname: string;
Fontsize: string;
PrimaryColour: string;
SecondaryColour: string;
OutlineColour: string;
BackColour: string;
Bold: string;
Italic: string;
Underline: string;
StrikeOut: string;
ScaleX: string;
ScaleY: string;
Spacing: string;
Angle: string;
BorderStyle: string;
Outline: string;
Shadow: string;
Alignment: string;
MarginL: string;
MarginR: string;
MarginV: string;
Encoding: string;
}
*/

showText(Text: ParsedASSEventText, style: SingleStyle) {
// console.debug(style.Name, Text)
const text = Text.parsed[0]?.text as string
Expand Down Expand Up @@ -124,7 +96,7 @@ export class Renderer {

let tweaks = this.teawksDrawSettings(tags, fontDescriptor);
if (tweaks.tweaked) {
console.debug("tweaks", tweaks)
// console.debug("tweaks", tweaks)

if (typeof tweaks.primaryColor !== "undefined") { this.ctx.fillStyle = tweaks.primaryColor }
if (typeof tweaks.secondaryColor !== "undefined") { this.ctx.strokeStyle = tweaks.secondaryColor }
Expand Down Expand Up @@ -226,7 +198,7 @@ export class Renderer {
fontDescriptor.strikeout = strikeOut;
}

console.debug("new Font", `${fontDescriptor.bold ? "bold" : ""} ${fontDescriptor.italic ? "italic" : ""} ${fontDescriptor.fontsize}px ${fontDescriptor.fontname}`)
// console.debug("new Font", `${fontDescriptor.bold ? "bold" : ""} ${fontDescriptor.italic ? "italic" : ""} ${fontDescriptor.fontsize}px ${fontDescriptor.fontname}`)

return {
tweaked,
Expand Down Expand Up @@ -297,10 +269,11 @@ export class Renderer {
break;
}
if (this.ctx.lineWidth > 0) {
// console.debug("strokeText", lineWidth);
this.ctx.strokeText(line, x, y);
}
this.ctx.fillText(line, x, y);
y += lineHeight + lineHeight / lines.length;
y += lineHeight
})

this.ctx.lineWidth = 0;
Expand Down Expand Up @@ -351,10 +324,12 @@ export class Renderer {
break;
}
if (this.ctx.lineWidth > 0) {
console.debug("strokeText", lineWidth);
this.ctx.strokeText(line, x, y);
}
this.ctx.fillText(line, x, y);
y += lineHeight;
// TODO: add line spacing
y += lineHeight + this.ctx.lineWidth;
})

this.ctx.lineWidth = 0;
Expand Down

0 comments on commit 33b963a

Please sign in to comment.