svg-imp.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (C) 2004-2021 Artifex Software, Inc.
  2. //
  3. // This file is part of MuPDF.
  4. //
  5. // MuPDF is free software: you can redistribute it and/or modify it under the
  6. // terms of the GNU Affero General Public License as published by the Free
  7. // Software Foundation, either version 3 of the License, or (at your option)
  8. // any later version.
  9. //
  10. // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
  11. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. // details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
  17. //
  18. // Alternative licensing terms are available from the licensor.
  19. // For commercial licensing, see <https://www.artifex.com/> or contact
  20. // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
  21. // CA 94129, USA, for further information.
  22. #ifndef SOURCE_SVG_IMP_H
  23. #define SOURCE_SVG_IMP_H
  24. typedef struct svg_document_s svg_document;
  25. struct svg_document_s
  26. {
  27. fz_document super;
  28. fz_xml_doc *xml;
  29. fz_xml *root;
  30. fz_tree *idmap;
  31. float width;
  32. float height;
  33. fz_archive *zip; /* for locating external resources */
  34. char base_uri[2048];
  35. };
  36. const char *svg_lex_number(float *fp, const char *str);
  37. float svg_parse_number(const char *str, float min, float max, float inherit);
  38. float svg_parse_number_from_style(fz_context *ctx, svg_document *doc, const char *string, const char *name, float number);
  39. int svg_parse_enum_from_style(fz_context *ctx, svg_document *doc, const char *style, const char *att,
  40. int ecount, const char *etable[], int value);
  41. char *svg_parse_string_from_style(fz_context *ctx, svg_document *doc, const char *style, const char *att,
  42. char *buf, int buf_size, const char *value);
  43. /*
  44. Return length/coordinate in points.
  45. */
  46. float svg_parse_length(const char *str, float percent, float font_size);
  47. float svg_parse_angle(const char *str);
  48. void svg_parse_color_from_style(fz_context *ctx, svg_document *doc, const char *str,
  49. int *fill_is_set, float fill[3], int *stroke_is_set, float stroke[3]);
  50. void svg_parse_color(fz_context *ctx, svg_document *doc, const char *str, float *rgb);
  51. fz_matrix svg_parse_transform(fz_context *ctx, svg_document *doc, const char *str, fz_matrix transform);
  52. int svg_is_whitespace_or_comma(int c);
  53. int svg_is_whitespace(int c);
  54. int svg_is_alpha(int c);
  55. int svg_is_digit(int c);
  56. void svg_parse_document_bounds(fz_context *ctx, svg_document *doc, fz_xml *root);
  57. void svg_run_document(fz_context *ctx, svg_document *doc, fz_xml *root, fz_device *dev, fz_matrix ctm);
  58. #endif