From 87dc5e4e6f9471304ba85f508de30e664b484d3a Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 5 Feb 2016 18:52:57 -0500 Subject: [PATCH] ... --- MagickCore/annotate.c | 71 ++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 44 deletions(-) diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c index bb99cf998..0b9d3b302 100644 --- a/MagickCore/annotate.c +++ b/MagickCore/annotate.c @@ -109,23 +109,15 @@ #if defined(MAGICKCORE_RAQM_DELEGATE) #include #endif -typedef enum -{ - GRAPHEME_DIRECTION_DEFAULT, - GRAPHEME_DIRECTION_RTL, - GRAPHEME_DIRECTION_LTR, - GRAPHEME_DIRECTION_TTB -} GraphemeDirection; - typedef struct _GraphemeInfo { - int + size_t index, x_offset, x_advance, y_offset; - unsigned int + size_t cluster; } GraphemeInfo; @@ -1026,33 +1018,33 @@ static MagickBooleanType RenderType(Image *image,const DrawInfo *draw_info, #if defined(MAGICKCORE_FREETYPE_DELEGATE) -static size_t ComplexTextLayout(const Image *image,const char *text, - const size_t length,const FT_Face face,const GraphemeDirection direction, - const FT_Int32 flags,GraphemeInfo **grapheme,ExceptionInfo *exception) +static size_t ComplexTextLayout(const Image *image,const DrawInfo *draw_info, + const char *text,const size_t length,const FT_Face face,const FT_Int32 flags, + GraphemeInfo **grapheme,ExceptionInfo *exception) { #if defined(MAGICKCORE_RAQM_DELEGATE) const char *features; - int - i; - - size_t - count; - raqm_t *rq; raqm_glyph_t *glyphs; + register size_t + i; + + ssize_t + count; + count=0; rq=raqm_create(); if (rq == (raqm_t *) NULL) goto cleanup; if (raqm_set_text_utf8(rq,text,length) == 0) goto cleanup; - if (raqm_set_par_direction(rq,(raqm_direction_t) direction) == 0) + if (raqm_set_par_direction(rq,(raqm_direction_t) draw_info->direction) == 0) goto cleanup; if (raqm_set_freetype_face(rq,face) == 0) goto cleanup; @@ -1064,16 +1056,16 @@ static size_t ComplexTextLayout(const Image *image,const char *text, quote, *token; - TokenInfo - *token_info; - int next, status_token; + TokenInfo + *token_info; + next=0; token_info=AcquireTokenInfo(); - token=(char *) AcquireQuantumMemory(50,sizeof(*token)); + token=AcquireString(""); status_token=Tokenizer(token_info,0,token,50,features,"",",","",'\0', &breaker,&next,"e); while (status_token == 0) @@ -1099,7 +1091,7 @@ static size_t ComplexTextLayout(const Image *image,const char *text, count=0; goto cleanup; } - for (i = 0; i < count; i++) + for (i=0; i < (ssize_t) count; i++) { (*grapheme)[i].index=glyphs[i].index; (*grapheme)[i].x_offset=glyphs[i].x_offset; @@ -1112,6 +1104,9 @@ cleanup: raqm_destroy(rq); return(count); #else + const char + *p; + FT_Error ft_status; @@ -1121,9 +1116,6 @@ cleanup: ssize_t last_glyph; - const char - *p; - /* Simple layout for bi-directional text (right-to-left or left-to-right). */ @@ -1134,7 +1126,7 @@ cleanup: p=text; for (i=0; GetUTFCode(p) != 0; p+=GetUTFOctets(p), i++) { - (*grapheme)[i].index=FT_Get_Char_Index(face,GetUTFCode(p)); + (*grapheme)[i].index=(ssize_t) FT_Get_Char_Index(face,GetUTFCode(p)); (*grapheme)[i].x_offset=0; (*grapheme)[i].y_offset=0; if (((*grapheme)[i].index != 0) && (last_glyph != 0)) @@ -1147,8 +1139,8 @@ cleanup: ft_status=FT_Get_Kerning(face,last_glyph,(*grapheme)[i].index, ft_kerning_default,&kerning); if (ft_status == 0) - (*grapheme)[i-1].x_advance+=(FT_Pos) ((direction == - GRAPHEME_DIRECTION_RTL ? -1.0 : 1.0)*kerning.x); + (*grapheme)[i-1].x_advance+=(FT_Pos) ((draw_info->direction == + RightToLeftDirection ? -1.0 : 1.0)*kerning.x); } } ft_status=FT_Load_Glyph(face,(*grapheme)[i].index,flags); @@ -1284,9 +1276,6 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, glyph, last_glyph; - GraphemeDirection - direction; - GraphemeInfo *grapheme; @@ -1513,14 +1502,8 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, p=(char *) utf8; } status=MagickTrue; - direction=GRAPHEME_DIRECTION_DEFAULT; - if (draw_info->direction == RightToLeftDirection) - direction=GRAPHEME_DIRECTION_RTL; - else - if (draw_info->direction == LeftToRightDirection) - direction=GRAPHEME_DIRECTION_LTR; grapheme=(GraphemeInfo *) NULL; - length=ComplexTextLayout(image,p,strlen(p),face,direction,flags,&grapheme, + length=ComplexTextLayout(image,draw_info,p,strlen(p),face,flags,&grapheme, exception); code=0; for (i=0; i < (ssize_t) length; i++) @@ -1592,13 +1575,13 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, r=bitmap->bitmap.buffer; for (y=0; y < (ssize_t) bitmap->bitmap.rows; y++) { + double + fill_opacity; + MagickBooleanType active, sync; - double - fill_opacity; - PixelInfo fill_color; -- 2.40.0