weizhenye / ASS

A lightweight JavaScript ASS subtitle renderer
https://ass.js.org
MIT License
535 stars 79 forks source link

Error showing some Unicode charicters #47

Closed yuygfgg closed 3 months ago

yuygfgg commented 3 months ago
截屏2024-07-25 20 50 40

轻音少女.se2.ep21.ass.zip

weizhenye commented 3 months ago

It works fine in mine.

Style: Default,ZhunYuan,68,&H00FFFFFF,&HF0000000,&H00ED2AAC,&H78E645B0,-1,0,0,0,100,100,3,0,1,3.15,1.8,2,45,45,15,1

The Default Style use Fontname ZhunYuan, if this font is not installed in your computer, browser will fallback to sans-serif, ASS.js doesn't handle any font loading or rendering.

Screen Shot 2024-07-25 at 21 51 50

You can open DevTools with F12 and uncheck the font-family to see if it's OK.

yuygfgg commented 3 months ago

It works fine in mine.

Style: Default,ZhunYuan,68,&H00FFFFFF,&HF0000000,&H00ED2AAC,&H78E645B0,-1,0,0,0,100,100,3,0,1,3.15,1.8,2,45,45,15,1

The Default Style use Fontname ZhunYuan, if this font is not installed in your computer, browser will fallback to sans-serif, ASS.js doesn't handle any font loading or rendering.

Screen Shot 2024-07-25 at 21 51 50

You can open DevTools with F12 and uncheck the font-family to see if it's OK.

Unchecking font-family fixed my problem. But I got a question: Other software, including iina and infuse, shows ass subtitle correctly even without fonts required. As you mentioned, browser will fall back to sans-serif. Why didn't that work?

And after installing ZhunYuan, the same problem still exsist if I check font-family.

截屏2024-07-25 22 10 48
weizhenye commented 3 months ago

Is your system Linux?

Check font-family and try these:

Will any of these work?

yuygfgg commented 3 months ago
  • ZhunYuan

Well, none of these work. And I'm on macos.

截屏2024-07-25 22 37 27 截屏2024-07-25 22 40 10

But I found that the following code works.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>字体测试</title>
<style>
  .zhunyuan {
    font-family: ZhunYuan;
  }
  .arial {
    font-family: Arial;
  }
  .sans-serif {
    font-family: sans-serif;
  }
</style>
</head>
<body>
  <h1>字体测试</h1>
  <p class="zhunyuan">这是一段使用 ZhunYuan 字体的测试文本。</p>
  <p class="arial">这是一段使用 Arial 字体的测试文本。</p>
  <p class="sans-serif">这是一段使用 sans-serif 字体的测试文本。</p>
</body>
</html>
截屏2024-07-25 22 38 43
yuygfgg commented 3 months ago

Well, the problem seems to be solved by uninstalling the 2 ZhunYuan fonts. I don't know why. Maybe the 2 fonts are somehow broken?

截屏2024-07-25 22 48 16
weizhenye commented 3 months ago

Do you install any ZhunYuan fonts before?

From my experience, after installing fonts, browser should be reopened to properly load the new font.

A possibility reason:

  1. You installed a broken ZhunYuan before
  2. 不太行… doesn't show in ASS.js, or in any other pages
  3. You installed a good ZhunYuan, but the ASS.js page is not reload, or the browser is not reopened, so it's not works
  4. You open a test page, which browser already properly load it, so it works
  5. You uninstalled all ZhunYuan fonts, so browser fallback to sans-serif and it works