42 lines
No EOL
10 KiB
HTML
42 lines
No EOL
10 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The `Fallback` trait allows for configurable font fallback lists to be set during construction of the `FontSystem`."><title>Fallback in cosmic::iced::daemon::program::graphics::text::cosmic_text - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../../../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../../../../../static.files/rustdoc-aa0817cf.css"><meta name="rustdoc-vars" data-root-path="../../../../../../../" data-static-root-path="../../../../../../../static.files/" data-current-crate="cosmic" data-themes="" data-resource-suffix="" data-rustdoc-version="1.90.0-nightly (3048886e5 2025-07-30)" data-channel="nightly" data-search-js="search-fa3e91e5.js" data-settings-js="settings-5514c975.js" ><script src="../../../../../../../static.files/storage-68b7e25d.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../../../../../static.files/main-eebb9057.js"></script><noscript><link rel="stylesheet" href="../../../../../../../static.files/noscript-32bb7600.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../../../../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../../../../../cosmic/index.html">cosmic</a><span class="version">1.0.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Fallback</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.common_fallback" title="common_fallback">common_fallback</a></li><li><a href="#tymethod.forbidden_fallback" title="forbidden_fallback">forbidden_fallback</a></li><li><a href="#tymethod.script_fallback" title="script_fallback">script_fallback</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In cosmic::<wbr>iced::<wbr>daemon::<wbr>program::<wbr>graphics::<wbr>text::<wbr>cosmic_<wbr>text</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../../../../../index.html">cosmic</a>::<wbr><a href="../../../../../index.html">iced</a>::<wbr><a href="../../../../index.html">daemon</a>::<wbr><a href="../../../index.html">program</a>::<wbr><a href="../../index.html">graphics</a>::<wbr><a href="../index.html">text</a>::<wbr><a href="index.html">cosmic_text</a></div><h1>Trait <span class="trait">Fallback</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub trait Fallback: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> {
|
||
// Required methods
|
||
fn <a href="#tymethod.common_fallback" class="fn">common_fallback</a>(&self) -> &[&'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>];
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.forbidden_fallback" class="fn">forbidden_fallback</a>(&self) -> &[&'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>];
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.script_fallback" class="fn">script_fallback</a>(&self, script: Script, locale: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> &[&'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>];
|
||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The <code>Fallback</code> trait allows for configurable font fallback lists to be set during construction of the <a href="struct.FontSystem.html" title="struct cosmic::iced::daemon::program::graphics::text::cosmic_text::FontSystem"><code>FontSystem</code></a>.</p>
|
||
<p>A custom fallback list can be added via the <a href="struct.FontSystem.html#method.new_with_locale_and_db_and_fallback" title="associated function cosmic::iced::daemon::program::graphics::text::cosmic_text::FontSystem::new_with_locale_and_db_and_fallback"><code>FontSystem::new_with_locale_and_db_and_fallback</code></a> constructor.</p>
|
||
<p>A default implementation is provided by the <a href="struct.PlatformFallback.html" title="struct cosmic::iced::daemon::program::graphics::text::cosmic_text::PlatformFallback"><code>PlatformFallback</code></a> struct, which encapsulates the target platform’s pre-configured fallback lists.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>MyFallback;
|
||
<span class="kw">impl </span>Fallback <span class="kw">for </span>MyFallback {
|
||
<span class="kw">fn </span>common_fallback(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="kw-2">&</span>[<span class="kw-2">&</span><span class="lifetime">'static </span>str] {
|
||
<span class="kw-2">&</span>[
|
||
<span class="string">"Segoe UI"</span>,
|
||
<span class="string">"Segoe UI Emoji"</span>,
|
||
<span class="string">"Segoe UI Symbol"</span>,
|
||
<span class="string">"Segoe UI Historic"</span>,
|
||
]
|
||
}
|
||
|
||
<span class="kw">fn </span>forbidden_fallback(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="kw-2">&</span>[<span class="kw-2">&</span><span class="lifetime">'static </span>str] {
|
||
<span class="kw-2">&</span>[]
|
||
}
|
||
|
||
<span class="kw">fn </span>script_fallback(<span class="kw-2">&</span><span class="self">self</span>, script: Script, locale: <span class="kw-2">&</span>str) -> <span class="kw-2">&</span>[<span class="kw-2">&</span><span class="lifetime">'static </span>str] {
|
||
<span class="kw">match </span>script {
|
||
Script::Adlam => <span class="kw-2">&</span>[<span class="string">"Ebrima"</span>],
|
||
Script::Bengali => <span class="kw-2">&</span>[<span class="string">"Nirmala UI"</span>],
|
||
Script::Canadian_Aboriginal => <span class="kw-2">&</span>[<span class="string">"Gadugi"</span>],
|
||
<span class="comment">// ...
|
||
</span><span class="kw">_ </span>=> <span class="kw-2">&</span>[],
|
||
}
|
||
}
|
||
}
|
||
|
||
<span class="kw">let </span>locale = <span class="string">"en-US"</span>.to_string();
|
||
<span class="kw">let </span>db = fontdb::Database::new();
|
||
<span class="kw">let </span>font_system = FontSystem::new_with_locale_and_db_and_fallback(locale, db, MyFallback);</code></pre></div>
|
||
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.common_fallback" class="method"><h4 class="code-header">fn <a href="#tymethod.common_fallback" class="fn">common_fallback</a>(&self) -> &[&'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>]</h4></section></summary><div class="docblock"><p>Fallbacks to use after any script specific fallbacks</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.forbidden_fallback" class="method"><h4 class="code-header">fn <a href="#tymethod.forbidden_fallback" class="fn">forbidden_fallback</a>(&self) -> &[&'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>]</h4></section></summary><div class="docblock"><p>Fallbacks to never use</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.script_fallback" class="method"><h4 class="code-header">fn <a href="#tymethod.script_fallback" class="fn">script_fallback</a>(&self, script: Script, locale: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> &[&'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>]</h4></section></summary><div class="docblock"><p>Fallbacks to use per script</p>
|
||
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Fallback-for-PlatformFallback" class="impl"><a href="#impl-Fallback-for-PlatformFallback" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Fallback.html" title="trait cosmic::iced::daemon::program::graphics::text::cosmic_text::Fallback">Fallback</a> for <a class="struct" href="struct.PlatformFallback.html" title="struct cosmic::iced::daemon::program::graphics::text::cosmic_text::PlatformFallback">PlatformFallback</a></h3></section></div><script src="../../../../../../../trait.impl/cosmic_text/font/fallback/trait.Fallback.js" data-ignore-extern-crates="cosmic_text" async></script></section></div></main></body></html> |