-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
40 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package crt | ||
|
||
import ( | ||
"github.com/hajimehoshi/ebiten/v2" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
// DeviceScale returns the current device scale factor. | ||
// | ||
// If the environment variable CRT_DEVICE_SCALE is set, it will be used instead. | ||
func DeviceScale() float64 { | ||
if os.Getenv("CRT_DEVICE_SCALE") != "" { | ||
s, err := strconv.ParseFloat(os.Getenv("CRT_DEVICE_SCALE"), 64) | ||
if err == nil { | ||
return s | ||
} | ||
} | ||
|
||
return ebiten.DeviceScaleFactor() | ||
} | ||
|
||
// GetFontDPI returns the recommended font DPI for the current device. | ||
func GetFontDPI() float64 { | ||
return 72.0 * DeviceScale() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters