Git Product home page Git Product logo

libdrawtext's Introduction

libdrawtext

GNU/Linux build status Windows build status MacOS X build status

About

Libdrawtext is a simple library for fast anti-aliased text rendering in OpenGL.

Since version 0.3 libdrawtext can also render text on plain RGBA pixel buffers.

Libdrawtext uses freetype2 for glyph rasterization. If you would rather avoid having freetype2 as a dependency, you can optionally compile libdrawtext without it, and use pre-rendered glyphmaps. Glyphmaps can be generated by the included font2glyphmap tool, or by calling dtx_save_glyphmap.

See examples subdir for simple programs demonstrating libdrawtext usage, and refer to the heavily commented drawtext.h header file.

Dependencies

License

Copyright (C) 2011-2023 John Tsiombikas [email protected]
You may freely use, modify and/or redistribute libdrawtext, under the terms of the GNU Lesser General Public License (LGPL) version 3 (or at your option, any later version published by the Free Software Foundation). See COPYING, and COPYING.LESSER for details.

Build

To build and install libdrawtext on UNIX or on Windows with MinGW, run:

./configure
make
make install

See ./configure --help for build-time options.

To cross-compile for windows with mingw-w64, try the following incantation:

./configure --prefix=/usr/i686-w64-mingw32
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar sys=mingw
make install sys=mingw

Previous versions of this library included a visual studio project file. As I'm not able to maintain it, I decided to remove it completely from this release. The only way it can return in future releases, is if someone steps up to maintain it. Send me an e-mail if you're interested.

Contact

Feel free to send in bug reports, patches, and comments to: [email protected]

Only plain text email messages, hard-wrapped at 72 columns will be accepted.

libdrawtext's People

Contributors

jtsiomb avatar fetterless avatar ilovezfs avatar

Stargazers

 avatar Ed_ avatar Koji D avatar ollydbg avatar  avatar Stephen Wall avatar Brandon avatar  avatar  avatar  avatar Leonardo Fadul avatar Victor Suarez Rovere avatar Matevz Mihalic avatar Gerry avatar  avatar  avatar Tomás Pollak avatar Samuel Gomes avatar Billy Wayne avatar Johan Lind avatar Andy Kipp avatar Semih Artan avatar  avatar Piotr Plombon avatar Anon Ymous avatar Daniel Vincent Horgan avatar  avatar toge avatar skeet avatar  avatar Cas Argilla avatar Michael (misc147) avatar Vic P. avatar Cleroth avatar lanbudao avatar  avatar  avatar w1n5t0n avatar Liam M. avatar Luobin Wang avatar Andrei-Sergiu Pițiș avatar mid avatar David Landa avatar  avatar Dan Tocchini IV avatar Ryan Stillings avatar Ivailo Monev avatar Liang Yunfeng avatar Maks avatar Cogmeta avatar  avatar Nathan avatar Andrew Woo avatar  avatar d3vviL avatar  avatar Tibor Szász avatar lysgwl avatar genBTC avatar Anton Shramko avatar  avatar Garett Bass avatar Yash avatar Albert Tavares de Almeida avatar Richard Selneck avatar  avatar Daniel Grimshaw avatar sm50 avatar Alex May avatar Artur Bikmullin avatar yuning avatar  avatar Michael Auerswald avatar Hunter Elbourn avatar Alex Barker avatar  avatar Emmanuel Oga avatar Angelos Gkountis avatar GK avatar Alexander Popov avatar  avatar Diego Lopes avatar david guimard avatar Jim Susinno avatar

Watchers

Tom Lee(Kanghee Lee) avatar  avatar James Cloos avatar Eleni Maria Stea avatar  avatar Nathan avatar  avatar Diego Lopes avatar  avatar  avatar Angelos Gkountis avatar  avatar

libdrawtext's Issues

Build fails on macOS with Xcode 15

