2014-10-20 09:31:18 +00:00
|
|
|
--
|
|
|
|
-- Disguiser SWEP - Lets you disguise as any prop on a map.
|
|
|
|
--
|
|
|
|
-- File:
|
|
|
|
-- patch_createfont.lua
|
|
|
|
--
|
|
|
|
-- Purpose:
|
|
|
|
-- This code will allow any font to be checked for existence. I hope it works
|
|
|
|
-- as it is only a function patch which should be loaded right at the beginning.
|
|
|
|
-- Can't guarantee that it loads right at the beginning though.
|
|
|
|
--
|
|
|
|
-- Copyright (C) 2013 Carl Kittelberger (Icedream)
|
|
|
|
--
|
|
|
|
-- This program is free software: you can redistribute it and/or modify
|
|
|
|
-- it under the terms of the GNU Affero General Public License as
|
|
|
|
-- published by the Free Software Foundation, either version 3 of the
|
|
|
|
-- License, or (at your option) any later version.
|
|
|
|
--
|
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
-- GNU Affero General Public License for more details.
|
|
|
|
--
|
|
|
|
-- You should have received a copy of the GNU Affero General Public License
|
|
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2013-12-21 09:46:51 +00:00
|
|
|
|
|
|
|
print("[Disguiser] Loading compatibility layer for surface.CreateFont...")
|
|
|
|
|
|
|
|
local registered_fonts = {}
|
|
|
|
|
2014-10-20 09:31:18 +00:00
|
|
|
-- Function already patched by us?
|
|
|
|
if not surface.__createFont == nil then
|
2013-12-21 09:46:51 +00:00
|
|
|
MsgC(Color(255, 255, 0), "[Fontpatch] Can't patch surface.CreateFont, already patched. Skipping patch.\n")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2014-10-20 09:31:18 +00:00
|
|
|
-- Original function
|
2013-12-21 09:46:51 +00:00
|
|
|
surface.__createFont = surface.CreateFont
|
|
|
|
|
2014-10-20 09:31:18 +00:00
|
|
|
-- Patch function
|
2013-12-21 09:46:51 +00:00
|
|
|
function surface.CreateFont(name, data)
|
2014-10-20 09:31:18 +00:00
|
|
|
if not name or not data then return false end
|
2013-12-21 09:46:51 +00:00
|
|
|
|
2014-10-20 09:31:18 +00:00
|
|
|
if registered_fonts[name] then
|
2013-12-21 09:46:51 +00:00
|
|
|
MsgN("[Fontpatch] Skipping font " .. name .. ", already registered")
|
|
|
|
else
|
|
|
|
MsgN("[Fontpatch] Registering font " .. name .. "...")
|
|
|
|
end
|
|
|
|
registered_fonts[name] = true
|
|
|
|
surface.__createFont(name, data)
|
|
|
|
end
|
|
|
|
|
2014-10-20 09:31:18 +00:00
|
|
|
-- Check if a font exists
|
2013-12-21 09:46:51 +00:00
|
|
|
function surface.FontExists(name)
|
2014-10-20 09:31:18 +00:00
|
|
|
return not not registered_fonts[name]
|
2013-12-21 09:46:51 +00:00
|
|
|
end
|