textspan.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @file
  3. * @brief @ref textspan_t, @ref textfont_t, @ref PostscriptAlias
  4. * @ingroup public_apis
  5. * @ingroup common_render
  6. */
  7. /*************************************************************************
  8. * Copyright (c) 2011 AT&T Intellectual Property
  9. * All rights reserved. This program and the accompanying materials
  10. * are made available under the terms of the Eclipse Public License v1.0
  11. * which accompanies this distribution, and is available at
  12. * https://www.eclipse.org/legal/epl-v10.html
  13. *
  14. * Contributors: Details at https://graphviz.org
  15. *************************************************************************/
  16. #pragma once
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define GV_TEXTFONT_FLAGS_WIDTH 7
  21. /* Bold, Italic, Underline, Sup, Sub, Strike */
  22. /* Stored in textfont_t.flags, which is GV_TEXTFONT_FLAGS_WIDTH bits, so full */
  23. /* Probably should be moved to textspan_t */
  24. #define HTML_BF (1 << 0)
  25. #define HTML_IF (1 << 1)
  26. #define HTML_UL (1 << 2)
  27. #define HTML_SUP (1 << 3)
  28. #define HTML_SUB (1 << 4)
  29. #define HTML_S (1 << 5)
  30. #define HTML_OL (1 << 6)
  31. typedef struct _PostscriptAlias {
  32. char* name;
  33. char* family;
  34. char* weight;
  35. char* stretch;
  36. char* style;
  37. int xfig_code;
  38. char* svg_font_family;
  39. char* svg_font_weight;
  40. char* svg_font_style;
  41. } PostscriptAlias;
  42. /* font information
  43. * If name or color is NULL, or size < 0, that attribute
  44. * is unspecified.
  45. */
  46. typedef struct {
  47. char* name;
  48. char* color;
  49. PostscriptAlias *postscript_alias;
  50. double size;
  51. unsigned int flags:GV_TEXTFONT_FLAGS_WIDTH; // HTML_UL, HTML_IF, HTML_BF, etc.
  52. unsigned int cnt:(sizeof(unsigned int) * 8 - GV_TEXTFONT_FLAGS_WIDTH);
  53. ///< reference count
  54. } textfont_t;
  55. /* atomic unit of text emitted using a single htmlfont_t */
  56. typedef struct {
  57. char *str; /* stored in utf-8 */
  58. textfont_t *font;
  59. void *layout;
  60. void (*free_layout) (void *layout); /* FIXME - this is ugly */
  61. double yoffset_layout, yoffset_centerline;
  62. pointf size;
  63. char just; ///< 'l' 'n' 'r'
  64. } textspan_t;
  65. #ifdef __cplusplus
  66. }
  67. #endif