Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: a1ex on September 07, 2013, 11:51:30 AM

Title: Proportional fonts
Post by: a1ex on September 07, 2013, 11:51:30 AM
Bitbucket discussion here: https://bitbucket.org/hudson/magic-lantern/pull-request/222/added-rbf-font-support/diff
Source code here: https://bitbucket.org/g3gg0/magic-lantern-rbf

If you don't see major issues (like significant slowdown, much higher memory usage, completely unreadable fonts on some displays, or everybody likes the old fonts), I'd say it can be merged (and g3gg0 said the same).

History:

[aug26] stevefal suggests (http://www.magiclantern.fm/forum/index.php?topic=7889.msg70467#msg70467) (once again) to use proportional fonts.

[sep03] g3gg0 ported RBF font format from CHDK.

[sep07] proportional fonts are already usable (of course, ther's still a bunch of things to fine-tune)


Screenshots (may change, since stevefal is still fine-tuning the fonts)
(http://a1ex.magiclantern.fm/bleeding-edge/newfont.png)

New printing API:

Centered text (example from spotmeter):

        bmp_printf(
            fnt | FONT_ALIGN_CENTER,
            xcb, ycb,
            "#%02x%02x%02x",
            R,G,B
        );



Right-aligned text, clipped if it exceeds some maximum width (example from module name in Modules tab):

int fg = COLOR_GRAY(40);
int bg = COLOR_BLACK;
int fnt = SHADOW_FONT(FONT(FONT_MED, fg, bg));
bmp_printf(fnt | FONT_ALIGN_RIGHT | FONT_TEXT_WIDTH(300), 690, info->y+5, name);



Justified text with manual line breaking (example from module README):

big_bmp_printf(FONT_MED | FONT_ALIGN_JUSTIFIED | FONT_TEXT_WIDTH(690), 10, 60, "%s", desc);



Special characters (ISO, small 1/ or f/, degree symbol)

bmp_printf( font, x, y,"T=%d"SYM_DEGREE"C", EFIC_CELSIUS);

-bmp_printf(..., "ISO %d 1/%d f/%d.%d %dK", iso, shutter, aperture, kelvin)
+bmp_printf(..., SYM_ISO"%d "SYM_1_SLASH"%d "SYM_F_SLASH"%d.%d %dK", iso, shutter, aperture, kelvin



#define SYM_DOTS        "\x7F"
#define SYM_ISO         "\x80"
#define SYM_F_SLASH     "\x81"
#define SYM_1_SLASH     "\x82"
#define SYM_DEGREE      "\x83"
#define SYM_MICRO       "\x84"     /* maybe not needed */
#define SYM_PLUSMINUS   "\x85"
#define SYM_LV          "\x86"
#define SYM_BULLET      "\x87"
#define SYM_EM_DASH     "\x88"



Expanded/condensed text (not yet implemented):

FONT_EXPAND(x) /* range: -4 ... +3 pixels per character */

Title: Re: Proportional fonts
Post by: Marsu42 on September 08, 2013, 10:37:10 AM
Quote from: a1ex on September 07, 2013, 11:51:30 AM
Bitbucket discussion here

You suggested to "drop that codepage stuff, since I don't see localization anytime soon (maintenance nightmare)". I dunno about the string localization discussion, as some of the ideas in the respective thread seem very practical and reasonable to me - but barring that way for the future now when a new feature like proportional fonts is introduced, is adding codepages really that much of an overhead in itself?
Title: Re: Proportional fonts
Post by: a1ex on September 08, 2013, 10:54:46 AM
You can undo that changeset later if you really want.
Title: bmp_printf enhancement
Post by: stevefal on September 18, 2013, 03:21:04 AM
Idea to have bmp_printf return the height & width of string printed, in order to help horizontal and vertical arrangement of of elements without hard-coded offsets.

Likewise bmp_printf_get_size, in order to compute string sizes offscreen, before printing - for centering etc.

This should be handy when proportional fonts are introduced. When used, it will aide swapping fonts without lots of manual fix-ups. It should also help implement layout changes without as much trial and error.
Title: Re: Proportional fonts
Post by: a1ex on September 19, 2013, 09:58:38 AM
Code is now in the main repo.

Please look for redraw issues (like unreadable text or things looking funny) and post screenshots.
Title: Re: Proportional fonts
Post by: RenatoPhoto on September 19, 2013, 05:11:31 PM
Quote from: a1ex on September 19, 2013, 09:58:38 AM
Code is now in the main repo.

Please look for redraw issues (like unreadable text or things looking funny) and post screenshots.
I compiled but during camera boot there is some unreadable message about fonts..  I suppose I need new stuff for the ML directory.  I have never generated that other stuff like data, docs, etc.

Is there a thread explaining this procedure?
Title: Re: Proportional fonts
Post by: a1ex on September 19, 2013, 05:14:58 PM
Did you run "make install" or try the nightly?
Title: Re: Proportional fonts
Post by: RenatoPhoto on September 19, 2013, 05:33:12 PM
Quote from: a1ex on September 19, 2013, 05:14:58 PM
Did you run "make install" or try the nightly?
Thanks, I got it working with the ML structure files from nightly!

I still need to learn the make install stuff!  :o
Title: Re: Proportional fonts
Post by: Marsu42 on September 19, 2013, 09:25:03 PM
Quote from: a1ex on September 19, 2013, 09:58:38 AM
Code is now in the main repo.

Great work, looks good and as a space saver solves the char counting in the menu :-)

One suggestion: If you've got access to the Canon font, any messages which are usually short on the lv screen should also be in the Canon font for a more coherent experience.

Quote from: RenatoPhoto on September 19, 2013, 05:11:31 PM
I compiled but during camera boot there is some unreadable message about fonts..

You just need to copy the "fonts" dir from the source root to the card to ml/fonts
Title: Re: Proportional fonts
Post by: stevefal on September 20, 2013, 03:03:36 AM
Now that we're fairly settled on the small(23), medium(28) and large(32) sizes, I'll go through and refine all of them. Here's the first:

Argand Normal 32 v.51 http://popspring.com/mldrop/argnor32.rbf

- Improved 389aABghWXKPRUIryzijkn<>+-^™
- Added '×' symbol to use instead of 'x' in dimensions
Title: Re: Proportional fonts
Post by: Andy600 on September 20, 2013, 03:18:07 AM
@stevefal - Thanks for your work! The new fonts are looking really good on the 50D  :)
Title: Re: Proportional fonts
Post by: glubber on September 20, 2013, 08:59:35 AM
Quote from: Andy600 on September 20, 2013, 03:18:07 AM
@stevefal - Thanks for your work! The new fonts are looking really good on the 50D  :)

With the new fonts it feels like having Magic Lantern 3.0  :D
Title: Re: Proportional fonts
Post by: Stedda on September 20, 2013, 01:55:13 PM
Fonts look classy. Love em! THANKS!!!!!!!!!!!!!  8)
Title: Re: Proportional fonts
Post by: LucaBrasi on September 20, 2013, 02:18:19 PM

