Giter Site home page Giter Site logo

viler-int10h / fontraption Goto Github PK

View Code? Open in Web Editor NEW
85.0 6.0 5.0 313 KB

A tiny but powerful VGA text mode font editor for DOS

License: MIT License

Assembly 99.97% Batchfile 0.03%
vga font font-editor bitmap-font ansi-art ascii-art textmode asm assembly-x86 x86-16

fontraption's Introduction

fontraption

A tiny but powerful VGA text mode font editor for DOS.

  • Assemble w/build.bat (FASM required)
  • See FRAPT.TXT for full documentation
  • A large collection of fonts is available separately: VGA text mode fonts

Key features:

  • Edit two fonts at a time, using tabs to keep the UI consistent
  • Flexible clipboard transfer of full/partial characters or character ranges
  • Various block manipulation functions: flip X/Y, fill/erase, invert, slide
  • Grab any of the built-in fonts from the VGA BIOS ROM
  • Save/load as raw binary data; import/export BMP, XBIN and COM (plain/TSR)
  • Supports any font height that VGA text mode can handle, up to 32 lines
  • Preview your font in 40 or 80 columns (8 or 9 pixels per column)
  • Uses pure text mode for speed; runs on any VGA-capable system (8088 and up)
  • Various palettes, a decent file browser, etc.

Screenshots:

fontraption's People

Contributors

viler-int10h avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fontraption's Issues

Making Fontraption resident

Hi, today I was drawing some text interfaces in The Draw and I was thinking how nice would be to have Fontraption resident, load it, load some font and keep drawing, this can be used also in text editors, or other ANSI editors as AcidDraw, so you can load it and edit or load/save fonts whenever you like.
I know fonts can be activated from commandline, but having it resident all the time could be a nice feature.
Regards.

I wrote a library to convert to BDF

Is this of interest? If so I can publish it

from collections.abc import Generator, Iterable
from copy import deepcopy
from more_itertools import chunked

from bitarray import bitarray
from bdflib.model import Font as BDFLibFont
from ibm437 import to_ibm437
import bdflib.writer
import bdflib.xlfd
import os.path


class Font:
    def __init__(
        self,
        filename: str,
        strict=True,
        bits_per_scanline_byte: int = 8,
        bytes_per_scanline: int = 1,
    ):
        self.filename = filename
        self.strict = strict
        self.bpsb = bits_per_scanline_byte
        self.bpsl = bytes_per_scanline
        self.populate_filename_info()
        self.fontbuf = bitarray()
        with open(filename, "rb") as f:
            self.fontbuf.fromfile(f)
        self.populate_glyphs()

    def populate_filename_info(self) -> int:
        temp = self.filename.split(".F")
        assert len(temp) == 2, "Bad filename!"
        fontname, self.scanlines_per = temp
        assert all(
            c.isdigit() for c in self.scanlines_per
        ), "Non-digits in scanline specifier!"
        self.scanlines_per = int(self.scanlines_per)
        assert (
            0 < self.scanlines_per <= 32
        ), f"Scanline count {self.scanlines_per} not between 0…32!"
        assert self.bpsl in (1, 2), f"Only 1 or 2 bytes per scanline allowed!"
        self.family = fontname.split(os.path.sep)[-1]
        return self.scanlines_per

    def _glyphs_gen(self) -> Generator[Generator[list[int]]]:
        return chunked(
            list(chunked(list(self.fontbuf), self.bpsb * self.bpsl, strict=True)),
            self.scanlines_per,
            strict=False,
        )

    def populate_glyphs(self) -> None:
        self.glyphs = list()
        for glyph in self._glyphs_gen():
            self.glyphs.append(glyph)

    @staticmethod
    def expand_glyph(
        glyph: Iterable[Iterable[list[int]]], boxdrawing: bool = True
    ) -> Generator[list[str]]:

        if boxdrawing:
            chars = " █"
        else:
            chars = "01"

        def expand_line(line: list[int]) -> str:
            return "".join([chars[1] if i else chars[0] for i in line])

        for l in glyph:
            yield expand_line(l)

    def expanded_glyphs(self, **kwargs) -> Generator[str]:
        for g in self.glyphs:
            yield "\n".join(Font.expand_glyph(g, **kwargs))

    def pretty(self) -> str:
        return "\n\n".join(
            [
                "Glyph 0x{i:X} ({c}):\n\n{g}".format(c=to_ibm437(i), i=i, g=g)
                for i, g in enumerate(self.expanded_glyphs())
            ]
        )


class BDF(BDFLibFont):
    @staticmethod
    def _convert_glyph_data(glyph):
        return list(reversed([int("".join([str(bb) for bb in b]), 2) for b in glyph]))

    def __init__(self, font: Font):
        self.name = font.family.replace("&", "").encode("ascii")
        self.ptSize = font.scanlines_per
        self.xdpi = self.ydpi = 100
        super().__init__(self.name, self.ptSize, self.xdpi, self.ydpi)
        for i, glyph in enumerate(font.glyphs):
            cp = ord(to_ibm437(i))
            glyph_data = dict(
                codepoint=cp, bbW=font.bpsb, bbH=font.scanlines_per, advance=font.bpsb
            )
            gname = "uni{:04X}".format(cp).encode("ascii")
            gdata = BDF._convert_glyph_data(glyph)
            self.new_glyph_from_data(gname, gdata, **glyph_data)


def main():
    import sys

    _, FONT = sys.argv
    assert ".F" in FONT
    parsed = Font(FONT)
    # print(parsed.pretty())
    bdf = BDF(parsed)
    bdflib.xlfd.fix(bdf)
    bdf.properties[bdflib.xlfd.CHARSET_REGISTRY] = b"Unicode"
    bdflib.writer.write_bdf(bdf, sys.stdout.buffer)


if __name__ == "__main__":
    main()

How to apply my new font to the whole system

I made my own font with your charming app. but I don't know how to apply it to the system.
is there any way to make an EXE file when I run it and apply the font?
I made a Persian/Arabic font and I want to use it when I left [Fontraption]

Port to an easier assembler setup for better assembly!

Hello, Love the Font editor you created, I may ask, Can you port it to a much better setup such as compiling on x64 (64bit) operating systems while maintaining DOS compatibility for generating executables, Flat Assembler G, or NASM alternatively, could do the job nicely.

Again, I appreciate the good work. Thank you.

FRAPT doesn't export font 2 correctly

Reproduce:

  • Switch to font 2.
  • Edit the "A" character.
  • Export to a .com file
  • Run the com file.

Expected:

  • Font 2 is changed, normal font doesn't change.

What I saw:

  • "A" is replaced in font 1 of the VGA mem.

Add Export to Pascal Data (Turbo and Free Pascal compatible),

I'm using Fontraption and seem to notice that there is a lack of a Pascal Export in it. so can you make a built-in pascal converter so we can include it in the next version, please?

I'm currently using DosBox and an outdated utility called Font Mania, which is a Dos utility that lets you output Dos binary .CHR/.Fxx fonts as pascal data. It was useful. but need something newer and free.

Good luck

-Hamtaro126

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.