Skip to content

Commit

Permalink
Merge pull request #765 from Nats-ji/iconfont
Browse files Browse the repository at this point in the history
Add icon font support
  • Loading branch information
WSSDude authored Dec 4, 2022
2 parents c65a753 + cb8ce83 commit e2764cd
Show file tree
Hide file tree
Showing 9 changed files with 14,238 additions and 1 deletion.
23 changes: 23 additions & 0 deletions ThirdParty_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,26 @@ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

=========== Material Design Icons ============

Pictogrammers Free License
--------------------------

This icon collection is released as free, open source, and GPL friendly by
the [Pictogrammers](http://pictogrammers.com/) icon group. You may use it
for commercial projects, open source projects, or anything really.

# Icons: Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
Some of the icons are redistributed under the Apache 2.0 license. All other
icons are either redistributed under their respective licenses or are
distributed under the Apache 2.0 license.

# Fonts: Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
All web and desktop fonts are distributed under the Apache 2.0 license. Web
and desktop fonts contain some icons that are redistributed under the Apache
2.0 license. All other icons are either redistributed under their respective
licenses or are distributed under the Apache 2.0 license.

# Code: MIT (https://opensource.org/licenses/MIT)
The MIT license applies to all non-font and non-icon files.
Binary file added fonts/materialdesignicons.ttf
Binary file not shown.
7,102 changes: 7,102 additions & 0 deletions scripts/IconGlyphs/icons.lua

Large diffs are not rendered by default.

7,103 changes: 7,103 additions & 0 deletions src/common/FontMaterialDesignIcons.h

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/d3d12/D3D12_Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ void D3D12::ReloadFonts()
}
else
io.Fonts->AddFontFromFileTTF(UTF16ToUTF8(customFontPath.native()).c_str(), config.SizePixels, &config, cpGlyphRanges);

// add icons from fontawesome4
config.GlyphMinAdvanceX = config.SizePixels;
static const ImWchar icon_ranges[] = {ICON_MIN_MD, ICON_MAX_MD, 0};
auto cetIconPath = GetAbsolutePath(L"materialdesignicons.ttf", m_paths.Fonts(), false);
io.Fonts->AddFontFromFileTTF(UTF16ToUTF8(cetIconPath.native()).c_str(), config.SizePixels, &config, icon_ranges);
}

bool D3D12::InitializeImGui(size_t aBuffersCounts)
Expand Down
1 change: 1 addition & 0 deletions src/scripting/LuaSandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static constexpr const char* s_cVMGlobalObjectsWhitelist[] =
"math",
"bit32",
"json",
"IconGlyphs",
};

static constexpr const char* s_cGlobalObjectsWhitelist[] =
Expand Down
1 change: 1 addition & 0 deletions src/scripting/Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void Scripting::Initialize()
const auto previousCurrentPath = std::filesystem::current_path();
current_path(m_paths.CETRoot() / "scripts");
luaVm.script("json = require 'json/json'", sol:: detail::default_chunk_name(), sol::load_mode::text);
luaVm.script("IconGlyphs = require 'IconGlyphs/icons'", sol:: detail::default_chunk_name(), sol::load_mode::text);
current_path(previousCurrentPath);

// initialize sandbox
Expand Down
1 change: 1 addition & 0 deletions src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

#include "CETVersion.h"
#include "common/Logging.h"
#include "common/FontMaterialDesignIcons.h"
#include "Options.h"
#include "Paths.h"
#include "PersistentState.h"
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ add_requires("xbyak")
add_requires("stb")
add_requires("sol2", { configs = { includes_lua = false } })
add_requires("openrestry-luajit", { configs = { gc64 = true } })
add_requires("imgui v1.88-docking", { configs = { user_config = imguiUserConfig } })
add_requires("imgui v1.88-docking", { configs = { wchar32 = true, freetype = true, user_config = imguiUserConfig } })

target("RED4ext.SDK")
set_kind("static")
Expand Down

0 comments on commit e2764cd

Please sign in to comment.