1 049 352 …. Bytes !!!

1 049 352 bytes !!  Ironically just 776 bytes after 1 MegaByte !!

(which is 1024*1024= 1048576 bytes)

To my surprise, this will be more or less the final size of #MathTouchBook for Android, that is to be released within the coming week (for sure, I promise, btw it’s a scoop !).

Capture d’écran 2016-02-05 à 22.50.35

The Apple iPhone/iPad version is more likely to weight 3 or 4 Mb, due to some external program libraries that iOS needs.

I wasn’t expecting less than One Mega for this App, this is great news to discover that thin number ! As light as powerful !

What happened ? I planned to include the Facebook SDK at first (3Mb), but I realised the “Share with Intent” system from Android was better. So I cleaned all the useless stuffs and logs from the App…

The tool is primarily using only my own C++ libraries, but I was a bit afraid because of the use of templates at some points in the code: C++ templates can really be useful for coding Maths because they allow to “Overload” simple operators (Addition,Substraction,Multiplication, whatever else.) by making abstraction of the actual type of your data. (Well, more or less.)


But C++ is an old language and C++ templates have a big disadvantage: Every template’s functions operators and methods you use is recompiled each time you use it. I mean: when you read a data in a map (C++’s hash table) , the whole read code is compiled for each call. ( for the record, only allocators are external with templates, and C++ libs like boost stands in includes and not .cpp for these reasons.)

But even if it has a funky side, MathTouchBook is an App with 95% Code and 5% data, so it’s really a “Algorithms and nothing else” approach. Beside that, I only have some little mp3 and PNG out there ! – Just what you need ! Capture d’écran 2016-02-04 à 13.11.58


Rendering Nice Characters In a 3D Engine

Let me tell you a developer story:Capture d’écran 2016-01-30 à 15.43.02

I always thought most vectorial font engines where limited when it comes to dynamise things a bit. I mean, drawing texts in applications: Everything is always static and monochrome.
With a Graphical API like OpenGL, and even more so, OpenGL ES for mobile, there is little hope to find a really interesting library that fits my needs.

Basically, I want all characters fitting one OpenGl texture, possibly colored, I also want my text drawing routine to make the characters dance, and finally I want to be able to create my own special characters within an existing font.
So I investigated on the best way to develop such a font engine…

Surprisingly, I found a way to not spend years creating my own font format. The two key words here are SVG and batik.

Capture d’écran 2016-01-30 à 15.19.33 SVG is a format for vectorial images, it is widely used to create nice colored vector images, and nice free applications like Inkscape are available to draw such images.
Batik is a set of open-source libraries maintained by Apache to draw and manipulate SVG, written in Java.

The interesting detail is that SVG is meant to have an inner Font format, some way to define a complete set of characters, within a SVG document. it seems obsolete, because none of the SVG tool I know use this “define my own font” feature. But there is an Open-Source “ttf to SVG Font” converter within batik. Here we are…

Capture d’écran 2016-01-30 à 15.16.41

I patched the java batik ttf converter to output another kind of SVG, that splits characters into Inkscape layers: So I can redraw  and optimize an existing font using Inkscape, and add my own characters in it.

Then I did a second tool, that converts SVG characters to a format I can draw on opengl textures. At this level, SVG helps again because it only contains simple quadratic bezier curves.Capture d’écran 2016-01-30 à 15.32.33.png

 Then I can directly use that for the real time rendering !
This engine was used to draw more funky texts in my previous game, and now it allows me to add specific mathematical symbols in my app. It inits the bitmaps very quickly, and allows each equations of Math Touch book to be drawn in one OpenGl call.
It was actually some weeks of work, but it really opened a lots of possibilities and works with all minimal OpenGl Configurations.