summaryrefslogtreecommitdiffstats
path: root/src/sdl_pango-1-api-adds.patch
blob: 4c2078e05dd2e5df898a3a9dfeafd2ae52b5ce75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
This file is part of MXE. See LICENSE.md for licensing information.

This patch has been taken from:
http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch

--- SDL_Pango-0.1.2.orig/src/SDL_Pango.c	2004-12-10 10:06:33.000000000 +0100
+++ SDL_Pango-0.1.2/src/SDL_Pango.c	2006-09-24 22:46:24.000000000 +0200
@@ -723,13 +723,8 @@
     SDL_UnlockSurface(surface);
 }
 
-/*!
-    Create a context which contains Pango objects.
-
-    @return A pointer to the context as a SDLPango_Context*.
-*/
 SDLPango_Context*
-SDLPango_CreateContext()
+SDLPango_CreateContext_GivenFontDesc(const char* font_desc)
 {
     SDLPango_Context *context = g_malloc(sizeof(SDLPango_Context));
     G_CONST_RETURN char *charset;
@@ -743,8 +738,7 @@
     pango_context_set_language (context->context, pango_language_from_string (charset));
     pango_context_set_base_dir (context->context, PANGO_DIRECTION_LTR);
 
-    context->font_desc = pango_font_description_from_string(
-	MAKE_FONT_NAME (DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE));
+    context->font_desc = pango_font_description_from_string(font_desc);
 
     context->layout = pango_layout_new (context->context);
 
@@ -762,6 +756,17 @@
 }
 
 /*!
+    Create a context which contains Pango objects.
+
+    @return A pointer to the context as a SDLPango_Context*.
+*/
+SDLPango_Context*
+SDLPango_CreateContext()
+{
+     SDLPango_CreateContext_GivenFontDesc(MAKE_FONT_NAME(DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE));
+}
+
+/*!
     Free a context.
 
     @param *context [i/o] Context to be free
@@ -1053,6 +1058,20 @@
     pango_layout_set_font_description (context->layout, context->font_desc);
 }
 
+void
+SDLPango_SetText_GivenAlignment(
+    SDLPango_Context *context,
+    const char *text,
+    int length,
+    SDLPango_Alignment alignment)
+{
+    pango_layout_set_attributes(context->layout, NULL);
+    pango_layout_set_text (context->layout, text, length);
+    pango_layout_set_auto_dir (context->layout, TRUE);
+    pango_layout_set_alignment (context->layout, alignment);
+    pango_layout_set_font_description (context->layout, context->font_desc);
+}
+
 /*!
     Set plain text to context.
     Text must be utf-8.
@@ -1067,11 +1086,7 @@
     const char *text,
     int length)
 {
-    pango_layout_set_attributes(context->layout, NULL);
-    pango_layout_set_text (context->layout, text, length);
-    pango_layout_set_auto_dir (context->layout, TRUE);
-    pango_layout_set_alignment (context->layout, PANGO_ALIGN_LEFT);
-    pango_layout_set_font_description (context->layout, context->font_desc);
+     SDLPango_SetText_GivenAlignment(context, text, length, SDLPANGO_ALIGN_LEFT);
 }
 
 /*!
--- SDL_Pango-0.1.2.orig/src/SDL_Pango.h	2004-12-10 10:06:33.000000000 +0100
+++ SDL_Pango-0.1.2/src/SDL_Pango.h	2006-09-24 22:46:01.000000000 +0200
@@ -109,12 +109,20 @@
     SDLPANGO_DIRECTION_NEUTRAL	/*! Neutral */
 } SDLPango_Direction;
 
-
+/*!
+    Specifies alignment of text. See Pango reference for detail
+*/
+typedef enum {
+    SDLPANGO_ALIGN_LEFT,
+    SDLPANGO_ALIGN_CENTER,
+    SDLPANGO_ALIGN_RIGHT
+} SDLPango_Alignment;
 
 extern DECLSPEC int SDLCALL SDLPango_Init();
 
 extern DECLSPEC int SDLCALL SDLPango_WasInit();
 
+extern DECLSPEC SDLPango_Context* SDLCALL SDLPango_CreateContext_GivenFontDesc(const char* font_desc);
 extern DECLSPEC SDLPango_Context* SDLCALL SDLPango_CreateContext();
 
 extern DECLSPEC void SDLCALL SDLPango_FreeContext(
@@ -157,6 +165,12 @@
     const char *markup,
     int length);
 
+extern DECLSPEC void SDLCALL SDLPango_SetText_GivenAlignment(
+    SDLPango_Context *context,
+    const char *text,
+    int length,
+    SDLPango_Alignment alignment);
+
 extern DECLSPEC void SDLCALL SDLPango_SetText(
     SDLPango_Context *context,
     const char *markup,