Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 31 additions & 40 deletions crates/typst-library/src/text/deco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ use crate::layout::{Abs, Corners, Length, Rel, Sides};
use crate::text::{BottomEdge, BottomEdgeMetric, TextElem, TopEdge, TopEdgeMetric};
use crate::visualize::{Color, FixedStroke, Paint, Stroke};

/// Underlines text.
/// テキスト下部に線を追加。
///
/// # Example
/// #
/// ```example
/// This is #underline[important].
/// ```
#[elem(Show)]
pub struct UnderlineElem {
/// How to [stroke] the line.
/// 線の[stroke]をどうするか。
///
/// If set to `{auto}`, takes on the text's color and a thickness defined in
/// the current font.
/// `{auto}`に設定された場合、現在のテキストフォントで使用されているテキストの太さと色が使用されます。
///
/// ```example
/// Take #underline(
Expand All @@ -31,8 +30,8 @@ pub struct UnderlineElem {
#[fold]
pub stroke: Smart<Stroke>,

/// The position of the line relative to the baseline, read from the font
/// tables if `{auto}`.
/// ベースラインを基準とする線の位置。
/// `{auto}`の場合、フォントテーブルから読まれます。
///
/// ```example
/// #underline(offset: 5pt)[
Expand All @@ -42,8 +41,7 @@ pub struct UnderlineElem {
#[resolve]
pub offset: Smart<Length>,

/// The amount by which to extend the line beyond (or within if negative)
/// the content.
/// コンテンツの外側に(負の値のときは内側に)線を左右に拡張する量。
///
/// ```example
/// #align(center,
Expand All @@ -53,8 +51,7 @@ pub struct UnderlineElem {
#[resolve]
pub extent: Length,

/// Whether the line skips sections in which it would collide with the
/// glyphs.
/// 字形と衝突する線の部分を省略するかどうか。
///
/// ```example
/// This #underline(evade: true)[is great].
Expand All @@ -63,7 +60,7 @@ pub struct UnderlineElem {
#[default(true)]
pub evade: bool,

/// Whether the line is placed behind the content it underlines.
/// 線をコンテンツの背後に置くかどうか。
///
/// ```example
/// #set underline(stroke: (thickness: 1em, paint: maroon, cap: "round"))
Expand All @@ -73,7 +70,7 @@ pub struct UnderlineElem {
#[default(false)]
pub background: bool,

/// The content to underline.
/// 下部に線を置くコンテンツ。
#[required]
pub body: Content,
}
Expand All @@ -93,18 +90,17 @@ impl Show for Packed<UnderlineElem> {
}
}

/// Adds a line over text.
/// テキスト上部に線を追加。
///
/// # Example
/// #
/// ```example
/// #overline[A line over text.]
/// ```
#[elem(Show)]
pub struct OverlineElem {
/// How to [stroke] the line.
/// 線の[stroke]をどうするか。
///
/// If set to `{auto}`, takes on the text's color and a thickness defined in
/// the current font.
/// `{auto}`に設定された場合、現在のテキストフォントで使用されているテキストの太さと色が使用されます。
///
/// ```example
/// #set text(fill: olive)
Expand All @@ -118,8 +114,8 @@ pub struct OverlineElem {
#[fold]
pub stroke: Smart<Stroke>,

/// The position of the line relative to the baseline. Read from the font
/// tables if `{auto}`.
/// ベースラインを基準とする線の位置。
/// `{auto}`の場合、フォントテーブルから読まれます。
///
/// ```example
/// #overline(offset: -1.2em)[
Expand All @@ -129,8 +125,7 @@ pub struct OverlineElem {
#[resolve]
pub offset: Smart<Length>,

/// The amount by which to extend the line beyond (or within if negative)
/// the content.
/// コンテンツの外側に(負の値のときは内側に)線を左右に拡張する量。
///
/// ```example
/// #set overline(extent: 4pt)
Expand All @@ -140,8 +135,7 @@ pub struct OverlineElem {
#[resolve]
pub extent: Length,

/// Whether the line skips sections in which it would collide with the
/// glyphs.
/// 字形と衝突する線の部分を省略するかどうか。
///
/// ```example
/// #overline(
Expand All @@ -155,7 +149,7 @@ pub struct OverlineElem {
#[default(true)]
pub evade: bool,

/// Whether the line is placed behind the content it overlines.
/// 線をコンテンツの背後に置くかどうか。
///
/// ```example
/// #set overline(stroke: (thickness: 1em, paint: maroon, cap: "round"))
Expand All @@ -165,7 +159,7 @@ pub struct OverlineElem {
#[default(false)]
pub background: bool,

/// The content to add a line over.
/// 上部に線を置くコンテンツ。
#[required]
pub body: Content,
}
Expand All @@ -185,21 +179,19 @@ impl Show for Packed<OverlineElem> {
}
}

/// Strikes through text.
/// テキストの打ち消し。
///
/// # Example
/// #
/// ```example
/// This is #strike[not] relevant.
/// ```
#[elem(title = "Strikethrough", Show)]
pub struct StrikeElem {
/// How to [stroke] the line.
/// 線の[stroke]をどうするか。
///
/// If set to `{auto}`, takes on the text's color and a thickness defined in
/// the current font.
/// `{auto}`に設定された場合、現在のテキストフォントで使用されているテキストの太さと色が使用されます。
///
/// _Note:_ Please don't use this for real redaction as you can still copy
/// paste the text.
/// _注意:_ テキストのコピー・ペーストは依然として可能なため、実際の黒塗りには使用しないでください。
///
/// ```example
/// This is #strike(stroke: 1.5pt + red)[very stricken through]. \
Expand All @@ -209,10 +201,10 @@ pub struct StrikeElem {
#[fold]
pub stroke: Smart<Stroke>,

/// The position of the line relative to the baseline. Read from the font
/// tables if `{auto}`.
/// ベースラインを基準とする線の位置。
/// `{auto}`の場合、フォントテーブルから読まれます。
///
/// This is useful if you are unhappy with the offset your font provides.
/// これはフォントが提供するオフセットに不満がある場合に便利です。
///
/// ```example
/// #set text(font: "Inria Serif")
Expand All @@ -222,8 +214,7 @@ pub struct StrikeElem {
#[resolve]
pub offset: Smart<Length>,

/// The amount by which to extend the line beyond (or within if negative)
/// the content.
/// コンテンツの外側に(負の値のときは内側に)線を左右に拡張する量。
///
/// ```example
/// This #strike(extent: -2pt)[skips] parts of the word.
Expand All @@ -232,7 +223,7 @@ pub struct StrikeElem {
#[resolve]
pub extent: Length,

/// Whether the line is placed behind the content.
/// 線をコンテンツの背後に置くかどうか。
///
/// ```example
/// #set strike(stroke: red)
Expand All @@ -242,7 +233,7 @@ pub struct StrikeElem {
#[default(false)]
pub background: bool,

/// The content to strike through.
/// 打ち消すコンテンツ。
#[required]
pub body: Content,
}
Expand Down
6 changes: 3 additions & 3 deletions website/translation-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@
"/docs/reference/text/linebreak/": "untranslated",
"/docs/reference/text/lorem/": "untranslated",
"/docs/reference/text/lower/": "untranslated",
"/docs/reference/text/overline/": "untranslated",
"/docs/reference/text/overline/": "translated",
"/docs/reference/text/raw/": "untranslated",
"/docs/reference/text/smallcaps/": "untranslated",
"/docs/reference/text/smartquote/": "untranslated",
"/docs/reference/text/strike/": "untranslated",
"/docs/reference/text/strike/": "translated",
"/docs/reference/text/sub/": "untranslated",
"/docs/reference/text/super/": "untranslated",
"/docs/reference/text/text/": "untranslated",
"/docs/reference/text/underline/": "untranslated",
"/docs/reference/text/underline/": "translated",
"/docs/reference/text/upper/": "untranslated",
"/docs/reference/math/": "untranslated",
"/docs/reference/math/accent/": "translated",
Expand Down