font-variant-east-asian
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Thuộc tính CSS font-variant-east-asian kiểm soát việc sử dụng các glyph thay thế cho chữ viết Đông Á, như tiếng Nhật và tiếng Trung.
Try it
font-variant-east-asian: normal;
font-variant-east-asian: ruby;
font-variant-east-asian: jis78;
font-variant-east-asian: proportional-width;
<section id="default-example">
<div id="example-element">
<p>
JIS78とJIS83以降では、檜と桧、籠と篭など、一部の文字の入れ替えが行われている。また、「唖然」や「躯体」などの書体が変更されている。
</p>
</div>
</section>
section {
font-family:
"YuGothic Medium", "YuGothic", "Yu Gothic Medium", "Yu Gothic", sans-serif;
margin-top: 10px;
font-size: 1.5em;
}
Cú pháp
font-variant-east-asian: normal;
font-variant-east-asian: ruby;
font-variant-east-asian: jis78; /* <east-asian-variant-values> */
font-variant-east-asian: jis83; /* <east-asian-variant-values> */
font-variant-east-asian: jis90; /* <east-asian-variant-values> */
font-variant-east-asian: jis04; /* <east-asian-variant-values> */
font-variant-east-asian: simplified; /* <east-asian-variant-values> */
font-variant-east-asian: traditional; /* <east-asian-variant-values> */
font-variant-east-asian: full-width; /* <east-asian-width-values> */
font-variant-east-asian: proportional-width; /* <east-asian-width-values> */
font-variant-east-asian: ruby full-width jis83;
/* Giá trị toàn cục */
font-variant-east-asian: inherit;
font-variant-east-asian: initial;
font-variant-east-asian: revert;
font-variant-east-asian: revert-layer;
font-variant-east-asian: unset;
Giá trị
normal-
Từ khóa này dẫn đến việc hủy kích hoạt việc sử dụng các glyph thay thế đó.
ruby-
Từ khóa này buộc sử dụng các glyph đặc biệt cho các ký tự ruby. Vì những ký tự này thường nhỏ hơn, các nhà tạo phông chữ thường thiết kế các dạng cụ thể, thường đậm hơn một chút để cải thiện độ tương phản. Từ khóa này tương ứng với các giá trị OpenType
ruby. <east-asian-variant-values>-
Các giá trị này chỉ định một tập hợp các biến thể glyph biểu tượng học được dùng để hiển thị. Các giá trị có thể là:
Từ khóa Tiêu chuẩn định nghĩa glyph Tương đương OpenType jis78JIS X 0208:1978 jp78jis83JIS X 0208:1983 jp83jis90JIS X 0208:1990 jp90jis04JIS X 0213:2004 jp04simplifiedKhông có, sử dụng các glyph tiếng Trung giản thể smpltraditionalKhông có, sử dụng các glyph tiếng Trung phồn thể trad <east-asian-width-values>-
Các giá trị này kiểm soát kích thước của các ký tự dùng cho ký tự Đông Á. Có hai giá trị có thể:
proportional-widthkích hoạt tập hợp các ký tự Đông Á có chiều rộng thay đổi. Nó tương ứng với các giá trị OpenTypepwid.full-widthkích hoạt tập hợp các ký tự Đông Á đều có cùng kích thước gần như vuông. Nó tương ứng với các giá trị OpenTypefwid.
Định nghĩa hình thức
| Initial value | normal |
|---|---|
| Applies to | all elements and text. It also applies to ::first-letter and ::first-line. |
| Inherited | yes |
| Computed value | as specified |
| Animation type | discrete |
Cú pháp hình thức
font-variant-east-asian =
normal |
[ <east-asian-variant-values> || <east-asian-width-values> || ruby ]
<east-asian-variant-values> =
jis78 |
jis83 |
jis90 |
jis04 |
simplified |
traditional
<east-asian-width-values> =
full-width |
proportional-width
Ví dụ
>Đặt các biến thể glyph Đông Á
Ví dụ này yêu cầu phông chữ "Yu Gothic" được cài đặt trong hệ điều hành của bạn, các phông chữ khác có thể không hỗ trợ các tính năng OpenType.
HTML
<table>
<thead></thead>
<tbody>
<tr>
<th>normal/jis78:</th>
<td>麹町</td>
<td class="jis78">麹町</td>
</tr>
<tr>
<th>normal/ruby:</th>
<td>しんかんせん</td>
<td class="ruby">しんかんせん</td>
</tr>
<tr>
<th>normal/traditional:</th>
<td>大学</td>
<td class="traditional">大学</td>
</tr>
</tbody>
</table>
CSS
tbody {
border: 0;
}
td {
font-family: "Yu Gothic", fantasy;
font-size: 20px;
}
th {
color: grey;
padding-right: 10px;
}
.ruby {
font-variant-east-asian: ruby;
}
.jis78 {
font-variant-east-asian: jis78;
}
.traditional {
font-variant-east-asian: traditional;
}
Kết quả
Thông số kỹ thuật
| Specification |
|---|
| CSS Fonts Module Level 4> # font-variant-east-asian-prop> |