mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 13:07:01 +00:00
Added IO.FontYOffset. Added asserts.
This commit is contained in:
parent
8fc50f5ed3
commit
3b339efeb2
@ -279,6 +279,7 @@ ImGuiIO::ImGuiIO()
|
||||
IniFilename = "imgui.ini";
|
||||
LogFilename = "imgui_log.txt";
|
||||
Font = NULL;
|
||||
FontYOffset = 0.0f;
|
||||
FontTexUvForWhite = ImVec2(0.0f,0.0f);
|
||||
FontAllowScaling = false;
|
||||
PixelCenterOffset = 0.0f;
|
||||
@ -1199,6 +1200,7 @@ void NewFrame()
|
||||
ImGui::GetDefaultFontData(&fnt_data, &fnt_size, NULL, NULL);
|
||||
g.IO.Font = new ImBitmapFont();
|
||||
g.IO.Font->LoadFromMemory(fnt_data, fnt_size);
|
||||
g.IO.FontYOffset = +1;
|
||||
}
|
||||
g.Initialized = true;
|
||||
}
|
||||
@ -5093,6 +5095,8 @@ void ImBitmapFont::Clear()
|
||||
|
||||
bool ImBitmapFont::LoadFromFile(const char* filename)
|
||||
{
|
||||
IM_ASSERT(!IsLoaded()); // Call Clear()
|
||||
|
||||
// Load file
|
||||
FILE* f;
|
||||
if ((f = fopen(filename, "rb")) == NULL)
|
||||
@ -5123,6 +5127,8 @@ bool ImBitmapFont::LoadFromFile(const char* filename)
|
||||
|
||||
bool ImBitmapFont::LoadFromMemory(const void* data, size_t data_size)
|
||||
{
|
||||
IM_ASSERT(!IsLoaded()); // Call Clear()
|
||||
|
||||
Data = (unsigned char*)data;
|
||||
DataSize = data_size;
|
||||
|
||||
@ -5262,7 +5268,7 @@ void ImBitmapFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& c
|
||||
|
||||
// Align to be pixel perfect
|
||||
pos.x = (float)(int)pos.x;
|
||||
pos.y = (float)(int)pos.y;
|
||||
pos.y = (float)(int)pos.y + GImGui.IO.FontYOffset;
|
||||
|
||||
const ImVec4 clip_rect = clip_rect_ref;
|
||||
|
||||
|
1
imgui.h
1
imgui.h
@ -391,6 +391,7 @@ struct ImGuiIO
|
||||
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
||||
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
||||
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
|
||||
float FontYOffset; // = 0.0f // Offset font rendering by xx pixels in Y axis.
|
||||
ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
|
||||
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
||||
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
|
||||
|
Loading…
Reference in New Issue
Block a user