8 Commits

Author SHA1 Message Date
dskuza
a629422a34 Support supplying mobile fallback fonts by style with caching
This pull request builds on top of fallback font support on iOS by including the ability to provide fallback fonts based on the styling of the missing character. Currently, the style information only contains weight. This weight is grabbed by calling `getAxisValue`. According to Luigi, this is a linear search, so perhaps there's room for a performance optimization later on.

There is one lower-level C++ change: `gFallbackProc` returns the font for the missing character, in addition _to_ the missing character (as a second parameter). This font will be used to generate the requested styling within the iOS runtime.

This adds a new class property to `RiveFont`: `fallbackFontCallback` (whose name I'm open to changing). This is a block (i.e closure) that will be called when a fallback font is requested. It supplies the styling of the missing character so that, for example, different fonts can be used based on the weight of the missing character. For example usage, see `SwiftFallbackFonts.swift`. This provider is what's used under-the-hood, and utilizes the pre-existing `fallbackFonts` class property

The "trickiest" bit here is the caching. NSDictionary requires equatable / hashable types as keys, and we want to minimize additional generation of a Rive font, so we cache any used fonts in a wrapper type, used as the value. When new fallback fonts are provided, either directly or when a new provider block is set, the cache will be reset. Once the weight is determined, generating the right key is as simple as calling the right initializer, and when set, generating the right value is simple as calling the right initializer with the created Rive font.

Finally, `RiveFactory` was getting a little bloated, so I did a little file cleanup.

This pull requests also includes Android support from #8621

Diffs=
7986d64d83 Support supplying mobile fallback fonts by style with caching (#8396)

Co-authored-by: David Skuza <david@rive.app>
Co-authored-by: Umberto <usonnino@gmail.com>
Co-authored-by: Umberto Sonnino <umberto@rive.app>
2024-11-27 16:50:58 +00:00
luigi-rosso
118b04085a DrawImage for Tess Renderer
drawImage (without a Rive provided mesh) wasn't implemented in Tess. For now this just builds a tiny vertex buffer when it uploads the image.

I'll rework this when I add batching to this renderer (the vertex buffer will only be generated on demand and placed into the batched vertex buffer for the whole frame/artboard depending on where we'll create the batching boundary)

Diffs=
c9f97f7c1 DrawImage for Tess Renderer
2022-08-24 02:30:59 +00:00
luigi-rosso
f17eb06604 Multi backend viewer
Re-works viewer to use GL, Metal, and optionally in the future D3D. Also introduces a new renderer and allows the viewer to be compiled with either Skia or the new example Tess renderer (with either GL or Metal).

I want to re-work the dependency building to be more similar to what Mike did with the third_party directory in a separate PR. It's pretty similar to what's been done here, but generalized at the top level which I think is nice and more re-usable. Also removes the need for some of my path building shell scripts...

There's a new README.md in the viewer directory with some details.

```
cd packages/runtime/viewer/build/macosx
```

Build and run with a Metal backed Skia Renderer:
```
./build_viewer.sh metal skia run
```

Build and run with a GL backed Skia Renderer:
```
./build_viewer.sh gl skia run
```

Build and run with a Metal backed Tess Renderer:
```
./build_viewer.sh metal tess run
```

... and so on

You can also clean directly from the same command:
```
./build_viewer.sh metal tess run clean
```

Diffs=
86d5b0924 Cleanup skia build
83506229a Fix skia dir.
7d4a3bdcf Remove tess to simplify PR.
14346ad9e Nuke old viewer
fba2696cf See clang-format after update
15b8fd753 Remove mat4 test from main rive project
69a2ce9ad Render font cleanup
abd8fa89b Missed files.
e690870a4 Move shader.h and remove formatting for generated files.
afc437b17 Tweaks for failed tests.
2f9a936fc Moving mat4 to tess renderer.
27a3606d6 Cleanup
a4034ff0f Adding viewer readme
bebcd8abe Adding text viewers.
5a1da4ed2 Getting image rendering working in with tess
2c81fee81 Silence deprecation warning.
52f410dfc Getting mesh rendering working.
8de842c7f Starting to use sokol to render meshes. Adding Mat4 class.
dbd5c79b5 Updating clang format for objc
ca0ea9d84 Getting image content working too and fixing contention with sokol
79405a77d Starting to add handle draw support.
8b9f14a16 Adding gl renderer for skia.
af23274ae Adding support for rendering Skia with Metal.
92139ce08 Adding tess renderer.
dc3e1b49b Adding dependencies at top level
22fa8e6ce Updating build scripts
b5cb990aa Merging with latest master.
d08ac18e2 Reorg
a828e92da Updating project json
086890736 Cleanup unused glfw and gl3w for new viewer
55161f36c Using sokol.
72b62b563 Separating GL and TessRenderer.
611b991b6 Adding limits import to fix compilation on all platforms.
820ab8e2f Missed build files.
0964b4416 Stubbing out a generalized viewer and alternate renderer.
2022-07-16 04:21:44 +00:00
Luigi Rosso
0c4e80da46 Starting to process events in state machine instance. 2022-04-25 12:07:55 -04:00
Luigi Rosso
5d0e8d045f Adding more docs and utility tasks. 2021-05-01 18:10:33 -07:00
Maxwell Talbot
cfcbaac302 updated gitignore to include ffmpeg and h264 2021-02-25 09:40:28 +00:00
Luigi Rosso
c7d5976630 Getting bones working (better) with C++ runtimes. 2020-08-27 18:50:41 -07:00
Luigi Rosso
20c629987c Getting more of the file loading working. Backboard, Artboards, Objects, and Animations are now loading. Animation properties are next. 2020-07-11 18:03:52 -07:00