|
TheExDeus
|
|
Reply #31 Posted on: May 12, 2011, 05:58:07 am |
|
|
Joined: Apr 2008
Posts: 1860
|
Yeah, but I need the highest offset from the baseline. I will illustrate: Here is the code: str="This is text. p and q"; draw_set_font(font_0); draw_text(10,10,str); draw_circle_color(10,10,2,c_red,c_red,0); draw_line(10,10+string_height(str),10+string_width(str),10+string_height(str)); I added explanation in paint.net. So I need to get the highest y2 value to subtract from the baseline. The red dot is the drawing origin position. edit: Also on the side note. Which file is used: GAME_GLOBALS.h or key_game_globals.h? Or both? Or none? Because when I include GAME_GLOBALS.h it shows that "string does not name a type" which makes me think that it is not actually included anywhere (and my search didn't return anything either). key_game_globals.h is included in roomsystem.cpp but it even has this besides it: "//TODO: Remove all instances of this line. It's just sloppy. Figure out the dependencies manually.". So how exactly I add globals? I want to make keyboard_string (or at least very limited version). The basics is just adding this line: if (last_keybdstatus[i] != keybdstatus[i]) keyboard_string+=chr(i); To void input_push() functions "for" cycle inside WINDOWScallback.cpp. You can clearly see lots of problems (like adding every button on the keyboard to a string), but what I need is just basics for a little test so I don't mind about this.
|
|
« Last Edit: May 12, 2011, 11:09:36 am by HaRRiKiRi »
|
Logged
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #33 Posted on: May 12, 2011, 12:56:34 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
HaRRi: That's because the offsets I calculate in the texture are relative to the baseline rather than to the bottommost point on any glyph or the topmost. You are simply adding the height of the glyph to the supplied "y" coordinate of draw_text. You should instead be adding the difference between the topmost point of the tallest glyph and the baseline.
I will add a calculation for the aforementioned value, which you will use to offset the supplied "y".
IsmAvatar: No further action is required of you.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
TheExDeus
|
|
Reply #34 Posted on: May 12, 2011, 01:24:27 pm |
|
|
Joined: Apr 2008
Posts: 1860
|
HaRRi: That's because the offsets I calculate in the texture are relative to the baseline rather than to the bottommost point on any glyph or the topmost. You are simply adding the height of the glyph to the supplied "y" coordinate of draw_text. You should instead be adding the difference between the topmost point of the tallest glyph and the baseline. I am fully aware of this. That is why I asked if a new value will be introduced to show the highest y coordinate of the bottom most point. So basically you are going to give me this value via the struct? So I will be able to just do this: yy = y - fnt->baseoffset; Or something similar? I can actually do all of this myself, but I wanted to ask if this is ok way to do it. Anyway, I will wait until the next rev. Is everything working correctly in the latest rev? That's the reason I still use 710. Time to update I guess.
|
|
|
Logged
|
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #37 Posted on: June 18, 2011, 03:16:28 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
CompilerSource/compiler/components/write_font_info.cpp writes the structures containing the font data. This is where you'd insert the baseline position;
CompilerSource/compiler/reshandlers/refont.h defines that structure; add a member to it.
Most of the glyph iteration is done in CompilerSource/compiler/components/module_write_fonts.cpp; you may need to copy one of the for loops out ahead of time to calculate that member (if so, you don't need to edit the structure in refont.h).
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
Josh @ Dreamland
|
|
Reply #39 Posted on: July 07, 2011, 05:29:31 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
I made some move toward implementing that for you, but I forget where I left off. *shrug* Sorry about that. Case-closed then, yes?
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
TheExDeus
|
|
Reply #40 Posted on: July 07, 2011, 05:55:44 pm |
|
|
Joined: Apr 2008
Posts: 1860
|
but I forget where I left off Near the first line probably. Case-closed then, yes? Yes, I also committed 801, but SF doesn't show that for some reason. Thou I didn't change font_add_sprite function, forgot about that.
|
|
« Last Edit: July 07, 2011, 05:57:48 pm by HaRRiKiRi »
|
Logged
|
|
|
|
|
TheExDeus
|
|
Reply #42 Posted on: July 09, 2011, 05:24:43 am |
|
|
Joined: Apr 2008
Posts: 1860
|
That's good, because my changes don't really change the position or height of a separate glyph. It looks for the biggest y2 and then subtracts that from the whole y position when drawing. When this is done it draws properly.
Also, I just tested and I can't even load wingdings in LGM, it just renders boxes. And that leads to my next question - How UTF support will be added? I am actually quite incompetent in that matter, because UTF standard has more than hundred thousand characters, and then I guess fonts just have the basic chars in them and not all of them, right? I doubt games that has UTF support renders all of thous chars on a texture, but they do use them somehow. For example, in Source Engine games (like CS:S) I have seen chinese symbols in chat while I don't actually have that charset installed. LGM's scripting editor does seem to handle utf chars so no problem there (though I don't know if gm6 format supports them, but the newest gmk does).
Next thing is about draw_set_halign(). I have an idea on how to do this, but that will involve cluttering the draw_text functions. I wouldn't want to make them slower than they need to be. This is the original line:
int xx = x, yy = y+fnt->yoffset; and it will have to be changed to this:
if (halign == fa_left){ xx = x; }else if (halign == fa_middle){ xx = x-string_width(str)/2; }else{ //fa_right xx = x-string_width(str); } I did fa_left the first because its the default and usual alignment. So in default case this will slow the code down by a one if statement. On the other hand things like fa_middle require me to know the width of the string, and string_width() is O(n). And this only for the halign.
|
|
|
Logged
|
|
|
|
Josh @ Dreamland
|
|
Reply #43 Posted on: July 09, 2011, 10:35:51 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
That code doesn't consider newlines. Not having the code as fa_left fucks everything up, efficiency wise. You're best to fork up front.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
polygone
|
|
Reply #44 Posted on: July 09, 2011, 11:05:21 am |
|
|
Location: England Joined: Mar 2009
Posts: 794
|
There should be functions added for draw_get_halign / valign these are missing from gml.
|
|
|
Logged
|
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
|
|
|
|