|
@@ -58,8 +58,6 @@
|
|
|
#define IMGUI_NEW(type) new (ImGui::MemAlloc(sizeof(type) ) ) type
|
|
#define IMGUI_NEW(type) new (ImGui::MemAlloc(sizeof(type) ) ) type
|
|
|
#define IMGUI_DELETE(type, obj) reinterpret_cast<type*>(obj)->~type(), ImGui::MemFree(obj)
|
|
#define IMGUI_DELETE(type, obj) reinterpret_cast<type*>(obj)->~type(), ImGui::MemFree(obj)
|
|
|
|
|
|
|
|
-const stbtt_fontinfo& getFontInfo(int index);
|
|
|
|
|
-
|
|
|
|
|
static void fillRectangle(Scintilla::PRectangle _rc, Scintilla::ColourDesired _color)
|
|
static void fillRectangle(Scintilla::PRectangle _rc, Scintilla::ColourDesired _color)
|
|
|
{
|
|
{
|
|
|
const uint32_t abgr = (uint32_t)_color.AsLong();
|
|
const uint32_t abgr = (uint32_t)_color.AsLong();
|
|
@@ -82,8 +80,8 @@ static inline uint32_t makeRgba(uint32_t r, uint32_t g, uint32_t b, uint32_t a =
|
|
|
|
|
|
|
|
struct FontInt
|
|
struct FontInt
|
|
|
{
|
|
{
|
|
|
- stbtt_fontinfo m_fontInfo;
|
|
|
|
|
- float m_scale;
|
|
|
|
|
|
|
+ ImFont* m_font;
|
|
|
|
|
+ float m_scale;
|
|
|
float m_fontSize;
|
|
float m_fontSize;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -238,31 +236,19 @@ public:
|
|
|
virtual Scintilla::XYPOSITION WidthChar(Scintilla::Font& _font, char ch) BX_OVERRIDE
|
|
virtual Scintilla::XYPOSITION WidthChar(Scintilla::Font& _font, char ch) BX_OVERRIDE
|
|
|
{
|
|
{
|
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
|
-
|
|
|
|
|
- int advance, leftBearing;
|
|
|
|
|
- stbtt_GetCodepointHMetrics(&fi->m_fontInfo, ch, &advance, &leftBearing);
|
|
|
|
|
-
|
|
|
|
|
- return advance * fi->m_scale;
|
|
|
|
|
|
|
+ return fi->m_font->GetCharAdvance((unsigned int)ch) * fi->m_scale;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
virtual Scintilla::XYPOSITION Ascent(Scintilla::Font& _font) BX_OVERRIDE
|
|
virtual Scintilla::XYPOSITION Ascent(Scintilla::Font& _font) BX_OVERRIDE
|
|
|
{
|
|
{
|
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
|
-
|
|
|
|
|
- int ascent, descent, lineGap;
|
|
|
|
|
- stbtt_GetFontVMetrics(&fi->m_fontInfo, &ascent, &descent, &lineGap);
|
|
|
|
|
-
|
|
|
|
|
- return ascent * fi->m_scale;
|
|
|
|
|
|
|
+ return fi->m_font->Ascent * fi->m_scale;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
virtual Scintilla::XYPOSITION Descent(Scintilla::Font& _font) BX_OVERRIDE
|
|
virtual Scintilla::XYPOSITION Descent(Scintilla::Font& _font) BX_OVERRIDE
|
|
|
{
|
|
{
|
|
|
- int ascent, descent, lineGap;
|
|
|
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
|
-
|
|
|
|
|
- stbtt_GetFontVMetrics(&fi->m_fontInfo, &ascent, &descent, &lineGap);
|
|
|
|
|
-
|
|
|
|
|
- return -descent * fi->m_scale;
|
|
|
|
|
|
|
+ return -fi->m_font->Descent * fi->m_scale;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
virtual Scintilla::XYPOSITION InternalLeading(Scintilla::Font& /*_font*/) BX_OVERRIDE
|
|
virtual Scintilla::XYPOSITION InternalLeading(Scintilla::Font& /*_font*/) BX_OVERRIDE
|
|
@@ -270,12 +256,9 @@ public:
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- virtual Scintilla::XYPOSITION ExternalLeading(Scintilla::Font& _font) BX_OVERRIDE
|
|
|
|
|
|
|
+ virtual Scintilla::XYPOSITION ExternalLeading(Scintilla::Font& /*_font*/) BX_OVERRIDE
|
|
|
{
|
|
{
|
|
|
- FontInt* fi = (FontInt*)_font.GetID();
|
|
|
|
|
- int ascent, descent, lineGap;
|
|
|
|
|
- stbtt_GetFontVMetrics(&fi->m_fontInfo, &ascent, &descent, &lineGap);
|
|
|
|
|
- return lineGap * fi->m_scale;
|
|
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
virtual Scintilla::XYPOSITION Height(Scintilla::Font& _font) BX_OVERRIDE
|
|
virtual Scintilla::XYPOSITION Height(Scintilla::Font& _font) BX_OVERRIDE
|
|
@@ -314,9 +297,8 @@ private:
|
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
FontInt* fi = (FontInt*)_font.GetID();
|
|
|
|
|
|
|
|
ImVec2 pos = ImGui::GetCursorScreenPos();
|
|
ImVec2 pos = ImGui::GetCursorScreenPos();
|
|
|
- ImFont* imFont = ImGui::GetWindowFont();
|
|
|
|
|
ImDrawList* drawList = ImGui::GetWindowDrawList();
|
|
ImDrawList* drawList = ImGui::GetWindowDrawList();
|
|
|
- drawList->AddText(imFont
|
|
|
|
|
|
|
+ drawList->AddText(fi->m_font
|
|
|
, fi->m_fontSize
|
|
, fi->m_fontSize
|
|
|
, ImVec2(xt + pos.x, yt + pos.y - fi->m_fontSize)
|
|
, ImVec2(xt + pos.x, yt + pos.y - fi->m_fontSize)
|
|
|
, fore
|
|
, fore
|
|
@@ -872,15 +854,12 @@ namespace Scintilla
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Font::Create(const FontParameters& fp)
|
|
void Font::Create(const FontParameters& fp)
|
|
|
- {
|
|
|
|
|
|
|
+ {
|
|
|
FontInt* newFont = (FontInt*)ImGui::MemAlloc(sizeof(FontInt) );
|
|
FontInt* newFont = (FontInt*)ImGui::MemAlloc(sizeof(FontInt) );
|
|
|
fid = newFont;
|
|
fid = newFont;
|
|
|
-
|
|
|
|
|
- const stbtt_fontinfo& fontInfo = getFontInfo(0);
|
|
|
|
|
-
|
|
|
|
|
- memcpy(&newFont->m_fontInfo, &fontInfo, sizeof(stbtt_fontinfo) );
|
|
|
|
|
- newFont->m_scale = stbtt_ScaleForPixelHeight(&fontInfo, fp.size);
|
|
|
|
|
|
|
+ newFont->m_font = ImGui::GetIO().Fonts->Fonts[0];
|
|
|
newFont->m_fontSize = fp.size;
|
|
newFont->m_fontSize = fp.size;
|
|
|
|
|
+ newFont->m_scale = fp.size / newFont->m_font->FontSize;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Font::Release()
|
|
void Font::Release()
|