diff options
author | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-11-29 16:53:01 +0000 |
---|---|---|
committer | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-11-29 16:53:01 +0000 |
commit | 87fa1a78e323cd68189519e3413403f4423491a4 (patch) | |
tree | 0b9180dbb194480deff71dd71f5fccce8902071d | |
parent | 1be74e0b703a569fee0129b0560f4e5b92da7f5b (diff) |
iconv: copy extra data verbatim to allow font conversion/compression
-rw-r--r-- | sys/man/1/crop | 7 | ||||
-rw-r--r-- | sys/src/cmd/iconv.c | 23 |
2 files changed, 20 insertions, 10 deletions
diff --git a/sys/man/1/crop b/sys/man/1/crop index c1a676ce0..ce8ce8966 100644 --- a/sys/man/1/crop +++ b/sys/man/1/crop @@ -114,8 +114,11 @@ The default color is black. .I Iconv changes the format of pixels in the image .I file -(default standard input) and writes the resulting image to standard output. -Pixels in the image are converted according to the channel descriptor +(default standard input) and writes the resulting image to standard +output. Any extra data following the source image is copied verbatim, +which allows converting fonts without losing subfont header and +character information. Pixels in the image are converted according to +the channel descriptor .IR chandesc , (see .IR image (6)). diff --git a/sys/src/cmd/iconv.c b/sys/src/cmd/iconv.c index 5a9552005..cf03d0268 100644 --- a/sys/src/cmd/iconv.c +++ b/sys/src/cmd/iconv.c @@ -40,9 +40,10 @@ void main(int argc, char *argv[]) { char *tostr, *file; - int fd, uncompressed; + int fd, uncompressed, r; ulong tochan; Memimage *m, *n; + uchar extra[8192]; tostr = nil; uncompressed = 0; @@ -60,24 +61,20 @@ main(int argc, char *argv[]) memimageinit(); file = "<stdin>"; - m = nil; - + fd = 0; switch(argc){ case 0: - m = readmemimage(0); break; case 1: - file = argv[0]; - fd = open(file, OREAD); + fd = open(file = argv[0], OREAD); if(fd < 0) sysfatal("can't open %s: %r", file); - m = readmemimage(fd); - close(fd); break; default: usage(); } + m = readmemimage(fd); if(m == nil) sysfatal("can't read %s: %r", file); @@ -98,5 +95,15 @@ main(int argc, char *argv[]) writeuncompressed(1, n); else writememimage(1, n); + + for(;;){ + if((r = read(fd, extra, sizeof(extra))) < 0) + sysfatal("read failed: %r"); + if(r == 0) + break; + if(write(1, extra, r) != r) + sysfatal("write failed: %r"); + } + exits(nil); } |