diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-03-18 16:37:19 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-03-19 12:52:05 +0100 |
commit | 30bcbe60b93a0e4a697871f69e8367476796f27c (patch) | |
tree | 39c2fa6d826a866fe6a5692b6e3575956b41c44c /include/mupdf/fitz/output.h | |
parent | 4c2715a0bcecfed6ebdfee901920631b09364d7e (diff) | |
download | mupdf-30bcbe60b93a0e4a697871f69e8367476796f27c.tar.xz |
Implement our own vsnprintf variant.
The primary motivator for this is so that we can print floating point
values and get the full accuracy out, without having to print 1.5 as
1.5000000, and without getting 23e24 etc.
We only support %c, %f, %d, %o, %x and %s currently.
We only support the zero padding qualifier, for integers.
We do support some extensions:
%C turns values >=128 into UTF-8.
%M prints a fz_matrix.
%R prints a fz_rect.
%P prints a fz_point.
We also implement a fprintf variant on top of this to allow for
consistent results when using fz_output.
a
Diffstat (limited to 'include/mupdf/fitz/output.h')
-rw-r--r-- | include/mupdf/fitz/output.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h index 8b171f87..01d4d227 100644 --- a/include/mupdf/fitz/output.h +++ b/include/mupdf/fitz/output.h @@ -90,4 +90,20 @@ fz_write_byte(fz_output *out, int x) fz_write(out, &data, 1); } +/* + fz_vsnprintf: Our customised vsnprintf routine. Takes %c, %d, %o, %s, %x, as usual. + Modifiers are not supported except for zero-padding ints (e.g. %02d, %03o, %04x, etc). + %f and %g both output in "as short as possible hopefully lossless non-exponent" form, + see fz_ftoa for specifics. + %C outputs a utf8 encoded int. + %M outputs a fz_matrix*. %R outputs a fz_rect*. %P outputs a fz_point*. +*/ +int fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args); + +/* + fz_vfprintf: Our customised vfprintf routine. Same supported + format specifiers as for fz_vsnprintf. +*/ +int fz_vfprintf(fz_context *ctx, FILE *file, const char *fmt, va_list ap); + #endif |