summaryrefslogtreecommitdiff
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
parent36b48b9123d8b77bd0aaab7bf2ba7e358aaf8bfa (diff)
update mkvlib:fix bugs & ignore case for font ext name.
-rw-r--r--mkvlib/ass.go24
-rw-r--r--mkvlib/shared.go2
-rw-r--r--mkvlib/utils.go2
3 files changed, 24 insertions, 4 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 {
diff --git a/mkvlib/shared.go b/mkvlib/shared.go
index 43904af..51072f2 100644
--- a/mkvlib/shared.go
+++ b/mkvlib/shared.go
@@ -11,7 +11,7 @@ import (
)
const libName = "mkvlib"
-const libVer = "v1.1.3"
+const libVer = "v1.1.4"
const LibFName = libName + " " + libVer
diff --git a/mkvlib/utils.go b/mkvlib/utils.go
index 461194b..46a505c 100644
--- a/mkvlib/utils.go
+++ b/mkvlib/utils.go
@@ -193,6 +193,6 @@ func findMKVs(dir string) []string {
}
func findFonts(dir string) []string {
- list, _ := findPath(dir, `\.((ttf)|(otf)|(ttc)|(fon))$`)
+ list, _ := findPath(dir, `\.((?i)(ttf)|(otf)|(ttc)|(fon))$`)
return list
}