annotate.c revision 03f187ee83f1927717c93c57af06d5e030a194be
13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% AAA N N N N OOO TTTTT AAA TTTTT EEEEE % 73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A A NN N NN N O O T A A T E % 83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% AAAAA N N N N N N O O T AAAAA T EEE % 93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A A N NN N NN O O T A A T E % 103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A A N N N N OOO T A A T EEEEE % 113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickCore Image Annotation Methods % 143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Software Design % 163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% John Cristy % 173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% July 1992 % 183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2045ef08fd6a09813e4a8f5ddadf85ba9e0ec2cdc7cristy% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization % 213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% dedicated to making software imaging solutions freely available. % 223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% You may not use this file except in compliance with the License. You may % 243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% obtain a copy of the License at % 253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% http://www.imagemagick.org/script/license.php % 273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Unless required by applicable law or agreed to in writing, software % 293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% distributed under the License is distributed on an "AS IS" BASIS, % 303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% See the License for the specific language governing permissions and % 323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% limitations under the License. % 333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Digital Applications (www.digapp.com) contributed the stroked text algorithm. 373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% It was written by Leonard Rosenthol. 383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Include declarations. 443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 454c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/studio.h" 464c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/annotate.h" 475ff4eaf57b3cd47d0371f204f865cbba614674a0cristy#include "MagickCore/annotate-private.h" 484c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/attribute.h" 494c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/cache-view.h" 504c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/client.h" 514c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/color.h" 524c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/color-private.h" 5354b92627b2e9657853beee431546d08234276477cristy#include "MagickCore/colorspace-private.h" 544c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/composite.h" 554c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/composite-private.h" 564c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/constitute.h" 574c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/draw.h" 584c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/draw-private.h" 593644bdf56f0081bcae1f4dbc69c2d06713f6203bcristy#include "MagickCore/enhance.h" 604c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception.h" 614c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception-private.h" 624c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/gem.h" 634c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/geometry.h" 644c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image-private.h" 654c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/log.h" 664c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/quantum.h" 674c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/quantum-private.h" 684c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/pixel-accessor.h" 694c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/property.h" 704c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/resource_.h" 714c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/semaphore.h" 724c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/statistic.h" 734c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/string_.h" 744c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/token-private.h" 754c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/transform.h" 764c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/type.h" 774c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/utility.h" 78d1dd6e4fefa0810b9893e6ac9418f79c97c1b39acristy#include "MagickCore/utility-private.h" 79bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy#include "MagickCore/xwindow.h" 804c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/xwindow-private.h" 813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_FREETYPE_DELEGATE) 8207a3cca00593c795eb8e0427f5bc4c2bcad3f0fbcristy#if defined(__MINGW32__) || defined(__MINGW64__) 833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# undef interface 843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 8503f187ee83f1927717c93c57af06d5e030a194becristy#include <ft2build.h> 863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(FT_FREETYPE_H) 873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include FT_FREETYPE_H 883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include <freetype/freetype.h> 903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(FT_GLYPH_H) 923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include FT_GLYPH_H 933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include <freetype/ftglyph.h> 953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(FT_OUTLINE_H) 973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include FT_OUTLINE_H 983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include <freetype/ftoutln.h> 1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(FT_BBOX_H) 1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include FT_BBOX_H 1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include <freetype/ftbbox.h> 1053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif /* defined(FT_BBOX_H) */ 1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 109d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy Annotate semaphores. 110d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy*/ 111d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristystatic SemaphoreInfo 112d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy *annotate_semaphore = (SemaphoreInfo *) NULL; 113d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy 114d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy/* 1153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Forward declarations. 1163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1173ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType 1185cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy RenderType(Image *,const DrawInfo *,const PointInfo *,TypeMetric *, 1195cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ExceptionInfo *), 1205cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy RenderPostscript(Image *,const DrawInfo *,const PointInfo *,TypeMetric *, 1215cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ExceptionInfo *), 1223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RenderFreetype(Image *,const DrawInfo *,const char *,const PointInfo *, 1235cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy TypeMetric *,ExceptionInfo *), 1245cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy RenderX11(Image *,const DrawInfo *,const PointInfo *,TypeMetric *, 1255cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ExceptionInfo *); 1263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 1303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 132d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy+ A n n o t a t e C o m p o n e n t G e n e s i s % 133d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 134d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 135d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 136d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 137d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 138d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% AnnotateComponentGenesis() instantiates the annotate component. 139d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 140d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% The format of the AnnotateComponentGenesis method is: 141d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 142d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% MagickBooleanType AnnotateComponentGenesis(void) 143d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 144d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy*/ 1455ff4eaf57b3cd47d0371f204f865cbba614674a0cristyMagickPrivate MagickBooleanType AnnotateComponentGenesis(void) 146d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{ 147d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy AcquireSemaphoreInfo(&annotate_semaphore); 148d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy return(MagickTrue); 149d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy} 150d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy 151d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy/* 152d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 153d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 154d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 155d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 156d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy+ 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 % 157d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 158d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 159d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 160d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 161d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 162d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% AnnotateComponentTerminus() destroys the annotate component. 163d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 164d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% The format of the AnnotateComponentTerminus method is: 165d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 166d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% AnnotateComponentTerminus(void) 167d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% 168d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy*/ 1695ff4eaf57b3cd47d0371f204f865cbba614674a0cristyMagickPrivate void AnnotateComponentTerminus(void) 170d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{ 171d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy if (annotate_semaphore == (SemaphoreInfo *) NULL) 172d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy AcquireSemaphoreInfo(&annotate_semaphore); 173d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy DestroySemaphoreInfo(&annotate_semaphore); 174d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy} 175d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy 176d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy/* 177d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 178d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 179d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 180d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy% % 1813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A n n o t a t e I m a g e % 1823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 1833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 1843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 1853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% AnnotateImage() annotates an image with text. Optionally you can include 1883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% any of the following bits of information about the image by embedding 1893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the appropriate special characters: 1903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %b file size in bytes. 1923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %c comment. 1933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %d directory in which the image resides. 1943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %e extension of the image file. 1953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %f original filename of the image. 1963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %h height of image. 1973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %i filename of the image. 1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %k number of unique colors. 1993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %l image label. 2003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %m image file format. 2013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %n number of images in a image sequence. 2023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %o output image filename. 2033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %p page number of the image. 2043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %q image depth (8 or 16). 2053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %q image depth (8 or 16). 2063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %s image scene number. 2073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %t image filename without any extension. 2083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %u a unique temporary filename. 2093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %w image width. 2103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %x x resolution of the image. 2113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% %y y resolution of the image. 2123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the AnnotateImage method is: 2143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2155cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% MagickBooleanType AnnotateImage(Image *image,DrawInfo *draw_info, 2165cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% ExceptionInfo *exception) 2173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 2193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 2213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 2233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2245cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 2255cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 2263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2273ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport MagickBooleanType AnnotateImage(Image *image, 2285cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const DrawInfo *draw_info,ExceptionInfo *exception) 2293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 2313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy primitive[MaxTextExtent], 2323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **textlist; 2333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo 2353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate, 2363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info; 2373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GeometryInfo 2393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry_info; 2403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 2423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 2433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PointInfo 2453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset; 2463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 2483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry; 2493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 250bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 2513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 2523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t 2543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length; 2553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TypeMetric 2573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics; 2583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 259bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 2605846039e7fade723e168819490eb771446e4b81fcristy height, 2613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_lines; 2623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 2643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image->signature == MagickSignature); 2653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 2663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 2673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info != (DrawInfo *) NULL); 2683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info->signature == MagickSignature); 2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->text == (char *) NULL) 2703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 2713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*draw_info->text == '\0') 2723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 2733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=StringToList(draw_info->text); 2743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (textlist == (char **) NULL) 2753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length=strlen(textlist[0]); 2773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=1; textlist[i] != (char *) NULL; i++) 2783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (strlen(textlist[i]) > length) 2793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length=strlen(textlist[i]); 280bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy number_lines=(size_t) i; 2813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate=CloneDrawInfo((ImageInfo *) NULL,draw_info); 2823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); 2833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetGeometry(image,&geometry); 2843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetGeometryInfo(&geometry_info); 2853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_info->geometry != (char *) NULL) 2863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ParsePageGeometry(image,annotate_info->geometry,&geometry, 2885cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy exception); 2893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ParseGeometry(annotate_info->geometry,&geometry_info); 2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2915cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) 2923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 293574c5b0416d0ed0db3a5c02e0230feb95bfa5b31cristy if (IsGrayColorspace(image->colorspace) != MagickFalse) 294b09db11cc8fa61710ac2bc9c46c06733c39d67b7cristy (void) TransformImageColorspace(image,RGBColorspace,exception); 2953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=MagickTrue; 2963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; textlist[i] != (char *) NULL; i++) 2973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 2993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Position text relative to image. 3003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.tx=geometry_info.xi-image->page.x; 3023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ty=geometry_info.psi-image->page.y; 3033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate->text,textlist[i]); 3045cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) GetTypeMetrics(image,annotate,&metrics,exception); 305bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy height=(ssize_t) (metrics.ascent-metrics.descent+ 3065846039e7fade723e168819490eb771446e4b81fcristy draw_info->interline_spacing+0.5); 3073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (annotate->gravity) 3083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case UndefinedGravity: 3103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 3113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height; 3133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height; 3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case NorthWestGravity: 3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* 3193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*height+annotate_info->affine.ry* 3203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (metrics.ascent+metrics.descent); 3213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* 3223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*height+annotate_info->affine.sy* 3233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.ascent; 3243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case NorthGravity: 3273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ 3293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.width/2.0+i*annotate_info->affine.ry*height- 3303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1)/2.0+ 3313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*(metrics.ascent+metrics.descent); 3323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* 3333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*height+annotate_info->affine.sy* 3343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.ascent-annotate_info->affine.rx*(metrics.width- 3353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.bounds.x1)/2.0; 3363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case NorthEastGravity: 3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ 3413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.width+i*annotate_info->affine.ry*height- 3423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1)+ 3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*(metrics.ascent+metrics.descent)-1.0; 3443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+i* 3453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*height+annotate_info->affine.sy* 3463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.ascent-annotate_info->affine.rx*(metrics.width- 3473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.bounds.x1); 3483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case WestGravity: 3513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* 3533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*height+annotate_info->affine.ry* 3543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (metrics.ascent+metrics.descent-(number_lines-1.0)*height)/2.0; 3553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ 3563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.height/2.0+i*annotate_info->affine.sy*height+ 3573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*(metrics.ascent+metrics.descent- 3583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_lines-1.0)*height)/2.0; 3593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case CenterGravity: 3623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ 3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.width/2.0+i*annotate_info->affine.ry*height- 3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1)/2.0+ 3663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*(metrics.ascent+metrics.descent- 3673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_lines-1)*height)/2.0; 3683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ 3693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.height/2.0+i*annotate_info->affine.sy*height- 3703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.rx*(metrics.width+metrics.bounds.x1)/2.0+ 3713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*(metrics.ascent+metrics.descent- 3723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_lines-1.0)*height)/2.0; 3733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case EastGravity: 3763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ 3783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.width+i*annotate_info->affine.ry*height- 3793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1)+ 3803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*(metrics.ascent+metrics.descent- 3813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_lines-1.0)*height)/2.0-1.0; 3823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? -1.0 : 1.0)*annotate_info->affine.ty+ 3833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.height/2.0+i*annotate_info->affine.sy*height- 3843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.rx*(metrics.width+metrics.bounds.x1)+ 3853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*(metrics.ascent+metrics.descent- 3863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_lines-1.0)*height)/2.0; 3873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case SouthWestGravity: 3903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+i* 3923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*height-annotate_info->affine.ry* 3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_lines-1.0)*height; 3943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ 3953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.height+i*annotate_info->affine.sy*height- 3963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent; 3973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case SouthGravity: 4003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? -1.0 : 1.0)*annotate_info->affine.tx+ 4023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.width/2.0+i*annotate_info->affine.ry*height- 4033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1)/2.0- 4043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*(number_lines-1.0)*height/2.0; 4053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ 4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.height+i*annotate_info->affine.sy*height- 4073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.rx*(metrics.width+metrics.bounds.x1)/2.0- 4083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent; 4093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case SouthEastGravity: 4123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=(geometry.width == 0 ? 1.0 : -1.0)*annotate_info->affine.tx+ 4143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.width+i*annotate_info->affine.ry*height- 4153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1)- 4163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ry*(number_lines-1.0)*height-1.0; 4173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=(geometry.height == 0 ? 1.0 : -1.0)*annotate_info->affine.ty+ 4183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry.height+i*annotate_info->affine.sy*height- 4193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.rx*(metrics.width+metrics.bounds.x1)- 4203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sy*(number_lines-1.0)*height+metrics.descent; 4213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (annotate->align) 4253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case LeftAlign: 4273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height; 4293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height; 4303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case CenterAlign: 4333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height- 4353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1)/2.0; 4363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height- 4373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.rx*(metrics.width+metrics.bounds.x1)/2.0; 4383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case RightAlign: 4413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=annotate_info->affine.tx+i*annotate_info->affine.ry*height- 4433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.sx*(metrics.width+metrics.bounds.x1); 4443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=annotate_info->affine.ty+i*annotate_info->affine.sy*height- 4453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.rx*(metrics.width+metrics.bounds.x1); 4463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 4493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4514c08aed51c5899665ade97263692328eea4af106cristy if (draw_info->undercolor.alpha != TransparentAlpha) 4523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo 4543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *undercolor_info; 4553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 4573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Text box. 4583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 4593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy undercolor_info=CloneDrawInfo((ImageInfo *) NULL,(DrawInfo *) NULL); 4603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy undercolor_info->fill=draw_info->undercolor; 4613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy undercolor_info->affine=draw_info->affine; 4623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy undercolor_info->affine.tx=offset.x-draw_info->affine.ry*metrics.ascent; 4633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy undercolor_info->affine.ty=offset.y-draw_info->affine.sy*metrics.ascent; 464b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(primitive,MaxTextExtent, 465a8549b176173db7680652304c372c64bb1a51737cristy "rectangle 0,0 %g,%.20g",metrics.origin.x,(double) height); 4663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&undercolor_info->primitive,primitive); 467018f07f7333b25743d0afff892450cebdb905c1acristy (void) DrawImage(image,undercolor_info,exception); 4683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) DestroyDrawInfo(undercolor_info); 4693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.tx=offset.x; 4713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ty=offset.y; 472b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(primitive,MaxTextExtent,"stroke-width %g " 473a8549b176173db7680652304c372c64bb1a51737cristy "line 0,0 %g,0",metrics.underline_thickness,metrics.width); 4743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate->decorate == OverlineDecoration) 4753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ty-=(draw_info->affine.sy*(metrics.ascent+ 4773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.descent-metrics.underline_position)); 4783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->primitive,primitive); 479018f07f7333b25743d0afff892450cebdb905c1acristy (void) DrawImage(image,annotate_info,exception); 4803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 4823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate->decorate == UnderlineDecoration) 4833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ty-=(draw_info->affine.sy* 4853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.underline_position); 4863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->primitive,primitive); 487018f07f7333b25743d0afff892450cebdb905c1acristy (void) DrawImage(image,annotate_info,exception); 4883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 4903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Annotate image with text. 4913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 4925cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy status=RenderType(image,annotate,&offset,&metrics,exception); 4933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == MagickFalse) 4943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate->decorate == LineThroughDecoration) 4963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ty-=(draw_info->affine.sy*(height+ 4983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics.underline_position+metrics.descent)/2.0); 4993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->primitive,primitive); 500018f07f7333b25743d0afff892450cebdb905c1acristy (void) DrawImage(image,annotate_info,exception); 5013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Relinquish resources. 5053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=DestroyDrawInfo(annotate_info); 5073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate=DestroyDrawInfo(annotate); 5083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; textlist[i] != (char *) NULL; i++) 5093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist[i]=DestroyString(textlist[i]); 5103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=(char **) RelinquishMagickMemory(textlist); 5113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status); 5123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 5133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 5153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 5173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 5183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 5193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% F o r m a t M a g i c k C a p t i o n % 5203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 5213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 5223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 5233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% FormatMagickCaption() formats a caption so that it fits within the image 5263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% width. It returns the number of lines in the formatted caption. 5273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the FormatMagickCaption method is: 5293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 530bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy% ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info, 5315cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% const MagickBooleanType split,TypeMetric *metrics,char **caption, 5325cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% ExceptionInfo *exception) 5333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows. 5353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: The image. 5373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 5393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5406b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy% o split: when no convenient line breaks-- insert newline. 5416b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy% 5423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o metrics: Return the font metrics in this structure. 5433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5446b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy% o caption: the caption. 5456b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy% 5465cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 5475cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 5483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 549bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristyMagickExport ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info, 5505cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const MagickBooleanType split,TypeMetric *metrics,char **caption, 5515cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ExceptionInfo *exception) 5523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 55374966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy char 55474966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy *text; 55574966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy 5563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 5573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 5583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 5603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p, 5613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q, 5623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *s; 5633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 564bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 5653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 5663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 567bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 5683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 5693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5706193b86c0b59030b647a10c75f37ec82d73e3695cristy ssize_t 5716193b86c0b59030b647a10c75f37ec82d73e3695cristy n; 5726193b86c0b59030b647a10c75f37ec82d73e3695cristy 57374966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy text=AcquireString(draw_info->text); 5743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=draw_info->text; 5753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy s=(char *) NULL; 5763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=(*caption); GetUTFCode(p) != 0; p+=GetUTFOctets(p)) 5773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsUTFSpace(GetUTFCode(p)) != MagickFalse) 5793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy s=p; 5802911f2d54257d36e1086061dbcc312fdad781070cristy if (GetUTFCode(p) == '\n') 581e2c81adf02cbe4bb92991389437a2a1daf8ed313cristy q=draw_info->text; 582bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) GetUTFOctets(p); i++) 5833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(*(p+i)); 5843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q='\0'; 5855cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy status=GetTypeMetrics(image,draw_info,metrics,exception); 5863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == MagickFalse) 5873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 5889e2b1e3c8f940957fe5c213f05c47462493baf86cristy width=(size_t) floor(metrics->width+metrics->max_advance/2.0+0.5); 58974966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy if ((width <= image->columns) || (strcmp(text,draw_info->text) == 0)) 5906193b86c0b59030b647a10c75f37ec82d73e3695cristy continue; 59174966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy (void) strcpy(text,draw_info->text); 5924aa314e7f9e09c30fcedcd112156b1dfb712b62dcristy if ((s != (char *) NULL) && (GetUTFOctets(s) == 1)) 5933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *s='\n'; 5953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=s; 5963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 5984aa314e7f9e09c30fcedcd112156b1dfb712b62dcristy if ((s != (char *) NULL) || (split != MagickFalse)) 5996b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy { 6006b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy char 6016b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy *target; 6023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6036b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy /* 6046b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy No convenient line breaks-- insert newline. 6056b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy */ 6066b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy target=AcquireString(*caption); 6076b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy n=p-(*caption); 6086b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy CopyMagickString(target,*caption,n+1); 6096b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy ConcatenateMagickString(target,"\n",strlen(*caption)+1); 6106b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy ConcatenateMagickString(target,p,strlen(*caption)+2); 6116b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy (void) DestroyString(*caption); 6126b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy *caption=target; 6136b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy p=(*caption)+n; 6146b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy } 6153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=draw_info->text; 6166193b86c0b59030b647a10c75f37ec82d73e3695cristy s=(char *) NULL; 6173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61874966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy text=DestroyString(text); 6196193b86c0b59030b647a10c75f37ec82d73e3695cristy n=0; 6203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=(*caption); GetUTFCode(p) != 0; p+=GetUTFOctets(p)) 6213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (GetUTFCode(p) == '\n') 6226193b86c0b59030b647a10c75f37ec82d73e3695cristy n++; 6236193b86c0b59030b647a10c75f37ec82d73e3695cristy return(n); 6243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 6253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 6273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 6293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 6303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 6313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% G e t M u l t i l i n e T y p e M e t r i c s % 6323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 6333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 6343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 6353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% GetMultilineTypeMetrics() returns the following information for the 6383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% specified font and text: 6393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% character width 6413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% character height 6423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% ascender 6433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% descender 6443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% text width 6453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% text height 6463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% maximum horizontal advance 6473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: x1 6483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: y1 6493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: x2 6503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: y2 6513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% origin: x 6523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% origin: y 6533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% underline position 6543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% underline thickness 6553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% This method is like GetTypeMetrics() but it returns the maximum text width 6573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% and height for multiple lines of text. 6583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the GetMultilineTypeMetrics method is: 6603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType GetMultilineTypeMetrics(Image *image, 6625cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% const DrawInfo *draw_info,TypeMetric *metrics,ExceptionInfo *exception) 6633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 6653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 6673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 6693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o metrics: Return the font metrics in this structure. 6713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6725cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 6735cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 6743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 6753ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport MagickBooleanType GetMultilineTypeMetrics(Image *image, 6765cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const DrawInfo *draw_info,TypeMetric *metrics,ExceptionInfo *exception) 6773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 6783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 6793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **textlist; 6803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo 6823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info; 6833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 6853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 6863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 687bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 6883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 6893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TypeMetric 6913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy extent; 6923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 6943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image->signature == MagickSignature); 6953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 6963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 6973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info != (DrawInfo *) NULL); 6983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info->text != (char *) NULL); 6993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info->signature == MagickSignature); 7003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*draw_info->text == '\0') 7013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 7023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); 7033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->text=DestroyString(annotate_info->text); 7043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 7053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert newlines to multiple lines of text. 7063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=StringToList(draw_info->text); 7083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (textlist == (char **) NULL) 7093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 7103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->render=MagickFalse; 711024843f38984cd26602f0b3b28a0768dfa056bb5cristy annotate_info->direction=UndefinedDirection; 7123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(metrics,0,sizeof(*metrics)); 7133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(&extent,0,sizeof(extent)); 7143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 7153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Find the widest of the text lines. 7163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->text=textlist[0]; 7185cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy status=GetTypeMetrics(image,annotate_info,&extent,exception); 7193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *metrics=extent; 7203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=1; textlist[i] != (char *) NULL; i++) 7213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->text=textlist[i]; 7235cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy status=GetTypeMetrics(image,annotate_info,&extent,exception); 7243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (extent.width > metrics->width) 7253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *metrics=extent; 7263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 727e2c81adf02cbe4bb92991389437a2a1daf8ed313cristy metrics->height=(double) (i*(size_t) (metrics->ascent-metrics->descent+0.5)+ 728e2c81adf02cbe4bb92991389437a2a1daf8ed313cristy (i-1)*draw_info->interline_spacing); 7293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 7303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Relinquish resources. 7313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->text=(char *) NULL; 7333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=DestroyDrawInfo(annotate_info); 7343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; textlist[i] != (char *) NULL; i++) 7353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist[i]=DestroyString(textlist[i]); 7363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=(char **) RelinquishMagickMemory(textlist); 7373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status); 7383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 7393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 7413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% G e t T y p e M e t r i c s % 7463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% GetTypeMetrics() returns the following information for the specified font 7523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% and text: 7533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% character width 7553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% character height 7563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% ascender 7573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% descender 7583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% text width 7593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% text height 7603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% maximum horizontal advance 7613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: x1 7623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: y1 7633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: x2 7643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounds: y2 7653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% origin: x 7663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% origin: y 7673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% underline position 7683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% underline thickness 7693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the GetTypeMetrics method is: 7713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType GetTypeMetrics(Image *image,const DrawInfo *draw_info, 7735cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% TypeMetric *metrics,ExceptionInfo *exception) 7743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 7763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 7783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 7803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o metrics: Return the font metrics in this structure. 7823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7835cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 7845cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 7853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 7863ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport MagickBooleanType GetTypeMetrics(Image *image, 7875cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const DrawInfo *draw_info,TypeMetric *metrics,ExceptionInfo *exception) 7883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 7893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo 7903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info; 7913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 7933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 7943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PointInfo 7963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset; 7973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 7993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image->signature == MagickSignature); 8003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 8013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 8023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info != (DrawInfo *) NULL); 8033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info->text != (char *) NULL); 8043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info->signature == MagickSignature); 8053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); 8063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->render=MagickFalse; 807024843f38984cd26602f0b3b28a0768dfa056bb5cristy annotate_info->direction=UndefinedDirection; 8083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(metrics,0,sizeof(*metrics)); 8093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.x=0.0; 8103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy offset.y=0.0; 8115cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy status=RenderType(image,annotate_info,&offset,metrics,exception); 8123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 8133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(AnnotateEvent,GetMagickModule(),"Metrics: text: %s; " 814e7f5109f30fc7242d04a26174a9138483dda5b6acristy "width: %g; height: %g; ascent: %g; descent: %g; max advance: %g; " 815a8549b176173db7680652304c372c64bb1a51737cristy "bounds: %g,%g %g,%g; origin: %g,%g; pixels per em: %g,%g; " 816e7f5109f30fc7242d04a26174a9138483dda5b6acristy "underline position: %g; underline thickness: %g",annotate_info->text, 8173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->width,metrics->height,metrics->ascent,metrics->descent, 8183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->max_advance,metrics->bounds.x1,metrics->bounds.y1, 8194c08aed51c5899665ade97263692328eea4af106cristy metrics->bounds.x2,metrics->bounds.y2,metrics->origin.x,metrics->origin.y, 8204c08aed51c5899665ade97263692328eea4af106cristy metrics->pixels_per_em.x,metrics->pixels_per_em.y, 8213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->underline_position,metrics->underline_thickness); 8223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=DestroyDrawInfo(annotate_info); 8233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status); 8243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 8253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 8273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ R e n d e r T y p e % 8323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% RenderType() renders text on the image. It also returns the bounding box of 8383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the text relative to the image. 8393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the RenderType method is: 8413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType RenderType(Image *image,DrawInfo *draw_info, 8435cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 8443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 8463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 8483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 8503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o offset: (x,y) location of text relative to image. 8523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o metrics: bounding box of text. 8543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8555cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 8565cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 8573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8583ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType RenderType(Image *image,const DrawInfo *draw_info, 8595cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 8603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 8613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const TypeInfo 8623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *type_info; 8633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo 8653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info; 8663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 8683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 8693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type_info=(const TypeInfo *) NULL; 8713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->font != (char *) NULL) 8723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*draw_info->font == '@') 8743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=RenderFreetype(image,draw_info,draw_info->encoding,offset, 8765cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy metrics,exception); 8773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status); 8783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*draw_info->font == '-') 8805cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy return(RenderX11(image,draw_info,offset,metrics,exception)); 8813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsPathAccessible(draw_info->font) != MagickFalse) 8823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=RenderFreetype(image,draw_info,draw_info->encoding,offset, 8845cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy metrics,exception); 8853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status); 8863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8875cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy type_info=GetTypeInfo(draw_info->font,exception); 8883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type_info == (const TypeInfo *) NULL) 8895cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) ThrowMagickException(exception,GetMagickModule(),TypeWarning, 890efe601ce9ea5ad34ad0e8ad6e61d9be9b148b2a3cristy "UnableToReadFont","`%s'",draw_info->font); 8913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((type_info == (const TypeInfo *) NULL) && 8933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (draw_info->family != (const char *) NULL)) 8943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type_info=GetTypeInfoByFamily(draw_info->family,draw_info->style, 8965cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy draw_info->stretch,draw_info->weight,exception); 8973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type_info == (const TypeInfo *) NULL) 8985cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) ThrowMagickException(exception,GetMagickModule(),TypeWarning, 899efe601ce9ea5ad34ad0e8ad6e61d9be9b148b2a3cristy "UnableToReadFont","`%s'",draw_info->family); 9003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type_info == (const TypeInfo *) NULL) 902d984f27fbbb96073787c88f4c9409d7f836cedc5cristy type_info=GetTypeInfoByFamily("Arial",draw_info->style, 9035cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy draw_info->stretch,draw_info->weight,exception); 904d984f27fbbb96073787c88f4c9409d7f836cedc5cristy if (type_info == (const TypeInfo *) NULL) 905cbb34a4def108d6db032ca9631a433afd3ea5a5dcristy type_info=GetTypeInfoByFamily("Helvetica",draw_info->style, 9065cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy draw_info->stretch,draw_info->weight,exception); 9073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type_info == (const TypeInfo *) NULL) 908704acaaebbfeec018847456e79de0ce301db126ecristy type_info=GetTypeInfoByFamily("Century Schoolbook",draw_info->style, 9095cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy draw_info->stretch,draw_info->weight,exception); 910704acaaebbfeec018847456e79de0ce301db126ecristy if (type_info == (const TypeInfo *) NULL) 9116193b86c0b59030b647a10c75f37ec82d73e3695cristy type_info=GetTypeInfoByFamily("Sans",draw_info->style, 9125cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy draw_info->stretch,draw_info->weight,exception); 9136193b86c0b59030b647a10c75f37ec82d73e3695cristy if (type_info == (const TypeInfo *) NULL) 9143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type_info=GetTypeInfoByFamily((const char *) NULL,draw_info->style, 9155cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy draw_info->stretch,draw_info->weight,exception); 9163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type_info == (const TypeInfo *) NULL) 9175cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy type_info=GetTypeInfo("*",exception); 918704acaaebbfeec018847456e79de0ce301db126ecristy if (type_info == (const TypeInfo *) NULL) 9193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9205cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy status=RenderFreetype(image,draw_info,draw_info->encoding,offset,metrics, 9215cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy exception); 9223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status); 9233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); 9253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->face=type_info->face; 9263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type_info->metrics != (char *) NULL) 9273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->metrics,type_info->metrics); 9283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type_info->glyphs != (char *) NULL) 9293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->font,type_info->glyphs); 9305cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy status=RenderFreetype(image,annotate_info,type_info->encoding,offset,metrics, 9315cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy exception); 9323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=DestroyDrawInfo(annotate_info); 9333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status); 9343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 9353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 9373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ R e n d e r F r e e t y p e % 9423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% RenderFreetype() renders text on the image with a Truetype font. It also 9483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returns the bounding box of the text relative to the image. 9493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the RenderFreetype method is: 9513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType RenderFreetype(Image *image,DrawInfo *draw_info, 9535cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% const char *encoding,const PointInfo *offset,TypeMetric *metrics, 9545cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% ExceptionInfo *exception) 9553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 9573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 9593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 9613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o encoding: the font encoding. 9633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o offset: (x,y) location of text relative to image. 9653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o metrics: bounding box of text. 9673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9685cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 9695cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 9703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_FREETYPE_DELEGATE) 9732857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy 9743ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int TraceCubicBezier(FT_Vector *p,FT_Vector *q,FT_Vector *to, 9753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo *draw_info) 9763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 9773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AffineMatrix 9783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine; 9793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 9813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy path[MaxTextExtent]; 9823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine=draw_info->affine; 984b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(path,MaxTextExtent, 985a8549b176173db7680652304c372c64bb1a51737cristy "C%g,%g %g,%g %g,%g",affine.tx+p->x/64.0,affine.ty- 9868cd5b3193212b4aebce08c4e7afbb66b09778029cristy p->y/64.0,affine.tx+q->x/64.0,affine.ty-q->y/64.0,affine.tx+to->x/64.0, 9878cd5b3193212b4aebce08c4e7afbb66b09778029cristy affine.ty-to->y/64.0); 9883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateString(&draw_info->primitive,path); 9893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 9903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 9913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9923ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int TraceLineTo(FT_Vector *to,DrawInfo *draw_info) 9933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 9943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AffineMatrix 9953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine; 9963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 9983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy path[MaxTextExtent]; 9993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine=draw_info->affine; 1001b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(path,MaxTextExtent,"L%g,%g",affine.tx+ 10028cd5b3193212b4aebce08c4e7afbb66b09778029cristy to->x/64.0,affine.ty-to->y/64.0); 10033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateString(&draw_info->primitive,path); 10043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 10053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 10063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10073ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int TraceMoveTo(FT_Vector *to,DrawInfo *draw_info) 10083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 10093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AffineMatrix 10103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine; 10113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 10133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy path[MaxTextExtent]; 10143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine=draw_info->affine; 1016b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(path,MaxTextExtent,"M%g,%g",affine.tx+ 10178cd5b3193212b4aebce08c4e7afbb66b09778029cristy to->x/64.0,affine.ty-to->y/64.0); 10183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateString(&draw_info->primitive,path); 10193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 10203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 10213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10223ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int TraceQuadraticBezier(FT_Vector *control,FT_Vector *to, 10233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo *draw_info) 10243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 10253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AffineMatrix 10263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine; 10273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 10293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy path[MaxTextExtent]; 10303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine=draw_info->affine; 1032b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(path,MaxTextExtent,"Q%g,%g %g,%g", 10333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.tx+control->x/64.0,affine.ty-control->y/64.0,affine.tx+to->x/64.0, 10343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.ty-to->y/64.0); 10353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateString(&draw_info->primitive,path); 10363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 10373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 10383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10393ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, 10405cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const char *encoding,const PointInfo *offset,TypeMetric *metrics, 10415cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ExceptionInfo *exception) 10423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 10433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined(FT_OPEN_PATHNAME) 10443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define FT_OPEN_PATHNAME ft_open_pathname 10453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 10463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct _GlyphInfo 10483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_UInt 10503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id; 10513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Vector 10533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy origin; 10543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Glyph 10563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image; 10573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } GlyphInfo; 10583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char 10603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *value; 10613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1062c9b129570a277337cf0e887229741497e2ead5cfcristy double 1063c9b129570a277337cf0e887229741497e2ead5cfcristy direction; 1064c9b129570a277337cf0e887229741497e2ead5cfcristy 10653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DrawInfo 10663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info; 10673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_BBox 10693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bounds; 10703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_BitmapGlyph 10723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bitmap; 10733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Encoding 10753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type; 10763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Error 10783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 10793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Face 10813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy face; 10823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Int32 10843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags; 10853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Library 10873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy library; 10883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Matrix 10903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine; 10913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Open_Args 10933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy args; 10943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Vector 10963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy origin; 10973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GlyphInfo 10993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy glyph, 11003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy last_glyph; 11013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PointInfo 11033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy point, 11043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution; 11053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 11073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 11083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11099d314ff2c17a77996c05413c2013880387e50f0ecristy ssize_t 11109d314ff2c17a77996c05413c2013880387e50f0ecristy code, 11119d314ff2c17a77996c05413c2013880387e50f0ecristy y; 11129d314ff2c17a77996c05413c2013880387e50f0ecristy 11133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static FT_Outline_Funcs 11143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy OutlineMethods = 11153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (FT_Outline_MoveTo_Func) TraceMoveTo, 11173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (FT_Outline_LineTo_Func) TraceLineTo, 11183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (FT_Outline_ConicTo_Func) TraceQuadraticBezier, 11193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (FT_Outline_CubicTo_Func) TraceCubicBezier, 11203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0, 0 11213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 11223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11232857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy unsigned char 11242857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy *utf8; 11252857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy 11263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 11273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize Truetype library. 11283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 11293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Init_FreeType(&library); 11303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != 0) 11313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowBinaryException(TypeError,"UnableToInitializeFreetypeLibrary", 11323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 11333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy args.flags=FT_OPEN_PATHNAME; 11343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->font == (char *) NULL) 11353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy args.pathname=ConstantString("helvetica"); 11363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 11373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*draw_info->font != '@') 11383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy args.pathname=ConstantString(draw_info->font); 11393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 11403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy args.pathname=ConstantString(draw_info->font+1); 11413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy face=(FT_Face) NULL; 1142eaedf06777741da32408da72c1e512975c600c48cristy status=FT_Open_Face(library,&args,(long) draw_info->face,&face); 11433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy args.pathname=DestroyString(args.pathname); 11443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != 0) 11453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FT_Done_FreeType(library); 11475cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) ThrowMagickException(exception,GetMagickModule(),TypeError, 1148efe601ce9ea5ad34ad0e8ad6e61d9be9b148b2a3cristy "UnableToReadFont","`%s'",draw_info->font); 11495cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy return(RenderPostscript(image,draw_info,offset,metrics,exception)); 11503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((draw_info->metrics != (char *) NULL) && 11523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (IsPathAccessible(draw_info->metrics) != MagickFalse)) 11533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FT_Attach_File(face,draw_info->metrics); 11543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_unicode; 11553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Select_Charmap(face,encoding_type); 11563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status != 0) && (face->num_charmaps != 0)) 11573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Set_Charmap(face,face->charmaps[0]); 11583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (encoding != (const char *) NULL) 11593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"AdobeCustom") == 0) 11613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_adobe_custom; 11623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"AdobeExpert") == 0) 11633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_adobe_expert; 11643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"AdobeStandard") == 0) 11653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_adobe_standard; 11663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"AppleRoman") == 0) 11673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_apple_roman; 11683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"BIG5") == 0) 11693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_big5; 11703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"GB2312") == 0) 11713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_gb2312; 11723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"Johab") == 0) 11733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_johab; 11743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(ft_encoding_latin_1) 11753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"Latin-1") == 0) 11763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_latin_1; 11773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 11783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"Latin-2") == 0) 11793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_latin_2; 11803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"None") == 0) 11813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_none; 11823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"SJIScode") == 0) 11833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_sjis; 11843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"Symbol") == 0) 11853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_symbol; 11863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"Unicode") == 0) 11873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_unicode; 11883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(encoding,"Wansung") == 0) 11893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding_type=ft_encoding_wansung; 11903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Select_Charmap(face,encoding_type); 11913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != 0) 11923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowBinaryException(TypeError,"UnrecognizedFontEncoding",encoding); 11933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 11953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set text size. 11963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 11973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.x=DefaultResolution; 11983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.y=DefaultResolution; 11993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->density != (char *) NULL) 12003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GeometryInfo 12023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry_info; 12033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickStatusType 12053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags; 12063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=ParseGeometry(draw_info->density,&geometry_info); 12083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.x=geometry_info.rho; 12093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.y=geometry_info.sigma; 12103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & SigmaValue) == 0) 12113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.y=resolution.x; 12123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Set_Char_Size(face,(FT_F26Dot6) (64.0*draw_info->pointsize), 12143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (FT_F26Dot6) (64.0*draw_info->pointsize),(FT_UInt) resolution.x, 12153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (FT_UInt) resolution.y); 12163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->pixels_per_em.x=face->size->metrics.x_ppem; 12173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->pixels_per_em.y=face->size->metrics.y_ppem; 12183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->ascent=(double) face->size->metrics.ascender/64.0; 12193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->descent=(double) face->size->metrics.descender/64.0; 12203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->width=0; 12213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->origin.x=0; 12223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->origin.y=0; 12233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->height=(double) face->size->metrics.height/64.0; 12243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->max_advance=0.0; 12253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (face->size->metrics.max_advance > MagickEpsilon) 12263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->max_advance=(double) face->size->metrics.max_advance/64.0; 12273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x1=0.0; 12283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y1=metrics->descent; 12293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x2=metrics->ascent+metrics->descent; 12303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y2=metrics->ascent+metrics->descent; 12313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->underline_position=face->underline_position/64.0; 12323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->underline_thickness=face->underline_thickness/64.0; 123371709bfb884744dbf7c9030810cc8599600ab7d3cristy if ((draw_info->text == (char *) NULL) || (*draw_info->text == '\0')) 12343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FT_Done_Face(face); 12363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FT_Done_FreeType(library); 12373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 12383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 12403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Compute bounding box. 12413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 12423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 12433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(AnnotateEvent,GetMagickModule(),"Font %s; " 1244e7f5109f30fc7242d04a26174a9138483dda5b6acristy "font-encoding %s; text-encoding %s; pointsize %g", 12453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->font != (char *) NULL ? draw_info->font : "none", 12463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy encoding != (char *) NULL ? encoding : "none", 12473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->encoding != (char *) NULL ? draw_info->encoding : "none", 12483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->pointsize); 12493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=FT_LOAD_NO_BITMAP; 125055a804e2631f770f45d3a671076b0dfe29fdf188cristy if (draw_info->text_antialias == MagickFalse) 12514f9709e37140157c7845a03f3612534081a5b540cristy flags|=FT_LOAD_TARGET_MONO; 125255a804e2631f770f45d3a671076b0dfe29fdf188cristy else 125355a804e2631f770f45d3a671076b0dfe29fdf188cristy { 1254a89189d6e227db53ecff8624fb6b4388560d9b4acristy#if defined(FT_LOAD_TARGET_LIGHT) 125555a804e2631f770f45d3a671076b0dfe29fdf188cristy flags|=FT_LOAD_TARGET_LIGHT; 1256a89189d6e227db53ecff8624fb6b4388560d9b4acristy#elif defined(FT_LOAD_TARGET_LCD) 1257a89189d6e227db53ecff8624fb6b4388560d9b4acristy flags|=FT_LOAD_TARGET_LCD; 125855a804e2631f770f45d3a671076b0dfe29fdf188cristy#endif 125955a804e2631f770f45d3a671076b0dfe29fdf188cristy } 1260d15e65928aec551b7388c2863de3e3e628e2e0ddcristy value=GetImageProperty(image,"type:hinting",exception); 126133204240c3ef57786ee59c2692ffe8ffdce97bf9cristy if ((value != (const char *) NULL) && (LocaleCompare(value,"off") == 0)) 12623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags|=FT_LOAD_NO_HINTING; 12633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy glyph.id=0; 12643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy glyph.image=NULL; 12653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy last_glyph.id=0; 12663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy last_glyph.image=NULL; 12673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy origin.x=0; 12683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy origin.y=0; 12693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.xx=65536L; 12703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.yx=0L; 12713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.xy=0L; 12723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.yy=65536L; 12733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->render != MagickFalse) 12743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.xx=(FT_Fixed) (65536L*draw_info->affine.sx+0.5); 12763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.yx=(FT_Fixed) (-65536L*draw_info->affine.rx+0.5); 12773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.xy=(FT_Fixed) (-65536L*draw_info->affine.ry+0.5); 12783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affine.yy=(FT_Fixed) (65536L*draw_info->affine.sy+0.5); 12793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info); 12813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->primitive,"path '"); 12823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->render != MagickFalse) 12833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->storage_class != DirectClass) 12855cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) SetImageStorageClass(image,DirectClass,exception); 12868a46d827a124555f0c48fb2368ec1bba8e079ab6cristy if (image->alpha_trait != BlendPixelTrait) 12875cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); 12883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1289c9b129570a277337cf0e887229741497e2ead5cfcristy direction=1.0; 1290cf5467b5dddb5084ec79a5921b48ce9bb2a897cecristy if (draw_info->direction == RightToLeftDirection) 1291c9b129570a277337cf0e887229741497e2ead5cfcristy direction=(-1.0); 12923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy point.x=0.0; 12933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy point.y=0.0; 12943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=draw_info->text; GetUTFCode(p) != 0; p+=GetUTFOctets(p)) 1295bd51246ae63047fa139606f6c6862ff989ab1fbdcristy if (GetUTFCode(p) < 0) 1296bd51246ae63047fa139606f6c6862ff989ab1fbdcristy break; 12972857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy utf8=(unsigned char *) NULL; 1298d913ea1f524066a6a8bf3d046755a5c0f7eb471fcristy if (GetUTFCode(p) == 0) 12992857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy p=draw_info->text; 13002857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy else 1301bd51246ae63047fa139606f6c6862ff989ab1fbdcristy { 13022857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy utf8=ConvertLatin1ToUTF8((unsigned char *) draw_info->text); 13032857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (utf8 != (unsigned char *) NULL) 1304c9b129570a277337cf0e887229741497e2ead5cfcristy p=(char *) utf8; 13052857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 13062857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy for (code=0; GetUTFCode(p) != 0; p+=GetUTFOctets(p)) 13072857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 13082857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy /* 13092857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy Render UTF-8 sequence. 13102857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy */ 13112857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy glyph.id=FT_Get_Char_Index(face,GetUTFCode(p)); 13122857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (glyph.id == 0) 13132857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy glyph.id=FT_Get_Char_Index(face,'?'); 13142857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if ((glyph.id != 0) && (last_glyph.id != 0)) 13152857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 1316aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy if (fabs(draw_info->kerning) >= MagickEpsilon) 131794b11835effe9f2ded8638e50db5fb7acd92ea0bcristy origin.x+=(FT_Pos) (64.0*direction*draw_info->kerning); 13182857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy else 13192857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (FT_HAS_KERNING(face)) 13202857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 13212857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy FT_Vector 13222857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy kerning; 13233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13242857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=FT_Get_Kerning(face,last_glyph.id,glyph.id, 13252857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy ft_kerning_default,&kerning); 13262857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (status == 0) 132794b11835effe9f2ded8638e50db5fb7acd92ea0bcristy origin.x+=(FT_Pos) (direction*kerning.x); 13282857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 13292857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 13302857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy glyph.origin=origin; 13312857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=FT_Load_Glyph(face,glyph.id,flags); 13322857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (status != 0) 13332857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 13342857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=FT_Get_Glyph(face->glyph,&glyph.image); 13352857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (status != 0) 13362857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 13372857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline, 13382857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy &bounds); 13392857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (status != 0) 13402857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 13412857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1)) 1342aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy metrics->bounds.x1=(double) bounds.xMin; 13432857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1)) 1344aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy metrics->bounds.y1=(double) bounds.yMin; 13452857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2)) 1346aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy metrics->bounds.x2=(double) bounds.xMax; 13472857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2)) 1348aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy metrics->bounds.y2=(double) bounds.yMax; 13492857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (draw_info->render != MagickFalse) 13504c08aed51c5899665ade97263692328eea4af106cristy if ((draw_info->stroke.alpha != TransparentAlpha) || 13512857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy (draw_info->stroke_pattern != (Image *) NULL)) 13523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1353bd51246ae63047fa139606f6c6862ff989ab1fbdcristy /* 13542857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy Trace the glyph. 1355bd51246ae63047fa139606f6c6862ff989ab1fbdcristy */ 13562857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy annotate_info->affine.tx=glyph.origin.x/64.0; 13572857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy annotate_info->affine.ty=glyph.origin.y/64.0; 13582857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy (void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)-> 13592857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy outline,&OutlineMethods,annotate_info); 1360bd51246ae63047fa139606f6c6862ff989ab1fbdcristy } 13612857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy FT_Vector_Transform(&glyph.origin,&affine); 13622857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy (void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin); 13632857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal, 13642857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy (FT_Vector *) NULL,MagickTrue); 13652857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (status != 0) 13662857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 13672857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy bitmap=(FT_BitmapGlyph) glyph.image; 13682857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy point.x=offset->x+bitmap->left; 13692f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy if (bitmap->bitmap.pixel_mode == ft_pixel_mode_mono) 13702f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy point.x=offset->x+(origin.x >> 6); 13712857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy point.y=offset->y-bitmap->top; 13722857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (draw_info->render != MagickFalse) 13732857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 13742857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy CacheView 13752857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy *image_view; 1376bd51246ae63047fa139606f6c6862ff989ab1fbdcristy 13772857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy MagickBooleanType 13782857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status; 1379bd51246ae63047fa139606f6c6862ff989ab1fbdcristy 13802f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy register unsigned char 13812f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy *p; 13822f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy 13832857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy /* 13842857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy Rasterize the glyph. 13852857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy */ 13862857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=MagickTrue; 138746ff2676b1044ea4101ac7a59b83289cd8f6cfdacristy image_view=AcquireAuthenticCacheView(image,exception); 13882f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy p=bitmap->bitmap.buffer; 1389bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (y=0; y < (ssize_t) bitmap->bitmap.rows; y++) 13902857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 1391bd51246ae63047fa139606f6c6862ff989ab1fbdcristy MagickBooleanType 13922857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy active, 13932857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy sync; 1394bd51246ae63047fa139606f6c6862ff989ab1fbdcristy 1395a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy double 13962857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy fill_opacity; 13972857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy 1398101ab708b0574518ac5715da4d3915400e9df79acristy PixelInfo 13992857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy fill_color; 14002857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy 14014c08aed51c5899665ade97263692328eea4af106cristy register Quantum 14022857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy *restrict q; 14032857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy 14048815806717c3b3e2b4f8700b4cc18b751bd3c23fcristy register ssize_t 14058815806717c3b3e2b4f8700b4cc18b751bd3c23fcristy x; 14068815806717c3b3e2b4f8700b4cc18b751bd3c23fcristy 140773ce31bc9ca5fc03ff0cef499e58ab2973add52ccristy ssize_t 14082f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy n, 140973ce31bc9ca5fc03ff0cef499e58ab2973add52ccristy x_offset, 141073ce31bc9ca5fc03ff0cef499e58ab2973add52ccristy y_offset; 141173ce31bc9ca5fc03ff0cef499e58ab2973add52ccristy 14122857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (status == MagickFalse) 14132857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 1414bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy x_offset=(ssize_t) ceil(point.x-0.5); 1415bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy y_offset=(ssize_t) ceil(point.y+y-0.5); 1416bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows)) 14172857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 14184c08aed51c5899665ade97263692328eea4af106cristy q=(Quantum *) NULL; 1419bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns)) 14202857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy active=MagickFalse; 14212857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy else 14222857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 14232857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset, 14242857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy bitmap->bitmap.width,1,exception); 14254c08aed51c5899665ade97263692328eea4af106cristy active=q != (Quantum *) NULL ? MagickTrue : MagickFalse; 14262857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 1427854209afe797f1a6ecec8679889302af4d4b0faccristy n=y*bitmap->bitmap.pitch-1; 1428854209afe797f1a6ecec8679889302af4d4b0faccristy for (x=0; x < (ssize_t) bitmap->bitmap.width; x++) 1429bd51246ae63047fa139606f6c6862ff989ab1fbdcristy { 1430854209afe797f1a6ecec8679889302af4d4b0faccristy n++; 14312857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy x_offset++; 14322f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns)) 14333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1434ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 14352857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 14363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14372f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy if (bitmap->bitmap.pixel_mode != ft_pixel_mode_mono) 1438a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy fill_opacity=(double) (p[n])/(bitmap->bitmap.num_grays-1); 14392f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy else 14402f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy fill_opacity=((p[(x >> 3)+y*bitmap->bitmap.pitch] & 14412f5b5c7c0813cc6f696a4dfc00aaf62e2dfb2a23cristy (1 << (~x & 0x07)))) == 0 ? 0.0 : 1.0; 14422857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (draw_info->text_antialias == MagickFalse) 14432857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0; 14442857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (active == MagickFalse) 14452857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1, 14462857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy exception); 14476193b86c0b59030b647a10c75f37ec82d73e3695cristy if (q == (Quantum *) NULL) 14482857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 1449ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 14502857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy continue; 14512857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 1452ec061ec752ff58a96a5de680b18e43fb8beea7c0cristy GetPixelInfo(image,&fill_color); 14532ed42f6d7c2245432767ea446742977ee87e963ccristy (void) GetFillColor(draw_info,x_offset,y_offset,&fill_color, 14542ed42f6d7c2245432767ea446742977ee87e963ccristy exception); 14554c08aed51c5899665ade97263692328eea4af106cristy fill_opacity=fill_opacity*fill_color.alpha; 14564c08aed51c5899665ade97263692328eea4af106cristy CompositePixelOver(image,&fill_color,fill_opacity,q, 14574c08aed51c5899665ade97263692328eea4af106cristy GetPixelAlpha(image,q),q); 14582857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (active == MagickFalse) 14592857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy { 14602857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy sync=SyncCacheViewAuthenticPixels(image_view,exception); 14612857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (sync == MagickFalse) 14622857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=MagickFalse; 14632857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 1464ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 14653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14662857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy sync=SyncCacheViewAuthenticPixels(image_view,exception); 14672857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (sync == MagickFalse) 14682857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy status=MagickFalse; 14693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14702857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy image_view=DestroyCacheView(image_view); 14712857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 14722857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if ((bitmap->left+bitmap->bitmap.width) > metrics->width) 14732857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy metrics->width=bitmap->left+bitmap->bitmap.width; 1474aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy if ((fabs(draw_info->interword_spacing) >= MagickEpsilon) && 14752857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy (IsUTFSpace(GetUTFCode(p)) != MagickFalse) && 14762857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy (IsUTFSpace(code) == MagickFalse)) 147794b11835effe9f2ded8638e50db5fb7acd92ea0bcristy origin.x+=(FT_Pos) (64.0*direction*draw_info->interword_spacing); 14782857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy else 147994b11835effe9f2ded8638e50db5fb7acd92ea0bcristy origin.x+=(FT_Pos) (direction*face->glyph->advance.x); 1480aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy metrics->origin.x=(double) origin.x; 1481aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy metrics->origin.y=(double) origin.y; 1482bd5a96cd2b69f218f85a7adc306296a736f91a56cristy if (last_glyph.id != 0) 1483bd5a96cd2b69f218f85a7adc306296a736f91a56cristy FT_Done_Glyph(last_glyph.image); 14842857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy last_glyph=glyph; 14852857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy code=GetUTFCode(p); 14862857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy } 14872857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (utf8 != (unsigned char *) NULL) 14882857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy utf8=(unsigned char *) RelinquishMagickMemory(utf8); 1489bd5a96cd2b69f218f85a7adc306296a736f91a56cristy if (last_glyph.id != 0) 1490bd5a96cd2b69f218f85a7adc306296a736f91a56cristy FT_Done_Glyph(last_glyph.image); 14914c08aed51c5899665ade97263692328eea4af106cristy if ((draw_info->stroke.alpha != TransparentAlpha) || 14923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (draw_info->stroke_pattern != (Image *) NULL)) 14933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->render != MagickFalse) 14953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 14973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Draw text stroke. 14983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->linejoin=RoundJoin; 15003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.tx=offset->x; 15013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->affine.ty=offset->y; 15023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateString(&annotate_info->primitive,"'"); 1503018f07f7333b25743d0afff892450cebdb905c1acristy (void) DrawImage(image,annotate_info,exception); 15043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 15053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 15063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 15073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine font metrics. 15083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 15093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy glyph.id=FT_Get_Char_Index(face,'_'); 15103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy glyph.origin=origin; 15113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Load_Glyph(face,glyph.id,flags); 15123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == 0) 15133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 15143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Get_Glyph(face->glyph,&glyph.image); 15153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == 0) 15163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1517a367d94b831afbcdfe12449f1da943beb008e080cristy status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline, 1518a367d94b831afbcdfe12449f1da943beb008e080cristy &bounds); 15193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == 0) 15203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 15213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FT_Vector_Transform(&glyph.origin,&affine); 15223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin); 15233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal, 15243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (FT_Vector *) NULL,MagickTrue); 15253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bitmap=(FT_BitmapGlyph) glyph.image; 15263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bitmap->left > metrics->width) 15273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->width=bitmap->left; 15283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 15293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1530e2c81adf02cbe4bb92991389437a2a1daf8ed313cristy FT_Done_Glyph(glyph.image); 15313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 15323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->width-=metrics->bounds.x1/64.0; 153355cb9f15b804f98ac7d37615b8f5f8888fc792f4cristy metrics->width+=annotate_info->stroke_width; 15343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x1/=64.0; 15353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y1/=64.0; 15363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x2/=64.0; 15373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y2/=64.0; 15383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->origin.x/=64.0; 15393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->origin.y/=64.0; 15403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 15413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Relinquish resources. 15423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 15433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=DestroyDrawInfo(annotate_info); 15443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FT_Done_Face(face); 15453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FT_Done_FreeType(library); 15463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 15473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 15483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 15493ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, 15503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *magick_unused(encoding),const PointInfo *offset, 15515cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy TypeMetric *metrics,ExceptionInfo *exception) 15523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 15535cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) ThrowMagickException(exception,GetMagickModule(), 1554e5b39652d8d21bc3940d83b8d6088d4070a8a34aanthony MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","'%s' (Freetype)", 1555ee08182aae410ed78e712a845bee7e51eedf73f3cristy draw_info->font != (char *) NULL ? draw_info->font : "none"); 1556e3b062a2f84bdc16645c3ef9de153b2c6f44d04ccristy return(RenderPostscript(image,draw_info,offset,metrics,exception)); 15573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 15583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 15593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 15613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ R e n d e r P o s t s c r i p t % 15663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% RenderPostscript() renders text on the image with a Postscript font. It 15723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% also returns the bounding box of the text relative to the image. 15733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the RenderPostscript method is: 15753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType RenderPostscript(Image *image,DrawInfo *draw_info, 15775cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 15783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 15803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 15823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 15843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o offset: (x,y) location of text relative to image. 15863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o metrics: bounding box of text. 15883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15895cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 15905cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 15913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 15923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15933ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic inline size_t MagickMin(const size_t x,const size_t y) 15943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 15953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < y) 15963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(x); 15973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(y); 15983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 15993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16003ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic char *EscapeParenthesis(const char *text) 16013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 16023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 16033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *buffer; 16043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 16063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 16073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1608bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 16093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 16103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t 16123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy escapes; 16133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy escapes=0; 16153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy buffer=AcquireString(text); 16163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=buffer; 1617bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) MagickMin(strlen(text),MaxTextExtent-escapes-1); i++) 16183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 16193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((text[i] == '(') || (text[i] == ')')) 16203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 16213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++='\\'; 16223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy escapes++; 16233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 16243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=text[i]; 16253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 16263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p='\0'; 16273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(buffer); 16283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 16293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16303ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType RenderPostscript(Image *image, 16315cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const DrawInfo *draw_info,const PointInfo *offset,TypeMetric *metrics, 16325cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ExceptionInfo *exception) 16333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 16343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 16353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename[MaxTextExtent], 16363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry[MaxTextExtent], 16373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *text; 16383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FILE 16403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *file; 16413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 16433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_image; 16443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 16463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info; 16473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 16493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unique_file; 16503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 16523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy identity; 16533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PointInfo 16553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy extent, 16563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy point, 16573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution; 16583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1659bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 16603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 16613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 166214d712974a2c2cd2aebf8db11c7ca686bb67596fcristy size_t 166314d712974a2c2cd2aebf8db11c7ca686bb67596fcristy length; 166414d712974a2c2cd2aebf8db11c7ca686bb67596fcristy 16659d314ff2c17a77996c05413c2013880387e50f0ecristy ssize_t 16669d314ff2c17a77996c05413c2013880387e50f0ecristy y; 16679d314ff2c17a77996c05413c2013880387e50f0ecristy 16683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 16693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Render label with a Postscript font. 16703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 16713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 16723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(AnnotateEvent,GetMagickModule(), 1673e7f5109f30fc7242d04a26174a9138483dda5b6acristy "Font %s; pointsize %g",draw_info->font != (char *) NULL ? 16743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->font : "none",draw_info->pointsize); 16753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy file=(FILE *) NULL; 16763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unique_file=AcquireUniqueFileResource(filename); 16773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (unique_file != -1) 16783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy file=fdopen(unique_file,"wb"); 16793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((unique_file == -1) || (file == (FILE *) NULL)) 16803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 16815cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ThrowFileException(exception,FileOpenError,"UnableToOpenFile",filename); 16823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 16833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1684b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"%%!PS-Adobe-3.0\n"); 1685b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"/ReencodeType\n"); 1686b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"{\n"); 1687b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," findfont dup length\n"); 1688b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file, 16893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " dict begin { 1 index /FID ne {def} {pop pop} ifelse } forall\n"); 1690b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file, 16913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " /Encoding ISOLatin1Encoding def currentdict end definefont pop\n"); 1692b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"} bind def\n"); 16933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 16943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Sample to compute bounding box. 16953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 1696aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy identity=(fabs(draw_info->affine.sx-draw_info->affine.sy) < MagickEpsilon) && 1697aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy (fabs(draw_info->affine.rx) < MagickEpsilon) && 1698aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy (fabs(draw_info->affine.ry) < MagickEpsilon) ? MagickTrue : MagickFalse; 16993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy extent.x=0.0; 17003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy extent.y=0.0; 170114d712974a2c2cd2aebf8db11c7ca686bb67596fcristy length=strlen(draw_info->text); 170214d712974a2c2cd2aebf8db11c7ca686bb67596fcristy for (i=0; i <= (ssize_t) (length+2); i++) 17033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 17043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy point.x=fabs(draw_info->affine.sx*i*draw_info->pointsize+ 17053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->affine.ry*2.0*draw_info->pointsize); 17063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy point.y=fabs(draw_info->affine.rx*i*draw_info->pointsize+ 17073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->affine.sy*2.0*draw_info->pointsize); 17083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (point.x > extent.x) 17093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy extent.x=point.x; 17103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (point.y > extent.y) 17113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy extent.y=point.y; 17123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1713b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"%g %g moveto\n",identity != MagickFalse ? 0.0 : 17143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy extent.x/2.0,extent.y/2.0); 1715b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"%g %g scale\n",draw_info->pointsize, 17163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->pointsize); 17173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((draw_info->font == (char *) NULL) || (*draw_info->font == '\0') || 17183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (strchr(draw_info->font,'/') != (char *) NULL)) 1719b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file, 17203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "/Times-Roman-ISO dup /Times-Roman ReencodeType findfont setfont\n"); 17213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 17221e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file, 17231e604812fad85bb96f757a2393015ae3d061c39acristy "/%s-ISO dup /%s ReencodeType findfont setfont\n",draw_info->font, 17241e604812fad85bb96f757a2393015ae3d061c39acristy draw_info->font); 1725b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"[%g %g %g %g 0 0] concat\n", 17268cd5b3193212b4aebce08c4e7afbb66b09778029cristy draw_info->affine.sx,-draw_info->affine.rx,-draw_info->affine.ry, 17278cd5b3193212b4aebce08c4e7afbb66b09778029cristy draw_info->affine.sy); 17283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy text=EscapeParenthesis(draw_info->text); 17293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (identity == MagickFalse) 17301e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file,"(%s) stringwidth pop -0.5 mul -0.5 rmoveto\n", 17311e604812fad85bb96f757a2393015ae3d061c39acristy text); 1732b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"(%s) show\n",text); 17333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy text=DestroyString(text); 1734b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"showpage\n"); 17353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) fclose(file); 1736b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g+0+0!", 1737e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy floor(extent.x+0.5),floor(extent.y+0.5)); 17383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=AcquireImageInfo(); 1739b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(annotate_info->filename,MaxTextExtent,"ps:%s", 17403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename); 17413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->page,geometry); 17423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->density != (char *) NULL) 17433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&annotate_info->density,draw_info->density); 17443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->antialias=draw_info->text_antialias; 17455cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy annotate_image=ReadImage(annotate_info,exception); 17465cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy CatchException(exception); 17473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info=DestroyImageInfo(annotate_info); 17483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RelinquishUniqueFileResource(filename); 17493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_image == (Image *) NULL) 17503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 175155cb9f15b804f98ac7d37615b8f5f8888fc792f4cristy (void) NegateImage(annotate_image,MagickFalse,exception); 17523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.x=DefaultResolution; 17533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.y=DefaultResolution; 17543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->density != (char *) NULL) 17553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 17563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GeometryInfo 17573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry_info; 17583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickStatusType 17603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags; 17613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=ParseGeometry(draw_info->density,&geometry_info); 17633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.x=geometry_info.rho; 17643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.y=geometry_info.sigma; 17653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & SigmaValue) == 0) 17663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resolution.y=resolution.x; 17673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 17683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (identity == MagickFalse) 1769e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (void) TransformImage(&annotate_image,"0x0",(char *) NULL,exception); 17703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 17713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 17723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 17733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 17743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17755cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy crop_info=GetImageBoundingBox(annotate_image,exception); 1776bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height=(size_t) ((resolution.y/DefaultResolution)* 17773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5); 1778bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.y=(ssize_t) ceil((resolution.y/DefaultResolution)*extent.y/8.0- 177906609eef311d5af857f65f20ed3af6860c1994becristy 0.5); 1780b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(geometry,MaxTextExtent, 17816d8abbae64da926477182d86d5007bc2c5a8b979cristy "%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double) 1782e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy crop_info.height,(double) crop_info.x,(double) crop_info.y); 1783e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (void) TransformImage(&annotate_image,geometry,(char *) NULL,exception); 17843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 17853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->pixels_per_em.x=(resolution.y/DefaultResolution)* 17863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExpandAffine(&draw_info->affine)*draw_info->pointsize; 17873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->pixels_per_em.y=metrics->pixels_per_em.x; 17883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->ascent=metrics->pixels_per_em.x; 17893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->descent=metrics->pixels_per_em.y/-5.0; 17903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->width=(double) annotate_image->columns/ 17913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExpandAffine(&draw_info->affine); 17923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->height=1.152*metrics->pixels_per_em.x; 17933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->max_advance=metrics->pixels_per_em.x; 17943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x1=0.0; 17953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y1=metrics->descent; 17963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x2=metrics->ascent+metrics->descent; 17973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y2=metrics->ascent+metrics->descent; 17983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->underline_position=(-2.0); 17993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->underline_thickness=1.0; 18003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->render == MagickFalse) 18013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 18023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image=DestroyImage(annotate_image); 18033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 18043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 18054c08aed51c5899665ade97263692328eea4af106cristy if (draw_info->fill.alpha != TransparentAlpha) 18063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1807bd65948def60e897a2641d9503470945c304f46fcristy CacheView 1808bd65948def60e897a2641d9503470945c304f46fcristy *annotate_view; 1809bd65948def60e897a2641d9503470945c304f46fcristy 18103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 18113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sync; 18123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1813101ab708b0574518ac5715da4d3915400e9df79acristy PixelInfo 18143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fill_color; 18153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 18173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Render fill color. 18183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 18198a46d827a124555f0c48fb2368ec1bba8e079ab6cristy if (image->alpha_trait != BlendPixelTrait) 182063240888c3975789a09c2494a4654b523931df96cristy (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); 18218a46d827a124555f0c48fb2368ec1bba8e079ab6cristy if (annotate_image->alpha_trait != BlendPixelTrait) 182263240888c3975789a09c2494a4654b523931df96cristy (void) SetImageAlphaChannel(annotate_image,OpaqueAlphaChannel, 182363240888c3975789a09c2494a4654b523931df96cristy exception); 18243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fill_color=draw_info->fill; 182546ff2676b1044ea4101ac7a59b83289cd8f6cfdacristy annotate_view=AcquireAuthenticCacheView(annotate_image,exception); 1826bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (y=0; y < (ssize_t) annotate_image->rows; y++) 18273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1828bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 18293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 18303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18314c08aed51c5899665ade97263692328eea4af106cristy register Quantum 1832c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 18333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=GetCacheViewAuthenticPixels(annotate_view,0,y,annotate_image->columns, 18353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1,exception); 18366193b86c0b59030b647a10c75f37ec82d73e3695cristy if (q == (Quantum *) NULL) 18373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 1838bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (x=0; x < (ssize_t) annotate_image->columns; x++) 18393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 18402ed42f6d7c2245432767ea446742977ee87e963ccristy (void) GetFillColor(draw_info,x,y,&fill_color,exception); 184155cb9f15b804f98ac7d37615b8f5f8888fc792f4cristy SetPixelAlpha(annotate_image,ClampToQuantum((((double) QuantumScale* 184255cb9f15b804f98ac7d37615b8f5f8888fc792f4cristy GetPixelIntensity(annotate_image,q)*fill_color.alpha))),q); 18434c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(annotate_image,fill_color.red,q); 18444c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(annotate_image,fill_color.green,q); 18454c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(annotate_image,fill_color.blue,q); 1846ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(annotate_image); 18473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 18483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sync=SyncCacheViewAuthenticPixels(annotate_view,exception); 18493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (sync == MagickFalse) 18503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 18513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 18523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_view=DestroyCacheView(annotate_view); 185339172408bad7ef2ef00a815fa9abf9979e7857cbcristy (void) CompositeImage(image,annotate_image,OverCompositeOp,MagickTrue, 1854bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (ssize_t) ceil(offset->x-0.5),(ssize_t) ceil(offset->y-(metrics->ascent+ 1855e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy metrics->descent)-0.5),exception); 18563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 18573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image=DestroyImage(annotate_image); 18583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 18593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 18603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 18623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ R e n d e r X 1 1 % 18673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% RenderX11() renders text on the image with an X11 font. It also returns the 18733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% bounding box of the text relative to the image. 18743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the RenderX11 method is: 18763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType RenderX11(Image *image,DrawInfo *draw_info, 18785cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 18793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 18813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 18833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: the draw info. 18853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o offset: (x,y) location of text relative to image. 18873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o metrics: bounding box of text. 18893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18905cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% o exception: return any errors or warnings in this structure. 18915cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% 18923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 18933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_X11_DELEGATE) 18943ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType RenderX11(Image *image,const DrawInfo *draw_info, 18955cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 18963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 18973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 18983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 18993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static DrawInfo 19013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cache_info; 19023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static Display 19043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *display = (Display *) NULL; 19053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XAnnotateInfo 19073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info; 19083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XFontStruct 19103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *font_info; 19113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XPixelInfo 19133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 19143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XResourceInfo 19163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info; 19173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XrmDatabase 19193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_database; 19203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XStandardColormap 19223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info; 19233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XVisualInfo 19253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual_info; 19263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1927bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 19283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 19293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 19303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1931d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy if (annotate_semaphore == (SemaphoreInfo *) NULL) 1932d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy AcquireSemaphoreInfo(&annotate_semaphore); 1933d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy LockSemaphoreInfo(annotate_semaphore); 19343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 19353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1936104cea817534e8601291610f22e496c10f8f9ddbcristy const char 1937104cea817534e8601291610f22e496c10f8f9ddbcristy *client_name; 1938104cea817534e8601291610f22e496c10f8f9ddbcristy 19393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 19403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image_info; 19413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Open X server connection. 19443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display=XOpenDisplay(draw_info->server_name); 19463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 19473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 19483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToOpenXServer", 19493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->server_name); 19503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 19513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 19523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get user defaults from X resource database. 19543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetErrorHandler(XError); 19563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=AcquireImageInfo(); 1957104cea817534e8601291610f22e496c10f8f9ddbcristy client_name=GetClientName(); 1958309c861abe279e5ad97173157f7c05fb9f4d5f8bcristy resource_database=XGetResourceDatabase(display,client_name); 1959f9d6dc0085244ce46c61d16e4614e43e535da3afcristy XGetResourceInfo(image_info,resource_database,client_name, 1960f9d6dc0085244ce46c61d16e4614e43e535da3afcristy &resource_info); 19613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info.close_server=MagickFalse; 19623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info.colormap=PrivateColormap; 19633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info.font=AcquireString(draw_info->font); 19643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info.background_color=AcquireString("#ffffffffffff"); 19653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info.foreground_color=AcquireString("#000000000000"); 19663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info=XAllocStandardColormap(); 19673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info == (XStandardColormap *) NULL) 19683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 19693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed", 19703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 19713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 19723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 19733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize visual info. 19753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=XBestVisualInfo(display,map_info,&resource_info); 19773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info == (XVisualInfo *) NULL) 19783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 19793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToGetVisual", 19803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 19813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 19823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 19833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap=(Colormap) NULL; 1984f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel.pixels=(unsigned long *) NULL; 19853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize Standard Colormap info. 19873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGetMapInfo(visual_info,XDefaultColormap(display,visual_info->screen), 19893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info); 19904c08aed51c5899665ade97263692328eea4af106cristy XGetPixelInfo(display,visual_info,map_info,&resource_info,(Image *) NULL, 19914c08aed51c5899665ade97263692328eea4af106cristy &pixel); 19923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel.annotate_context=XDefaultGC(display,visual_info->screen); 19933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize font info. 19953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=XBestFont(display,&resource_info,MagickFalse); 19973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info == (XFontStruct *) NULL) 19983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 19993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToLoadFont", 20003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->font); 20013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 20023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((map_info == (XStandardColormap *) NULL) || 20043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info == (XVisualInfo *) NULL) || 20053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (font_info == (XFontStruct *) NULL)) 20063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFreeResources(display,visual_info,map_info,&pixel,font_info, 20083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &resource_info,(XWindowInfo *) NULL); 20093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToLoadFont", 20103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 20113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 20123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cache_info=(*draw_info); 20143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2015d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy UnlockSemaphoreInfo(annotate_semaphore); 20163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize annotate info. 20183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGetAnnotateInfo(&annotate_info); 20203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info.stencil=ForegroundStencil; 20213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (cache_info.font != draw_info->font) 20223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Type name has changed. 20253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeFont(display,font_info); 20273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&resource_info.font,draw_info->font); 20283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=XBestFont(display,&resource_info,MagickFalse); 20293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info == (XFontStruct *) NULL) 20303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToLoadFont", 20323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->font); 20333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 20343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 20373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(AnnotateEvent,GetMagickModule(), 2038e7f5109f30fc7242d04a26174a9138483dda5b6acristy "Font %s; pointsize %g",draw_info->font != (char *) NULL ? 20393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->font : "none",draw_info->pointsize); 20403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cache_info=(*draw_info); 20413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info.font_info=font_info; 20423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info.text=(char *) draw_info->text; 20433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info.width=(unsigned int) XTextWidth(font_info,draw_info->text, 20443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) strlen(draw_info->text)); 20453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info.height=(unsigned int) font_info->ascent+font_info->descent; 20463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->pixels_per_em.x=(double) font_info->max_bounds.width; 20473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->pixels_per_em.y=(double) font_info->ascent+font_info->descent; 20483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->ascent=(double) font_info->ascent+4; 20493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->descent=(double) (-font_info->descent); 20503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->width=annotate_info.width/ExpandAffine(&draw_info->affine); 20513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->height=font_info->ascent+font_info->descent; 20523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->max_advance=(double) font_info->max_bounds.width; 20533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x1=0.0; 20543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y1=metrics->descent; 20553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.x2=metrics->ascent+metrics->descent; 20563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->bounds.y2=metrics->ascent+metrics->descent; 20573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->underline_position=(-2.0); 20583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy metrics->underline_thickness=1.0; 20593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->render == MagickFalse) 20603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 20614c08aed51c5899665ade97263692328eea4af106cristy if (draw_info->fill.alpha == TransparentAlpha) 20623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 20633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Render fill color. 20653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=annotate_info.width; 20673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=annotate_info.height; 2068aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy if ((fabs(draw_info->affine.rx) >= MagickEpsilon) || 2069aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy (fabs(draw_info->affine.ry) >= MagickEpsilon)) 20703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2071aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy if ((fabs(draw_info->affine.sx-draw_info->affine.sy) < MagickEpsilon) && 2072aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy (fabs(draw_info->affine.rx+draw_info->affine.ry) < MagickEpsilon)) 2073aa83c2c383e62bd5342c0d38dc5f6e746998bde8cristy annotate_info.degrees=(double) (180.0/MagickPI)* 2074854209afe797f1a6ecec8679889302af4d4b0faccristy atan2(draw_info->affine.rx,draw_info->affine.sx); 20753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2076b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(annotate_info.geometry,MaxTextExtent, 20776d8abbae64da926477182d86d5007bc2c5a8b979cristy "%.20gx%.20g%+.20g%+.20g",(double) width,(double) height, 2078e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy ceil(offset->x-0.5),ceil(offset->y-metrics->ascent-metrics->descent+ 207906609eef311d5af857f65f20ed3af6860c1994becristy draw_info->interline_spacing-0.5)); 20803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel.pen_color.red=ScaleQuantumToShort(draw_info->fill.red); 20813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel.pen_color.green=ScaleQuantumToShort(draw_info->fill.green); 20823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel.pen_color.blue=ScaleQuantumToShort(draw_info->fill.blue); 20837c3af951210f34d3f244b31f06ee291e5be8ecb7cristy status=XAnnotateImage(display,&pixel,&annotate_info,image,exception); 20843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == 0) 20853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed", 20873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 20883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 20893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 20913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 20923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 20933ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType RenderX11(Image *image,const DrawInfo *draw_info, 20945cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 20953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 20963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) draw_info; 20973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) offset; 20983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) metrics; 20995cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (void) ThrowMagickException(exception,GetMagickModule(), 2100e5b39652d8d21bc3940d83b8d6088d4070a8a34aanthony MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","'%s' (X11)", 21013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 21023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 21033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 21043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 2105