Class FontSourceCache
Cache that stores loaded font bytes keyed by Mapsui.Styles.FontSource.SourceId. It implements IFetchableSource so that the DataFetcher automatically populates it when the viewport changes, including during RefreshDataAsync(Viewport?). Accessed via FontSourceCache.
Implements
Inherited Members
Namespace: Mapsui.Styles
Assembly: Mapsui.dll
Syntax
public sealed class FontSourceCache : IFetchableSource
Properties
| Edit this page View SourceId
The layer identifier.
Declaration
public int Id { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceClearCache()
Clears all cached font bytes and requests a new fetch cycle.
Declaration
public void ClearCache()
FetchAllFontDataAsync()
Fetch all font sources that have been declared but not yet loaded. This variant is currently only used in tests.
Declaration
public Task FetchAllFontDataAsync()
Returns
| Type | Description |
|---|---|
| Task |
Get(FontSource)
Get cached font bytes for the given FontSource, or null if not yet loaded.
Declaration
public byte[]? Get(FontSource fontSource)
Parameters
| Type | Name | Description |
|---|---|---|
| FontSource | fontSource |
Returns
| Type | Description |
|---|---|
| byte[] |
GetFetchJobs(int, int)
Gets the fetch requests for this layer. The requests are based on the viewport stored within the layer.
Declaration
public FetchJob[] GetFetchJobs(int activeFetchCount, int availableFetchSlots)
Parameters
| Type | Name | Description |
|---|---|---|
| int | activeFetchCount | Number of active fetches for this layer. It is relevant if the layer itself has a maximum on the number of active fetches for itself. |
| int | availableFetchSlots | Number of available fetch slots in the caller. It is the maximum number of fetch jobs the method should return. |
Returns
| Type | Description |
|---|---|
| FetchJob[] |
TryRegisterAsync(string, string)
Fetch and cache the bytes for a single font source. Returns false if it was already registered.
Declaration
public Task<bool> TryRegisterAsync(string sourceId, string source)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceId | |
| string | source |
Returns
| Type | Description |
|---|---|
| Task<bool> |
ViewportChanged(FetchInfo)
Informs the layer that the viewport has changed and it should update its data accordingly.
Declaration
public void ViewportChanged(FetchInfo fetchInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| FetchInfo | fetchInfo |
Events
| Edit this page View SourceFetchRequested
Indicates to the listener that it should fetch data again. This event is raised when there was a change in source data, so only relevant for dynamic data. The fetches triggered by viewport changes do not depend on it.
Declaration
public event EventHandler<FetchRequestedEventArgs>? FetchRequested
Event Type
| Type | Description |
|---|---|
| EventHandler<FetchRequestedEventArgs> |