Coder Social home page Coder Social logo

babel's Introduction

Babel Universal Language Library

Building on the ideas I was exploring over here. The gist: rather than muck about looking for glyph data in a file on a filesystem, just dedicate an entire 2 MB chip to nothing but universal language support. You end up saving on storage space and on RAM, and it's simple: you just point the chip at an address and get the bits as fast as your bus can clock them in.

The goal remains the same: performant display of all the languages of the world.

Background

The GD25Q16C SPI Flash chip can hold 2,097,152 bytes. Squashing everything I put into the GFX fork โ€” bitmaps, width, basic bidirectional info and spacing โ€” got me to 1,923,376 bytes, leaving about 170 KB to play with. So I added:

  • Two more bytes per character for additional metadata, including general category and proper bidi class, for more technically correct bidirectional algorithm implementation
  • A bit to indicate whether the character is whitespace.
  • A bit to indicate word wrapping opportunities.
  • One-to-one case mappings from uppercase to lowercase and lowercase to uppercase / titlecase for all bicameral scripts in the Basic Multilingual Plane.
  • Mappings of supported BMP glyphs to their mirror images, for correct bidirectional mirroring in right-to-left text runs.
  • A lookup table for mapping isolated Perso-Arabic characters to connected presentation forms.

This still leaves just over 25 kilobytes at the end, for more mappings or other glyph-specific features. There are also two free bits per character in the additional metadata field, for general features that apply to all glyphs. Haven't decided how to use them yet.

As of February 2020 I'm considering a return to the filesystem use case, for a couple of reasons: one, most of the devices I want to use this with already have a Flash chip; making it bigger is cheaper than adding a second one. It also frees up a microcontroller pin. Mostly though it opens up the possibility of supporting more Unicode planes; without the 2MB limitation, we can add even more glyphs!

Project Structure

  • babelconvert - a hastily assembled python script to generate the Flash image.
  • src - an Arduino library that allows basic access to the glyph data and metadata. Very work-in-progress.
  • BabelTest and BabelTest.xcodeproj - Uses the same base class from src but implements a mock version using a file on the file system. Good for testing.
  • examples - Arduino sketches:
    • BurnBabelBurn burns the Babel image to a chip.
    • BabelView dumps all character info to Serial.
  • sample.txt - output of the BabelTest tool, previews of all glyphs plus what the babel.bin metadata says about them.

Next Steps

  • Create a subclass of Babel that can draw text to a GFX display.
    • Handle screen size and margins, clipping
    • Handle character wrapping
    • Handle RTL direction changes
    • Handle combining marks
    • Glyph magnification (i.e. size=2)
  • String manipulation
    • Uppercase
    • Lowercase
    • Capitalization
    • Word wrap (WIP)
  • Make a simple FeatherWing with the chip, for easier testing on more devices.
  • Port to CircuitPython!

babel's People

Contributors

josecastillo avatar joeycastillo 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.