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