SDL_Pango-0.1.2-API-adds.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. --- src/SDL_Pango.c 2004-12-10 10:06:33.000000000 +0100
  2. +++ src/SDL_Pango.c 2006-09-24 22:46:24.000000000 +0200
  3. @@ -723,13 +723,8 @@
  4. SDL_UnlockSurface(surface);
  5. }
  6. -/*!
  7. - Create a context which contains Pango objects.
  8. -
  9. - @return A pointer to the context as a SDLPango_Context*.
  10. -*/
  11. SDLPango_Context*
  12. -SDLPango_CreateContext()
  13. +SDLPango_CreateContext_GivenFontDesc(const char* font_desc)
  14. {
  15. SDLPango_Context *context = g_malloc(sizeof(SDLPango_Context));
  16. G_CONST_RETURN char *charset;
  17. @@ -743,8 +738,7 @@
  18. pango_context_set_language (context->context, pango_language_from_string (charset));
  19. pango_context_set_base_dir (context->context, PANGO_DIRECTION_LTR);
  20. - context->font_desc = pango_font_description_from_string(
  21. - MAKE_FONT_NAME (DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE));
  22. + context->font_desc = pango_font_description_from_string(font_desc);
  23. context->layout = pango_layout_new (context->context);
  24. @@ -762,6 +756,17 @@
  25. }
  26. /*!
  27. + Create a context which contains Pango objects.
  28. +
  29. + @return A pointer to the context as a SDLPango_Context*.
  30. +*/
  31. +SDLPango_Context*
  32. +SDLPango_CreateContext()
  33. +{
  34. + SDLPango_CreateContext_GivenFontDesc(MAKE_FONT_NAME(DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE));
  35. +}
  36. +
  37. +/*!
  38. Free a context.
  39. @param *context [i/o] Context to be free
  40. @@ -1053,6 +1058,20 @@
  41. pango_layout_set_font_description (context->layout, context->font_desc);
  42. }
  43. +void
  44. +SDLPango_SetText_GivenAlignment(
  45. + SDLPango_Context *context,
  46. + const char *text,
  47. + int length,
  48. + SDLPango_Alignment alignment)
  49. +{
  50. + pango_layout_set_attributes(context->layout, NULL);
  51. + pango_layout_set_text (context->layout, text, length);
  52. + pango_layout_set_auto_dir (context->layout, TRUE);
  53. + pango_layout_set_alignment (context->layout, alignment);
  54. + pango_layout_set_font_description (context->layout, context->font_desc);
  55. +}
  56. +
  57. /*!
  58. Set plain text to context.
  59. Text must be utf-8.
  60. @@ -1067,11 +1086,7 @@
  61. const char *text,
  62. int length)
  63. {
  64. - pango_layout_set_attributes(context->layout, NULL);
  65. - pango_layout_set_text (context->layout, text, length);
  66. - pango_layout_set_auto_dir (context->layout, TRUE);
  67. - pango_layout_set_alignment (context->layout, PANGO_ALIGN_LEFT);
  68. - pango_layout_set_font_description (context->layout, context->font_desc);
  69. + SDLPango_SetText_GivenAlignment(context, text, length, SDLPANGO_ALIGN_LEFT);
  70. }
  71. /*!
  72. --- src/SDL_Pango.h 2004-12-10 10:06:33.000000000 +0100
  73. +++ src/SDL_Pango.h 2006-09-24 22:46:01.000000000 +0200
  74. @@ -109,12 +109,20 @@
  75. SDLPANGO_DIRECTION_NEUTRAL /*! Neutral */
  76. } SDLPango_Direction;
  77. -
  78. +/*!
  79. + Specifies alignment of text. See Pango reference for detail
  80. +*/
  81. +typedef enum {
  82. + SDLPANGO_ALIGN_LEFT,
  83. + SDLPANGO_ALIGN_CENTER,
  84. + SDLPANGO_ALIGN_RIGHT
  85. +} SDLPango_Alignment;
  86. extern DECLSPEC int SDLCALL SDLPango_Init();
  87. extern DECLSPEC int SDLCALL SDLPango_WasInit();
  88. +extern DECLSPEC SDLPango_Context* SDLCALL SDLPango_CreateContext_GivenFontDesc(const char* font_desc);
  89. extern DECLSPEC SDLPango_Context* SDLCALL SDLPango_CreateContext();
  90. extern DECLSPEC void SDLCALL SDLPango_FreeContext(
  91. @@ -157,6 +165,12 @@
  92. const char *markup,
  93. int length);
  94. +extern DECLSPEC void SDLCALL SDLPango_SetText_GivenAlignment(
  95. + SDLPango_Context *context,
  96. + const char *text,
  97. + int length,
  98. + SDLPango_Alignment alignment);
  99. +
  100. extern DECLSPEC void SDLCALL SDLPango_SetText(
  101. SDLPango_Context *context,
  102. const char *markup,