6

Using the Raspberry Pi 2 with the official 7" touchscreen, I want to display some high quality text without using an Xorg server. I'm looking for APIs that provide simple functions such as:

Render_text ("hello", x,y, blue, size, "nicefontX");

Such a library could be build on top of the linux kernel framebuffer or openGLES/VG. I have found at least one such thing that appears to be pi specific.

Again, I am interested in C -- I have already found many things involving python.

goldilocks
60.4k17 gold badges117 silver badges236 bronze badges
asked Nov 22, 2015 at 17:30
2
  • Zogger -> I think I may have been wrong about not referring to this as the framebuffer, since everything that does this seems to require it be built into the kernel -- all apologies. But I'm still sure I'm right about the fact that you will find much more material here if you search beyond "raspberry pi". Anyway, good luck. Commented Nov 26, 2015 at 21:06
  • BTW, I can't provide a complete answer, but it looks to me like SDL runs on the Pi using the framebuffer -- although again examples of its use won't be pi specific (if you keep waiting for that, you are going to be waiting a long time, honestly). Anyway, I am pretty sure it does have text features, although it has been 6-7 years since I used it. Commented Nov 26, 2015 at 21:19

2 Answers 2

4

Did you consider 2D Game engines/libraries ? Because OpenGL/OpenVG are very low-level and don't do font handling , the added "belt and suspenders" of those libs will make your life much easier :

http://www.raylib.com/

https://github.com/raysan5/raylib

answered Feb 5, 2016 at 10:21
1

I got 2D vector graphics library working, using it from C Language, currently with a 128x128 OLED display on a headless Raspberry Pi 3B, using the following recipe. Note: X-Windows (X11) is not installed (e.g. Raspian lite edition). As for performance considerations, OpenVG's claim to fame is that it utilizes available HW acceleration layer(s) rather than just load the CPU.

  1. Install: Raspian lite edition

  2. Install: fbcp-ili9341: "Blazingly fast display driver for SPI-based LCD displays for Raspberry Pi A,B,2,3, and Zero"

    I built that from source, and configured the the GPIO pins SPI pins via the (documented) -D commands on the compiler line. For example:

    # cmake -DSSD1351=ON -DGPIO_TFT_DATA_CONTROL=25 -DGPIO_TFT_RESET_PIN=24 -DSPI_BUS_CLOCK_DIVISOR=30 -DARMV8A=ON \ ..
    

    and then proved it work sanity tested it by writing stuff to /dev/fb0.

  3. Didn't need to install OpenGL libraries on my Raspian systems, because they seemed to be pre-installed at /opt/vc/lib, opt/vc/include.

    However, I created the following symlinks:

    # cd /opt/vc/lib
    # ln -s libbrcmGLESv2.so libGLESv2.so
    # ln -s libbrcmEGL.so libEGL.so
    
  4. OpenVG "The Standard for Vector Graphics Acceleration"

    https://github.com/ajstarks/openvg
    
  5. Compiled the following C program and ran it. Worked perfectly.

    $ cc -o demo demo.c -I/opt/vc/include -Lopt/vc/lib -lshapes
    #include <stdio.h>
    #include <stdlib.h>
    #include <stddef.h>
    #include <stdint.h>
    #include <unistd.h>
    #include "VG/openvg.h"
    #include "VG/vgu.h"
    #include "fontinfo.h"
    #include "shapes.h"
    int main() {
     int width, height;
     char s[3];
     init(&width, &height); // Graphics initialization
     Start(width, height); // Start the picture
     Background(0, 50, 0); // Black background
     Fill(44, 77, 232, 1); // Big blue marble
     Circle(width / 2, 0, width); // The "world"
     Fill(255, 255, 255, 1); // White text
     TextMid(width / 2, height / 2, 
     "hello, world", 
     SerifTypeface, width / 10); // Greetings 
     End(); // End the picture
     fgets(s, 2, stdin); // look at the pic, end with [RETURN]
     finish(); // Graphics cleanup
     exit(0);
    }
    

enter image description here

enter image description here

answered Dec 24, 2018 at 8:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.