summaryrefslogtreecommitdiff
path: root/mkvlib/ass.go
diff options
context:
space:
mode:
authorb5f0d6c3 <[email protected]>2021-11-02 12:59:36 +0800
committerb5f0d6c3 <[email protected]>2021-11-02 12:59:36 +0800
commit9f2aace19f7763ad9eb52eca000a32c4dd8e1aff (patch)
tree180faa5a602a676053b81885a4926d5feb61def9 /mkvlib/ass.go
parent36b48b9123d8b77bd0aaab7bf2ba7e358aaf8bfa (diff)
update mkvlib:fix bugs & ignore case for font ext name.
Diffstat (limited to 'mkvlib/ass.go')
-rw-r--r--mkvlib/ass.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/mkvlib/ass.go b/mkvlib/ass.go
index 00ff7f1..e529f73 100644
--- a/mkvlib/ass.go
+++ b/mkvlib/ass.go
@@ -1,6 +1,7 @@
package mkvlib
import (
+ "bytes"
"encoding/binary"
"fmt"
"github.com/antchfx/xmlquery"
@@ -286,9 +287,17 @@ func (self *assProcessor) createFontSubset(font *fontInfo) bool {
args = append(args, "--name-languages="+"*")
args = append(args, "--font-number="+font.index)
args = append(args, font.file)
- if p, err := newProcess(nil, nil, nil, "", pyftsubset, args...); err == nil {
+ buf := bytes.NewBufferString("")
+ if p, err := newProcess(nil, nil, buf, "", pyftsubset, args...); err == nil {
s, err := p.Wait()
ok = err == nil && s.ExitCode() == 0
+ if strings.Contains(buf.String(), "WARNING: mort NOT subset; don't know how to subset; dropped") {
+ _ = os.Remove(_fn)
+ if len(findFonts(self.output)) == 0 {
+ _ = os.RemoveAll(self.output)
+ }
+ ok = false
+ }
}
if !ok {
printLog(self.lcb, `Failed to subset font: "%s"[%s].`, n, font.index)
@@ -359,8 +368,19 @@ func (self *assProcessor) changeFontName(font *fontInfo) bool {
args = append(args, "-o", font.sFont)
args = append(args, fn)
ok := false
- if p, err := newProcess(os.Stdin, nil, nil, "", ttx, args...); err == nil {
+ buf := bytes.NewBufferString("")
+ if p, err := newProcess(nil, nil, buf, "", ttx, args...); err == nil {
+ r := true
+ go func() {
+ for r {
+ time.Sleep(500 * time.Millisecond)
+ if strings.Contains(buf.String(), "(Hit any key to exit)") {
+ _ = p.Kill()
+ }
+ }
+ }()
s, err := p.Wait()
+ r = false
ok = err == nil && s.ExitCode() == 0
}
if !ok {