Skip to content

Commit

Permalink
fix: font-size in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhenye committed Aug 4, 2024
1 parent aba114a commit c2c0ed5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
transform-origin: var(--ass-align-h) var(--ass-align-v);
}
.ASS-fix-font-size {
font-size: 2048px;
font-family: Arial;
line-height: normal;
width: 0;
Expand Down
9 changes: 6 additions & 3 deletions src/renderer/font-size.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// https://github.com/weizhenye/ASS/wiki/Font-Size-in-ASS

// It seems max line-height is 1200px in Firefox.
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
const unitsPerEm = isFirefox ? 512 : 2048;
const lineSpacing = Object.create(null);

export const $fixFontSize = document.createElement('div');
$fixFontSize.className = 'ASS-fix-font-size';
$fixFontSize.style.fontSize = `${unitsPerEm}px`;
const $span = document.createElement('span');
$span.textContent = '0';
$fixFontSize.append($span);

const unitsPerEm = 2048;
const lineSpacing = Object.create(null);

export function getRealFontSize(fn, fs) {
if (!lineSpacing[fn]) {
$span.style.fontFamily = fn;
Expand Down

0 comments on commit c2c0ed5

Please sign in to comment.