ws-apifix: an outline font saved as BMFont writes its pages (opts.files; without a destination F.save returns them as a third value { [page file] = PNG bytes }; caps.extraFiles); pages named after the destination
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
4557a3c792
commit
2abada340b
6 files changed
+83
-9
No files matched your search
+10
-3
@@ -557,8 +557,10 @@ function encodeTextures(scene: any): Err.Err?
|
||||
return nil
|
||||
end
|
||||
|
||||
-- save(value, dest?, opts?) -> buffer (no dest) | true (written to dest) | nil, Err
|
||||
function F.save(value: any, dest: string?, opts: Options?): (any, Err.Err?)
|
||||
-- save(value, dest?, opts?) -> buffer (no dest) | true (written to dest) | nil, Err. Formats that write extra files
|
||||
-- (caps.extraFiles: bmfont pages) return them without a dest as a third value { [file name] = bytes } (or fill the
|
||||
-- caller's opts.files); with a dest they are written next to it.
|
||||
function F.save(value: any, dest: string?, opts: Options?): (any, Err.Err?, { [string]: any }?)
|
||||
local o: Options = opts or {}
|
||||
local entry, m, err, key = encoderFor(value, dest, o)
|
||||
if not entry then
|
||||
@@ -573,6 +575,8 @@ function F.save(value: any, dest: string?, opts: Options?): (any, Err.Err?)
|
||||
if o.files == nil then
|
||||
o.files = {}
|
||||
end
|
||||
elseif o.files == nil and entry.caps.extraFiles then
|
||||
o.files = {} -- returned as the third value: F.save(ttf, nil, { format = "bmfont" }) -> fnt, nil, pages
|
||||
end
|
||||
if entry.category == "video" and type(value) == "table" and value.kind == "image" then
|
||||
local v, verr = F.video.fromImage(value)
|
||||
@@ -624,6 +628,9 @@ function F.save(value: any, dest: string?, opts: Options?): (any, Err.Err?)
|
||||
end
|
||||
return true
|
||||
end
|
||||
if type(o.files) == "table" and o.files ~= (opts and opts.files) and next(o.files) ~= nil then
|
||||
return buf, nil, o.files
|
||||
end
|
||||
return buf
|
||||
end
|
||||
|
||||
@@ -637,7 +644,7 @@ function F.saveString(value: any, opts: Options?): (string?, Err.Err?)
|
||||
end
|
||||
|
||||
-- convert(src, format, opts?) -> buffer (or true with opts.out = a path) | nil, Err. opts go to both load and save.
|
||||
function F.convert(src: any, format: string, opts: Options?): (any, Err.Err?)
|
||||
function F.convert(src: any, format: string, opts: Options?): (any, Err.Err?, { [string]: any }?)
|
||||
local o: Options = opts or {}
|
||||
local value, err = F.load(src, o)
|
||||
if value == nil then
|
||||
|
||||
Reference in new issue
Block a user