]> granicus.if.org Git - imagemagick/commitdiff
Added text direction to Wand and added DrawableTextDirection to Magick++.
authordirk <dirk@git.imagemagick.org>
Mon, 27 Jan 2014 19:08:45 +0000 (19:08 +0000)
committerdirk <dirk@git.imagemagick.org>
Mon, 27 Jan 2014 19:08:45 +0000 (19:08 +0000)
Magick++/lib/Drawable.cpp
Magick++/lib/Magick++/Drawable.h
MagickCore/draw.c
MagickWand/drawing-wand.c
MagickWand/drawing-wand.h

index 22da085e06f8d798572275f48f0d47ed25e72de6..fbf2020f8ae4acfe9c003cbb91428fa8575a3169 100644 (file)
@@ -1354,6 +1354,38 @@ Magick::DrawableBase* Magick::DrawableTextDecoration::copy() const
   return new DrawableTextDecoration(*this);
 }
 
+// DrawableTextDirection
+Magick::DrawableTextDirection::DrawableTextDirection(
+  DirectionType direction_)
+  : _direction(direction_)
+{
+}
+
+Magick::DrawableTextDirection::~DrawableTextDirection(void)
+{
+}
+
+void Magick::DrawableTextDirection::operator()(
+  MagickCore::DrawingWand *context_) const
+{
+  DrawSetTextDirection(context_,_direction);
+}
+
+void Magick::DrawableTextDirection::direction(DirectionType direction_)
+{
+  _direction=direction_;
+}
+
+Magick::DirectionType Magick::DrawableTextDirection::direction(void) const
+{
+  return(_direction);
+}
+
+Magick::DrawableBase *Magick::DrawableTextDirection::copy() const
+{
+  return new DrawableTextDirection(*this);
+}
+
 // DrawableTextInterlineSpacing
 Magick::DrawableTextInterlineSpacing::DrawableTextInterlineSpacing(
   double spacing_)
index 59d203690a5166dd9e263ba709b4e1a15f6c0f07..e35f829c780befc655db1ec930d27f798a2bcd75 100644 (file)
@@ -1986,6 +1986,26 @@ private:
   DecorationType _decoration;
 };
 
+  // Render text right-to-left or left-to-right.
+  class MagickPPExport DrawableTextDirection : public DrawableBase
+  {
+  public:
+
+    DrawableTextDirection(DirectionType direction_);
+
+    ~DrawableTextDirection(void);
+
+    void operator()(MagickCore::DrawingWand *context_) const;
+
+    void direction(DirectionType direction_);
+    DirectionType direction(void) const;
+
+    DrawableBase* copy() const;
+
+  private:
+    DirectionType _direction;
+  };
+
   // Specify text inter-line spacing
   class MagickPPExport DrawableTextInterlineSpacing : public DrawableBase
   {
index 56649cad8853a423badedda9bd21e1c45967c1e9..30ef126c296e7890f780a62f2c5df55d21cc2846 100644 (file)
@@ -1961,6 +1961,20 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
               graphic_context[n]->decorate=(DecorationType) decorate;
             break;
           }
+        if (LocaleCompare("direction",keyword) == 0)
+          {
+            ssize_t
+              direction;
+
+            GetMagickToken(q,&q,token);
+            direction=ParseCommandOption(MagickDirectionOptions,MagickFalse,
+              token);
+            if (direction == -1)
+              status=MagickFalse;
+            else
+              graphic_context[n]->direction=(DirectionType) direction;
+            break;
+          }
         status=MagickFalse;
         break;
       }
index 440d04bb7369d8929cbb9acb61280beb81e5c349..a3ef2f047128a482650778953fb324ae2348b9b2 100644 (file)
@@ -2298,6 +2298,38 @@ WandExport DecorationType DrawGetTextDecoration(const DrawingWand *wand)
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   D r a w G e t T e x t D i r e c t i o n                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DrawGetTextDirection() returns the direction that will be used when
+%  annotating with text.
+%
+%  The format of the DrawGetTextDirection method is:
+%
+%      DirectionType DrawGetTextDirection(const DrawingWand *wand)
+%
+%  A description of each parameter follows:
+%
+%    o wand: the drawing wand.
+%
+*/
+WandExport DirectionType DrawGetTextDirection(const DrawingWand *wand)
+{
+  assert(wand != (const DrawingWand *) NULL);
+  assert(wand->signature == WandSignature);
+  if (wand->debug != MagickFalse)
+    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
+  return(CurrentContext->direction);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   D r a w G e t T e x t E n c o d i n g                                     %
 %                                                                             %
 %                                                                             %
@@ -5914,7 +5946,51 @@ WandExport void DrawSetTextDecoration(DrawingWand *wand,
         MagickDecorateOptions,(ssize_t) decoration));
     }
 }
-\f
+
+\f/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   D r a w S e t T e x t D i r e c t i o n                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DrawSetTextDirection() specifies the direction to be used when
+%  annotating with text.
+%
+%  The format of the DrawSetTextDirection method is:
+%
+%      void DrawSetTextDirection(DrawingWand *wand,
+%        const DirectionType direction)
+%
+%  A description of each parameter follows:
+%
+%    o wand: the drawing wand.
+%
+%    o direction: text direction. One of RightToLeftDirection,
+%      LeftToRightDirection
+%
+*/
+WandExport void DrawSetTextDirection(DrawingWand *wand,
+  const DirectionType direction)
+{
+  assert(wand != (DrawingWand *) NULL);
+  assert(wand->signature == WandSignature);
+
+  if (wand->debug != MagickFalse)
+    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
+  if ((wand->filter_off != MagickFalse) ||
+      (CurrentContext->direction != direction))
+    {
+      CurrentContext->direction=direction;
+      (void) MvgPrintf(wand,"direction '%s'\n",CommandOptionToMnemonic(
+        MagickDirectionOptions,(ssize_t) direction));
+    }
+}
+
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
index c5af076896b54e58bdd4189c48916a283dff01d5..aeeb66426ebae533cb57980a203308e933949ba6 100644 (file)
@@ -44,6 +44,9 @@ extern WandExport ClipPathUnits
 extern WandExport DecorationType
   DrawGetTextDecoration(const DrawingWand *);
 
+extern WandExport DirectionType
+  DrawGetTextDirection(const DrawingWand *);
+
 extern WandExport double
   DrawGetFillAlpha(const DrawingWand *),
   DrawGetFontSize(const DrawingWand *),
@@ -207,6 +210,7 @@ extern WandExport void
   DrawSetTextAlignment(DrawingWand *,const AlignType),
   DrawSetTextAntialias(DrawingWand *,const MagickBooleanType),
   DrawSetTextDecoration(DrawingWand *,const DecorationType),
+  DrawSetTextDirection(DrawingWand *,const DirectionType),
   DrawSetTextEncoding(DrawingWand *,const char *),
   DrawSetTextUnderColor(DrawingWand *,const PixelWand *),
   DrawSetViewbox(DrawingWand *,const double,const double,const double,