1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-04-28 17:20:13 +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 {
background-color: rgb(0, 0, 170);
letter-spacing: -1px;
}
#gx-container {

View file

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

View file

@ -1,7 +1,7 @@
.cm-s-qbjs {
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 .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); }
@ -46,9 +46,6 @@
.cm-s-qbjs .CodeMirror-search-field { font-family: dosvga; font-size: 1em; }
.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:before { content: "< "; }
#help-nav a:after { content: " >"; }

View file

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

View file

@ -20,7 +20,6 @@
.cm-s-win-classic .cm-header { color: #FF6400; }
.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-error { border-bottom: 1px solid red; }*/
div.cm-s-win-classic .CodeMirror-activeline-background { background: #efefff; }
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 {
font-family: 'Courier New', monospace;
font-size: 14px;
letter-spacing: normal;
border: 2px inset;
}
dialog textarea:focus {
@ -65,7 +63,6 @@ dialog {
#code {
border: 2px inset;
/*border-top: 0;*/
font-size: 14px;
}
@ -73,7 +70,6 @@ dialog {
#output-content, #warning-container {
font-family: 'Courier New', monospace;
/*font-size: 14px;*/
}
#output-content {

View file

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

102
qb.js
View file

@ -60,7 +60,6 @@ var QB = new function() {
var _windowDef = [];
var _fileHandles = null;
var _typeMap = {};
var _letterSpacingSupport = null;
// Array handling methods
@ -394,14 +393,6 @@ var QB = new function() {
};
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;
_locX = 0;
_lastTextX = 0;
@ -751,43 +742,23 @@ var QB = new function() {
ctx.beginPath();
var f = _fonts[_font];
ctx.font = f.size + " " + f.name;
// ------------------------------------------------------------------
// special case for built-in fonts and safari
// if safari adds 2d canvas letterSpacing support this can be removed
if (!_letterSpacingSupport && _font < 1000) {
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);
}
}
var tm = ctx.measureText(s);
var fheight = 0;
if (tm.fontBoundingBoxAscent) {
fheight = tm.fontBoundingBoxAscent + tm.fontBoundingBoxDescent;
}
// ------------------------------------------------------------------
else {
var tm = ctx.measureText(s);
var fheight = 0;
if (tm.fontBoundingBoxAscent) {
fheight = tm.fontBoundingBoxAscent + tm.fontBoundingBoxDescent;
}
else {
fheight = tm.actualBoundingBoxAscent + tm.actualBoundingBoxDescent;
}
if (_printMode != QB._KEEPBACKGROUND) {
ctx.fillStyle = _bgColor.rgba();
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);
}
fheight = tm.actualBoundingBoxAscent + tm.actualBoundingBoxDescent;
}
if (_printMode != QB._KEEPBACKGROUND) {
ctx.fillStyle = _bgColor.rgba();
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();
// ------------------------------------------------------------------
// special case for built-in fonts and safari
// if safari adds 2d canvas letterSpacing support this can be removed
if (!_letterSpacingSupport && _font < 1000) {
for (var i=0; i < subline.length; i++) {
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();
// Draw the text background
var tm = ctx.measureText(subline);
if (_printMode != QB._KEEPBACKGROUND) {
ctx.fillStyle = _bgColor.rgba();
ctx.fillRect(x, y, tm.width, QB.func__FontHeight());
}
// ------------------------------------------------------------------
else {
// Draw the text background
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;
if (_printMode != QB._ONLYBACKGROUND) {
ctx.fillStyle = _fgColor.rgba();
ctx.fillText(subline, x, (y + QB.func__FontHeight() - f.offset));
}
x += tm.width;
_locX += subline.length;
}
@ -2958,10 +2908,6 @@ var QB = new function() {
_keyDownMap = {};
// 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) {

View file

@ -1,6 +1,6 @@
@font-face {
font-family: dosvga;
src: url(dosvga.ttf);
src: url(qbjs.woff2);
}
body {
background-color: rgb(0, 0, 39);
@ -47,7 +47,6 @@ a:after { content: " >"; }
#gx-canvas {
border: 1px solid #222;
background-color: #000;
letter-spacing: -1px;
font-family: dosvga;
}
#output-container {
@ -187,7 +186,6 @@ dialog textarea,
#prog-sel-dialog select {
font-family: dosvga;
font-size: 1em;
letter-spacing: -1px;
background-color: #efefef;
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-hover.svg", await getFile("export/fullscreen-hover.svg", "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("qbjs.css", await getFile("export/qbjs.css", "text"));
zip.file("qb.js", await getFile("qb.js", "text"));

BIN
qbjs.woff2 Normal file

Binary file not shown.