History

bitmap fonts: error on uninmplemented bit depths

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit 19827001 parent 2296ee33 files · +16 −5Browse files

Unified · Split

3 files
  1. otf.c.in +5 −0
  2. plan9/otf.c +5 −0
  3. rast.c +6 −5
otf.c.in+5−0
@@ -681,6 +681,10 @@ bitglyf(Otf *o, Glyf *g, RasterOpts *opts) · 680 unmodified lines
681681 break;
682682
683683 b.bitDepth = bs->bitDepth;
684+ if(b.bitDepth != 1 && b.bitDepth != 8){
685+ werrstr("unsupported bit depth: %d", b.bitDepth);
686+ goto err;
687+ }
684688 b.ppemX = bs->ppemX;
685689 b.ppemY = bs->ppemY;
686690 isr = bs->indexSubtableList;
@@ -765,6 +769,7 @@ done: · 78 unmodified lines
765769 return bitebdt(o, g, &best);
766770
767771 werrstr("no bitmap");
772+err:
768773 free(g);
769774 return nil;
770775 }
plan9/otf.c+5−0
@@ -682,6 +682,10 @@ bitglyf(Otf *o, Glyf *g, RasterOpts *opts) · 681 unmodified lines
682682 break;
683683
684684 b.bitDepth = bs->bitDepth;
685+ if(b.bitDepth != 1 && b.bitDepth != 8){
686+ werrstr("unsupported bit depth: %d", b.bitDepth);
687+ goto err;
688+ }
685689 b.ppemX = bs->ppemX;
686690 b.ppemY = bs->ppemY;
687691 isr = bs->indexSubtableList;
@@ -766,6 +770,7 @@ done: · 78 unmodified lines
766770 return bitebdt(o, g, &best);
767771
768772 werrstr("no bitmap");
773+err:
769774 free(g);
770775 return nil;
771776 }
rast.c+6−5
@@ -774,18 +774,19 @@ bitpixel(BitmapGlyph *bg, int x, int y) · 773 unmodified lines
774774 {
775775 int i;
776776
777− if(bg->bitDepth == 1){
777+ switch(bg->bitDepth){
778+ case 1:
778779 i = y*bg->pitchBits + x;
779780 if(bg->format == 2 || bg->format == 5)
780781 x = i - (i & ~7);
781782 else
782783 x &= 7;
783784 return (bg->image[i>>3] & (0x80>>x)) ? 255 : 0;
784− }else if(bg->bitDepth == 4){
785+ case 2:
786+ case 4:
785787 /* FIXME */
786− assert(nil);
787− return 0;
788− }else if(bg->bitDepth == 8){
788+ break;
789+ case 8:
789790 return bg->image[y*bg->pitchBits/8 + x];
790791 }
791792 return 0;

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