diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/README.md b/README.md new file mode 100644 index 0000000..0730b46 --- /dev/null +++ b/README.md @@ -0,0 +1,208 @@ +# RetroTxt + +RetroTxt is a handy little extension that takes old fashioned text files and stylises them in a more pleasing visual format. Despite the web being built on text, web browsers are often incapable of accurately displaying texts written during the pre and early web eras. This is where RetroTxt comes in! It imports the text into a modern format, injects a font that mimics a chosen retro computer, then applies styling to improve the display and readability. It can also double up as a text viewer for your locally stored, off-line files and even serve as an NFO text viewer. + +In developing this extension I had a few goals in mind. + +* Make it simple, by focusing on the styling of the text rather than extensive, cryptic character conversion options. +* Make it text, to take advantage of the browser's text parsing and rendering features for resizing, styles, searchability and accessibility. +* Make it semi-automated, so you can configure it once and then forget. +* Make it convenient, by using context menus that contain some of the more useful features and options. +* Make it light, by using the recommended Chrome guidelines to have less impact on your browser resources. + +--- + +![Cows animated gif](assets/cows.gif) + +## Install +Chrome and compatible browsers (Vivaldi, Chromium) can install the extension using the Chrome Store. + +[RetroTxt on Chrome store](https://chrome.google.com/webstore/search/retrotxt) + +You can test your new RetroTxt install with the thousands of text files hosted at [textfiles.com](http://textfiles.com/directory.html) or with [Project Gutenberg's](http://www.gutenberg.org/catalog/) _plain text_ books. +## Requirements +Chrome __41__, newer or compatible browser. + +- Depends on JavaScript [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) introduced in Chrome 41. +- Uses the [V2 Options page](https://developer.chrome.com/extensions/optionsV2) introduced in Chrome 40. + +Tested on [Chrome](https://www.google.com/intl/en/chrome/browser/desktop/index.html) for Windows, [Chromium](https://www.chromium.org/Home) on Linux, [ChromeOS](https://www.chromium.org/chromium-os), [Vivaldi](https://vivaldi.com/) for Windows and Linux. + +## Options Help + +![Options screen capture](assets/options.png) + +######Show text and font information + +Reveals a small text header detailing the document size and font information. + +![80 x 39 VGA9 9x16](assets/readme-header_example.png) +[columns] x [lines] [font] [font width]x[font height] + +* _columns_ the number of characters per line. +* _lines_ the number of lines counted in the text. +* _font_ the font family currently in use. +* _font width_ the pixel width of each text character, all fonts are fixed, mono-spaced. +* _font height_ the pixel height of each text character. + +######Center alignment of text + +Centres the vertical and horizontal positioning of the text. + +######Font shadows + +Applies a subtle shadow effect to each character and glyph within the text. + +######Display formatting control codes as DOS CP-437 glyphs + +IBM's and MS-DOS's Code Page 437 has a few glyphs values that are normally reserved for document formatting (control characters). Enabling this will display these glyphs on-screen. +- ◘ _backspace_ +- ○ _tab_ +- ♪ _carriage return_ +- → _EOF_ (end of file) +- ⌂ _delete_ + +######Automatic detect & run RetroTxt on text files (experimental) + +Runs the extension in the background and applies RetroTxt on all text files encountered by Chrome. This offers a better user experience but unfortunately comes with some caveats due to limitations imposed by Chrome. + +1. It only works with files hosted on _web_ servers or those stored on your local computer and accessed using the `file:///` scheme. `ftp://` does not work. +2. RetroTxt can access web server meta-data describing the text encoding and general purpose of a file. So it is relatively accurate in discovering text files over the web. +3. `file:///` has no access to any meta-data nor can RetroTxt read the content of the file when it needs to, so instead it relies on a file extension blacklist. This, unfortunately, is less accurate and prone to false-positives. +4. `file:///` also cannot detect a file's character encoding and so RetroTxt may fail to correctly render newer Unicode texts. + +If RetroTxt inaccurately converts a text, you can disable RetroTxt character encoding conversion by right-clicking on the page and select __Text encoding__ from the __RetroTxt__ menu. Or you can also click the RetroTxt toolbar button ![insert capture here](assets/rt_button.png) to switch back to the original text. + +## Context Menu Help + +######Display + +- __Text and font information__ runs the Option _Show text and font information_ +- __Text alignment__ runs the Option _Center alignment of text_ +- __Font shadows__ runs the Option _Font shadows_ + + +- __MS-DOS__ +- __Web__ +- __Amiga__ +- __Apple II__ +- __Commodore 64__ + +Are coloured, retro computer font themes that _will overwrite_ your previously chosen selections done in the Options dialogue. + +- __Text encoding__ + +Available only from the page context menu, when you click this item the page will be refreshed. This enables you to disable the character encoding conversion that RetroTxt normally applies to text. This may be useful if RetroTxt mistakenly scrambles a Unicode text file or when you're trying to view text written in a non-English (Latin-1) code page. + +## Permissions + +RetroTxt requires __Read and change all your data on the websites that you visit__ access so it can apply its styling and rendering to text files hosted online. + +It also needs __Allow access to file URLs__ selected if you wish to use RetroTxt with text files stored on your local computer. + +When __Automatic detect & run RetroTxt on text files__ is enabled (it is by default). RetroTxt will make background `XMLHttpRequest()` `HEAD` requests to the opened websites you visit so it can fetch their `HTTP HEAD` responses. This meta-data is used to decide if the page is HTML or a text file and which character encoding is in use. + +## Q.A. + +#### Can I adjust the size of the font? + +You can adjust the _zoom_ of the font by using the __Ctrl +__ and __Ctrl -__ keys. + +#### Can I view files stored on my computer? + +By typing a path into the address bar, Chrome is quite happy to read files and directories stored locally on your computer. + +On Windows, for example, pasting `C:\Users\Ben\Downloads\myfile.txt` into Chrome will convert it to into a browser-friendly file URI and view the document in the browser. +``` +file:///C:/Users/Ben/Downloads/myfile.txt +``` + +You can also [browse your Windows drive](file:///C:/) or [your Linux and OSX drives](file:///). + +Chrome will need [__Allow access to the file URLs__ permission](chrome://extensions/) enabled if you want the __Automatic detect & run RetroTxt on text files__ feature to work with local files. If it is selected by default, you should reselect it so the permission is actually applied by Chrome. +![Allow access to the file URLs helper](assets/allow_access_to_file_urls.png) + +To make Chrome your default text file viewer in Windows. Right-click on your desktop and choose __text file__ under __New__. This creates the file `New Text Document.txt`. Right-click on the file, select __Choose another app__ (_Choose default program..._ in Windows 7) under __Open with__ item. Then under __Other options__ scroll down and select Chrome. + +#### Is the conversion and styling historically accurate? +Somewhat but it depends. The extension is English-centric, focusing on [CP-437](https://msdn.microsoft.com/en-us/goglobal/cc305156.aspx), [ISO 8850-15](https://msdn.microsoft.com/en-us/goglobal/cc305176) and [Windows 1252](https://msdn.microsoft.com/en-us/goglobal/cc305145) code page support. Text files written in character encodings for other European languages will mostly render but the text may not be accurate. Non-Latin based languages will probably be illegible. + +The extension uses TrueType fonts which are affected by the operating system's font smoothing effects; ClearType on Windows, Quartz in OS X and FreeType on Linux. The degree of the font modification depends on the effect applied and the colour combinations in use with the text. Darker backgrounds seem to suffer less than light ones. + +A number of fonts were designed for 40 columns (characters per line of text) but the extension doesn't enforce that limitation. + +The web browser and the operating system can make modifications the font width, height, and spacing for either accessibility or due to user applied themes. + +The Apple II, Commodore Amiga, Commodore 64, VGA LCD fonts were a bit small and have been up-sized by 1.5x. You can return these fonts to their original size by pressing __Ctrl -__ in Chrome and reducing the font size to _67%_. + +#### What text encodings are supported? +- UTF-8 Unicode (Windows, OS X, Linux) +- ISO/IEC 8859-15 (Windows, Commodore Amiga*, Linux) +- Windows 1252 (Windows) +- Code page 437 (PC/MS-DOS, NFO and ASCII text art) +- ASCII-1967/US-ASCII (Universal, American English legacy text) + + +*The Amiga uses 1987 ISO 8859-1 encoding, it's near identical to 1999 ISO 8859-15 except for [8 character differences](https://en.wikipedia.org/wiki/ISO/IEC_8859-15). + +###### Platform specific encodings that are not currently supported +- Mac OS Roman (Apple Macintosh) +- ATASCII (8-bit Atari computers) & Atari ST character set +- PETSCII (Commodore 8-bit computers) + + +#### Text is garbled +There could be a number of causes of this but generally it is related to the web server or browser choosing the incorrect character encoding for the file. You can manually switch this in Chrome. Click the Chrome menu icon ![Chrome menu icon example](assets/chrome_hotdog_menu.png) and select __Encoding__ from the __More tools__ menu. Choose a more suitable character encoding, but if you are not quite sure which one to use and you know the document is in English. First, try the __Unicode (UTF-8)__ then each of the other __Western__ options. + +You could also disable RetroTxt character encoding conversion by right-clicking on the page and select __Text encoding__ from the __RetroTxt__ page menu. + +![Context menu screen](assets/context_menu-text_encoding.png) + +## Known issues + +* Context and tool bar button menus actions don't always apply changes to existing tabs. Pressing __F5__ will refresh and update the tab. +* When using Chrome Developer Tools the font selection may not be applied to the text. + +## Possible future enhancements + +- The automatic opening of downloaded text files. +- Decent detection for text files already encoded as Unicode. +- ChromeOS support for local file browsing. +- Port to Firefox when its [Web Extensions API](https://wiki.mozilla.org/WebExtensions) is complete. +- Port to Edge when its Chrome compatible extension support is introduced. +- Asynchronous text encoding if native [async functions](http://tc39.github.io/ecmascript-asyncawait/) are eventually supported. +- ~~Overwrite the web server `content-disposition` header that forces the downloads of text files.~~ (discovered this is not possible with the Chrome extension API) + +## An important note about the license! + +While RetroTxt is covered under a [GNU Lesser General Public License v3.0](http://choosealicense.com/licenses/lgpl-3.0/), the included fonts __are not__. +You should read each individual font license that can be found in the `fonts/` subdirectory before redistribution. As some of the included collections do not permit the sale or modification of their fonts and packages. + +## Code page tables +- [ascii codes](http://www.ascii-codes.com/) +- [ASCII-1967/US-ASCII](http://0x6a.org/ASCII) +- [CP-437](https://msdn.microsoft.com/en-us/goglobal/cc305156) +- [ISO 8859-1](https://msdn.microsoft.com/en-us/goglobal/cc305167) +- [Windows 1252](https://msdn.microsoft.com/en-us/goglobal/cc305145) +- [Unicode](http://unicode-table.com/) + +## Credits +- RetroTxt by [Ben Garrett](http://bens.zone/) [:octocat:](https://github.com/bengarrett/) +- PC fonts [_The Ultimate Oldschool PC Font Pack_](http://int10h.org/oldschool-pc-fonts/) by Viler +- Apple II font [_Print Char 21_](http://www.kreativekorp.com/software/fonts/apple2.shtml) by Kreative Korp +- Commodore Amiga font [_Amiga 4ever_](http://www.freakyfonts.de/) by ck! +- Commodore 64 font [_C64 Pro Mono TrueType v1.2_](http://style64.org/c64-truetype) from Style + +## Favourite style +Currently, my favourite font style is the __Amstrad PC1512__ _narrow_ font using shadowing with the __Commodore 64__ colour theme. + +## Similar projects +##### ansilove +Is a collection of tools for various systems to convert many more formats of text art into PNG images. +- [ansilove.js](http://ansilove.github.io/ansilove.js/) (JavaScript) +- [ansilove](http://www.ansilove.org/) (PHP) +- [AnsiLove/C](https://github.com/ansilove/ansilove) (Linux, OS X, Unix) + +##### PabloDraw +_PabloDraw is an Ansi/Ascii text and RIPscrip vector graphic art editor/viewer with multi-user capabilities._ +- [PabloDraw](http://picoe.ca/products/pablodraw/) (Windows, OS X and Linux) \ No newline at end of file diff --git a/_locales/en_GB/messages.json b/_locales/en_GB/messages.json new file mode 100644 index 0000000..552b7b7 --- /dev/null +++ b/_locales/en_GB/messages.json @@ -0,0 +1,11 @@ +{ + "color": { + "message": "colour" + }, + "center": { + "message": "centre" + }, + "gray_white_option": { + "message": "DOS grey on white" + } +} \ No newline at end of file diff --git a/_locales/en_US/messages.json b/_locales/en_US/messages.json new file mode 100644 index 0000000..672092c --- /dev/null +++ b/_locales/en_US/messages.json @@ -0,0 +1,14 @@ +{ + "color": { + "message": "color" + }, + "center": { + "message": "center" + }, + "gray_white_option": { + "message": "DOS gray on white" + }, + "url_help": { + "message": "https://github.com/bengarrett/RetroTxt/blob/master/README.md" + } +} \ No newline at end of file diff --git a/assets/RetroTxt-128.png b/assets/RetroTxt-128.png new file mode 100644 index 0000000..1ed1d81 Binary files /dev/null and b/assets/RetroTxt-128.png differ diff --git a/assets/RetroTxt-16.png b/assets/RetroTxt-16.png new file mode 100644 index 0000000..e4cc513 Binary files /dev/null and b/assets/RetroTxt-16.png differ diff --git a/assets/RetroTxt-19.png b/assets/RetroTxt-19.png new file mode 100644 index 0000000..b45b434 Binary files /dev/null and b/assets/RetroTxt-19.png differ diff --git a/assets/RetroTxt-32.png b/assets/RetroTxt-32.png new file mode 100644 index 0000000..b6f13d3 Binary files /dev/null and b/assets/RetroTxt-32.png differ diff --git a/assets/RetroTxt-38.png b/assets/RetroTxt-38.png new file mode 100644 index 0000000..b0a37a4 Binary files /dev/null and b/assets/RetroTxt-38.png differ diff --git a/assets/RetroTxt-48.png b/assets/RetroTxt-48.png new file mode 100644 index 0000000..442a81a Binary files /dev/null and b/assets/RetroTxt-48.png differ diff --git a/assets/allow_access_to_file_urls.png b/assets/allow_access_to_file_urls.png new file mode 100644 index 0000000..73464c4 Binary files /dev/null and b/assets/allow_access_to_file_urls.png differ diff --git a/assets/chrome_hotdog_menu.png b/assets/chrome_hotdog_menu.png new file mode 100644 index 0000000..4d36151 Binary files /dev/null and b/assets/chrome_hotdog_menu.png differ diff --git a/assets/context_menu-text_encoding.png b/assets/context_menu-text_encoding.png new file mode 100644 index 0000000..116f3ff Binary files /dev/null and b/assets/context_menu-text_encoding.png differ diff --git a/assets/cows.gif b/assets/cows.gif new file mode 100644 index 0000000..4b8181a Binary files /dev/null and b/assets/cows.gif differ diff --git a/assets/options.png b/assets/options.png new file mode 100644 index 0000000..781f6fc Binary files /dev/null and b/assets/options.png differ diff --git a/assets/readme-header_example.png b/assets/readme-header_example.png new file mode 100644 index 0000000..90f2b87 Binary files /dev/null and b/assets/readme-header_example.png differ diff --git a/assets/rt_button.png b/assets/rt_button.png new file mode 100644 index 0000000..388f3c8 Binary files /dev/null and b/assets/rt_button.png differ diff --git a/eventPage.js b/eventPage.js new file mode 100644 index 0000000..3170c23 --- /dev/null +++ b/eventPage.js @@ -0,0 +1,709 @@ +"use strict"; + +function clickRetroTxt(tab) +// Chrome tool bar button click callback to execute RetroText +// @tab Required tab information object otherwise the function will do nothing +{ + if (typeof tab === "object" && typeof tab.url === "string" && tab.url.length > -1) { + if (typeof tab.id === "number" && tab.id > 0) { + var evalText = sessionStorage.getItem("retroTxt" + tab.id + "isText"); + if (typeof evalText !== "string") { + // determine if active tab is a text file and save the results to a sessionStore + // so we do not create unnecessary future HTTP HEAD requests + var url = new handleURL(tab.url); + sessionStorage.setItem("retroTxt" + tab.id + "isText", url.isTextFile); + sessionStorage.setItem("retroTxt" + tab.id + "encoding", url.encoding); + } else { + var url = new handleURL(); + url.isTextFile = evalText; + } + } + if (url.isTextFile == "true") { + chrome.tabs.executeScript(null, { + file: "functions.js" + }); + chrome.tabs.executeScript(null, { + file: "text.js" + }, + function(results) { + // has to be run after text.js is loaded + chrome.tabs.executeScript(null, { + code: "exeRetroTxt()", + runAt: "document_end" + }); + }); + } + } + +} + +function tabRetroTxt(encoding) +// Chrome tab callback to execute RetroText +// @encoding Optional string to state the text's encoding +{ + if (typeof encoding !== "string") encoding = ""; + chrome.tabs.executeScript(null, { + file: "functions.js" + }); + chrome.tabs.executeScript(null, { + file: "text.js" + }, + // automatic execute + function(results) { + // has to be run after text.js is loaded + switch (encoding.toLowerCase) { + case "utf-8": + chrome.tabs.executeScript(null, { + code: "exeRetroTxt('tab-UTF8')", + runAt: "document_end" + }); + break; + default: + chrome.tabs.executeScript(null, { + code: "exeRetroTxt('tab-unknown')", + runAt: "document_end" + }); + break; + }; + }); +} + +function contSaveMSDOS() { + chrome.storage.local.set({ + 'retroFont': "vga9" + }); + chrome.storage.local.set({ + 'retroColor': "gray-black" + }); +} + +function contSaveWeb() { + chrome.storage.local.set({ + 'retroFont': "vga9" + }); + chrome.storage.local.set({ + 'retroColor': "black-white" + }); +} + +function contSaveAmiga() { + chrome.storage.local.set({ + 'retroFont': "amiga" + }); + chrome.storage.local.set({ + 'retroColor': "amigaWhite-amigaGray" + }); +} + +function contSaveAppleII() { + chrome.storage.local.set({ + 'retroFont': "appleii" + }); + chrome.storage.local.set({ + 'retroColor': "appleiiGreen-appleiiBlack" + }); +} + +function contSaveC64() { + chrome.storage.local.set({ + 'retroFont': "c64" + }); + chrome.storage.local.set({ + 'retroColor': "c64fg-c64bg" + }); +} + +function contSaveInfo() { + chrome.storage.local.get("textFontInformation", function(result) { + var r = result.textFontInformation; + if (typeof r !== "boolean") r = true; + chrome.storage.local.set({ + 'textFontInformation': !r + }); + }); +} + +function contSaveAlignment() { + chrome.storage.local.get("centerAlignment", function(result) { + var r = result.centerAlignment; + if (typeof r !== "boolean") r = true; + chrome.storage.local.set({ + 'centerAlignment': !r + }); + }); +} + +function contSaveShadows() { + chrome.storage.local.get("fontShadows", function(result) { + var r = result.fontShadows; + if (typeof r !== "boolean") r = true; + chrome.storage.local.set({ + 'fontShadows': !r + }); + }); +} + +function handleURL(url, tabid) +// Handle the URL depending on its scheme and http data as +// RetroTxt only works with plain text files. +// Chrome event pages cannot read the content of the active tab. +// @url URL +// @tabId Optional tabid number +{ + // if no url given then return an empty prototype + if (typeof url === "undefined" || typeof url !== "string") { + this.isTextFile = null; + this.encoding = null; + return; + } + if (typeof tabid !== "number") tabid = 0; + + function extMatch(url, exts) + // Returns a boolean on whether the file name extension matches the supplied array + // @url URI containing the file name + // @exts Array of file name extensions to compare + { + var split, ext; + split = url.split("."); + ext = split[split.length - 1]; + if (exts.indexOf(ext) >= 0) { + return true; + } else { + return false; + } + } + + var lastChr, scheme, r, + ext, ignoreExt = ["css", "htm", "html", "ini", "js", "json", "md", "xml", "yml"], + textFile = false, + textEncoding = "other"; + scheme = url.split(":")[0]; + switch (scheme) { + case "chrome": + case "chrome-extension": + case "chrome-extension-resource": + case "data": + // these are not text files so do nothing + break; + case "file": + // all local files viewable in Chrome are assumed to be text + var e = url.length, + s = (parseInt(e) - 1); + lastChr = url.slice(s, e); + // if last character is forward slash / then assume it's a local + // directory and not a file, so don't run retroTxt(). + if (lastChr !== "/") { + // detect file extension from ignore list. + // because we used an ignore list, we store the opposite (! not) result + textFile = !extMatch(url, ignoreExt); + } + break; + case "ftp": + // not supported + break; + case "http": + case "https": + // test to see if url points to a text file + // XMLHttpRequest() to obtain HTTP header info such as file encoding & + // file type, it unfortunately only works with HTTP/HTTPS + var xhttp, xstatus; + xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + + // Request finished + if (xhttp.readyState == 4) { + xstatus = xhttp.status.toString(); + // success response + if (xhttp.status == 200) { + r = new httpHandler(xhttp); + if (r.isText) { + textFile = true; + textEncoding = r.encode; + } + } + // If response is a client error but not 404 file not found + else if (xhttp.status != 404 && xstatus.slice(0, 1) == 4) { + // some servers block http head requests so we fall back + // and review the file name extension, though this method is unreliable + var whiteListExt = ["asc", "ascii", "diz", "faq", "nfo", "text", "txt"]; + textFile = extMatch(url, whiteListExt); + //console.log("White list extension match? " + textFile); + } + } + }; + xhttp.open("HEAD", url, false); // false = a synchronous request, it may not work in the future + xhttp.send(); + + function httpHandler(xhttp) + // Handles the HTTP Request and determines if it is a text file + // @xhttp XMLHttpRequest() response + { + var content = new parseContentType(xhttp.getResponseHeader("Content-Type")), + firstChr, + r = false, + text = xhttp.responseText.trim(); + firstChr = text.split(0, 1); + if (content.type !== null) { + if (content.type === "text") r = true; + if (content.subtype !== "plain") r = false; + } + // xhttp.open("HEAD", url, false) returns an empty responseText value + // (but saves bandwidth). So to enable this 'is first character a ?' check, + // replace the xhttp method with xhttp.open("GET", url, false) + else if (firstChr !== "<") { + // if no content-type given by server & first character is not the start of a tag < + // then assume it's a text file + r = true; + } + this.isText = r; + this.encode = content.encoding; + } + break; + } + this.isTextFile = textFile; + this.encoding = textEncoding; +} + +function parseContentType(response) +// Parse HTTP response header Content-Type +// i.e. Content-Type: text/html; charset=iso-8859-1 +{ + var content, + subtype = null, + type = null, + charset = null; + if (typeof response === "string") { + content = response; + try { + content = content.split(";"); + } catch (err) { + return; + } + try { + type = content[0].split("/")[0]; // text + subtype = content[0].split("/")[1]; // html + } catch (err) {} + try { + charset = content[1].split("=")[1]; // iso-8859-1 + } catch (err) {} + } + this.type = type; + this.subtype = subtype; + this.encoding = charset; +} + +/* Context Menus */ +// https://developer.chrome.com/extensions/contextMenus + +function switchMenus(evt, state) +// Updates the context menus to either enabled or disabled +// @evt Required event name used by the context menu's identification +// @state Required boolean to enable or disable the context menu +{ + try { + if (typeof evt !== "string" || evt.length < 1) throw "'evt' is missing but is a required string"; + if (typeof state !== "boolean") throw "'state' is a required boolean used to enable or disable the context menus"; + } catch (err) { + console.error("switchMenus(evt, state) parameter " + err); + return; + } + //console.log("Switch menu state? " + state); + if (state === "true") return; + var id, menuid, + ids = ["displaysub", "sep1", "infotext", "centertext", "shadowtext", "msdos", "web", "amiga", "appleii", "c64", "sep2", "abortEncoding"]; + for (id in ids) { + menuid = ids[id]; + chrome.contextMenus.update(menuid, { + "enabled": state + }); + } +} + +function buildMenus(evt, contexts) +// Creates the context menus +// @evt Event name used by the context menu's identification +// @contexts An object containing a collection of contextMenus context values +{ + try { + if (typeof evt !== "string" || evt.length < 1) throw "'evt' is missing but is a required string" + if (typeof contexts !== "object" || contexts.length < 1) throw "'contexts' is missing but is a required object containing a collection of Chrome contextMenus, contexts values" + } catch (err) { + console.error("buildMenus(evt, contexts) parameter " + err); + return; + } + var docMatches = ["*://*/*", "file:///*"]; // matches HTTP, HTTPS, FILE + chrome.contextMenus.create({ + "title": "Options", + "contexts": ["page"], + "documentUrlPatterns": docMatches, + "id": "options" + }); + chrome.contextMenus.create({ + "title": "Help", + "contexts": ["browser_action"], + "documentUrlPatterns": docMatches, + "id": "helpbrowser" + }); + chrome.contextMenus.create({ + "title": "Display", + "contexts": contexts, + "documentUrlPatterns": docMatches, + "id": "displaysub" + }); + chrome.contextMenus.create({ + "type": "separator", + "documentUrlPatterns": docMatches, + "id": "sep1" + }); + chrome.contextMenus.create({ + "title": "Text and font information", + "contexts": contexts, + "id": "infotext", + "parentId": "displaysub", + "documentUrlPatterns": docMatches + }); + chrome.contextMenus.create({ + "title": "Text alignment", + "contexts": contexts, + "id": "centertext", + "parentId": "displaysub", + "documentUrlPatterns": docMatches + }); + chrome.contextMenus.create({ + "title": "Font shadows", + "contexts": contexts, + "id": "shadowtext", + "parentId": "displaysub", + "documentUrlPatterns": docMatches + }); + chrome.contextMenus.create({ + "title": "MS-DOS", + "contexts": contexts, + "id": "msdos", + "documentUrlPatterns": docMatches + }); + chrome.contextMenus.create({ + "title": "Web", + "contexts": contexts, + "id": "web", + "documentUrlPatterns": docMatches + }); + chrome.contextMenus.create({ + "title": "Amiga", + "contexts": contexts, + "documentUrlPatterns": docMatches, + "id": "amiga" + }); + chrome.contextMenus.create({ + "title": "Apple II", + "contexts": contexts, + "documentUrlPatterns": docMatches, + "id": "appleii" + }); + chrome.contextMenus.create({ + "title": "Commodore 64", + "contexts": contexts, + "documentUrlPatterns": docMatches, + "id": "c64" + }); + chrome.contextMenus.create({ + "type": "separator", + "contexts": ["page"], + "documentUrlPatterns": docMatches, + "id": "sep2" + }); + chrome.contextMenus.create({ + "title": "Text encoding", + "contexts": contexts, + "documentUrlPatterns": docMatches, + "id": "abortEncoding" + }); + chrome.contextMenus.create({ + "title": "Help", + "contexts": ["page"], + "documentUrlPatterns": docMatches, + "id": "helppage" + }); +} + +(function() { + // Contexts types for RetroTxt's context menus + // browser_action, tool bar button + // page, right click on the body of the web page / text file + var contexts = ["browser_action", "page"]; // add more context types here + + function eventHandleUrl(menuId, url, tabid) + // Used with events listeners, this decides whether to create context menus + // and whether to run RetroTxt. As determined by the URL of the active Chrome tab. + // @url URL to check + // @menuId The name of the initial event that created the context menu + // @tabId Optional tab ID used for ticking off tabs that have been processed + { + try { + if (typeof menuId !== "string" || menuId.length < 1) throw "'menuId' is missing, it needs to be the context menu ID" + if (typeof url !== "string" || url.length < 1) throw "'url' is missing, it needs to be a URL of the active Chrome tab" + } catch (err) { + console.error("eventHandleUrl(menuId, url, tabid) parameter " + err); + return; + } + if (typeof tabid !== "number") tabid = 0; + + // attempt to work out if URL points to a text file + var u = new handleURL(url, tabid); + sessionStorage.setItem("retroTxt" + tabid + "isText", u.isTextFile); + sessionStorage.setItem("retroTxt" + tabid + "encoding", u.encoding); + + var scheme = url.split(":")[0]; // discover the [scheme]:// of the URL + if (!u.isTextFile) { + switchMenus(menuId, false); + chrome.browserAction.disable(tabid); + } else { + switchMenus(menuId, true); + chrome.browserAction.enable(tabid); + // automatically run retroTxt // + // is automatic execution of RetroTxt disabled? + var run = localStorage.getItem("autoDetectRun"); + if (typeof run !== "string" || run === "false") return; // abort + + // check optional permissions for access to 'file://*/' + if (scheme === "file") { + chrome.permissions.contains({ + permissions: ['tabs'], + origins: ['file:///*'] + }, function(result) { + if (result) { + tabRetroTxt(); + } + }); + } + // other schemes do not need permission for access + else { + if (u.encoding === "utf-8") tabRetroTxt(u.encoding); + else tabRetroTxt(); + } + } + } + + // Set default options for first-time users + // see options.js for other similar listeners + chrome.runtime.onInstalled.addListener(function() { + chrome.storage.local.get("retroColor", function(result) { + var r = result.retroColor; + if (typeof r !== "string") { + chrome.storage.local.set({ + 'retroColor': "gray-black" + }); + } + }); + chrome.storage.local.get("retroFont", function(result) { + var r = result.retroFont; + if (typeof r !== "string") { + chrome.storage.local.set({ + 'retroFont': "vga8" + }); + } + }); + chrome.storage.local.get("textFontInformation", function(result) { + var r = result.textFontInformation; + if (typeof r !== "boolean") { + chrome.storage.local.set({ + 'textFontInformation': true + }); + } + }); + chrome.storage.local.get("centerAlignment", function(result) { + var r = result.centerAlignment; + if (typeof r !== "boolean") { + chrome.storage.local.set({ + 'centerAlignment': true + }); + } + }); + chrome.storage.local.get("fontShadows", function(result) { + var r = result.fontShadows; + if (typeof r !== "boolean") { + chrome.storage.local.set({ + 'fontShadows': false + }); + } + }); + chrome.storage.local.get("cp437CtrlCodes", function(result) { + var r = result.cp437CtrlCodes; + if (typeof r !== "boolean") { + chrome.storage.local.set({ + 'cp437CtrlCodes': false + }); + } + }); + chrome.storage.local.get("autoDetectRun", function(result) { + var r = result.autoDetectRun; + if (typeof r !== "boolean") { + r = true; + chrome.storage.local.set({ + 'autoDetectRun': r + }); + } + // Also set session storage + localStorage.setItem("autoDetectRun", r); + }); + }); + + // on Chrome tab activated listener + chrome.tabs.onActivated.addListener(function(activeInfo) { + //console.log("Activated tab id " + activeInfo.tabId); + var sessIsText = sessionStorage.getItem("retroTxt" + activeInfo.tabId + "isText"); + if (typeof sessIsText === "string") { + if (sessIsText === "true") { + sessIsText = true; + chrome.browserAction.enable(activeInfo.tabId); + } else if (sessIsText === "false") { + sessIsText = false; + chrome.browserAction.disable(activeInfo.tabId); + } + switchMenus("onInstalled", sessIsText); + + return; // abort + } + chrome.tabs.query({ + 'active': true, + 'lastFocusedWindow': true + }, function(tabs) { + if (typeof tabs === "object") { + var url = tabs[0].url; + eventHandleUrl("onInstalled", url, tabs[0].id); + } + }); + }); + + // on Chrome tab created listener + chrome.tabs.onCreated.addListener(function(tab) { + //console.log("Created new tab with id " + tab.id); + chrome.tabs.query({ + 'active': true, + 'lastFocusedWindow': true + }, function(tabs) { + if (typeof tabs === "object") { + var url = tabs[0].url; + eventHandleUrl("onInstalled", url, tabs[0].id); + } + }); + }); + + // on Chrome tab updated listener + // updated listener is needed for when a tab is refreshed + chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { + // many web apps also trigger this listener so we must make sure the tab + // is activate and not running in the background + if (typeof tab !== "object" || tab.active !== true) return; // abort + chrome.tabs.query({ + 'active': true, + 'lastFocusedWindow': true + }, function(tabs) { + if (typeof tabs === "object" && typeof tabs[0] === "object") { + var tabid = tabs[0].id, + url = tabs[0].url; + eventHandleUrl("onInstalled", url, tabid); + } + }); + }); + + // on Chrome tab close listener + chrome.tabs.onRemoved.addListener(function(tabId, changeInfo) { + //console.log("Closed tab with id " + tabId); + // Clean up loose sesssionStorage + var sessIsText = sessionStorage.getItem("retroTxt" + tabId + "isText"), + sessEncoding = sessionStorage.getItem("retroTxt" + tabId + "encoding"); + if (typeof sessIsText === "string") sessionStorage.removeItem("retroTxt" + tabId + "isText"); + if (typeof sessEncoding === "string") sessionStorage.removeItem("retroTxt" + tabId + "encoding"); + }); + + // Copy autoDetectRun to localStorage for use with all the Chrome tabs + chrome.storage.local.get("autoDetectRun", function(result) { + var r = result.autoDetectRun; + if (typeof r !== "boolean") r = true; + localStorage.setItem("autoDetectRun", r); + }); + + // Build context menu on Chrome launch and extension load + chrome.runtime.onInstalled.addListener(function() { + buildMenus("onInstalled", contexts); + }); + + // Browser action (tool bar button) onClick event + chrome.browserAction.onClicked.addListener(function(tab) { + var scheme = tab.url.split(":")[0].toLowerCase(), + okaySchemes = ["http", "https", "ftp", "file"], + valid = okaySchemes.indexOf(scheme); + if (valid > -1) { + //console.log("Toolbar tab " + tab.id + " was clicked. Is scheme valid? " + valid); + clickRetroTxt(tab); + } + }); + + // Context menus onClick events + chrome.contextMenus.onClicked.addListener(function(info, tab) { + var autorun = localStorage.getItem("autoDetectRun"); + switch (info.menuItemId) { + case "options": + chrome.runtime.openOptionsPage(); + break; + case "infotext": + contSaveInfo(); + break; + case "centertext": + contSaveAlignment(); + break; + case "shadowtext": + contSaveShadows(); + break; + case "msdos": + contSaveMSDOS(); + break; + case "web": + contSaveWeb(); + break; + case "amiga": + contSaveAmiga(); + break; + case "appleii": + contSaveAppleII(); + break; + case "c64": + contSaveC64(); + break; + case "abortEncoding": + // http://stackoverflow.com/questions/14245334/chrome-extension-sendmessage-from-background-to-content-script-doesnt-work + chrome.tabs.query({ + active: true, + currentWindow: true + }, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { + action: "abortEncoding", + id: "abortEncoding" + }, function() { + //console.log("Abort text encoding request sent"); + }); + }); + break; + case "helpbrowser": + case "helppage": + chrome.tabs.create({ + "url": chrome.i18n.getMessage("url_help") + }); + break; + } + // If a theme option is clicked while viewing the browser default text + // then we should also apply the new theme. + if (typeof autorun !== "string" || autorun === "false") { + switch (info.menuItemId) { + case "msdos": + case "web": + case "amiga": + case "appleii": + case "c64": + tabRetroTxt(tab); + break; + } + } + }); +})(); \ No newline at end of file diff --git a/fonts/Amiga/AMIGA.FON b/fonts/Amiga/AMIGA.FON new file mode 100644 index 0000000..cb4ec80 Binary files /dev/null and b/fonts/Amiga/AMIGA.FON differ diff --git a/fonts/Amiga/Amiga.gif b/fonts/Amiga/Amiga.gif new file mode 100644 index 0000000..b1ba48f Binary files /dev/null and b/fonts/Amiga/Amiga.gif differ diff --git a/fonts/Amiga/Readme.html b/fonts/Amiga/Readme.html new file mode 100644 index 0000000..a3dd38a --- /dev/null +++ b/fonts/Amiga/Readme.html @@ -0,0 +1,51 @@ + + +www.freakyfonts.de + + + + +

 >> Amiga 4ever
