1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-05-12 08:00:12 +00:00

updated dos font to eliminate need for -1px letter-spacing hacks

This commit is contained in:
boxgaming 2024-01-11 14:32:18 -06:00
parent 000d4f35b7
commit a6de3c57d8
10 changed files with 28 additions and 100 deletions

View file

@ -45,7 +45,6 @@
body { body {
background-color: rgb(0, 0, 170); background-color: rgb(0, 0, 170);
letter-spacing: -1px;
} }
#gx-container { #gx-container {

View file

@ -45,11 +45,6 @@
body { body {
background-color: #0000AA; background-color: #0000AA;
letter-spacing: -1px;
}
#gx-container {
letter-spacing: normal;
} }
#code, #gx-container, #toolbar, #toolbar .spacer, .tab, #output-content { #code, #gx-container, #toolbar, #toolbar .spacer, .tab, #output-content {

View file

@ -1,7 +1,7 @@
.cm-s-qbjs { .cm-s-qbjs {
line-height: 1em; line-height: 1em;
} }
.cm-s-qbjs.CodeMirror { background: rgb(0, 0, 39); color: rgb(216, 216, 216); text-shadow: 0 -1px 1px #262626; font-family: dosvga; letter-spacing: -1px} .cm-s-qbjs.CodeMirror { background: rgb(0, 0, 39); color: rgb(216, 216, 216); text-shadow: 0 -1px 1px #262626; font-family: dosvga; }
.cm-s-qbjs div.CodeMirror-selected { background: #45443B; } /* 33322B*/ .cm-s-qbjs div.CodeMirror-selected { background: #45443B; } /* 33322B*/
.cm-s-qbjs .CodeMirror-line::selection, .cm-s-qbjs .CodeMirror-line > span::selection, .cm-s-qbjs .CodeMirror-line > span > span::selection { background: rgba(0, 49, 78, .99); } .cm-s-qbjs .CodeMirror-line::selection, .cm-s-qbjs .CodeMirror-line > span::selection, .cm-s-qbjs .CodeMirror-line > span > span::selection { background: rgba(0, 49, 78, .99); }
.cm-s-qbjs .CodeMirror-line::-moz-selection, .cm-s-qbjs .CodeMirror-line > span::-moz-selection, .cm-s-qbjs .CodeMirror-line > span > span::-moz-selection { background: rgba(69, 68, 59, .99); } .cm-s-qbjs .CodeMirror-line::-moz-selection, .cm-s-qbjs .CodeMirror-line > span::-moz-selection, .cm-s-qbjs .CodeMirror-line > span > span::-moz-selection { background: rgba(69, 68, 59, .99); }
@ -46,9 +46,6 @@
.cm-s-qbjs .CodeMirror-search-field { font-family: dosvga; font-size: 1em; } .cm-s-qbjs .CodeMirror-search-field { font-family: dosvga; font-size: 1em; }
.cm-s-qbjs .cm-searching { color: #333 !important; background-color: #ccc; } .cm-s-qbjs .cm-searching { color: #333 !important; background-color: #ccc; }
body { letter-spacing: -1px; }
#gx-container { letter-spacing: normal; }
#help-nav a:hover { color: #fff; } #help-nav a:hover { color: #fff; }
#help-nav a:before { content: "< "; } #help-nav a:before { content: "< "; }
#help-nav a:after { content: " >"; } #help-nav a:after { content: " >"; }

View file

@ -59,7 +59,6 @@ body {
#slider { #slider {
font-family: dosvga; font-family: dosvga;
letter-spacing: -1px;
} }
a, #tabs { a, #tabs {
@ -89,7 +88,6 @@ a, #tabs {
dialog textarea { dialog textarea {
font-family: Consolas, 'Courier New', monospace; font-family: Consolas, 'Courier New', monospace;
letter-spacing: normal;
background-color: #1e1e1e; background-color: #1e1e1e;
color: #ccc; color: #ccc;
} }

View file

@ -20,7 +20,6 @@
.cm-s-win-classic .cm-header { color: #FF6400; } .cm-s-win-classic .cm-header { color: #FF6400; }
.cm-s-win-classic .cm-hr { color: #AEAEAE; } .cm-s-win-classic .cm-hr { color: #AEAEAE; }
.cm-s-win-classic .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } .cm-s-win-classic .cm-link { color:#ad9361; font-style:italic; text-decoration:none; }
/*.cm-s-win-classic .cm-error { border-bottom: 1px solid red; }*/
div.cm-s-win-classic .CodeMirror-activeline-background { background: #efefff; } div.cm-s-win-classic .CodeMirror-activeline-background { background: #efefff; }
div.cm-s-win-classic span.CodeMirror-matchingbracket { outline:1px solid grey; color: inherit; } div.cm-s-win-classic span.CodeMirror-matchingbracket { outline:1px solid grey; color: inherit; }
@ -51,7 +50,6 @@ li a:active { border: 0; }
dialog textarea { dialog textarea {
font-family: 'Courier New', monospace; font-family: 'Courier New', monospace;
font-size: 14px; font-size: 14px;
letter-spacing: normal;
border: 2px inset; border: 2px inset;
} }
dialog textarea:focus { dialog textarea:focus {
@ -65,7 +63,6 @@ dialog {
#code { #code {
border: 2px inset; border: 2px inset;
/*border-top: 0;*/
font-size: 14px; font-size: 14px;
} }
@ -73,7 +70,6 @@ dialog {
#output-content, #warning-container { #output-content, #warning-container {
font-family: 'Courier New', monospace; font-family: 'Courier New', monospace;
/*font-size: 14px;*/
} }
#output-content { #output-content {

View file

@ -1,11 +1,10 @@
@font-face { @font-face {
font-family: dosvga; font-family: dosvga;
src: url(dosvga.ttf); src: url(qbjs.woff2);
} }
body { body {
background-color: #000; background-color: #000;
font-family: dosvga, Arial, Helvetica, sans-serif; font-family: dosvga, Arial, Helvetica, sans-serif;
letter-spacing: -1px;
color: #999; color: #999;
} }
#gx-container { #gx-container {

102
qb.js
View file

@ -60,7 +60,6 @@ var QB = new function() {
var _windowDef = []; var _windowDef = [];
var _fileHandles = null; var _fileHandles = null;
var _typeMap = {}; var _typeMap = {};
var _letterSpacingSupport = null;
// Array handling methods // Array handling methods
@ -394,14 +393,6 @@ var QB = new function() {
}; };
this.sub__Font = function(fnt) { this.sub__Font = function(fnt) {
if (fnt < 1000) {
GX.ctx().letterSpacing = "-1px";
GX.canvas().style.letterSpacing = "-1px";
}
else {
GX.ctx().letterSpacing = "0px";
GX.canvas().style.letterSpacing = "normal";
}
_font = fnt; _font = fnt;
_locX = 0; _locX = 0;
_lastTextX = 0; _lastTextX = 0;
@ -751,43 +742,23 @@ var QB = new function() {
ctx.beginPath(); ctx.beginPath();
var f = _fonts[_font]; var f = _fonts[_font];
ctx.font = f.size + " " + f.name; ctx.font = f.size + " " + f.name;
// ------------------------------------------------------------------ var tm = ctx.measureText(s);
// special case for built-in fonts and safari var fheight = 0;
// if safari adds 2d canvas letterSpacing support this can be removed if (tm.fontBoundingBoxAscent) {
if (!_letterSpacingSupport && _font < 1000) { fheight = tm.fontBoundingBoxAscent + tm.fontBoundingBoxDescent;
for (var i=0; i < s.length; i++) {
var ch = s.substring(i, i+1);
if (_printMode != QB._KEEPBACKGROUND) {
ctx.fillStyle = _bgColor.rgba();
ctx.fillRect(x + (i * QB.func__FontWidth()), y, QB.func__FontWidth(), QB.func__FontHeight());
}
if (_printMode != QB._ONLYBACKGROUND) {
// Draw the string
ctx.fillStyle = _fgColor.rgba();
ctx.fillText(ch, x + (i * QB.func__FontWidth()), y + QB.func__FontHeight() - f.offset);
}
}
} }
// ------------------------------------------------------------------
else { else {
var tm = ctx.measureText(s); fheight = tm.actualBoundingBoxAscent + tm.actualBoundingBoxDescent;
var fheight = 0; }
if (tm.fontBoundingBoxAscent) {
fheight = tm.fontBoundingBoxAscent + tm.fontBoundingBoxDescent; if (_printMode != QB._KEEPBACKGROUND) {
} ctx.fillStyle = _bgColor.rgba();
else { ctx.fillRect(x, y, tm.width, fheight);
fheight = tm.actualBoundingBoxAscent + tm.actualBoundingBoxDescent; }
} if (_printMode != QB._ONLYBACKGROUND) {
// Draw the string
if (_printMode != QB._KEEPBACKGROUND) { ctx.fillStyle = _fgColor.rgba();
ctx.fillStyle = _bgColor.rgba(); ctx.fillText(s, x, y + fheight - f.offset);
ctx.fillRect(x, y, tm.width, fheight);
}
if (_printMode != QB._ONLYBACKGROUND) {
// Draw the string
ctx.fillStyle = _fgColor.rgba();
ctx.fillText(s, x, y + fheight - f.offset);
}
} }
}; };
@ -2408,38 +2379,17 @@ var QB = new function() {
} }
var y = _locY * QB.func__FontHeight(); var y = _locY * QB.func__FontHeight();
// ------------------------------------------------------------------ // Draw the text background
// special case for built-in fonts and safari var tm = ctx.measureText(subline);
// if safari adds 2d canvas letterSpacing support this can be removed if (_printMode != QB._KEEPBACKGROUND) {
if (!_letterSpacingSupport && _font < 1000) { ctx.fillStyle = _bgColor.rgba();
for (var i=0; i < subline.length; i++) { ctx.fillRect(x, y, tm.width, QB.func__FontHeight());
var ch = subline.substring(i, i+1);
if (_printMode != QB._KEEPBACKGROUND) {
ctx.fillStyle = _bgColor.rgba();
ctx.fillRect(x + (i * QB.func__FontWidth()), y, QB.func__FontWidth(), QB.func__FontHeight());
}
if (_printMode != QB._ONLYBACKGROUND) {
// Draw the string
ctx.fillStyle = _fgColor.rgba();
ctx.fillText(ch, x + (i * QB.func__FontWidth()), y + QB.func__FontHeight() - f.offset);
}
}
x += QB.func__FontWidth();
} }
// ------------------------------------------------------------------ if (_printMode != QB._ONLYBACKGROUND) {
else { ctx.fillStyle = _fgColor.rgba();
// Draw the text background ctx.fillText(subline, x, (y + QB.func__FontHeight() - f.offset));
var tm = ctx.measureText(subline);
if (_printMode != QB._KEEPBACKGROUND) {
ctx.fillStyle = _bgColor.rgba();
ctx.fillRect(x, y, tm.width, QB.func__FontHeight());
}
if (_printMode != QB._ONLYBACKGROUND) {
ctx.fillStyle = _fgColor.rgba();
ctx.fillText(subline, x, (y + QB.func__FontHeight() - f.offset));
}
x += tm.width;
} }
x += tm.width;
_locX += subline.length; _locX += subline.length;
} }
@ -2958,10 +2908,6 @@ var QB = new function() {
_keyDownMap = {}; _keyDownMap = {};
// TODO: set the appropriate default font for the selected screen mode above instead of here // TODO: set the appropriate default font for the selected screen mode above instead of here
if (_letterSpacingSupport == null) {
_letterSpacingSupport = (GX.ctx().letterSpacing) ? true : false;
}
QB.sub__Font(_font);
}; };
this.func_Seek = function(fh) { this.func_Seek = function(fh) {

View file

@ -1,6 +1,6 @@
@font-face { @font-face {
font-family: dosvga; font-family: dosvga;
src: url(dosvga.ttf); src: url(qbjs.woff2);
} }
body { body {
background-color: rgb(0, 0, 39); background-color: rgb(0, 0, 39);
@ -47,7 +47,6 @@ a:after { content: " >"; }
#gx-canvas { #gx-canvas {
border: 1px solid #222; border: 1px solid #222;
background-color: #000; background-color: #000;
letter-spacing: -1px;
font-family: dosvga; font-family: dosvga;
} }
#output-container { #output-container {
@ -187,7 +186,6 @@ dialog textarea,
#prog-sel-dialog select { #prog-sel-dialog select {
font-family: dosvga; font-family: dosvga;
font-size: 1em; font-size: 1em;
letter-spacing: -1px;
background-color: #efefef; background-color: #efefef;
padding: 5px; padding: 5px;
} }

View file

@ -365,7 +365,7 @@ var IDE = new function() {
zip.file("fullscreen.svg", await getFile("export/fullscreen.svg", "blob")); zip.file("fullscreen.svg", await getFile("export/fullscreen.svg", "blob"));
zip.file("fullscreen-hover.svg", await getFile("export/fullscreen-hover.svg", "blob")); zip.file("fullscreen-hover.svg", await getFile("export/fullscreen-hover.svg", "blob"));
zip.file("logo.png", await getFile("export/logo.png", "blob")); zip.file("logo.png", await getFile("export/logo.png", "blob"));
zip.file("dosvga.ttf", await getFile("dosvga.ttf", "blob")); zip.file("qbjs.woff2", await getFile("qbjs.woff2", "blob"));
zip.file("play.png", await getFile("play.png", "blob")); zip.file("play.png", await getFile("play.png", "blob"));
zip.file("qbjs.css", await getFile("export/qbjs.css", "text")); zip.file("qbjs.css", await getFile("export/qbjs.css", "text"));
zip.file("qb.js", await getFile("qb.js", "text")); zip.file("qb.js", await getFile("qb.js", "text"));

BIN
qbjs.woff2 Normal file

Binary file not shown.