Skip to content

Commit

Permalink
[ADD] : add the prototype of a translation systeme (WIP)
Browse files Browse the repository at this point in the history
[IMP] : improvement of ImGuiFreetype, customized to take into account the color change of the PR ocornut/imgui#3369. static func copy from ImDraw for avoid modification of Imdraw
[FiX] : fix project change notif for some widget, was not take into account
[ADD] : add a black screen under the texture, because a colored glyph need to have a tint color of Vec4(1,1,1,1). else on light theme we can see only full ImGuiColText color
[IMP] : improvement of FontInfos for create a table who can say which glyph is colored or not. glyphInfos was modified for reflect this change. due to that, each glyphs is rendered differently regarding if colored or not
[FIX] : add COLR and partial CMAP parsing/display in fontParser
  • Loading branch information
aiekick committed Jan 21, 2021
1 parent 003af57 commit ad89e33
Show file tree
Hide file tree
Showing 17 changed files with 1,068 additions and 143 deletions.
17 changes: 15 additions & 2 deletions src/Gui/ImGuiWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,6 @@ bool ImGui::SliderScalarDefaultCompact(float width, const char* label, ImGuiData
{
bool change = false;

float ax = ImGui::GetCursorPosX();

ImGui::PushID(label);
if (CustomButton(ICON_IGFS_RESET))
{
Expand Down Expand Up @@ -1308,4 +1306,19 @@ bool ImGui::TransparentButton(const char* label, const ImVec2& size_arg, ImGuiBu
RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb);

return pressed;
}

void ImGui::PlainImageWithBG(ImTextureID user_texture_id, const ImVec2& size, const ImVec4& bg_col, const ImVec4& tint_col)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;

ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
ItemSize(bb);
if (!ItemAdd(bb, 0))
return;

window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(bg_col), 0.0f);
window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, ImVec2(0, 0), ImVec2(1, 1), GetColorU32(tint_col));
}
4 changes: 4 additions & 0 deletions src/Gui/ImGuiWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,9 @@ namespace ImGui
////////////////////////////////////////////////////////////////////////////

IMGUI_API bool TransparentButton(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);

////////////////////////////////////////////////////////////////////////////

IMGUI_API void PlainImageWithBG(ImTextureID user_texture_id, const ImVec2& size, const ImVec4& bg_col, const ImVec4& tint_col);
}

6 changes: 4 additions & 2 deletions src/Helper/FontHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,9 @@ bool FontHelper::Assemble_Head_Table()
offset += head->WriteULong(offset, hea->ChecksumAdjustment()); // checkSumAdjustment
offset += head->WriteULong(offset, 0x5F0F3CF5); // magicNumber
offset += head->WriteUShort(offset, hea->FlagsAsInt()); // flags
if (m_FontBoundingBox.Size().emptyOR())

int UnitsPerEM = m_FontBoundingBox.upperBound.x - m_FontBoundingBox.lowerBound.x;
if (UnitsPerEM >= 16 && UnitsPerEM <= 16384) // freetype will refused font if not ok
{
offset += head->WriteUShort(offset, hea->UnitsPerEm()); // unitsPerEm
}
Expand All @@ -882,7 +884,7 @@ bool FontHelper::Assemble_Head_Table()
}
offset += head->WriteDateTime(offset, hea->Created()); // created
offset += head->WriteDateTime(offset, hea->Modified()); // modified
if (m_FontBoundingBox.Size().emptyOR())
if (UnitsPerEM >= 16 && UnitsPerEM <= 16384) // freetype will refused font if not ok
{
offset += head->WriteShort(offset, hea->XMin()); // xMin
offset += head->WriteShort(offset, hea->YMin()); // yMin
Expand Down
Loading

0 comments on commit ad89e33

Please sign in to comment.