Giter Club home page Giter Club logo

vga-font-editor's Introduction

VGA FONT EDITOR

This is a cross-platform editor and library for VGA ROM fonts. This has code for rendering text using a loaded font. The source code is written in QB64-PE and works natively without using any third party libraries. Selecting and editing using the mouse is supported.

Screenshot Screenshot Screenshot Screenshot

What is a VGA ROM font?

These are fonts that are embedded in the VGA ROM BIOS. To learn more about VGA ROM fonts see:

How is a character stored in memory?

It's quite simple, 0 encodes background, 1 encodes foreground color. VGA fonts are always 8 bits wide so that each byte contains exactly one row. For letter 'A' in the typical 8x16 font it would be (in binary):

00000000b  byte  0
00000000b  byte  1
00000000b  byte  2
00010000b  byte  3
00111000b  byte  4
01101100b  byte  5
11000110b  byte  6
11000110b  byte  7
11111110b  byte  8
11000110b  byte  9
11000110b  byte 10
11000110b  byte 11
11000110b  byte 12
00000000b  byte 13
00000000b  byte 14
00000000b  byte 15

The full bitmap contains bitmaps for every character, thus it's 256*16 bytes, 4096 bytes long (for 8x16 fonts). If you want to get the bitmap for a specific character, you have to multiply the ASCII code by 16 (number of rows in a character for 8x16 fonts).

What are these PSF files?

These PSFs (PC Screen Font) were created using the bin2psf conversion tool from raw VGA ROM font dumps from various sources. These files are extemely small and suitable for embedded, memory limited or retro projects. The files are almost a raw dump of the VGA ROM font with just a few bytes for the header.

               FONT FILE FORMAT
+--------------------------------------------+
| PSF1_MAGIC0 0x36 (1 byte)                  |
+--------------------------------------------+
| PSF1_MAGIC1 0x04 (1 byte)                  |
+--------------------------------------------+
| MODE (1 byte)                              |
+--------------------------------------------+
| FONT HEIGHT (1 byte)                       |
+--------------------------------------------+
| CHAR 1 SCAN LINE 1 (1 byte)                |
| CHAR 1 SCAN LINE 2 (1 byte)                |
| CHAR 1 SCAN LINE 3 (1 byte)                |
| CHAR 1 SCAN LINE 4 (1 byte)                |
| CHAR 1 SCAN LINE 5 (1 byte)                |
|                    ..                      |
|                    ..                      |
|                    ..                      |
| CHAR 1 SCAN LINE <FONT HEIGHT>  (1 byte)   |
+--------------------------------------------+
| CHAR 2 SCAN LINE 1 (1 byte)                |
| CHAR 2 SCAN LINE 2 (1 byte)                |
| CHAR 2 SCAN LINE 3 (1 byte)                |
| CHAR 2 SCAN LINE 4 (1 byte)                |
| CHAR 2 SCAN LINE 5 (1 byte)                |
|                    ..                      |
|                    ..                      |
|                    ..                      |
| CHAR 2 SCAN LINE <FONT HEIGHT>  (1 byte)   |
+--------------------------------------------+
|                    ..                      |
|                    ..                      |
|                    ..                      |
+--------------------------------------------+
|                    ..                      |
|                    ..                      |
|                    ..                      |
+--------------------------------------------+
|                    ..                      |
|                    ..                      |
|                    ..                      |
+--------------------------------------------+
| CHAR 256 SCAN LINE 1 (1 byte)              |
| CHAR 256 SCAN LINE 2 (1 byte)              |
| CHAR 256 SCAN LINE 3 (1 byte)              |
| CHAR 256 SCAN LINE 4 (1 byte)              |
| CHAR 256 SCAN LINE 5 (1 byte)              |
|                    ..                      |
|                    ..                      |
|                    ..                      |
| CHAR 256 SCAN LINE <FONT HEIGHT>  (1 byte) |
+--------------------------------------------+

What can I do with this?

Anything you want! You may use the file format or sourcecode for embedded, retro, game projects and more. This does not require you to have DOS or any old PC hardware. All code here is written for modern hardware. The font file format is super simple and the text rendering code is straightforward and clean. With very little effort, the rendering code can be ported to your favorite programming language and library. There are many example fonts in the fonts directory. I honestly do not know the orginal souces of these and highly recommend you to create your own fonts using this tool for your projects.

API

Function ReadFont%% (sFile As String, ignoreMode As Byte)
Function WriteFont%% (sFile As String)
Sub DrawCharacter (nChar As Unsigned Byte, x As Long, y As Long)
Sub DrawString (sText As String, x As Long, y As Long)

Assets

Important note

The editor uses new features introduced in QB64-PE v3.4+ and as such may not work correctly or reliably with older versions of QB64-PE or any version of QB64. You've been warned. Please don't nag me about backwards compatiblity.

vga-font-editor's People

Contributors

a740g avatar

Stargazers

Cory Smith avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.