| @@ -19,7 +19,7 @@ static double ppem; · 18 unmodified lines |
| 19 | static Rune rune = NoRune; | 19 | static Rune rune = NoRune; |
| 20 | | 20 | |
| 21 | static int | 21 | static int |
| 22 | dumpmap(Otfile *f, GlyfImage *im, int n) | 22 | dumpmap(Otfile *f, GlyfImage **im, int n) |
| 23 | { | 23 | { |
| 24 | int x, y, i, j, t, maxh, prebase, postbase, d, border; | 24 | int x, y, i, j, t, maxh, prebase, postbase, d, border; |
| 25 | int gap, total, mid, npix, bw, bh, lines, fill; | 25 | int gap, total, mid, npix, bw, bh, lines, fill; |
| @@ -31,20 +31,20 @@ dumpmap(Otfile *f, GlyfImage *im, int n) · 5 unmodified lines |
| 31 | fill = map > 2; | 31 | fill = map > 2; |
| 32 | if(n == 1){ | 32 | if(n == 1){ |
| 33 | gap = 8; | 33 | gap = 8; |
| 34 | maxh = im->h; | 34 | maxh = im[0]->h; |
| 35 | if(im->baseline) | 35 | if(im[0]->baseline) |
| 36 | maxh += im->baseline; | 36 | maxh += im[0]->baseline; |
| 37 | bw = 2*gap + im->w; | 37 | bw = 2*gap + im[0]->w; |
| 38 | bh = 2*gap + maxh; | 38 | bh = 2*gap + maxh; |
| 39 | npix = bw * bh; | 39 | npix = bw * bh; |
| 40 | }else{ | 40 | }else{ |
| 41 | gap = 1; | 41 | gap = 1; |
| 42 | for(i = 0; i < n; i++){ | 42 | for(i = 0; i < n; i++){ |
| 43 | if(im[i].b == nil) | 43 | if(im[i] == nil) |
| 44 | continue; | 44 | continue; |
| 45 | if(maxh < im[i].h) | 45 | if(maxh < im[i]->h) |
| 46 | maxh = im[i].h; | 46 | maxh = im[i]->h; |
| 47 | total += im[i].w; | 47 | total += im[i]->w; |
| 48 | } | 48 | } |
| 49 | mid = total / n; | 49 | mid = total / n; |
| 50 | npix = (mid+gap)*(maxh+gap)*n; | 50 | npix = (mid+gap)*(maxh+gap)*n; |
| @@ -61,31 +61,29 @@ dumpmap(Otfile *f, GlyfImage *im, int n) · 10 unmodified lines |
| 61 | for(i = 0; i < n;){ | 61 | for(i = 0; i < n;){ |
| 62 | prebase = postbase = 0; | 62 | prebase = postbase = 0; |
| 63 | for(x = 0, j = i; j < n; j++){ | 63 | for(x = 0, j = i; j < n; j++){ |
| 64 | if(im[j].b == nil) | 64 | if(im[j] == nil) |
| 65 | continue; | 65 | continue; |
| 66 | x += im[j].w + gap; | 66 | x += im[j]->w + gap; |
| 67 | if(x > bw) | 67 | if(x > bw) |
| 68 | break; | 68 | break; |
| 69 | if(prebase < im[j].h+im[j].baseline) | 69 | if(prebase < im[j]->h+im[j]->baseline) |
| 70 | prebase = im[j].h+im[j].baseline; | 70 | prebase = im[j]->h+im[j]->baseline; |
| 71 | if(im[j].baseline < 0 && postbase < -im[j].baseline) | 71 | if(im[j]->baseline < 0 && postbase < -im[j]->baseline) |
| 72 | postbase = -im[j].baseline; | 72 | postbase = -im[j]->baseline; |
| 73 | } | 73 | } |
| 74 | maxh = prebase + postbase; | 74 | maxh = prebase + postbase; |
| 75 | if(j == i || y+maxh > bh) | 75 | if(j == i || y+maxh > bh) |
| 76 | break; | 76 | break; |
| 77 | | 77 | |
| 78 | for(x = 0; i < j; i++){ | 78 | for(x = 0; i < j; i++){ |
| 79 | if(im[i].b == nil) | 79 | u8int *lt = b + ((y + prebase - (im[i]->h+im[i]->baseline))*bw + x)*3; |
| 80 | continue; | 80 | x += im[i]->w + gap; |
| 81 | u8int *lt = b + ((y + prebase - (im[i].h+im[i].baseline))*bw + x)*3; | 81 | for(d = 0; d < im[i]->h; d++, lt += bw*3){ |
| 82 | x += im[i].w + gap; | 82 | for(t = 0; t < im[i]->w; t++){ |
| 83 | for(d = 0; d < im[i].h; d++, lt += bw*3){ | | |
| 84 | for(t = 0; t < im[i].w; t++){ | | |
| 85 | u8int r, g, b; | 83 | u8int r, g, b; |
| 86 | r = g = b = im[i].b[d*im[i].w + t]; | 84 | r = g = b = im[i]->b[d*im[i]->w + t]; |
| 87 | border = d == 0 || t == 0 || t == im[i].w-1 || d == im[i].h-1; | 85 | border = d == 0 || t == 0 || t == im[i]->w-1 || d == im[i]->h-1; |
| 88 | if((lines || highlight == i) && g == 0xff && (d == im[i].h+im[i].baseline)){ | 86 | if((lines || highlight == i) && g == 0xff && (d == im[i]->h+im[i]->baseline)){ |
| 89 | g = 0; | 87 | g = 0; |
| 90 | b = 0; | 88 | b = 0; |
| 91 | }else if((lines || highlight == i) && g == 0xff && (fill || border)){ | 89 | }else if((lines || highlight == i) && g == 0xff && (fill || border)){ |
| @@ -117,7 +115,7 @@ dumpmap(Otfile *f, GlyfImage *im, int n) · 25 unmodified lines |
| 117 | static int | 115 | static int |
| 118 | process(Otfile *in, Otfile *out) | 116 | process(Otfile *in, Otfile *out) |
| 119 | { | 117 | { |
| 120 | GlyfImage *im; | 118 | GlyfImage **im; |
| 121 | int i, n; | 119 | int i, n; |
| 122 | Glyf *g; | 120 | Glyf *g; |
| 123 | Otf *o; | 121 | Otf *o; |
| @@ -150,7 +148,7 @@ glypherr: · 26 unmodified lines |
| 150 | return -1; | 148 | return -1; |
| 151 | } | 149 | } |
| 152 | if(ppem > 0 && g->numberOfContours != 0){ | 150 | if(ppem > 0 && g->numberOfContours != 0){ |
| 153 | if(otfdrawglyf(o, g, ppem, im+i) != 0) | 151 | if((im[i] = otfdrawglyf(o, g, ppem)) == nil) |
| 154 | goto glypherr; | 152 | goto glypherr; |
| 155 | }else if(ppem <= 0){ | 153 | }else if(ppem <= 0){ |
| 156 | out->print(out->aux, "%d (%s):\n", i, | 154 | out->print(out->aux, "%d (%s):\n", i, |
| @@ -163,7 +161,7 @@ glypherr: · 6 unmodified lines |
| 163 | if(out->write != otfdiscard && dumpmap(out, im, n) != 0) | 161 | if(out->write != otfdiscard && dumpmap(out, im, n) != 0) |
| 164 | return -1; | 162 | return -1; |
| 165 | for(i = 0; i < n; i++) | 163 | for(i = 0; i < n; i++) |
| 166 | free(im[i].b); | 164 | free(im[i]); |
| 167 | free(im); | 165 | free(im); |
| 168 | } | 166 | } |
| 169 | }else if(gind < 0){ | 167 | }else if(gind < 0){ |
| @@ -172,12 +170,12 @@ glypherr: · 2 unmodified lines |
| 172 | if((g = otfglyf(o, gind)) == nil){ | 170 | if((g = otfglyf(o, gind)) == nil){ |
| 173 | goto glypherr; | 171 | goto glypherr; |
| 174 | }else if(ppem > 0){ | 172 | }else if(ppem > 0){ |
| 175 | GlyfImage im; | 173 | GlyfImage *im; |
| 176 | if(otfdrawglyf(o, g, ppem, &im) != 0) | 174 | if((im = otfdrawglyf(o, g, ppem)) == nil) |
| 177 | goto glypherr; | 175 | goto glypherr; |
| 178 | if(out->write != otfdiscard && dumpmap(out, &im, 1) != 0) | 176 | if(out->write != otfdiscard && dumpmap(out, &im, 1) != 0) |
| 179 | return -1; | 177 | return -1; |
| 180 | free(im.b); | 178 | free(im); |
| 181 | }else{ | 179 | }else{ |
| 182 | out->print(out->aux, "\n%d:\n", gind); | 180 | out->print(out->aux, "\n%d:\n", gind); |
| 183 | print_Glyf(out, indentΔ, o, g); | 181 | print_Glyf(out, indentΔ, o, g); |