⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 font.c

📁 zgv-5.6,一个Linux系统下的图片浏览器(VGA/SVGA)
💻 C
📖 第 1 页 / 共 2 页
字号:
      case '7':        vga_drawline(a,b,a+s2,b); vga_drawline(a+s2,b,a+s1,b+s4); break;      case '9':        vga_drawline(a+s2,b,a+s2,b+s4);        /* FALLS THROUGH and does top circle of 8 to complete the 9 */      case '8':        fontcircle(a+s1,b+s1,siz); break;            /* 2d: some punctuation (not much!) */            case '-':        vga_drawline(a,b+s2,a+s1,b+s2); break;      case '.':        vga_drawpixel(a,b+s4); a+=-s1+1; break;      case '(':        fontc_ul(a+s1,b+s1,siz); fontc_ll(a+s1,b+s3,siz);        vga_drawline(a,b+s1,a,b+s3); break;      case ')':        fontc_ur(a,b+s1,siz); fontc_lr(a,b+s3,siz);        vga_drawline(a+s1,b+s1,a+s1,b+s3); break;      case '%':        vga_drawpixel(a,b);        vga_drawpixel(a+s2,b+s4);        /* FALLS THROUGH drawing the slash to finish the % */      case '/':        vga_drawline(a,b+s4,a+s2,b); break;      case '?':        fontc_u(a+s1,b+s1,siz);        vga_drawline(a+s2,b+s1,a+s1,b+s2);        vga_drawline(a+s1,b+s2,a+s1,b+s3);        vga_drawpixel(a+s1,b+s4);        break;      }      /*** 3rd part: finally, move along for the next letter ***/  /* we do this even if go_through_the_motions is set */  if(strchr("ltfijk-. ()",c)!=NULL)    a+=s1;  else    {    if(strchr("?/%abcdeghnopqrsuvxyz"              "ABCDEFGHIJKLNOPQRSTUVXYZ0123456789",c)!=NULL)      a+=s2;    else      {      if(strchr("mwMW",c)!=NULL)        a+=s4;      else        {        if(c==9)          {          /* congratulations madam, it's a tab */          a=((a/TABSIZE)+1)*TABSIZE;          }        else          {          /* oh, don't know this one. do an underscore */          /* (we don't if go_through_the_motions is set) */          if(!go_through_the_motions)            vga_drawline(a,b+s4,a+s2,b+s4);          a+=s2;          }        }      }    }  a+=gap;   /* and add a gap */  }return(a-x);}/* never mind. Character building, wasn't it? (groan) */void fontcircle(int x,int y,int r){fontc_u(x,y,r);fontc_l(x,y,r);}void fontc_l(int x,int y,int r){fontc_ll(x,y,r);fontc_lr(x,y,r);}void fontc_u(int x,int y,int r){fontc_ul(x,y,r);fontc_ur(x,y,r);}void fontc_r(int x,int y,int r){fontc_ur(x,y,r);fontc_lr(x,y,r);}void fontc_left(int x,int y,int r){fontc_ul(x,y,r);fontc_ll(x,y,r);}void fontc_ul(int x,int y,int r){int r34;if(go_through_the_motions) return;r34=((r*3)>>2);vga_drawline(x-r,y,x-r34,y-r34);vga_drawline(x-r34,y-r34,x,y-r);}void fontc_ur(int x,int y,int r){int r34;if(go_through_the_motions) return;r34=((r*3)>>2);vga_drawline(x+r,y,x+r34,y-r34);vga_drawline(x+r34,y-r34,x,y-r);}void fontc_ll(int x,int y,int r){int r34;if(go_through_the_motions) return;r34=((r*3)>>2);vga_drawline(x-r,y,x-r34,y+r34);vga_drawline(x-r34,y+r34,x,y+r);}void fontc_lr(int x,int y,int r){int r34;if(go_through_the_motions) return;r34=((r*3)>>2);vga_drawline(x+r,y,x+r34,y+r34);vga_drawline(x+r34,y+r34,x,y+r);}/* lose 360x480 junk */#undef vga_drawline#undef vga_drawpixel/* this gets how wide text will be */int vgatextsize(int sizearg,char *str){int r;go_through_the_motions=1;r=vgadrawtext(0,0,sizearg,str);go_through_the_motions=0;return(r);}void set_max_text_width(int width){stop_after_this_x=width;}static int vgadrawtext_bmp(int xpos,int ypos,int siz,char *str){static unsigned char scanbit[128];static int old_colour=-1;struct fontinfo_tag *fontinfo_ptr;int f,c,x,y;int initxpos=xpos;signed char *ptr,*fontdat;int ox,oy,w,h,dw;int yst;int xrunst=-1;int *fonttbl;int fontyofs,fontfh,fontoy;int widthadd=0;int m_ellipsis_size;int dont_use_lines=0;	/* needed for use from rbmenu.c */int origxpos=xpos;	/* this and above needed for 360x480 mode */if(vga_getcolors()>256 || squish_x)  dont_use_lines=1;if(current_colour!=old_colour && !dont_use_lines)  memset(scanbit,old_colour=current_colour,sizeof(scanbit));/* pick font to match siz. */switch(siz)  {  /* special case, small italic font for "version X.Y" text */  case 0: fontinfo_ptr=&font0; break;      case 5: fontinfo_ptr=&font3; break;  case 4: widthadd=1;    /* falls through */  case 3:    fontinfo_ptr=&font2;    if(cfg.thicktext) fontinfo_ptr=&font2b;    break;    case USE_BOLD_FONT:    fontinfo_ptr=&font2b;    break;    /* this doesn't appear normally, but will if someone hacks   * on zgv blindly. It gently gives them a clue. :-)   */  default:    fprintf(stderr,"unsupported text size - treating siz as 2\n");    /* falls through */    case 2: fontinfo_ptr=&font1; break;  }fontdat=fontinfo_ptr->data;fonttbl=fontinfo_ptr->table;fontyofs=fontinfo_ptr->yofs;fontfh=fontinfo_ptr->fh;fontoy=fontinfo_ptr->oy;/* m_ellipsis_size is the size that an ellipsis will take up, plus the * widest possible letter (which we assume is M). */m_ellipsis_size=2*(widthadd+fontdat[fonttbl['.'-32]+4])+		   widthadd+fontdat[fonttbl['m'-32]+4];for(f=0;f<strlen(str);f++)  {  if(xpos-initxpos>stop_after_this_x-m_ellipsis_size)    {    int tmp;        /* print an ellipsis... well, three^H^H^H^H^Htwo dots :-) */    /* blast the width restriction to stop possible infinite recursion */    tmp=stop_after_this_x;    set_max_text_width(NO_CLIP_FONT);    xpos+=vgadrawtext_bmp(xpos,ypos,siz,"..");    stop_after_this_x=tmp;    /* now give up */    break;    }  c=str[f];  if(c=='\t')    {    xpos=((xpos/TABSIZE)+1)*TABSIZE;    continue;    }  if(c<32 || c>126) c='_';  ptr=fontdat+fonttbl[c-32];  ox=*ptr++; oy=*ptr++;  w =*ptr++; h =*ptr++;  dw=*ptr++;  yst=fontfh-(oy-fontoy)-fontyofs-h;    if(!go_through_the_motions && c!='\t')    for(y=ypos+yst;y<ypos+yst+h;y++)      {      /* use the obvious way for 15/16/24-bit modes       * (saves having to deal with colours directly).       * also do pixel-by-pixel for 360x480, as we want to       * divide x offset by two, which is much easier this way.       */      if(dont_use_lines)        {        if(squish_x)          {          for(x=xpos+ox;x<xpos+ox+w;x++)            if(*ptr++) vga_drawpixel((x-origxpos)/2+origxpos,y);          }        else          for(x=xpos+ox;x<xpos+ox+w;x++)            if(*ptr++) vga_drawpixel(x,y);        }      else        {        for(x=xpos+ox;x<xpos+ox+w;x++)          /* this is a little faster, I think, especially           * for large fonts. (It uses horizontal lines where possible.)           */          if(*ptr++)            {if(xrunst==-1) xrunst=x;}          else            if(xrunst!=-1)              {              if(xrunst==x-1)                vga_drawpixel(xrunst,y);              else                vga_drawscansegment(scanbit,xrunst,y,x-xrunst);              xrunst=-1;              }                if(xrunst!=-1)          {          if(xrunst==x-1)            vga_drawpixel(xrunst,y);          else            vga_drawscansegment(scanbit,xrunst,y,x-xrunst);          }        xrunst=-1;        }      }    xpos+=dw+widthadd;  }return(xpos-initxpos);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -