Add SetFontScaleMode(ImFontPtr, FontScaleMode) (#1666)

* Add SetFontScaleMode(ImFontPtr, FontScaleMode)

`IgnoreGlobalScale` was advertised as "excludes the given font from
global scaling", but the intent I had in mind was "excludes the given
font from being scaled in any manner". As the latter functionality is
needed, obsoleted `IgnoreGlobalScale` and added `SetFontScaleMode`.

* Make it correct

* Name consistency
This commit is contained in:
srkizer 2024-02-18 23:08:07 +09:00 committed by GitHub
parent 7dc99c9307
commit 2d8b71c647
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 166 additions and 66 deletions

View file

@ -342,9 +342,7 @@ public sealed class SingleFontChooserDialog : IDisposable
{
this.fontHandle ??= this.selectedFont.CreateFontHandle(
this.atlas,
tk =>
tk.OnPreBuild(e => e.IgnoreGlobalScale(e.Font))
.OnPostBuild(e => e.Font.AdjustGlyphMetrics(1f / e.Scale)));
tk => tk.OnPreBuild(e => e.SetFontScaleMode(e.Font, FontScaleMode.UndoGlobalScale)));
}
else
{
@ -837,7 +835,7 @@ public sealed class SingleFontChooserDialog : IDisposable
var changed = false;
if (!ImGui.BeginTable("##advancedOptions", 4))
return changed;
return false;
var labelWidth = ImGui.CalcTextSize("Letter Spacing:").X;
labelWidth = Math.Max(labelWidth, ImGui.CalcTextSize("Offset:").X);