-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unicode UTF8 dont displayed correctly #2991
Comments
You need to provide a font containing the required glyphs and load them. Please, check the Please, also note that this is not a forum for questions, follow the required Issues template before publishing new issues or ask in raylib Discord, probably the community can hel with this kind of questions. |
Thank you. By the way, the example from "text_unicode.c" - doesn't work if I pass a string: PS: That is, in fact, we can say in raylib There is no support for Unicode and UTF8 encoding in particular. |
You cannot say that. It depends on the availability of the fonts. The UTF8 encodings should be fine. If you display those strings in hexadecimal, they should reveal that correct UTF8 is employed in both cases. raylib is not responsible for the support of CJK glyphs in a chosen font. Font providers handle that or not. I suspect the default font used in raylib DrawText() does not support any glyphs except those graphical ones in u0000 - u00ff, and that's what you have demonstrated. As Ramon suggests, ask for font solutions on Discord, although I would expect that your computer has one, because you can enter and see them. |
I can, I already said.
The fonts that are in the examples work. The fonts that are in the examples work. Therefore, we can say that raylib does not, in fact, support the output of Unicode text, or it does, but with very complex manipulations. That is, you cannot receive, for example, an array of bytes encoded for example UTF8 from the server and display it in the window. And this is a fact. |
I'm sorry it didn't work for you. Please note raylib is a free and open source project, you can contribute with features, improvements or clearer examples. Contributions are welcome. |
I can see the calligraphy in u8"东东东" because I do have a font to do it (or GitHub is creating tiny images, which I do not believe is the case). That does not mean that everyone on GitHub can see it. In email, the situation is worse. There are many characters I cannot use because different readers (or the list servers that forward to them) do not have the fonts or do not recognize/preserve messages in UTF-8. That I have the fonts on my machine already is happenstance, although perhaps likely these days. There are other situations such as running a console application, where it is more difficult to get Unicode rendering even though I know the application is using UTF8. raylib default fonts in examples is another such case. What raylib does not do is selective font fall-back and substitution when a Unicode code point is not satisfied in the current font and there are other (known) fonts that have glyphs for that code point. That is much to expect from raylib. Also from the underlying graphical libraries that are used for text display. So would you prefer that it be declared raylib does not handle UTF8 at all? Then we'd have to select code pages and double-byte encoding schemes. Is that an improvement? With UTF8 recognized and handled, at least there is a direction for expanding the support of Unicode code points in text graphics at some point. Are you prepared to dig into word-processing software, see how this is managed there, and find a comparable solution for raylib? PS: I did paste u8"东东东" successfully into Microsoft Word, LibreOffice Writer, and Apache OpenOffice Writer documents. The last two are open source and all three use an open format (OOXML and ODF) that can be inspected to see how that is accomplished in document parameters. PPS: You can compile UTF-8 into a program. How well are you able to output it in a shell/terminal application? |
I understand it. |
@JaydenSu "So, apparently, I'm too used to simply passing text in UTF16 encoding to WinApi functions, in particular GDI + functions, and they themselves figured out what and how to draw 'under the hood'." Yes, GDI is very high level in that respect, and there is an entire operating system behind it. Raylib is not at that level; it is much simpler in terms of what it makes easy to accomplish. That's very different. I decided to look at something like DirectX to see what it affords. This article is pretty scary compared to what raylib provides: https://learn.microsoft.com/en-us/archive/msdn-magazine/2013/october/directx-factor-text-formatting-and-scrolling-with-directwrite The interesting thing is at the beginninng. A font was named as part of setting up text. From the examples, it appears that font metrics are handled and so are a number of other features around types of fonts. This all works by using platform-specific facilities. I am reminded that raylib's inspiration is work by Borland in the 1980s. None of these complexities and capabilities were prevalent in those times. I am disappointed that your expectations are not satisfied. It would be useful to explain and demonstrate the successful use of Unicode across a variety of languages and glyph forms. That has not been done here. It is probably best not to suggest much about the abiliity to pass UTF-8 (or Wide character UTF-16) around. |
I am still curious about this and I found out some things about attempting to present text with OpenGL. I found this report. It provides much useful information. https://learnopengl.com/In-Practice/Text-Rendering It doesn't get anywhere close to dealing with UTF-8 and UTF-16 but it reveals the rather limited handling. There is emphasis on the creation of bitmaps for glyphs and also use of TrueType for scaling glyphs without the awful pixelation that happens when a bitmap is enlarged. FreeType is suggested as a library of choice. I am not certain why the availability to use that on native windows seems to be suppressed, possibly for ideological reasons. There is a tolerable (BSD-like) license choice. I have not examined raylib's rtext.c file very closely. The use of TrueType (TTF) is a compilation option. Also, the built-in default font is strictly raster (as one can tell by struggling with different sizes) and only supports the UTF-8 code points for graphic glyphs in the interval U+0000 to U+00FF. That accounts for the lack of support for additional code points by default, especially the CJK families, etc. For handling TrueType, None of this is very enccouraging. |
https://en.wikipedia.org/wiki/2,147,483,647 |
@chriscamacho If those libraries were explicit about That's an incidental concern. If modification of It appears that the API has all the interfaces needed although I have some concern for what it would take to work with something like CJK with a ton of code points. A code-point vector would be quite lengthy and then there is the generation of different font sizes for rasterizing. (There's a related consideration with regard to IME and input of codes for such characters.) I think these concerns apply for other non-alphabetic languages. Is there advice about all this somewhere? I am unfamiliar with the wiki. My neglect. Sorry. Finally, I agree about the level at which raylib sits in terms of graphics, GUIs, and game-engine support. I admire the inspiration from BGI. |
@JaydenSu There are examples of non-trivial Unicode usage in the raylib/examples/text/ folder. The *.png files there are informative. The only use of CJK glyphs seems to be from a raster font, unfortunately (or the TTF-generated rasters are up-scaled). See the text/resources/noto_cjk.png. |
i can confirm it does not work.
utf8Size makes not even sense cause the standard is either
will crash.
works just fine, despite a lot memory eaten. |
Please notice that In your example, In the PS: I don't see anything in ā or in the capital Greek Letter Α that would make any difficulties with respect to rasterization of the font. |
@designerfuzzi Wow! This is very interesting, I assumed the glyphs image height could not be bigger than requested font size... I'm opening a separate issue to review this: #3858 |
In continuation of the issue: #2022
If I understood correctly from this "issue", then the code:
Should be displayed on the raylib window without any problems - and it is, everything is displayed perfectly.
BUT, this code does not want to be displayed correctly:
Please tell me - why?
The text was updated successfully, but these errors were encountered: