Represent a non-specified pixel size and font weight through a None option.
This is cleaner and has the added benefit that the backend can now
easily decide what the default size/weight should be.
For the GL backend a resolved font is just a handle (femtovg::FontId)
and we can cache that. Consequently we don't really need Rc<dyn Font>
but can let `fn font(...)` on the backend return a "resolved" font that
includes the pixel size, which in turn simplifies the Font trait
signatures.
The only caveat is that because on the item level we don't know what the
chosen backend type is, we can only receive a `dyn Font`, which means
it's wrapped - for now - in a Box.
* When calculating the height of text for vertical alignment purposes,
don't use the minimum height but stick to ascent + descent - like the old
renderer. This gives Text items a constant height that depends on the
font size and not the content.
* Avoid scaling text metrics twice. It turns out that femtovg uses the
device pixel ratio / dpi argument for `set_size` only for scaling text
metrics. Since we do all the mapping from logical pixels to physical pixels
it's correct to let femto only operate in physical pixel range. As a bonus
this allows removing the refresh_window_scale_factor() dance in the
backend (including making the context current, etc.)
Ensure the dpi on the canvas is up-to-date before/after rendering, as
measure_text etc. rely on it and it's otherwise initialized to 1 by
default. Unfortunately this requires jumping through some hoops, but
that can be fixed later in the canvas.
This means going back to an immutable renderer reference and interior
mutability for the canvas and the gpu cache. This is because while
traversing the item tree for rendering we may end up destroying
other items due to the lazyness of the models.
Don't require the caller to Box the closure. With the assumption that
the majority of callers *want* the closure to be boxed (i.e. it's not
already boxed), the API becomes easier to use.
Group all fields we need to determine a physical font into one FontRequest
structure and use that throughout.
That way adding more fields will require less changes.
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.
This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.
This also fixes the duplicate line edit focus in the 7gui cells
test case.