Switch to using double for numbers, since they are also used to record lengths

and other potentially large contents.
This commit is contained in:
Michael R Sweet
2021-05-29 21:16:21 -04:00
parent 35d22705fa
commit a18b8fd606
13 changed files with 142 additions and 166 deletions

View File

@@ -44,7 +44,7 @@ typedef enum pdfio_linejoin_e // Line joining modes
PDFIO_LINEJOIN_BEVEL // Bevel joint
} pdfio_linejoin_t;
typedef float pdfio_matrix_t[3][2]; // Transform matrix
typedef double pdfio_matrix_t[3][2]; // Transform matrix
typedef enum pdfio_textrendering_e // Text rendering modes
{
@@ -59,16 +59,16 @@ typedef enum pdfio_textrendering_e // Text rendering modes
PDFIO_TEXTRENDERING_TEXT_PATH // Add text to path (invisible)
} pdfio_textrendering_t;
extern const float pdfioAdobeRGBGamma;
extern const double pdfioAdobeRGBGamma;
// AdobeRGB gamma
extern const float pdfioAdobeRGBWhitePoint[];
extern const double pdfioAdobeRGBWhitePoint[];
// AdobeRGB white point
extern const float pdfioDisplayP3Gamma;
extern const double pdfioDisplayP3Gamma;
// Display P3 gamma
extern const float pdfioDisplayP3WhitePoint[];
extern const double pdfioDisplayP3WhitePoint[];
// Display P3 white point
extern const float pdfioSRGBGamma; // sRGB gamma
extern const float pdfioSRGBWhitePoint[];
extern const double pdfioSRGBGamma; // sRGB gamma
extern const double pdfioSRGBWhitePoint[];
// sRGB white point
@@ -79,55 +79,55 @@ extern const float pdfioSRGBWhitePoint[];
// PDF content drawing functions...
extern bool pdfioContentBeginText(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentClip(pdfio_stream_t *st, bool even_odd) PDFIO_PUBLIC;
extern bool pdfioContentDrawImage(pdfio_stream_t *st, const char *name, float x, float y, float w, float h) PDFIO_PUBLIC;
extern bool pdfioContentDrawImage(pdfio_stream_t *st, const char *name, double x, double y, double w, double h) PDFIO_PUBLIC;
extern bool pdfioContentEndText(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentFill(pdfio_stream_t *st, bool even_odd) PDFIO_PUBLIC;
extern bool pdfioContentFillAndStroke(pdfio_stream_t *st, bool even_odd) PDFIO_PUBLIC;
extern bool pdfioContentMatrixConcat(pdfio_stream_t *st, pdfio_matrix_t m) PDFIO_PUBLIC;
extern bool pdfioContentMatrixRotate(pdfio_stream_t *st, float degrees) PDFIO_PUBLIC;
extern bool pdfioContentMatrixScale(pdfio_stream_t *st, float sx, float sy) PDFIO_PUBLIC;
extern bool pdfioContentMatrixTranslate(pdfio_stream_t *st, float tx, float ty) PDFIO_PUBLIC;
extern bool pdfioContentMatrixRotate(pdfio_stream_t *st, double degrees) PDFIO_PUBLIC;
extern bool pdfioContentMatrixScale(pdfio_stream_t *st, double sx, double sy) PDFIO_PUBLIC;
extern bool pdfioContentMatrixTranslate(pdfio_stream_t *st, double tx, double ty) PDFIO_PUBLIC;
extern bool pdfioContentPathClose(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve(pdfio_stream_t *st, float x1, float y1, float x2, float y2, float x3, float y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve13(pdfio_stream_t *st, float x1, float y1, float x3, float y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve23(pdfio_stream_t *st, float x2, float y2, float x3, float y3) PDFIO_PUBLIC;
extern bool pdfioContentPathLineTo(pdfio_stream_t *st, float x, float y) PDFIO_PUBLIC;
extern bool pdfioContentPathMoveTo(pdfio_stream_t *st, float x, float y) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve(pdfio_stream_t *st, double x1, double y1, double x2, double y2, double x3, double y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve13(pdfio_stream_t *st, double x1, double y1, double x3, double y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve23(pdfio_stream_t *st, double x2, double y2, double x3, double y3) PDFIO_PUBLIC;
extern bool pdfioContentPathLineTo(pdfio_stream_t *st, double x, double y) PDFIO_PUBLIC;
extern bool pdfioContentPathMoveTo(pdfio_stream_t *st, double x, double y) PDFIO_PUBLIC;
extern bool pdfioContentPathRect(pdfio_stream_t *st, pdfio_rect_t *rect) PDFIO_PUBLIC;
extern bool pdfioContentRestore(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentSave(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, int phase, int on, int off) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, float c, float m, float y, float k) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorSpace(pdfio_stream_t *st, const char *name) PDFIO_PUBLIC;
extern bool pdfioContentSetFlatness(pdfio_stream_t *st, float f) PDFIO_PUBLIC;
extern bool pdfioContentSetFlatness(pdfio_stream_t *st, double f) PDFIO_PUBLIC;
extern bool pdfioContentSetLineCap(pdfio_stream_t *st, pdfio_linecap_t lc) PDFIO_PUBLIC;
extern bool pdfioContentSetLineJoin(pdfio_stream_t *st, pdfio_linejoin_t lj) PDFIO_PUBLIC;
extern bool pdfioContentSetLineWidth(pdfio_stream_t *st, float width) PDFIO_PUBLIC;
extern bool pdfioContentSetMiterLimit(pdfio_stream_t *st, float limit) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceCMYK(pdfio_stream_t *st, float c, float m, float y, float k) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetLineWidth(pdfio_stream_t *st, double width) PDFIO_PUBLIC;
extern bool pdfioContentSetMiterLimit(pdfio_stream_t *st, double limit) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorSpace(pdfio_stream_t *st, const char *name) PDFIO_PUBLIC;
extern bool pdfioContentSetTextCharacterSpacing(pdfio_stream_t *st, float spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextFont(pdfio_stream_t *st, const char *name, float size) PDFIO_PUBLIC;
extern bool pdfioContentSetTextLeading(pdfio_stream_t *st, float leading) PDFIO_PUBLIC;
extern bool pdfioContentSetTextCharacterSpacing(pdfio_stream_t *st, double spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextFont(pdfio_stream_t *st, const char *name, double size) PDFIO_PUBLIC;
extern bool pdfioContentSetTextLeading(pdfio_stream_t *st, double leading) PDFIO_PUBLIC;
extern bool pdfioContentSetTextMatrix(pdfio_stream_t *st, pdfio_matrix_t m) PDFIO_PUBLIC;
extern bool pdfioContentSetTextRenderingMode(pdfio_stream_t *st, pdfio_textrendering_t mode) PDFIO_PUBLIC;
extern bool pdfioContentSetTextRise(pdfio_stream_t *st, float rise) PDFIO_PUBLIC;
extern bool pdfioContentSetTextWordSpacing(pdfio_stream_t *st, float spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextXScaling(pdfio_stream_t *st, float percent) PDFIO_PUBLIC;
extern bool pdfioContentSetTextRise(pdfio_stream_t *st, double rise) PDFIO_PUBLIC;
extern bool pdfioContentSetTextWordSpacing(pdfio_stream_t *st, double spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextXScaling(pdfio_stream_t *st, double percent) PDFIO_PUBLIC;
extern bool pdfioContentStroke(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveLine(pdfio_stream_t *st, float tx, float ty) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveTo(pdfio_stream_t *st, float tx, float ty) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveLine(pdfio_stream_t *st, double tx, double ty) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveTo(pdfio_stream_t *st, double tx, double ty) PDFIO_PUBLIC;
extern bool pdfioContentTextNextLine(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentTextShow(pdfio_stream_t *st, const char *s, bool new_line) PDFIO_PUBLIC;
extern bool pdfioContentTextShowJustified(pdfio_stream_t *st, size_t num_fragments, const float *offsets, const char * const *fragments) PDFIO_PUBLIC;
extern bool pdfioContentTextShowJustified(pdfio_stream_t *st, size_t num_fragments, const double *offsets, const char * const *fragments) PDFIO_PUBLIC;
// Resource helpers...
extern pdfio_obj_t *pdfioFileCreateFontObject(pdfio_file_t *pdf, const char *filename) PDFIO_PUBLIC;
@@ -135,12 +135,12 @@ extern pdfio_obj_t *pdfioFileCreateICCProfileObject(pdfio_file_t *pdf, const cha
extern pdfio_obj_t *pdfioFileCreateImageObject(pdfio_file_t *pdf, const char *filename, bool interpolate) PDFIO_PUBLIC;
// Image object helpers...
extern float pdfioImageGetHeight(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern float pdfioImageGetWidth(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern double pdfioImageGetHeight(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern double pdfioImageGetWidth(pdfio_obj_t *obj) PDFIO_PUBLIC;
// Page dictionary helpers...
extern bool pdfioPageDictAddICCColorSpace(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj) PDFIO_PUBLIC;
extern bool pdfioPageDictAddCalibratedColorSpace(pdfio_dict_t *dict, const char *name, size_t num_colors, const float *white_point, float gamma) PDFIO_PUBLIC;
extern bool pdfioPageDictAddCalibratedColorSpace(pdfio_dict_t *dict, const char *name, size_t num_colors, const double *white_point, double gamma) PDFIO_PUBLIC;
extern bool pdfioPageDictAddFont(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj) PDFIO_PUBLIC;
extern bool pdfioPageDictAddImage(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj) PDFIO_PUBLIC;