blob: 3262b353f843257c72e3153807560ac64d67c84a [file] [log] [blame]
cristybb06a1a2012-03-15 00:16:53 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% PPPP AAA N N GGGG OOO %
7% P P A A NN N G O O %
cristyfde4ac32012-03-15 11:25:35 +00008% PPPP AAAAA N N N G GGG O O %
9% P M A A N NN G G O O %
10% P A A N N GGGG OOO %
cristybb06a1a2012-03-15 00:16:53 +000011% %
12% %
cristyfde4ac32012-03-15 11:25:35 +000013% Read Pango Markup Language Format %
cristybb06a1a2012-03-15 00:16:53 +000014% %
15% Software Design %
16% John Cristy %
cristyfde4ac32012-03-15 11:25:35 +000017% March 2012 %
cristybb06a1a2012-03-15 00:16:53 +000018% %
19% %
20% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
21% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37*/
38
39/*
40 Include declarations.
41*/
42#include "MagickCore/studio.h"
43#include "MagickCore/annotate.h"
44#include "MagickCore/blob.h"
45#include "MagickCore/blob-private.h"
46#include "MagickCore/composite-private.h"
47#include "MagickCore/draw.h"
48#include "MagickCore/draw-private.h"
49#include "MagickCore/exception.h"
50#include "MagickCore/exception-private.h"
51#include "MagickCore/image.h"
52#include "MagickCore/image-private.h"
53#include "MagickCore/list.h"
54#include "MagickCore/magick.h"
cristyfde4ac32012-03-15 11:25:35 +000055#include "MagickCore/memory_.h"
cristy19642b02012-03-26 19:33:21 +000056#include "MagickCore/module.h"
57#include "MagickCore/monitor.h"
58#include "MagickCore/monitor-private.h"
cristybb06a1a2012-03-15 00:16:53 +000059#include "MagickCore/option.h"
cristyfde4ac32012-03-15 11:25:35 +000060#include "MagickCore/pixel-accessor.h"
cristybb06a1a2012-03-15 00:16:53 +000061#include "MagickCore/property.h"
62#include "MagickCore/quantum-private.h"
63#include "MagickCore/static.h"
64#include "MagickCore/string_.h"
65#include "MagickCore/string-private.h"
cristye40005d2012-03-23 12:18:45 +000066#include "MagickCore/token.h"
cristybb06a1a2012-03-15 00:16:53 +000067#include "MagickCore/utility.h"
cristy19642b02012-03-26 19:33:21 +000068#if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
cristybb06a1a2012-03-15 00:16:53 +000069#include <pango/pango.h>
cristy19642b02012-03-26 19:33:21 +000070#include <pango/pangocairo.h>
cristybb06a1a2012-03-15 00:16:53 +000071#include <pango/pango-features.h>
72#endif
73
cristy19642b02012-03-26 19:33:21 +000074#if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
cristybb06a1a2012-03-15 00:16:53 +000075/*
76%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77% %
78% %
79% %
80% R e a d P A N G O I m a g e %
81% %
82% %
83% %
84%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85%
cristyfde4ac32012-03-15 11:25:35 +000086% ReadPANGOImage() reads an image in the Pango Markup Language Format.
cristybb06a1a2012-03-15 00:16:53 +000087%
88% The format of the ReadPANGOImage method is:
89%
90% Image *ReadPANGOImage(const ImageInfo *image_info,
91% ExceptionInfo *exception)
92%
93% A description of each parameter follows:
94%
95% o image_info: the image info.
96%
97% o exception: return any errors or warnings in this structure.
98%
99*/
cristyfde4ac32012-03-15 11:25:35 +0000100static Image *ReadPANGOImage(const ImageInfo *image_info,
101 ExceptionInfo *exception)
cristybb06a1a2012-03-15 00:16:53 +0000102{
cristy19642b02012-03-26 19:33:21 +0000103 cairo_font_options_t
104 *font_options;
105
106 cairo_surface_t
107 *surface;
108
cristyfde4ac32012-03-15 11:25:35 +0000109 char
110 *caption,
111 *property;
112
cristy19642b02012-03-26 19:33:21 +0000113 cairo_t
cristyab1975c2012-03-27 01:34:11 +0000114 *cairo_image;
cristy19642b02012-03-26 19:33:21 +0000115
cristybb06a1a2012-03-15 00:16:53 +0000116 const char
117 *option;
118
cristyfde4ac32012-03-15 11:25:35 +0000119 DrawInfo
120 *draw_info;
121
cristyfde4ac32012-03-15 11:25:35 +0000122 Image
123 *image;
124
cristy19642b02012-03-26 19:33:21 +0000125 MagickBooleanType
126 status;
127
cristybb06a1a2012-03-15 00:16:53 +0000128 PangoAlignment
129 align;
130
131 PangoContext
132 *context;
133
cristybb06a1a2012-03-15 00:16:53 +0000134 PangoFontMap
135 *fontmap;
136
137 PangoGravity
138 gravity;
139
140 PangoLayout
141 *layout;
142
143 PangoRectangle
144 extent;
145
146 PixelInfo
147 fill_color;
148
149 RectangleInfo
150 page;
151
cristybb06a1a2012-03-15 00:16:53 +0000152 register unsigned char
153 *p;
154
cristyab1975c2012-03-27 01:34:11 +0000155 size_t
156 stride;
157
cristybb06a1a2012-03-15 00:16:53 +0000158 ssize_t
159 y;
160
cristy19642b02012-03-26 19:33:21 +0000161 unsigned char
162 *pixels;
163
cristybb06a1a2012-03-15 00:16:53 +0000164 /*
cristyfde4ac32012-03-15 11:25:35 +0000165 Initialize Image structure.
166 */
167 assert(image_info != (const ImageInfo *) NULL);
168 assert(image_info->signature == MagickSignature);
169 if (image_info->debug != MagickFalse)
170 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
171 image_info->filename);
172 assert(exception != (ExceptionInfo *) NULL);
173 assert(exception->signature == MagickSignature);
174 image=AcquireImage(image_info,exception);
175 (void) ResetImagePage(image,"0x0+0+0");
176 /*
cristyc0732c42012-03-20 19:28:35 +0000177 Format caption.
178 */
179 option=GetImageOption(image_info,"filename");
180 if (option == (const char *) NULL)
181 property=InterpretImageProperties(image_info,image,image_info->filename,
182 exception);
183 else
184 if (LocaleNCompare(option,"pango:",6) == 0)
185 property=InterpretImageProperties(image_info,image,option+6,exception);
186 else
187 property=InterpretImageProperties(image_info,image,option,exception);
188 (void) SetImageProperty(image,"caption",property,exception);
189 property=DestroyString(property);
190 caption=ConstantString(GetImageProperty(image,"caption",exception));
191 /*
cristybb06a1a2012-03-15 00:16:53 +0000192 Get context.
193 */
cristy19642b02012-03-26 19:33:21 +0000194 fontmap=pango_cairo_font_map_new();
195 pango_cairo_font_map_set_resolution(PANGO_CAIRO_FONT_MAP(fontmap),
196 image->resolution.x);
197 font_options=cairo_font_options_create();
cristybafa8702012-03-15 00:20:24 +0000198 option=GetImageOption(image_info,"pango:hinting");
cristy19642b02012-03-26 19:33:21 +0000199 if (option != (const char *) NULL)
200 {
201 if (LocaleCompare(option,"none") != 0)
202 cairo_font_options_set_hint_style(font_options,CAIRO_HINT_STYLE_NONE);
203 if (LocaleCompare(option,"full") != 0)
204 cairo_font_options_set_hint_style(font_options,CAIRO_HINT_STYLE_FULL);
205 }
cristybb06a1a2012-03-15 00:16:53 +0000206 context=pango_font_map_create_context(fontmap);
cristy19642b02012-03-26 19:33:21 +0000207 pango_cairo_context_set_font_options(context,font_options);
cristyab1975c2012-03-27 01:34:11 +0000208 cairo_font_options_destroy(font_options);
cristybafa8702012-03-15 00:20:24 +0000209 option=GetImageOption(image_info,"pango:language");
cristybb06a1a2012-03-15 00:16:53 +0000210 if (option != (const char *) NULL)
211 pango_context_set_language(context,pango_language_from_string(option));
cristyfde4ac32012-03-15 11:25:35 +0000212 draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
cristybb06a1a2012-03-15 00:16:53 +0000213 pango_context_set_base_dir(context,draw_info->direction ==
214 RightToLeftDirection ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR);
215 switch (draw_info->gravity)
216 {
cristy58845e32012-03-27 15:44:05 +0000217 case NorthGravity:
218 {
219 gravity=PANGO_GRAVITY_NORTH;
220 break;
221 }
222 case NorthWestGravity:
223 case WestGravity:
224 case SouthWestGravity:
225 {
226 gravity=PANGO_GRAVITY_WEST;
227 break;
228 }
229 case NorthEastGravity:
230 case EastGravity:
231 case SouthEastGravity:
232 {
233 gravity=PANGO_GRAVITY_EAST;
234 break;
235 }
236 case SouthGravity:
237 {
238 gravity=PANGO_GRAVITY_SOUTH;
239 break;
240 }
241 default:
242 {
243 gravity=PANGO_GRAVITY_AUTO;
244 break;
245 }
cristybb06a1a2012-03-15 00:16:53 +0000246 }
247 pango_context_set_base_gravity(context,gravity);
cristybafa8702012-03-15 00:20:24 +0000248 option=GetImageOption(image_info,"pango:gravity-hint");
cristybb06a1a2012-03-15 00:16:53 +0000249 if (option != (const char *) NULL)
250 {
251 if (LocaleCompare(option,"line") == 0)
252 pango_context_set_gravity_hint(context,PANGO_GRAVITY_HINT_LINE);
253 if (LocaleCompare(option,"natural") == 0)
254 pango_context_set_gravity_hint(context,PANGO_GRAVITY_HINT_NATURAL);
255 if (LocaleCompare(option,"strong") == 0)
256 pango_context_set_gravity_hint(context,PANGO_GRAVITY_HINT_STRONG);
257 }
258 /*
259 Configure layout.
260 */
261 layout=pango_layout_new(context);
cristybafa8702012-03-15 00:20:24 +0000262 option=GetImageOption(image_info,"pango:auto-dir");
cristybb06a1a2012-03-15 00:16:53 +0000263 if (option != (const char *) NULL)
264 pango_layout_set_auto_dir(layout,1);
cristybafa8702012-03-15 00:20:24 +0000265 option=GetImageOption(image_info,"pango:ellipsize");
cristybb06a1a2012-03-15 00:16:53 +0000266 if (option != (const char *) NULL)
267 {
268 if (LocaleCompare(option,"end") == 0)
269 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_END);
270 if (LocaleCompare(option,"middle") == 0)
271 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_MIDDLE);
272 if (LocaleCompare(option,"none") == 0)
273 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_NONE);
274 if (LocaleCompare(option,"start") == 0)
275 pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_START);
276 }
cristybafa8702012-03-15 00:20:24 +0000277 option=GetImageOption(image_info,"pango:justify");
anthony7bcfe7f2012-03-30 14:01:22 +0000278 if (IfMagickTrue(IsStringTrue(option)))
cristybb06a1a2012-03-15 00:16:53 +0000279 pango_layout_set_justify(layout,1);
cristybafa8702012-03-15 00:20:24 +0000280 option=GetImageOption(image_info,"pango:single-paragraph");
anthony7bcfe7f2012-03-30 14:01:22 +0000281 if (IfMagickTrue(IsStringTrue(option)))
cristybb06a1a2012-03-15 00:16:53 +0000282 pango_layout_set_single_paragraph_mode(layout,1);
cristybafa8702012-03-15 00:20:24 +0000283 option=GetImageOption(image_info,"pango:wrap");
cristybb06a1a2012-03-15 00:16:53 +0000284 if (option != (const char *) NULL)
285 {
286 if (LocaleCompare(option,"char") == 0)
287 pango_layout_set_wrap(layout,PANGO_WRAP_CHAR);
288 if (LocaleCompare(option,"word") == 0)
289 pango_layout_set_wrap(layout,PANGO_WRAP_WORD);
290 if (LocaleCompare(option,"word-char") == 0)
291 pango_layout_set_wrap(layout,PANGO_WRAP_WORD_CHAR);
292 }
cristybafa8702012-03-15 00:20:24 +0000293 option=GetImageOption(image_info,"pango:indent");
cristybb06a1a2012-03-15 00:16:53 +0000294 if (option != (const char *) NULL)
cristy22fd9d32012-03-19 11:50:33 +0000295 pango_layout_set_indent(layout,(int) ((StringToLong(option)*
296 image->resolution.x*PANGO_SCALE+36)/72.0+0.5));
cristybb06a1a2012-03-15 00:16:53 +0000297 switch (draw_info->align)
298 {
299 case CenterAlign: align=PANGO_ALIGN_CENTER; break;
300 case RightAlign: align=PANGO_ALIGN_RIGHT; break;
301 case LeftAlign: align=PANGO_ALIGN_LEFT; break;
302 default:
303 {
304 if (draw_info->gravity == CenterGravity)
cristyfde4ac32012-03-15 11:25:35 +0000305 {
cristybb06a1a2012-03-15 00:16:53 +0000306 align=PANGO_ALIGN_CENTER;
307 break;
308 }
309 align=PANGO_ALIGN_LEFT;
310 break;
311 }
312 }
313 if ((align != PANGO_ALIGN_CENTER) &&
314 (draw_info->direction == RightToLeftDirection))
315 align=(PangoAlignment) (PANGO_ALIGN_LEFT+PANGO_ALIGN_RIGHT-align);
316 pango_layout_set_alignment(layout,align);
cristy19642b02012-03-26 19:33:21 +0000317 if (draw_info->font != (char *) NULL)
318 {
319 PangoFontDescription
320 *description;
321
322 /*
323 Set font.
324 */
325 description=pango_font_description_from_string(draw_info->font);
326 pango_font_description_set_size(description,(int) (PANGO_SCALE*
327 draw_info->pointsize+0.5));
328 pango_layout_set_font_description(layout,description);
329 pango_font_description_free(description);
330 }
cristybafa8702012-03-15 00:20:24 +0000331 option=GetImageOption(image_info,"pango:markup");
cristyf3dbd112012-04-11 21:05:40 +0000332 if ((option != (const char *) NULL) && (IsStringTrue(option) == MagickFalse))
cristyfde4ac32012-03-15 11:25:35 +0000333 pango_layout_set_text(layout,caption,-1);
cristy4d84e4a2012-03-19 11:27:53 +0000334 else
335 {
336 GError
337 *error;
338
339 error=(GError *) NULL;
340 if (pango_parse_markup(caption,-1,0,NULL,NULL,NULL,&error) == 0)
341 (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
342 error->message,"`%s'",image_info->filename);
343 pango_layout_set_markup(layout,caption,-1);
344 }
cristybb06a1a2012-03-15 00:16:53 +0000345 pango_layout_context_changed(layout);
346 page.x=0;
347 page.y=0;
348 if (image_info->page != (char *) NULL)
349 (void) ParseAbsoluteGeometry(image_info->page,&page);
350 if (image->columns == 0)
351 {
352 pango_layout_get_pixel_extents(layout,NULL,&extent);
cristy973b85f2012-03-27 14:56:21 +0000353 image->columns=extent.x+extent.width+2*page.x;
cristybb06a1a2012-03-15 00:16:53 +0000354 }
355 else
356 {
357 image->columns-=2*page.x;
cristy22fd9d32012-03-19 11:50:33 +0000358 pango_layout_set_width(layout,(int) ((PANGO_SCALE*image->columns*
359 image->resolution.x+36.0)/72.0+0.5));
cristybb06a1a2012-03-15 00:16:53 +0000360 }
361 if (image->rows == 0)
362 {
363 pango_layout_get_pixel_extents(layout,NULL,&extent);
cristy973b85f2012-03-27 14:56:21 +0000364 image->rows=extent.y+extent.height+2*page.y;
cristybb06a1a2012-03-15 00:16:53 +0000365 }
366 else
367 {
368 image->rows-=2*page.y;
cristy22fd9d32012-03-19 11:50:33 +0000369 pango_layout_set_height(layout,(int) ((PANGO_SCALE*image->rows*
370 image->resolution.y+36.0)/72.0+0.5));
cristybb06a1a2012-03-15 00:16:53 +0000371 }
372 /*
cristyba275302012-03-27 14:42:23 +0000373 Render markup.
cristybb06a1a2012-03-15 00:16:53 +0000374 */
cristyab1975c2012-03-27 01:34:11 +0000375 stride=(size_t) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
376 image->columns);
cristye5dc0282012-04-09 19:07:44 +0000377 pixels=(unsigned char *) AcquireQuantumMemory(image->rows,stride*
cristyab1975c2012-03-27 01:34:11 +0000378 sizeof(*pixels));
cristy19642b02012-03-26 19:33:21 +0000379 if (pixels == (unsigned char *) NULL)
cristyab1975c2012-03-27 01:34:11 +0000380 {
381 draw_info=DestroyDrawInfo(draw_info);
382 caption=DestroyString(caption);
383 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
384 }
cristy19642b02012-03-26 19:33:21 +0000385 surface=cairo_image_surface_create_for_data(pixels,CAIRO_FORMAT_ARGB32,
cristyab1975c2012-03-27 01:34:11 +0000386 image->columns,image->rows,stride);
387 cairo_image=cairo_create(surface);
cristyba275302012-03-27 14:42:23 +0000388 cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR);
cristyab1975c2012-03-27 01:34:11 +0000389 cairo_paint(cairo_image);
390 cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER);
cristy973b85f2012-03-27 14:56:21 +0000391 cairo_translate(cairo_image,page.x,page.y);
cristyab1975c2012-03-27 01:34:11 +0000392 pango_cairo_show_layout(cairo_image,layout);
cristyab1975c2012-03-27 01:34:11 +0000393 cairo_destroy(cairo_image);
cristy19642b02012-03-26 19:33:21 +0000394 cairo_surface_destroy(surface);
cristyba275302012-03-27 14:42:23 +0000395 g_object_unref(layout);
cristy19642b02012-03-26 19:33:21 +0000396 g_object_unref(fontmap);
cristybb06a1a2012-03-15 00:16:53 +0000397 /*
cristyab1975c2012-03-27 01:34:11 +0000398 Convert surface to image.
cristybb06a1a2012-03-15 00:16:53 +0000399 */
cristy19642b02012-03-26 19:33:21 +0000400 (void) SetImageBackgroundColor(image,exception);
401 p=pixels;
cristybb06a1a2012-03-15 00:16:53 +0000402 GetPixelInfo(image,&fill_color);
cristy19642b02012-03-26 19:33:21 +0000403 for (y=0; y < (ssize_t) image->rows; y++)
cristybb06a1a2012-03-15 00:16:53 +0000404 {
cristyba275302012-03-27 14:42:23 +0000405 register Quantum
406 *q;
407
cristyab1975c2012-03-27 01:34:11 +0000408 register ssize_t
409 x;
cristybb06a1a2012-03-15 00:16:53 +0000410
411 q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
412 if (q == (Quantum *) NULL)
413 break;
cristy19642b02012-03-26 19:33:21 +0000414 for (x=0; x < (ssize_t) image->columns; x++)
cristybb06a1a2012-03-15 00:16:53 +0000415 {
cristyab1975c2012-03-27 01:34:11 +0000416 double
417 gamma;
418
419 fill_color.blue=(MagickRealType) ScaleCharToQuantum(*p++);
420 fill_color.green=(MagickRealType) ScaleCharToQuantum(*p++);
421 fill_color.red=(MagickRealType) ScaleCharToQuantum(*p++);
422 fill_color.alpha=(MagickRealType) ScaleCharToQuantum(*p++);
423 /*
424 Disassociate alpha.
425 */
426 gamma=1.0-QuantumScale*fill_color.alpha;
cristy1d1b10f2012-06-02 20:02:55 +0000427 gamma=ClampReciprocal(gamma);
cristyab1975c2012-03-27 01:34:11 +0000428 fill_color.blue*=gamma;
429 fill_color.green*=gamma;
430 fill_color.red*=gamma;
cristy19642b02012-03-26 19:33:21 +0000431 CompositePixelOver(image,&fill_color,fill_color.alpha,q,(MagickRealType)
432 GetPixelAlpha(image,q),q);
cristybb06a1a2012-03-15 00:16:53 +0000433 q+=GetPixelChannels(image);
434 }
cristy19642b02012-03-26 19:33:21 +0000435 if (SyncAuthenticPixels(image,exception) == MagickFalse)
436 break;
437 if (image->previous == (Image *) NULL)
438 {
439 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
440 image->rows);
441 if (status == MagickFalse)
442 break;
443 }
cristybb06a1a2012-03-15 00:16:53 +0000444 }
445 /*
446 Relinquish resources.
447 */
cristy19642b02012-03-26 19:33:21 +0000448 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
cristyfde4ac32012-03-15 11:25:35 +0000449 draw_info=DestroyDrawInfo(draw_info);
cristybb06a1a2012-03-15 00:16:53 +0000450 caption=DestroyString(caption);
cristybb06a1a2012-03-15 00:16:53 +0000451 return(GetFirstImageInList(image));
452}
cristyfde4ac32012-03-15 11:25:35 +0000453#endif
cristybb06a1a2012-03-15 00:16:53 +0000454
455/*
456%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
457% %
458% %
459% %
460% R e g i s t e r P A N G O I m a g e %
461% %
462% %
463% %
464%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465%
cristyfde4ac32012-03-15 11:25:35 +0000466% RegisterPANGOImage() adds attributes for the Pango Markup Language format to
cristybb06a1a2012-03-15 00:16:53 +0000467% the list of supported formats. The attributes include the image format
468% tag, a method to read and/or write the format, whether the format
469% supports the saving of more than one frame to the same file or blob,
470% whether the format supports native in-memory I/O, and a brief
471% description of the format.
472%
473% The format of the RegisterPANGOImage method is:
474%
475% size_t RegisterPANGOImage(void)
476%
477*/
478ModuleExport size_t RegisterPANGOImage(void)
479{
480 char
481 version[MaxTextExtent];
482
483 MagickInfo
484 *entry;
485
486 *version='\0';
487#if defined(PANGO_VERSION_STRING)
cristy19642b02012-03-26 19:33:21 +0000488 (void) FormatLocaleString(version,MaxTextExtent,"Pangocairo %s",
cristybb06a1a2012-03-15 00:16:53 +0000489 PANGO_VERSION_STRING);
490#endif
491 entry=SetMagickInfo("PANGO");
cristy19642b02012-03-26 19:33:21 +0000492#if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
cristybb06a1a2012-03-15 00:16:53 +0000493 entry->decoder=(DecodeImageHandler *) ReadPANGOImage;
cristyfde4ac32012-03-15 11:25:35 +0000494#endif
495 entry->description=ConstantString("Pango Markup Language");
cristybb06a1a2012-03-15 00:16:53 +0000496 if (*version != '\0')
497 entry->version=ConstantString(version);
498 entry->adjoin=MagickFalse;
499 entry->module=ConstantString("PANGO");
500 (void) RegisterMagickInfo(entry);
501 return(MagickImageCoderSignature);
502}
503
504/*
505%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
506% %
507% %
508% %
509% U n r e g i s t e r P A N G O I m a g e %
510% %
511% %
512% %
513%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
514%
cristyfde4ac32012-03-15 11:25:35 +0000515% UnregisterPANGOImage() removes format registrations made by the Pango module
516% from the list of supported formats.
cristybb06a1a2012-03-15 00:16:53 +0000517%
518% The format of the UnregisterPANGOImage method is:
519%
520% UnregisterPANGOImage(void)
521%
522*/
523ModuleExport void UnregisterPANGOImage(void)
524{
525 (void) UnregisterMagickInfo("PANGO");
526}