[ANN] First ocb (OCaml Badgen) release


A few days ago, I released ocb. It’s a library and a command-line tool to generate SVG badges.

To get started quickly:

ocb --label Hello --color green --style flat --labelcolor white --status Goodbye

Will gives this result: SVG example.

My first use case was To.ml where I’m using bisect_ppx to generate and deploy a coverage report. I wanted to display the coverage percentage in the README and tried existing tools but wasn’t fully satisfied as they didn’t work or were failing randomly. Now, I’m generating the badge directly in a GitHub action.

The project was inspired by badgen. I still have to add support for icons and to improve the documentation but it’s usable.

Enjoy ! :slight_smile:


Hey, late to the announcement.

Really cool library!

I’m playing around rendering SVG as well but I don’t seem to understand how you load the Verdana font, I understand that it relies on the browser rendering engine, even when it’s an svg file. Looking at it you got the verdana.ml as a character map, but I don’t get how this thing works.

Do you mind sharing what I’m missing?


I saw the verdana.ml which contains the character map (I guess), but I can’t see how this make

Briefly looking at the source, Verdana stores the character width (in pixel) of each character with the index being the font’s codepoint.
Rendering is still done by browser of course

1 Like

Hi ! First, as it’s stated in the README and in the first post, the library is inspired by badgen and I wrote it in the same way. The fact is that I know near to nothing about SVG.

Anyway, as far as I know, the answer given by @thangngoc89 is correct. The rendering is made by the browser, but we need to know the width of each character before rendering to compute various other things.

With Verdana, for a given codepoint, the width is known before rendering - I believe that’s not the case for all fonts, but I may be wrong. Thus we can just store all these widths in a file, verdana.ml and get the value we need easily.

1 Like

Totally thanks, didn’t look deeply enough!