1185
1173
if (image->matte == MagickFalse)
1186
1174
(void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
1189
if (draw_info->direction == RightToLeftDirection)
1193
1179
for (p=draw_info->text; GetUTFCode(p) != 0; p+=GetUTFOctets(p))
1194
1180
if (GetUTFCode(p) < 0)
1196
utf8=(unsigned char *) NULL;
1197
1182
if (GetUTFCode(p) == 0)
1183
for (p=draw_info->text; GetUTFCode(p) != 0; p+=GetUTFOctets(p))
1186
Render UTF-8 sequence.
1188
glyph.id=FT_Get_Char_Index(face,GetUTFCode(p));
1190
glyph.id=FT_Get_Char_Index(face,'?');
1191
if ((glyph.id != 0) && (last_glyph.id != 0))
1193
if (draw_info->kerning != 0.0)
1194
origin.x+=64.0*draw_info->kerning;
1196
if (FT_HAS_KERNING(face))
1201
status=FT_Get_Kerning(face,last_glyph.id,glyph.id,
1202
ft_kerning_default,&kerning);
1204
origin.x+=kerning.x;
1207
glyph.origin=origin;
1208
status=FT_Load_Glyph(face,glyph.id,flags);
1211
status=FT_Get_Glyph(face->glyph,&glyph.image);
1214
status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
1218
if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
1219
metrics->bounds.x1=bounds.xMin;
1220
if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
1221
metrics->bounds.y1=bounds.yMin;
1222
if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
1223
metrics->bounds.x2=bounds.xMax;
1224
if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
1225
metrics->bounds.y2=bounds.yMax;
1226
if (draw_info->render != MagickFalse)
1227
if ((draw_info->stroke.opacity != TransparentOpacity) ||
1228
(draw_info->stroke_pattern != (Image *) NULL))
1233
annotate_info->affine.tx=glyph.origin.x/64.0;
1234
annotate_info->affine.ty=glyph.origin.y/64.0;
1235
(void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)->
1236
outline,&OutlineMethods,annotate_info);
1238
FT_Vector_Transform(&glyph.origin,&affine);
1239
(void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin);
1240
status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal,
1241
(FT_Vector *) NULL,MagickTrue);
1244
bitmap=(FT_BitmapGlyph) glyph.image;
1245
point.x=offset->x+bitmap->left;
1246
point.y=offset->y-bitmap->top;
1247
if (draw_info->render != MagickFalse)
1259
Rasterize the glyph.
1262
exception=(&image->exception);
1263
image_view=AcquireCacheView(image);
1264
for (y=0; y < (long) bitmap->bitmap.rows; y++)
1283
register PixelPacket
1286
register unsigned char
1289
if (status == MagickFalse)
1291
x_offset=(long) (point.x+0.5);
1292
y_offset=(long) (point.y+y+0.5);
1293
if ((y_offset < 0) || (y_offset >= (long) image->rows))
1295
q=(PixelPacket *) NULL;
1296
if ((x_offset < 0) || (x_offset >= (long) image->columns))
1300
q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,
1301
bitmap->bitmap.width,1,exception);
1302
active=q != (PixelPacket *) NULL ? MagickTrue : MagickFalse;
1304
p=bitmap->bitmap.buffer+y*bitmap->bitmap.width;
1305
for (x=0; x < (long) bitmap->bitmap.width; x++)
1308
if ((*p == 0) || (x_offset < 0) ||
1309
(x_offset >= (long) image->columns))
1315
fill_opacity=(MagickRealType) (*p)/(bitmap->bitmap.num_grays-1);
1316
if (draw_info->text_antialias == MagickFalse)
1317
fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0;
1318
if (active == MagickFalse)
1319
q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
1321
if (q == (PixelPacket *) NULL)
1327
(void) GetFillColor(draw_info,x_offset,y_offset,&fill_color);
1328
fill_opacity=QuantumRange-fill_opacity*(QuantumRange-
1329
fill_color.opacity);
1330
MagickCompositeOver(&fill_color,fill_opacity,q,q->opacity,q);
1331
if (active == MagickFalse)
1333
sync=SyncCacheViewAuthenticPixels(image_view,exception);
1334
if (sync == MagickFalse)
1340
sync=SyncCacheViewAuthenticPixels(image_view,exception);
1341
if (sync == MagickFalse)
1344
image_view=DestroyCacheView(image_view);
1346
if ((bitmap->left+bitmap->bitmap.width) > metrics->width)
1347
metrics->width=bitmap->left+bitmap->bitmap.width;
1348
if ((draw_info->interword_spacing != 0.0) &&
1349
(IsUTFSpace(GetUTFCode(p)) != MagickFalse) &&
1350
(IsUTFSpace(code) == MagickFalse))
1351
origin.x+=64.0*draw_info->interword_spacing;
1353
origin.x+=face->glyph->advance.x;
1354
metrics->origin.x=origin.x;
1355
metrics->origin.y=origin.y;
1356
if (last_glyph.id != 0)
1357
FT_Done_Glyph(last_glyph.image);
1362
for (p=draw_info->text; *p != 0; p++)
1201
utf8=ConvertLatin1ToUTF8((unsigned char *) draw_info->text);
1202
if (utf8 != (unsigned char *) NULL)
1205
for (code=0; GetUTFCode(p) != 0; p+=GetUTFOctets(p))
1208
Render UTF-8 sequence.
1210
glyph.id=FT_Get_Char_Index(face,GetUTFCode(p));
1212
glyph.id=FT_Get_Char_Index(face,'?');
1213
if ((glyph.id != 0) && (last_glyph.id != 0))
1215
if (draw_info->kerning != 0.0)
1216
origin.x+=64.0*direction*draw_info->kerning;
1218
if (FT_HAS_KERNING(face))
1223
status=FT_Get_Kerning(face,last_glyph.id,glyph.id,
1224
ft_kerning_default,&kerning);
1226
origin.x+=direction*kerning.x;
1229
glyph.origin=origin;
1230
status=FT_Load_Glyph(face,glyph.id,flags);
1233
status=FT_Get_Glyph(face->glyph,&glyph.image);
1236
status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
1240
if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
1241
metrics->bounds.x1=bounds.xMin;
1242
if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
1243
metrics->bounds.y1=bounds.yMin;
1244
if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
1245
metrics->bounds.x2=bounds.xMax;
1246
if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
1247
metrics->bounds.y2=bounds.yMax;
1248
if (draw_info->render != MagickFalse)
1249
if ((draw_info->stroke.opacity != TransparentOpacity) ||
1250
(draw_info->stroke_pattern != (Image *) NULL))
1365
Render Latin-1 sequence.
1367
glyph.id=FT_Get_Char_Index(face,(unsigned char) *p);
1369
glyph.id=FT_Get_Char_Index(face,'?');
1370
if ((glyph.id != 0) && (last_glyph.id != 0))
1372
if (draw_info->kerning != 0.0)
1373
origin.x+=64.0*draw_info->kerning;
1375
if (FT_HAS_KERNING(face))
1380
status=FT_Get_Kerning(face,last_glyph.id,glyph.id,
1381
ft_kerning_default,&kerning);
1383
origin.x+=kerning.x;
1386
glyph.origin=origin;
1387
status=FT_Load_Glyph(face,glyph.id,flags);
1390
status=FT_Get_Glyph(face->glyph,&glyph.image);
1393
status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
1397
if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
1398
metrics->bounds.x1=bounds.xMin;
1399
if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
1400
metrics->bounds.y1=bounds.yMin;
1401
if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
1402
metrics->bounds.x2=bounds.xMax;
1403
if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
1404
metrics->bounds.y2=bounds.yMax;
1405
if (draw_info->render != MagickFalse)
1406
if ((draw_info->stroke.opacity != TransparentOpacity) ||
1407
(draw_info->stroke_pattern != (Image *) NULL))
1412
annotate_info->affine.tx=glyph.origin.x/64.0;
1413
annotate_info->affine.ty=glyph.origin.y/64.0;
1414
(void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)->
1415
outline,&OutlineMethods,annotate_info);
1417
FT_Vector_Transform(&glyph.origin,&affine);
1418
(void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin);
1419
status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal,
1420
(FT_Vector *) NULL,MagickTrue);
1423
bitmap=(FT_BitmapGlyph) glyph.image;
1424
point.x=offset->x+bitmap->left;
1425
point.y=offset->y-bitmap->top;
1426
if (draw_info->render != MagickFalse)
1438
Rasterize the glyph.
1255
annotate_info->affine.tx=glyph.origin.x/64.0;
1256
annotate_info->affine.ty=glyph.origin.y/64.0;
1257
(void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)->
1258
outline,&OutlineMethods,annotate_info);
1260
FT_Vector_Transform(&glyph.origin,&affine);
1261
(void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin);
1262
status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal,
1263
(FT_Vector *) NULL,MagickTrue);
1266
bitmap=(FT_BitmapGlyph) glyph.image;
1267
point.x=offset->x+bitmap->left;
1268
point.y=offset->y-bitmap->top;
1269
if (draw_info->render != MagickFalse)
1281
Rasterize the glyph.
1284
exception=(&image->exception);
1285
image_view=AcquireCacheView(image);
1286
for (y=0; y < (ssize_t) bitmap->bitmap.rows; y++)
1301
register PixelPacket
1304
register unsigned char
1311
if (status == MagickFalse)
1313
x_offset=(ssize_t) ceil(point.x-0.5);
1314
y_offset=(ssize_t) ceil(point.y+y-0.5);
1315
if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
1317
q=(PixelPacket *) NULL;
1318
if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
1441
exception=(&image->exception);
1442
image_view=AcquireCacheView(image);
1443
for (y=0; y < (long) bitmap->bitmap.rows; y++)
1462
register PixelPacket
1465
register unsigned char
1468
if (status == MagickFalse)
1470
x_offset=(long) (point.x+0.5);
1471
y_offset=(long) (point.y+y+0.5);
1472
if ((y_offset < 0) || (y_offset >= (long) image->rows))
1474
q=(PixelPacket *) NULL;
1475
if ((x_offset < 0) || (x_offset >= (long) image->columns))
1479
q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,
1480
bitmap->bitmap.width,1,exception);
1481
active=q != (PixelPacket *) NULL ? MagickTrue : MagickFalse;
1483
p=bitmap->bitmap.buffer+y*bitmap->bitmap.width;
1484
for (x=0; x < (long) bitmap->bitmap.width; x++)
1322
q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,
1323
bitmap->bitmap.width,1,exception);
1324
active=q != (PixelPacket *) NULL ? MagickTrue : MagickFalse;
1487
if ((*p == 0) || (x_offset < 0) ||
1488
(x_offset >= (long) image->columns))
1494
fill_opacity=(MagickRealType) (*p)/(bitmap->bitmap.num_grays-1);
1495
if (draw_info->text_antialias == MagickFalse)
1496
fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0;
1497
if (active == MagickFalse)
1498
q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
1500
if (q == (PixelPacket *) NULL)
1506
(void) GetFillColor(draw_info,x_offset,y_offset,&fill_color);
1507
fill_opacity=QuantumRange-fill_opacity*(QuantumRange-
1508
fill_color.opacity);
1509
MagickCompositeOver(&fill_color,fill_opacity,q,q->opacity,q);
1510
if (active == MagickFalse)
1512
sync=SyncCacheViewAuthenticPixels(image_view,exception);
1513
if (sync == MagickFalse)
1326
p=bitmap->bitmap.buffer+y*bitmap->bitmap.width;
1327
for (x=0; x < (ssize_t) bitmap->bitmap.width; x++)
1330
if ((*p == 0) || (x_offset < 0) ||
1331
(x_offset >= (ssize_t) image->columns))
1337
fill_opacity=(MagickRealType) (*p)/(bitmap->bitmap.num_grays-1);
1338
if (draw_info->text_antialias == MagickFalse)
1339
fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0;
1340
if (active == MagickFalse)
1341
q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
1343
if (q == (PixelPacket *) NULL)
1349
(void) GetFillColor(draw_info,x_offset,y_offset,&fill_color);
1350
fill_opacity=QuantumRange-fill_opacity*(QuantumRange-
1351
fill_color.opacity);
1352
MagickCompositeOver(&fill_color,fill_opacity,q,q->opacity,q);
1353
if (active == MagickFalse)
1355
sync=SyncCacheViewAuthenticPixels(image_view,exception);
1356
if (sync == MagickFalse)
1519
sync=SyncCacheViewAuthenticPixels(image_view,exception);
1520
if (sync == MagickFalse)
1362
sync=SyncCacheViewAuthenticPixels(image_view,exception);
1363
if (sync == MagickFalse)
1523
image_view=DestroyCacheView(image_view);
1366
image_view=DestroyCacheView(image_view);
1368
if ((bitmap->left+bitmap->bitmap.width) > metrics->width)
1369
metrics->width=bitmap->left+bitmap->bitmap.width;
1370
if ((draw_info->interword_spacing != 0.0) &&
1371
(IsUTFSpace(GetUTFCode(p)) != MagickFalse) &&
1372
(IsUTFSpace(code) == MagickFalse))
1373
origin.x+=64.0*direction*draw_info->interword_spacing;
1375
origin.x+=direction*face->glyph->advance.x;
1376
metrics->origin.x=origin.x;
1377
metrics->origin.y=origin.y;
1378
if (last_glyph.id != 0)
1379
FT_Done_Glyph(last_glyph.image);
1383
if (utf8 != (unsigned char *) NULL)
1384
utf8=(unsigned char *) RelinquishMagickMemory(utf8);
1525
if ((bitmap->left+bitmap->bitmap.width) > metrics->width)
1526
metrics->width=bitmap->left+bitmap->bitmap.width;
1527
if ((draw_info->interword_spacing != 0.0) &&
1528
(isspace((int) ((unsigned char) *p)) != 0) &&
1529
(isspace((int) code) == 0))
1530
origin.x+=64.0*draw_info->interword_spacing;
1532
origin.x+=face->glyph->advance.x;
1533
metrics->origin.x=origin.x;
1534
metrics->origin.y=origin.y;
1535
if (last_glyph.id != 0)
1536
FT_Done_Glyph(last_glyph.image);
1385
1540
if (last_glyph.id != 0)
1386
1541
FT_Done_Glyph(last_glyph.image);
1387
1542
if ((draw_info->stroke.opacity != TransparentOpacity) ||