Zoltan Baldaszti 43af6f21b0 Workaround qemu segfault 1 سال پیش
..
Makefile 426205e2a3 Added makefiles for LLVM Clang 5 سال پیش
Makefile.clang 9c5c2813a0 Update QEMU command in all README and Makefile 2 سال پیش
Makefile.gcc 9c5c2813a0 Update QEMU command in all README and Makefile 2 سال پیش
OLVASSEL.md c819f2087d Added printing UTF-8 strings example 4 سال پیش
README.md 907c77f8fa Fixed typos 2 سال پیش
delays.c 910619de4c fix missing semicolon 1 سال پیش
delays.h 7ace64ba9f Initial commit 6 سال پیش
font.psf 7ace64ba9f Initial commit 6 سال پیش
font.sfn c819f2087d Added printing UTF-8 strings example 4 سال پیش
gpio.h 7ace64ba9f Initial commit 6 سال پیش
kernel8.img c819f2087d Added printing UTF-8 strings example 4 سال پیش
lfb.c 43af6f21b0 Workaround qemu segfault 1 سال پیش
lfb.h c819f2087d Added printing UTF-8 strings example 4 سال پیش
link.ld 7ace64ba9f Initial commit 6 سال پیش
main.c c819f2087d Added printing UTF-8 strings example 4 سال پیش
mbox.c 214885df63 compute the mailbox cmd only once 6 سال پیش
mbox.h 7ace64ba9f Initial commit 6 سال پیش
start.S ea4691947c Improve comments wrt stack setup 3 سال پیش
uart.c 8a80ab88b9 Clearified mbox call in uart per issue #49 6 سال پیش
uart.h 7ace64ba9f Initial commit 6 سال پیش

README.md

Tutorial 0A - PC Screen Font

Drawing pixmaps is fun, but definitely there's a need to display characters as well. Basicaly fonts are nothing more than bitmaps for each character. For this tutorial I choosed PC Screen Font format, the same Linux Console uses.

UPDATE: because I had many requests, I've added demonstration on how to print UTF-8 strings.

Lfb.h, lfb.c

lfb_init() sets up resolution, depth, and color channel order. Also queries framebuffer's address.

lfb_print(x,y,s) displays a string on screen with fixed-sized glyphs using PSF.

lfb_proprint(x,y,s) displays a string on screen with proportional SSFN font.

Font.psf

The font file. Use any file from /usr/share/kbd/consolefonts. Unicode table is not supported. Translating characters to glyph index using that table (instead of one-to-one relation) is a homework for you. This font is generated from the original IBM PC VGA 8x16 Font ROM, and includes 127 glyphs.

Font.sfn

One of the biggest drawbacks of PSF that it does not store glyph metrics. To support UTF-8 strings, you will need proportional fonts (that is, 8x16 bitmaps for Latin script and 16x16 for CJK glyphs for example). So I've added a demonstration on how to use Scalable Screen Font to overcome this. More information, example fonts and font converter can be found in the SSFN repository.

Makefile

I've added two object files, generated from the psf and sfn fonts. It's a good example of how to include and reference a binary file in C. I've used the following command to find out the label:

$ aarch64-elf-readelf -s font_psf.o
        ... output removed for clarity ...
     2: 0000000000000820     0 NOTYPE  GLOBAL DEFAULT    1 _binary_font_psf_end
     3: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 _binary_font_psf_start
     4: 0000000000000820     0 NOTYPE  GLOBAL DEFAULT  ABS _binary_font_psf_size

Main

Very simple. We set the resolution and display the string. First with PSF, and then with SSFN.