Comments (27)
I like just calling it vkvg_text_run_create_with_length
.
from vkvg.
2. I think the easy thing would be to just store a pointer to the raw font data instead of the path in `vkvg_font_identity_t`, and then just skip the `fopen` (stbtt) or use `FT_New_Memory_Face`.
This sounded a so good and straightforward idea that I've implemented it . #89
I've quickly test it, tell me if it fits your needs.
from vkvg.
3. I think this would just be a public API for `glyphs` in `vkvg_text_run_t`
I've implemented vkvg_text_run_get_glyph_positions in the same branch, the struc returned will be different with hb or not, but it's a compile time feature...
from vkvg.
Or maybe, to keep it simple, just a non-variadic function which always requires the length
parameter, in which case for 0-terminated strings a strlen(text)
would suffice?
Ping @jpbruyere.
from vkvg.
I've implemented vkvg_text_run_get_glyph_positions in the same branch, the struc returned will be different with hb or not, but it's a compile time feature...
Thanks. It's unfortunate that hb_glyph_position_t
is partially opaque with an undefined length.
One option is to define vkvg_glyph_info_t
in the public API and internally just copy the 5 fields you need from hb_glyph_position_t
over.
from vkvg.
So rasterized for smaller sizes? Yeah, that would probably be ideal.
from vkvg.
stb fonts are not working because of this line:
assert(stbtt_InitFont(&font->stbInfo, font->fontBuffer, 0) && "stbtt_initFont failed");
assert() gets compiled out in release code, the font never gets initialized, and it segfaults.
from vkvg.
In _font_cache_create_text_run
, strlen
still gets called on all strings.
from vkvg.
I was assuming that assert would not discard the expression in release mode, but it looks like it's also discarded with gcc. I've pushed the fix on master, thanks for the report.
from vkvg.
In
_font_cache_create_text_run
,strlen
still gets called on all strings.
I've pushed the removal on master (311d063).
from vkvg.
return array of glyph positions. useful for selecting text with a mouse.
I think that would be useful in pangovkvg, too.
from vkvg.
I've implemented your first point by adding vkvg_text_run_create2 with a length parameter (glyph count). ( #88 )
We should find a better name for the method, and also perform tests. This point was quiet straightforward to implement...
from vkvg.
What about making vkvg_text_run_create
a variadic function, with an optional length
parameter, like the open
system call? So you don't have to maintain two functions.
from vkvg.
What about making
vkvg_text_run_create
a variadic function, with an optionallength
parameter, like theopen
system call? So you don't have to maintain two functions.
Bof, higher level wrappers may have problems to handle variadic func, and it add complexity to the code for a low gain. (in that case)
from vkvg.
Or maybe, to keep it simple, just a non-variadic function which always requires the
length
parameter, in which case for 0-terminated strings astrlen(text)
would suffice?
harfbuzz compute length for null terminated string, also utf8 string is expected with the character count , not the byte length.
from vkvg.
Oh ok
from vkvg.
1. support for text strings that are not null terminated. just a convenience for rendering long/multi-line text.
So I've quickly implemented it, but not yet tested.
2. load font from memory
For now, each font size has it's own face instance. I have to study this feature combined with 'single face shared among sizes', this is some work.
3. return array of glyph positions. useful for selecting text with a mouse.
For harfbuzz, this is straightforward, I have to study how to do without.
4. font kerning without harfbuzz
I've never played with kerning by myself, maybe that's not too much work. But without harfbuzz, text shaping support will be minimal.
from vkvg.
- Thank you.
- I think the easy thing would be to just store a pointer to the raw font data instead of the path in
vkvg_font_identity_t
, and then just skip thefopen
(stbtt) or useFT_New_Memory_Face
. - I think this would just be a public API for
glyphs
invkvg_text_run_t
- Freetype has
FT_Get_Kerning
and stbtt hasstbtt_GetGlyphKernAdvance
.
from vkvg.
This sounded a so good and straightforward idea that I've implemented it . #89 I've quickly test it, tell me if it fits your needs.
Awesome. I just checked, this is basically what nanovg does. Although it only has one font struct. It autoscales that font size with the transformation matrix. This looks better better when zooming in, but probably uses a lot more memory. The ideal solution is probably using mipmapping with the requested size and a set of arbitrarily chosen larger sizes scaled down.
from vkvg.
Ah yes, an opaque pointer, so I would have had to implement some query functions on it. What about returning individual position elements by glyph index, I've pushed the fix.
from vkvg.
This sounded a so good and straightforward idea that I've implemented it . #89 I've quickly test it, tell me if it fits your needs.
Awesome. I just checked, this is basically what nanovg does. Although it only has one font struct. It autoscales that font size with the transformation matrix. This looks better better when zooming in, but probably uses a lot more memory. The ideal solution is probably using mipmapping with the requested size and a set of arbitrarily chosen larger sizes scaled down.
Due to font subpixel filtering, mipmapping could hardly improve, unless mipmaps are constructed with font rasteriser, but it could be tricky to implement. I plan to implement sdf fonts for adaptative scaling...
from vkvg.
vkvg don't use the freetype font matrix transform, cairo does, at least in some cases. This transforms also the subpixel filter result (I need to double check, but if not, I can't see another advantage to have a font matrix), which gives better result. The vkvg's font cache store untransformed glyphs for each sizes. The context matrix transformation gives poor results on fonts due to the existing subpixel filter on cached glyphs.
from vkvg.
another option for better adaptative scaling, is uploading vectorized glyphs instead of rasterized bitmaps per sizes...
from vkvg.
normally, the method should be called in release without the assert check. Do you experienced that the complete line is discarded? even the stbtt_InitFont call?
from vkvg.
Correct, from assert.h:
ifdef NDEBUG
#define assert(x) (void)0
#else
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
#endif
from vkvg.
I've confirmed the above fix works.
from vkvg.
- return array of glyph positions. useful for selecting text with a mouse.
How would you implement text selection?
from vkvg.
Related Issues (20)
- gradient alpha channel ignored HOT 2
- Segfaults in surface test HOT 1
- Build deb for Debian / Ubuntu HOT 2
- Premult Alpha handling for image load/write
- Special objects with VKVG_STATUS_NO_MEMORY instead of NULL pointer.
- TimeLine semaphore HOT 2
- Issue with getting glyphs info HOT 26
- Implementing Unit Testing with Meson
- Tests crash and other related bugs and Validation errors: HOT 11
- Having trouble using vkh.h HOT 1
- M_PI undeclared HOT 2
- tests/bezier screen not clear on each frame HOT 3
- Cannot build tests on linux with static GLFW HOT 3
- Multi-window support? HOT 3
- crash when i use multithreaded to draw text HOT 5
- i want to remove the font lock HOT 1
- Vulkan validator prints error on fragment compilation (vkCreateShaderModule) HOT 8
- feature request: box (rounded rectangle) gradient
- vkvg api to query vulkan context creation requirements
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 vkvg.