Sex* Posted February 16, 2013 Share Posted February 16, 2013 So i got this script and its got another font at mapinfo and stuff but in loadingscreen the font is bankgothic, so i changed font to mine but it still is in bankgothic font... font1 = dxCreateFont("font.ttf", 18) g_dxGUI['travelText4'] = dxText:create('', screenWidth/2, screenHeight/2-70, false, font1, 0.70, 'center' ) In other text the font works like this: dxDrawColorText ('#FF4000FPS: #FFFFFF??', 2, screenHeight - dxGetFontHeight(3.00, font1)/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.48, font1, 0.48, 'left') Link to comment
Castillo Posted February 16, 2013 Share Posted February 16, 2013 the dxText library doesn't support custom fonts if I'm right. Link to comment
Baseplate Posted February 16, 2013 Share Posted February 16, 2013 the dxText library doesn't support custom fonts if I'm right. This function creates a DX font element that can be used in dxDrawText. Successful font creation is not guaranteed, and may fail due to hardware or memory limitations. Link to comment
Sex* Posted February 16, 2013 Author Share Posted February 16, 2013 DxDrawColorText supports then. But how to make so it would be the same height and stuff? Something....But check if im right: g_dxGUI['travelText4'] = dxDrawColorText ('', 2, screenHeight - dxGetFontHeight(2.00, font1)/2, 100, 100, tocolor ( 255, 50, 0, 255 ), 0.70, font1, 0.70, 'center') In this way it would be right and work? Link to comment
Castillo Posted February 16, 2013 Share Posted February 16, 2013 the dxText library doesn't support custom fonts if I'm right. This function creates a DX font element that can be used in dxDrawText. Successful font creation is not guaranteed, and may fail due to hardware or memory limitations. I'm not talking about the MTA DX functions, I'm talking about the dxText library used for race. Link to comment
Sex* Posted February 16, 2013 Author Share Posted February 16, 2013 DxDrawColorText supports then. But how to make so it would be the same height and stuff?Something....But check if im right: g_dxGUI['travelText4'] = dxDrawColorText ('', 2, screenHeight - dxGetFontHeight(2.00, font1)/2, 100, 100, tocolor ( 255, 50, 0, 255 ), 0.70, font1, 0.70, 'center') In this way it would be right and work? But would this work then? Link to comment
DNL291 Posted February 16, 2013 Share Posted February 16, 2013 You can put the 'colorCoded' argument to true in the dxDrawText function to enable color codes. Link to comment
Castillo Posted February 16, 2013 Share Posted February 16, 2013 DxDrawColorText supports then. But how to make so it would be the same height and stuff?Something....But check if im right: g_dxGUI['travelText4'] = dxDrawColorText ('', 2, screenHeight - dxGetFontHeight(2.00, font1)/2, 100, 100, tocolor ( 255, 50, 0, 255 ), 0.70, font1, 0.70, 'center') In this way it would be right and work? But would this work then? It won't work just like that, you should add custom fonts in the dxText library. Link to comment
Sex* Posted February 18, 2013 Author Share Posted February 18, 2013 But it works at the other text... --mapdisplaytitle = dxText:create('Map: ', 3, screenHeight - dxGetFontHeight(scale, 'bankgothic')/2, false, 'bankgothic', scale, 'left'), dxDrawColorText ('#FF4000Map: #ffffFF' .. g_MapInfo.name, 2, screenHeight - dxGetFontHeight(2.00, font1)/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.48, font1, 0.48, 'left') else dxDrawColorText ('#FF4000Map: #ffffFFNo map is set yet', 2, screenHeight - dxGetFontHeight(2.00, font1)/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.48, font1, 0.48, 'left') end So its got to work with that also! And its in the same file! Link to comment
Anderl Posted February 18, 2013 Share Posted February 18, 2013 "dxDrawColorText" isn't the same as DxText lib. Link to comment
Sex* Posted February 19, 2013 Author Share Posted February 19, 2013 BUT HOW ITS WORKING THEN WITH dxText!?! Link to comment
Castillo Posted February 19, 2013 Share Posted February 19, 2013 It's because is not just dxDrawText. Link to comment
Sex* Posted February 25, 2013 Author Share Posted February 25, 2013 And where i can modify the dxText library then? Link to comment
Anderl Posted February 25, 2013 Share Posted February 25, 2013 Race resource - "textlib.lua". Link to comment
Sex* Posted February 25, 2013 Author Share Posted February 25, 2013 And what i have to modify there?? Link to comment
ZL|LuCaS Posted February 25, 2013 Share Posted February 25, 2013 você adicionando isso no "textlib.lua" você vai poder user "dxDrawColorText" function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end Link to comment
50p Posted February 25, 2013 Share Posted February 25, 2013 @ZL|LuCaS, Speak English in the English forums. @Sex*, You can check my drift resource. I used dxText lib and it supports custom fonts. Just the the textlib.lua from there. https://community.multitheftauto.com/ind ... ls&id=5078 Link to comment
Anderl Posted February 25, 2013 Share Posted February 25, 2013 você adicionando isso no "textlib.lua" você vai poder user "dxDrawColorText" function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end That has completely nothing to do with what he wants, and dxDrawText already supports color codes. 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