Skip to content
Simple OpenVG API wrapper for direct-to-screen 2D graphics from C and python
Branch: master
Clone or download
Pull request Compare This branch is 10 commits ahead, 1 commit behind mgthomas99:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

EasyVG [mk-fg fork]


EasyVG provides an abstraction layer on top of native OpenVG graphics API, for easy creation of OpenVG contexts and drawing shapes, images, and text, without requiring anything other than the most minimal system setup.

EasyVG follows standard C and EGL API naming conventions.

EasyVG is fully compatible with Raspberry Pi boards.

This mk-fg/easy-vg repository is a fork of (in a recent-first order):

Difference from upstream EasyVG (mgthomas99/easy-vg):

  • Has API frozen at a state of ~2018-08-01 master branch, with simple "draw things via single call" API, same as ajstarks/openvg has, before introducing paths (which are still in mgthomas99/easy-vg#develop branch at the time of writing).

  • Intended to be built and used as a shared library, including from python via ctypes wrapper.

  • Updated with fixes and minor additional API features where necessary, without changing its current methods and logic if possible.

Text & Fonts

EasyVG is capable of rendering text.

One default font (DejaVuSans.ttf) is converted and built-into via Makefile.

To use custom TrueType fonts, developers should convert the font into C code use the font2openvg binary (use make lib/font2openvg or just make to build it), and then include and init it using loadfont() in C API.

Loading custom fonts at runtime (incl. via python wrapper) is not supported.

Using font2openvg

The font2openvg repository contains more information on font2openvg tool included in this repo.

Once the lib/font2openvg is built, compile a TrueType font file.

For the below demonstrations, it will be assumed that you are using a source font file named DejaVuSans.ttf and a compiled output named

Once a font is compiled, it can be included in your code like this:

    #include ""
    Fontinfo DejaFont


    // Unload the font when done
    unloadfont(DejaFont.Glyphs, DejaFont.Count);

Build and Run Examples

Note that you will need at least 64 MB of GPU RAM (when using a single DispmanX layer, 128+ for more)

For building and/or including the code, requirements are:

  • DejaVu fonts, jpeg and freetype libraries with headers.
  • For building and easy packaging on raspbian/debian: build-essentials checkinstall
# apt install libfreetype6-dev libjpeg8-dev ttf-dejavu-core
# apt install build-essentials checkinstall

Runtime requirements for and python wrapper:

  • libbrcmEGL / libbrcmGLESv2 - RPi's VC4 GL libs.
  • libjpeg - for createImageFromJpeg, can be omitted when including code from C.
  • python3 - when/if using python wrapper.
# apt install libjpeg8 python3

Basic build process:

% curl | tar -xz
% cd easy-vg-master
% make

Build and run C example(s):

% pushd example
% make hello
% ./hello
% popd

Package/install on raspbian/debian (including and python module):

% sudo checkinstall -Dy --pkgname=easy-vg --pkgversion=1 --backup=no -- make install-checkinstall
% dpkg -L easy-vg
% dpkg-deb -I easy-vg_1-1_armhf.deb

Install / uninstall to current rootfs (not recommended outside of packaging scripts and such):

% make install
% make install-python
% make uninstall

Run python example:

% python3 python/

Build self-contained C binary (e.g. example.c, see also example/hello.c) based on the library code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <jpeglib.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "./src/fontinfo.h"
#include "./src/libshapes.h"

// Load image from specified jpg file and display it stretched to full screen.

int main(int argc, char *argv[]) {
  int w, h;
  evgInit(&w, &h, -1);
  evgImage(0, 0, w, h, argv[1]);
  while (1) sleep(3600);
  return 0;
% gcc -Wall \
  -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads \
  -I. ./example.c -o ./example \
  ./build/libshapes.o ./build/oglinit.o -L/opt/vc/lib -lbrcmEGL -lbrcmGLESv2 -lbcm_host -lpthread -ljpeg
% curl -OL
% ./example Example.jpg

Build C binary linked against installed

#include <shapes.h>
#include <fontinfo.h>

// ... code using
% gcc -Wall \
  -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads \
  example.c -o example -lshapes
% ./example

Have fun!


See the LICENSE file for license information.

You can’t perform that action at this time.