if (type (Require) ~= 'function') then loadstring(exports['nc_libraries']:extend('Extend'), 'Require')() end local math = math; local math_round = math.round or (function(number) return (math_floor((number * (10 ^ 0)) + 0.5)) / (10 ^ 0) end) local Fonts = {}; function Fonts:Constructor() if (not Responsive and not _G.Responsive) then _G.Responsive = Require('Interface/Responsive') self.Responsive = _G.Responsive else self.Responsive = Responsive end if (not Draw and not _G.Draw) then _G.Draw = Require('Interface/Draw') self.Draw = _G.Draw else self.Draw = Draw end Require('Math') self.Elements = {}; self.ResourceAssets = getResourceFromName('nc_assets'); self.AssetsExport = self.ResourceAssets and getResourceState(self.ResourceAssets) == 'running' and exports['nc_assets']; return self; end function Fonts:GetSize(Directory, Size) Directory = ':nc_assets/files/fonts/'..Directory..'.ttf' local _Size = math_round(Size) local _Max = 200 for i = 1, _Max do local Font = dxCreateFont(Directory, i) if isElement(Font) then local Height = dxGetFontHeight(1, Font) destroyElement(Font) if Height >= _Size then return Height end end end end function Fonts:nearestEven(n) return math.floor(n / 2 + 0.5) * 2 end function Fonts:Get(FontName, FontSize, Recursive, ...) self.Elements[FontName] = self.Elements[FontName] or {} self.Elements[FontName][FontSize] = self.Elements[FontName][FontSize] or {} Recursive = type(Recursive) == 'boolean' and Recursive or false if not self.Elements[FontName][FontSize][Recursive] then local _FontSize = Recursive and self.Responsive:RespcX(FontSize) or FontSize --local _FontSize = Recursive and self.Responsive:Respc(FontSize / 1.25 + 0.65) or FontSize --_FontSize = self:nearestEven(_FontSize) local FONT_Element if not self.ResourceAssets then self.ResourceAssets = getResourceFromName('nc_assets') end if not self.AssetsExport then self.AssetsExport = getResourceState(self.ResourceAssets) == 'running' and exports['nc_assets'] end if self.AssetsExport and self.AssetsExport:isLoaded() then FONT_Element = self.AssetsExport:getFont(FontName, _FontSize, ...) end if isElement(FONT_Element) then self.Elements[FontName][FontSize][Recursive] = FONT_Element addEventHandler('onClientElementDestroy', FONT_Element, function() if self.Elements[FontName] and self.Elements[FontName][FontSize] then self.Elements[FontName][FontSize][Recursive] = nil if next(self.Elements[FontName][FontSize]) == nil then self.Elements[FontName][FontSize] = nil end if next(self.Elements[FontName]) == nil then self.Elements[FontName] = nil end end end) end end return (self.Elements[FontName][FontSize] and self.Elements[FontName][FontSize][Recursive]) or 'default-bold' end _G.Fonts = Fonts; return Fonts;