Jump to content

Font changing


Sex*

Recommended Posts

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

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
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
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
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

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...