+
+ + Amiga 4ever + Truetype Font Family, based on the Amiga OS 3.x rom font
+Copyright (c) 2001 by ck! [Freaky Fonts]. + All rights reserved.
+
+ The personal, non-commercial use of my font is free.
+ But Donations are accepted and highly appreciated!
+ The use of my fonts for commercial and profit purposes is prohibited,
+ unless a small donation is send to me.
+ Contact: ck@freakyfonts.de
+ These font files may not be modified or renamed.
+ This readme file must be included with each font, unchanged.
+ Redistribute? Sure, but contact me first.
+
+ If you like the font, please mail: + ck@freakyfonts.de
+
+ Visit .:Freaky Fonts:. for updates and new + fonts (PC & MAC) :
+ www.freakyfonts.de
+ www.geocities.com/Area51/Shadowlands/7677/
+
+ Thanks again to {ths} for the Mac conversion.
+ 1@ths.nu or visit: www.ths.nu
+
+ Note:
+
Photoshop + use: Size 8 (& multiplier) - antialising turned off
+
Paintshop use: Size 6 (& multiplier) - antialising turned off
+Amiga 4ever = like the original, 8x8 + - sideborder vary
+Amiga 4ever pro = modified, mainly 2 pixel sideborder
+Amiga 4ever pro2 = ... mainly 1 pixel sideborder
+
+ + This font includes some dingbats, cut & paste:
+ + + All trademarks are property of their respective owners.