Build fails on recent macOS (with Xcode 15):

  src/drawgl.c:215:3: error: call to undeclared function 'gluBuild2DMipmaps'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                  gluBuild2DMipmaps(GL_TEXTURE_2D, GL_ALPHA, gmap->xsz, gmap->ysz, GL_ALPHA, GL_UNSIGNED_BYTE, gmap->pixels);
                  ^
  1 error generated.
  make: *** [src/drawgl.o] Error 1

I think it is missing the right header?

How to install Freetype to compile

Hello!

I'm having problems with the compilation process. How should I install freetype so that it is possible to compile libdrawtext? I am using visual studio 2017.

Kind regards

OpenGL ES support

does this library support OpenGL ES?

specifically Android GLESv3 (OpenGL ES 3.2 with EGL 1.4)

Ubuntu cannot find libdrawtext.so.0

Even after make install, ubuntu can not find the libdrawtext.so.0 file. I was able to fix this with the command: sudo cp libdrawtext/ libdrawtext.so.0 /usr/lib

glBlendFunc override

I suggest that glBlendFunc be removed from the GL backend, I came across a case where I had to use my own blending function, I found this to be a bit limiting.

(Yes, I can edit the source, and that's what I did, but it's still worthy to discuss).

Selectively skipping glyphs

It seems like if I hand-edited the comment header of the .glyphmap file I could selectively delete specific glyphs from the range, such as those not available in that particular font. But I'd also need to go delete the pixels or I'd reduce the utilisation of the texture memory.

Say in this case I just wanted the arrows. I could exact each pair as a range, and then write a script to combine them back into a new .glyphmap file?

Do you feel like this is a job for libdrawtext or something wrapped on top of it?

linux-biolinum_s96_r25a0-25cf

Does greyscale make sense for dtx_save_glyphmap_stream?

I'm interested in using libdrawtext with pre-cooked glyphmap files, perhaps gzipped.

I noticed in the implementation that P6 PPM RGB mode is being used, but that P5 PGM greyscale could be used to reduce the file size. Seems like dtx_load_glyphmap_stream could be extended to support P5 for input.

-rw-r--r--   1 nigels  staff   1.0M 25 Jun 20:15 linux-biolinum_s96_r0020-007f.glyphmap
-rw-r--r--   1 nigels  staff    48K 25 Jun 20:15 linux-biolinum_s96_r0020-007f.pgm.gz
-rw-r--r--   1 nigels  staff    82K 25 Jun 19:58 linux-biolinum_s96_r0020-007f.ppm.gz

Rotating the text?

Okay so, in my project I changed the glOrtho like so (it's a must):

   glOrtho(-x/2, x/2, -y/2, y/2, -1, 1); // from
   glOrtho(0, x, y, 0, 0, 1); // to

And as expected, the text is now flipped and upside down. No matter what I do; I can't seem to get the text to flip/rotate. I have rotated textures in the past with OpenGL, but for some reason my methods will not work with dtx_string.

  • Thanks, I am only classifying this as an issue because I am capable of rotating everything else properly, but not the text.

Chinese is not supported

Hello, I learned from the source code that there are 0-255 character sets, and there is no way to support Chinese.

Using Shaders

I can't figure out how to use shaders with this library. I would like to have an example...

Display Fonts

The Intel integrated graphics card cannot display fonts

Fails to compiler with clang

make -C tools/font2glyphmap fails with clang compiler (on macOS) because:

clang -pedantic -Wall -g -I../../src   -c -o src/font2glyphmap.o src/font2glyphmap.c
clang -o font2glyphmap src/font2glyphmap.o -L../.. -Wl,-rpath=../.. -ldrawtext
ld: unknown option: -rpath=../..

-Wl,-rpath=../.. is not a valid option, it should be -Wl,-rpath,../..

multiple dtx_prepare_range calls is failing for me.

Hello. When I compile unicode example (commented out cjk stuff) I get the following result:
1
Russian characters are drawing corrupted except for the last word.

But when make only one call to dtx_prepare_range like so:
dtx_prepare_range(fntmain, FONT_SZ, 0, 0x500); /* cyrilic */
(from zero to 0x500)
then russian characters are drawing as expected:
2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.