templeos-info/public/Wb/Demo/Graphics/FontEd.HC.HTML

184 lines
17 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF2>/*After making a font...</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF2>You can save it as a binary file with:</span><span class=cF0>
<a name="l4"></a> </span><span class=cF2>FileWrite(&quot;filename.BIN.Z&quot;,text.font,256*FONT_HEIGHT);</span><span class=cF0>
<a name="l5"></a>
<a name="l6"></a></span><span class=cF2>You can load it with:</span><span class=cF0>
<a name="l7"></a> </span><span class=cF2>U64 *my_font=FileRead(&quot;filename.BIN.Z&quot;);</span><span class=cF0>
<a name="l8"></a> </span><span class=cF2>text.aux_font=my_font;</span><span class=cF0>
<a name="l9"></a>
<a name="l10"></a></span><span class=cF2>&lt;CTRL-ALT-f&gt; will toggle main font and aux_font.</span><span class=cF0>
<a name="l11"></a>
<a name="l12"></a></span><span class=cF2>If you want to change the system font permanently,</span><span class=cF0>
<a name="l13"></a></span><span class=cF2>save to a file with this font editor program</span><span class=cF0>
<a name="l14"></a></span><span class=cF2>and cut and paste the code into </span><a href="/Wb/Kernel/FontStd.HC.HTML#l1"><span class=cF4>::/Kernel/FontStd.HC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l15"></a></span><span class=cF2>You will need to recompile Kernel by calling </span><a href="/Wb/Adam/Opt/Boot/BootHDIns.HC.HTML#l18"><span class=cF4>BootHDIns</span></a><span class=cF2>().</span><span class=cF0>
<a name="l16"></a>
<a name="l17"></a></span><span class=cF2>See </span><a href="/Wb/Demo/ExtChars.HC.HTML#l1"><span class=cF4>::/Demo/ExtChars.HC</span></a><span class=cF2>, </span><a href="/Wb/Demo/Games/CharDemo.HC.HTML#l1"><span class=cF4>::/Demo/Games/CharDemo.HC</span></a><span class=cF2>,</span><span class=cF4>
<a name="l18"></a></span><a href="/Wb/Demo/Graphics/CharAnimation.HC.HTML#l1"><span class=cF4>::/Demo/Graphics/CharAnimation.HC</span></a><span class=cF2> and </span><a href="/Wb/Demo/ScrnCodes.HC.HTML#l1"><span class=cF4>::/Demo/ScrnCodes.HC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l19"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l20"></a>
<a name="l21"></a>#</span><span class=cF1>define</span><span class=cF0> BLOW_UP_CHAR_X (18*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>)
<a name="l22"></a>#</span><span class=cF1>define</span><span class=cF0> BLOW_UP_CHAR_Y (4*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>)
<a name="l23"></a>
<a name="l24"></a></span><span class=cF1>U8</span><span class=cF0> cur_ch;
<a name="l25"></a>
<a name="l26"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawIt</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task,</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l27"></a>{
<a name="l28"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,k,c;
<a name="l29"></a> </span><span class=cF5>TextPrint</span><span class=cF0>(task,0,0,</span><span class=cF3>BLUE</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>YELLOW</span><span class=cF0>,</span><span class=cF6>&quot;Press &lt;CTRL-ALT-f&gt; to Toggle Aux Font.&quot;</span><span class=cF0>);
<a name="l30"></a> k=0;
<a name="l31"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;16;i++)
<a name="l32"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;16;j++) </span><span class=cF7>{</span><span class=cF0>
<a name="l33"></a> </span><span class=cF1>if</span><span class=cF0> (k==cur_ch) {
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l35"></a> c=(</span><span class=cF3>BLUE</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>YELLOW</span><span class=cF0>)&lt;&lt;8 + k++;
<a name="l36"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l37"></a> c=(</span><span class=cF3>YELLOW</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>BLUE</span><span class=cF0>)&lt;&lt;8 + k++;
<a name="l38"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l39"></a> c=(</span><span class=cF3>BLUE</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>WHITE</span><span class=cF0>)&lt;&lt;8 + k++;
<a name="l40"></a> </span><span class=cF5>TextChar</span><span class=cF0>(task,,j,i+2,c);
<a name="l41"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l42"></a>
<a name="l43"></a> k=0;
<a name="l44"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>;i++)
<a name="l45"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;</span><span class=cF3>FONT_WIDTH</span><span class=cF0>;j++) </span><span class=cF7>{</span><span class=cF0>
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>text</span><span class=cF0>.font[cur_ch],k++</span><span class=cF7>)</span><span class=cF0>)
<a name="l47"></a> dc-&gt;color=</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l48"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l49"></a> dc-&gt;color=</span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l50"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,BLOW_UP_CHAR_X+j*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>,
<a name="l51"></a> BLOW_UP_CHAR_Y+i*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,
<a name="l52"></a> </span><span class=cF3>FONT_WIDTH</span><span class=cF0>,</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>);
<a name="l53"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l54"></a>}
<a name="l55"></a>
<a name="l56"></a></span><span class=cF1>U0</span><span class=cF0> FESave(</span><span class=cF1>Bool</span><span class=cF0> pmt)
<a name="l57"></a>{
<a name="l58"></a> </span><span class=cF1>U8</span><span class=cF0> old_draw_it=</span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it;
<a name="l59"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocNew</span><span class=cF0>;
<a name="l60"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l61"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;256;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l62"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;0x%016X,&quot;</span><span class=cF0>,</span><span class=cFB>text</span><span class=cF0>.font[i]);
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_safe_dollar</span><span class=cF0>,i</span><span class=cF7>)</span><span class=cF0>)
<a name="l64"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;//%c&quot;</span><span class=cF0>,i);
<a name="l65"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i==</span><span class=cF6>'$'</span><span class=cF0>)
<a name="l66"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;//$$&quot;</span><span class=cF0>,i);
<a name="l67"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;\n&quot;</span><span class=cF0>);
<a name="l68"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l69"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l70"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc,pmt);
<a name="l71"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it=old_draw_it;
<a name="l72"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l73"></a>}
<a name="l74"></a>
<a name="l75"></a></span><span class=cF1>U0</span><span class=cF0> FontEd()
<a name="l76"></a>{
<a name="l77"></a> </span><span class=cF9>I64</span><span class=cF0> msg_code,arg1,arg2,k;
<a name="l78"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="/Wb/Adam/TaskSettings.HC.HTML#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l79"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l80"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l81"></a> </span><span class=cF6>&quot; SaveAs(,CH_CTRLA);&quot;</span><span class=cF0>
<a name="l82"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l83"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l84"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>);
<a name="l85"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l86"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l87"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l88"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit|=</span><span class=cF3>WIG_DBL_CLICK</span><span class=cF0>;
<a name="l89"></a> cur_ch=0;
<a name="l90"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l91"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it=&amp;</span><span class=cF5>DrawIt</span><span class=cF0>;
<a name="l92"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l93"></a> </span><span class=cF1>switch</span><span class=cF0> (msg_code=</span><span class=cF5>GetMsg</span><span class=cF7>(</span><span class=cF0>&amp;arg1,&amp;arg2,
<a name="l94"></a> 1&lt;&lt;</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_R_DOWN</span><span class=cF0>|1&lt;&lt;</span><span class=cF3>MSG_MS_MOVE</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l95"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l96"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l97"></a> </span><span class=cF1>case</span><span class=cF0> 0:
<a name="l98"></a> </span><span class=cF1>switch</span><span class=cF0> (arg2.u8[0]) </span><span class=cF7>{</span><span class=cF0>
<a name="l99"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l100"></a> cur_ch--;
<a name="l101"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l102"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l103"></a> cur_ch++;
<a name="l104"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l105"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l106"></a> cur_ch-=16;
<a name="l107"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l108"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l109"></a> cur_ch+=16;
<a name="l110"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l111"></a>
<a name="l112"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l113"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l114"></a> </span><span class=cF1>goto</span><span class=cF0> fe_done;
<a name="l115"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLA</span><span class=cF0>:
<a name="l116"></a> FESave(</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l117"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l118"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l119"></a> FESave(</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l120"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l121"></a> </span><span class=cF1>goto</span><span class=cF0> fe_done;
<a name="l122"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l123"></a> cur_ch=arg1;
<a name="l124"></a> }
<a name="l125"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l126"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
<a name="l127"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_R_DOWN</span><span class=cF0>:
<a name="l128"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=arg1&lt;</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*16 &amp;&amp; 0&lt;=arg2-2*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>&lt;</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>*16) {
<a name="l129"></a> cur_ch=(arg2/</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>-2)*16+arg1/</span><span class=cF3>FONT_WIDTH</span><span class=cF0>;
<a name="l130"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l131"></a> } </span><span class=cF2>//fall through</span><span class=cF0>
<a name="l132"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>:
<a name="l133"></a> k=(</span><span class=cF7>(</span><span class=cF0>arg2-BLOW_UP_CHAR_Y</span><span class=cF7>)</span><span class=cF0>/</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>)*</span><span class=cF3>FONT_WIDTH</span><span class=cF0>+
<a name="l134"></a> (arg1-BLOW_UP_CHAR_X)/</span><span class=cF3>FONT_WIDTH</span><span class=cF0>;
<a name="l135"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=k&lt;</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>) {
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms</span><span class=cF0>.lb||msg_code==</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>)
<a name="l137"></a> </span><span class=cF5>Bts</span><span class=cF0>(&amp;</span><span class=cFB>text</span><span class=cF0>.font[cur_ch],k);
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms</span><span class=cF0>.rb||msg_code==</span><span class=cF3>MSG_MS_R_DOWN</span><span class=cF0>)
<a name="l139"></a> </span><span class=cF5>Btr</span><span class=cF0>(&amp;</span><span class=cFB>text</span><span class=cF0>.font[cur_ch],k);
<a name="l140"></a> }
<a name="l141"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l142"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l143"></a> }
<a name="l144"></a>fe_done:
<a name="l145"></a> </span><span class=cF5>GetMsg</span><span class=cF0>(,,1&lt;&lt;</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>);
<a name="l146"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
<a name="l147"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l148"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l149"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l150"></a>}
<a name="l151"></a>
<a name="l152"></a>FontEd;
</span></pre></body>
</html>