Closed Rubo3 closed 2 years ago
and? hb return x_advance, that looks normal for me. metrics looks different between with/without harfbuzz.
But if that's normal, what should you do with this info? I mean, it's the same for all glyphs.
Wait do you mean it returns x_advance only?
Oh ok, but isn't 1024 too much? The glyphs are clearly not distant 1024 pixels from each other.
Font metrics has some subtilities, we have to define clearly what unit we use for both harfbuzz and stb for returned values.
Yes, it would be a good idea to return the same values from vkvg_get_glyph_position
regardless of the backend vkvg uses.
I noticed that with or without HarfBuzz I always get 1024, 0, 0, 0.
I made a quick test this afternoon, and I got different results, I have to double check this.
@billzez do you have the same issue?
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
.
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
.
give me a complete run-able sample so that I could check everything.
Here you go: https://gitlab.com/Rubo/shitty. The relevant function is here: https://gitlab.com/Rubo/shitty/-/blob/master/editor/main.c#L42
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.
Oh right, that was so easy I didn't think about it...
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
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
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
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....
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.
How old are you Rubo?
Does it matter?
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.
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.
I didn't mean to hurt you, sorry.
Don't worry! I was just exaggerating.
When I call
vkvg_text_run_get_glyph_position
with HarfBuzz with a pointer to enough memory, no matter what the index is or the number of glyphs is, I always getx_advance = 1024
, andy_advance
,x_offset
andy_offset = 0
. The text is correctly displayed though.