/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a g i c k Q u e r y M u l t i l i n e F o n t M e t r i c s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MagickQueryMultilineFontMetrics() returns a 13 element array representing the % following font metrics: % % Element Description % ------------------------------------------------- % 0 character width % 1 character height % 2 ascender % 3 descender % 4 text width % 5 text height % 6 maximum horizontal advance % 7 bounding box: x1 % 8 bounding box: y1 % 9 bounding box: x2 % 10 bounding box: y2 % 11 origin: x % 12 origin: y % % This method is like MagickQueryFontMetrics() but it returns the maximum text % width and height for multiple lines of text. % % The format of the MagickQueryFontMetrics method is: % % double *MagickQueryMultilineFontMetrics(MagickWand *wand, % const DrawingWand *drawing_wand,const char *text) % % A description of each parameter follows: % % o wand: the Magick wand. % % o drawing_wand: the drawing wand. % % o text: the text. % */ WandExport double *MagickQueryMultilineFontMetrics(MagickWand *wand, const DrawingWand *drawing_wand,const char *text) { double *font_metrics; DrawInfo *draw_info; MagickBooleanType status; TypeMetric metrics; assert(wand != (MagickWand *) NULL); assert(wand->signature == WandSignature); if (wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); assert(drawing_wand != (const DrawingWand *) NULL); if (wand->images == (Image *) NULL) { (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError, "ContainsNoImages","`%s'",wand->name); return((double *) NULL); } font_metrics=(double *) AcquireQuantumMemory(13UL,sizeof(*font_metrics)); if (font_metrics == (double *) NULL) return((double *) NULL); draw_info=PeekDrawingWand(drawing_wand); if (draw_info == (DrawInfo *) NULL) { font_metrics=(double *) RelinquishMagickMemory(font_metrics); return((double *) NULL); } (void) CloneString(&draw_info->text,text); (void) ResetMagickMemory(&metrics,0,sizeof(metrics)); status=GetMultilineTypeMetrics(wand->images,draw_info,&metrics, wand->exception); draw_info=DestroyDrawInfo(draw_info); if (status == MagickFalse) { font_metrics=(double *) RelinquishMagickMemory(font_metrics); return((double *) NULL); } font_metrics[0]=metrics.pixels_per_em.x; font_metrics[1]=metrics.pixels_per_em.y; font_metrics[2]=metrics.ascent; font_metrics[3]=metrics.descent; font_metrics[4]=metrics.width; font_metrics[5]=metrics.height; font_metrics[6]=metrics.max_advance; font_metrics[7]=metrics.bounds.x1; font_metrics[8]=metrics.bounds.y1; font_metrics[9]=metrics.bounds.x2; font_metrics[10]=metrics.bounds.y2; font_metrics[11]=metrics.origin.x; font_metrics[12]=metrics.origin.y; return(font_metrics); }
static bool HHVM_METHOD(ImagickDraw, setResolution, double x, double y) { auto wand = getDrawingWandResource(Object{this_}); std::ostringstream density; density << x << "x" << y; auto drawInfo = PeekDrawingWand(wand->getWand()); drawInfo->density = AcquireString(density.str().c_str()); auto drawWand = DrawAllocateWand(drawInfo, nullptr); if (drawWand == nullptr) { IMAGICKDRAW_THROW("Failed to allocate new DrawingWand structure"); } setWandResource(s_ImagickDraw, Object{this_}, drawWand); return true; }