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