diff options
Diffstat (limited to 'library/src/visualize')
| -rw-r--r-- | library/src/visualize/image.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/library/src/visualize/image.rs b/library/src/visualize/image.rs index 8a81a40e..3e4d1adb 100644 --- a/library/src/visualize/image.rs +++ b/library/src/visualize/image.rs @@ -3,7 +3,10 @@ use std::path::Path; use typst::image::{Image, ImageFormat, RasterFormat, VectorFormat}; -use crate::prelude::*; +use crate::{ + meta::{Figurable, LocalName}, + prelude::*, +}; /// A raster or vector graphic. /// @@ -22,7 +25,7 @@ use crate::prelude::*; /// /// Display: Image /// Category: visualize -#[element(Layout)] +#[element(Layout, LocalName, Figurable)] pub struct ImageElem { /// Path to an image file. #[required] @@ -112,6 +115,24 @@ impl Layout for ImageElem { } } +impl LocalName for ImageElem { + fn local_name(&self, lang: Lang) -> &'static str { + match lang { + Lang::CHINESE => "图", + Lang::GERMAN => "Abbildung", + Lang::ITALIAN | Lang::PORTUGUESE => "Figura", + Lang::RUSSIAN => "Рисунок", + Lang::ENGLISH | Lang::FRENCH | _ => "Figure", + } + } +} + +impl Figurable for ImageElem { + fn priority(&self, _styles: StyleChain) -> isize { + 1000 + } +} + /// How an image should adjust itself to a given area. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum ImageFit { |
