Git Product home page Git Product logo

Comments (27)

billzez avatar billzez commented on May 24, 2024 2

I like just calling it vkvg_text_run_create_with_length.

from vkvg.

jpbruyere avatar jpbruyere commented on May 24, 2024 2
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.

jpbruyere avatar jpbruyere commented on May 24, 2024 2
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.

Rubo3 avatar Rubo3 commented on May 24, 2024 1

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.

billzez avatar billzez commented on May 24, 2024 1

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.

billzez avatar billzez commented on May 24, 2024 1

So rasterized for smaller sizes? Yeah, that would probably be ideal.

from vkvg.

billzez avatar billzez commented on May 24, 2024 1

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.

billzez avatar billzez commented on May 24, 2024 1

In _font_cache_create_text_run, strlen still gets called on all strings.

from vkvg.

jpbruyere avatar jpbruyere commented on May 24, 2024 1

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.

jpbruyere avatar jpbruyere commented on May 24, 2024 1

In _font_cache_create_text_run, strlen still gets called on all strings.

I've pushed the removal on master (311d063).

from vkvg.

Rubo3 avatar Rubo3 commented on May 24, 2024

return array of glyph positions. useful for selecting text with a mouse.

I think that would be useful in pangovkvg, too.

from vkvg.

jpbruyere avatar jpbruyere commented on May 24, 2024

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.

Rubo3 avatar Rubo3 commented on May 24, 2024

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.

jpbruyere avatar jpbruyere commented on May 24, 2024

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.

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.

jpbruyere avatar jpbruyere commented on May 24, 2024

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?
harfbuzz compute length for null terminated string, also utf8 string is expected with the character count , not the byte length.

from vkvg.

Rubo3 avatar Rubo3 commented on May 24, 2024

Oh ok

from vkvg.

jpbruyere avatar jpbruyere commented on May 24, 2024
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.

billzez avatar billzez commented on May 24, 2024
  1. Thank you.
  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.
  3. I think this would just be a public API for glyphs in vkvg_text_run_t
  4. Freetype has FT_Get_Kerning and stbtt has stbtt_GetGlyphKernAdvance.

from vkvg.

billzez avatar billzez commented on May 24, 2024

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.

jpbruyere avatar jpbruyere commented on May 24, 2024

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.

jpbruyere avatar jpbruyere commented on May 24, 2024

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.

jpbruyere avatar jpbruyere commented on May 24, 2024

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.

jpbruyere avatar jpbruyere commented on May 24, 2024

another option for better adaptative scaling, is uploading vectorized glyphs instead of rasterized bitmaps per sizes...

from vkvg.

jpbruyere avatar jpbruyere commented on May 24, 2024

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.

billzez avatar billzez commented on May 24, 2024

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.

billzez avatar billzez commented on May 24, 2024

I've confirmed the above fix works.

from vkvg.

Rubo3 avatar Rubo3 commented on May 24, 2024
  1. return array of glyph positions. useful for selecting text with a mouse.

How would you implement text selection?

from vkvg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.