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