+ + diff --git a/fonts/Amiga/Readme.txt b/fonts/Amiga/Readme.txt new file mode 100644 index 0000000..3923da7 --- /dev/null +++ b/fonts/Amiga/Readme.txt @@ -0,0 +1,29 @@ +"Amiga 4ever" Truetype Font +Copyright (c) 2001 by ck! [Freaky Fonts]. All rights reserved. + +The personal, non-commercial use of my font is free. +But Donations are accepted and highly appreciated! +The use of my fonts for commercial and profit purposes is prohibited, +unless a small donation is send to me. +Contact: ck@freakyfonts.de +These font files may not be modified or renamed. +This readme file must be included with each font, unchanged. +Redistribute? Sure, but contact me first. + +If you like the font, please mail: ck@freakyfonts.de + +Visit .:Freaky Fonts:. for updates and new fonts (PC & MAC) : +www.freakyfonts.de +www.geocities.com/Area51/Shadowlands/7677/ + +Thanks again to {ths} for the Mac conversion. +1@ths.nu or visit: www.ths.nu + +Note: +Photoshop use: Size 8 (& multiplier) - antialising turned off +Paintshop use: Size 6 (& multiplier) - antialising turned off +Amiga 4ever = like the original, 8x8 - sideborder vary +Amiga 4ever pro = modified, mainly 2 pixel sideborder +Amiga 4ever pro2 = ... mainly 1 pixel sideborder +This font includes some dingbats, cut & paste: +All trademarks are property of their respective owners. diff --git a/fonts/Amiga/amiga4ever.gif b/fonts/Amiga/amiga4ever.gif new file mode 100644 index 0000000..eb95769 Binary files /dev/null and b/fonts/Amiga/amiga4ever.gif differ diff --git a/fonts/Amiga/amiga4ever.ttf b/fonts/Amiga/amiga4ever.ttf new file mode 100644 index 0000000..ada736f Binary files /dev/null and b/fonts/Amiga/amiga4ever.ttf differ diff --git a/fonts/Amiga/amiga4ever_pro.ttf b/fonts/Amiga/amiga4ever_pro.ttf new file mode 100644 index 0000000..63bf214 Binary files /dev/null and b/fonts/Amiga/amiga4ever_pro.ttf differ diff --git a/fonts/Amiga/amiga4ever_pro2.ttf b/fonts/Amiga/amiga4ever_pro2.ttf new file mode 100644 index 0000000..6a9b293 Binary files /dev/null and b/fonts/Amiga/amiga4ever_pro2.ttf differ diff --git a/fonts/AppleII/FreeLicense.txt b/fonts/AppleII/FreeLicense.txt new file mode 100644 index 0000000..09450f2 --- /dev/null +++ b/fonts/AppleII/FreeLicense.txt @@ -0,0 +1,20 @@ +KREATIVE SOFTWARE RELAY FONTS FREE USE LICENSE +version 1.2f + +Permission is hereby granted, free of charge, to any person or entity (the "User") obtaining a copy of the included font files (the "Software") produced by Kreative Software, to utilize, display, embed, or redistribute the Software, subject to the following conditions: + +1. The User may not sell copies of the Software for a fee. + +1a. The User may give away copies of the Software free of charge provided this license and any documentation is included verbatim and credit is given to Kreative Korporation or Kreative Software. + +2. The User may not modify, reverse-engineer, or create any derivative works of the Software. + +3. Any Software carrying the following font names or variations thereof is not covered by this license and may not be used under the terms of this license: Jewel Hill, Miss Diode n Friends, This is Beckie's font! + +3a. Any Software carrying a font name ending with the string "Pro CE" is not covered by this license and may not be used under the terms of this license. + +4. This license becomes null and void if any of the above conditions are not met. + +5. Kreative Software reserves the right to change this license at any time without notice. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE SOFTWARE OR FROM OTHER DEALINGS IN THE SOFTWARE. diff --git a/fonts/AppleII/PRNumber3.ttf b/fonts/AppleII/PRNumber3.ttf new file mode 100644 index 0000000..d4ff1a1 Binary files /dev/null and b/fonts/AppleII/PRNumber3.ttf differ diff --git a/fonts/AppleII/PrintChar21.ttf b/fonts/AppleII/PrintChar21.ttf new file mode 100644 index 0000000..91f8438 Binary files /dev/null and b/fonts/AppleII/PrintChar21.ttf differ diff --git a/fonts/Commodore64/STYLE.nfo b/fonts/Commodore64/STYLE.nfo new file mode 100644 index 0000000..11ab983 --- /dev/null +++ b/fonts/Commodore64/STYLE.nfo @@ -0,0 +1,136 @@ + + + ۰ ۱ + ۲ + ۲ + ۲ ۲ + ۱ ۲ + ۱ ۲ + ۰ ۲ + ۲ + ۲ + ۱ + ۲ ۱ + ۱ + ۰ + + + + + ۲ + ۱ + ۱ + ۰ + + + ۲ + ۲ + ۱ + ۰ + + + + + ۲ + ۲ + ۲ + + ۰ ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۲ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + ۰ ۰ ۰ ۰ ۰ + + + title: C64 TrueType v1.2 type: fonts + date: September 2, 2014 platform: Any OS/web + + + Welcome to the second release and first major update + (since 2010) of our C64 TrueType font package. Note + that there was no v1.1 release. This version brings + updates to two of the faces, C64 Pro Mono and C64 + Pro, the variable pitch version of the legendary + character set: + + * Both fonts: + > corrected a couple Unicode mappings + > added a couple missing Mac Roman mappings for + anyone still using pre-OSX fruit + > some name table updates re: version and font + family to maximize compatibility + > added mappings to conform with Apple/MS + TrueType recommendations re: $00-$1f + > now includes the 'Direct PETSCII' mappings + ($e0xx/$e1xx) that were previously only found + in C64 Elite Mono from the v1.0 package + > added SVG and WOFF2 variants + + * C64 Pro: + > corrected bullet, pipe (VERTICAL LINE) + bearing/width + > removed some Unicode "spacing" glyphs that + didn't fall on even 'pixel' boundaries + + We didn't update C64 User, C64 User Mono, or C64 + Elite, choosing instead to simplify and focus on + the Pro faces. C64 Elite was our answer to the + potential complaint that our other font faces + contained more than the bare minimum 304 glyphs + and was meant to be a smaller file for programmatic + use. C64 User was meant to be a small font for + people who only wanted to produce documents with + the glyphs that reasonably map to ASCII, CP-1252 + and Mac Roman - that is, none of the extra PETSCII + graphical characters. If those fonts previously + included in v1.0 are working well for whatever your + usage entails there is no reason you need to switch. + But C64 Pro Mono is now a superset of C64 Elite and + still not much larger thanks to compositing + optimizations while C64 Pro is a superset of + C64 User. + + Note also that DirMaster v3.x uses the C64 Pro Mono + font face. The DirMaster installer should provide + that font, but the version included in this package + is compatible as well. + + Known issue: the SVG files are quite large (many + redundant nodes) and could possibly be optimized; + but SVG fonts are on their way out and gzipping + from the server side should bring them back to a + very reasonable size anyway. + + + For more information: + + http://style64.org/c64-truetype + + http://style64.org/c64-truetype/license + + http://style64.org/petscii + + + Greetings + + NTSC: FTA, RPG, FOE, UDI, Arkanix Labs, Retro64, + PSW, Krionyx, Venom, Carcass, Electron + + PAL: Censor Design, Scene World staff + + PC: Deathy/Brainstorm, Vintage + + + Keep scene spirit alive! + diff --git a/fonts/Commodore64/file_id.diz b/fonts/Commodore64/file_id.diz new file mode 100644 index 0000000..2394788 --- /dev/null +++ b/fonts/Commodore64/file_id.diz @@ -0,0 +1,16 @@ + + + C64 TrueType v1.2/Style + + + ۲ + ۱ ܰ release type: + ۰ ߰ fonts + ۲ + ۲ for platform: + ۱ Any OS/web + ۰ + released on: + 2014-09-02 + + [01/01] diff --git a/fonts/Commodore64/fonts/C64_Pro-STYLE.eot b/fonts/Commodore64/fonts/C64_Pro-STYLE.eot new file mode 100644 index 0000000..cbcf7ce Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro-STYLE.eot differ diff --git a/fonts/Commodore64/fonts/C64_Pro-STYLE.svg b/fonts/Commodore64/fonts/C64_Pro-STYLE.svg new file mode 100644 index 0000000..7074f28 --- /dev/null +++ b/fonts/Commodore64/fonts/C64_Pro-STYLE.svg @@ -0,0 +1,1488 @@ + + + + +Created by FontForge 20131121 at Sun Aug 31 13:18:44 2014 + +(c) 2010-2014, Style. (http://style64.org) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fonts/Commodore64/fonts/C64_Pro-STYLE.ttf b/fonts/Commodore64/fonts/C64_Pro-STYLE.ttf new file mode 100644 index 0000000..75d78e9 Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro-STYLE.ttf differ diff --git a/fonts/Commodore64/fonts/C64_Pro-STYLE.woff b/fonts/Commodore64/fonts/C64_Pro-STYLE.woff new file mode 100644 index 0000000..3c40ba1 Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro-STYLE.woff differ diff --git a/fonts/Commodore64/fonts/C64_Pro-STYLE.woff2 b/fonts/Commodore64/fonts/C64_Pro-STYLE.woff2 new file mode 100644 index 0000000..bf0d7ba Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro-STYLE.woff2 differ diff --git a/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.eot b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.eot new file mode 100644 index 0000000..f6ebf61 Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.eot differ diff --git a/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.svg b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.svg new file mode 100644 index 0000000..f086089 --- /dev/null +++ b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.svg @@ -0,0 +1,1495 @@ + + + + +Created by FontForge 20131121 at Sun Aug 31 02:43:58 2014 + +(c) 2010-2014, Style. (http://style64.org) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.ttf b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.ttf new file mode 100644 index 0000000..3e1a82a Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.ttf differ diff --git a/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.woff b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.woff new file mode 100644 index 0000000..3bcbea3 Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.woff differ diff --git a/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.woff2 b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.woff2 new file mode 100644 index 0000000..69d0fbd Binary files /dev/null and b/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.woff2 differ diff --git a/fonts/Commodore64/fonts/test-eot.html b/fonts/Commodore64/fonts/test-eot.html new file mode 100644 index 0000000..36aad25 --- /dev/null +++ b/fonts/Commodore64/fonts/test-eot.html @@ -0,0 +1,266 @@ + + + + C64 Pro Mono: EOT (Embedded OpenType) test + + + + + + + +
+ + + + +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/fonts/Commodore64/fonts/test-svg.html b/fonts/Commodore64/fonts/test-svg.html new file mode 100644 index 0000000..5bdf4cf --- /dev/null +++ b/fonts/Commodore64/fonts/test-svg.html @@ -0,0 +1,266 @@ + + + + C64 Pro Mono: SVG (Scalable Vector Graphics) test + + + + + + + +
+ + + + +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/fonts/Commodore64/fonts/test-ttf.html b/fonts/Commodore64/fonts/test-ttf.html new file mode 100644 index 0000000..5df195b --- /dev/null +++ b/fonts/Commodore64/fonts/test-ttf.html @@ -0,0 +1,265 @@ + + + + C64 Pro Mono: TTF (TrueType) test + + + + + + + +
+ + + +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/fonts/Commodore64/fonts/test-woff.html b/fonts/Commodore64/fonts/test-woff.html new file mode 100644 index 0000000..da1ab26 --- /dev/null +++ b/fonts/Commodore64/fonts/test-woff.html @@ -0,0 +1,266 @@ + + + + C64 Pro Mono: WOFF (Web Open Font Format) test + + + + + + + +
+ + + + +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/fonts/Commodore64/fonts/test-woff2.html b/fonts/Commodore64/fonts/test-woff2.html new file mode 100644 index 0000000..aa8f2a7 --- /dev/null +++ b/fonts/Commodore64/fonts/test-woff2.html @@ -0,0 +1,266 @@ + + + + C64 Pro Mono: WOFF2 (Web Open Font Format 2.0) test + + + + + + + +
+ + + + +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/fonts/Commodore64/license.txt b/fonts/Commodore64/license.txt new file mode 100644 index 0000000..9a9341e --- /dev/null +++ b/fonts/Commodore64/license.txt @@ -0,0 +1,8 @@ + +Fonts in this package are (c) 2010-2014 Style. + +This license is applicable to each font file included in this package in all their variants (ttf, eot, woff, woff2, svg). + +You MAY NOT: sell this font; include/redistribute the font in any font collection regardless of pricing; provide the font for direct download from any web site, modify or rename the font. You MAY: link to "http://style64.org/c64-truetype" in order for others to download and install the font; embed the font (without any modification or file renaming) for display on any web site using @font-face rules; use this font in static images and vector art; include this font (without any modification or file renaming) as part of a software package but ONLY if said software package is freely provided to end users. You may also contact us to negotiate a (possibly commercial) license for your use outside of these guidelines at "http://style64.org/contact-style". + +At all times the most recent version of this license can be found at "http://style64.org/c64-truetype/license". diff --git a/fonts/Commodore64/screenshot.png b/fonts/Commodore64/screenshot.png new file mode 100644 index 0000000..dcec67f Binary files /dev/null and b/fonts/Commodore64/screenshot.png differ diff --git a/fonts/PC/LICENSE.TXT b/fonts/PC/LICENSE.TXT new file mode 100644 index 0000000..fd662a7 --- /dev/null +++ b/fonts/PC/LICENSE.TXT @@ -0,0 +1,428 @@ +Attribution-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-ShareAlike 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-ShareAlike 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + + including for purposes of Section 3(b); and + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. + diff --git a/fonts/PC/PxPlus_AmstradPC1512-2y.ttf b/fonts/PC/PxPlus_AmstradPC1512-2y.ttf new file mode 100644 index 0000000..091001c Binary files /dev/null and b/fonts/PC/PxPlus_AmstradPC1512-2y.ttf differ diff --git a/fonts/PC/PxPlus_AmstradPC1512.ttf b/fonts/PC/PxPlus_AmstradPC1512.ttf new file mode 100644 index 0000000..248a001 Binary files /dev/null and b/fonts/PC/PxPlus_AmstradPC1512.ttf differ diff --git a/fonts/PC/PxPlus_IBM_BIOS-2x.ttf b/fonts/PC/PxPlus_IBM_BIOS-2x.ttf new file mode 100644 index 0000000..130bb4a Binary files /dev/null and b/fonts/PC/PxPlus_IBM_BIOS-2x.ttf differ diff --git a/fonts/PC/PxPlus_IBM_BIOS-2y.ttf b/fonts/PC/PxPlus_IBM_BIOS-2y.ttf new file mode 100644 index 0000000..2a1ec89 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_BIOS-2y.ttf differ diff --git a/fonts/PC/PxPlus_IBM_BIOS.ttf b/fonts/PC/PxPlus_IBM_BIOS.ttf new file mode 100644 index 0000000..672aac7 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_BIOS.ttf differ diff --git a/fonts/PC/PxPlus_IBM_CGA-2y.ttf b/fonts/PC/PxPlus_IBM_CGA-2y.ttf new file mode 100644 index 0000000..f20e848 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_CGA-2y.ttf differ diff --git a/fonts/PC/PxPlus_IBM_CGA.ttf b/fonts/PC/PxPlus_IBM_CGA.ttf new file mode 100644 index 0000000..11cbae7 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_CGA.ttf differ diff --git a/fonts/PC/PxPlus_IBM_CGAthin-2y.ttf b/fonts/PC/PxPlus_IBM_CGAthin-2y.ttf new file mode 100644 index 0000000..e8aa21e Binary files /dev/null and b/fonts/PC/PxPlus_IBM_CGAthin-2y.ttf differ diff --git a/fonts/PC/PxPlus_IBM_CGAthin.ttf b/fonts/PC/PxPlus_IBM_CGAthin.ttf new file mode 100644 index 0000000..bca6a64 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_CGAthin.ttf differ diff --git a/fonts/PC/PxPlus_IBM_EGA8-2x.ttf b/fonts/PC/PxPlus_IBM_EGA8-2x.ttf new file mode 100644 index 0000000..5aeb931 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_EGA8-2x.ttf differ diff --git a/fonts/PC/PxPlus_IBM_EGA8.ttf b/fonts/PC/PxPlus_IBM_EGA8.ttf new file mode 100644 index 0000000..22983e3 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_EGA8.ttf differ diff --git a/fonts/PC/PxPlus_IBM_EGA9-2x.ttf b/fonts/PC/PxPlus_IBM_EGA9-2x.ttf new file mode 100644 index 0000000..66c93d8 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_EGA9-2x.ttf differ diff --git a/fonts/PC/PxPlus_IBM_EGA9.ttf b/fonts/PC/PxPlus_IBM_EGA9.ttf new file mode 100644 index 0000000..d07ca5d Binary files /dev/null and b/fonts/PC/PxPlus_IBM_EGA9.ttf differ diff --git a/fonts/PC/PxPlus_IBM_MDA.ttf b/fonts/PC/PxPlus_IBM_MDA.ttf new file mode 100644 index 0000000..db3b7b2 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_MDA.ttf differ diff --git a/fonts/PC/PxPlus_IBM_VGA8-2x.ttf b/fonts/PC/PxPlus_IBM_VGA8-2x.ttf new file mode 100644 index 0000000..6963c72 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_VGA8-2x.ttf differ diff --git a/fonts/PC/PxPlus_IBM_VGA8.ttf b/fonts/PC/PxPlus_IBM_VGA8.ttf new file mode 100644 index 0000000..0368d2b Binary files /dev/null and b/fonts/PC/PxPlus_IBM_VGA8.ttf differ diff --git a/fonts/PC/PxPlus_IBM_VGA9-2x.ttf b/fonts/PC/PxPlus_IBM_VGA9-2x.ttf new file mode 100644 index 0000000..f159709 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_VGA9-2x.ttf differ diff --git a/fonts/PC/PxPlus_IBM_VGA9.ttf b/fonts/PC/PxPlus_IBM_VGA9.ttf new file mode 100644 index 0000000..53c6068 Binary files /dev/null and b/fonts/PC/PxPlus_IBM_VGA9.ttf differ diff --git a/fonts/PC/PxPlus_TandyNew_225-2y.ttf b/fonts/PC/PxPlus_TandyNew_225-2y.ttf new file mode 100644 index 0000000..e52ba0d Binary files /dev/null and b/fonts/PC/PxPlus_TandyNew_225-2y.ttf differ diff --git a/fonts/PC/PxPlus_TandyNew_225.ttf b/fonts/PC/PxPlus_TandyNew_225.ttf new file mode 100644 index 0000000..f279c67 Binary files /dev/null and b/fonts/PC/PxPlus_TandyNew_225.ttf differ diff --git a/fonts/PC/PxPlus_TandyNew_TV-2y.ttf b/fonts/PC/PxPlus_TandyNew_TV-2y.ttf new file mode 100644 index 0000000..653a100 Binary files /dev/null and b/fonts/PC/PxPlus_TandyNew_TV-2y.ttf differ diff --git a/fonts/PC/PxPlus_TandyNew_TV.ttf b/fonts/PC/PxPlus_TandyNew_TV.ttf new file mode 100644 index 0000000..d206e1d Binary files /dev/null and b/fonts/PC/PxPlus_TandyNew_TV.ttf differ diff --git a/fonts/PC/PxPlus_VGA_SquarePx.ttf b/fonts/PC/PxPlus_VGA_SquarePx.ttf new file mode 100644 index 0000000..9fe3e4a Binary files /dev/null and b/fonts/PC/PxPlus_VGA_SquarePx.ttf differ diff --git a/fonts/PC/README.NFO b/fonts/PC/README.NFO new file mode 100644 index 0000000..69e7de6 --- /dev/null +++ b/fonts/PC/README.NFO @@ -0,0 +1,48 @@ + + _ --- _ --- + ." ,, ~=_ .. ." ~=_ + . . .OZZZO ^g, . .~. ^% .s%ZO + ` qZp' `Z, ` _., `gZ :ZZ| + _g%%oc, ~ _., ` Z; _.,©y%Z=-: .s%Z%L, `OZZYi%g_ + jOZZZZOL jOZZ, `Zb _.©y%ZZZZZZZZ%=: jZZZZZZZb `ZZZZZZZb + ZZ?~ ~\ZZZ| |ZZZZO\ ?Z.%ZZZZZZ*^"`' /ZZ"~"ZZ\ T ~!ZZ + Z6f ZZZO|ZZZ^ZZi ]Z1:-":ZZZ' _. OZ/ \ZZL : |6Z' + . `ZZ._ ~"^Z| ZZZ;\ZZ Z ZZZ _%ZZ l%! .oZo, ]ZZ _ZZ' . + , ~^*^~.ZZZZl ZZZZ1 ZZZZ ^!ZZ :=l dZZZb ZZ| ~^"~ + g%ZZZZZZZ `ZZZ : ZZZZ: lZZ| ; :ZZZF ZZ| .' + ~_ ZZZZ| ZZZZ ZZ' ?ZZZ! :ZZ "" dZg _~ + ~"^ :ZZZO|ZZZ! `^' ' `ZZZ ZZ: ./ZZf --`~ + OZZZ jZ~ `. _ _. . ~^L, YZZZZOzz :=CO/ + -V! j^~ . ~--~ . `^ʦZZF':%CG' . O R G + ~_ T _~ ~' '^"~ + ~"=|="~ + p r e s e n t s + + + + The Ultimate Oldschool PC Font Pack + + < http://int10h.org/oldschool-pc-fonts/ > + + v1.0 // 2016-01-16 + + + -------------- + DOCUMENTATION: + -------------- + + Readme: < http://int10h.org/oldschool-pc-fonts/readme/ > + + Font list: < http://int10h.org/oldschool-pc-fonts/fontlist/ > + + + + + The Ultimate Oldschool PC Font Pack is licensed under a Creative Commons + Attribution-ShareAlike 4.0 International License. + + You should have received a copy of the license along with this work. If + not, see < http://creativecommons.org/licenses/by-sa/4.0/ >. + + (c) 2016 VileR + diff --git a/functions.js b/functions.js new file mode 100644 index 0000000..267af6a --- /dev/null +++ b/functions.js @@ -0,0 +1,409 @@ +// These functions are shared with text.js and options.js +"use strict"; + +function fontSettings(ff) +// Return CSS3 styles to use with the font. +// @ ff CSS font family class name +{ + if (typeof ff !== "string") ff = "vga8"; + var cols = 80, // columns (characters per line) + csslh, cssfs, // css values + fh = 8, // font height in pixels + fw = 8, // font width in pixels + fx = 1.5, // multiplier for small, square fonts + str, // humanise font family name + use40Cols = false, // place holder for future 40 column wrapping + width = fw * cols; // text container width in pixels + // Font base height // + // apply 14px height + if (["ega", "mda"].indexOf(ff.substring(0, 3)) !== -1) { + fh = 14; + } + // apply 16px height + else if (["vga8", "vga9"].indexOf(ff.substring(0, 4)) !== -1) { + fh = 16; + } + // apply 19px height + else if (ff === "vgalcd") { + fh = 19; + } + // apply 9px height + else if (["tandynew225"].indexOf(ff.substring(0, 11)) !== -1) { + fh = 9; + } + // Character base width // + // apply 9px width + if (["mda"].indexOf(ff) !== -1 || ff.substring(3, 4) === "9") { + fw = 9; + } + // 40 columns restrictions place holder + if (use40Cols && ["bios-2x", "cgathin", "ega8-2x", "ega9-2x", "pc1512", "tandynewtv", "tandynew225", "vga8-2x", "vga9-2x"].indexOf(ff) !== -1) { + cols = 40; + // to implement would need to implement the following CSS; pre.style.whiteSpace = "pre-wrap"; pre.style.wordBreak = "break-all"; + } + // Wide & narrow font type width and height adjustments // + switch (ff.split("-")[1]) { + // wide fonts end with "-2x" + case "2x": + fw *= 2; + width *= 2; + break; + // narrow fonts end with "-2y" + case "2y": + fh *= 2; + break; + default: + } + // Double font size for Amiga and Commodore 64 as they are a bit small. + if (ff.substring(0, 5) === "amiga" || ff.substring(0, 7) === "appleii" || ff.substring(0, 3) === "c64" || ff.substring(0, 6) === "vgalcd") { + fh *= fx; + fw *= fx; + width *= fx; + } + // CSS font size hacks (not sure if these result in accurate representations) + if (ff.substring(0, 5) === "amiga" || ff.substring(0, 7) === "appleii" || ff.substring(0, 4) === "bios" || ff.substring(0, 3) === "c64" || ff.substring(0, 3) === "cga" || ff.substring(0, 7) === "cgathin" || ff.substring(0, 6) === "pc1512" || ff.substring(0, 5) === "tandy" || ff.substring(0, 6) === "vgalcd") { + csslh = "normal"; + cssfs = `${fh}px`; + } else { + csslh = `${fh}px`; + cssfs = "100%"; + } + // Humanise font family name + str = ff.toUpperCase(); + str = str.replace("-2X", " (wide)"); + str = str.replace("-2Y", " (narrow)"); + str = str.replace("CGATHIN", " CGA Thin"); + str = str.replace("TANDYNEW", " Tandy "); + // properties + this.columns = cols; + this.container = width; + this.cssLineHeight = csslh; + this.cssFontSize = cssfs; + this.family = ff; + this.height = fh; + this.string = str; + this.width = fw; +} + +function linkCSS(f, i) +// Creates a LINK tag used to load a style sheet. +// @f CSS file name +// @i ID name to apply to link tag +{ + if (typeof f === "undefined") f = ""; + if (typeof i === "undefined") i = ""; + var l = document.createElement("link"); + if (i.length) l.id = i; + l.href = chrome.extension.getURL(f); + l.type = "text/css"; + l.rel = "stylesheet"; + return l; +} + +function i18nWord(name, cls) +// Annoying word-around to add i18n support to .html files +// @name i18n message name +// @cls span class name to inject translation into +{ + if (typeof name === "undefined") return; + if (typeof cls === "undefined") return; + // word capitalization + function capitalize(s) { + return s[0].toUpperCase() + s.slice(1); + } + var newword, word, + words = document.getElementsByClassName(cls), + wordCnt = words.length; + for (var i = 0, len = wordCnt; i < len; i++) { + word = words[i].innerHTML; + newword = chrome.i18n.getMessage(name); + if (word.slice(0, 1).toUpperCase()) { + newword = capitalize(newword); + } + words[i].innerHTML = newword; + } +} + +function rgbColors() +// Colours as RGB (Red, Green, Blue) +{ + // pc colours + this.amber = "rgb(185,128,0)"; + this.black = "rgb(0,0,0)"; + this.gray = "rgb(170,170,170)"; + this.green = "rgb(41,244,24)"; + this.white = "rgb(255,255,255)"; + // amiga + this.amigaWhite = "rgb(247,247,247)"; + this.amigaGray = "rgb(148,148,148)"; + // apple ii (ntsc) + // http://www.kreativekorp.com/miscpages/a2info/munafo.shtml + this.appleiiBlack = "rgb(41,41,41)"; + this.appleiiGreen = "rgb(12,234,97)"; + // commodore 64 + this.c64fg = "rgb(108,94,181)"; + this.c64bg = "rgb(53,40,121)"; +} + +function textShadow(s, elm, color) +// Applies CSS3 text shadowing effects to an element +// @s required boolean to enable or disable text show +// @elm required HTML DOM element object to apply shadow effect to +// @color optional CSS colour class when we already know the new colour values +{ + try { + if (typeof elm !== "object") throw "'elm' is missing, it should be the a HTML DOM element"; + } catch (err) { + console.error("textShadow(s, elm) the required parameter " + err); + return; + } + + function applyStyle(c) { + if (typeof c === "string") { + switch (c) { + case "gray-black": + elm.style.textShadow = "2px 2px 0px rgba(64, 64, 64, 1)"; + break; + case "amigaWhite-amigaGray": + case "appleiiGreen-appleiiBlack": + elm.style.textShadow = "2px 2px 0px rgba(72, 72, 72, 1)"; + break; + case "c64fg-c64bg": + elm.style.textShadow = "2px 2px 0px rgba(30, 20, 77, 1)"; + break; + default: + if (c.split("-")[1] === "white") { + elm.style.textShadow = "2px 2px 0px rgba(224, 224, 224, 1)"; + } else { + elm.style.textShadow = "2px 2px 0px rgba(72, 72, 72, 1)"; + } + break; + } + } + } + + if (typeof s === null) s = true; + // if s is false then disable the style + if (!s) { + elm.style.textShadow = "none"; + } + // use colours provided by the colour parameter + else if (typeof color === "string") { + applyStyle(color); + } + // use colours fetched from chrome's storage (default) + else { + chrome.storage.local.get("retroColor", function(result) { + var r = result.retroColor; + applyStyle(r); + }); + } +} + +function txtConvert(s) +/* + txtConvert takes text loaded as Windows-1252 or ISO 8859-1 but created for + PC/MS-DOS extended Code Page 437 and converts it into UTF-8 Unicode. + CP-437 (DOS) https://msdn.microsoft.com/en-us/goglobal/cc305156 + CP-862 (DOS) https://msdn.microsoft.com/en-us/goglobal/cc305165 + IS0 8859-1 https://msdn.microsoft.com/en-us/goglobal/cc305167 + Windows 1252 https://msdn.microsoft.com/en-us/goglobal/cc305145 +*/ +// @s String of text to convert +{ + if (typeof s === "undefined") s = ""; + var t = s, + ctrlCodes = sessionStorage.getItem("cp437CtrlCodes"), + fullConversion = true; + // We must convert the text user interface glyphs before the language characters. + // All the characters [21-7E] are ASCII 7-bit and shared between both sets. + // dithering [B0-B2] + t = t.replace(/°/g, "░"); + t = t.replace(/±/g, "▒"); + t = t.replace(/²/g, "▓"); + // lines [B3-BF] + t = t.replace(/³/g, "│"); + t = t.replace(/´/g, "┤"); + t = t.replace(/µ/g, "╡"); + t = t.replace(/¶/g, "╢"); + t = t.replace(/·/g, "╖"); + t = t.replace(/¸/g, "╕"); + t = t.replace(/¹/g, "╣"); + t = t.replace(/º/g, "║"); + t = t.replace(/»/g, "╗"); + t = t.replace(/¼/g, "╝"); + t = t.replace(/½/g, "╜"); + t = t.replace(/¾/g, "╛"); + t = t.replace(/¿/g, "┐"); + t = t.replace(/Ú/g, "┌"); + // lines [C0-CF] + t = t.replace(/À/g, "└"); + t = t.replace(/Á/g, "┴"); + t = t.replace(/Â/g, "┬"); + t = t.replace(/Ã/g, "├"); + t = t.replace(/Ä/g, "─"); + t = t.replace(/Å/g, "┼"); + t = t.replace(/Æ/g, "╞"); + t = t.replace(/Ç/g, "╟"); + t = t.replace(/È/g, "╚"); + t = t.replace(/É/g, "╔"); + t = t.replace(/Ê/g, "╩"); + t = t.replace(/Ë/g, "╦"); + t = t.replace(/Ì/g, "╠"); + t = t.replace(/Í/g, "═"); + t = t.replace(/Î/g, "╬"); + t = t.replace(/Ï/g, "╧"); + // lines [D0-DA] + t = t.replace(/Ð/g, "╨"); + t = t.replace(/Ñ/g, "╤"); + t = t.replace(/Ò/g, "╥"); + t = t.replace(/Ó/g, "╙"); + t = t.replace(/Ô/g, "╘"); + t = t.replace(/Õ/g, "╒"); + t = t.replace(/Ö/g, "╓"); + t = t.replace(/×/g, "╫"); + t = t.replace(/Ø/g, "╪"); + t = t.replace(/Ù/g, "┘"); + t = t.replace(/Ú/g, "┌"); + // blocks [DB-DF] + t = t.replace(/Û/g, "█"); + t = t.replace(/Ü/g, "▄"); + t = t.replace(/Ý/g, "▌"); + t = t.replace(RegExp(String.fromCharCode(222), "g"), "▐"); + t = t.replace(/ß/g, "▀"); + t = t.replace(RegExp(String.fromCharCode(254), "g"), "■"); // [FE] + //return t; // You could exit here to improve performance on large files? + // misc characters [01-08] + t = t.replace(RegExp(String.fromCharCode(1), "g"), "☺"); + t = t.replace(RegExp(String.fromCharCode(2), "g"), "☻"); + t = t.replace(RegExp(String.fromCharCode(3), "g"), "♥"); + t = t.replace(RegExp(String.fromCharCode(4), "g"), "♦"); + t = t.replace(RegExp(String.fromCharCode(5), "g"), "♣"); + t = t.replace(RegExp(String.fromCharCode(6), "g"), "♠"); + t = t.replace(RegExp(String.fromCharCode(7), "g"), "•"); + // pseudo-control codes (user option 'Display CP-437 control codes as DOS glyphs') + if (typeof ctrlCodes === "string" && ctrlCodes === "true") { + // [08-0A] + t = t.replace(RegExp(String.fromCharCode(8), "g"), "◘"); // backspace + t = t.replace(RegExp(String.fromCharCode(9), "g"), "○"); // tab + //t = t.replace(RegExp(String.fromCharCode(10), "g"), "◙"); // line feed + t = t.replace(RegExp(String.fromCharCode(13), "g"), "♪"); // carriage return + t = t.replace(RegExp(String.fromCharCode(26), "g"), "→"); // DOS end of file + t = t.replace(RegExp(String.fromCharCode(127), "g"), "⌂"); // [7F] delete + } + t = t.replace(RegExp(String.fromCharCode(255), "g"), " "); // [FF] space + // [0B-0F] + t = t.replace(RegExp(String.fromCharCode(11), "g"), "♂"); + t = t.replace(RegExp(String.fromCharCode(12), "g"), "♀"); + t = t.replace(RegExp(String.fromCharCode(14), "g"), "♫"); + t = t.replace(RegExp(String.fromCharCode(15), "g"), "☼"); + // [10-1F] + t = t.replace(RegExp(String.fromCharCode(16), "g"), "►"); + t = t.replace(RegExp(String.fromCharCode(17), "g"), "◄"); + t = t.replace(RegExp(String.fromCharCode(18), "g"), "↕"); + t = t.replace(RegExp(String.fromCharCode(19), "g"), "‼"); + t = t.replace(RegExp(String.fromCharCode(20), "g"), "¶"); + t = t.replace(RegExp(String.fromCharCode(21), "g"), "§"); + t = t.replace(RegExp(String.fromCharCode(22), "g"), "▬"); + t = t.replace(RegExp(String.fromCharCode(23), "g"), "↨"); + // Directional arrows [18-1B] + t = t.replace(RegExp(String.fromCharCode(24), "g"), "↑"); + t = t.replace(RegExp(String.fromCharCode(25), "g"), "↓"); + // [1A] 26 right arrow used as EOF + t = t.replace(RegExp(String.fromCharCode(27), "g"), "←"); + // [1C-1F] + t = t.replace(RegExp(String.fromCharCode(28), "g"), "∟"); + t = t.replace(RegExp(String.fromCharCode(29), "g"), "↔"); + t = t.replace(RegExp(String.fromCharCode(30), "g"), "▲"); + t = t.replace(RegExp(String.fromCharCode(31), "g"), "▼"); + // [A8-AF] + t = t.replace(RegExp(String.fromCharCode(169), "g"), "⌐"); + t = t.replace(RegExp(String.fromCharCode(170), "g"), "¬"); + t = t.replace(RegExp(String.fromCharCode(171), "g"), "½"); + t = t.replace(RegExp(String.fromCharCode(172), "g"), "¼"); + t = t.replace(RegExp(String.fromCharCode(173), "g"), "¡"); + t = t.replace(RegExp(String.fromCharCode(174), "g"), "«"); + t = t.replace(RegExp(String.fromCharCode(175), "g"), "»"); + // [20] 32 is space + // Can usually end here for most ascii art text and nfo files + if (!fullConversion) return t; + // [E0-EF] + t = t.replace(RegExp(String.fromCharCode(224), "g"), "α"); + t = t.replace(RegExp(String.fromCharCode(225), "g"), "ß"); + t = t.replace(RegExp(String.fromCharCode(226), "g"), "Γ"); + t = t.replace(RegExp(String.fromCharCode(227), "g"), "π"); + t = t.replace(RegExp(String.fromCharCode(228), "g"), "Σ"); + t = t.replace(RegExp(String.fromCharCode(229), "g"), "σ"); + t = t.replace(RegExp(String.fromCharCode(230), "g"), "µ"); + t = t.replace(RegExp(String.fromCharCode(231), "g"), "τ"); + t = t.replace(RegExp(String.fromCharCode(232), "g"), "Φ"); + t = t.replace(RegExp(String.fromCharCode(233), "g"), "Θ"); + t = t.replace(RegExp(String.fromCharCode(234), "g"), "Ω"); + t = t.replace(RegExp(String.fromCharCode(235), "g"), "δ"); + t = t.replace(RegExp(String.fromCharCode(236), "g"), "∞"); + t = t.replace(RegExp(String.fromCharCode(237), "g"), "φ"); + t = t.replace(RegExp(String.fromCharCode(238), "g"), "ε"); + t = t.replace(RegExp(String.fromCharCode(239), "g"), "∩"); + // [F0-FF] + t = t.replace(/ð/g, "≡"); // 240 + t = t.replace(RegExp(String.fromCharCode(241), "g"), "±"); + t = t.replace(RegExp(String.fromCharCode(242), "g"), "≥"); + t = t.replace(RegExp(String.fromCharCode(243), "g"), "≤"); + t = t.replace(RegExp(String.fromCharCode(244), "g"), "⌠"); + t = t.replace(RegExp(String.fromCharCode(245), "g"), "⌡"); + t = t.replace(RegExp(String.fromCharCode(246), "g"), "÷"); + t = t.replace(/÷/g, "≈"); // 247 + t = t.replace(RegExp(String.fromCharCode(248), "g"), "°"); + t = t.replace(/ù/g, "∙"); // 249 + t = t.replace(RegExp(String.fromCharCode(250), "g"), "·"); + t = t.replace(RegExp(String.fromCharCode(251), "g"), "√"); + t = t.replace(RegExp(String.fromCharCode(252), "g"), "ⁿ"); + t = t.replace(RegExp(String.fromCharCode(253), "g"), "²"); + // [FF] 255 is space and was handled earlier + // Language specific characters with accents, currency & math. + // [80-8F] + t = t.replace(RegExp(String.fromCharCode(128), "g"), "Ç"); + t = t.replace(RegExp(String.fromCharCode(129), "g"), "ü"); + t = t.replace(RegExp(String.fromCharCode(130), "g"), "é"); + t = t.replace(RegExp(String.fromCharCode(131), "g"), "â"); + t = t.replace(RegExp(String.fromCharCode(132), "g"), "ä"); + t = t.replace(RegExp(String.fromCharCode(133), "g"), "à"); + t = t.replace(RegExp(String.fromCharCode(134), "g"), "å"); + t = t.replace(RegExp(String.fromCharCode(135), "g"), "ç"); + t = t.replace(RegExp(String.fromCharCode(136), "g"), "ê"); + t = t.replace(RegExp(String.fromCharCode(137), "g"), "ë"); + t = t.replace(RegExp(String.fromCharCode(138), "g"), "è"); + t = t.replace(RegExp(String.fromCharCode(139), "g"), "ï"); + // [90-9F] + t = t.replace(RegExp(String.fromCharCode(140), "g"), "î"); + t = t.replace(RegExp(String.fromCharCode(141), "g"), "ì"); + t = t.replace(RegExp(String.fromCharCode(142), "g"), "Ä"); + t = t.replace(RegExp(String.fromCharCode(143), "g"), "Å"); + t = t.replace(RegExp(String.fromCharCode(144), "g"), "É"); + t = t.replace(RegExp(String.fromCharCode(145), "g"), "æ"); + t = t.replace(RegExp(String.fromCharCode(146), "g"), "Æ"); + t = t.replace(RegExp(String.fromCharCode(147), "g"), "ô"); + t = t.replace(RegExp(String.fromCharCode(148), "g"), "ö"); + t = t.replace(RegExp(String.fromCharCode(149), "g"), "ò"); + t = t.replace(RegExp(String.fromCharCode(150), "g"), "û"); + t = t.replace(RegExp(String.fromCharCode(151), "g"), "ù"); + t = t.replace(RegExp(String.fromCharCode(152), "g"), "ÿ"); + t = t.replace(RegExp(String.fromCharCode(153), "g"), "Ö"); + t = t.replace(RegExp(String.fromCharCode(154), "g"), "Ü"); + t = t.replace(RegExp(String.fromCharCode(155), "g"), "¢"); + t = t.replace(RegExp(String.fromCharCode(156), "g"), "£"); + t = t.replace(RegExp(String.fromCharCode(157), "g"), "¥"); + t = t.replace(RegExp(String.fromCharCode(158), "g"), "₧"); + t = t.replace(RegExp(String.fromCharCode(159), "g"), "ƒ"); + // [A0-A8] + t = t.replace(RegExp(String.fromCharCode(160), "g"), "á"); + t = t.replace(RegExp(String.fromCharCode(161), "g"), "í"); + t = t.replace(RegExp(String.fromCharCode(162), "g"), "ó"); + t = t.replace(RegExp(String.fromCharCode(163), "g"), "ú"); + t = t.replace(RegExp(String.fromCharCode(164), "g"), "ñ"); + t = t.replace(RegExp(String.fromCharCode(165), "g"), "Ñ"); + t = t.replace(RegExp(String.fromCharCode(166), "g"), "ª"); + t = t.replace(RegExp(String.fromCharCode(167), "g"), "º"); + t = t.replace(RegExp(String.fromCharCode(168), "g"), "¿"); + return t; +} \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..97eac9c --- /dev/null +++ b/manifest.json @@ -0,0 +1,62 @@ +{ + "manifest_version": 2, + + "name": "RetroTxt", + "description": "RetroTxt stylises ASCII and MS-DOS text-art files with authentic fonts and colours from the 8 and 16-bit home computing eras.", + "version": "1.0.0", + "version_name": "1.0", + "minimum_chrome_version": "41", + "default_locale": "en_US", + "author": "Ben Garrett", + "homepage_url": "https://github.com/bengarrett/RetroTxt", + + "background": { + "scripts": ["functions.js", "eventPage.js"], + "persistent": false + }, + + "browser_action": { + "default_title": "Stylise this text" + }, + + "icons": { + "16": "assets/RetroTxt-16.png", + "19": "assets/RetroTxt-19.png", + "32": "assets/RetroTxt-32.png", + "38": "assets/RetroTxt-38.png", + "48": "assets/RetroTxt-48.png", + "128": "assets/RetroTxt-128.png" + }, + + "commands": { + "_execute_browser_action": { + "suggested_key": { + "windows": "Alt+T", + "mac": "Alt+T", + "chromeos": "Alt+T", + "linux": "Alt+T" + } + } + }, + + "permissions": [ + "activeTab", + "contextMenus", + "storage", + "tabs", "http://*/", "https://*/" + ], + "optional_permissions": ["tabs", "file:///*"], + "options_ui": { + "page": "options.html", + "chrome_style": true + }, + + "web_accessible_resources": [ + "fonts/PC/*.ttf", + "fonts/Amiga/*.ttf", + "fonts/AppleII/*.ttf", + "fonts/Commodore64/fonts/*.ttf", + "text.css", + "text.js" + ] +} \ No newline at end of file diff --git a/options.html b/options.html new file mode 100644 index 0000000..e3ace57 --- /dev/null +++ b/options.html @@ -0,0 +1,238 @@ + + + + + + Options + + + + +
Sample text ╔═╝ ░▒▓▒░
+
 