Quote from: glubber
With the new fonts it feels like having Magic Lantern 3.0  :D

Agree, looks great!!
Title: Re: Proportional fonts
Post by: stevefal on September 20, 2013, 02:22:42 PM
Thanks to g3gg0 and a1ex for implementing support for new fonts.
Title: Re: Proportional fonts
Post by: SpcCb on September 20, 2013, 04:48:12 PM
Tested on 5D mkII: good job, it's more clear and a bit bigger (easer to read). 8)
Title: Re: Proportional fonts
Post by: stevefal on September 21, 2013, 03:20:57 AM
Updates:

Argand Normal 32 v.52 http://popspring.com/mldrop/argnor32.rbf

- Improved cge%$
- Added mm cm
- Removed long dash

Argand Normal 28 v.52 http://popspring.com/mldrop/argnor28.rbf

- Improved  mm cm PBZ:"$'!()abdpqyglv02345
- Added '×'
Title: Re: Proportional fonts
Post by: hjfilmspeed on September 21, 2013, 06:12:12 AM
running sep 20th on 5d3 and loving the new fonts!!!!!!! AWESOME!!!!!! Thank you for giving me a brand new 5d3!!!!
Title: Re: Proportional fonts
Post by: britom on September 21, 2013, 08:07:35 AM
tried on my 7d... works and looks great, but had to disable all modules, and when i enable the raw_rec module it shows a memory error in the debug menu: Last error: 4 at libtcc.c:222, task module_task

maybe there is something on the memory refactoring thing that needs to be ported or fixed for the 7d
Title: Re: Proportional fonts
Post by: dmilligan on September 21, 2013, 05:11:28 PM
I'm getting the same error as britom on my 60D, it also doesn't seem to matter which modules are loaded, load any module and this happens. Though everything seems to work fine. (compiled myself from changeset 4b3129d)
Title: Re: Proportional fonts
Post by: SpcCb on September 22, 2013, 03:07:03 AM
(error, sorry)
Title: Re: Proportional fonts
Post by: stevefal on September 22, 2013, 06:16:58 PM
Updates:

