History

raster: use ppem for scaling

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit def6bc81 parent c623ba38 files · +105 −84Browse files

Unified · Split

8 files
  1. otf.c.in +6 −0
  2. otf.h.in +1 −1
  3. otf.rkt +1 −1
  4. plan9/otf.c +6 −0
  5. plan9/otf.h +2 −1
  6. plan9/test.c +34 −32
  7. rast.c +18 −14
  8. unix/test.c +37 −35
otf.c.in+6−0
@@ -539,6 +539,10 @@ otfglyf(Otf *o, int index) · 538 unmodified lines
539 werrstr("no memory");539 werrstr("no memory");
540 goto err;540 goto err;
541 }541 }
542 if(o->td.head == nil){
543 werrstr("no head table");
544 goto err;
545 }
542 if(o->td.loca == nil){546 if(o->td.loca == nil){
543 werrstr("no loca table");547 werrstr("no loca table");
544 goto err;548 goto err;
@@ -577,6 +581,8 @@ otfglyf(Otf *o, int index) · 32 unmodified lines
577 if(read_Glyf(o, g) < 0){581 if(read_Glyf(o, g) < 0){
578 free(g);582 free(g);
579 g = nil;583 g = nil;
584 }else{
585 g->unitsPerEm = o->td.head->unitsPerEm;
580 }586 }
581 otfpoprange(o);587 otfpoprange(o);
582 otfpoprange(o);588 otfpoprange(o);
otf.h.in+1−1
@@ -80,4 +80,4 @@ void otfclose(Otf *o); · 79 unmodified lines
80typedef struct Glyf Glyf;80typedef struct Glyf Glyf;
81Glyf *otfglyf(Otf *o, int index);81Glyf *otfglyf(Otf *o, int index);
82int otfglyfnum(Otf *o);82int otfglyfnum(Otf *o);
83u8int *otfdrawglyf(Glyf *g, int h, int *wo);83u8int *otfdrawglyf(Glyf *g, int ppem, int *wo, int *ho);
otf.rkt+1−1
@@ -209,7 +209,7 @@ · 208 unmodified lines
209 {int16 xMax}209 {int16 xMax}
210 {int16 yMax}210 {int16 yMax}
211 #:extra211 #:extra
212 (list (cons 'field (list (~a "ComponentGlyph *component;") (~a "SimpleGlyph *simple;")))212 (list (cons 'field (list (~a "ComponentGlyph *component;") (~a "SimpleGlyph *simple;") (~a "u16int unitsPerEm;")))
213 (cons 'read213 (cons 'read
214 (list (~a "if(v->numberOfContours < 0 && read_ComponentGlyph(o, &v->component, 0) < 0)")214 (list (~a "if(v->numberOfContours < 0 && read_ComponentGlyph(o, &v->component, 0) < 0)")
215 (~a " goto err;")215 (~a " goto err;")
plan9/otf.c+6−0
@@ -553,6 +553,10 @@ otfglyf(Otf *o, int index) · 552 unmodified lines
553 werrstr("no memory");553 werrstr("no memory");
554 goto err;554 goto err;
555 }555 }
556 if(o->td.head == nil){
557 werrstr("no head table");
558 goto err;
559 }
556 if(o->td.loca == nil){560 if(o->td.loca == nil){
557 werrstr("no loca table");561 werrstr("no loca table");
558 goto err;562 goto err;
@@ -591,6 +595,8 @@ otfglyf(Otf *o, int index) · 32 unmodified lines
591 if(read_Glyf(o, g) < 0){595 if(read_Glyf(o, g) < 0){
592 free(g);596 free(g);
593 g = nil;597 g = nil;
598 }else{
599 g->unitsPerEm = o->td.head->unitsPerEm;
594 }600 }
595 otfpoprange(o);601 otfpoprange(o);
596 otfpoprange(o);602 otfpoprange(o);
plan9/otf.h+2−1
@@ -80,7 +80,7 @@ void otfclose(Otf *o); · 79 unmodified lines
80typedef struct Glyf Glyf;80typedef struct Glyf Glyf;
81Glyf *otfglyf(Otf *o, int index);81Glyf *otfglyf(Otf *o, int index);
82int otfglyfnum(Otf *o);82int otfglyfnum(Otf *o);
83u8int *otfdrawglyf(Glyf *g, int h, int *wo);83u8int *otfdrawglyf(Glyf *g, int ppem, int *wo, int *ho);
84 84
85typedef struct SubHeader SubHeader;85typedef struct SubHeader SubHeader;
86typedef struct MapGroup MapGroup;86typedef struct MapGroup MapGroup;
@@ -451,6 +451,7 @@ struct Glyf { · 364 unmodified lines
451 s16int yMax;451 s16int yMax;
452 ComponentGlyph *component;452 ComponentGlyph *component;
453 SimpleGlyph *simple;453 SimpleGlyph *simple;
454 u16int unitsPerEm;
454};455};
455 456
456int read_Glyf(Otf *o, Glyf *v);457int read_Glyf(Otf *o, Glyf *v);
plan9/test.c+34−32
@@ -6,38 +6,43 @@ · 5 unmodified lines
6typedef struct Image Image;6typedef struct Image Image;
7 7
8struct Image {8struct Image {
9 int h;
9 int w;10 int w;
10 u8int *b;11 u8int *b;
11};12};
12 13
13static void14static void
14fit(u8int *b, int bw, int bh, Image *im, int h, int *x, int *y, int gap)15fit(u8int *b, int bw, int bh, Image *im, int maxh, int *x, int *y, int gap)
15{16{
16 int d;17 int d;
17 18
18 if((bw-*x) < im->w+gap){19 if((bw-*x) < im->w+gap){
19 *y += h + gap;20 *y += maxh + gap;
20 *x = gap;21 *x = gap;
21 }22 }
22 if((bh-*y) < h+gap)23 if((bh-*y) < maxh+gap)
23 return;24 return;
24 for(d = 0; d < h; d++)25 for(d = 0; d < im->h; d++)
25 memcpy(b + (*y + d)*bw + *x, im->b + d*im->w, im->w);26 memcpy(b + (*y + d)*bw + *x, im->b + d*im->w, im->w);
26 *x += im->w + gap;27 *x += im->w + gap;
27}28}
28 29
29static void30static void
30dumpmap(Biobuf *out, Image *im, int n, int h)31dumpmap(Biobuf *out, Image *im, int n)
31{32{
32#define gap 233#define gap 1
33 int total, mid, npix, bw, bh, x, y, i;34 int total, mid, npix, bw, bh, x, y, i, maxh;
34 u8int *b;35 u8int *b;
35 36
36 total = 0;37 total = 0;
37 for(i = 0; i < n; i++)38 maxh = 0;
39 for(i = 0; i < n; i++){
40 if(maxh < im[i].h)
41 maxh = im[i].h;
38 total += im[i].w;42 total += im[i].w;
43 }
39 mid = total / n;44 mid = total / n;
40 npix = (mid+gap)*(h+gap)*n;45 npix = (mid+gap)*(maxh+gap)*n;
41 bh = sqrt(npix);46 bh = sqrt(npix);
42 bw = npix/bh;47 bw = npix/bh;
43 bh *= 1.5;48 bh *= 1.5;
@@ -48,9 +53,9 @@ dumpmap(Biobuf *out, Image *im, int n, int h) · 4 unmodified lines
48 memset(b, 0xff, npix);53 memset(b, 0xff, npix);
49 x = y = gap;54 x = y = gap;
50 for(i = 0; i < n; i++)55 for(i = 0; i < n; i++)
51 fit(b, bw, bh, im+i, h, &x, &y, gap);56 fit(b, bw, bh, im+i, maxh, &x, &y, gap);
52 Bprint(out, "%11s %11d %11d %11d %11d ", "k8", 0, 0, bw, y+h+gap);57 Bprint(out, "%11s %11d %11d %11d %11d ", "k8", 0, 0, bw, y+maxh+gap);
53 Bwrite(out, b, bw*(y+h+gap));58 Bwrite(out, b, bw*(y+maxh+gap));
54 free(b);59 free(b);
55}60}
56 61
@@ -69,23 +74,23 @@ otfread(void *aux, void *dst, int sz) · 12 unmodified lines
69static void74static void
70usage(void)75usage(void)
71{76{
72 fprint(2, "usage: %s [-g GLYPH_ID] [-G] [-i N] [-s PX] font.otf ...\n", argv0);77 fprint(2, "usage: %s [-g GLYPH_ID] [-G] [-i N] [-p PPM] font.otf ...\n", argv0);
73 fprint(2, " -g: specifies a single glyph id\n");78 fprint(2, " -g: specifies a single glyph id\n");
74 fprint(2, " -G: print out glyph ids, only ones that can be drawn atm (no compound yet)\n");79 fprint(2, " -G: print out glyph ids, only ones that can be drawn atm (no compound yet)\n");
75 fprint(2, " -s: draw (of size PX) and write the image to stdout\n");80 fprint(2, " -p: draw (of size in pixels per em) and write the image to stdout\n");
76 exits("usage");81 exits("usage");
77}82}
78 83
79void84void
80main(int argc, char **argv)85main(int argc, char **argv)
81{86{
82 int i, gi, G, h;87 int i, gi, G, ppem;
83 Otfile in, out;88 Otfile in, out;
84 Otf *o;89 Otf *o;
85 90
86 gi = -1;91 gi = -1;
87 G = 0;92 G = 0;
88 h = 0;93 ppem = 0;
89 ARGBEGIN{94 ARGBEGIN{
90 case 'g':95 case 'g':
91 gi = strtol(EARGF(usage()), nil, 0);96 gi = strtol(EARGF(usage()), nil, 0);
@@ -93,8 +98,8 @@ main(int argc, char **argv) · 1 unmodified line
93 case 'G':98 case 'G':
94 G++;99 G++;
95 break;100 break;
96 case 's':101 case 'p':
97 h = strtol(EARGF(usage()), nil, 0);102 ppem = strtol(EARGF(usage()), nil, 0);
98 break;103 break;
99 default:104 default:
100 usage();105 usage();
@@ -110,30 +115,27 @@ main(int argc, char **argv) · 9 unmodified lines
110 fprint(2, "%r\n");115 fprint(2, "%r\n");
111 continue;116 continue;
112 }117 }
113 if(h <= 0)118 if(ppem <= 0)
114 Bprint(out.aux, "%s\n", argv[i]);119 Bprint(out.aux, "%s\n", argv[i]);
115 if(G && gi < 0){120 if(G && gi < 0){
116 int i, n = otfglyfnum(o);121 int i, n = otfglyfnum(o);
117 Image *im = h > 0 ? calloc(n, sizeof(*im)) : nil;122 Image *im = ppem > 0 ? calloc(n, sizeof(*im)) : nil;
118 for(i = 0; i < n; i++){123 for(i = 0; i < n; i++){
119 Glyf *g = otfglyf(o, i);124 Glyf *g = otfglyf(o, i);
120 if(g == nil)125 if(g == nil)
121 sysfatal("%r");126 sysfatal("%r");
122 if(h > 0 && g->simple != nil && g->numberOfContours > 0){127 if(ppem > 0 && g->simple != nil && g->numberOfContours > 0){
123 int w;128 im[i].b = otfdrawglyf(g, ppem, &im[i].w, &im[i].h);
124 u8int *b = otfdrawglyf(g, h, &w);129 if(im[i].b == nil)
125 if(b == nil)
126 sysfatal("%r");130 sysfatal("%r");
127 im[i].w = w;131 }else if(ppem <= 0){
128 im[i].b = b;
129 }else if(h <= 0){
130 Bprint(out.aux, "%d (%s):\n", i, g->simple ? "simple" : "component");132 Bprint(out.aux, "%d (%s):\n", i, g->simple ? "simple" : "component");
131 print_Glyf(&out, indentΔ, o, g);133 print_Glyf(&out, indentΔ, o, g);
132 }134 }
133 free(g);135 free(g);
134 }136 }
135 if(h > 0){137 if(ppem > 0){
136 dumpmap(out.aux, im, n, h);138 dumpmap(out.aux, im, n);
137 for(i = 0; i < n; i++)139 for(i = 0; i < n; i++)
138 free(im[i].b);140 free(im[i].b);
139 free(im);141 free(im);
@@ -149,12 +151,12 @@ main(int argc, char **argv) · 9 unmodified lines
149 Glyf *g = otfglyf(o, gi);151 Glyf *g = otfglyf(o, gi);
150 if(g == nil){152 if(g == nil){
151 fprint(2, "%d: %r\n", gi);153 fprint(2, "%d: %r\n", gi);
152 }else if(h > 0){154 }else if(ppem > 0){
153 if(g->component != nil)155 if(g->component != nil)
154 fprint(2, "%d: component\n", gi);156 fprint(2, "%d: component\n", gi);
155 else{157 else{
156 int w;158 int w, h;
157 u8int *b = otfdrawglyf(g, h, &w);159 u8int *b = otfdrawglyf(g, ppem, &w, &h);
158 if(b == nil)160 if(b == nil)
159 sysfatal("%r");161 sysfatal("%r");
160 fprint(1, "%11s %11d %11d %11d %11d ", "k8", 0, 0, w, h);162 fprint(1, "%11s %11d %11d %11d %11d ", "k8", 0, 0, w, h);
rast.c+18−14
@@ -57,6 +57,8 @@ struct SegQ { · 56 unmodified lines
57 */57 */
58#define QBZR_PIX_SCALE 4.058#define QBZR_PIX_SCALE 4.0
59 59
60#define GAP 0
61
60#define ε 1.0e-1062#define ε 1.0e-10
61 63
62static int64static int
@@ -450,21 +452,17 @@ qbzr(SegQ *seg, int ns, int dw, int dh, Sval *p) · 387 unmodified lines
450}452}
451 453
452u8int *454u8int *
453otfdrawglyf(Glyf *g, int h, int *wo)455otfdrawglyf(Glyf *g, int ppem, int *wo, int *ho)
454{456{
455 int w, i, r, k, npts, npx, ns;457 int w, h, i, r, k, npts, npx, ns;
456 Point *p₀, *p, *prev;458 Point *p₀, *p, *prev;
457 Spt *pts₀, *pts, *e;459 Spt *pts₀, *pts, *e;
458 double scale;
459 SegQ *s₀, *s;460 SegQ *s₀, *s;
460 Sval *fp;461 Sval *fp;
461 u8int *b;462 u8int *b;
462 463
463 /* FIXME those epsilons and ceil is a rather dumb hack for now */464#define scale (double)ppem/g->unitsPerEm
464 scale = (double)h / (g->yMax - g->yMin) + ε;
465 w = *wo = ceil((g->xMax - g->xMin) * scale + ε);
466 465
467 npx = w * h;
468 ns = 0;466 ns = 0;
469 s₀ = nil;467 s₀ = nil;
470 468
@@ -507,16 +505,19 @@ otfdrawglyf(Glyf *g, int h, int *wo) · 36 unmodified lines
507 s = s₀ + ns;505 s = s₀ + ns;
508 pts = e;506 pts = e;
509 for(e = pts₀; e <= pts-3; e += 2, s++, ns++){507 for(e = pts₀; e <= pts-3; e += 2, s++, ns++){
510 s->v0[0] = (e[0].x - g->xMin) * scale;508 s->v0[0] = (e[0].x - g->xMin) * scale + GAP;
511 s->v0[1] = (e[0].y - g->yMin) * scale;509 s->v0[1] = (e[0].y - g->yMin) * scale + GAP;
512 s->v1[0] = (e[1].x - g->xMin) * scale;510 s->v1[0] = (e[1].x - g->xMin) * scale + GAP;
513 s->v1[1] = (e[1].y - g->yMin) * scale;511 s->v1[1] = (e[1].y - g->yMin) * scale + GAP;
514 s->v2[0] = (e[2].x - g->xMin) * scale;512 s->v2[0] = (e[2].x - g->xMin) * scale + GAP;
515 s->v2[1] = (e[2].y - g->yMin) * scale;513 s->v2[1] = (e[2].y - g->yMin) * scale + GAP;
516 }514 }
517 free(pts₀);515 free(pts₀);
518 }516 }
519 517
518 w = ceil((g->xMax - g->xMin)*scale + 2*GAP);
519 h = ceil((g->yMax - g->yMin)*scale + 2*GAP);
520 npx = w*h;
520 fp = calloc(1, npx*sizeof(*fp));521 fp = calloc(1, npx*sizeof(*fp));
521 r = qbzr(s₀, ns, w, h, fp);522 r = qbzr(s₀, ns, w, h, fp);
522 free(s₀);523 free(s₀);
@@ -526,8 +527,11 @@ otfdrawglyf(Glyf *g, int h, int *wo) · 3 unmodified lines
526 b = (u8int*)fp;527 b = (u8int*)fp;
527 for(i = 0; i < npx; i++)528 for(i = 0; i < npx; i++)
528 b[i] = 255 - (fp[i] <= 0 ? 0 : (fp[i] >= QBZR_PIX_SCALE ? 255 : fp[i]/QBZR_PIX_SCALE*255));529 b[i] = 255 - (fp[i] <= 0 ? 0 : (fp[i] >= QBZR_PIX_SCALE ? 255 : fp[i]/QBZR_PIX_SCALE*255));
529 if((b = realloc(b, npx)) != nil)530 if((b = realloc(b, npx)) != nil){
531 *wo = w;
532 *ho = h;
530 fp = nil;533 fp = nil;
534 }
531 }535 }
532 free(fp);536 free(fp);
533 return b;537 return b;
unix/test.c+37−35
@@ -9,37 +9,42 @@ typedef struct Image Image; · 8 unmodified lines
9 9
10struct Image {10struct Image {
11 int w;11 int w;
12 int h;
12 u8int *b;13 u8int *b;
13};14};
14 15
15static void16static void
16fit(u8int *b, int bw, int bh, Image *im, int h, int *x, int *y, int gap)17fit(u8int *b, int bw, int bh, Image *im, int maxh, int *x, int *y, int gap)
17{18{
18 int d;19 int d;
19 20
20 if((bw-*x) < im->w+gap){21 if((bw-*x) < im->w+gap){
21 *y += h + gap;22 *y += maxh + gap;
22 *x = gap;23 *x = gap;
23 }24 }
24 if((bh-*y) < h+gap)25 if((bh-*y) < maxh+gap)
25 return;26 return;
26 for(d = 0; d < h; d++)27 for(d = 0; d < im->h; d++)
27 memcpy(b + (*y + d)*bw + *x, im->b + d*im->w, im->w);28 memcpy(b + (*y + d)*bw + *x, im->b + d*im->w, im->w);
28 *x += im->w + gap;29 *x += im->w + gap;
29}30}
30 31
31static void32static void
32dumpmap(FILE *out, Image *im, int n, int h)33dumpmap(FILE *out, Image *im, int n)
33{34{
34#define gap 235#define gap 1
35 int total, mid, npix, bw, bh, x, y, i;36 int total, mid, npix, bw, bh, x, y, i, maxh;
36 u8int *b;37 u8int *b;
37 38
38 total = 0;39 total = 0;
39 for(i = 0; i < n; i++)40 maxh = 0;
41 for(i = 0; i < n; i++){
42 if(maxh < im[i].h)
43 maxh = im[i].h;
40 total += im[i].w;44 total += im[i].w;
45 }
41 mid = total / n;46 mid = total / n;
42 npix = (mid+gap)*(h+gap)*n;47 npix = (mid+gap)*(maxh+gap)*n;
43 bh = sqrt(npix);48 bh = sqrt(npix);
44 bw = npix/bh;49 bw = npix/bh;
45 bh *= 1.5;50 bh *= 1.5;
@@ -51,9 +56,9 @@ dumpmap(FILE *out, Image *im, int n, int h) · 5 unmodified lines
51 memset(b, 0xff, npix);56 memset(b, 0xff, npix);
52 x = y = gap;57 x = y = gap;
53 for(i = 0; i < n; i++)58 for(i = 0; i < n; i++)
54 fit(b, bw, bh, im+i, h, &x, &y, gap);59 fit(b, bw, bh, im+i, maxh, &x, &y, gap);
55 fprintf(out, "%11s %11d %11d %11d %11d ", "k8", 0, 0, bw, y+h+gap);60 fprintf(out, "%11s %11d %11d %11d %11d ", "k8", 0, 0, bw, y+maxh+gap);
56 fwrite(b, 1, bw*(y+h+gap), out);61 fwrite(b, 1, bw*(y+maxh+gap), out);
57 free(b);62 free(b);
58}63}
59 64
@@ -99,20 +104,20 @@ usage(void) · 39 unmodified lines
99 fprintf(stderr, "usage: %s [-g GLYPH_ID] [-G] [-i N] [-s PX] font.otf ...\n", argv0);104 fprintf(stderr, "usage: %s [-g GLYPH_ID] [-G] [-i N] [-s PX] font.otf ...\n", argv0);
100 fprintf(stderr, " -g: specifies a single glyph id\n");105 fprintf(stderr, " -g: specifies a single glyph id\n");
101 fprintf(stderr, " -G: print out glyph ids, only ones that can be drawn atm (no compound yet)\n");106 fprintf(stderr, " -G: print out glyph ids, only ones that can be drawn atm (no compound yet)\n");
102 fprintf(stderr, " -s: draw (of size PX) and write the image to stdout\n");107 fprintf(stderr, " -p: draw (of size in pixels per em) and write the image to stdout\n");
103 exit(1);108 exit(1);
104}109}
105 110
106int111int
107main(int argc, char **argv)112main(int argc, char **argv)
108{113{
109 int i, gi, G, h;114 int i, gi, G, ppem;
110 Otfile in, out;115 Otfile in, out;
111 Otf *o;116 Otf *o;
112 117
113 gi = -1;118 gi = -1;
114 G = 0;119 G = 0;
115 h = 0;120 ppem = 0;
116 ARGBEGIN{121 ARGBEGIN{
117 case 'g':122 case 'g':
118 gi = strtol(EARGF(usage()), NULL, 0);123 gi = strtol(EARGF(usage()), NULL, 0);
@@ -120,8 +125,8 @@ main(int argc, char **argv) · 1 unmodified line
120 case 'G':125 case 'G':
121 G++;126 G++;
122 break;127 break;
123 case 's':128 case 'p':
124 h = strtol(EARGF(usage()), NULL, 0);129 ppem = strtol(EARGF(usage()), NULL, 0);
125 break;130 break;
126 default:131 default:
127 usage();132 usage();
@@ -137,30 +142,27 @@ main(int argc, char **argv) · 9 unmodified lines
137 err(1, "%s", argv[i]);142 err(1, "%s", argv[i]);
138 if((o = otfopen(&in)) == NULL)143 if((o = otfopen(&in)) == NULL)
139 errx(1, "%s: %s", argv[i], otferrstr());144 errx(1, "%s: %s", argv[i], otferrstr());
140 if(h <= 0)145 if(ppem <= 0)
141 fprintf(out.aux, "%s\n", argv[i]);146 fprintf(out.aux, "%s\n", argv[i]);
142 if(G && gi < 0){147 if(G && gi < 0){
143 int i, n = otfglyfnum(o);148 int i, n = otfglyfnum(o);
144 Image *im = h > 0 ? calloc(n, sizeof(*im)) : NULL;149 Image *im = ppem > 0 ? calloc(n, sizeof(*im)) : NULL;
145 for(i = 0; i < n; i++){150 for(i = 0; i < n; i++){
146 Glyf *g = otfglyf(o, i);151 Glyf *g = otfglyf(o, i);
147 if(g == NULL)152 if(g == NULL)
148 errx(1, "glyph %d: %s", i, otferrstr());153 errx(1, "glyph %d: %s", i, otferrstr());
149 if(h > 0 && g->simple != NULL && g->numberOfContours > 0){154 if(ppem > 0 && g->simple != NULL && g->numberOfContours > 0){
150 int w;155 im[i].b = otfdrawglyf(g, ppem, &im[i].w, &im[i].h);
151 u8int *b = otfdrawglyf(g, h, &w);156 if(im[i].b == NULL)
152 if(b == NULL)
153 errx(1, "glyph %d: %s", i, otferrstr());157 errx(1, "glyph %d: %s", i, otferrstr());
154 im[i].w = w;158 }else if(ppem <= 0){
155 im[i].b = b;
156 }else if(h <= 0){
157 fprintf(out.aux, "%d (%s):\n", i, g->simple ? "simple" : "component");159 fprintf(out.aux, "%d (%s):\n", i, g->simple ? "simple" : "component");
158 print_Glyf(&out, indentΔ, o, g);160 print_Glyf(&out, indentΔ, o, g);
159 }161 }
160 free(g);162 free(g);
161 }163 }
162 if(h > 0){164 if(ppem > 0){
163 dumpmap(out.aux, im, n, h);165 dumpmap(out.aux, im, n);
164 for(i = 0; i < n; i++)166 for(i = 0; i < n; i++)
165 free(im[i].b);167 free(im[i].b);
166 free(im);168 free(im);
@@ -174,17 +176,17 @@ main(int argc, char **argv) · 7 unmodified lines
174 Glyf *g = otfglyf(o, gi);176 Glyf *g = otfglyf(o, gi);
175 if(g == NULL){177 if(g == NULL){
176 errx(1, "glyph %d: %s", gi, otferrstr());178 errx(1, "glyph %d: %s", gi, otferrstr());
177 }else if(h > 0){179 }else if(ppem > 0){
178 if(g->component != NULL)180 if(g->component != NULL)
179 errx(1, "glyph %d: component", gi);181 errx(1, "glyph %d: component", gi);
180 else{182 else{
181 int w;183 Image im;
182 u8int *b = otfdrawglyf(g, h, &w);184 im.b = otfdrawglyf(g, ppem, &im.w, &im.h);
183 if(b == NULL)185 if(im.b == NULL)
184 errx(1, "glyph %d: %s", gi, otferrstr());186 errx(1, "glyph %d: %s", gi, otferrstr());
185 fprintf(out.aux, "%11s %11d %11d %11d %11d ", "k8", 0, 0, w, h);187 fprintf(out.aux, "%11s %11d %11d %11d %11d ", "k8", 0, 0, im.w, im.h);
186 fwrite(b, 1, w*h, out.aux);188 fwrite(im.b, 1, im.w*im.h, out.aux);
187 free(b);189 free(im.b);
188 }190 }
189 }else{191 }else{
190 fprintf(out.aux, "\n%d:\n", gi);192 fprintf(out.aux, "\n%d:\n", gi);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t