Last active
June 23, 2021 17:25
-
-
Save drdnar/57bb2f69598d5f8533cd25d824e87eb4 to your computer and use it in GitHub Desktop.
FontLibC font in a .asm file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section .text | |
assume adl = 1 | |
; Exposes the _myfont symbol for other source code files to see. | |
public _myfont | |
; Note the underscore prefix on the name. This is required for linking with C | |
; code. | |
_myfont: | |
; FONT METADATA | |
; Code Page = ASCII | |
db 0 ; font format version | |
db 14 ; height | |
db 2 ; glyph count, if you have 256 glyphs this would be 0 not 256 (a 0-glyph font is considered invalid) | |
db 01Bh ; first codepoint | |
dl myfont_widthsTable - myfont ; offset to widths table | |
dl myfont_bitmapsTable - myfont ; offset to bitmaps offsets table | |
db 0 ; italics space adjust | |
db 0 ; suggested blank space above | |
db 0 ; suggested blank space below | |
db 128 ; weight (boldness/thinness) | |
db 8 ; style field | |
; These allow for vertical alignment of different fonts. | |
db 0 ; capital height | |
db 3 ; lowercase x height | |
db 7 ; baseline height | |
myfont_widthsTable: ; start of widths table | |
db 11 ; Code point 1B: Square root symbol | |
db 7 ; Code point 1C: Less-than-equal-to symbol | |
myfont_bitmapsTable: ; start of table of offsets to bitmaps | |
; Subtract 0 for a glyph 3 bytes wide. | |
; Subtract 1 for a glyph 2 bytes wide. | |
; Subtract 2 for a glyph 1 byte wide. | |
; This weirdness allows a small optimization in FontLibC. | |
dw myfont_glyph_1B - myfont - 1 | |
dw myfont_glyph_1C - myfont - 2 | |
myfont_glyph_1B: ; Code point 1B: Square root symbol | |
; Bitmap data are left-aligned. | |
; For a glyph 1 byte wide, use db. | |
; For a glyph 2 bytes wide, use dw. | |
; For a glyph 3 bytes wide, use dl. | |
dw 0000000000000000b | |
dw 0000000011000000b | |
dw 0000000011000000b | |
dw 0000000110000000b | |
dw 0000000110000000b | |
dw 0000000110000000b | |
dw 0000001100000000b | |
dw 1110001100000000b | |
dw 1110001100000000b | |
dw 0011011000000000b | |
dw 0011011000000000b | |
dw 0001110000000000b | |
dw 0001110000000000b | |
dw 0000000000000000b | |
myfont_glyph_1C: ; Code point 1C: Less-than-equal-to symbol | |
db 00000000b | |
db 00000000b | |
db 00000000b | |
db 00000000b | |
db 00011100b | |
db 01110000b | |
db 11000000b | |
db 01110000b | |
db 00011100b | |
db 00000000b | |
db 11111100b | |
db 00000000b | |
db 00000000b | |
db 00000000b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MYFONT_H | |
#define MYFONT_H | |
#include <fontlibc.h> | |
extern "C" const fontlib_font_t *myfont; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment