File size: 3,804 Bytes
806d4b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

/*After making a font...

You can save it as a binary file with:
        FileWrite("filename.BIN.Z",text.font,256*FONT_HEIGHT);

You can load it with:
        U64 *my_font=FileRead("filename.BIN.Z");
        text.aux_font=my_font;

<CTRL-ALT-f> will toggle main font and aux_font.

If you want to change the system font permanently,
save to a file with this font editor program
and cut and paste the code into ::/Kernel/FontStd.HC.
You will need to recompile Kernel by calling BootHDIns().

See ::/Demo/ExtChars.HC, ::/Demo/Games/CharDemo.HC,
::/Demo/Graphics/CharAnimation.HC and ::/Demo/ScrnCodes.HC.
*/

#define BLOW_UP_CHAR_X  (18*FONT_WIDTH)
#define BLOW_UP_CHAR_Y  (4*FONT_HEIGHT)

U8 cur_ch;

U0 DrawIt(CTask *task,CDC *dc)
{
  I64 i,j,k,c;
  TextPrint(task,0,0,BLUE<<4+YELLOW,"Press <CTRL-ALT-f> to Toggle Aux Font.");
  k=0;
  for (i=0;i<16;i++)
    for (j=0;j<16;j++) {
      if (k==cur_ch) {
        if (Blink)
          c=(BLUE<<4+YELLOW)<<8 + k++;
        else
          c=(YELLOW<<4+BLUE)<<8 + k++;
      } else
        c=(BLUE<<4+WHITE)<<8 + k++;
      TextChar(task,,j,i+2,c);
    }

  k=0;
  for (i=0;i<FONT_HEIGHT;i++)
    for (j=0;j<FONT_WIDTH;j++) {
      if (Bt(&text.font[cur_ch],k++))
        dc->color=YELLOW;
      else
        dc->color=BLUE;
      GrRect(dc,BLOW_UP_CHAR_X+j*FONT_WIDTH,
            BLOW_UP_CHAR_Y+i*FONT_HEIGHT,
            FONT_WIDTH,FONT_HEIGHT);
    }
}

U0 FESave(Bool pmt)
{
  U8 old_draw_it=Fs->draw_it;
  CDoc *doc=DocNew;
  I64 i;
  for (i=0;i<256;i++) {
    DocPrint(doc,"0x%016X,",text.font[i]);
    if (Bt(char_bmp_safe_dollar,i))
      DocPrint(doc,"//%c",i);
    else if (i=='$')
      DocPrint(doc,"//$$",i);
    DocPrint(doc,"\n");
  }
  Fs->draw_it=NULL;
  DocWrite(doc,pmt);
  Fs->draw_it=old_draw_it;
  DocDel(doc);
}

U0 FontEd()
{
  I64 msg_code,arg1,arg2,k;
  SettingsPush; //See SettingsPush
  MenuPush(
        "File {"
        "  SaveAs(,CH_CTRLA);"
        "  Abort(,CH_SHIFT_ESC);"
        "  Exit(,CH_ESC);"
        "}");
  AutoComplete;
  DocCursor;
  DocClear;
  Fs->win_inhibit|=WIG_DBL_CLICK;
  cur_ch=0;
  try {
    Fs->draw_it=&DrawIt;
    while (TRUE) {
      switch (msg_code=GetMsg(&arg1,&arg2,
            1<<MSG_KEY_DOWN|1<<MSG_MS_L_DOWN|1<<MSG_MS_R_DOWN|1<<MSG_MS_MOVE)) {
        case MSG_KEY_DOWN:
          switch (arg1) {
            case 0:
              switch (arg2.u8[0]) {
                case SC_CURSOR_LEFT:
                  cur_ch--;
                  break;
                case SC_CURSOR_RIGHT:
                  cur_ch++;
                  break;
                case SC_CURSOR_UP:
                  cur_ch-=16;
                  break;
                case SC_CURSOR_DOWN:
                  cur_ch+=16;
                  break;

              }
              break;
              goto fe_done;
            case CH_CTRLA:
              FESave(TRUE);
              break;
            case CH_ESC:
              FESave(FALSE);
            case CH_SHIFT_ESC:
              goto fe_done;
            default:
              cur_ch=arg1;
          }
          break;
        case MSG_MS_L_DOWN:
        case MSG_MS_R_DOWN:
          if (0<=arg1<FONT_WIDTH*16 && 0<=arg2-2*FONT_HEIGHT<FONT_HEIGHT*16) {
            cur_ch=(arg2/FONT_HEIGHT-2)*16+arg1/FONT_WIDTH;
            break;
          } //fall through
        case MSG_MS_MOVE:
          k=((arg2-BLOW_UP_CHAR_Y)/FONT_HEIGHT)*FONT_WIDTH+
                (arg1-BLOW_UP_CHAR_X)/FONT_WIDTH;
          if (0<=k<FONT_WIDTH*FONT_HEIGHT) {
            if (ms.lb||msg_code==MSG_MS_L_DOWN)
              Bts(&text.font[cur_ch],k);
            if (ms.rb||msg_code==MSG_MS_R_DOWN)
              Btr(&text.font[cur_ch],k);
          }
          break;
      }
    }
fe_done:
    GetMsg(,,1<<MSG_KEY_UP);
  } catch
    PutExcept;
  MenuPop;
  SettingsPop;
}

FontEd;