Unified · Split
| @@ -681,6 +681,10 @@ bitglyf(Otf *o, Glyf *g, RasterOpts *opts) · 680 unmodified lines | ||
| 681 | 681 | break; |
| 682 | 682 | |
| 683 | 683 | b.bitDepth = bs->bitDepth; |
| 684 | + if(b.bitDepth != 1 && b.bitDepth != 8){ | |
| 685 | + werrstr("unsupported bit depth: %d", b.bitDepth); | |
| 686 | + goto err; | |
| 687 | + } | |
| 684 | 688 | b.ppemX = bs->ppemX; |
| 685 | 689 | b.ppemY = bs->ppemY; |
| 686 | 690 | isr = bs->indexSubtableList; |
| @@ -765,6 +769,7 @@ done: · 78 unmodified lines | ||
| 765 | 769 | return bitebdt(o, g, &best); |
| 766 | 770 | |
| 767 | 771 | werrstr("no bitmap"); |
| 772 | +err: | |
| 768 | 773 | free(g); |
| 769 | 774 | return nil; |
| 770 | 775 | } |
| @@ -682,6 +682,10 @@ bitglyf(Otf *o, Glyf *g, RasterOpts *opts) · 681 unmodified lines | ||
| 682 | 682 | break; |
| 683 | 683 | |
| 684 | 684 | b.bitDepth = bs->bitDepth; |
| 685 | + if(b.bitDepth != 1 && b.bitDepth != 8){ | |
| 686 | + werrstr("unsupported bit depth: %d", b.bitDepth); | |
| 687 | + goto err; | |
| 688 | + } | |
| 685 | 689 | b.ppemX = bs->ppemX; |
| 686 | 690 | b.ppemY = bs->ppemY; |
| 687 | 691 | isr = bs->indexSubtableList; |
| @@ -766,6 +770,7 @@ done: · 78 unmodified lines | ||
| 766 | 770 | return bitebdt(o, g, &best); |
| 767 | 771 | |
| 768 | 772 | werrstr("no bitmap"); |
| 773 | +err: | |
| 769 | 774 | free(g); |
| 770 | 775 | return nil; |
| 771 | 776 | } |
| @@ -774,18 +774,19 @@ bitpixel(BitmapGlyph *bg, int x, int y) · 773 unmodified lines | ||
| 774 | 774 | { |
| 775 | 775 | int i; |
| 776 | 776 | |
| 777 | − if(bg->bitDepth == 1){ | |
| 777 | + switch(bg->bitDepth){ | |
| 778 | + case 1: | |
| 778 | 779 | i = y*bg->pitchBits + x; |
| 779 | 780 | if(bg->format == 2 || bg->format == 5) |
| 780 | 781 | x = i - (i & ~7); |
| 781 | 782 | else |
| 782 | 783 | x &= 7; |
| 783 | 784 | return (bg->image[i>>3] & (0x80>>x)) ? 255 : 0; |
| 784 | − }else if(bg->bitDepth == 4){ | |
| 785 | + case 2: | |
| 786 | + case 4: | |
| 785 | 787 | /* FIXME */ |
| 786 | − assert(nil); | |
| 787 | − return 0; | |
| 788 | − }else if(bg->bitDepth == 8){ | |
| 788 | + break; | |
| 789 | + case 8: | |
| 789 | 790 | return bg->image[y*bg->pitchBits/8 + x]; |
| 790 | 791 | } |
| 791 | 792 | return 0; |