MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
annotate.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % AAA N N N N OOO TTTTT AAA TTTTT EEEEE %
7 % A A NN N NN N O O T A A T E %
8 % AAAAA N N N N N N O O T AAAAA T EEE %
9 % A A N NN N NN O O T A A T E %
10 % A A N N N N OOO T A A T EEEEE %
11 % %
12 % %
13 % MagickCore Image Annotation Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % July 1992 %
18 % %
19 % %
20 % Copyright 1999-2018 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 % https://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 % Digital Applications (www.digapp.com) contributed the stroked text algorithm.
37 % It was written by Leonard Rosenthol.
38 %
39 %
40 */
41 
42 /*
43  Include declarations.
44 */
45 #include "MagickCore/studio.h"
46 #include "MagickCore/annotate.h"
48 #include "MagickCore/attribute.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/channel.h"
52 #include "MagickCore/client.h"
53 #include "MagickCore/color.h"
56 #include "MagickCore/composite.h"
58 #include "MagickCore/constitute.h"
59 #include "MagickCore/draw.h"
61 #include "MagickCore/enhance.h"
62 #include "MagickCore/exception.h"
64 #include "MagickCore/gem.h"
65 #include "MagickCore/geometry.h"
67 #include "MagickCore/log.h"
68 #include "MagickCore/quantum.h"
71 #include "MagickCore/property.h"
72 #include "MagickCore/resource_.h"
73 #include "MagickCore/semaphore.h"
74 #include "MagickCore/statistic.h"
75 #include "MagickCore/string_.h"
76 #include "MagickCore/token.h"
78 #include "MagickCore/transform.h"
80 #include "MagickCore/type.h"
81 #include "MagickCore/utility.h"
83 #include "MagickCore/xwindow.h"
85 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
86 #if defined(__MINGW32__)
87 # undef interface
88 #endif
89 #include <ft2build.h>
90 #if defined(FT_FREETYPE_H)
91 # include FT_FREETYPE_H
92 #else
93 # include <freetype/freetype.h>
94 #endif
95 #if defined(FT_GLYPH_H)
96 # include FT_GLYPH_H
97 #else
98 # include <freetype/ftglyph.h>
99 #endif
100 #if defined(FT_OUTLINE_H)
101 # include FT_OUTLINE_H
102 #else
103 # include <freetype/ftoutln.h>
104 #endif
105 #if defined(FT_BBOX_H)
106 # include FT_BBOX_H
107 #else
108 # include <freetype/ftbbox.h>
109 #endif /* defined(FT_BBOX_H) */
110 #endif
111 #if defined(MAGICKCORE_RAQM_DELEGATE)
112 #include <raqm.h>
113 #endif
114 typedef struct _GraphemeInfo
115 {
116  size_t
118  x_offset,
119  x_advance,
120  y_offset;
121 
122  size_t
124 } GraphemeInfo;
125 
126 /*
127  Annotate semaphores.
128 */
129 static SemaphoreInfo
131 
132 /*
133  Forward declarations.
134 */
135 static MagickBooleanType
136  RenderType(Image *,const DrawInfo *,const PointInfo *,TypeMetric *,
137  ExceptionInfo *),
138  RenderPostscript(Image *,const DrawInfo *,const PointInfo *,TypeMetric *,
139  ExceptionInfo *),
140  RenderFreetype(Image *,const DrawInfo *,const char *,const PointInfo *,
142  RenderX11(Image *,const DrawInfo *,const PointInfo *,TypeMetric *,
143  ExceptionInfo *);
144 
145 /*
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147 % %
148 % %
149 % %
150 + A n n o t a t e C o m p o n e n t G e n e s i s %
151 % %
152 % %
153 % %
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 %
156 % AnnotateComponentGenesis() instantiates the annotate component.
157 %
158 % The format of the AnnotateComponentGenesis method is:
159 %
160 % MagickBooleanType AnnotateComponentGenesis(void)
161 %
162 */
164 {
165  if (annotate_semaphore == (SemaphoreInfo *) NULL)
167  return(MagickTrue);
168 }
169 
170 /*
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172 % %
173 % %
174 % %
175 + A n n o t a t e C o m p o n e n t T e r m i n u s %
176 % %
177 % %
178 % %
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 %
181 % AnnotateComponentTerminus() destroys the annotate component.
182 %
183 % The format of the AnnotateComponentTerminus method is:
184 %
185 % AnnotateComponentTerminus(void)
186 %
187 */
189 {
190  if (annotate_semaphore == (SemaphoreInfo *) NULL)
193 }
194 
195 /*
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
197 % %
198 % %
199 % %
200 % A n n o t a t e I m a g e %
201 % %
202 % %
203 % %
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 %
206 % AnnotateImage() annotates an image with text. Optionally you can include
207 % any of the following bits of information about the image by embedding
208 % the appropriate special characters:
209 %
210 % \n newline
211 % \r carriage return
212 % < less-than character.
213 % > greater-than character.
214 % & ampersand character.
215 % %% a percent sign
216 % %b file size of image read in
217 % %c comment meta-data property
218 % %d directory component of path
219 % %e filename extension or suffix
220 % %f filename (including suffix)
221 % %g layer canvas page geometry (equivalent to "%Wx%H%X%Y")
222 % %h current image height in pixels
223 % %i image filename (note: becomes output filename for "info:")
224 % %k CALCULATED: number of unique colors
225 % %l label meta-data property
226 % %m image file format (file magic)
227 % %n number of images in current image sequence
228 % %o output filename (used for delegates)
229 % %p index of image in current image list
230 % %q quantum depth (compile-time constant)
231 % %r image class and colorspace
232 % %s scene number (from input unless re-assigned)
233 % %t filename without directory or extension (suffix)
234 % %u unique temporary filename (used for delegates)
235 % %w current width in pixels
236 % %x x resolution (density)
237 % %y y resolution (density)
238 % %z image depth (as read in unless modified, image save depth)
239 % %A image transparency channel enabled (true/false)
240 % %C image compression type
241 % %D image GIF dispose method
242 % %G original image size (%wx%h; before any resizes)
243 % %H page (canvas) height
244 % %M Magick filename (original file exactly as given, including read mods)
245 % %O page (canvas) offset ( = %X%Y )
246 % %P page (canvas) size ( = %Wx%H )
247 % %Q image compression quality ( 0 = default )
248 % %S ?? scenes ??
249 % %T image time delay (in centi-seconds)
250 % %U image resolution units
251 % %W page (canvas) width
252 % %X page (canvas) x offset (including sign)
253 % %Y page (canvas) y offset (including sign)
254 % %Z unique filename (used for delegates)
255 % %@ CALCULATED: trim bounding box (without actually trimming)
256 % %# CALCULATED: 'signature' hash of image values
257 %
258 % The format of the AnnotateImage method is:
259 %
260 % MagickBooleanType AnnotateImage(Image *image,DrawInfo *draw_info,
261 % ExceptionInfo *exception)
262 %
263 % A description of each parameter follows:
264 %
265 % o image: the image.
266 %
267 % o draw_info: the draw info.
268 %
269 % o exception: return any errors or warnings in this structure.
270 %
271 */
273  const DrawInfo *draw_info,ExceptionInfo *exception)
274 {
275  char
276  primitive[MagickPathExtent],
277  **textlist;
278 
279  DrawInfo
280  *annotate,
281  *annotate_info;
282 
284  geometry_info;
285 
287  status;
288 
289  PointInfo
290  offset;
291 
293  geometry;
294 
295  register ssize_t
296  i;
297 
298  size_t
299  length;
300 
301  TypeMetric
302  metrics;
303 
304  size_t
305  height,
306  number_lines;
307 
308  assert(image != (Image *) NULL);
309  assert(image->signature == MagickCoreSignature);
310  if (image->debug != MagickFalse)
311  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
312  assert(draw_info != (DrawInfo *) NULL);
313  assert(draw_info->signature == MagickCoreSignature);
314  if (draw_info->text == (char *) NULL)
315  return(MagickFalse);
316  if (*draw_info->text == '\0')
317  return(MagickTrue);
318  textlist=StringToList(draw_info->text);
319  if (textlist == (char **) NULL)
320  return(MagickFalse);
321  length=strlen(textlist[0]);
322  for (i=1; textlist[i] != (char *) NULL; i++)
323  if (strlen(textlist[i]) > length)
324  length=strlen(textlist[i]);
325  number_lines=(size_t) i;
326  annotate=CloneDrawInfo((ImageInfo *) NULL,draw_info);
327  annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
328  SetGeometry(image,&geometry);
329  SetGeometryInfo(&geometry_info);
330  if (annotate_info->geometry != (char *) NULL)
331  {
332  (void) ParsePageGeometry(image,annotate_info->geometry,&geometry,
333  exception);
334  (void) ParseGeometry(annotate_info->geometry,&geometry_info);
335  }
336  if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
337  return(MagickFalse);
338  if (IsGrayColorspace(image->colorspace) != MagickFalse)
339  (void) SetImageColorspace(image,sRGBColorspace,exception);
340  status=MagickTrue;
341  for (i=0; textlist[i] != (char *) NULL; i++)
342  {
343  /*
344  Position text relative to image.
345  */
346  annotate_info->affine.tx=geometry_info.xi-image->page.x;
347  annotate_info->affine.ty=geometry_info.psi-image->page.y;
348  (void) CloneString(&annotate->text,textlist[i]);
349  (void) GetTypeMetrics(image,annotate,&metrics,exception);
350  height=(ssize_t) (metrics.ascent-metrics.descent+
351  draw_info->interline_spacing+0.5);
352  switch (annotate->gravity)
353  {
354  case UndefinedGravity:
355  default:
356  {
357  offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height;
358  offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height;
359  break;
360  }
361  case NorthWestGravity:
362  {
363  offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i*
364  annotate_info->affine.ry*height+annotate_info->affine.ry*
365  (metrics.ascent+metrics.descent);
366  offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i*
367  annotate_info->affine.sy*height+annotate_info->affine.sy*
368  metrics.ascent;
369  break;
370  }
371  case NorthGravity:
372  {
373  offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+
374  geometry.width/2.0+i*annotate_info->affine.ry*height-
375  annotate_info->affine.sx*metrics.width/2.0+annotate_info->affine.ry*
376  (metrics.ascent+metrics.descent);
377  offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i*
378  annotate_info->affine.sy*height+annotate_info->affine.sy*
379  metrics.ascent-annotate_info->affine.rx*metrics.width/2.0;
380  break;
381  }
382  case NorthEastGravity:
383  {
384  offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+
385  geometry.width+i*annotate_info->affine.ry*height-
386  annotate_info->affine.sx*metrics.width+annotate_info->affine.ry*
387  (metrics.ascent+metrics.descent)-1.0;
388  offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i*
389  annotate_info->affine.sy*height+annotate_info->affine.sy*
390  metrics.ascent-annotate_info->affine.rx*metrics.width;
391  break;
392  }
393  case WestGravity:
394  {
395  offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i*
396  annotate_info->affine.ry*height+annotate_info->affine.ry*
397  (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0;
398  offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+
399  geometry.height/2.0+i*annotate_info->affine.sy*height+
400  annotate_info->affine.sy*(metrics.ascent+metrics.descent-
401  (number_lines-1.0)*height)/2.0;
402  break;
403  }
404  case CenterGravity:
405  {
406  offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+
407  geometry.width/2.0+i*annotate_info->affine.ry*height-
408  annotate_info->affine.sx*metrics.width/2.0+annotate_info->affine.ry*
409  (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0;
410  offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+
411  geometry.height/2.0+i*annotate_info->affine.sy*height-
412  annotate_info->affine.rx*metrics.width/2.0+annotate_info->affine.sy*
413  (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0;
414  break;
415  }
416  case EastGravity:
417  {
418  offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+
419  geometry.width+i*annotate_info->affine.ry*height-
420  annotate_info->affine.sx*metrics.width+
421  annotate_info->affine.ry*(metrics.ascent+metrics.descent-
422  (number_lines-1.0)*height)/2.0-1.0;
423  offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+
424  geometry.height/2.0+i*annotate_info->affine.sy*height-
425  annotate_info->affine.rx*metrics.width+
426  annotate_info->affine.sy*(metrics.ascent+metrics.descent-
427  (number_lines-1.0)*height)/2.0;
428  break;
429  }
430  case SouthWestGravity:
431  {
432  offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i*
433  annotate_info->affine.ry*height-annotate_info->affine.ry*
434  (number_lines-1.0)*height;
435  offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+
436  geometry.height+i*annotate_info->affine.sy*height-
437  annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent;
438  break;
439  }
440  case SouthGravity:
441  {
442  offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+
443  geometry.width/2.0+i*annotate_info->affine.ry*height-
444  annotate_info->affine.sx*metrics.width/2.0-
445  annotate_info->affine.ry*(number_lines-1.0)*height/2.0;
446  offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+
447  geometry.height+i*annotate_info->affine.sy*height-
448  annotate_info->affine.rx*metrics.width/2.0-
449  annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent;
450  break;
451  }
452  case SouthEastGravity:
453  {
454  offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+
455  geometry.width+i*annotate_info->affine.ry*height-
456  annotate_info->affine.sx*metrics.width-
457  annotate_info->affine.ry*(number_lines-1.0)*height-1.0;
458  offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+
459  geometry.height+i*annotate_info->affine.sy*height-
460  annotate_info->affine.rx*metrics.width-
461  annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent;
462  break;
463  }
464  }
465  switch (annotate->align)
466  {
467  case LeftAlign:
468  {
469  offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height;
470  offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height;
471  break;
472  }
473  case CenterAlign:
474  {
475  offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height-
476  annotate_info->affine.sx*metrics.width/2.0;
477  offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height-
478  annotate_info->affine.rx*metrics.width/2.0;
479  break;
480  }
481  case RightAlign:
482  {
483  offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height-
484  annotate_info->affine.sx*metrics.width;
485  offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height-
486  annotate_info->affine.rx*metrics.width;
487  break;
488  }
489  default:
490  break;
491  }
492  if (draw_info->undercolor.alpha != TransparentAlpha)
493  {
494  DrawInfo
495  *undercolor_info;
496 
497  /*
498  Text box.
499  */
500  undercolor_info=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL);
501  undercolor_info->fill=draw_info->undercolor;
502  undercolor_info->affine=draw_info->affine;
503  undercolor_info->affine.tx=offset.x-draw_info->affine.ry*metrics.ascent;
504  undercolor_info->affine.ty=offset.y-draw_info->affine.sy*metrics.ascent;
505  (void) FormatLocaleString(primitive,MagickPathExtent,
506  "rectangle 0.0,0.0 %g,%g",metrics.origin.x,(double) height);
507  (void) CloneString(&undercolor_info->primitive,primitive);
508  (void) DrawImage(image,undercolor_info,exception);
509  (void) DestroyDrawInfo(undercolor_info);
510  }
511  annotate_info->affine.tx=offset.x;
512  annotate_info->affine.ty=offset.y;
513  (void) FormatLocaleString(primitive,MagickPathExtent,"stroke-width %g "
514  "line 0,0 %g,0",metrics.underline_thickness,metrics.width);
515  if (annotate->decorate == OverlineDecoration)
516  {
517  annotate_info->affine.ty-=(draw_info->affine.sy*(metrics.ascent+
518  metrics.descent-metrics.underline_position));
519  (void) CloneString(&annotate_info->primitive,primitive);
520  (void) DrawImage(image,annotate_info,exception);
521  }
522  else
523  if (annotate->decorate == UnderlineDecoration)
524  {
525  annotate_info->affine.ty-=(draw_info->affine.sy*
526  metrics.underline_position);
527  (void) CloneString(&annotate_info->primitive,primitive);
528  (void) DrawImage(image,annotate_info,exception);
529  }
530  /*
531  Annotate image with text.
532  */
533  status=RenderType(image,annotate,&offset,&metrics,exception);
534  if (status == MagickFalse)
535  break;
536  if (annotate->decorate == LineThroughDecoration)
537  {
538  annotate_info->affine.ty-=(draw_info->affine.sy*(height+
539  metrics.underline_position+metrics.descent)/2.0);
540  (void) CloneString(&annotate_info->primitive,primitive);
541  (void) DrawImage(image,annotate_info,exception);
542  }
543  }
544  /*
545  Relinquish resources.
546  */
547  annotate_info=DestroyDrawInfo(annotate_info);
548  annotate=DestroyDrawInfo(annotate);
549  for (i=0; textlist[i] != (char *) NULL; i++)
550  textlist[i]=DestroyString(textlist[i]);
551  textlist=(char **) RelinquishMagickMemory(textlist);
552  return(status);
553 }
554 
555 /*
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
557 % %
558 % %
559 % %
560 % F o r m a t M a g i c k C a p t i o n %
561 % %
562 % %
563 % %
564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 %
566 % FormatMagickCaption() formats a caption so that it fits within the image
567 % width. It returns the number of lines in the formatted caption.
568 %
569 % The format of the FormatMagickCaption method is:
570 %
571 % ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info,
572 % const MagickBooleanType split,TypeMetric *metrics,char **caption,
573 % ExceptionInfo *exception)
574 %
575 % A description of each parameter follows.
576 %
577 % o image: The image.
578 %
579 % o draw_info: the draw info.
580 %
581 % o split: when no convenient line breaks-- insert newline.
582 %
583 % o metrics: Return the font metrics in this structure.
584 %
585 % o caption: the caption.
586 %
587 % o exception: return any errors or warnings in this structure.
588 %
589 */
590 MagickExport ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info,
591  const MagickBooleanType split,TypeMetric *metrics,char **caption,
592  ExceptionInfo *exception)
593 {
595  digit,
596  status;
597 
598  register char
599  *p,
600  *q,
601  *s;
602 
603  register ssize_t
604  i;
605 
606  size_t
607  width;
608 
609  ssize_t
610  n;
611 
612  digit=MagickFalse;
613  q=draw_info->text;
614  s=(char *) NULL;
615  width=0;
616  for (p=(*caption); GetUTFCode(p) != 0; p+=GetUTFOctets(p))
617  {
618  if ((digit == MagickFalse) && (IsUTFSpace(GetUTFCode(p)) != MagickFalse))
619  s=p;
620  digit=((GetUTFCode(p) >= 0x0030) && (GetUTFCode(p) <= 0x0039)) ?
622  if (GetUTFCode(p) == '\n')
623  q=draw_info->text;
624  for (i=0; i < (ssize_t) GetUTFOctets(p); i++)
625  *q++=(*(p+i));
626  *q='\0';
627  status=GetTypeMetrics(image,draw_info,metrics,exception);
628  if (status == MagickFalse)
629  break;
630  width=(size_t) floor(metrics->width+draw_info->stroke_width+0.5);
631  if ((width <= image->columns) || (s == (char *) NULL))
632  continue;
633  if ((s != (char *) NULL) && (GetUTFOctets(s) == 1))
634  {
635  *s='\n';
636  p=s;
637  }
638  else
639  if (split != MagickFalse)
640  {
641  char
642  *target;
643 
644  /*
645  No convenient line breaks-- insert newline.
646  */
647  target=AcquireString(*caption);
648  n=p-(*caption);
649  CopyMagickString(target,*caption,n+1);
650  ConcatenateMagickString(target,"\n",strlen(*caption)+1);
651  ConcatenateMagickString(target,p,strlen(*caption)+2);
652  (void) DestroyString(*caption);
653  *caption=target;
654  p=(*caption)+n;
655  }
656  q=draw_info->text;
657  s=(char *) NULL;
658  }
659  if (width > image->columns)
660  {
661  char
662  *text;
663 
664  /*
665  No convenient break point, force one.
666  */
667  text=AcquireString(draw_info->text);
668  q=draw_info->text;
669  s=(char *) NULL;
670  for (p=(*caption); GetUTFCode(p) != 0; p+=GetUTFOctets(p))
671  {
672  if (IsUTFSpace(GetUTFCode(p)) != MagickFalse)
673  s=p;
674  if (GetUTFCode(p) == '\n')
675  q=draw_info->text;
676  for (i=0; i < (ssize_t) GetUTFOctets(p); i++)
677  *q++=(*(p+i));
678  *q='\0';
679  status=GetTypeMetrics(image,draw_info,metrics,exception);
680  if (status == MagickFalse)
681  break;
682  width=(size_t) floor(metrics->width+draw_info->stroke_width+0.5);
683  if ((width <= image->columns) || (strcmp(text,draw_info->text) == 0))
684  continue;
685  (void) strcpy(text,draw_info->text);
686  if ((s != (char *) NULL) && (GetUTFOctets(s) == 1))
687  {
688  *s='\n';
689  p=s;
690  }
691  else
692  if ((s != (char *) NULL) || (split != MagickFalse))
693  {
694  char
695  *target;
696 
697  /*
698  No convenient line breaks-- insert newline.
699  */
700  target=AcquireString(*caption);
701  n=p-(*caption);
702  CopyMagickString(target,*caption,n+1);
703  ConcatenateMagickString(target,"\n",strlen(*caption)+1);
704  ConcatenateMagickString(target,p,strlen(*caption)+2);
705  (void) DestroyString(*caption);
706  *caption=target;
707  p=(*caption)+n;
708  }
709  q=draw_info->text;
710  s=(char *) NULL;
711  }
712  text=DestroyString(text);
713  }
714  n=0;
715  for (p=(*caption); GetUTFCode(p) != 0; p+=GetUTFOctets(p))
716  if (GetUTFCode(p) == '\n')
717  n++;
718  return(n);
719 }
720 
721 /*
722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
723 % %
724 % %
725 % %
726 % G e t M u l t i l i n e T y p e M e t r i c s %
727 % %
728 % %
729 % %
730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
731 %
732 % GetMultilineTypeMetrics() returns the following information for the
733 % specified font and text:
734 %
735 % character width
736 % character height
737 % ascender
738 % descender
739 % text width
740 % text height
741 % maximum horizontal advance
742 % bounds: x1
743 % bounds: y1
744 % bounds: x2
745 % bounds: y2
746 % origin: x
747 % origin: y
748 % underline position
749 % underline thickness
750 %
751 % This method is like GetTypeMetrics() but it returns the maximum text width
752 % and height for multiple lines of text.
753 %
754 % The format of the GetMultilineTypeMetrics method is:
755 %
756 % MagickBooleanType GetMultilineTypeMetrics(Image *image,
757 % const DrawInfo *draw_info,TypeMetric *metrics,ExceptionInfo *exception)
758 %
759 % A description of each parameter follows:
760 %
761 % o image: the image.
762 %
763 % o draw_info: the draw info.
764 %
765 % o metrics: Return the font metrics in this structure.
766 %
767 % o exception: return any errors or warnings in this structure.
768 %
769 */
771  const DrawInfo *draw_info,TypeMetric *metrics,ExceptionInfo *exception)
772 {
773  char
774  **textlist;
775 
776  DrawInfo
777  *annotate_info;
778 
780  status;
781 
782  register ssize_t
783  i;
784 
785  TypeMetric
786  extent;
787 
788  assert(image != (Image *) NULL);
789  assert(image->signature == MagickCoreSignature);
790  if (image->debug != MagickFalse)
791  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
792  assert(draw_info != (DrawInfo *) NULL);
793  assert(draw_info->text != (char *) NULL);
794  assert(draw_info->signature == MagickCoreSignature);
795  if (*draw_info->text == '\0')
796  return(MagickFalse);
797  annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
798  annotate_info->text=DestroyString(annotate_info->text);
799  /*
800  Convert newlines to multiple lines of text.
801  */
802  textlist=StringToList(draw_info->text);
803  if (textlist == (char **) NULL)
804  return(MagickFalse);
805  annotate_info->render=MagickFalse;
806  annotate_info->direction=UndefinedDirection;
807  (void) ResetMagickMemory(metrics,0,sizeof(*metrics));
808  (void) ResetMagickMemory(&extent,0,sizeof(extent));
809  /*
810  Find the widest of the text lines.
811  */
812  annotate_info->text=textlist[0];
813  status=GetTypeMetrics(image,annotate_info,&extent,exception);
814  *metrics=extent;
815  for (i=1; textlist[i] != (char *) NULL; i++)
816  {
817  annotate_info->text=textlist[i];
818  status=GetTypeMetrics(image,annotate_info,&extent,exception);
819  if (extent.width > metrics->width)
820  *metrics=extent;
821  }
822  metrics->height=(double) (i*(size_t) (metrics->ascent-metrics->descent+0.5)+
823  (i-1)*draw_info->interline_spacing);
824  /*
825  Relinquish resources.
826  */
827  annotate_info->text=(char *) NULL;
828  annotate_info=DestroyDrawInfo(annotate_info);
829  for (i=0; textlist[i] != (char *) NULL; i++)
830  textlist[i]=DestroyString(textlist[i]);
831  textlist=(char **) RelinquishMagickMemory(textlist);
832  return(status);
833 }
834 
835 /*
836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
837 % %
838 % %
839 % %
840 % G e t T y p e M e t r i c s %
841 % %
842 % %
843 % %
844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
845 %
846 % GetTypeMetrics() returns the following information for the specified font
847 % and text:
848 %
849 % character width
850 % character height
851 % ascender
852 % descender
853 % text width
854 % text height
855 % maximum horizontal advance
856 % bounds: x1
857 % bounds: y1
858 % bounds: x2
859 % bounds: y2
860 % origin: x
861 % origin: y
862 % underline position
863 % underline thickness
864 %
865 % The format of the GetTypeMetrics method is:
866 %
867 % MagickBooleanType GetTypeMetrics(Image *image,const DrawInfo *draw_info,
868 % TypeMetric *metrics,ExceptionInfo *exception)
869 %
870 % A description of each parameter follows:
871 %
872 % o image: the image.
873 %
874 % o draw_info: the draw info.
875 %
876 % o metrics: Return the font metrics in this structure.
877 %
878 % o exception: return any errors or warnings in this structure.
879 %
880 */
882  const DrawInfo *draw_info,TypeMetric *metrics,ExceptionInfo *exception)
883 {
884  DrawInfo
885  *annotate_info;
886 
888  status;
889 
890  PointInfo
891  offset;
892 
893  assert(image != (Image *) NULL);
894  assert(image->signature == MagickCoreSignature);
895  if (image->debug != MagickFalse)
896  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
897  assert(draw_info != (DrawInfo *) NULL);
898  assert(draw_info->text != (char *) NULL);
899  assert(draw_info->signature == MagickCoreSignature);
900  annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
901  annotate_info->render=MagickFalse;
902  annotate_info->direction=UndefinedDirection;
903  (void) ResetMagickMemory(metrics,0,sizeof(*metrics));
904  offset.x=0.0;
905  offset.y=0.0;
906  status=RenderType(image,annotate_info,&offset,metrics,exception);
907  if (image->debug != MagickFalse)
908  (void) LogMagickEvent(AnnotateEvent,GetMagickModule(),"Metrics: text: %s; "
909  "width: %g; height: %g; ascent: %g; descent: %g; max advance: %g; "
910  "bounds: %g,%g %g,%g; origin: %g,%g; pixels per em: %g,%g; "
911  "underline position: %g; underline thickness: %g",annotate_info->text,
912  metrics->width,metrics->height,metrics->ascent,metrics->descent,
913  metrics->max_advance,metrics->bounds.x1,metrics->bounds.y1,
914  metrics->bounds.x2,metrics->bounds.y2,metrics->origin.x,metrics->origin.y,
915  metrics->pixels_per_em.x,metrics->pixels_per_em.y,
916  metrics->underline_position,metrics->underline_thickness);
917  annotate_info=DestroyDrawInfo(annotate_info);
918  return(status);
919 }
920 
921 /*
922 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
923 % %
924 % %
925 % %
926 + R e n d e r T y p e %
927 % %
928 % %
929 % %
930 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
931 %
932 % RenderType() renders text on the image. It also returns the bounding box of
933 % the text relative to the image.
934 %
935 % The format of the RenderType method is:
936 %
937 % MagickBooleanType RenderType(Image *image,DrawInfo *draw_info,
938 % const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception)
939 %
940 % A description of each parameter follows:
941 %
942 % o image: the image.
943 %
944 % o draw_info: the draw info.
945 %
946 % o offset: (x,y) location of text relative to image.
947 %
948 % o metrics: bounding box of text.
949 %
950 % o exception: return any errors or warnings in this structure.
951 %
952 */
953 static MagickBooleanType RenderType(Image *image,const DrawInfo *draw_info,
954  const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception)
955 {
956  const TypeInfo
957  *type_info;
958 
959  DrawInfo
960  *annotate_info;
961 
963  status;
964 
965  type_info=(const TypeInfo *) NULL;
966  if (draw_info->font != (char *) NULL)
967  {
968  if (*draw_info->font == '@')
969  {
970  status=RenderFreetype(image,draw_info,draw_info->encoding,offset,
971  metrics,exception);
972  return(status);
973  }
974  if (*draw_info->font == '-')
975  return(RenderX11(image,draw_info,offset,metrics,exception));
976  if (*draw_info->font == '^')
977  return(RenderPostscript(image,draw_info,offset,metrics,exception));
978  if (IsPathAccessible(draw_info->font) != MagickFalse)
979  {
980  status=RenderFreetype(image,draw_info,draw_info->encoding,offset,
981  metrics,exception);
982  return(status);
983  }
984  type_info=GetTypeInfo(draw_info->font,exception);
985  if (type_info == (const TypeInfo *) NULL)
987  "UnableToReadFont","`%s'",draw_info->font);
988  }
989  if ((type_info == (const TypeInfo *) NULL) &&
990  (draw_info->family != (const char *) NULL))
991  {
992  type_info=GetTypeInfoByFamily(draw_info->family,draw_info->style,
993  draw_info->stretch,draw_info->weight,exception);
994  if (type_info == (const TypeInfo *) NULL)
996  "UnableToReadFont","`%s'",draw_info->family);
997  }
998  if (type_info == (const TypeInfo *) NULL)
999  type_info=GetTypeInfoByFamily("Arial",draw_info->style,
1000  draw_info->stretch,draw_info->weight,exception);
1001  if (type_info == (const TypeInfo *) NULL)
1002  type_info=GetTypeInfoByFamily("Helvetica",draw_info->style,
1003  draw_info->stretch,draw_info->weight,exception);
1004  if (type_info == (const TypeInfo *) NULL)
1005  type_info=GetTypeInfoByFamily("Century Schoolbook",draw_info->style,
1006  draw_info->stretch,draw_info->weight,exception);
1007  if (type_info == (const TypeInfo *) NULL)
1008  type_info=GetTypeInfoByFamily("Sans",draw_info->style,
1009  draw_info->stretch,draw_info->weight,exception);
1010  if (type_info == (const TypeInfo *) NULL)
1011  type_info=GetTypeInfoByFamily((const char *) NULL,draw_info->style,
1012  draw_info->stretch,draw_info->weight,exception);
1013  if (type_info == (const TypeInfo *) NULL)
1014  type_info=GetTypeInfo("*",exception);
1015  if (type_info == (const TypeInfo *) NULL)
1016  {
1017  status=RenderFreetype(image,draw_info,draw_info->encoding,offset,metrics,
1018  exception);
1019  return(status);
1020  }
1021  annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
1022  annotate_info->face=type_info->face;
1023  if (type_info->metrics != (char *) NULL)
1024  (void) CloneString(&annotate_info->metrics,type_info->metrics);
1025  if (type_info->glyphs != (char *) NULL)
1026  (void) CloneString(&annotate_info->font,type_info->glyphs);
1027  status=RenderFreetype(image,annotate_info,type_info->encoding,offset,metrics,
1028  exception);
1029  annotate_info=DestroyDrawInfo(annotate_info);
1030  return(status);
1031 }
1032 
1033 /*
1034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1035 % %
1036 % %
1037 % %
1038 + R e n d e r F r e e t y p e %
1039 % %
1040 % %
1041 % %
1042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1043 %
1044 % RenderFreetype() renders text on the image with a Truetype font. It also
1045 % returns the bounding box of the text relative to the image.
1046 %
1047 % The format of the RenderFreetype method is:
1048 %
1049 % MagickBooleanType RenderFreetype(Image *image,DrawInfo *draw_info,
1050 % const char *encoding,const PointInfo *offset,TypeMetric *metrics,
1051 % ExceptionInfo *exception)
1052 %
1053 % A description of each parameter follows:
1054 %
1055 % o image: the image.
1056 %
1057 % o draw_info: the draw info.
1058 %
1059 % o encoding: the font encoding.
1060 %
1061 % o offset: (x,y) location of text relative to image.
1062 %
1063 % o metrics: bounding box of text.
1064 %
1065 % o exception: return any errors or warnings in this structure.
1066 %
1067 */
1068 
1069 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
1070 
1071 static size_t ComplexTextLayout(const Image *image,const DrawInfo *draw_info,
1072  const char *text,const size_t length,const FT_Face face,const FT_Int32 flags,
1073  GraphemeInfo **grapheme,ExceptionInfo *exception)
1074 {
1075 #if defined(MAGICKCORE_RAQM_DELEGATE)
1076  const char
1077  *features;
1078 
1079  raqm_t
1080  *rq;
1081 
1082  raqm_glyph_t
1083  *glyphs;
1084 
1085  register size_t
1086  i;
1087 
1088  size_t
1089  extent;
1090 
1091  extent=0;
1092  rq=raqm_create();
1093  if (rq == (raqm_t *) NULL)
1094  goto cleanup;
1095  if (raqm_set_text_utf8(rq,text,length) == 0)
1096  goto cleanup;
1097  if (raqm_set_par_direction(rq,(raqm_direction_t) draw_info->direction) == 0)
1098  goto cleanup;
1099  if (raqm_set_freetype_face(rq,face) == 0)
1100  goto cleanup;
1101  features=GetImageProperty(image,"type:features",exception);
1102  if (features != (const char *) NULL)
1103  {
1104  char
1105  breaker,
1106  quote,
1107  *token;
1108 
1109  int
1110  next,
1111  status_token;
1112 
1113  TokenInfo
1114  *token_info;
1115 
1116  next=0;
1117  token_info=AcquireTokenInfo();
1118  token=AcquireString("");
1119  status_token=Tokenizer(token_info,0,token,50,features,"",",","",'\0',
1120  &breaker,&next,&quote);
1121  while (status_token == 0)
1122  {
1123  raqm_add_font_feature(rq,token,strlen(token));
1124  status_token=Tokenizer(token_info,0,token,50,features,"",",","",'\0',
1125  &breaker,&next,&quote);
1126  }
1127  token_info=DestroyTokenInfo(token_info);
1128  token=DestroyString(token);
1129  }
1130  if (raqm_layout(rq) == 0)
1131  goto cleanup;
1132  glyphs=raqm_get_glyphs(rq,&extent);
1133  if (glyphs == (raqm_glyph_t *) NULL)
1134  {
1135  extent=0;
1136  goto cleanup;
1137  }
1138  *grapheme=(GraphemeInfo *) AcquireQuantumMemory(extent,sizeof(**grapheme));
1139  if (*grapheme == (GraphemeInfo *) NULL)
1140  {
1141  extent=0;
1142  goto cleanup;
1143  }
1144  for (i=0; i < (ssize_t) extent; i++)
1145  {
1146  (*grapheme)[i].index=glyphs[i].index;
1147  (*grapheme)[i].x_offset=glyphs[i].x_offset;
1148  (*grapheme)[i].x_advance=glyphs[i].x_advance;
1149  (*grapheme)[i].y_offset=glyphs[i].y_offset;
1150  (*grapheme)[i].cluster=glyphs[i].cluster;
1151  }
1152 
1153 cleanup:
1154  raqm_destroy(rq);
1155  return(extent);
1156 #else
1157  const char
1158  *p;
1159 
1160  FT_Error
1161  ft_status;
1162 
1163  register ssize_t
1164  i;
1165 
1166  ssize_t
1167  last_glyph;
1168 
1169  magick_unreferenced(image);
1170  magick_unreferenced(exception);
1171 
1172  /*
1173  Simple layout for bi-directional text (right-to-left or left-to-right).
1174  */
1175  *grapheme=(GraphemeInfo *) AcquireQuantumMemory(length+1,sizeof(**grapheme));
1176  if (*grapheme == (GraphemeInfo *) NULL)
1177  return(0);
1178  last_glyph=0;
1179  p=text;
1180  for (i=0; GetUTFCode(p) != 0; p+=GetUTFOctets(p), i++)
1181  {
1182  (*grapheme)[i].index=(ssize_t) FT_Get_Char_Index(face,GetUTFCode(p));
1183  (*grapheme)[i].x_offset=0;
1184  (*grapheme)[i].y_offset=0;
1185  if (((*grapheme)[i].index != 0) && (last_glyph != 0))
1186  {
1187  if (FT_HAS_KERNING(face))
1188  {
1189  FT_Vector
1190  kerning;
1191 
1192  ft_status=FT_Get_Kerning(face,(FT_UInt) last_glyph,(FT_UInt)
1193  (*grapheme)[i].index,ft_kerning_default,&kerning);
1194  if (ft_status == 0)
1195  (*grapheme)[i-1].x_advance+=(FT_Pos) ((draw_info->direction ==
1196  RightToLeftDirection ? -1.0 : 1.0)*kerning.x);
1197  }
1198  }
1199  ft_status=FT_Load_Glyph(face,(FT_UInt) (*grapheme)[i].index,flags);
1200  (*grapheme)[i].x_advance=face->glyph->advance.x;
1201  (*grapheme)[i].cluster=p-text;
1202  last_glyph=(*grapheme)[i].index;
1203  }
1204  return((size_t) i);
1205 #endif
1206 }
1207 
1208 static int TraceCubicBezier(FT_Vector *p,FT_Vector *q,FT_Vector *to,
1209  DrawInfo *draw_info)
1210 {
1211  AffineMatrix
1212  affine;
1213 
1214  char
1215  path[MagickPathExtent];
1216 
1217  affine=draw_info->affine;
1218  (void) FormatLocaleString(path,MagickPathExtent,"C%g,%g %g,%g %g,%g",
1219  affine.tx+p->x/64.0,affine.ty-p->y/64.0,affine.tx+q->x/64.0,affine.ty-
1220  q->y/64.0,affine.tx+to->x/64.0,affine.ty-to->y/64.0);
1221  (void) ConcatenateString(&draw_info->primitive,path);
1222  return(0);
1223 }
1224 
1225 static int TraceLineTo(FT_Vector *to,DrawInfo *draw_info)
1226 {
1227  AffineMatrix
1228  affine;
1229 
1230  char
1231  path[MagickPathExtent];
1232 
1233  affine=draw_info->affine;
1234  (void) FormatLocaleString(path,MagickPathExtent,"L%g,%g",affine.tx+to->x/64.0,
1235  affine.ty-to->y/64.0);
1236  (void) ConcatenateString(&draw_info->primitive,path);
1237  return(0);
1238 }
1239 
1240 static int TraceMoveTo(FT_Vector *to,DrawInfo *draw_info)
1241 {
1242  AffineMatrix
1243  affine;
1244 
1245  char
1246  path[MagickPathExtent];
1247 
1248  affine=draw_info->affine;
1249  (void) FormatLocaleString(path,MagickPathExtent,"M%g,%g",affine.tx+to->x/64.0,
1250  affine.ty-to->y/64.0);
1251  (void) ConcatenateString(&draw_info->primitive,path);
1252  return(0);
1253 }
1254 
1255 static int TraceQuadraticBezier(FT_Vector *control,FT_Vector *to,
1256  DrawInfo *draw_info)
1257 {
1258  AffineMatrix
1259  affine;
1260 
1261  char
1262  path[MagickPathExtent];
1263 
1264  affine=draw_info->affine;
1265  (void) FormatLocaleString(path,MagickPathExtent,"Q%g,%g %g,%g",affine.tx+
1266  control->x/64.0,affine.ty-control->y/64.0,affine.tx+to->x/64.0,affine.ty-
1267  to->y/64.0);
1268  (void) ConcatenateString(&draw_info->primitive,path);
1269  return(0);
1270 }
1271 
1272 static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
1273  const char *encoding,const PointInfo *offset,TypeMetric *metrics,
1274  ExceptionInfo *exception)
1275 {
1276 #if !defined(FT_OPEN_PATHNAME)
1277 #define FT_OPEN_PATHNAME ft_open_pathname
1278 #endif
1279 
1280  typedef struct _GlyphInfo
1281  {
1282  FT_UInt
1283  id;
1284 
1285  FT_Vector
1286  origin;
1287 
1288  FT_Glyph
1289  image;
1290  } GlyphInfo;
1291 
1292  const char
1293  *value;
1294 
1295  DrawInfo
1296  *annotate_info;
1297 
1298  FT_BBox
1299  bounds;
1300 
1301  FT_BitmapGlyph
1302  bitmap;
1303 
1304  FT_Encoding
1305  encoding_type;
1306 
1307  FT_Error
1308  ft_status;
1309 
1310  FT_Face
1311  face;
1312 
1313  FT_Int32
1314  flags;
1315 
1316  FT_Library
1317  library;
1318 
1319  FT_Matrix
1320  affine;
1321 
1322  FT_Open_Args
1323  args;
1324 
1325  FT_Vector
1326  origin;
1327 
1328  GlyphInfo
1329  glyph,
1330  last_glyph;
1331 
1332  GraphemeInfo
1333  *grapheme;
1334 
1336  status;
1337 
1338  PointInfo
1339  point,
1340  resolution;
1341 
1342  register char
1343  *p;
1344 
1345  register ssize_t
1346  i;
1347 
1348  size_t
1349  length;
1350 
1351  ssize_t
1352  code,
1353  y;
1354 
1355  static FT_Outline_Funcs
1356  OutlineMethods =
1357  {
1358  (FT_Outline_MoveTo_Func) TraceMoveTo,
1359  (FT_Outline_LineTo_Func) TraceLineTo,
1360  (FT_Outline_ConicTo_Func) TraceQuadraticBezier,
1361  (FT_Outline_CubicTo_Func) TraceCubicBezier,
1362  0, 0
1363  };
1364 
1365  unsigned char
1366  *utf8;
1367 
1368  /*
1369  Initialize Truetype library.
1370  */
1371  ft_status=FT_Init_FreeType(&library);
1372  if (ft_status != 0)
1373  ThrowBinaryException(TypeError,"UnableToInitializeFreetypeLibrary",
1374  image->filename);
1375  args.flags=FT_OPEN_PATHNAME;
1376  if (draw_info->font == (char *) NULL)
1377  args.pathname=ConstantString("helvetica");
1378  else
1379  if (*draw_info->font != '@')
1380  args.pathname=ConstantString(draw_info->font);
1381  else
1382  args.pathname=ConstantString(draw_info->font+1);
1383  face=(FT_Face) NULL;
1384  ft_status=FT_Open_Face(library,&args,(long) draw_info->face,&face);
1385  if (ft_status != 0)
1386  {
1387  (void) FT_Done_FreeType(library);
1388  (void) ThrowMagickException(exception,GetMagickModule(),TypeError,
1389  "UnableToReadFont","`%s'",args.pathname);
1390  args.pathname=DestroyString(args.pathname);
1391  return(MagickFalse);
1392  }
1393  args.pathname=DestroyString(args.pathname);
1394  if ((draw_info->metrics != (char *) NULL) &&
1395  (IsPathAccessible(draw_info->metrics) != MagickFalse))
1396  (void) FT_Attach_File(face,draw_info->metrics);
1397  encoding_type=ft_encoding_unicode;
1398  ft_status=FT_Select_Charmap(face,encoding_type);
1399  if ((ft_status != 0) && (face->num_charmaps != 0))
1400  ft_status=FT_Set_Charmap(face,face->charmaps[0]);
1401  if (encoding != (const char *) NULL)
1402  {
1403  if (LocaleCompare(encoding,"AdobeCustom") == 0)
1404  encoding_type=ft_encoding_adobe_custom;
1405  if (LocaleCompare(encoding,"AdobeExpert") == 0)
1406  encoding_type=ft_encoding_adobe_expert;
1407  if (LocaleCompare(encoding,"AdobeStandard") == 0)
1408  encoding_type=ft_encoding_adobe_standard;
1409  if (LocaleCompare(encoding,"AppleRoman") == 0)
1410  encoding_type=ft_encoding_apple_roman;
1411  if (LocaleCompare(encoding,"BIG5") == 0)
1412  encoding_type=ft_encoding_big5;
1413  if (LocaleCompare(encoding,"GB2312") == 0)
1414  encoding_type=ft_encoding_gb2312;
1415  if (LocaleCompare(encoding,"Johab") == 0)
1416  encoding_type=ft_encoding_johab;
1417 #if defined(ft_encoding_latin_1)
1418  if (LocaleCompare(encoding,"Latin-1") == 0)
1419  encoding_type=ft_encoding_latin_1;
1420 #endif
1421  if (LocaleCompare(encoding,"Latin-2") == 0)
1422  encoding_type=ft_encoding_latin_2;
1423  if (LocaleCompare(encoding,"None") == 0)
1424  encoding_type=ft_encoding_none;
1425  if (LocaleCompare(encoding,"SJIScode") == 0)
1426  encoding_type=ft_encoding_sjis;
1427  if (LocaleCompare(encoding,"Symbol") == 0)
1428  encoding_type=ft_encoding_symbol;
1429  if (LocaleCompare(encoding,"Unicode") == 0)
1430  encoding_type=ft_encoding_unicode;
1431  if (LocaleCompare(encoding,"Wansung") == 0)
1432  encoding_type=ft_encoding_wansung;
1433  ft_status=FT_Select_Charmap(face,encoding_type);
1434  if (ft_status != 0)
1435  {
1436  (void) FT_Done_Face(face);
1437  (void) FT_Done_FreeType(library);
1438  ThrowBinaryException(TypeError,"UnrecognizedFontEncoding",encoding);
1439  }
1440  }
1441  /*
1442  Set text size.
1443  */
1444  resolution.x=DefaultResolution;
1445  resolution.y=DefaultResolution;
1446  if (draw_info->density != (char *) NULL)
1447  {
1448  GeometryInfo
1449  geometry_info;
1450 
1452  geometry_flags;
1453 
1454  geometry_flags=ParseGeometry(draw_info->density,&geometry_info);
1455  resolution.x=geometry_info.rho;
1456  resolution.y=geometry_info.sigma;
1457  if ((geometry_flags & SigmaValue) == 0)
1458  resolution.y=resolution.x;
1459  }
1460  ft_status=FT_Set_Char_Size(face,(FT_F26Dot6) (64.0*draw_info->pointsize),
1461  (FT_F26Dot6) (64.0*draw_info->pointsize),(FT_UInt) resolution.x,
1462  (FT_UInt) resolution.y);
1463  if (ft_status != 0)
1464  {
1465  (void) FT_Done_Face(face);
1466  (void) FT_Done_FreeType(library);
1467  ThrowBinaryException(TypeError,"UnableToReadFont",draw_info->font);
1468  }
1469  metrics->pixels_per_em.x=face->size->metrics.x_ppem;
1470  metrics->pixels_per_em.y=face->size->metrics.y_ppem;
1471  metrics->ascent=(double) face->size->metrics.ascender/64.0;
1472  metrics->descent=(double) face->size->metrics.descender/64.0;
1473  metrics->width=0;
1474  metrics->origin.x=0;
1475  metrics->origin.y=0;
1476  metrics->height=(double) face->size->metrics.height/64.0;
1477  metrics->max_advance=0.0;
1478  if (face->size->metrics.max_advance > MagickEpsilon)
1479  metrics->max_advance=(double) face->size->metrics.max_advance/64.0;
1480  metrics->bounds.x1=0.0;
1481  metrics->bounds.y1=metrics->descent;
1482  metrics->bounds.x2=metrics->ascent+metrics->descent;
1483  metrics->bounds.y2=metrics->ascent+metrics->descent;
1484  metrics->underline_position=face->underline_position/64.0;
1485  metrics->underline_thickness=face->underline_thickness/64.0;
1486  if ((draw_info->text == (char *) NULL) || (*draw_info->text == '\0'))
1487  {
1488  (void) FT_Done_Face(face);
1489  (void) FT_Done_FreeType(library);
1490  return(MagickTrue);
1491  }
1492  /*
1493  Compute bounding box.
1494  */
1495  if (image->debug != MagickFalse)
1496  (void) LogMagickEvent(AnnotateEvent,GetMagickModule(),"Font %s; "
1497  "font-encoding %s; text-encoding %s; pointsize %g",
1498  draw_info->font != (char *) NULL ? draw_info->font : "none",
1499  encoding != (char *) NULL ? encoding : "none",
1500  draw_info->encoding != (char *) NULL ? draw_info->encoding : "none",
1501  draw_info->pointsize);
1502  flags=FT_LOAD_DEFAULT;
1503  if (draw_info->render == MagickFalse)
1504  flags=FT_LOAD_NO_BITMAP;
1505  if (draw_info->text_antialias == MagickFalse)
1506  flags|=FT_LOAD_TARGET_MONO;
1507  else
1508  {
1509 #if defined(FT_LOAD_TARGET_LIGHT)
1510  flags|=FT_LOAD_TARGET_LIGHT;
1511 #elif defined(FT_LOAD_TARGET_LCD)
1512  flags|=FT_LOAD_TARGET_LCD;
1513 #endif
1514  }
1515  value=GetImageProperty(image,"type:hinting",exception);
1516  if ((value != (const char *) NULL) && (LocaleCompare(value,"off") == 0))
1517  flags|=FT_LOAD_NO_HINTING;
1518  glyph.id=0;
1519  glyph.image=NULL;
1520  last_glyph.id=0;
1521  last_glyph.image=NULL;
1522  origin.x=0;
1523  origin.y=0;
1524  affine.xx=65536L;
1525  affine.yx=0L;
1526  affine.xy=0L;
1527  affine.yy=65536L;
1528  if (draw_info->render != MagickFalse)
1529  {
1530  affine.xx=(FT_Fixed) (65536L*draw_info->affine.sx+0.5);
1531  affine.yx=(FT_Fixed) (-65536L*draw_info->affine.rx+0.5);
1532  affine.xy=(FT_Fixed) (-65536L*draw_info->affine.ry+0.5);
1533  affine.yy=(FT_Fixed) (65536L*draw_info->affine.sy+0.5);
1534  }
1535  annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
1536  if (annotate_info->dash_pattern != (double *) NULL)
1537  annotate_info->dash_pattern[0]=0.0;
1538  (void) CloneString(&annotate_info->primitive,"path '");
1539  status=MagickTrue;
1540  if (draw_info->render != MagickFalse)
1541  {
1542  if (image->storage_class != DirectClass)
1543  (void) SetImageStorageClass(image,DirectClass,exception);
1544  if (image->alpha_trait == UndefinedPixelTrait)
1545  (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
1546  }
1547  point.x=0.0;
1548  point.y=0.0;
1549  for (p=draw_info->text; GetUTFCode(p) != 0; p+=GetUTFOctets(p))
1550  if (GetUTFCode(p) < 0)
1551  break;
1552  utf8=(unsigned char *) NULL;
1553  if (GetUTFCode(p) == 0)
1554  p=draw_info->text;
1555  else
1556  {
1557  utf8=ConvertLatin1ToUTF8((unsigned char *) draw_info->text);
1558  if (utf8 != (unsigned char *) NULL)
1559  p=(char *) utf8;
1560  }
1561  grapheme=(GraphemeInfo *) NULL;
1562  length=ComplexTextLayout(image,draw_info,p,strlen(p),face,flags,&grapheme,
1563  exception);
1564  code=0;
1565  for (i=0; i < (ssize_t) length; i++)
1566  {
1567  /*
1568  Render UTF-8 sequence.
1569  */
1570  glyph.id=(FT_UInt) grapheme[i].index;
1571  if (glyph.id == 0)
1572  glyph.id=FT_Get_Char_Index(face,'?');
1573  if ((glyph.id != 0) && (last_glyph.id != 0))
1574  origin.x+=(FT_Pos) (64.0*draw_info->kerning);
1575  glyph.origin=origin;
1576  glyph.origin.x+=(FT_Pos) grapheme[i].x_offset;
1577  glyph.origin.y+=(FT_Pos) grapheme[i].y_offset;
1578  ft_status=FT_Load_Glyph(face,glyph.id,flags);
1579  if (ft_status != 0)
1580  continue;
1581  ft_status=FT_Get_Glyph(face->glyph,&glyph.image);
1582  if (ft_status != 0)
1583  continue;
1584  ft_status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
1585  &bounds);
1586  if (ft_status != 0)
1587  continue;
1588  if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
1589  if (bounds.xMin != 0)
1590  metrics->bounds.x1=(double) bounds.xMin;
1591  if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
1592  if (bounds.yMin != 0)
1593  metrics->bounds.y1=(double) bounds.yMin;
1594  if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
1595  if (bounds.xMax != 0)
1596  metrics->bounds.x2=(double) bounds.xMax;
1597  if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
1598  if (bounds.yMax != 0)
1599  metrics->bounds.y2=(double) bounds.yMax;
1600  if (((draw_info->stroke.alpha != TransparentAlpha) ||
1601  (draw_info->stroke_pattern != (Image *) NULL)) &&
1602  ((status != MagickFalse) && (draw_info->render != MagickFalse)))
1603  {
1604  /*
1605  Trace the glyph.
1606  */
1607  annotate_info->affine.tx=glyph.origin.x/64.0;
1608  annotate_info->affine.ty=(-glyph.origin.y/64.0);
1609  (void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)->outline,
1610  &OutlineMethods,annotate_info);
1611  }
1612  FT_Vector_Transform(&glyph.origin,&affine);
1613  (void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin);
1614  ft_status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal,
1615  (FT_Vector *) NULL,MagickTrue);
1616  if (ft_status != 0)
1617  continue;
1618  bitmap=(FT_BitmapGlyph) glyph.image;
1619  point.x=offset->x+bitmap->left;
1620  if (bitmap->bitmap.pixel_mode == ft_pixel_mode_mono)
1621  point.x=offset->x+(origin.x >> 6);
1622  point.y=offset->y-bitmap->top;
1623  if (draw_info->render != MagickFalse)
1624  {
1625  CacheView
1626  *image_view;
1627 
1629  transparent_fill;
1630 
1631  register unsigned char
1632  *r;
1633 
1634  /*
1635  Rasterize the glyph.
1636  */
1637  transparent_fill=((draw_info->fill.alpha == TransparentAlpha) &&
1638  (draw_info->fill_pattern == (Image *) NULL) &&
1639  (draw_info->stroke.alpha == TransparentAlpha) &&
1640  (draw_info->stroke_pattern == (Image *) NULL)) ? MagickTrue :
1641  MagickFalse;
1642  image_view=AcquireAuthenticCacheView(image,exception);
1643  r=bitmap->bitmap.buffer;
1644  for (y=0; y < (ssize_t) bitmap->bitmap.rows; y++)
1645  {
1646  double
1647  fill_opacity;
1648 
1650  active,
1651  sync;
1652 
1653  PixelInfo
1654  fill_color;
1655 
1656  register Quantum
1657  *magick_restrict q;
1658 
1659  register ssize_t
1660  x;
1661 
1662  ssize_t
1663  n,
1664  x_offset,
1665  y_offset;
1666 
1667  if (status == MagickFalse)
1668  continue;
1669  x_offset=(ssize_t) ceil(point.x-0.5);
1670  y_offset=(ssize_t) ceil(point.y+y-0.5);
1671  if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
1672  continue;
1673  q=(Quantum *) NULL;
1674  if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
1675  active=MagickFalse;
1676  else
1677  {
1678  q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,
1679  bitmap->bitmap.width,1,exception);
1680  active=q != (Quantum *) NULL ? MagickTrue : MagickFalse;
1681  }
1682  n=y*bitmap->bitmap.pitch-1;
1683  for (x=0; x < (ssize_t) bitmap->bitmap.width; x++)
1684  {
1685  n++;
1686  x_offset++;
1687  if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
1688  {
1689  if (q != (Quantum *) NULL)
1690  q+=GetPixelChannels(image);
1691  continue;
1692  }
1693  if (bitmap->bitmap.pixel_mode != ft_pixel_mode_mono)
1694  fill_opacity=(double) (r[n])/(bitmap->bitmap.num_grays-1);
1695  else
1696  fill_opacity=((r[(x >> 3)+y*bitmap->bitmap.pitch] &
1697  (1 << (~x & 0x07)))) == 0 ? 0.0 : 1.0;
1698  if (draw_info->text_antialias == MagickFalse)
1699  fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0;
1700  if (active == MagickFalse)
1701  q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
1702  exception);
1703  if (q == (Quantum *) NULL)
1704  continue;
1705  if (transparent_fill == MagickFalse)
1706  {
1707  GetPixelInfo(image,&fill_color);
1708  GetFillColor(draw_info,x_offset,y_offset,&fill_color,
1709  exception);
1710  fill_opacity=fill_opacity*fill_color.alpha;
1711  CompositePixelOver(image,&fill_color,fill_opacity,q,
1712  GetPixelAlpha(image,q),q);
1713  }
1714  else
1715  {
1716  double
1717  Sa,
1718  Da;
1719 
1720  Da=1.0-(QuantumScale*GetPixelAlpha(image,q));
1721  Sa=fill_opacity;
1722  fill_opacity=(1.0-RoundToUnity(Sa+Da-Sa*Da))*QuantumRange;
1723  SetPixelAlpha(image,fill_opacity,q);
1724  }
1725  if (active == MagickFalse)
1726  {
1727  sync=SyncCacheViewAuthenticPixels(image_view,exception);
1728  if (sync == MagickFalse)
1729  status=MagickFalse;
1730  }
1731  q+=GetPixelChannels(image);
1732  }
1733  sync=SyncCacheViewAuthenticPixels(image_view,exception);
1734  if (sync == MagickFalse)
1735  status=MagickFalse;
1736  }
1737  image_view=DestroyCacheView(image_view);
1738  if (((draw_info->stroke.alpha != TransparentAlpha) ||
1739  (draw_info->stroke_pattern != (Image *) NULL)) &&
1740  (status != MagickFalse))
1741  {
1742  /*
1743  Draw text stroke.
1744  */
1745  annotate_info->linejoin=RoundJoin;
1746  annotate_info->affine.tx=offset->x;
1747  annotate_info->affine.ty=offset->y;
1748  (void) ConcatenateString(&annotate_info->primitive,"'");
1749  (void) DrawImage(image,annotate_info,exception);
1750  (void) CloneString(&annotate_info->primitive,"path '");
1751  }
1752  }
1753  if ((fabs(draw_info->interword_spacing) >= MagickEpsilon) &&
1754  (IsUTFSpace(GetUTFCode(p+grapheme[i].cluster)) != MagickFalse) &&
1755  (IsUTFSpace(code) == MagickFalse))
1756  origin.x+=(FT_Pos) (64.0*draw_info->interword_spacing);
1757  else
1758  origin.x+=(FT_Pos) grapheme[i].x_advance;
1759  metrics->origin.x=(double) origin.x;
1760  metrics->origin.y=(double) origin.y;
1761  if (metrics->origin.x > metrics->width)
1762  metrics->width=metrics->origin.x;
1763  if (last_glyph.id != 0)
1764  FT_Done_Glyph(last_glyph.image);
1765  last_glyph=glyph;
1766  code=GetUTFCode(p+grapheme[i].cluster);
1767  }
1768  if (grapheme != (GraphemeInfo *) NULL)
1769  grapheme=(GraphemeInfo *) RelinquishMagickMemory(grapheme);
1770  if (utf8 != (unsigned char *) NULL)
1771  utf8=(unsigned char *) RelinquishMagickMemory(utf8);
1772  if (last_glyph.id != 0)
1773  FT_Done_Glyph(last_glyph.image);
1774  /*
1775  Determine font metrics.
1776  */
1777  metrics->bounds.x1/=64.0;
1778  metrics->bounds.y1/=64.0;
1779  metrics->bounds.x2/=64.0;
1780  metrics->bounds.y2/=64.0;
1781  metrics->origin.x/=64.0;
1782  metrics->origin.y/=64.0;
1783  metrics->width/=64.0;
1784  /*
1785  Relinquish resources.
1786  */
1787  annotate_info=DestroyDrawInfo(annotate_info);
1788  (void) FT_Done_Face(face);
1789  (void) FT_Done_FreeType(library);
1790  return(status);
1791 }
1792 #else
1793 static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
1794  const char *magick_unused(encoding),const PointInfo *offset,
1795  TypeMetric *metrics,ExceptionInfo *exception)
1796 {
1797  (void) ThrowMagickException(exception,GetMagickModule(),
1798  MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","'%s' (Freetype)",
1799  draw_info->font != (char *) NULL ? draw_info->font : "none");
1800  return(RenderPostscript(image,draw_info,offset,metrics,exception));
1801 }
1802 #endif
1803 
1804 /*
1805 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1806 % %
1807 % %
1808 % %
1809 + R e n d e r P o s t s c r i p t %
1810 % %
1811 % %
1812 % %
1813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1814 %
1815 % RenderPostscript() renders text on the image with a Postscript font. It
1816 % also returns the bounding box of the text relative to the image.
1817 %
1818 % The format of the RenderPostscript method is:
1819 %
1820 % MagickBooleanType RenderPostscript(Image *image,DrawInfo *draw_info,
1821 % const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception)
1822 %
1823 % A description of each parameter follows:
1824 %
1825 % o image: the image.
1826 %
1827 % o draw_info: the draw info.
1828 %
1829 % o offset: (x,y) location of text relative to image.
1830 %
1831 % o metrics: bounding box of text.
1832 %
1833 % o exception: return any errors or warnings in this structure.
1834 %
1835 */
1836 
1837 static char *EscapeParenthesis(const char *source)
1838 {
1839  char
1840  *destination;
1841 
1842  register char
1843  *q;
1844 
1845  register const char
1846  *p;
1847 
1848  size_t
1849  length;
1850 
1851  assert(source != (const char *) NULL);
1852  length=0;
1853  for (p=source; *p != '\0'; p++)
1854  {
1855  if ((*p == '\\') || (*p == '(') || (*p == ')'))
1856  {
1857  if (~length < 1)
1858  ThrowFatalException(ResourceLimitFatalError,"UnableToEscapeString");
1859  length++;
1860  }
1861  length++;
1862  }
1863  destination=(char *) NULL;
1864  if (~length >= (MagickPathExtent-1))
1865  destination=(char *) AcquireQuantumMemory(length+MagickPathExtent,
1866  sizeof(*destination));
1867  if (destination == (char *) NULL)
1868  ThrowFatalException(ResourceLimitFatalError,"UnableToEscapeString");
1869  *destination='\0';
1870  q=destination;
1871  for (p=source; *p != '\0'; p++)
1872  {
1873  if ((*p == '\\') || (*p == '(') || (*p == ')'))
1874  *q++='\\';
1875  *q++=(*p);
1876  }
1877  *q='\0';
1878  return(destination);
1879 }
1880 
1882  const DrawInfo *draw_info,const PointInfo *offset,TypeMetric *metrics,
1883  ExceptionInfo *exception)
1884 {
1885  char
1886  filename[MagickPathExtent],
1887  geometry[MagickPathExtent],
1888  *text;
1889 
1890  FILE
1891  *file;
1892 
1893  Image
1894  *annotate_image;
1895 
1896  ImageInfo
1897  *annotate_info;
1898 
1899  int
1900  unique_file;
1901 
1903  identity;
1904 
1905  PointInfo
1906  extent,
1907  point,
1908  resolution;
1909 
1910  register ssize_t
1911  i;
1912 
1913  size_t
1914  length;
1915 
1916  ssize_t
1917  y;
1918 
1919  /*
1920  Render label with a Postscript font.
1921  */
1922  if (image->debug != MagickFalse)
1924  "Font %s; pointsize %g",draw_info->font != (char *) NULL ?
1925  draw_info->font : "none",draw_info->pointsize);
1926  file=(FILE *) NULL;
1927  unique_file=AcquireUniqueFileResource(filename);
1928  if (unique_file != -1)
1929  file=fdopen(unique_file,"wb");
1930  if ((unique_file == -1) || (file == (FILE *) NULL))
1931  {
1932  ThrowFileException(exception,FileOpenError,"UnableToOpenFile",filename);
1933  return(MagickFalse);
1934  }
1935  (void) FormatLocaleFile(file,"%%!PS-Adobe-3.0\n");
1936  (void) FormatLocaleFile(file,"/ReencodeType\n");
1937  (void) FormatLocaleFile(file,"{\n");
1938  (void) FormatLocaleFile(file," findfont dup length\n");
1939  (void) FormatLocaleFile(file,
1940  " dict begin { 1 index /FID ne {def} {pop pop} ifelse } forall\n");
1941  (void) FormatLocaleFile(file,
1942  " /Encoding ISOLatin1Encoding def currentdict end definefont pop\n");
1943  (void) FormatLocaleFile(file,"} bind def\n");
1944  /*
1945  Sample to compute bounding box.
1946  */
1947  identity=(fabs(draw_info->affine.sx-draw_info->affine.sy) < MagickEpsilon) &&
1948  (fabs(draw_info->affine.rx) < MagickEpsilon) &&
1949  (fabs(draw_info->affine.ry) < MagickEpsilon) ? MagickTrue : MagickFalse;
1950  extent.x=0.0;
1951  extent.y=0.0;
1952  length=strlen(draw_info->text);
1953  for (i=0; i <= (ssize_t) (length+2); i++)
1954  {
1955  point.x=fabs(draw_info->affine.sx*i*draw_info->pointsize+
1956  draw_info->affine.ry*2.0*draw_info->pointsize);
1957  point.y=fabs(draw_info->affine.rx*i*draw_info->pointsize+
1958  draw_info->affine.sy*2.0*draw_info->pointsize);
1959  if (point.x > extent.x)
1960  extent.x=point.x;
1961  if (point.y > extent.y)
1962  extent.y=point.y;
1963  }
1964  (void) FormatLocaleFile(file,"%g %g moveto\n",identity != MagickFalse ? 0.0 :
1965  extent.x/2.0,extent.y/2.0);
1966  (void) FormatLocaleFile(file,"%g %g scale\n",draw_info->pointsize,
1967  draw_info->pointsize);
1968  if ((draw_info->font == (char *) NULL) || (*draw_info->font == '\0') ||
1969  (strchr(draw_info->font,'/') != (char *) NULL))
1970  (void) FormatLocaleFile(file,
1971  "/Times-Roman-ISO dup /Times-Roman ReencodeType findfont setfont\n");
1972  else
1973  (void) FormatLocaleFile(file,
1974  "/%s-ISO dup /%s ReencodeType findfont setfont\n",draw_info->font,
1975  draw_info->font);
1976  (void) FormatLocaleFile(file,"[%g %g %g %g 0 0] concat\n",
1977  draw_info->affine.sx,-draw_info->affine.rx,-draw_info->affine.ry,
1978  draw_info->affine.sy);
1979  text=EscapeParenthesis(draw_info->text);
1980  if (identity == MagickFalse)
1981  (void) FormatLocaleFile(file,"(%s) stringwidth pop -0.5 mul -0.5 rmoveto\n",
1982  text);
1983  (void) FormatLocaleFile(file,"(%s) show\n",text);
1984  text=DestroyString(text);
1985  (void) FormatLocaleFile(file,"showpage\n");
1986  (void) fclose(file);
1987  (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g+0+0!",
1988  floor(extent.x+0.5),floor(extent.y+0.5));
1989  annotate_info=AcquireImageInfo();
1990  (void) FormatLocaleString(annotate_info->filename,MagickPathExtent,"ps:%s",
1991  filename);
1992  (void) CloneString(&annotate_info->page,geometry);
1993  if (draw_info->density != (char *) NULL)
1994  (void) CloneString(&annotate_info->density,draw_info->density);
1995  annotate_info->antialias=draw_info->text_antialias;
1996  annotate_image=ReadImage(annotate_info,exception);
1997  CatchException(exception);
1998  annotate_info=DestroyImageInfo(annotate_info);
1999  (void) RelinquishUniqueFileResource(filename);
2000  if (annotate_image == (Image *) NULL)
2001  return(MagickFalse);
2002  (void) NegateImage(annotate_image,MagickFalse,exception);
2003  resolution.x=DefaultResolution;
2004  resolution.y=DefaultResolution;
2005  if (draw_info->density != (char *) NULL)
2006  {
2007  GeometryInfo
2008  geometry_info;
2009 
2011  flags;
2012 
2013  flags=ParseGeometry(draw_info->density,&geometry_info);
2014  resolution.x=geometry_info.rho;
2015  resolution.y=geometry_info.sigma;
2016  if ((flags & SigmaValue) == 0)
2017  resolution.y=resolution.x;
2018  }
2019  if (identity == MagickFalse)
2020  (void) TransformImage(&annotate_image,"0x0",(char *) NULL,exception);
2021  else
2022  {
2024  crop_info;
2025 
2026  crop_info=GetImageBoundingBox(annotate_image,exception);
2027  crop_info.height=(size_t) ((resolution.y/DefaultResolution)*
2028  ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5);
2029  crop_info.y=(ssize_t) ceil((resolution.y/DefaultResolution)*extent.y/8.0-
2030  0.5);
2031  (void) FormatLocaleString(geometry,MagickPathExtent,
2032  "%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
2033  crop_info.height,(double) crop_info.x,(double) crop_info.y);
2034  (void) TransformImage(&annotate_image,geometry,(char *) NULL,exception);
2035  }
2036  metrics->pixels_per_em.x=(resolution.y/DefaultResolution)*
2037  ExpandAffine(&draw_info->affine)*draw_info->pointsize;
2038  metrics->pixels_per_em.y=metrics->pixels_per_em.x;
2039  metrics->ascent=metrics->pixels_per_em.x;
2040  metrics->descent=metrics->pixels_per_em.y/-5.0;
2041  metrics->width=(double) annotate_image->columns/
2042  ExpandAffine(&draw_info->affine);
2043  metrics->height=1.152*metrics->pixels_per_em.x;
2044  metrics->max_advance=metrics->pixels_per_em.x;
2045  metrics->bounds.x1=0.0;
2046  metrics->bounds.y1=metrics->descent;
2047  metrics->bounds.x2=metrics->ascent+metrics->descent;
2048  metrics->bounds.y2=metrics->ascent+metrics->descent;
2049  metrics->underline_position=(-2.0);
2050  metrics->underline_thickness=1.0;
2051  if (draw_info->render == MagickFalse)
2052  {
2053  annotate_image=DestroyImage(annotate_image);
2054  return(MagickTrue);
2055  }
2056  if (draw_info->fill.alpha != TransparentAlpha)
2057  {
2058  CacheView
2059  *annotate_view;
2060 
2062  sync;
2063 
2064  PixelInfo
2065  fill_color;
2066 
2067  /*
2068  Render fill color.
2069  */
2070  if (image->alpha_trait == UndefinedPixelTrait)
2071  (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
2072  if (annotate_image->alpha_trait == UndefinedPixelTrait)
2073  (void) SetImageAlphaChannel(annotate_image,OpaqueAlphaChannel,
2074  exception);
2075  fill_color=draw_info->fill;
2076  annotate_view=AcquireAuthenticCacheView(annotate_image,exception);
2077  for (y=0; y < (ssize_t) annotate_image->rows; y++)
2078  {
2079  register ssize_t
2080  x;
2081 
2082  register Quantum
2083  *magick_restrict q;
2084 
2085  q=GetCacheViewAuthenticPixels(annotate_view,0,y,annotate_image->columns,
2086  1,exception);
2087  if (q == (Quantum *) NULL)
2088  break;
2089  for (x=0; x < (ssize_t) annotate_image->columns; x++)
2090  {
2091  GetFillColor(draw_info,x,y,&fill_color,exception);
2092  SetPixelAlpha(annotate_image,ClampToQuantum((((double) QuantumScale*
2093  GetPixelIntensity(annotate_image,q)*fill_color.alpha))),q);
2094  SetPixelRed(annotate_image,fill_color.red,q);
2095  SetPixelGreen(annotate_image,fill_color.green,q);
2096  SetPixelBlue(annotate_image,fill_color.blue,q);
2097  q+=GetPixelChannels(annotate_image);
2098  }
2099  sync=SyncCacheViewAuthenticPixels(annotate_view,exception);
2100  if (sync == MagickFalse)
2101  break;
2102  }
2103  annotate_view=DestroyCacheView(annotate_view);
2104  (void) CompositeImage(image,annotate_image,OverCompositeOp,MagickTrue,
2105  (ssize_t) ceil(offset->x-0.5),(ssize_t) ceil(offset->y-(metrics->ascent+
2106  metrics->descent)-0.5),exception);
2107  }
2108  annotate_image=DestroyImage(annotate_image);
2109  return(MagickTrue);
2110 }
2111 
2112 /*
2113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2114 % %
2115 % %
2116 % %
2117 + R e n d e r X 1 1 %
2118 % %
2119 % %
2120 % %
2121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2122 %
2123 % RenderX11() renders text on the image with an X11 font. It also returns the
2124 % bounding box of the text relative to the image.
2125 %
2126 % The format of the RenderX11 method is:
2127 %
2128 % MagickBooleanType RenderX11(Image *image,DrawInfo *draw_info,
2129 % const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception)
2130 %
2131 % A description of each parameter follows:
2132 %
2133 % o image: the image.
2134 %
2135 % o draw_info: the draw info.
2136 %
2137 % o offset: (x,y) location of text relative to image.
2138 %
2139 % o metrics: bounding box of text.
2140 %
2141 % o exception: return any errors or warnings in this structure.
2142 %
2143 */
2144 static MagickBooleanType RenderX11(Image *image,const DrawInfo *draw_info,
2145  const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception)
2146 {
2148  status;
2149 
2150  if (annotate_semaphore == (SemaphoreInfo *) NULL)
2153  status=XRenderImage(image,draw_info,offset,metrics,exception);
2155  return(status);
2156 }
double psi
Definition: geometry.h:105
size_t rows
Definition: image.h:172
#define magick_restrict
Definition: MagickCore.h:41
size_t face
Definition: type.h:52
PixelInfo fill
Definition: draw.h:213
MagickExport MagickBooleanType NegateImage(Image *image, const MagickBooleanType grayscale, ExceptionInfo *exception)
Definition: enhance.c:3400
MagickExport CacheView * DestroyCacheView(CacheView *cache_view)
Definition: cache-view.c:252
PixelInfo undercolor
Definition: draw.h:213
MagickExport TokenInfo * DestroyTokenInfo(TokenInfo *token_info)
Definition: token.c:128
#define TransparentAlpha
Definition: image.h:26
char * primitive
Definition: draw.h:203
double x2
Definition: image.h:107
double rx
Definition: geometry.h:94
MagickExport ImageInfo * AcquireImageInfo(void)
Definition: image.c:341
MagickPrivate void AnnotateComponentTerminus(void)
Definition: annotate.c:188
double interword_spacing
Definition: draw.h:311
static Quantum GetPixelAlpha(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
GravityType gravity
Definition: draw.h:284
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:450
MagickExport const TypeInfo * GetTypeInfo(const char *name, ExceptionInfo *exception)
Definition: type.c:276
double interline_spacing
Definition: draw.h:311
#define ThrowFatalException(severity, tag)
PixelInfo stroke
Definition: draw.h:213
double ty
Definition: geometry.h:94
size_t cluster
Definition: annotate.c:123
char * metrics
Definition: type.h:70
double kerning
Definition: draw.h:311
Definition: draw.h:89
double rho
Definition: geometry.h:105
static void GetFillColor(const DrawInfo *draw_info, const ssize_t x, const ssize_t y, PixelInfo *fill, ExceptionInfo *exception)
Definition: draw-private.h:29
MagickExport void SetGeometryInfo(GeometryInfo *geometry_info)
Definition: geometry.c:1605
Image * fill_pattern
Definition: draw.h:219
MagickExport size_t ConcatenateMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:410
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
Definition: semaphore.c:192
MagickBooleanType render
Definition: draw.h:305
MagickRealType red
Definition: pixel.h:188
static MagickBooleanType IsUTFSpace(int code)
MagickBooleanType antialias
Definition: image.h:375
double pointsize
Definition: draw.h:275
StyleType style
Definition: draw.h:263
DecorationType decorate
Definition: draw.h:248
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:473
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
static MagickBooleanType RenderPostscript(Image *, const DrawInfo *, const PointInfo *, TypeMetric *, ExceptionInfo *)
Definition: annotate.c:1881
size_t y_offset
Definition: annotate.c:117
MagickRealType alpha
Definition: pixel.h:188
Definition: draw.h:33
#define MagickEpsilon
Definition: magick-type.h:110
double sigma
Definition: geometry.h:105
ClassType storage_class
Definition: image.h:154
MagickExport MagickBooleanType CompositeImage(Image *image, const Image *composite, const CompositeOperator compose, const MagickBooleanType clip_to_self, const ssize_t x_offset, const ssize_t y_offset, ExceptionInfo *exception)
Definition: composite.c:539
AffineMatrix affine
Definition: draw.h:210
size_t width
Definition: geometry.h:129
#define ThrowBinaryException(severity, tag, context)
Definition: log.h:52
MagickExport void GetPixelInfo(const Image *image, PixelInfo *pixel)
Definition: pixel.c:2161
Definition: image.h:151
double tx
Definition: geometry.h:94
double x
Definition: geometry.h:122
MagickExport TokenInfo * AcquireTokenInfo(void)
Definition: token.c:95
#define MagickCoreSignature
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport Quantum * GetCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:299
static MagickBooleanType RenderType(Image *, const DrawInfo *, const PointInfo *, TypeMetric *, ExceptionInfo *)
Definition: annotate.c:953
double stroke_width
Definition: draw.h:223
MagickExport double ExpandAffine(const AffineMatrix *affine)
Definition: gem.c:1420
MagickExport ssize_t FormatMagickCaption(Image *image, DrawInfo *draw_info, const MagickBooleanType split, TypeMetric *metrics, char **caption, ExceptionInfo *exception)
Definition: annotate.c:590
Image * stroke_pattern
Definition: draw.h:219
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
Definition: locale.c:378
MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, const AlphaChannelOption alpha_type, ExceptionInfo *exception)
Definition: channel.c:966
MagickBooleanType
Definition: magick-type.h:156
MagickExport char ** StringToList(const char *text)
Definition: string.c:2304
unsigned int MagickStatusType
Definition: magick-type.h:119
MagickExport char * AcquireString(const char *source)
Definition: string.c:124
MagickExport MagickStatusType ParsePageGeometry(const Image *image, const char *geometry, RectangleInfo *region_info, ExceptionInfo *exception)
Definition: geometry.c:1463
MagickExport int AcquireUniqueFileResource(char *path)
Definition: resource.c:549
MagickExport MagickBooleanType AnnotateImage(Image *image, const DrawInfo *draw_info, ExceptionInfo *exception)
Definition: annotate.c:272
static int GetUTFCode(const char *text)
double width
Definition: draw.h:354
MagickExport void * ResetMagickMemory(void *memory, int byte, const size_t size)
Definition: memory.c:1164
PointInfo origin
Definition: draw.h:366
double height
Definition: draw.h:354
double x1
Definition: image.h:107
double descent
Definition: draw.h:354
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:529
char filename[MagickPathExtent]
Definition: image.h:471
char * metrics
Definition: draw.h:254
size_t face
Definition: draw.h:260
double y
Definition: geometry.h:122
MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path)
Definition: resource.c:1131
MagickExport MagickBooleanType ConcatenateString(char **destination, const char *source)
Definition: string.c:476
#define magick_unused(x)
RectangleInfo page
Definition: image.h:212
MagickPrivate MagickBooleanType XRenderImage(Image *, const DrawInfo *, const PointInfo *, TypeMetric *, ExceptionInfo *)
Definition: xwindow.c:9968
size_t x_advance
Definition: annotate.c:117
char * family
Definition: draw.h:254
#define MagickPathExtent
double ry
Definition: geometry.h:94
char * glyphs
Definition: type.h:70
MagickExport MagickBooleanType DrawImage(Image *image, const DrawInfo *draw_info, ExceptionInfo *exception)
Definition: draw.c:1668
Definition: type.h:49
static SemaphoreInfo * annotate_semaphore
Definition: annotate.c:130
#define ThrowFileException(exception, severity, tag, context)
PixelTrait alpha_trait
Definition: image.h:280
MagickRealType blue
Definition: pixel.h:188
PointInfo pixels_per_em
Definition: draw.h:351
MagickExport Image * ReadImage(const ImageInfo *image_info, ExceptionInfo *exception)
Definition: constitute.c:358
static unsigned int GetUTFOctets(const char *text)
static MagickBooleanType RenderX11(Image *, const DrawInfo *, const PointInfo *, TypeMetric *, ExceptionInfo *)
Definition: annotate.c:2144
double sx
Definition: geometry.h:94
static unsigned char * ConvertLatin1ToUTF8(const unsigned char *content)
Definition: token-private.h:54
double y2
Definition: image.h:107
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1058
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1397
MagickExport MagickBooleanType IsPathAccessible(const char *path)
Definition: utility.c:1466
char * density
Definition: draw.h:278
size_t signature
Definition: image.h:354
#define QuantumScale
Definition: magick-type.h:113
size_t columns
Definition: image.h:172
MagickExport const TypeInfo * GetTypeInfoByFamily(const char *family, const StyleType style, const StretchType stretch, const size_t weight, ExceptionInfo *exception)
Definition: type.c:323
ssize_t x
Definition: geometry.h:133
StretchType stretch
Definition: draw.h:266
MagickExport DrawInfo * CloneDrawInfo(const ImageInfo *image_info, const DrawInfo *draw_info)
Definition: draw.c:242
size_t height
Definition: geometry.h:129
static void SetPixelBlue(const Image *magick_restrict image, const Quantum blue, Quantum *magick_restrict pixel)
MagickPrivate MagickBooleanType AnnotateComponentGenesis(void)
Definition: annotate.c:163
MagickExport MagickBooleanType SetImageStorageClass(Image *image, const ClassType storage_class, ExceptionInfo *exception)
Definition: image.c:2508
MagickExport void CatchException(ExceptionInfo *exception)
Definition: exception.c:196
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:742
static double RoundToUnity(const double value)
char * encoding
Definition: draw.h:272
static size_t GetPixelChannels(const Image *magick_restrict image)
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1409
char filename[MagickPathExtent]
Definition: image.h:319
double max_advance
Definition: draw.h:354
#define GetMagickModule()
Definition: log.h:28
double sy
Definition: geometry.h:94
double underline_thickness
Definition: draw.h:354
MagickExport MagickBooleanType GetMultilineTypeMetrics(Image *image, const DrawInfo *draw_info, TypeMetric *metrics, ExceptionInfo *exception)
Definition: annotate.c:770
static Quantum ClampToQuantum(const MagickRealType value)
Definition: quantum.h:84
char * density
Definition: image.h:404
SegmentInfo bounds
Definition: draw.h:363
MagickExport ImageInfo * DestroyImageInfo(ImageInfo *image_info)
Definition: image.c:1253
size_t signature
Definition: draw.h:322
MagickExport MagickBooleanType GetTypeMetrics(Image *image, const DrawInfo *draw_info, TypeMetric *metrics, ExceptionInfo *exception)
Definition: annotate.c:881
char * geometry
Definition: draw.h:203
unsigned short Quantum
Definition: magick-type.h:82
double xi
Definition: geometry.h:105
MagickExport RectangleInfo GetImageBoundingBox(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:125
MagickExport MagickBooleanType SetImageColorspace(Image *image, const ColorspaceType colorspace, ExceptionInfo *exception)
Definition: colorspace.c:1080
MagickExport DrawInfo * DestroyDrawInfo(DrawInfo *draw_info)
Definition: draw.c:822
MagickExport char * DestroyString(char *string)
Definition: string.c:810
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:97
size_t index
Definition: annotate.c:117
MagickExport const char * GetImageProperty(const Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:2185
AlignType align
Definition: draw.h:281
double underline_position
Definition: draw.h:354
static char * EscapeParenthesis(const char *source)
Definition: annotate.c:1837
MagickBooleanType text_antialias
Definition: draw.h:229
MagickExport MagickStatusType ParseGeometry(const char *geometry, GeometryInfo *geometry_info)
Definition: geometry.c:836
size_t x_offset
Definition: annotate.c:117
static void SetPixelAlpha(const Image *magick_restrict image, const Quantum alpha, Quantum *magick_restrict pixel)
MagickExport void SetGeometry(const Image *image, RectangleInfo *geometry)
Definition: geometry.c:1571
static MagickBooleanType RenderFreetype(Image *, const DrawInfo *, const char *, const PointInfo *, TypeMetric *, ExceptionInfo *)
char * text
Definition: draw.h:254
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1038
#define magick_unreferenced(x)
double ascent
Definition: draw.h:354
char * encoding
Definition: type.h:70
MagickRealType green
Definition: pixel.h:188
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:270
static void SetPixelRed(const Image *magick_restrict image, const Quantum red, Quantum *magick_restrict pixel)
#define MagickPrivate
#define MagickExport
MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *magick_restrict cache_view, ExceptionInfo *exception)
Definition: cache-view.c:1100
ssize_t y
Definition: geometry.h:133
MagickExport CacheView * AcquireAuthenticCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:112
MagickExport const double DefaultResolution
Definition: image.c:125
double y1
Definition: image.h:107
char * page
Definition: image.h:381
double * dash_pattern
Definition: draw.h:290
MagickExport MagickRealType GetPixelIntensity(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
Definition: pixel.c:2356
char * font
Definition: draw.h:254
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:351
DirectionType direction
Definition: draw.h:316
MagickExport Image * DestroyImage(Image *image)
Definition: image.c:1182
MagickExport char * ConstantString(const char *source)
Definition: string.c:687
ColorspaceType colorspace
Definition: image.h:157
#define QuantumRange
Definition: magick-type.h:83
MagickExport int Tokenizer(TokenInfo *token_info, const unsigned flag, char *token, const size_t max_token_length, const char *line, const char *white, const char *break_set, const char *quote, const char escape, char *breaker, int *next, char *quoted)
Definition: token.c:858
static void CompositePixelOver(const Image *image, const PixelInfo *p, const double alpha, const Quantum *q, const double beta, Quantum *composite)
MagickBooleanType debug
Definition: image.h:334
static void SetPixelGreen(const Image *magick_restrict image, const Quantum green, Quantum *magick_restrict pixel)
struct _GraphemeInfo GraphemeInfo
size_t weight
Definition: draw.h:269
MagickPrivate MagickBooleanType TransformImage(Image **, const char *, const char *, ExceptionInfo *)
Definition: transform.c:2079