Creating Text with different fonts using opengles 2 - opengl-es

My project should display graphic overlay on the monitor using opengles2 in linux environment.
Need to display a text in different fonts on the monitor using opengles2. Freetype library can be used for rendering text in different fonts,
But I am not able to find an example program that would use freetype library in opengles2 Linux to render a text in different fonts.

I wouldn't use plain freetype on anything nowadays. It is missing so many opentype/unicode smarts which have been moved to other libraries a long time ago. So it will work on simple latin text, and hit problems on pretty much anything else (including not simple latin text).
You'd properly be better of long term taking a higher-level lib that abstracts all the text bits (freetype, fontconfig, harfbuzz, freebid, etc), such as pango cairo, and plug it on opengl es.
Some links:
https://dthompson.us/font-rendering-in-opengl-with-pango-and-cairo.html
http://emblemparade.net/blog/using-cairo-with-opengl-es/
http://cairographics.org/OpenGL/

Related

Programming language selection for showing image with other images on

I want to make a program that displays an image with other images on it (a map with various icons on it). What language (and library!) would you recommend, based on these facts:
-I have some basic oop knowledge
-I'll need a free and windows OS IDE for that
I would guess java? But it is not easy to compress my question to a good quality google search string....
displays an image with other images on it
Almost every language can achieve this. Such as Python with Pillow C++ with opencv and many other options. (I believe most of mainstream languages will have their own image library)
The problem is, what you want to implement specifically?
if you just want to put some images on to another image, and you do not need extra interactive function. Go with Python and Pillow, it is easy to learn and can perfectly solve your problems.

Default font sizes with wxWidgets on OSX

I've noticed that my wxWidgets application does not follow the native font sizes on OSX. They are typically too big and also the same font size is used for all widgets, which does not seem to be the case by native default.
I've tried to handle this myself by applying fonts to the top level windows. I've used TinkerTool to read the defaults (should be done automatically of course) and create corresponding fonts, for example using wxFont(wxFontInfo(12).FontName("Helvetica") but it does not render the same as other, native applications.
Does anyone know of a good method to handle this?
I don't know of any examples when wxWidgets controls don't use the same fonts as the native controls, please report any occurrences of this as bugs in the wxWidgets Trac, especially if this is using 2.9.4 (old 2.8 versions use Carbon and are hopeless on modern OS X anyhow). But without any concrete examples I can't really help with this.
As for the font sizes, I think you might be looking for wxWindow::SetWindowVariant() which allows to use smaller versions of the controls which is rather common in OS X UI.

Convert CFF fonts into OpenType fonts programmatically

Does anyone have any pointers where I can find extra information on how to create an opentype wrapper around a CFF font?
Currently I have a parser for CFF files so I can get all sorts of information out of it (cmap, glyph names, widths, names etc etc). Given this information I am unable to create an Opentype (truetype format like) wrapper so I can use the font on Windows using GDI; GDI will not load the Opentype font and the only thing I know is that it fails to load the font.
Does anyone know any additional information, validation applications, example code, get additional information why the font does not load from Windows etc etc?
Note: I am looking for information how to do it, not utilities and/or conversion tools.
Until now, I found three libraries you could reference:
FreeType: mainly in the cff package. Its main entry is cff\cffload.c. The library is now on GitHub.
FontForge: fontforge\parsettf.c, still on sf.net.
fonttools: fonttools\cffLib.py, on GitHub.
ots tools: cff.cc on Google Code
In parsettf.c, George Williams wrote that
"TrueType is a really icky format." ...Now that I understand it better it seems better designed, but the docs remain inconsistent. Sometimes badly so.
IMO, the cff spec is just as bad.
Maybe it is better designed. I might eventually look into it to confirm, but it might just be too old to be good.
What old things are good? Parents, math and philosophy :)
Anything else must be up-to-date!
CFF(Compact Font Format) is mainly used for embedded PostScript font in PDF files. And you can also find CFF in OpenType font files which is based on PostScript outlines.
If you got CFF from the embedded font file of a PDF, you can get a PostScript name from the NameIndex of the CFF. You should find the corresponding OpenType File by the PostScript Name.
If you got CFF from a OpenType file, why did you ask this question? :-D
I quote this link: Raster, Vector, TrueType, and OpenType Fonts
... the glyphs for a font are stored in a font-resource file. ...
So, Windows loads glyphs from a file with a format that it understands, not a CFF file, and not a structure from memory. If you want to draw CFF files without using a file conversion tool, I think you will need to load the CFF and draw the glyphs by yourself.
To load the CFF and determine the glyph, you can use the FreeType Project. Here is a link here on SO that explain how to build a Win32 DLL from FreeType source: Compiling FreeType to DLL (as opposed to static library)
To draw the glyphs, you can get some inspiration from the gdipp project, which is a replacement of the Windows text renderer, and contains Win32 C/C++ sample code that display glyphs loaded from FreeType.
It appears that the CFF format was made to be embedded directly into an OpenType file. Microsoft has a good overview of OpenType files: http://www.microsoft.com/typography/otspec/otff.htm

