易码技术论坛

 找回密码
 加入易码
搜索
12
返回列表 发新帖
楼主: niubo_

[工具] 可变宽度的 x*8和x*6 英文字体

[复制链接]
发表于 2007-6-13 19:25:10 | 显示全部楼层

实践是检验真理的唯一标准
发表于 2007-6-13 20:21:38 | 显示全部楼层
好啊
发表于 2007-6-13 20:47:02 | 显示全部楼层
哎,我在BAS上作过3*5和4*7的字体,一直没时间发布,现在看来不用了……
支持新技术!
发表于 2007-6-13 21:50:35 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2007-6-14 06:06:01 | 显示全部楼层
引用第17楼leesoft2007-06-13 10:54发表的“”:
变宽字体要提供计算字符串宽度的函数吧
开始就是这么想的,但是考虑到速度,光是显示都已经够慢的了,如果每个字再计算一下宽度就更慢了,不得已我自己先算出宽度做了个宽度列表
发表于 2007-6-15 13:22:01 | 显示全部楼层
呵呵
看着挺不错
发表于 2007-6-15 13:23:37 | 显示全部楼层
引用第23楼一捧米2007-06-13 20:47发表的“”:
哎,我在BAS上作过3*5和4*7的字体,一直没时间发布,现在看来不用了……
支持新技术!
BAS上...3*5和4*7的字体.....你好狂~~...发布上来看看
发表于 2007-6-16 17:49:01 | 显示全部楼层
做成象LOJA的放大镜那样的支持BAS那该多好啊~~~
发表于 2007-6-16 18:32:25 | 显示全部楼层
正需要呢!!!
 楼主| 发表于 2007-6-11 07:50:43 | 显示全部楼层 |阅读模式
  最近似乎总是很无聊啊。想起不久前红色激情的5×5小字体,当时我的意见是宽度都一样,看起来很散,于是就用了一个无聊的晚自习时间做了这么两套小字体(5×5太小了,还是做高度为6或者8的好看些)。下面是源码:
