1#![cfg_attr(not(feature = "std"), no_std)]
9#![forbid(unsafe_code)]
12#![warn(missing_docs)]
13#![allow(non_camel_case_types)]
14#![allow(non_upper_case_globals)]
15#![allow(non_snake_case)]
16#![allow(clippy::collapsible_if)]
17#![allow(clippy::collapsible_else_if)]
18#![allow(clippy::comparison_chain)]
19#![allow(clippy::needless_range_loop)]
20#![allow(clippy::non_canonical_partial_ord_impl)]
21#![allow(clippy::upper_case_acronyms)]
22#![allow(clippy::too_many_arguments)]
23#![allow(clippy::wildcard_in_or_patterns)]
24#![allow(clippy::identity_op)]
25#![allow(clippy::inline_always)]
26#![allow(clippy::mut_range_bound)]
27#![allow(clippy::enum_variant_names)]
28#![allow(clippy::manual_range_patterns)]
29#![allow(clippy::type_complexity)]
30#![allow(clippy::wrong_self_convention)]
31#![allow(clippy::match_like_matches_macro)]
32#![allow(clippy::manual_range_contains)]
33
34extern crate alloc;
35
36mod algs;
37mod budget;
38pub mod unicode;
39#[macro_use]
40mod buffer;
41mod aat;
42mod cache;
43mod direction;
44mod error;
45pub(crate) mod fallback;
46mod feature;
47mod hint;
48mod language;
49pub(crate) mod normalize;
50mod once;
51mod options;
52pub(crate) mod ot;
53mod parse_setting;
54mod plan;
55pub(crate) mod planner;
56mod scale;
57mod script;
58pub(crate) mod set_digest;
59mod shape;
60mod shaper_font;
61mod tag;
62mod tag_reverse;
63#[allow(clippy::collapsible_match)]
64mod tag_table;
65mod text_parser;
66
67type Mask = u32;
68
69#[inline(always)]
70fn clamp_i64_to_i32(value: i64) -> i32 {
71 value.clamp(i64::from(i32::MIN), i64::from(i32::MAX)) as i32
72}
73
74pub(crate) type U32Set = read_fonts::collections::int_set::U32Set;
75
76pub use error::ShapeError;
77pub use options::ShapeOptions;
78#[doc(hidden)]
79pub use parse_setting::ParseSetting;
80pub use plan::{ShapePlan, ShapePlanKey};
81pub(crate) use planner::ShapePlanner;
82pub use scale::Scale;
83pub use shape::shape;
84pub(crate) use shaper_font::LayoutData;
85
86#[cfg(feature = "tracing")]
87pub use buffer::MessageFunction;
88pub use buffer::{Buffer, ContentType, GlyphFlags, GlyphInfo, GlyphPosition};
89pub use direction::Direction;
90pub use feature::Feature;
91pub use language::Language;
92pub use script::Script;
93pub use shaper_font::{
94 Advances, FontFuncs, GlyphExtents, NominalGlyphs, RawAdvances, RawNominalGlyphs, ShaperFont,
95};
96pub use tag::{LanguageTags, ScriptTags};
97
98pub mod font {
100 pub use read_fonts::model::*;
101}
102
103#[doc(inline)]
104pub use font::Font;
105
106pub use read_fonts::types::{GlyphId, Tag};
107
108bitflags::bitflags! {
115 #[derive(Default, Debug, Clone, Copy)]
117 pub struct BufferFlags: u32 {
118 const BEGINNING_OF_TEXT = 0x0000_0001;
123 const END_OF_TEXT = 0x0000_0002;
127 const PRESERVE_DEFAULT_IGNORABLES = 0x0000_0004;
133 const REMOVE_DEFAULT_IGNORABLES = 0x0000_0008;
137 const DO_NOT_INSERT_DOTTED_CIRCLE = 0x0000_0010;
139 const VERIFY = 0x0000_0020;
143 const PRODUCE_UNSAFE_TO_CONCAT = 0x0000_0040;
147 const PRODUCE_SAFE_TO_INSERT_TATWEEL = 0x0000_0080;
149 const DEFINED = 0x0000_00FF;
151 }
152}
153
154#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
159pub enum ClusterLevel {
160 MonotoneGraphemes,
162 MonotoneCharacters,
164 Characters,
166 Graphemes,
168}
169
170impl ClusterLevel {
171 #[inline]
172 fn new(level: u32) -> Self {
173 match level {
174 0 => Self::MonotoneGraphemes,
175 1 => Self::MonotoneCharacters,
176 2 => Self::Characters,
177 3 => Self::Graphemes,
178 _ => Self::MonotoneGraphemes,
179 }
180 }
181 #[inline]
182 fn is_monotone(self) -> bool {
183 matches!(self, Self::MonotoneGraphemes | Self::MonotoneCharacters)
184 }
185 #[inline]
186 fn is_graphemes(self) -> bool {
187 matches!(self, Self::MonotoneGraphemes | Self::Graphemes)
188 }
189 #[inline]
190 fn _is_characters(self) -> bool {
191 matches!(self, Self::MonotoneCharacters | Self::Characters)
192 }
193}
194
195impl Default for ClusterLevel {
196 #[inline]
197 fn default() -> Self {
198 ClusterLevel::MonotoneGraphemes
199 }
200}
201
202bitflags::bitflags! {
203 #[derive(Default)]
205 pub struct SerializeFlags: u8 {
206 const NO_CLUSTERS = 0b0000_0001;
208 const NO_POSITIONS = 0b0000_0010;
210 const NO_GLYPH_NAMES = 0b0000_0100;
212 const GLYPH_EXTENTS = 0b0000_1000;
214 const GLYPH_FLAGS = 0b0001_0000;
216 const NO_ADVANCES = 0b0010_0000;
218 const DEFINED = 0b0011_1111;
220 }
221}