summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mkvlib/ass.go42
-rw-r--r--mkvlib/c/README.md8
-rw-r--r--mkvlib/c/exports.go10
-rw-r--r--mkvlib/c/sdk.cs8
-rw-r--r--mkvlib/c/sdk.py5
-rw-r--r--mkvlib/mkv.go5
-rw-r--r--mkvlib/shared.go2
7 files changed, 61 insertions, 19 deletions
diff --git a/mkvlib/ass.go b/mkvlib/ass.go
index c29b281..705c82f 100644
--- a/mkvlib/ass.go
+++ b/mkvlib/ass.go
@@ -735,6 +735,28 @@ func (self *assProcessor) replaceFontNameInAss() bool {
return ec == 0
}
+func (self *assProcessor) createFontCache(p string) *fontCache {
+ _m := self.getFontName(p)
+ _fonts := make([][]string, len(_m))
+ _types := make([][]string, len(_m))
+ for k, v := range _m {
+ _list := make([]string, 0)
+ for _k, _ := range v[0] {
+ _list = append(_list, _k)
+ }
+ _fonts[k] = _list
+ _list = make([]string, 0)
+ for _k, _ := range v[1] {
+ _list = append(_list, _k)
+ }
+ _types[k] = _list
+ }
+ if len(_fonts) > 0 && len(_types) > 0 {
+ return &fontCache{p, _fonts, _types}
+ }
+ return nil
+}
+
func (self *assProcessor) createFontsCache(output string) []string {
cache := make([]fontCache, 0)
if !filepath.IsAbs(self._fonts) {
@@ -751,24 +773,10 @@ func (self *assProcessor) createFontsCache(output string) []string {
go func(x int) {
_item := fonts[x]
m.Lock()
- _m := self.getFontName(_item)
- _fonts := make([][]string, len(_m))
- _types := make([][]string, len(_m))
- for k, v := range _m {
- _list := make([]string, 0)
- for _k, _ := range v[0] {
- _list = append(_list, _k)
- }
- _fonts[k] = _list
- _list = make([]string, 0)
- for _k, _ := range v[1] {
- _list = append(_list, _k)
- }
- _types[k] = _list
- }
- if len(_fonts) > 0 && len(_types) > 0 {
+ c := self.createFontCache(_item)
+ if c != nil {
ok++
- cache = append(cache, fontCache{_item, _fonts, _types})
+ cache = append(cache, *c)
printLog(self.lcb, "Cache font (%d/%d) done.", ok, l)
} else {
el = append(el, _item)
diff --git a/mkvlib/c/README.md b/mkvlib/c/README.md
index 873a992..dc652f8 100644
--- a/mkvlib/c/README.md
+++ b/mkvlib/c/README.md
@@ -67,10 +67,16 @@
### 查询相关
- ```c
+ char* GetFontInfo(char* p);
+ //查询一个字体的信息
+ //p: 字体文件路径
+ //return: json格式的文件信息,如果出错会返回"null".
+ ```
+- ```c
char* GetMKVInfo(char* file);
//查询一个mkv文件内封的字幕和字体信息
//file: 文件路径
- //return: json格式的文件信息,如果出错会返回"null".
+ //return: json格式的字体信息,如果出错会返回"null".
```
- ```c
char* CheckSubset(char* file, logCallbac lcb);
diff --git a/mkvlib/c/exports.go b/mkvlib/c/exports.go
index c728b69..5cb8c0f 100644
--- a/mkvlib/c/exports.go
+++ b/mkvlib/c/exports.go
@@ -195,6 +195,16 @@ func Check(check, strict bool) {
getter.GetProcessorInstance().Check(check, strict)
}
+//export GetFontInfo
+func GetFontInfo(p *C.char) *C.char {
+ if !checkInstance() {
+ return cs("")
+ }
+ info := getter.GetProcessorInstance().GetFontInfo(gs(p))
+ data, _ := json.Marshal(info)
+ return cs(string(data))
+}
+
func cs(gs string) *C.char {
return C.CString(gs)
}
diff --git a/mkvlib/c/sdk.cs b/mkvlib/c/sdk.cs
index 1958ae1..9b5c165 100644
--- a/mkvlib/c/sdk.cs
+++ b/mkvlib/c/sdk.cs
@@ -61,6 +61,9 @@ public static class mkvlib
[DllImport("mkvlib.so")]
static extern bool CopyFontsFromCache(IntPtr subs, IntPtr dist, logCallback lcb);
+ [DllImport("mkvlib.so")]
+ static extern IntPtr GetFontInfo(IntPtr p);
+
#endregion
public static bool InitInstance(Action<string> lcb)
@@ -154,6 +157,11 @@ public static class mkvlib
Check(check, strict);
}
+ public static string GetFontInfo(string p)
+ {
+ return css(GetFontInfo(cs(p)));
+ }
+
public static string[] CreateFontsCache(string dir, string output, Action<string> lcb)
{
string result = css(CreateFontsCache(cs(dir), cs(output), _lcb(lcb)));
diff --git a/mkvlib/c/sdk.py b/mkvlib/c/sdk.py
index f9da485..613b115 100644
--- a/mkvlib/c/sdk.py
+++ b/mkvlib/c/sdk.py
@@ -84,6 +84,11 @@ def cache(ccs):
_ccs = dumps(ccs)
call(_ccs.encode())
+def getFontInfo(p):
+ call = lib.GetFontInfo
+ call.restype = c_char_p
+ return loads(call(p.encode()).decode())
+
def createFontsCache(dir, output, lcb):
call = lib.CreateFontsCache
diff --git a/mkvlib/mkv.go b/mkvlib/mkv.go
index 53e3161..379a905 100644
--- a/mkvlib/mkv.go
+++ b/mkvlib/mkv.go
@@ -374,6 +374,11 @@ func (self *mkvProcessor) CopyFontsFromCache(subs, dist string, lcb logCallback)
return obj.copyFontsFromCache()
}
+func (self *mkvProcessor) GetFontInfo(p string) *fontCache {
+ obj := new(assProcessor)
+ return obj.createFontCache(p)
+}
+
func (self *mkvProcessor) Cache(ccs []string) {
self.caches = ccs
}
diff --git a/mkvlib/shared.go b/mkvlib/shared.go
index 423a350..cfabdd0 100644
--- a/mkvlib/shared.go
+++ b/mkvlib/shared.go
@@ -11,7 +11,7 @@ import (
)
const libName = "mkvlib"
-const libVer = "v1.7.3"
+const libVer = "v1.7.4"
const LibFName = libName + " " + libVer