Postscript Type 1 fonts handling/rendering using Freetype2/Qt4 on Mac OS X

I'm working on an Font Identification tool which runs natively on both Windows XP/7/Vista and Mac OS X and needs to perform high-speed quality rendering of Outline fonts.
As we needed high performance & multi-platform developing environment, we choose a Qt4 / C++ combination and we use freetype2 for font rendering.
By the way, I'm really impressed from the stability, performance & code quality of the freetype2 library and I highly recommend it!
When we switched from Qt4 internal font rendering to freetype2, the product performance increased by about 300% while the probability of an app-crash due to a bad font is lowered from 1:10.000 to 1:200.000.
Our product currently supports OpenType (OTF) and TrueType (TTF) fonts and we are about to add support for Postscript Type 1 (PS1) fonts.
In fact we have already added support for Windows Type-1 fonts but I have a real trouble to find the required information to handle Mac OS Type-1 fonts.
You can see some platform-depended differences of Type-1 fonts here:
http://www.asy.com/fonts.htm
On Windows, each Type-1 font is contained in 2 files: font-name.pfb (the font outlines) and font-name.pfm (the font metrics, kerning, etc)
To open a Type-1 font + metrics with freetype2 you can just do the following:
ftError = FT_New_Face(&ftLibrary, "font-name.pfb", ftFaceIndex, &ftFace);
if (ftError)
(...)
ftError = FT_Attach_File(ftFace, "font-name.pfm");
if (ftError)
(...)
I have the following issues/questions regarding Mac OS X:
1) Is there a corresponding *.pfm (metrics) file? and if the answer is yes, does it always exist on any given Mac-Type-1 font?
EDIT/Answer: There is no *.pfm file in Mac Type-1 fonts. The font-metrics are stored inside a bitmap font stored in the same Font-Suitcase. See the following link about transferring fonts between Windows & Mac, explaining many of the differences between Win-Type-1 and Mac-Type-1 fonts: http://www.macdisk.com/fontsen.php3
2) Is there a corresponding *.pfb (outlines) file?
My info so far is that an outlines file exists and it has no extension (pfb) but a "Mac type" of LWFN. How I can read the "LWFN" type associated with a file while scanning for all such Type-1 files on a given directory?
In general: How to handle Mac data/resource files and File-Types using Qt & C++ ?
3) Are those files (1),(2) exist always in the same directory?
EDIT/Answer: This question is no longer meaningful, after asnwer(1) [=there is no *.pfm file in Mac-Type-1 fonts].
4) If I know the filepaths of (1),(2) for a specific font, is it possible to install the font by just copying the files into User's font library folder (which is true for OTF/TTF fonts) or I have to use some other special installation method?
EDIT/Answer: The Mac-Type-1 fonts comes inside a Font-Suitcase. The correct installation method is to install the whole Suitcase to User's font library.
5) Is it possible to take a Windows-Type-1 font (pfb/pfm) and install/use it on a Mac OS X machine, without any conversion?
EDIT/Answer: The answer is NO. The pfb/pfm need conversion to be installed/used in Mac OS X but you can use them by Adobe applications like Photoshop/Indesign if you copy them to some special fonts folder of these Apps.
I will really appreciate any answers or links pointing to the right direction, because any search I have done so far, just points to another level of complexity without getting me any definite or useful answers.
Thanks
Fivos
PS: I tried to answer most of my questions, and I will also post a link to some pieces of code I have found.
I answered most of my questions by editing my original post. For future readers: I have found some piece of open-source C code which addresses the problem of handling Mac Font Suitcases and extracting OTF/TTF/Type-1 fonts from them.
It's a set of tools written by George Williams (see the description bellow).
The link to open-source project: http://fondu.sourceforge.net/#Fondu
Fondu -- A set of programs to interconvert between mac font formats and pfb, ttf, otf and bdf files on unix.
Dealing with mac fonts is hard on other operating systems because mac fonts are stored in the resource fork, and other operating systems do not support this concept. Fondu will extract the resource fork from either a macbinary file or a binhex file. Ufond will create a resource fork inside a macbinary file.

