using System; namespace MergeHub.Services { /// /// 코드 칸 글자 크기 하나에서 나오는 크기들(11차 F-5). 줄 높이 · 줄 번호 칸 · 여백 단추가 같은 비율로 따라간다. /// /// 기본 12 에서 지금까지의 값(줄 20 · 여백 66 = 번호 46 + 단추 20 · LOCAL 은 표식 6 + 번호 40 + 단추 20 · 단추 14 · 단추 글자 9)과 /// 정확히 같다. 네 칸이 모두 이 값을 쓰므로 어느 크기에서나 행이 같은 눈높이에 온다. /// /// 크기는 WPF 단위(1/96 인치)다. 모니터마다 Windows 배율은 플랫폼(PerMonitorV2)이 맞추므로 /// 한 값이 어느 모니터에서나 같은 눈 크기로 보인다(사용자 결정 "한 값을 모든 모니터에"). /// public sealed record CodeFontMetrics( double FontSize, double LineHeight, double GutterWidth, double NumberWidth, double NarrowNumberWidth, double MarkWidth, double ButtonWidth, double ButtonHeight, double ButtonFontSize) { public const double Default = 12; public const double Min = 8; public const double Max = 24; public static double Clamp(double size) => double.IsNaN(size) || size <= 0 ? Default : Math.Max(Min, Math.Min(Max, Math.Round(size))); /// 한 칸(1) 키우거나 줄인다. 끝에서는 그대로. public static double Step(double current, int delta) => Clamp(Math.Round(Clamp(current)) + delta); public static CodeFontMetrics For(double size) { var f = Clamp(size); var k = f / Default; var mark = Math.Round(6 * k); var narrow = Math.Round(40 * k); var button = Math.Round(20 * k); var number = mark + narrow; return new CodeFontMetrics( FontSize: f, LineHeight: Math.Round(20 * k), GutterWidth: number + button, NumberWidth: number, NarrowNumberWidth: narrow, MarkWidth: mark, ButtonWidth: button, ButtonHeight: Math.Round(14 * k), ButtonFontSize: Math.Round(9 * k, 1)); } } }