GithubHelp home page GithubHelp logo

Issue with getting glyphs info about vkvg HOT 26 CLOSED

Rubo3 avatar Rubo3 commented on July 23, 2024 1
Issue with getting glyphs info

from vkvg.

Comments (26)

Rubo3 avatar Rubo3 commented on July 23, 2024 1

Wait do you mean it returns x_advance only?

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024 1

Yes, it would be a good idea to return the same values from vkvg_get_glyph_position regardless of the backend vkvg uses.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024 1

Oh right, that was so easy I didn't think about it...

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024 1

Right, thank you, I also changed the x_advance type at line 29 to int32_t. Now I get:

Text x_advance = 184.000000
...
Total x_advance = 12083

which still are not the same.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024 1

Don't worry! I was just exaggerating.

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

and? hb return x_advance, that looks normal for me.
metrics looks different between with/without harfbuzz.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

But if that's normal, what should you do with this info? I mean, it's the same for all glyphs.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

Oh ok, but isn't 1024 too much? The glyphs are clearly not distant 1024 pixels from each other.

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

Font metrics has some subtilities, we have to define clearly what unit we use for both harfbuzz and stb for returned values.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

I noticed that with or without HarfBuzz I always get 1024, 0, 0, 0.

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

I made a quick test this afternoon, and I got different results, I have to double check this.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

@billzez do you have the same issue?

from vkvg.

billzez avatar billzez commented on July 23, 2024

I believe these values are fixed point, so you have to convert to float. (float)x_advance / 16.0 for subpixel position or just x_advance >> 6.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

Thanks, but why divide by 16? Also, comparing the result of vkvg_text_run_get_glyph_position with the one from vkvg_text_run_get_extents, with a text run of only one character, on the former I get sane values, like width = 16, height = 36, x_advance = 16, y_advance = 0, while on the latter I still get 1024, 0, 0, 0, 0. Even if I divide 2014 by 16, I get 64, which is four times greater than the text run x_advance.

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

give me a complete run-able sample so that I could check everything.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

Here you go: https://gitlab.com/Rubo/shitty. The relevant function is here: https://gitlab.com/Rubo/shitty/-/blob/master/editor/main.c#L42

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

I run 'make', and nothing happens. I was talking about a simple unit test, you may just add a method or two in the tests/text.c sample, this would be simpler for me.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

I think this would suffice: hello.txt (I changed its extension to .txt so that GitHub would not complain).

As a result, with HarfBuzz I get:

Text x_advance = 184.000000

Glyphs x_advance:
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000

Total x_advance = 12083.000000

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

my result with harfbuzz & freetype:

Text x_advance = 196.000000

Glyphs x_advance:
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000
196.000000

Total x_advance = 12953.000000

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

and without harfbuzz, small metrics diff:

Text x_advance = 203.000000

Glyphs x_advance:
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000
203.000000

Total x_advance = 12992.000000

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

change

printf("%f\n", info.x_advance);

with

printf("%d\n", info.x_advance);

It's an integer, that you try to print out as a float....

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

How old are you Rubo?

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

Does it matter?

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

Sometimes I feel you are very young (12-14yo), but maybe I'm wrong. I appreciate your involvement but you have to solve such simple issue by yourself. Creating opensource software is such demanding, you must be a little harder with yourself. Other pr are really complicated, there I'm pleased to help you, but here, you should be able to go forward by yourself. Tanks again for your help.

from vkvg.

Rubo3 avatar Rubo3 commented on July 23, 2024

Sometimes I feel you are very young (12-14yo)

Well this one did hurt...
Anyway, I solved by creating a text run for each glyph, then vkvg_text_extents_t.width and vkvg_text_extents_t.height did the trick. Sorry to have bothered you with such simple issues.

from vkvg.

jpbruyere avatar jpbruyere commented on July 23, 2024

I didn't mean to hurt you, sorry.

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.