C++ Cross Platform Image Loader for OpenGL

I have tried everything from SDL to DevIL, and they have all failed for various reasons.
SDL segfaults for various reasons, and DevIL is having some weird problem where even after i include IL/ilut.h and linking everything, and including the other headers, it is not defining the functions i need to load images into opengl textures (something about USE_OPEN_GL not being defined). I am asking for any other lib out there for loading bitmaps or png's into a format i can easily convert to opengl, or a solution to the devil problem.
thanks
Both libpng and libjpeg can be rather daunting to build & use -- no wonder there are all sorts of wrapper libraries for both.
A very simple and minimal no-nonsense loader for jpg/png (and some other stuff aswell) without dependencies in a single C file is Sean Barrett's stb_image.c, if you just want to load some image files it adds absolutely minimal overhead to your program and is straightforward to use:
http://nothings.org/stb_image.c
As Adam suggests, I would also recommend to use libpng and libjpeg. You are not specifying if you write in C or C++, but if in C++, then I'd suggest to take a look at two handy thin wrappers on the both libraries: pngxx and jpegxx
LodePNG is a highly compact PNG Loader with no dependencies.
Comment on your experience with DevIL - it works flawlessly for me and many others. Why not try again to resolve your build problems? - shouldn't be too hard)
You can also try FreeImage library. It supports loading different image types and is functionally similar to DevIL, may work out of the box for you.
And about your problem with DevIL, you do not have to build ilu or ilut libraries to make DevIL functional. I would recommend you manage the OpenGL texture objects yourself, including uploading image data to OpenGL side.
SOIL is a decent lightweight one I've used before. It's actually specialized for loading OpenGL textures too.
http://lonesock.net/soil.html
you dont need ILUT to do what you want. you can simply use ilGetData() and glTexImage2d()
Loading bitmaps (.bmp) and netpbm images (.pbm, pgm, .pnm) is fairly trivial, since they store images uncompressed. For loading PNGs, use libpng. For loading JPEGs, use libjpeg. For other image types, use an appropriate library. There's a good change that slapping on 'lib' to the beginning of the image name will give you such a library, e.g. libtiff, libtga, etc.
Once you've loaded and uncompressed the raw image data, loading it into an OpenGL texture is just a matter of calling glTexImage2D() with the right parameters, and a couple of other GL state changes (e.g. how to do mipmapping).
Image Magick with either the C or C++ bindings?
http://www.imagemagick.org/script/index.php
Young but yet great enough SFML could be the one you're searching for. I've used it for numerous projects and all of 'em worked well on all my platforms (Win7 and Ubuntu).

Resources