encre_css/plugins/typography/font_smoothing/
mod.rs1#![doc = include_str!("README.md")]
2#![doc(alias = "typography")]
3use crate::prelude::build_plugin::*;
4
5#[derive(Debug)]
6pub(crate) struct PluginDefinition;
7
8impl Plugin for PluginDefinition {
9 fn can_handle(&self, context: ContextCanHandle) -> bool {
10 matches!(
11 context.modifier,
12 Modifier::Builtin {
13 value: "antialised" | "subpixel-antialised",
14 ..
15 }
16 )
17 }
18
19 fn handle(&self, context: &mut ContextHandle) {
20 if let Modifier::Builtin { value, .. } = context.modifier {
21 match *value {
22 "antialised" => {
23 context.buffer.lines([
24 "-webkit-font-smoothing: antialiased;",
25 "-moz-osx-font-smoothing: grayscale;",
26 ]);
27 }
28 "subpixel-antialised" => {
29 context.buffer.lines([
30 "-webkit-font-smoothing: auto;",
31 "-moz-osx-font-smoothing: auto;",
32 ]);
33 }
34 _ => unreachable!(),
35 }
36 }
37 }
38}