Code Monkey home page Code Monkey logo

embedded-fonts's Introduction

FONTX2 fonts for embedded projects

This repository contains the public domain bitmap fonts to be used in embedded projects. The fonts are in FONTX2 format.

X Window System

These are the classic public domain X Window System bitmap fonts. ISO 10646-1 source files were downloaded from Dr Markus Kuhn's page and 8-bit encoding variants were generated with the provided Makefile. See X11 for preview of all different variants.

$ mkdir ucs-fonts
$ cd ucs-fonts
$ wget https://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz
$ wget https://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts-asian.tar.gz
$ tar -xzvf *.tar.gz
$ cd submission
$ make all-bdfs

And then regenerate everything.

$ git clone [email protected]:tuupola/embedded-fonts.git
$ cd embedded-fonts
$ make

Unscii

Unscii is a set of bitmapped Unicode fonts based on classic system fonts. Unscii attempts to support character cell art well while also being suitable for terminal and programming use. See misc/viznut/ for preview of all different variants.

$ cd fonts/misc/viznut
$ make

FONTX2 tools

To generate all files by yourself install FONTX2 tools.

$ git clone [email protected]:tuupola/fontx2_tools.git
$ cd fontx2_tools
$ make && make install

embedded-fonts's People

Contributors

tuupola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

embedded-fonts's Issues

Some fonts do not render correctly or at all

I saw that I couldn't render text with the unscii-8-fantasy font in my Pico VGA HAGL HAL, but it worked with X11 font8x13.

To verify it doesn't come from my HAL, I made a little example outputting text to GD HAGL HAL (by duplicating and adapting palette.c):

/*

MIT No Attribution

Copyright (c) 2018-2021 Mika Tuupola

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-cut-

SPDX-License-Identifier: MIT-0

*/

#include <time.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>

#include "hagl_hal.h"
#include "hagl.h"
#include "external/embedded-fonts/X11/include/font8x13.h"
#include "external/embedded-fonts/X11/include/font10x20.h"
#include "external/embedded-fonts/misc/viznut/include/unscii-8-fantasy.h"

int main()
{
    color_t color1 = hagl_color(128, 255, 255);
    color_t color2 = hagl_color(255, 128, 255);
    color_t color3 = hagl_color(255, 255, 128);
    uint16_t x, y;
    clock_t start, end;
    double time_spent;
    size_t bytes;

    wchar_t *text = L"The Quick Brown Fox Jumps Over The Lazy Dog 0123456789 Times!";

    hagl_init();
    start = clock();

    x = (DISPLAY_WIDTH  / 2) - wcslen(text) * 8 / 2;
    y = (DISPLAY_HEIGHT / 2) - 13 * 4;
    hagl_draw_rectangle(x - 2, y - 2, x + wcslen(text) * 8 + 2, y + 13 + 2, color1);
    hagl_put_text(text, x, y, color1, font8x13);

    x = (DISPLAY_WIDTH  / 2) - wcslen(text) * 10 / 2;
    y = (DISPLAY_HEIGHT / 2) - 20 / 2;
    hagl_draw_rectangle(x - 2, y - 2, x + wcslen(text) * 10 + 2, y + 20 + 2, color2);
    hagl_put_text(text, x, y, color2, font10x20);

    x = (DISPLAY_WIDTH  / 2) - wcslen(text) * 8 / 2;
    y = (DISPLAY_HEIGHT / 2) + 8 * 4;
    hagl_draw_rectangle(x - 2, y - 2, x + wcslen(text) * 8 + 2, y + 8 + 2, color3);
    hagl_put_text(text, x, y, color3, unscii_8_fantasy);

    end = clock();
    time_spent = (double)(end - start) / CLOCKS_PER_SEC;
    bytes = hagl_flush();
    printf("\nGenerated %zu bytes in %g seconds.\n\n", bytes, time_spent);
    hagl_close();

    return 0;
}

The result is below:

  • font8x13 OK
  • font10x20 displays garbage
  • unscii_8_fantasy doesn't show at all

hagl

Limited to 255 code blocks

I have noticed that the Number of code blocks is limited to 255, yet font 10x20 has 609 or 0x261 blocks so the value in position 17 is 0x61, the MSB is lost. Calculating the Font Image data position is therefore not possible.

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.