Argand Normal 32 v.53 http://popspring.com/mldrop/argnor32.rbf
Argand Normal 28 v.53 http://popspring.com/mldrop/argnor28.rbf

replaced mm and cm symbols with small 'c' and 'm' characters with tight spacing, combinable to create small mm, cm, and m symbols in bottombar etc.
Title: Re: Proportional fonts
Post by: Marsu42 on September 22, 2013, 08:28:39 PM
Quote from: britom on September 21, 2013, 08:07:35 AM
tried on my 7d... works and looks great, but had to disable all modules, and when i enable the raw_rec module it shows a memory error in the debug menu: Last error: 4 at libtcc.c:222, task module_task

Same thing on my 60d - and in addition live view craps out after some time with an err 80 which might be a hardware problem on my side, but then again it might not and ml is to blame (I didn't try reverting to an older build yet to debug).
Title: Re: Proportional fonts
Post by: stevefal on September 22, 2013, 10:16:03 PM
Updates:

Argand Normal 32 v.54 http://popspring.com/mldrop/argnor32.rbf
Argand Normal 28 v.54 http://popspring.com/mldrop/argnor28.rbf

- tapered f/, 1/
- kerning revelation

Argand Normal 23 v.53 http://popspring.com/mldrop/argnor23.rbf

- complete revision
- new stroke contrast
- new kerning
Title: Re: Proportional fonts
Post by: stevefal on September 24, 2013, 03:38:51 AM
New font for menu title:

Argand Normal 36 v.50 http://popspring.com/mldrop/argnor36.rbf

Note that all four fonts have been updated relative to the current build.
Title: Re: Proportional fonts
Post by: Marsu42 on September 24, 2013, 10:30:41 AM
Quote from: stevefal on September 24, 2013, 03:38:51 AM
New font for menu title

... I just have to mention it again: Great work, stevefal, as far as I remember something about typography creating these is a really difficult job and they look excellent :-) !
Title: Re: Proportional fonts
Post by: stevefal on September 24, 2013, 05:40:56 PM
Glad you're liking them  :)
Title: Re: Proportional fonts
Post by: RenatoPhoto on September 25, 2013, 01:27:54 AM
Quote from: stevefal on September 24, 2013, 05:40:56 PM
Glad you're liking them  :)
Me too!  Thanks a bunch! ;)
Title: Re: Proportional fonts
Post by: dmilligan on September 27, 2013, 04:22:32 AM
The small font (help text) is very difficult to read on the 1100D:
(https://bitbucket.org/dmilligan/magic-lantern/downloads/1100D_screenshot.jpg)
(I had to photograph the screen b/c screenshot was crashing the camera)
Title: Re: Proportional fonts
Post by: stevefal on September 27, 2013, 07:32:21 AM
Bummer. Looks like nearest-neighbor reductions and single-pixel strokes getting lost. The new stroke contrast is what makes the font nice at 720x480. Not sure which solution is best:

- Tweak the font so all horizontal strokes are only on every other line. Yuck.

- Have no stroke contrast - 2 pixels horizontal and vertical. Yuck again. That's why it looked clunky before.

- Have an alternate 2x2 font for low-res cameras

- I assume that rendering the font using interpolation is out of the question because it would require an alpha channel to render correctly against dynamic backgrounds.

- Vertical bolding might work - render once and again with a 1-pixel vertical offset. This will ensure that every horizontal stroke is seen, but with some artifacts. In all cases though, text rendering should be on either all even or all odd lines, since each produces a different decimated result. For example, look at "e" in menuitems 1 versus 2, and in help1 vs help2.
Title: Re: Proportional fonts
Post by: a1ex on September 27, 2013, 09:47:13 AM
For 1100D, you can design the font at half resolution (in both directions) and then double all the pixels. This is the cleanest solution IMO.
Title: Re: Proportional fonts
Post by: stevefal on September 27, 2013, 10:08:09 AM
Going along with that, isn't the cleanest to create an 11 pixel font and render it 1:1 on 1100D?
Title: Re: Proportional fonts
Post by: KurtAugust on September 27, 2013, 10:49:58 AM
The proportional fonts make the menus so much quicker to read. Really nice when you're under pressure and shooting in changing circumstances. It's more than just eye-candy.

(Canon 5d3)
Title: Re: Proportional fonts
Post by: a1ex on September 27, 2013, 11:24:29 AM
Quote from: stevefal on September 27, 2013, 10:08:09 AM
Going along with that, isn't the cleanest to create an 11 pixel font and render it 1:1 on 1100D?

Yes, this will use less RAM too. Caveat: if we do that, *all* fonts should be re-designed for half res (not only the small ones), because I'd like to keep only one font drawing routine (either normal or with pixel doubling).
Title: Re: Proportional fonts
Post by: stevefal on September 27, 2013, 03:33:43 PM
I'm not exactly clear what you mean. Are you saying design a set of 4 new fonts for only 1100D, and only it has special font rendering code?
Title: Re: Proportional fonts
Post by: a1ex on September 27, 2013, 03:41:03 PM
Yes, design them at half resolution (half size), and ML code will draw them by doubling the pixels.

Or, design them with doubled pixels from the beginning, and this will work with existing code.

Your choice.
Title: Re: Proportional fonts
Post by: stevefal on September 27, 2013, 09:16:58 PM
This will render at half-size without missing strokes. It is not a doubled font, but any rendered string will be self-consistent and readable regardless of original position at 480p. This is meant only for 1100D or other 240p displays.

Argand Half 22 v.50 http://popspring.com/mldrop/arghlf22.rbf

(http://i.imgur.com/Ol5PxA5.gif)
Title: Re: Proportional fonts
Post by: a1ex on September 27, 2013, 09:32:09 PM
Cool idea, like the animation.

A doubled font should look exactly the same regardless of the exact offset IMO, but this trick works well too.
Title: Re: Proportional fonts
Post by: dmilligan on September 27, 2013, 10:02:40 PM
Looks great!
(https://bitbucket.org/dmilligan/magic-lantern/downloads/1100D_ss_2.jpg)
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 01:34:56 AM
QuoteA doubled font should look exactly the same regardless of the exact offset IMO...

That's right. I started one, but to draw it manually is very laborious because every single boundary needs to be a multiple of two - cells, strokes, gaps, kerning. The rbf editor doesn't have any tools to make that convenient, besides the grid.

But given that this is a replacement and uses standard rendering, the font can be revised with perfect doubling, and it will still work, only better.

@dmilligan, you can see that the two help lines start on different fields. That's why one looks tall and one short. If you move either line one pixel higher or lower, both lines will look the same.
Title: Re: Proportional fonts
Post by: a1ex on September 28, 2013, 08:38:19 AM
I imagine, especially it's very easy to have 5 pixels instead of 4 and not notice it.

Can you design the font at half size? I can try to double the pixels from code.
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 09:00:29 AM
Do you mean double it in ML, or in RBF editor? If you could halve a font in RBF-editor, we could halve the font I just made, I could go in and do fix-up, then we could double it again.

And that process could work for all the fonts. Fix-up is way, way, way easier than starting from scratch.
Title: Re: Proportional fonts
Post by: a1ex on September 28, 2013, 09:03:24 AM
Got it, going to try.
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 09:20:11 AM
If so, keep in mind that halving can have four outcomes, depending on whether the font starts offset 0, +1H, +1V or +1H+1V. Ideally I could pick any of the four to start with, because they look quite different. For example, I would cherry-pick from #1 and #2 below:

(http://i.imgur.com/hiZk2I6.png)
Title: Re: Proportional fonts
Post by: a1ex on September 28, 2013, 09:50:47 AM
OK, here are the 4 versions:
http://a1ex.magiclantern.fm/bleeding-edge/arg11.zip

and also 4 versions of Argand 16 downsampled from 32:
http://a1ex.magiclantern.fm/bleeding-edge/arg16.zip

and also 4 versions of Terminus 10 downsampled from 20 (e.g. for console and other things that are best monospaced):
http://a1ex.magiclantern.fm/bleeding-edge/ter10.zip
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 10:34:56 AM
Great, the fix-up was quick. Not many pixels to start with!

Argand Normal 11 v.50 - http://popspring.com/mldrop/argnor11.rbf

This 11 pixel font is of course usable as well :)

Now if you can double it, it will be the new Argand Half 22 v.51
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 10:40:11 AM
It's 1:30am here, so I'm going to stop for now and pick this up later. I can do all of them eventually.
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 10:43:14 AM
Update:

Argand Normal 11 v.51 - http://popspring.com/mldrop/argnor11.rbf

tweaked 'e'
Title: Re: Proportional fonts
Post by: Marsu42 on September 28, 2013, 10:43:30 AM
Quote from: stevefal on September 28, 2013, 10:40:11 AM
It's 1:30am here, so I'm going to stop for now and pick this up later.

Just 1:30? Where's you're dedication and loyalty, man :-p ... no, really, thanks again and great work, don't overdo it, this must have been a lot of work and the new fonts arriving a few days or weeks sooner or later aren't critical, though very nice :-)

One question: Do these fonts have hintings, i.e. should we write things like "The A has too much space next to the v"?
Title: Re: Proportional fonts
Post by: a1ex on September 28, 2013, 10:58:15 AM
Doubled:

http://a1ex.magiclantern.fm/bleeding-edge/arghlf22.rbf (Argand Half 22 v.51)

This font file format doesn't have kerning support (hinting is something else). A kerning table would take 128x128 = 16K of RAM for O(1) lookup; if you store an array of (char1,char2,kerning) it may take less space, but printing may slow down a bit. Worth the extra trouble?

Edit: you can already try the new font in the 1100D nightly build.
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 05:27:19 PM
A kerning table would enable improvements, but i don't personally think it's worth it. I've tuned each font's fixed kerning at least as much as character spacing  accounts for area to the right of each figure, within the cell. For example, a 'B' has more space to the right than 'W' or 'C'. Tuning discreet pairs or groups would be a lot of work.

QuoteDo these fonts have hintings, i.e. should we write things like "The A has too much space next to the v"?

That's an example of a case that requires for more advanced kerning. The v could have less space on both sides, but not always, or vv would look like w. There are lots of examples like this.
Title: Re: Proportional fonts
Post by: stevefal on September 28, 2013, 05:29:12 PM
QuoteOK, here are the 4 versions:

Can you make downsampled 28 and 36 too?
Title: Re: Proportional fonts
Post by: stevefal on September 29, 2013, 05:11:37 PM
New:

Argand Normal 16 v.50: http://popspring.com/mldrop/argnor16.rbf

This should be suitable for doubling for Argand Half 32 v.50 (agrhlf32.rbf).
Title: Re: Proportional fonts
Post by: stevefal on September 29, 2013, 05:59:22 PM
New:

Terminus Normal 10 v.50: http://popspring.com/mldrop/ternor10.rbf

This should be suitable for doubling for Terminus Half 20 v.50 (terhlf20.rbf).

It is not totally faithful to the Terminus style - not enough pixels. Also some characters are wider than others, but the cells are still monospaced. You'll have to see if it's ok.
Title: Re: Proportional fonts
Post by: g3gg0 on September 29, 2013, 11:33:50 PM
i am just changing top/bottom bars and miss the infinity symbol.
can you add the it too?

http://www.decodeunicode.org/de/u+221e

thanks
Title: Re: Proportional fonts
Post by: stevefal on September 30, 2013, 01:12:12 AM
Updates with infinity symbol:

Argand Normal 11 v.52: http://popspring.com/mldrop/argnor11.rbf
Argand Normal 16 v.51: http://popspring.com/mldrop/argnor16.rbf
Argand Normal 23 v.54: http://popspring.com/mldrop/argnor23.rbf
Argand Normal 28 v.55: http://popspring.com/mldrop/argnor28.rbf
Argand Normal 32 v.55: http://popspring.com/mldrop/argnor32.rbf
Argand Normal 36 v.51: http://popspring.com/mldrop/argnor36.rbf
Argand Half 22 v.52: http://popspring.com/mldrop/arghlf22.rbf
Title: Re: Proportional fonts
Post by: a1ex on October 01, 2013, 05:13:56 PM
Added ETTR and DR symbols:

Argand Normal 28 v.56 (https://bitbucket.org/hudson/magic-lantern/src/c308b64db725eff41f6ca14c094d9b69cb4c788b/data/fonts/argnor28.rbf?at=unified)
Title: Re: Proportional fonts
Post by: g3gg0 on October 01, 2013, 07:24:50 PM
Quote from: stevefal on September 30, 2013, 01:12:12 AM
Updates with infinity symbol:

thanks, looks fine :)
Title: Re: Proportional fonts
Post by: stevefal on October 01, 2013, 10:12:47 PM
@a1ex, can you please generate the downsampled 28 and 36 fonts, so I can complete all the work for low-res displays?

Also, could you allocate up to row a0 in all Argand font files so I have room to create more icons? I use empty cells for proposals and for iterating characters/icons in progress. We can trim things down as necessary when things wind down (hah, do things ever wind down?)