I want to show an unicode text in my sdl program , but it doesnt render on screen correctly.
It renders from end to begining and the characters render seperatly (They should connect to each other)
You can see a screen shot here http://up.vatandownload.com/images/ea8d1c2kxpk5ehbjv2.png
SDL does not implement full Unicode text layout. It works for many languages, but Arabic (which has incredibly complex layout and glyph-selection rules) is not one of them. You will need to use either Pango or ICU's layout class to do your text layout if you need Arabic support.
Related
Suppose I wanted to create a text editor from scratch.
I searched around and everyone suggested using OS-specific native 2D APIs (e.g. GDI+ in Windows or XLib in Linux), especially for font rendering.
My question is: why is it that openGL isn't suited for such a task? Why is it so hard to render antialiased text and controls as in a text editor with openGL and why should I prefer the non-portable way of native 2D OS APIs?
Part of the difficulty is that OpenGL doesn't provide a font engine or any capabilities specifically for rendering text. In other words, it's not a matter of OpenGL being poorly suited to the rendering part of the task, just that OpenGL is missing a lot of pieces necessary to the task.
To render text under OpenGL, you'd typically start with some font engine to take (for example) a TrueType or OpenType font, and render a glyph from its info (e.g., FreeType). Then you need a text display engine to figure out how to render characters to display your strings decently. In a simple case like English, it has to handle things like kerning and leading. In a complex case like some Arabic scripts, you basically need kind of a feedback loop between the text rendering and the font rendering, because a glyph can take a different form depending on its context in the string.
In short, writing a text editor that renders its text via OpenGL means re-building a lot of a text rendering stack from the ground up.
If you don't care a lot about rendering quality, you might be able to get by with just rendering a few fonts to bitmaps, and displaying your text using them. This can simplify the code quite a bit, but a simple implementation will mean producing output that looks something like an MS-DOS command line. Even matching the output quality of, say, Windows 3.0 will take a fair amount of work. That's not to say it can't be done--but it could dwarf the difficulty of writing the editing part of the text editor.
I want to add an Unicode Symbol as a list widget item in QT. (Particularly this item : http://www.fileformat.info/info/unicode/char/25B6/index.htm )
I'm using following method for this :
this->addItem( new QListWidgetItem( QString::fromUtf8("\u25B6")) ) ;
But when I open the widget I see only a blank rectangle in place of this unicode symbol. I even tried other unicode symbols too, but they too are showing only blank rectangle.
What's wrong in this method?
EDIT: After following the answer, I changed the font of QListWidgetItem to Serif and it worked.
There are several possibilities, but the most probable one is that the font you are using doesn't implement the glyph at all. Can you see the triangle in eg. an editor when using the same font as your Qt font?
Edit: The fonts (which are stored in the system's font files) are the commands to draw the images of each character on the screen). Many (if not all) fonts are incomplete, which means they are not able to represent all 2,000,000,000+ codes which are possible in the unicode (the numbers which represent the characters). The files would just be to large to be practical.
The triangles you want printed are fairly basic, and should be available in many font sets. Liberation Sans and Liberation Serif are two I just checked.
I suspect Qt uses the font set of the system, which can probably be changed in the System Settings somewhere. If you tell us which distribution you are using (i.e. Ubuntu, Debian, ...), maybe we can help.
I'm having trouble displaying Unicode font on opengl. I need to show like 20 lines of Unicode font text on my game and it has to be dynamically loaded(since the text is Japanese). The only unicode font library I could found was slick but rendering is so slow...
Is there any way to display many lines of unicode font text on the fly without sacrificing FPS? No JOGL, I'm using slick and LWJGL right now
Just for clarity, can you define "so slow" so we have an idea of what your rendering constraints are?
As a possible solution you could render the text to off screen textures with alpha, and then draw the textures on screen. If the text is going to be exactly the same every time you could also just use static images with the pre-rendered text (e.g. .PNG files).
I'm rendering some text using pangomm, but the font that I am using doesn't have glyphs for parts of the text (in this case, there is some Japanese mixed in with English). Pango seems to render the text correctly using a fallback font.
How can I determine which font is being used as the fallback?
Actually the font selection is based on the selected Pango font backend. Mostly used (I think) is Fontconfig.
You fonts are basically always chosen by looking at the fonts Unicode coverage, meaning that Fontconfig tries to choose the font that covers the letters in the text you want to render best.
Not knowing if your problem applies to Fontconfig, I won't go into to much detail. But if so, have a look at http://www.freedesktop.org/software/fontconfig/fontconfig-user.html, especially the section on 'font matching'.
Feel free to ask again.
I wonder if there is any possibility to render special characters (0-31 ASCII, for example) my own way in Qt/QPlainTextEdit? I want to render them as small rectangles as seen in this screenshot: ...or as Notepad++ is doing it. My goal is to be able see all characters. So if a character fails to render with current font (there is no such char for example), a small square should be rendered instead.
Qt does have ways to represent non-characters in QTextDocument which is used in QTextEdit and QPlainTextEditor. There's a sample on inserting an SVG object into a text edit:
http://doc.qt.io/archives/qt-4.7/richtext-textobject.html
Or you can use your own QAbstractTextDocumentLayout to handle the drawing of various text objects in the QTextDocument.