Skip to content

Commit

Permalink
reenable content scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Sep 18, 2023
1 parent 3328dc3 commit f1dfa87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 8 additions & 8 deletions FontAtlasProsessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ func (a *FontAtlas) rebuildFontAtlas() {
}

// Scale font size with DPI scale factor
// TODO
//if runtime.GOOS == windows {
// fontInfo.size *= Context.GetPlatform().GetContentScale()
//}
if runtime.GOOS == windows {
xScale, _ := Context.backend.ContentScale()
fontInfo.size *= xScale
}

if len(fontInfo.fontByte) == 0 {
fonts.AddFontFromFileTTFV(fontInfo.fontPath, fontInfo.size, fontConfig, ranges.Data())
Expand All @@ -309,10 +309,10 @@ func (a *FontAtlas) rebuildFontAtlas() {
// Add extra fonts
for _, fontInfo := range a.extraFonts {
// Scale font size with DPI scale factor
// TODO
//if runtime.GOOS == windows {
// fontInfo.size *= Context.GetPlatform().GetContentScale()
//}
if runtime.GOOS == windows {
xScale, _ := Context.backend.ContentScale()
fontInfo.size *= xScale
}

// Store imgui.Font for PushFont
var f *imgui.Font
Expand Down
8 changes: 5 additions & 3 deletions MasterWindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package giu
import (
"image"
"image/color"
"runtime"

imgui "github.com/AllenDang/cimgui-go"
"github.com/faiface/mainthread"
Expand Down Expand Up @@ -117,9 +118,10 @@ func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) *

func (w *MasterWindow) setTheme() (fin func()) {
// Scale DPI in windows
//if runtime.GOOS == "windows" {
// style.ScaleAllSizes(Context.GetPlatform().GetContentScale())
//}
if runtime.GOOS == "windows" {
xScale, _ := Context.backend.ContentScale()
imgui.CurrentStyle().ScaleAllSizes(xScale)
}

imgui.PushStyleVarFloat(imgui.StyleVarWindowRounding, 2)
imgui.PushStyleVarFloat(imgui.StyleVarFrameRounding, 4)
Expand Down

0 comments on commit f1dfa87

Please sign in to comment.