+
+
+

Standard fonts
1:1 pixel ratios

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+

Wide fonts
2:1 pixel ratios

+ +
+ +
+ +
+ +
+ +
+
+

Narrow fonts
1:2 pixel ratios

+ +
+ +
+ +
+ +
+ +
+ +
+
+
+
+
+

Font color

+ +
+
+ +
+ +
+ +
+
+
+
+
+ +
+ +
+
+ + + + + + diff --git a/options.js b/options.js new file mode 100644 index 0000000..a6a29f0 --- /dev/null +++ b/options.js @@ -0,0 +1,247 @@ +"use strict"; + +function fontAdjust(ff, elm) +// Adjusts the font family and font height styles +// @ff Font family to apply +// @elm HTML element to apply the font styles too +{ + if (typeof ff === "undefined" || typeof elm === "undefined") return; + var font = new fontSettings(ff); + elm.fontFamily = ff; + elm.fontSize = font.cssFontSize; + elm.lineHeight = font.cssLineHeight; +} + +function getColorsRGB(v) +// Generates CSS for font colours. +// @v Font colours selection value +{ + if (typeof v === "undefined") v = ""; + var colors = v.split("-"), + style, + fg = colors[0], + bg = colors[1], + rgbs = new rgbColors(); + style = "background-color: " + rgbs[bg] + "; color: " + rgbs[fg] + ";"; + return style; +} + +function restoreOptions() +// Sets the options form to match the user's saved options +{ + var colorSel = document.getElementById("font-color"), + fontSel = document.getElementsByName('font'), + coLen = colorSel.length, + foLen = fontSel.length; + // Colour + chrome.storage.local.get("retroColor", function(result) { + var r = result.retroColor; + if (typeof r !== "string") return; + for (var i = 0, len = coLen; i < len; i++) { + if (colorSel[i].value === r) { + colorSel[i].selected = true; + break; + } + } + }); + // Font + chrome.storage.local.get("retroFont", function(result) { + var fi, + r = result.retroFont; + if (typeof r !== "string") return; + for (var i = 0, len = foLen; i < len; i++) { + fi = fontSel[i]; + if (fi.value === r) { + fi.checked = true; + break; + } + } + }); + // Check-boxes + chrome.storage.local.get("textFontInformation", function(result) { + var input = document.getElementById("text-font-information"), + r = result.textFontInformation; + if (typeof r !== "boolean") r = true; + input.checked = r; + }); + chrome.storage.local.get("centerAlignment", function(result) { + var input = document.getElementById("center-alignment"), + r = result.centerAlignment; + if (typeof r !== "boolean") r = true; + input.checked = r; + }); + chrome.storage.local.get("fontShadows", function(result) { + var input = document.getElementById("font-shadows"), + r = result.fontShadows; + if (typeof r !== "boolean") r = false; + input.checked = r; + }); + chrome.storage.local.get("cp437CtrlCodes", function(result) { + var input = document.getElementById("cp437-ctrl-codes"), + r = result.cp437CtrlCodes; + if (typeof r !== "boolean") r = false; + input.checked = r; + }); + chrome.storage.local.get("autoDetectRun", function(result) { + var input = document.getElementById("auto-detect-run"), + r = result.autoDetectRun; + if (typeof r !== "boolean") r = true; + input.checked = r; + }); +} + +function saveColors() +// Saves the user font and background colour selection to local browser storage. +{ + var select = document.getElementById("font-color"), + colors = select.options[select.selectedIndex].value; + chrome.storage.local.set({ + 'retroColor': colors + }); +} + +function saveFont() +// Saves the user font selection to local browser storage. +{ + var font = document["fonts"].font.value; + chrome.storage.local.set({ + 'retroFont': font + }); +} + +function useSavedColors() +// Gets and applies user's saved font colours to sample text. +{ + chrome.storage.local.get("retroColor", function(result) { + var sample = document.getElementById('sample-dos-text').style, + r = result.retroColor; + if (typeof r !== "string") return; + document.getElementById('sample-dos-text').style = getColorsRGB(r); + }); +} + +function useSavedFont() +// Gets and applies user's saved font family to sample text. +{ + chrome.storage.local.get("retroFont", function(result) { + var sample = document.getElementById('sample-dos-text').style, + r = result.retroFont; + if (typeof r !== "string") return; + fontAdjust(r, sample); + }); +} + +function useSavedEffects() +// Gets and applies user's saved font family to sample text. +{ + chrome.storage.local.get("fontShadows", function(result) { + var sample = document.getElementById('sample-dos-text'), + r = result.fontShadows; + if (typeof r !== "boolean") return; + textShadow(r, sample); + }); +} + +// Run when options menu is launched. +(function() { + + // default font and colour combination + var cssLink, + radios = document.forms["fonts"].getElementsByTagName("label"), + radiosLen = radios.length; + + // restore user saved options + document.addEventListener('DOMContentLoaded', restoreOptions); + useSavedColors(); + useSavedFont(); + useSavedEffects(); + + // insert a LINK into the options.html + cssLink = linkCSS("text.css"); + document.getElementsByTagName("head")[0].appendChild(cssLink); + + // font selection events + for (var i = 0, len = radiosLen; i < len; i++) { + radios[i].onclick = function() { + var fface = this.getElementsByTagName("input")[0].value, + status = document.getElementById('status'); + status.textContent = 'Saved font selection ' + fface; + saveFont(); + } + radios[i].onmouseover = function() { + var fface = this.getElementsByTagName("input")[0].value, + sample = document.getElementById('sample-dos-text').style; + fontAdjust(fface, sample); + } + radios[i].onmouseout = function() { + useSavedFont(); + } + } + + // colours selection events + document.getElementById("font-color").addEventListener("change", function() { + var status = document.getElementById('status'), + sample = document.getElementById('sample-dos-text'); + + function colorName(c) { + var s = c; + switch (c) { + case "appleiiGreen-appleiiBlack": + s = "Apple II" + break; + case "amigaWhite-amigaGray": + s = "Amiga" + break; + case "c64fg-c64bg": + s = "Commodore 64" + break; + default: + s = s.replace("-", " on "); + break; + } + return s; + } + status.textContent = 'Saved ' + chrome.i18n.getMessage("color") + ' selection ' + colorName(this.value); + sample.style = getColorsRGB(this.value); + useSavedFont(); + saveColors(); + useSavedEffects(); + }); + + // check-boxes + document.getElementById("text-font-information").addEventListener("change", function() { + chrome.storage.local.set({ + 'textFontInformation': this.checked + }); + }); + document.getElementById("center-alignment").addEventListener("change", function() { + chrome.storage.local.set({ + 'centerAlignment': this.checked + }); + }); + document.getElementById("font-shadows").addEventListener("change", function() { + chrome.storage.local.set({ + 'fontShadows': this.checked + }); + useSavedEffects(); + }); + document.getElementById("cp437-ctrl-codes").addEventListener("change", function() { + chrome.storage.local.set({ + 'cp437CtrlCodes': this.checked + }); + }); + document.getElementById("auto-detect-run").addEventListener("change", function() { + chrome.storage.local.set({ + 'autoDetectRun': this.checked + }); + localStorage.setItem("autoDetectRun", this.checked); // set localStorage for active Chrome tabs + }); + + // internationalisations + i18nWord("color", "msg-color"); // color vs colour + i18nWord("center", "msg-center"); // center vs centre + // gray vs grey + document.getElementById("gray-white-option").innerHTML = chrome.i18n.getMessage("gray_white_option"); + // help link + document.getElementById("help-id").href = chrome.i18n.getMessage("url_help"); +})(); \ No newline at end of file diff --git a/text.css b/text.css new file mode 100644 index 0000000..a9cfc7a --- /dev/null +++ b/text.css @@ -0,0 +1,233 @@ +// fonts +@font-face { + // for some reason this place-holder is needed otherwise the first font in this collection doesn't load. + font-family: dummy-font; +} + +@font-face { + font-family: amiga; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/Amiga/amiga4ever.ttf'); +} + +@font-face { + font-family: appleii; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/AppleII/PrintChar21.ttf'); +} + +@font-face { + font-family: bios; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_BIOS.ttf'); +} + +@font-face { + font-family: bios-2x; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_BIOS-2x.ttf'); +} + +@font-face { + font-family: bios-2y; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_BIOS-2y.ttf'); +} + +@font-face { + font-family: bios-2y; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_BIOS-2y.ttf'); +} + +@font-face { + font-family: c64; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/Commodore64/fonts/C64_Pro_Mono-STYLE.ttf'); +} + +@font-face { + font-family: cga; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_CGA.ttf'); +} + +@font-face { + font-family: cga-2y; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_CGA-2y.ttf'); +} + +@font-face { + font-family: cgathin; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_CGAthin.ttf'); +} + +@font-face { + font-family: cgathin-2y; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_CGAthin-2y.ttf'); +} + +@font-face { + font-family: pc1512; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_AmstradPC1512.ttf'); +} + +@font-face { + font-family: pc1512-2y; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_AmstradPC1512-2y.ttf'); +} + +@font-face { + font-family: ega8; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_EGA8.ttf'); +} + +@font-face { + font-family: ega8-2x; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_EGA8-2x.ttf'); +} + +@font-face { + font-family: ega9; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_EGA9.ttf'); +} + +@font-face { + font-family: ega9-2x; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_EGA9-2x.ttf'); +} + +@font-face { + font-family: mda; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_MDA.ttf'); +} + +@font-face { + font-family: tandynewtv; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_TandyNew_TV.ttf'); +} + +@font-face { + font-family: tandynewtv-2y; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_TandyNew_TV-2y.ttf'); +} + +@font-face { + font-family: tandynew225; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_TandyNew_225.ttf'); +} + +@font-face { + font-family: tandynew225-2y; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_TandyNew_225-2y.ttf'); +} + +@font-face { + font-family: vga8; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_VGA8.ttf'); +} + +@font-face { + font-family: vga8-2x; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_VGA8-2x.ttf'); +} + +@font-face { + font-family: vga9; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_VGA9.ttf'); +} + +@font-face { + font-family: vga9-2x; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_IBM_VGA9-2x.ttf'); +} + +@font-face { + font-family: vgalcd; + src: url('chrome-extension://__MSG_@@extension_id__/fonts/PC/PxPlus_VGA_SquarePx.ttf'); +} + +// Classes +.bios { + font-family: bios; +} + +.bios-2x { + font-family: bios-2x; +} + +.bios-2y { + font-family: bios-2y; +} + +.cga { + font-family: cga; +} + +.cga-2y { + font-family: cga-2y; +} + +.cgathin { + font-family: cgathin; +} + +.cgathin-2y { + font-family: cgathin-2y; +} + +.ega8 { + font-family: ega8; +} + +.ega8-2x { + font-family: ega8-2x; +} + +.ega9 { + font-family: ega9; +} + +.ega9-2x { + font-family: ega9-2x; +} + +.mda { + font-family: mda; +} + +.pc1512 { + font-family: pc1512; +} + +.pc1512-2x { + font-family: pc1512-2x; +} + +.tandynewtv { + font-family: tandynewtv; +} + +.tandynewtv-2y { + font-family: tandynewtv-2y; +} + +.tandynew225 { + font-family: tandynew225; +} + +.tandynew225-2y { + font-family: tandynew225-2y; +} + +.vga9 { + font-family: vga9; +} + +.vga9-2x { + font-family: vga9-2x; +} + +.vga8 { + font-family: vga8; +} + +.vga8-2x { + font-family: vga8-2x; +} + +.vga-square { + font-family: vgalcd; +} \ No newline at end of file diff --git a/text.js b/text.js new file mode 100644 index 0000000..5ea6ecd --- /dev/null +++ b/text.js @@ -0,0 +1,398 @@ +"use strict"; + +function calcColumns(text) +// Calculate the number of columns in use by the innerHTML text +// Regular expression sourced from +// http://stackoverflow.com/questions/8802145/replace-html-entities-with-regular-expression +// @text A required string of text +{ + try { + if (typeof text !== "string") throw "'text' must be a string of text not a " + (typeof text); + } catch (err) { + console.error("calcColumns(text) the required parameter " + err); + } + var cleanedText, cols, i, splitTxt, len = 0, + patt = /&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/img; // find HTML entities + cols = new textDefaults().columns; // default 80 columns + splitTxt = text.split(/\r\n|\r|\n/); // split original text into lines + for (i in splitTxt) { + cleanedText = splitTxt[i].replace(patt, " ").trim(); // replace HTML entities with spaces + if (len < cleanedText.length) len = cleanedText.length; + } + //console.log("Columns actual count: " + len); + if (len <= 40) cols = 40; + else if (len <= cols); // do nothing & keep cols as default + else cols = len; + return cols; +} + +function changeColors(ff) +// Applies background colour to the body and colour to the
 tag containing
