@@ -11,19 +11,19 @@ use crate::diag::{bail, HintedStrResult, SourceResult};
1111use crate :: foundations:: { func, scope, ty, Context , Fold , Repr , Resolve , StyleChain } ;
1212use crate :: layout:: { Abs , Em } ;
1313
14- /// A size or distance, possibly expressed with contextual units.
14+ /// 文脈に応じた単位で表現される場合もある、大きさまたは距離。
1515///
16- /// Typst supports the following length units:
16+ /// Typstは以下の長さの単位をサポートしています。
1717///
18- /// - Points : `{72pt}`
19- /// - Millimeters : `{254mm}`
20- /// - Centimeters : `{2.54cm}`
21- /// - Inches : `{1in}`
22- /// - Relative to font size : `{2.5em}`
18+ /// - ポイント : `{72pt}`
19+ /// - ミリメートル : `{254mm}`
20+ /// - センチメートル : `{2.54cm}`
21+ /// - インチ : `{1in}`
22+ /// - 相対フォントサイズ : `{2.5em}`
2323///
24- /// You can multiply lengths with and divide them by integers and floats.
24+ /// 長さは整数や浮動小数点数で乗除算できます。
2525///
26- /// # Example
26+ /// # 例
2727/// ```example
2828/// #rect(width: 20pt)
2929/// #rect(width: 2em)
@@ -35,10 +35,9 @@ use crate::layout::{Abs, Em};
3535/// #(5em).abs
3636/// ```
3737///
38- /// # Fields
39- /// - `abs`: A length with just the absolute component of the current length
40- /// (that is, excluding the `em` component).
41- /// - `em`: The amount of `em` units in this length, as a [float].
38+ /// # フィールド
39+ /// - `abs`: 現在の長さの単なる数値部分(すなわち`em`部分を除いたもの)。
40+ /// - `em`: [float]としての、この長さでの`em`単位の大きさ。
4241#[ ty( scope, cast) ]
4342#[ derive( Default , Copy , Clone , Eq , PartialEq , Hash ) ]
4443pub struct Length {
@@ -95,49 +94,47 @@ impl Length {
9594
9695#[ scope]
9796impl Length {
98- /// Converts this length to points.
97+ /// この長さをポイントに変換します。
9998 ///
100- /// Fails with an error if this length has non-zero `em` units (such as
101- /// `5em + 2pt` instead of just `2pt`). Use the `abs` field (such as in
102- /// `(5em + 2pt).abs.pt()`) to ignore the `em` component of the length (thus
103- /// converting only its absolute component).
99+ /// この長さが(単に`2pt`ではなく`5em + 2pt`のように)`em`以外の単位で非ゼロの値を持っているとエラーが発生して失敗します。
100+ /// 長さの`em`成分を無視するために(`(5em + 2pt).abs.pt()`のように)`abs`フィールドを使用してください(したがって数値部分のみが変換されます)。
104101 #[ func( name = "pt" , title = "Points" ) ]
105102 pub fn to_pt ( & self , span : Span ) -> SourceResult < f64 > {
106103 self . ensure_that_em_is_zero ( span, "pt" ) ?;
107104 Ok ( self . abs . to_pt ( ) )
108105 }
109106
110- /// Converts this length to millimeters.
107+ /// この長さをミリメートルに変換します。
111108 ///
112- /// Fails with an error if this length has non-zero `em` units. See the
113- /// [`pt`]($length.pt) method for more details.
109+ /// この長さが `em`以外の単位で非ゼロの値を持っているとエラーが発生して失敗します。
110+ /// 詳細は [`pt`]($length.pt)メソッドを参照して下さい。
114111 #[ func( name = "mm" , title = "Millimeters" ) ]
115112 pub fn to_mm ( & self , span : Span ) -> SourceResult < f64 > {
116113 self . ensure_that_em_is_zero ( span, "mm" ) ?;
117114 Ok ( self . abs . to_mm ( ) )
118115 }
119116
120- /// Converts this length to centimeters.
117+ /// この長さをセンチメートルに変換します。
121118 ///
122- /// Fails with an error if this length has non-zero `em` units. See the
123- /// [`pt`]($length.pt) method for more details.
119+ /// この長さが `em`以外の単位で非ゼロの値を持っているとエラーが発生して失敗します。
120+ /// 詳細は [`pt`]($length.pt)メソッドを参照して下さい。
124121 #[ func( name = "cm" , title = "Centimeters" ) ]
125122 pub fn to_cm ( & self , span : Span ) -> SourceResult < f64 > {
126123 self . ensure_that_em_is_zero ( span, "cm" ) ?;
127124 Ok ( self . abs . to_cm ( ) )
128125 }
129126
130- /// Converts this length to inches.
127+ /// この長さをインチに変換します。
131128 ///
132- /// Fails with an error if this length has non-zero `em` units. See the
133- /// [`pt`]($length.pt) method for more details.
129+ /// この長さが `em`以外の単位で非ゼロの値を持っているとエラーが発生して失敗します。
130+ /// 詳細は [`pt`]($length.pt)メソッドを参照して下さい。
134131 #[ func( name = "inches" ) ]
135132 pub fn to_inches ( & self , span : Span ) -> SourceResult < f64 > {
136133 self . ensure_that_em_is_zero ( span, "inches" ) ?;
137134 Ok ( self . abs . to_inches ( ) )
138135 }
139136
140- /// Resolve this length to an absolute length.
137+ /// この長さを絶対的な長さに変換します。
141138 ///
142139 /// ```example
143140 /// #set text(size: 12pt)
0 commit comments