summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-03 11:18:25 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-03 11:18:25 +0200
commit75e6dbfbe6cbd3c3245c825627881a16bfbd6c5d (patch)
tree587b57e5ab09b72ca0d2a5c25cf2cb8f8579303e /src
parent730715c064294337ee9befc3b9332d45eb74818f (diff)
Rename bold/italic to strong/emph ✏
Diffstat (limited to 'src')
-rw-r--r--src/layout/shaping.rs6
-rw-r--r--src/layout/tree.rs22
-rw-r--r--src/parse/mod.rs4
-rw-r--r--src/parse/tests.rs8
-rw-r--r--src/style.rs12
-rw-r--r--src/syntax/ast/tree.rs8
-rw-r--r--src/syntax/mod.rs8
7 files changed, 33 insertions, 35 deletions
diff --git a/src/layout/shaping.rs b/src/layout/shaping.rs
index 115a23e2..0f42d4bb 100644
--- a/src/layout/shaping.rs
+++ b/src/layout/shaping.rs
@@ -14,7 +14,7 @@ use crate::font::FontLoader;
use crate::geom::Size;
use crate::style::TextStyle;
-/// Layouts text into a box.
+/// Shape text into a box.
pub async fn shape(text: &str, ctx: ShapeOptions<'_>) -> BoxLayout {
Shaper::new(text, ctx).layout().await
}
@@ -115,11 +115,11 @@ impl<'a> Shaper<'a> {
async fn select_font(&mut self, c: char) -> Option<(FaceId, GlyphId, f64)> {
let mut variant = self.opts.style.variant;
- if self.opts.style.bolder {
+ if self.opts.style.strong {
variant.weight = variant.weight.thicken(300);
}
- if self.opts.style.italic {
+ if self.opts.style.emph {
variant.style = match variant.style {
FontStyle::Normal => FontStyle::Italic,
FontStyle::Italic => FontStyle::Normal,
diff --git a/src/layout/tree.rs b/src/layout/tree.rs
index 14359b86..b43ef089 100644
--- a/src/layout/tree.rs
+++ b/src/layout/tree.rs
@@ -60,24 +60,24 @@ impl<'a> TreeLayouter<'a> {
match &node.v {
SynNode::Space => self.layout_space(),
SynNode::Text(text) => {
- if self.style.text.italic {
- decorate(self, Decoration::Italic);
+ if self.style.text.emph {
+ decorate(self, Decoration::Emph);
}
- if self.style.text.bolder {
- decorate(self, Decoration::Bold);
+ if self.style.text.strong {
+ decorate(self, Decoration::Strong);
}
self.layout_text(text).await;
}
SynNode::Linebreak => self.layouter.finish_line(),
SynNode::Parbreak => self.layout_parbreak(),
- SynNode::ToggleItalic => {
- self.style.text.italic = !self.style.text.italic;
- decorate(self, Decoration::Italic);
+ SynNode::Emph => {
+ self.style.text.emph = !self.style.text.emph;
+ decorate(self, Decoration::Emph);
}
- SynNode::ToggleBolder => {
- self.style.text.bolder = !self.style.text.bolder;
- decorate(self, Decoration::Bold);
+ SynNode::Strong => {
+ self.style.text.strong = !self.style.text.strong;
+ decorate(self, Decoration::Strong);
}
SynNode::Heading(heading) => self.layout_heading(heading).await,
@@ -116,7 +116,7 @@ impl<'a> TreeLayouter<'a> {
async fn layout_heading(&mut self, heading: &NodeHeading) {
let style = self.style.text.clone();
self.style.text.font_scale *= 1.5 - 0.1 * heading.level.v as f64;
- self.style.text.bolder = true;
+ self.style.text.strong = true;
self.layout_parbreak();
self.layout_tree(&heading.contents).await;
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 395090af..42102bf5 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -62,8 +62,8 @@ fn node(p: &mut Parser, at_start: bool) -> Option<Spanned<SynNode>> {
Token::LineComment(_) | Token::BlockComment(_) => return None,
// Markup.
- Token::Star => SynNode::ToggleBolder,
- Token::Underscore => SynNode::ToggleItalic,
+ Token::Star => SynNode::Strong,
+ Token::Underscore => SynNode::Emph,
Token::Backslash => SynNode::Linebreak,
Token::Hashtag => {
if at_start {
diff --git a/src/parse/tests.rs b/src/parse/tests.rs
index a1b1fb13..feff2b9a 100644
--- a/src/parse/tests.rs
+++ b/src/parse/tests.rs
@@ -13,9 +13,7 @@ use crate::syntax::*;
// ------------------------------ Construct Syntax Nodes ------------------------------ //
use Decoration::*;
-use SynNode::{
- Linebreak as L, Parbreak as P, Space as S, ToggleBolder as B, ToggleItalic as I,
-};
+use SynNode::{Emph as E, Linebreak as L, Parbreak as P, Space as S, Strong as B};
fn T(text: &str) -> SynNode {
SynNode::Text(text.to_string())
@@ -230,7 +228,7 @@ fn test_parse_simple_nodes() {
t!("" => );
t!("hi" => T("hi"));
t!("*hi" => B, T("hi"));
- t!("hi_" => T("hi"), I);
+ t!("hi_" => T("hi"), E);
t!("hi you" => T("hi"), S, T("you"));
t!("special~name" => T("special"), T("\u{00A0}"), T("name"));
t!("special\\~name" => T("special"), T("~"), T("name"));
@@ -415,7 +413,7 @@ fn test_parse_values() {
v!("\"a\n[]\\\"string\"" => Str("a\n[]\"string"));
// Content.
- v!("{_hi_}" => Tree![I, T("hi"), I]);
+ v!("{_hi_}" => Tree![E, T("hi"), E]);
e!("[val: {_hi_}]" => );
v!("[hi]" => Tree![F!("hi")]);
e!("[val: [hi]]" => );
diff --git a/src/style.rs b/src/style.rs
index 9402f11d..7da7f0c6 100644
--- a/src/style.rs
+++ b/src/style.rs
@@ -22,12 +22,12 @@ pub struct TextStyle {
pub fallback: FallbackTree,
/// The selected font variant.
pub variant: FontVariant,
- /// Whether the bolder toggle is active or inactive. This determines
+ /// Whether the strong toggle is active or inactive. This determines
/// whether the next `*` adds or removes font weight.
- pub bolder: bool,
- /// Whether the italic toggle is active or inactive. This determines
+ pub strong: bool,
+ /// Whether the emphasis toggle is active or inactive. This determines
/// whether the next `_` makes italic or non-italic.
- pub italic: bool,
+ pub emph: bool,
/// The base font size.
pub base_font_size: f64,
/// The font scale to apply on the base font size.
@@ -83,8 +83,8 @@ impl Default for TextStyle {
weight: FontWeight::REGULAR,
stretch: FontStretch::Normal,
},
- bolder: false,
- italic: false,
+ strong: false,
+ emph: false,
base_font_size: Length::pt(11.0).as_raw(),
font_scale: 1.0,
word_spacing_scale: 0.25,
diff --git a/src/syntax/ast/tree.rs b/src/syntax/ast/tree.rs
index 03aa3439..c5dc4c65 100644
--- a/src/syntax/ast/tree.rs
+++ b/src/syntax/ast/tree.rs
@@ -18,10 +18,10 @@ pub enum SynNode {
Linebreak,
/// A paragraph break.
Parbreak,
- /// Italics were enabled / disabled.
- ToggleItalic,
- /// Bolder was enabled / disabled.
- ToggleBolder,
+ /// Emphasized text was enabled / disabled.
+ Emph,
+ /// Strong text was enabled / disabled.
+ Strong,
/// A section heading.
Heading(NodeHeading),
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs
index 98e1b4d7..3ac5176b 100644
--- a/src/syntax/mod.rs
+++ b/src/syntax/mod.rs
@@ -16,10 +16,10 @@ pub use token::*;
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
pub enum Decoration {
- /// Text in italics.
- Italic,
- /// Text in bold.
- Bold,
+ /// Emphasized text.
+ Emph,
+ /// Strong text.
+ Strong,
/// A valid, successfully resolved name.
Resolved,
/// An invalid, unresolved name.