//x*8
char sfont[]={
0,0,0,0,0,0,0,0
,64,64,64,64,64,0,64,0
,80,80,80,0,0,0,0,0
,0,40,124,40,40,124,40,0
,16,60,80,56,20,120,16,0
,0,0,68,72,16,36,68,0
,32,80,80,36,84,72,52,0
,64,64,64,0,0,0,0,0
,16,32,64,64,64,32,16,0
,64,32,16,16,16,32,64,0
,0,68,40,124,40,68,0,0
,0,16,16,124,16,16,0,0
,0,0,0,0,0,32,64,0
,0,0,0,124,0,0,0,0
,0,0,0,0,0,0,64,0
,16,16,32,32,32,64,64,0
,120,72,72,72,72,72,120,0
,32,96,32,32,32,32,32,0
,120,8,8,120,64,64,120,0
,120,8,8,120,8,8,120,0
,80,80,80,80,120,16,16,0
,120,64,64,120,8,8,120,0
,120,64,64,120,72,72,120,0
,120,8,8,8,8,8,8,0
,120,72,72,120,72,72,120,0
,120,72,72,120,8,8,120,0
,0,0,64,0,0,64,0,0
,0,0,32,0,0,32,64,0
,8,16,32,64,32,16,8,0
,0,0,124,0,124,0,0,0
,64,32,16,8,16,32,64,0
,56,68,68,8,16,0,16,0
,0,56,68,92,92,64,60,0
,48,72,72,120,72,72,72,0
,112,72,72,112,72,72,112,0
,48,72,64,64,64,72,48,0
,112,72,72,72,72,72,112,0
,120,64,64,120,64,64,120,0
,120,64,64,120,64,64,64,0
,48,72,64,64,88,72,56,0
,72,72,72,120,72,72,72,0
,112,32,32,32,32,32,112,0
,112,32,32,32,32,32,64,0
,68,72,80,96,80,72,68,0
,64,64,64,64,64,64,120,0
,65,99,85,85,73,73,65,0
,68,100,84,84,76,68,68,0
,56,68,68,68,68,68,56,0
,112,72,72,112,64,64,64,0
,56,68,68,68,84,72,52,0
,112,72,72,112,80,72,72,0
,56,64,64,48,8,8,112,0
,124,16,16,16,16,16,16,0
,68,68,68,68,68,68,56,0
,68,68,68,40,40,16,16,0
,68,84,84,84,40,40,40,0
,68,68,40,16,40,68,68,0
,68,68,40,16,16,16,16,0
,124,4,8,16,32,64,124,0
,96,64,64,64,64,64,96,0
,64,64,32,32,32,16,16,0
,96,32,32,32,32,32,96,0
,16,40,68,0,0,0,0,0
,0,0,0,0,0,0,120,0
,64,64,32,0,0,0,0,0
,0,0,56,72,72,72,56,0
,64,64,112,72,72,72,112,0
,0,0,48,64,64,64,48,0
,8,8,56,72,72,72,56,0
,0,0,48,72,120,64,48,0
,24,32,120,32,32,32,32,0
,0,0,56,72,72,56,8,48
,64,64,112,72,72,72,72,0
,64,0,64,64,64,64,64,0
,32,0,32,32,32,32,32,64
,64,64,72,80,96,80,72,0
,64,64,64,64,64,64,64,0
,0,0,54,73,73,73,73,0
,0,0,112,72,72,72,72,0
,0,0,48,72,72,72,48,0
,0,0,112,72,72,112,64,64
,0,0,56,72,72,56,8,8
,0,0,80,96,64,64,64,0
,0,0,48,64,32,16,96,0
,0,32,112,32,32,32,16,0
,0,0,72,72,72,72,56,0
,0,0,68,68,40,40,16,0
,0,0,68,84,84,40,40,0
,0,0,68,40,16,40,68,0
,0,0,72,72,72,56,8,112
,0,0,124,8,16,32,124,0
,16,32,32,64,32,32,16,0
,64,64,64,0,64,64,64,0
,64,32,32,16,32,32,64,0
,0,32,84,8,0,0,0,0
,0,0,0,16,40,68,124,0
,124,68,68,68,68,68,124,0};
char width[]={
3,2,4,6,6,6,6,2,4,4,6,6,3,6,2,4,5,3,5,5,5,5,5,5,5,5,2,3,5,6,5,6,6,5,5,5,6,5,5,5,5,4,4,6,5,8,6,6,5,6,5,5,6,6,6,6,6,6,6,3,4,3,6,5,3,5,5,4,5,5,5,5,5,2,3,5,2,8,5,5,5,5,4,4,4,5,6,6,6,5,6,4,2,4,6,6,6};
char demo[]={
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,0};
char demo1[]="The larger of the two moons had risen first this evening, and now hung pregnant and silver-white against a clear, star-dappled sky. Beneath the lambent moon the peaks of the Redridge Mountains strained for the sky.";
void stxt(int txt)
{
  char ch;
  char x,y;
  char sn,w,left;
  int pt;
  x=0;y=0;
  pt=txt;
  left=160;
  ClearScreen();
  Refresh();
  for(;;)
   {
   ch=*pt;
   sn=ch-32;
   if(ch==0)break;
   if(ch>31&&ch<128)
    {
    w=width[sn];
    if(w>left){
      x=0;y=y+9;left=160;
      if(y>79)break;}
    WriteBlock(x,y,8,8,64,(sfont+sn*8));
    x=x+w;left=left-w;
    }
   if(ch>127)
    {
    if(left<6){
      x=0;y=y+9;left=160;
      if(y>79)break;}
    WriteBlock(x,y,8,8,64,(sfont+768));
    pt++;x=x+6;left=left-6;
    }
   if(ch==13)
    {
    pt++;x=0;y=y+9;
    if(y>79)break;
    }
   pt++;
   }
}
void main()
{
  stxt(demo);
  getchar();
  stxt(demo1);
  getchar();
}
//x*6
char ssfont[]={
0,0,0,0,0,0,0,0
,64,64,64,0,64,0,0,0
,80,80,0,0,0,0,0,0
,40,124,40,124,40,0,0,0
,32,112,32,112,32,0,0,0
,0,72,16,32,72,0,0,0
,32,80,40,80,104,0,0,0
,64,64,0,0,0,0,0,0
,32,64,64,64,32,0,0,0
,64,32,32,32,64,0,0,0
,0,80,32,80,0,0,0,0
,0,32,112,32,0,0,0,0
,0,0,0,0,32,64,0,0
,0,0,112,0,0,0,0,0
,0,0,0,0,64,0,0,0
,16,48,32,96,64,0,0,0
,112,80,80,80,112,0,0,0
,32,96,32,32,32,0,0,0
,112,16,112,64,112,0,0,0
,112,16,112,16,112,0,0,0
,80,80,112,16,16,0,0,0
,112,64,112,16,112,0,0,0
,112,64,112,80,112,0,0,0
,112,16,16,16,16,0,0,0
,112,80,112,80,112,0,0,0
,112,80,112,16,112,0,0,0
,0,64,0,64,0,0,0,0
,0,32,0,32,64,0,0,0
,16,32,64,32,16,0,0,0
,0,112,0,112,0,0,0,0
,64,32,16,32,64,0,0,0
,48,72,16,0,16,0,0,0
,56,88,88,64,56,0,0,0
,48,72,72,120,72,0,0,0
,112,72,112,72,112,0,0,0
,48,72,64,72,48,0,0,0
,112,72,72,72,112,0,0,0
,112,64,112,64,112,0,0,0
,112,64,112,64,64,0,0,0
,48,64,88,72,48,0,0,0
,72,72,120,72,72,0,0,0
,112,32,32,32,112,0,0,0
,112,32,32,32,64,0,0,0
,72,80,96,80,72,0,0,0
,64,64,64,64,112,0,0,0
,68,108,124,84,68,0,0,0
,72,104,88,72,72,0,0,0
,48,72,72,72,48,0,0,0
,112,72,72,112,64,0,0,0
,48,72,72,80,40,0,0,0
,112,72,72,112,72,0,0,0
,56,64,48,8,112,0,0,0
,112,32,32,32,32,0,0,0
,72,72,72,72,48,0,0,0
,68,68,68,40,16,0,0,0
,68,84,84,124,40,0,0,0
,68,40,16,40,68,0,0,0
,68,40,16,16,16,0,0,0
,124,8,16,32,124,0,0,0
,96,64,64,64,96,0,0,0
,64,96,32,48,16,0,0,0
,96,32,32,32,96,0,0,0
,32,80,0,0,0,0,0,0
,0,0,0,0,112,0,0,0
,64,32,0,0,0,0,0,0
,0,56,72,72,56,0,0,0
,64,112,72,72,112,0,0,0
,0,48,64,64,48,0,0,0
,8,56,72,72,56,0,0,0
,0,48,120,64,48,0,0,0
,16,32,112,32,32,0,0,0
,0,56,72,56,8,48,0,0
,64,96,80,80,80,0,0,0
,64,0,64,64,64,0,0,0
,32,0,32,32,64,0,0,0
,64,64,80,96,80,0,0,0
,64,64,64,64,64,0,0,0
,0,40,84,84,84,0,0,0
,0,96,80,80,80,0,0,0
,0,48,72,72,48,0,0,0
,0,112,72,72,112,64,0,0
,0,56,72,72,56,8,0,0
,0,80,96,64,64,0,0,0
,0,48,96,16,96,0,0,0
,32,112,32,32,16,0,0,0
,0,72,72,72,56,0,0,0
,0,68,68,40,16,0,0,0
,0,68,84,124,40,0,0,0
,0,72,48,48,72,0,0,0
,0,72,72,56,8,112,0,0
,0,120,16,32,120,0,0,0
,48,32,64,32,48,0,0,0
,64,64,0,64,64,0,0,0
,96,32,16,32,96,0,0,0
,32,84,8,0,0,0,0,0
,0,16,40,68,124,0,0,0
,124,68,68,68,124,0,0,0};
char width[]={
3,2,4,6,4,5,5,2,3,3,4,4,3,4,2,4,4,3,4,4,4,4,4,4,4,4,2,3,4,4,4,5,5,5,5,5,5,4,4,5,5,4,4,5,4,6,5,5,5,5,5,5,4,5,6,6,6,6,6,3,4,3,4,4,3,5,5,4,5,5,4,5,4,2,3,4,2,6,4,5,5,5,4,4,4,5,6,6,5,5,5,4,2,4,6,6,6};
char demo[]={
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,0};
char demo1[]="The larger of the two moons had risen first this evening, and now hung pregnant and silver-white against a clear, star-dappled sky. Beneath the lambent moon the peaks of the Redridge Mountains strained for the sky.";
void sstxt(int txt)
{
  char ch;
  char x,y;
  char sn,w,left;
  int pt;
  x=0;
  y=0;
  pt=txt;
  left=160;
  ClearScreen();
  Refresh();
  for(;;)
   {
   ch=*pt;
   sn=ch-32;
   if(ch==0)break;
   if(ch>31&&ch<128)
    {
    w=width[sn];
    if(w>left){
      x=0;y=y+7;left=160;
      if(y>79)break;}
    WriteBlock(x,y,8,8,64,(ssfont+sn*8));
    x=x+w;left=left-w;
    }
   if(ch>127)
    {
    if(left<6){
      x=0;y=y+7;left=160;
      if(y>79)break;}
    WriteBlock(x,y,8,8,64,(ssfont+768));
    pt++;x=x+6;left=left-6;
    }
   if(ch==13)
    {
    pt++;x=0;y=y+7;
    if(y>79)break;
    }
   pt++;
   }
}
void main()
{
  sstxt(demo);
  getchar();
  sstxt(demo1);
  getchar();
}
smtxt.JPG
smtxt1.JPG
sstxt.JPG
sstxt1.JPG
您需要登录后才可以回帖 登录 | 加入易码

本版积分规则

Archiver|手机版|小黑屋|EMAX Studio

GMT+8, 2024-3-19 10:09 , Processed in 0.013007 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表