Fizo Posted December 9, 2017 Share Posted December 9, 2017 (edited) Hello, I have very simple problem but,I haven't idea how to solution this. If I typeing data to my table,and then displaying characters have diffrent sparation. This image shows my problem. This text meaning in English "example message". Thanks of lot for help. My Code: for i,v in ipairs(value) do dxDrawText(v,screenW * 0.8318, screenH * 0.4852, screenW * 0.055*i/3, screenH * 0.5157, tocolor(255, 255, 255, 255),2, "default", "center", "center", false, false, false, false, false) end Edited December 9, 2017 by Fizo Link to comment
Moderators IIYAMA Posted December 9, 2017 Moderators Share Posted December 9, 2017 That is obvious, every character has a different width so the spaces are different as well. Pick a font which has the same character width for every character. Or use this function: https://wiki.multitheftauto.com/wiki/DxGetTextWidth 1 Link to comment
Fizo Posted December 9, 2017 Author Share Posted December 9, 2017 (edited) for i,v in ipairs(value) do local width_char = dxGetTextWidth(v) dxDrawText(v,screenW * 0.8318, screenH * 0.4852, screenW * 0.055*width_char/i/2, screenH * 0.5157, tocolor(255, 255, 255, 255),2, "default","center", "center", false, false, false, false, false) end I have problem because i don't kown how to implement this. I'm trying but unsuccessfully 38 minutes ago, IIYAMA said: That is obvious, every character has a different width so the spaces are different as well. Pick a font which has the same character width for every character. Or use this function: https://wiki.multitheftauto.com/wiki/DxGetTextWidth Edited December 9, 2017 by Fizo Link to comment
Moderators IIYAMA Posted December 9, 2017 Moderators Share Posted December 9, 2017 (edited) local textInProgress = "" for i,v in ipairs(value) do local wordWidth = dxGetTextWidth(textInProgress) textInProgress = textInProgress .. v dxDrawText(v,screenW * 0.8318 + wordWidth, screenH * 0.4852, screenW * 0.8318 + wordWidth + 10, screenH * 0.5157, tocolor(255, 255, 255, 255),2, "default","left", "center", false, false, false, false, false) end Something like this. Do not align the X axis with center, because dxDrawText is working with a bounding box and not with `width` properties. Required Arguments text: the text to draw left: the absolute X coordinate of the top left corner of the text top: the absolute Y coordinate of the top left corner of the text Optional Arguments right: the absolute X coordinate of the right side of the text bounding box. Used for text aligning, clipping and word breaking. bottom: the absolute Y coordinate of the bottom side of the text bounding box. Used for text aligning, clipping and word breaking. Edited December 9, 2017 by IIYAMA Link to comment
Fizo Posted December 9, 2017 Author Share Posted December 9, 2017 It's work thank you very much 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now