summaryrefslogtreecommitdiff
path: root/library/src/text
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-03 16:50:26 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-03 16:50:26 +0100
commit33928a00dc58250e24da1dae4e5db17e7b598d70 (patch)
tree451083aa64f57b442359875b0415541463cb1a0c /library/src/text
parent46921a8c283718402322d4d09c0bd1d9194278b1 (diff)
Tidy up library
Diffstat (limited to 'library/src/text')
-rw-r--r--library/src/text/deco.rs4
-rw-r--r--library/src/text/mod.rs14
-rw-r--r--library/src/text/quotes.rs4
-rw-r--r--library/src/text/shaping.rs8
-rw-r--r--library/src/text/shift.rs16
5 files changed, 23 insertions, 23 deletions
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs
index cd3acef5..aaf6cfa8 100644
--- a/library/src/text/deco.rs
+++ b/library/src/text/deco.rs
@@ -70,7 +70,7 @@ impl<const L: DecoLine> Show for DecoNode<L> {
///
/// For more details, see [`DecoNode`].
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
-pub struct Decoration {
+pub(super) struct Decoration {
pub line: DecoLine,
pub stroke: PartialStroke<Abs>,
pub offset: Smart<Abs>,
@@ -91,7 +91,7 @@ pub const STRIKETHROUGH: DecoLine = 1;
pub const OVERLINE: DecoLine = 2;
/// Add line decorations to a single run of shaped text.
-pub fn decorate(
+pub(super) fn decorate(
frame: &mut Frame,
deco: &Decoration,
text: &Text,
diff --git a/library/src/text/mod.rs b/library/src/text/mod.rs
index d793f614..61edacbe 100644
--- a/library/src/text/mod.rs
+++ b/library/src/text/mod.rs
@@ -11,7 +11,6 @@ mod shift;
pub use deco::*;
pub use link::*;
pub use par::*;
-pub use quotes::*;
pub use raw::*;
pub use shaping::*;
pub use shift::*;
@@ -22,6 +21,7 @@ use rustybuzz::Tag;
use typst::font::{FontMetrics, FontStretch, FontStyle, FontWeight, VerticalFontMetric};
use typst::util::EcoString;
+use self::quotes::*;
use crate::prelude::*;
/// A single run of text with the same style.
@@ -107,22 +107,22 @@ impl TextNode {
/// Whether the font weight should be increased by 300.
#[property(skip, fold)]
- pub const BOLD: Toggle = false;
+ pub(super) const BOLD: Toggle = false;
/// Whether the font style should be inverted.
#[property(skip, fold)]
- pub const ITALIC: Toggle = false;
+ pub(super) const ITALIC: Toggle = false;
/// A case transformation that should be applied to the text.
#[property(skip)]
- pub const CASE: Option<Case> = None;
+ pub(super) const CASE: Option<Case> = None;
/// Whether small capital glyphs should be used. ("smcp")
#[property(skip)]
- pub const SMALLCAPS: bool = false;
+ pub(super) const SMALLCAPS: bool = false;
/// A destination the text should be linked to.
#[property(skip, referenced)]
- pub const LINK: Option<Destination> = None;
+ pub(crate) const LINK: Option<Destination> = None;
/// Decorative lines.
#[property(skip, fold)]
- pub const DECO: Decoration = vec![];
+ pub(super) const DECO: Decoration = vec![];
fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> {
// The text constructor is special: It doesn't create a text node.
diff --git a/library/src/text/quotes.rs b/library/src/text/quotes.rs
index ab4d3f9d..af10de46 100644
--- a/library/src/text/quotes.rs
+++ b/library/src/text/quotes.rs
@@ -4,7 +4,7 @@ use super::{Lang, Region};
/// State machine for smart quote subtitution.
#[derive(Debug, Clone)]
-pub struct Quoter {
+pub(super) struct Quoter {
/// How many quotes have been opened.
quote_depth: usize,
/// Whether an opening quote might follow.
@@ -68,7 +68,7 @@ fn is_opening_bracket(c: char) -> bool {
}
/// Decides which quotes to subtitute smart quotes with.
-pub struct Quotes<'s> {
+pub(super) struct Quotes<'s> {
/// The opening single quote.
pub single_open: &'s str,
/// The closing single quote.
diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs
index 32143862..bab02eca 100644
--- a/library/src/text/shaping.rs
+++ b/library/src/text/shaping.rs
@@ -13,7 +13,7 @@ use crate::prelude::*;
/// This type contains owned or borrowed shaped text runs, which can be
/// measured, used to reshape substrings more quickly and converted into a
/// frame.
-pub struct ShapedText<'a> {
+pub(super) struct ShapedText<'a> {
/// The text that was shaped.
pub text: &'a str,
/// The text direction.
@@ -32,7 +32,7 @@ pub struct ShapedText<'a> {
/// A single glyph resulting from shaping.
#[derive(Debug, Clone)]
-pub struct ShapedGlyph {
+pub(super) struct ShapedGlyph {
/// The font the glyph is contained in.
pub font: Font,
/// The glyph's index in the font.
@@ -318,7 +318,7 @@ struct ShapingContext<'a> {
}
/// Shape text into [`ShapedText`].
-pub fn shape<'a>(
+pub(super) fn shape<'a>(
world: Tracked<dyn World>,
text: &'a str,
styles: StyleChain<'a>,
@@ -534,7 +534,7 @@ fn nbsp_delta(font: &Font) -> Option<Em> {
Some(font.advance(nbsp)? - font.advance(space)?)
}
-/// Resolve the font variant with `BOLD` and `ITALIC` factored in.
+/// Resolve the font variant.
pub fn variant(styles: StyleChain) -> FontVariant {
let mut variant = FontVariant::new(
styles.get(TextNode::STYLE),
diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs
index e5f142dd..856d0f96 100644
--- a/library/src/text/shift.rs
+++ b/library/src/text/shift.rs
@@ -11,7 +11,7 @@ use crate::prelude::*;
/// codepoints. If that fails, we fall back to rendering shrunk normal letters
/// in a raised way.
#[derive(Debug, Hash)]
-pub struct ShiftNode<const S: ScriptKind>(pub Content);
+pub struct ShiftNode<const S: ShiftKind>(pub Content);
/// Shift the text into superscript.
pub type SuperNode = ShiftNode<SUPERSCRIPT>;
@@ -20,7 +20,7 @@ pub type SuperNode = ShiftNode<SUPERSCRIPT>;
pub type SubNode = ShiftNode<SUBSCRIPT>;
#[node(Show)]
-impl<const S: ScriptKind> ShiftNode<S> {
+impl<const S: ShiftKind> ShiftNode<S> {
/// Whether to prefer the dedicated sub- and superscript characters of the
/// font.
pub const TYPOGRAPHIC: bool = true;
@@ -35,7 +35,7 @@ impl<const S: ScriptKind> ShiftNode<S> {
}
}
-impl<const S: ScriptKind> Show for ShiftNode<S> {
+impl<const S: ShiftKind> Show for ShiftNode<S> {
fn unguard_parts(&self, _: Selector) -> Content {
Self(self.0.clone()).pack()
}
@@ -72,7 +72,7 @@ impl<const S: ScriptKind> Show for ShiftNode<S> {
/// Find and transform the text contained in `content` to the given script kind
/// if and only if it only consists of `Text`, `Space`, and `Empty` leaf nodes.
-fn search_text(content: &Content, mode: ScriptKind) -> Option<EcoString> {
+fn search_text(content: &Content, mode: ShiftKind) -> Option<EcoString> {
if content.is_empty() {
Some(EcoString::new())
} else if content.is::<SpaceNode>() {
@@ -114,7 +114,7 @@ fn is_shapable(world: Tracked<dyn World>, text: &str, styles: StyleChain) -> boo
/// Convert a string to sub- or superscript codepoints if all characters
/// can be mapped to such a codepoint.
-fn convert_script(text: &str, mode: ScriptKind) -> Option<EcoString> {
+fn convert_script(text: &str, mode: ShiftKind) -> Option<EcoString> {
let mut result = EcoString::with_capacity(text.len());
let converter = match mode {
SUPERSCRIPT => to_superscript_codepoint,
@@ -179,10 +179,10 @@ fn to_subscript_codepoint(c: char) -> Option<char> {
}
/// A category of script.
-pub type ScriptKind = usize;
+pub type ShiftKind = usize;
/// Text that is rendered smaller and raised, also known as superior.
-const SUPERSCRIPT: ScriptKind = 0;
+const SUPERSCRIPT: ShiftKind = 0;
/// Text that is rendered smaller and lowered, also known as inferior.
-const SUBSCRIPT: ScriptKind = 1;
+const SUBSCRIPT: ShiftKind = 1;