+// the text document.
+// @ff  Font family to apply
+{
+  // only apply colour changes when viewing the stylised text document
+  if (document.getElementById("retrotxt-styles") === null) return;
+  var body = document.body,
+    pre = document.getElementsByTagName("pre")[0],
+    colors = ff.split("-"),
+    rgbs = new rgbColors(),
+    foreground = rgbs[colors[0]],
+    background = rgbs[colors[1]];
+  body.style.backgroundColor = background;
+  pre.style.color = foreground;
+  if (colors[1] === "white") {
+    var h = document.getElementsByTagName("header")[0];
+    if (h !== null) {
+      h.style.color = rgbs.black;
+    }
+  }
+}
+
+function changeFont(ff)
+// Applies the font family to the 
 tag containing the text document.
+// @ff  Font family to apply
+{
+  var defaults = new textDefaults(),
+    font = new fontSettings(ff),
+    header = document.getElementById("h-doc-font"),
+    pre = document.getElementsByTagName("pre")[0],
+    spanCols = document.getElementById("h-doc-width").innerHTML,
+    spanPixels = document.getElementById("h-doc-size"),
+    textWidthPx = 0;
+  // determine width of text and header
+  textWidthPx = font.width * spanCols;
+  // sometimes text contains no fix lines breaks, 
+  // so in that case we use CSS to wrap the text.
+  if (spanCols > defaults.columns && window.innerWidth <= font.width * spanCols) {
+    pre.style.whiteSpace = "pre-line";
+    textWidthPx = font.width * defaults.columns; // override columns with default width
+  }
+  // apply width adjustments
+  pre.style.width = `${textWidthPx}px`;
+  header.style.width = `${textWidthPx}px`;
+  document.getElementById("h-doc-width").title = `Columns of text equalling ${textWidthPx}px`;
+  // apply changes to 
+  pre.style.fontFamily = font.family;
+  pre.style.lineHeight = font.cssLineHeight;
+  pre.style.fontSize = font.cssFontSize;
+  // apply to information 
+ header.innerHTML = font.string; + spanPixels.innerHTML = `${font.width}x${font.height}`; +} + +function changeHeader(colors, elm) +// Depending on the background colour, selects the text colour containing the font/doc information. +// @bgc Background colour name +{ + if (typeof elm !== "object") return; + if (typeof colors === "undefined") return; + var bgc = colors.split("-")[1], + c = "white", + def = new textDefaults(); + if (bgc === "white") c = "black"; + elm.style.color = c; + elm.style.fontFamily = def.family; + elm.style.width = def.width; +} + +function dspOriginalText(elm) +// Display the original, unmodified text document +{ + if (typeof elm !== "object" || typeof elm.body !== "object") { + elm = new pageElements(); + } + //console.log("Showing original document."); + // delete link to CSS + elm.head.removeChild(elm.head.childNodes[0]); + // delete page customisations + elm.body.removeAttribute('style'); + if (elm.preCount >= 2) { + elm.header.style.display = "none"; + elm.pre0.style.display = "none"; + elm.pre1.style.display = null; + } else { + elm.pre0.style.display = null; + } +} + +function dspRetroTxt(elm) +// Display the text document processed by RetroTxt +{ + if (typeof elm !== "object" || typeof elm.body !== "object") { + elm = new pageElements(); + } + //console.log("Showing stylised document."); + chrome.storage.local.get("textFontInformation", function(result) { + var r = result.textFontInformation; + if (typeof r === "boolean" && r === false) elm.header.style.display = "none"; + else elm.header.style.display = "block"; + }); + elm.pre0.style.display = "block"; + elm.pre1.style.display = "none"; +} + +function exeRetroTxt(evt) +// Execute RetroTxt +{ + if (typeof evt !== "string") evt = ""; + var elm = new pageElements(); + + // end the function if the browser tab already had RetroTxt applied + if (evt.split("-")[0] === "tab" && elm.cssLink !== null) return; + + chrome.storage.local.get("retroColor", function(result) { + var r = result.retroColor; + if (typeof r === "string") changeColors(r); + }); + // get and apply user's saved font selection + chrome.storage.local.get("retroFont", function(result) { + var r = result.retroFont; + if (typeof r === "string") changeFont(r); + }); + + // context menu onclick listener + chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + if (message.action === "abortEncoding") { + if (sessionStorage.getItem("abortEncoding") === null) { + // save a session item to tell RetroTxt not to render the text on this tab + sessionStorage.setItem("abortEncoding", true); + } else { + sessionStorage.removeItem("abortEncoding"); + } + // reload the active tab + window.location.reload(); + } + }); + + // monitor for any changed user options to either font or colour selections + chrome.storage.onChanged.addListener(function(changes, namespace) { + // font + if (changes.retroFont) { + changeFont(changes.retroFont.newValue); + } + // colour + else if (changes.retroColor) { + var changedC = changes.retroColor.newValue; + elm.header = document.getElementById("h-doc-container"); + changeColors(changedC); + changeHeader(changedC, elm.header); + // need to also update font shadow colour + chrome.storage.local.get("fontShadows", function(result) { + var r = result.fontShadows, + pre = document.getElementsByTagName("pre")[0]; + if (typeof r === "boolean" && r === true && typeof pre === "object") { + textShadow(true, pre, changedC); + } + }); + } + // information text + else if (changes.textFontInformation) { + var h = document.getElementById("h-doc-container"); + if (typeof h === "object") { + if (!changes.textFontInformation.newValue) h.style.display = "none"; + else h.style.display = "block"; + } + } + // centre alignment + else if (changes.centerAlignment) { + var h = document.body; + if (typeof h === "object" && changes.centerAlignment.newValue) { + elm.body.style.alignItems = "center"; + elm.body.style.justifyContent = "center"; + } else { + elm.body.style.alignItems = "initial"; + elm.body.style.justifyContent = "initial"; + } + } + // shadows + else if (changes.fontShadows) { + var pre = document.getElementsByTagName("pre")[0]; + if (typeof pre === "object") { + textShadow(changes.fontShadows.newValue, pre); + } + } + }); + + /* Switch between the original and our stylised copy of the text document */ + // Original text document + if (elm.cssLink !== null) { + dspOriginalText(elm); + } + // Stylised text document + else { + // make a to point to the custom CSS + var cssLink = linkCSS("text.css", "retrotxt-styles"); + elm.cssLink = document.getElementsByTagName("head")[0].appendChild(cssLink); + elm.cssLink.disabled = false; + elm.body.style.display = "flex"; // use css3 flexbox + elm.body.style.flexDirection = "column"; // stack items + // centre alignment of text + chrome.storage.local.get("centerAlignment", function(result) { + var r = result.centerAlignment; + if (typeof r === "boolean" && r === true) { + elm.body.style.alignItems = "center"; // vertical align + elm.body.style.justifyContent = "center"; // horizontal align + } + }); + // Restore stylised text, hide original unconverted text + if (elm.preCount >= 2) { + dspRetroTxt(elm); + } + // Create a copy of the text document for applying styles. + else { + //console.log("Building stylised document."); + var d0, d1, + newPre = document.createElement("pre"), + newHeader = document.createElement("header"), + txtCols, + txtDef = new textDefaults(), + txtFormat, txtLength, + txtStr = elm.pre0.innerHTML; + + // count the number of text columns + txtCols = calcColumns(txtStr); + + // TODO UTF-8 detection of text, by default JavaScript encodes everything into UTF-16. + + // User forced abort encoding + var utf8abort = sessionStorage.getItem("abortEncoding"); + + // if source text is already encoded in UTF-8, skip the conversion + if (utf8abort !== "true" && utf8abort !== true && (evt.length === 0 || evt.split("-")[1].toLowerCase !== "utf-8")) { + // chrome storage is asynchronous so fetch the user's saved + // options and store them as synchronous sessionStorage + chrome.storage.local.get("cp437CtrlCodes", function(result) { + var r = result.cp437CtrlCodes; + if (typeof r === "boolean") { + sessionStorage.setItem("cp437CtrlCodes", r); + } + }); + // converts cp437/iso/windows 1252 code page text into utf-8 + // run this asynchronously using Promise to speed up performance + var promise = new Promise(function(resolve, reject) { + var d0 = new Date().getTime(), + d1; + //var part1, part2, part3, part4; // sliced text containers + //var p1eol, p2eol, p3eol, p4eol = 0; // end of processing chr. position + var tasks = 1, + txtLen = txtStr.length; + /* + // place holder for future async function support + // http://www.sitepoint.com/javascript-goes-asynchronous-awesome/ + // slice text up into multiple threads if larger than + if (txtLen > 1024 * 40) tasks = 4; // 40KB + else if (txtLen > 1024 * 10) tasks = 2; // 10KB + //tasks = 1; + // synchronous processing + if (tasks <= 1) { + txtFormat = txtConvert(txtStr); + } + // asynchronous processing + else { + p1eol = (txtLen / tasks).toFixed(0); + if (tasks === 2) p2eol = txtLen; + else { + // 4 tasks + p2eol = ((txtLen / tasks) * 2).toFixed(0); + p3eol = ((txtLen / tasks) * 3).toFixed(0); + p4eol = txtLen; + } + part1 = txtStr.slice(0, p1eol); + part2 = txtStr.slice(p1eol++, p2eol); + if (tasks === 4) { + part3 = txtStr.slice(p2eol++, p3eol); + part4 = txtStr.slice(p3eol++, p4eol); + } + part1 = txtConvert(part1); + part2 = txtConvert(part2); + if (tasks === 4) { + part3 = txtConvert(part3); + part4 = txtConvert(part4); + } + if (tasks === 2) { + txtFormat = part1.concat(part2); + } else { + txtFormat = part1.concat(part2, part3, part4); + } + } + */ + txtFormat = txtConvert(txtStr); + d1 = new Date().getTime(); + // count number of lines + txtLength = txtFormat.split(/\r\n|\r|\n/).length; + //console.log("Time taken to convert text: " + (d1 - d0) + " milliseconds"); + if (txtFormat.length < txtLen) { + // the converted text should be at least the same size as the original + reject(Error("Text did not convert correctly, original length " + txtLen + " new length " + txtFormat.length)); + } else { + resolve(txtFormat); + } + }); + promise.then(function(data) { + // inject converted utf-8 encoded text + newPre.innerHTML = data; + }, function(error) { + // if an error occurred then inject the original, unmodified text + newPre.innerHTML = elm.pre0.innerHTML; + console.error(error.message); + }); + } else { + // if unicode encoding detected then inject and use the original text + txtFormat = elm.pre0.innerHTML; + txtLength = txtFormat.split(/\r\n|\r|\n/).length; + newPre.innerHTML = txtFormat; + } + + // lock centring alignment to 640px columns + newPre.style.width = txtDef.width; + + // create the information header + newHeader.id = "h-doc-container"; + newHeader.innerHTML = `${txtCols} x\ + ${txtLength} \ + \ + \ + `; + + // font shadow + chrome.storage.local.get("fontShadows", function(result) { + var r = result.fontShadows; + if (typeof r === "boolean" && r === true) textShadow(r, newPre); + }); + // invert header font colour when using a white background + chrome.storage.local.get("retroColor", function(result) { + var r = result.retroColor; + changeHeader(result.retroColor, newHeader); + }); + // display or hide header + chrome.storage.local.get("textFontInformation", function(result) { + var r = result.textFontInformation; + if (typeof r === "boolean" && r === false) newHeader.style.display = "none"; + }); + // hide original unconverted text + elm.pre0.style.display = "none"; + // insert new tags into HTML DOM + elm.body.insertBefore(newHeader, elm.pre0); + elm.body.insertBefore(newPre, elm.pre0); + } + } +} + +function pageElements() { + this.body = document.body; + this.head = document.getElementsByTagName("head")[0]; + this.header = document.getElementById("h-doc-container"); + this.cssLink = document.getElementById("retrotxt-styles"); + this.preCount = document.getElementsByTagName("pre").length; + this.pre0 = document.getElementsByTagName("pre")[0]; + this.pre1 = document.getElementsByTagName("pre")[1]; +} + +function textDefaults() +// Default font for text information header +{ + this.family = "vga9"; + this.columns = 80; + this.width = "640px"; +} \ No newline at end of file