-
Notifications
You must be signed in to change notification settings - Fork 80
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
Font dimensions, etc. #95
Comments
I'd be happy to consider a pull request focused on this particular aspect of GLUI. But if it has obvious side-effects, limitations or breaks compatibility, I would have reservations. Have you pushed code to a repo where we can go peruse the details? Or you'd rather build the suspense? |
Here is what I came up with today:
It's worth noting that The GLUT documentations says "Character to render (not confined to 8 bits). " however I believe freeglut is limited to 256. And I'm unsure what code-page it uses for its 8-bit values. So, I don't know why Here It dawned on me last night that the default font semantics can be straightforward if
|
P.S. I'm going to have to really rethink the constructors. I think it will make sense to inherit the font from the parent in most cases. That will inherit the GLUI container, and it will, I think, avoid initializing The "main_panel" control may require a special, internal constructor to pull it off. The constructors will need to be |
Part of the reason for the following quote is likely that
It's going to take some work to rewrite it. But basically in like 20 or 30 places there are loops that measure a string, add 1 character to the end, measure the whole string again, and so on, rather than just measuring the added character, and adding that to the total length. Whether that is significant work or not (it's hard to believe processing text could've caused detectable slowdown under any circumstances) it is definitely domestic abuse of your home computer. |
You'd want to look the whole string to support Kerning, for example. |
The pattern is not sizing the string. It's sizing letter 1. Sizing letter 1,2. Next 1,2,3. And so on, up to the length of each touched line. It accounts for tabs. (I assume you know, but GLUT doesn't do kerning since it doesn't have a string rendering API, in case someone reading this gets the impression otherwise.) |
Tonight I was looking at the font subroutines.
I noticed GLUT has a
glutBitmapLength
method that could replace the cache of widths currently stored (in a really zany way) in every single control.In my code I reduced the control cache to 128
char
sizers. Part of the reason trying to do anything for GLUI is miserable is back in 2017 even suggesting insane code like this required patching to be taken seriously was met with intense resistance!The
char_widths
field isint char_widths[128][2]
. Yeah, every control stores 1KB of useless memory, or more. 100 controls and you exceed the comment inglui.cpp
that says:Anyway, I've made the 256 char cache one per GLUT font, instead of per control. Assuming that's better (or at least simpler at this point) than
glutBitmapLength
. But also, the textbox control has a fixed height for fonts, set at 15 pixels. I'm now wondering what edittext uses.So I dug this out from the "freeglut" source code:
Assuming it holds for other versions of GLUT, this is the height of each of these fonts.
One problem that remains, is the controls fall back onto the GLUI object's font if their font is zeroed. To fix this somewhat I had the controls initialize their font stuff when added to the GLUI object. But it's not foolproof because the GLUI object's font pointer is exposed, and the control's is too. But at least controls have a
set_font
method.Anyway, that's the state of fonts. I just wanted to share the height information. And remind how sloppy things are, ahead of providing a major service in auditing/rewriting GLUI's code next week.
The text was updated successfully, but these errors were encountered: