-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[examples] BaseSize is divided twice in example 'draw 3d' in 'text' #4901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ZeanKey I'm not sure about this change, I did not create the example so I don't know the intention of the original creator but my guess is that font size in pixels is translated into 3d units, so the baseSize must be considered. Default raylib font has a baseSize of 10px, so, it is mapped to 10 units in 3d. Considering the baseSize maps that mapping correct. Have you tried using another font, for example of 16px, with your change, would it be mapped to 16 units in 3d? |
I just loaded the same font in two different size like following:
and here's the code I used to draw it:
I used the original version of Text3D functions in example in sample and this is the outcome: It's seenable that both text is resized to about 1px according to the grid behind(2px gap). It seems that the example version cannot show these font in units corresponding to different size. Both are shown in about 1 px size 'cause for the dup div. |
Here's how it works in my version: Noted that I used the MeasureTextEx() instead of the version from my PR here since I noticed that I didn't fully fixed the part of textHeight, its still directly returning the value of scale factor. Due to its not completely fixed I've closed that PR.
I think this version rightly, at least properly present the size argument user given which the former one cannot due to the dup div. |
Just also note that I noticed that the space calculation in MeasureText3D() (and its wave version) didn't seem to be right in 3 points:
this appear in MeasureTextWave3D() line 720, however in line 738 it has:
it seems like if font has advanceX not 0 the space would be dupelicated counted, in MeasureTextEx() in core its like:
which didn't count twice so I think example version is not right, since I'm not certain about how advanceX will be defined I didn't write test case. Secondly, for MeasureTextWave3D() only, consider this line for evaluating the width:
The MeasureTextWave3D() use tempLen to calculate the space which take the maximum lenCounter in each line, however, the lenCounter wasn't accumulated through the char to skip the '~~' commend, instead it just take the length of the line. So the spacing for '~~' is also counted which it shouldn't: which is very clear when space is adjusted to 20.0f. Thridly, for the same code:
I think space is also scaled by scale factor, which it shouldn't according to the MeasureTextEx(), but it perhaps was not a very serious problem:
|
I was trying to use code of DrawText3D() and MeasureText3D() in 'draw 3d' example in 'text' part like following and notice that the size of the text is significantly smaller then DrawText(). Also, the X, Z value as return value in MeasureText3D() was different to MeasureTextEx().
This is the native code in example copied from DrawTextCodepoint3D():
Notice that value added in position X and Z, it's OringinalSize / BaseSize * ScaleFactor, aka OringinalSize / BaseSize * FontSize / BaseSize since ScaleFactor defined in line two is FontSize / BaseSize, therefore the basesize is not supposed to be divided again I guess.
The result became normal on my test case after removing the second division.
The text was updated successfully, but these errors were encountered: