-
Notifications
You must be signed in to change notification settings - Fork 0
/
setFontFamily.c
134 lines (95 loc) · 3.15 KB
/
setFontFamily.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wand/MagickWand.h>
void ThrowWandException(MagickWand *wand) {
char *description;
ExceptionType severity;
description = MagickGetException(wand, &severity);
(void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
description=(char *) MagickRelinquishMemory(description);
exit(-1);
}
PixelWand *makePixelWand(char *string) {
PixelWand *pixel_wand;
pixel_wand = NewPixelWand();
if (PixelSetColor (pixel_wand, string) == MagickFalse) {
printf("Failed to set color");
exit(-1);
}
return pixel_wand;
}
void addImage(MagickWand *canvas, int offset, char *strokeColor) {
MagickBooleanType status;
MagickWand *pseudo_wand;
DrawingWand *drawing_wand;
PixelWand *fill_color_wand, *stroke_color_wand;
int columns = 100;
int rows = 100;
char *fillColor = "black";
char filename[1024];
sprintf(filename, "./output/bug61806_%d.png", offset);
drawing_wand = NewDrawingWand();
DrawSetFontSize(drawing_wand, 96);
stroke_color_wand = makePixelWand(strokeColor);
DrawSetStrokeColor(drawing_wand, stroke_color_wand);
fill_color_wand = makePixelWand(fillColor);
DrawSetFillColor(drawing_wand, fill_color_wand);
pseudo_wand = NewMagickWand();
DrawSetStrokeWidth(drawing_wand, 1);
status = MagickSetSize(pseudo_wand, columns, rows);
if (status == MagickFalse) {
ThrowWandException(pseudo_wand);
}
if (MagickReadImage(pseudo_wand, "canvas:white") == MagickFalse) {
printf("Goodbye\n");
ThrowWandException(pseudo_wand);
}
DrawSetFontWeight(drawing_wand, 100);
status = MagickAnnotateImage(
pseudo_wand, drawing_wand,
-50 + offset, 62, 0,
"test"
);
if (status == MagickFalse) {
printf("Failed to set format");
ThrowWandException(pseudo_wand);
}
MagickScaleImage(pseudo_wand, 400, 400);
status = MagickAddImage(canvas, pseudo_wand);
}
int main(int argc,char **argv) {
MagickWand *canvas_wand;
MagickWand *tmp_wand;
DrawingWand *drawing_wand;
MagickBooleanType status;
char *family;
MagickWand *pseudo_wand;
MagickWandGenesis();
drawing_wand = NewDrawingWand();
status = DrawSetFontFamily(drawing_wand, "Nsdsds Mono asdsdasds");
if (status == MagickFalse) {
printf("Failed to setFontFamily\n");
}
else {
printf("It's okay.\n");
}
family = DrawGetFontFamily(drawing_wand);
printf("Family is now %s\n", family);
PixelWand *pixel_wand = makePixelWand("red");
DrawSetFillColor(drawing_wand, pixel_wand);
DrawAnnotation(drawing_wand, 10, 20, "Hello there.");
pseudo_wand = NewMagickWand();
status = MagickSetSize(pseudo_wand, 300, 100);
if (status == MagickFalse) {
ThrowWandException(pseudo_wand);
}
if (MagickReadImage(pseudo_wand, "canvas:white") == MagickFalse) {
printf("Goodbye\n");
ThrowWandException(pseudo_wand);
}
MagickDrawImage(pseudo_wand, drawing_wand);
MagickWriteImage(pseudo_wand, "./setFontFamily.png");
MagickWandTerminus();
return (0);
}