DTextEntry doesn't update font style for some reason

I’m not sure if this is a Garry’s Mod issue or if I need to do something to get this working properly.

I’m making a placeholder text entry:


local PANEL = {}

surface.CreateFont("bgui_placeholdered",{
	size = 16,
	font = "Roboto",
	italic = true,
})
surface.CreateFont("bgui_textnormal",{
	size = 16,
	font = "Arial",
	italic = false,
})

function PANEL:SetPlaceHolder(text)
	self.PlaceHoldered = true
	self.PlaceHolder = text
	self:SetText(text)
	self:SetFont("bgui_placeholdered")
	self:SetTextColor(Color(64,64,64))
end

function PANEL:Init()
	self:SetFont("bgui_textnormal")
	self:SetTextColor(Color(255,0,0))

	self.OnGetFocus = function()
		if (self.PlaceHoldered == true) then
			self.PlaceHoldered = false
			self:SetFont("bgui_textnormal")
			self:SetTextColor(Color(255,0,0))
			self:SetText("")
		end
	end

	self.OnLoseFocus = function()
		if (self:GetValue() == "" and self.PlaceHolder) then
			self.PlaceHoldered = true
			self:SetText(self.PlaceHolder)
			self:SetFont("bgui_placeholdered")
			self:SetTextColor(Color(64,64,64))
		end
	end
end

function PANEL:OnValueChange(v)
	if (v == "" and self.PlaceHolder) then
		self.PlaceHoldered = true
		self:SetText(self.PlaceHolder)
		self:SetFont("bgui_placeholdered")
		self:SetTextColor(Color(64,64,64))
	end
end

function PANEL:OnKeyCodeTyped(kc)
	if (self.PlaceHoldered == true) then
		self.PlaceHoldered = false
		self:SetFont("bgui_textnormal")
		self:SetTextColor(Color(255,0,0))
		self:SetText("")
	end
end

function PANEL:GetUpdateOnType()
	return true
end

derma.DefineControl("BTextBox",nil,PANEL,"DTextEntry")

This is what happens:

http://billyvenner.xyz/files/2016-02-17_18-14-11.mp4

The text is red, this shows that the code is actually being executed, however, the font does not change.

Is there anything I have to do for this?

for some reason you have to use SetFont in a Paint type hook to set DTextEntry’s font
I may be wrong and that might only be for DRichText though.

Actually DTextEntry’s SetFont is wrong. I will try to fix it.

In the mean time you can try doing either

DLabel.SetFont( mytextentty, font )

OR

call :ApplySchemeSettings() after setting the font.