maintain the initial font size in a global

Apps should keep the global updated when changing the font size.
This commit is contained in:
Kartik K. Agaram 2023-06-05 22:17:01 -07:00
parent 44e3cdcdb7
commit 7e160e0de5
2 changed files with 11 additions and 2 deletions

View File

@ -36,6 +36,8 @@ function App.initialize_globals()
-- blinking cursor
Cursor_time = 0
Font_height = 20
-- for hysteresis in a few places
Current_time = 0
Last_focus_time = 0 -- https://love2d.org/forums/viewtopic.php?p=249700
@ -112,8 +114,8 @@ function load_settings()
App.screen.move(settings.x, settings.y, settings.displayindex)
if on.load_settings then on.load_settings(settings.app) end
else
local font_height = 20
love.graphics.setFont(love.graphics.newFont(font_height))
Font_height = 20
love.graphics.setFont(love.graphics.newFont(Font_height))
local os = love.system.getOS()
if os == 'Android' or os == 'iOS' then
-- maximizing on iOS breaks text rendering: https://github.com/deltadaedalus/vudu/issues/7

View File

@ -21,6 +21,10 @@ two categories.
* `flags` -- some properties of the app window. See [`flags` in `love.graphics.getMode`](https://love2d.org/wiki/love.window.getMode)
for details.
* `Font_height` -- remembers the current font height on initialization. But
you're responsible for setting it when updating font height. (Think of this
as the body font, but apps so far assume a single font size.)
## Functions you can implement that will get automatically called
* `on.initialize(arg)` -- called when app starts up. Provides in `arg` an
@ -237,6 +241,9 @@ early warning if you break something.
this for the most part, just run it after loading or modifying
`state.lines`.
* `edit.update_font_height(state, font_height)` -- updates all state dependent
on font height.
If you need more precise control, look at the comment at the top of
`edit.initialize_state` in edit.lua. In brief, the widget contains an array of
`lines`. Positions in the buffer are described in _schema-1_ locations