cohtml::System
A System owns multiple Views. These Views share resources among them. It is usually enough to have just one System per application run. All System APIs, unless explicitly stated otherwise, can be called on any thread, but should not be used on multiple threads simultaneously.
#include <System.h>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| virtual unsigned | GetId() =0 |
| virtual void | SetId(unsigned id) =0 |
| virtual | ~System() |
| virtual View * | CreateView(const ViewSettings & settings) =0 Creates a new View with the specified options. |
| virtual View * | CreateView() =0 Creates a new View with default options. |
| virtual SystemCacheStats * | GetSystemCacheStats() const =0 Returns an objects that holds the current statistics of the system-wide caches. Remember to Release when done. |
| virtual void | ClearCachedUnusedImages() =0 Removes all unused images (raster and svg) from internal caches. |
| virtual SystemRenderer * | CreateSystemRenderer(const SystemRendererSettings & settings) =0 Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread. |
| virtual SystemRenderer * | CreateSystemRenderer() =0 Creates a new SystemRenderer with default settings. |
| virtual SystemRenderer * | CreateSystemRendererWithExternalRenderingLibrary(const SystemRendererSettingsWithExternalRenderingLibrary & settings) =0 Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread. |
| virtual void | RegisterFont(const char * url, const FontDescription & desc =FontDescription(), Fonts::FontSDF useSDF =Fonts::SDF_Auto) =0 Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection). |
| virtual bool | UnregisterFont(const char * url) =0 Unregisters all registered fonts by the RegisterFont API for a specific font resource identified by the URL. Font resources are shared between the system and the views, so the font resource may not be freed if there are active at font-face rules using the same URL. Since the font resource is required for rendering, fonts will be freed after all pending frames are painted. |
| virtual void | AddUserFont(const char ** imagesData, unsigned * imagesDataSize, unsigned imagesCount, const UserFontDescription & description) =0 Load the user font using image files. |
| virtual void | AddUserFont(const IAsyncResourceResponse::UserImageData * userImages, unsigned imagesCount, const UserFontDescription & description) =0 Load the user font using preloaded images. |
| virtual bool | RemoveUserFont(const UserFontDescription & description) =0 Unregisters the bitmap font which has been registered by the user. |
| virtual void | Destroy() =0 Destroys the System. |
| virtual void | Advance(TimePoint timeMilliseconds) =0 Advances the internal timers and inspector when available. |
| virtual void | RegisterGamepad(unsigned id, const char * info, unsigned axesCount, unsigned buttonsCount, void * reserved =nullptr) =0 Registers a new gamepad. All views will receive the gamepadconnected event. You can provide any number of axes and buttons though the standard mapping according to the HTML spec has 4 axes and 17 buttons which can be found here https://w3c.github.io/gamepad/#remapping. |
| virtual void | UnregisterGamepad(unsigned id) =0 Unregisters a gamepad. All views will receive the gamepaddisconnected event. |
| virtual void | UpdateGamepadState(const cohtml::GamepadState & state) =0 Updates the state of a single gamepad. |
| virtual void | UpdateGamepadStateExtended(const cohtml::GamepadStateExtended & state) =0 Updates the state of a single gamepad with motion tracking information. |
| virtual void | UserImagesChanged(const unsigned * images, unsigned count) =0 Trigger repaint of a user provided texture. Call this whenever the image is changed by logic external to the library. Make sure to have ImageHandle set for such images. |
| virtual void | PreloadAndCacheStylesheet(const char * url) =0 Schedules a preload task for a given stylesheet and caches it upon successful parsing. |
| virtual bool | RemoveStylesheetCacheEntry(const char * url) =0 Clears data for a given stylesheet from the cache. |
| virtual void | ClearStylesheetCache() =0 Clears all preloaded stylesheet data from the cache. |
| virtual void | PreloadAndCacheHTML(const char * url) =0 Schedules a preload task for a given HTML, parses it, and caches it. |
| virtual bool | RemoveHTMLCacheEntry(const char * url) =0 Clears data for a given HTML from the cache. |
| virtual void | ClearHTMLCache() =0 Clears all preloaded HTML data from the cache. |
Public Functions Documentation
Section titled “Public Functions Documentation”function GetId
Section titled “function GetId”virtual unsigned GetId() =0function SetId
Section titled “function SetId”virtual void SetId( unsigned id) =0function ~System
Section titled “function ~System”virtual ~System()function CreateView
Section titled “function CreateView”virtual View * CreateView( const ViewSettings & settings) =0Creates a new View with the specified options.
function CreateView
Section titled “function CreateView”virtual View * CreateView() =0Creates a new View with default options.
function GetSystemCacheStats
Section titled “function GetSystemCacheStats”virtual SystemCacheStats * GetSystemCacheStats() const =0Returns an objects that holds the current statistics of the system-wide caches. Remember to Release when done.
Note: Waits for style solving generated from previous Advance. Avoid calling it too early.
function ClearCachedUnusedImages
Section titled “function ClearCachedUnusedImages”virtual void ClearCachedUnusedImages() =0Removes all unused images (raster and svg) from internal caches.
Note: Images must be unused (orphaned) for them to be cleared. If you want to force ALL images to be unloaded you need for first call View::UnloadDocument to remove any references the DOM might still hold to the images.
function CreateSystemRenderer
Section titled “function CreateSystemRenderer”virtual SystemRenderer * CreateSystemRenderer( const SystemRendererSettings & settings) =0Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread.
function CreateSystemRenderer
Section titled “function CreateSystemRenderer”virtual SystemRenderer * CreateSystemRenderer() =0Creates a new SystemRenderer with default settings.
function CreateSystemRendererWithExternalRenderingLibrary
Section titled “function CreateSystemRendererWithExternalRenderingLibrary”virtual SystemRenderer * CreateSystemRendererWithExternalRenderingLibrary( const SystemRendererSettingsWithExternalRenderingLibrary & settings) =0Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread.
See: cohtml::Library::InitializeWithRenderingLibrary
Note: Use this version when the Library is initialized with an external rendering library.
function RegisterFont
Section titled “function RegisterFont”virtual void RegisterFont( const char * url, const FontDescription & desc =FontDescription(), Fonts::FontSDF useSDF =Fonts::SDF_Auto) =0Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection).
Parameters:
- url URL for the font to be loaded. Must be a valid URL. Spaces aren’t allowed.
- desc The description of the font to be loaded
- useSDF Controls the method used when rendering fonts, same as the coh-font-sdf font-face property SDF reduces memory consumption but finer font details are lost. If you experience a loss of detail in font rendering, try turning SDF off.
Note: Waits for style solving generated from previous Advance. Avoid calling it too early.
function UnregisterFont
Section titled “function UnregisterFont”virtual bool UnregisterFont( const char * url) =0Unregisters all registered fonts by the RegisterFont API for a specific font resource identified by the URL. Font resources are shared between the system and the views, so the font resource may not be freed if there are active at font-face rules using the same URL. Since the font resource is required for rendering, fonts will be freed after all pending frames are painted.
Parameters:
- url URL identifying the font resource. Must be a valid URL. Spaces aren’t allowed.
Return: true, if the font was unregistered successfully and false otherwise.
Note: Waits for style solving generated from previous Advance. Avoid calling it too early.
function AddUserFont
Section titled “function AddUserFont”virtual void AddUserFont( const char ** imagesData, unsigned * imagesDataSize, unsigned imagesCount, const UserFontDescription & description) =0Load the user font using image files.
Parameters:
- imagesData pointer to image files data.
- imagesDataSize pointer to size of the image files.
- imagesCount number of images
- description Description of the bitmap font.
Note:
- The memory can be freed immediately after the call
- Images must have the appropriate number of channels Bitmap: 1-channel(A) texture MSDF: 3-channel(RGB) texture
- Waits for style solving generated from previous Advance. Avoid calling it too early.
function AddUserFont
Section titled “function AddUserFont”virtual void AddUserFont( const IAsyncResourceResponse::UserImageData * userImages, unsigned imagesCount, const UserFontDescription & description) =0Load the user font using preloaded images.
Parameters:
- userImages pointer to UserImageData structs describing the images.
- imagesCount number of images
- description Description of the bitmap font.
Note:
- After freeing the rendering resources you can call this method again in order to provide new images for the same bitmap font description.
- The memory can be freed immediately after the call
- Images must have the appropriate number of channels Bitmap: 1-channel(A) texture MSDF: 3-channel(RGB) texture
- Waits for style solving generated from previous Advance. Avoid calling it too early.
function RemoveUserFont
Section titled “function RemoveUserFont”virtual bool RemoveUserFont( const UserFontDescription & description) =0Unregisters the bitmap font which has been registered by the user.
Parameters:
- description Description of the bitmap font.
Return: true, if the font was unregistered successfully and false otherwise.
Note: Waits for style solving generated from previous Advance. Avoid calling it too early.
function Destroy
Section titled “function Destroy”virtual void Destroy() =0Destroys the System.
function Advance
Section titled “function Advance”virtual void Advance( TimePoint timeMilliseconds) =0Advances the internal timers and inspector when available.
function RegisterGamepad
Section titled “function RegisterGamepad”virtual void RegisterGamepad( unsigned id, const char * info, unsigned axesCount, unsigned buttonsCount, void * reserved =nullptr) =0Registers a new gamepad. All views will receive the gamepadconnected event. You can provide any number of axes and buttons though the standard mapping according to the HTML spec has 4 axes and 17 buttons which can be found here https://w3c.github.io/gamepad/#remapping.
Parameters:
- id the unique identifier for the gamepad
- info general information for the gamepad such as producer and model
- axesCount the number of analog axes the gamepad has
- buttonsCount the number of buttons the gamepad has
- reserved reserved parameter. Set to nullptr
function UnregisterGamepad
Section titled “function UnregisterGamepad”virtual void UnregisterGamepad( unsigned id) =0Unregisters a gamepad. All views will receive the gamepaddisconnected event.
Parameters:
- id the id of the gamepad to unregister
function UpdateGamepadState
Section titled “function UpdateGamepadState”virtual void UpdateGamepadState( const cohtml::GamepadState & state) =0Updates the state of a single gamepad.
Parameters:
- state new state of the gamepad
Note: All gamepad-related methods are system-wise. All views will get the new state.
function UpdateGamepadStateExtended
Section titled “function UpdateGamepadStateExtended”virtual void UpdateGamepadStateExtended( const cohtml::GamepadStateExtended & state) =0Updates the state of a single gamepad with motion tracking information.
Parameters:
- state new state of the gamepad
Note:
- All gamepad-related methods are system-wise. All views will get the new state.
- If you do not require motion tracking, use System::UpdateGamepadState
function UserImagesChanged
Section titled “function UserImagesChanged”virtual void UserImagesChanged( const unsigned * images, unsigned count) =0Trigger repaint of a user provided texture. Call this whenever the image is changed by logic external to the library. Make sure to have ImageHandle set for such images.
Parameters:
- images array of image handles - id-s of the user provided images that are changed
- count the number of changed images
function PreloadAndCacheStylesheet
Section titled “function PreloadAndCacheStylesheet”virtual void PreloadAndCacheStylesheet( const char * url) =0Schedules a preload task for a given stylesheet and caches it upon successful parsing.
Parameters:
- url A URL for the stylesheet to be preloaded and cached. Must be a valid URL. Spaces aren’t allowed.
Note: The stylesheet cache is shared among all views
function RemoveStylesheetCacheEntry
Section titled “function RemoveStylesheetCacheEntry”virtual bool RemoveStylesheetCacheEntry( const char * url) =0Clears data for a given stylesheet from the cache.
Parameters:
- url The URL for the stylesheet to be cleared from cache. Must be the same URL used for its preloading.
Return: true, if the cache entry corresponding to the given URL was found and cleared successfully
Note:
- If a stylesheet that is currently in use by a view is cleared, it won’t affect the view
- but a resource request will be fired the next time it is needed
function ClearStylesheetCache
Section titled “function ClearStylesheetCache”virtual void ClearStylesheetCache() =0Clears all preloaded stylesheet data from the cache.
Note:
- If a stylesheet that is currently in use by a view is cleared, it won’t affect the view
- but a resource request will be fired the next time it is needed
function PreloadAndCacheHTML
Section titled “function PreloadAndCacheHTML”virtual void PreloadAndCacheHTML( const char * url) =0Schedules a preload task for a given HTML, parses it, and caches it.
Parameters:
- url A URL for the HTML to be preloaded and cached. Must be a valid absolute URL. Spaces aren’t allowed.
Note: The HTML cache is shared among all views
function RemoveHTMLCacheEntry
Section titled “function RemoveHTMLCacheEntry”virtual bool RemoveHTMLCacheEntry( const char * url) =0Clears data for a given HTML from the cache.
Parameters:
- url The URL for the HTML to be cleared from the cache. Must be the same URL used for its preloading.
Return: true, if the cache entry corresponding to the given URL was found and cleared successfully
Note:
- Removing HTML from cache that is currently in use by a view won’t free HTML data immediately,
- data will be freed after the View finishes DOM building, even if the HTML is not loaded yet.
function ClearHTMLCache
Section titled “function ClearHTMLCache”virtual void ClearHTMLCache() =0Clears all preloaded HTML data from the cache.
Note:
- Removing HTML from cache that is currently in use by a view won’t free HTML data immediately,
- data will be freed after the View finishes DOM building, even if the HTML is not loaded yet.
© 2026 Coherent Labs. All rights reserved.