Comments (17)
I checked out https://github.com/akrinke/Font-Stash/. It's pretty interesting, but it's renderer uses OpenGL Compat Profile, that's not usable with OpenGL Core Profile. So font rendering algorithm will be reimplemented for OpenGL Core Profile. Also there is an stb
as dependency, and GWork has it already.
ResourceLoader
may be used with sth_add_font_from_memory
.
from gwork.
May be because the STB pre-renderer characters don't include those outside ASCII range?
from gwork.
from gwork.
I think this is your problem because pre-rendered text
from gwork.
Yes, that may be true. But also
typedef
forUnicodeCharacter
defined as
1 bytechar
may be a part of a problem.
All the text is UTF-8, but yes, I haven't dealt with multi-byte character encodings on all platforms. I don't know how STB font render works with UTF-8 multi-byte codes.
from gwork.
from gwork.
I researched problem and found several places.
- In
PlatformType.h
typeUnicodeChar
ischar
so useful data will be cut out. - No conversion from UTF-8 to unicode values (in renderers). It can be fixed with
utfcpp
library. stb
library can bake Unicode characters, but it can accept only first character unicode index and number of character to render. It has no any interface to perform more flexible baking. It may be a problem if required to render only specific sets of glyphs. Maybe project requires another (or modified) system of font baking. (I guess, just copy and modifystb
sstbtt_BakeFontBitmap
function can be enough. Also, this function is rendering all unknown symbols multiple times, instead of just once. (see img))
from gwork.
In PlatformType.h type UnicodeChar is char so useful data will be cut out.
Ok, that can be made an int
.
No conversion from UTF-8 to unicode values (in renderers). It can be fixed with utfcpp library.
I don't really want to have dependencies on many external libraries. Is there specific functionality that is required? I think UTF-8 to int may be all that is necessary and that is a one function that could go in Utility.
stb library can bake Unicode characters, ...
Yep. I think Allegro just bakes characters on the fly, whatever they are. I just added this range to get this to work. I mainly use Allegro so that is probably the most complete solution here.
Does STB remember the baked information? I.e. can you later bake more characters into the same texture? In which case you could just cache them like Allegro. And render from the cache.
from gwork.
Ok, that can be made an int.
I guess uint32_t
would be better. But yes, 32 bit variable will be enough.
I don't really want to have dependencies on many external libraries.
It's pretty small, and contains of only several headers. But I'm agree, that dependencies are bad.
Is there specific functionality that is required?
I guess yes, because utf-8 is a specification, where one symbol can be described in range of 1 to 6 bytes, but after decoding it will describe maximum 4 byte variable. But I think I can implement it myself without any particular problems.
Does STB remember the baked information?
Nope, It's just saving 1 byte per pixel image to buffer. It's not caching glyphs. I guess I can cache buffer for font and if required - add symbols to it, then update texture in GPU and continue rendering. This implementation also requires custom baking function.
from gwork.
I guess uint32_t would be better.
Agreed.
But I think I can implement it myself without any particular problems.
If the cpplib license is liberal you could copy the function and attribute it? I think a lot of the other functionality should be handled by C++1x.
I guess I can cache buffer for font and if required...
TBH I don't know what is required here. Maybe have a look at the Allegro strategy. I think they have multiple texture glyph atlases. New one added when it fills up. Each new font/glyph/size is cached when it is used. Not sure how easy this would be in STB. Perhaps need a rect packer (which I think STB has).
from gwork.
Perhaps this is what is needed: https://github.com/memononen/fontstash
Font stash is light-weight online font texture atlas builder written in C. It uses stb_truetype to render fonts on demand to a texture atlas.
The code is split in two parts, the font atlas and glyph quad generator fontstash.h, and an example OpenGL backend (glstash.h).
- 1 file dependency for fontstash and one per backend.
👍
This modification sounds interesting: https://github.com/akrinke/Font-Stash/ from memononen/fontstash#24.
The idea with the ResourceLoader is that there could be different flavours and users can choose an appropriate one. Likely, they would write their own because most games have their own resource management. Perhaps another one could be added that supports FontStash, and/or its variant (@akrinke).
from gwork.
I checked out https://github.com/akrinke/Font-Stash/. It's pretty interesting
I guess a concern is that it looks like a significant fork from fontstash, and that receives bug fixes and new features, so this fork would get less/no support. But I guess if it's all functional and looks reasonable to maintain then it will effectively just become part of GWork.
from gwork.
Might be useful https://github.com/DuffsDevice/tinyutf8
from gwork.
Hmm. This is extremely interesting library. First of all it has to be tested a little bit and if everything will be fine, it can replace standard string without any problems, I guess.
The only question to that library: why is this library using any .cpp
files, if it would be better to implement it like "single header" library.
from gwork.
if it would be better to implement it like "single header" library.
Ah. I thought is was single header as no source directory (cpp in "Lib"!).
License is liberal. If necessary you could take what you need and attribute?
from gwork.
I was playing with https://github.com/memononen/fontstash on the DirectX11 renderer. This method is a better solution than the hack of expanding the limited character range.
static const wchar_t BeginCharacter = L' '; // First Character of Wide Character Table
static const wchar_t LastCharacter = 0x2FFF; // Last Character of Wide Character Table
static const wchar_t NewLineCharacter = L'\n'; // New Line Character
topblast@e2b3e6e
I am planning to update the DirectX11 renderer to use a similar implementation that fits better into GWork; it should be portable into OpenGL* and possibly other renderers.
from gwork.
I'm gong to turn this into a bug and open a new issue for the "font module" #88 new feature.
from gwork.
Related Issues (20)
- Created a Discord server for anyone that wants to chat on GWorK
- Segfault when clicking on ImagePanel in GworkAllegro5Sample HOT 2
- CacheToTexture Never Updates Cached Textures? HOT 1
- Refactor colour picker HOT 1
- Baking FreeType Into Gwork? HOT 12
- Reduce compiler coverage in tests
- "LARGE_INTEGER" and "QueryPerformanceCounter" problem HOT 2
- Can't build OpenGL sample with MinGW HOT 1
- Can't use GWork as cmake `subdirectory`. HOT 1
- Fix OpenGL Core for OSX HOT 2
- GLFW input handler is now working with GLFW3 HOT 1
- Resource management refactoring HOT 12
- Add WYSIWYG editor
- Support multiple renderers
- Add Font Module
- Investigate Gwk::Utility::Widen too slow HOT 1
- SFML2 Compile fails - Linux Mint 18.3 HOT 2
- Error: expression in new-declarator must have integral or enumeration type HOT 1
- OpenGL renderer broken HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwork.