Skip to content

Truly independent web browser

LibUnicode+LibGfx+LibWeb: Use Vertical_Orientation for upright text

sideshowbarkered58ea689e16
diff --git a/Libraries/LibGfx/Rust/src/font.rs b/Libraries/LibGfx/Rust/src/font.rs
index fe44da74dd4..f5968617ba0 100644
--- a/Libraries/LibGfx/Rust/src/font.rs
+++ b/Libraries/LibGfx/Rust/src/font.rs
@@ -226,6 +226,7 @@ impl FontHandle {
0.0,
0.0,
crate::text_layout::JoiningContext::default(),
+ false,
)
}
diff --git a/Libraries/LibGfx/Rust/src/text_layout.rs b/Libraries/LibGfx/Rust/src/text_layout.rs
index c7ae0480ab8..eeca59bc118 100644
--- a/Libraries/LibGfx/Rust/src/text_layout.rs
+++ b/Libraries/LibGfx/Rust/src/text_layout.rs
@@ -161,6 +161,7 @@ unsafe extern "C" {
letter_spacing: f32,
word_spacing: f32,
joining_context: JoiningContext,
+ vertical_forms: bool,
sink: *mut c_void,
emit: unsafe extern "C" fn(*mut c_void, *const ShapedGlyph, usize, f32, usize, f32, f32, bool),
);
@@ -713,6 +714,8 @@ struct ShapeParams {
letter_spacing: f32,
word_spacing: f32,
joining_context: JoiningContext,
+ /// Whether the glyphs are set upright in vertical text, which takes the vertical forms the font has for them.
+ vertical_forms: bool,
}
impl ShapeParams {
@@ -723,6 +726,7 @@ impl ShapeParams {
&& self.letter_spacing.to_bits() == other.letter_spacing.to_bits()
&& self.word_spacing.to_bits() == other.word_spacing.to_bits()
&& self.joining_context == other.joining_context
+ && self.vertical_forms == other.vertical_forms
}
}
@@ -877,6 +881,7 @@ impl FontShapeCache {
&& params.letter_spacing == 0.0
&& params.word_spacing == 0.0
&& params.joining_context == JoiningContext::default()
+ && !params.vertical_forms
{
return self.single_ascii_common_shapes[code_unit as usize]
.get_or_insert_with(|| Arc::new(shape_uncached()));
@@ -1073,6 +1078,7 @@ fn shape_text_uncached(font: &FontHandle, text: &[u16], params: ShapeParams) ->
params.letter_spacing,
params.word_spacing,
params.joining_context,
+ params.vertical_forms,
(&raw mut shape).cast(),
emit,
);
@@ -1112,12 +1118,14 @@ pub fn shape_text_shared(
letter_spacing: f32,
word_spacing: f32,
joining_context: JoiningContext,
+ vertical_forms: bool,
) -> SharedShape {
let params = ShapeParams {
text_type,
letter_spacing,
word_spacing,
joining_context,
+ vertical_forms,
};
with_cached_shape(font, text, params, |shape| SharedShape(shape.clone()))
}
@@ -1129,12 +1137,14 @@ pub fn shaped_text_width(
letter_spacing: f32,
word_spacing: f32,
joining_context: JoiningContext,
+ vertical_forms: bool,
) -> f32 {
let params = ShapeParams {
text_type,
letter_spacing,
word_spacing,
joining_context,
+ vertical_forms,
};
with_cached_shape(font, text, params, |shape| shape.width)
}
@@ -1152,6 +1162,7 @@ pub fn shape_text(
letter_spacing,
word_spacing,
joining_context: JoiningContext::default(),
+ vertical_forms: false,
};
with_cached_shape(font, text, params, |shape| {
shaped_text_with_baseline_start(shape, baseline_start_x)
@@ -1433,6 +1444,7 @@ mod shaping_cache_tests {
letter_spacing,
word_spacing: 0.0,
joining_context: JoiningContext::default(),
+ vertical_forms: false,
}
}
diff --git a/Libraries/LibGfx/TextLayout.cpp b/Libraries/LibGfx/TextLayout.cpp
index ff4423624cd..75529ae3df0 100644
--- a/Libraries/LibGfx/TextLayout.cpp
+++ b/Libraries/LibGfx/TextLayout.cpp
@@ -409,7 +409,7 @@ Vector<float> glyph_run_glyph_intercepts(Font const& font, ReadonlySpan<ShapedGl
return intervals;
}
-static hb_buffer_t* setup_text_shaping(Utf16View const& string, Font const& font, FFI::TextType text_type, float letter_spacing, FFI::JoiningContext joining_context = {})
+static hb_buffer_t* setup_text_shaping(Utf16View const& string, Font const& font, FFI::TextType text_type, float letter_spacing, FFI::JoiningContext joining_context = {}, bool vertical_forms = false)
{
hb_buffer_t* buffer = hb_buffer_create();
@@ -446,7 +446,16 @@ static hb_buffer_t* setup_text_shaping(Utf16View const& string, Font const& font
auto* hb_font = font.harfbuzz_font();
Vector<hb_feature_t, 8> hb_features;
- hb_features.ensure_capacity(font.features().size());
+ hb_features.ensure_capacity(font.features().size() + (vertical_forms ? 1 : 0));
+ // https://drafts.csswg.org/css-writing-modes-4/#typeset-upright
+ // "Additionally, font features (such as alternate glyphs and other transformation) intended for use in vertical
+ // typesetting must be used. (E.g. the OpenType vert feature must be enabled.)"
+ // NB: That gives glyphs set upright the vertical forms the font has for them: the vertical long vowel mark,
+ // brackets that open downwards, and punctuation that sits in the top-right corner of the em box.
+ // NB: It goes first, so that font-feature-settings can still turn it off.
+ if (vertical_forms)
+ hb_features.append({ .tag = HB_TAG('v', 'e', 'r', 't'), .value = 1, .start = 0, .end = HB_FEATURE_GLOBAL_END });
+
for (auto const& feature : font.features()) {
hb_features.unchecked_append({
.tag = HB_TAG(feature.tag[0], feature.tag[1], feature.tag[2], feature.tag[3]),
@@ -582,10 +591,10 @@ struct ShapedGlyphs {
bool requires_context_for_breaks { false };
};
-static ShapedGlyphs build_origin_relative_shape(Utf16View const& string, Font const& font, FFI::TextType text_type, float letter_spacing, float word_spacing, FFI::JoiningContext joining_context)
+static ShapedGlyphs build_origin_relative_shape(Utf16View const& string, Font const& font, FFI::TextType text_type, float letter_spacing, float word_spacing, FFI::JoiningContext joining_context, bool vertical_forms)
{
auto const& metrics = font.pixel_metrics();
- auto* buffer = setup_text_shaping(string, font, text_type, letter_spacing, joining_context);
+ auto* buffer = setup_text_shaping(string, font, text_type, letter_spacing, joining_context, vertical_forms);
u32 glyph_count;
auto const* glyph_info = hb_buffer_get_glyph_infos(buffer, &glyph_count);
@@ -743,7 +752,7 @@ static_assert(offsetof(Gfx::FFI::ShapedGlyph, glyph_id) == offsetof(Gfx::ShapedG
static_assert(offsetof(Gfx::FFI::ShapedGlyph, should_paint) == offsetof(Gfx::ShapedGlyph, should_paint));
extern "C" {
-void ladybird_gfx_shape_text_uncached(void const*, u16 const*, size_t, Gfx::FFI::TextType, float, float, Gfx::FFI::JoiningContext, void*, void (*)(void*, Gfx::FFI::ShapedGlyph const*, size_t, float, size_t, float, float, bool));
+void ladybird_gfx_shape_text_uncached(void const*, u16 const*, size_t, Gfx::FFI::TextType, float, float, Gfx::FFI::JoiningContext, bool, void*, void (*)(void*, Gfx::FFI::ShapedGlyph const*, size_t, float, size_t, float, float, bool));
float ladybird_gfx_font_measure_text_width(void const*, u16 const*, size_t);
void ladybird_gfx_glyph_run_bounding_box(void const*, Gfx::FFI::ShapedGlyph const*, size_t, float, float*);
void ladybird_gfx_glyph_run_ink_bounding_box(void const*, Gfx::FFI::ShapedGlyph const*, size_t, float, float*);
@@ -758,6 +767,7 @@ extern "C" void ladybird_gfx_shape_text_uncached(
float letter_spacing,
float word_spacing,
Gfx::FFI::JoiningContext joining_context,
+ bool vertical_forms,
void* sink,
void (*emit)(void*, Gfx::FFI::ShapedGlyph const*, size_t, float, size_t, float, float, bool))
{
@@ -773,7 +783,8 @@ extern "C" void ladybird_gfx_shape_text_uncached(
text_type,
letter_spacing,
word_spacing,
- joining_context);
+ joining_context,
+ vertical_forms);
emit(
sink,
reinterpret_cast<Gfx::FFI::ShapedGlyph const*>(shape.glyphs.data()),
diff --git a/Libraries/LibUnicode/CharacterTypes.cpp b/Libraries/LibUnicode/CharacterTypes.cpp
index f3b8221ede4..6eda4800438 100644
--- a/Libraries/LibUnicode/CharacterTypes.cpp
+++ b/Libraries/LibUnicode/CharacterTypes.cpp
@@ -634,6 +634,20 @@ JoiningType joining_type(u32 code_point)
}
}
+VerticalOrientation vertical_orientation(u32 code_point)
+{
+ switch (u_getIntPropertyValue(static_cast<UChar32>(code_point), UCHAR_VERTICAL_ORIENTATION)) {
+ case U_VO_TRANSFORMED_ROTATED:
+ return VerticalOrientation::TransformedRotated;
+ case U_VO_TRANSFORMED_UPRIGHT:
+ return VerticalOrientation::TransformedUpright;
+ case U_VO_UPRIGHT:
+ return VerticalOrientation::Upright;
+ default:
+ return VerticalOrientation::Rotated;
+ }
+}
+
// 22.2.2.7.3 Canonicalize ( rer, ch ), https://tc39.es/ecma262/#sec-runtime-semantics-canonicalize-ch
u32 canonicalize(u32 code_point, bool unicode_mode)
{
@@ -862,6 +876,7 @@ u8 unicode_layout_bidirectional_class(u32);
u8 unicode_layout_line_break_class(u32);
u8 unicode_layout_joining_type(u32);
bool unicode_layout_code_point_has_emoji_property(u32);
+u8 unicode_layout_vertical_orientation(u32);
}
extern "C" bool unicode_property_matches(
@@ -1076,3 +1091,8 @@ extern "C" bool unicode_layout_code_point_has_emoji_property(u32 code_point)
{
return Unicode::code_point_has_emoji_property(code_point);
}
+
+extern "C" u8 unicode_layout_vertical_orientation(u32 code_point)
+{
+ return to_underlying(Unicode::vertical_orientation(code_point));
+}
diff --git a/Libraries/LibUnicode/CharacterTypes.h b/Libraries/LibUnicode/CharacterTypes.h
index 2f6e201a7eb..5410f172156 100644
--- a/Libraries/LibUnicode/CharacterTypes.h
+++ b/Libraries/LibUnicode/CharacterTypes.h
@@ -115,6 +115,15 @@ enum class JoiningType {
JoiningType joining_type(u32 code_point);
+// https://www.unicode.org/reports/tr50/#vo
+enum class VerticalOrientation : u8 {
+ Rotated,
+ TransformedRotated,
+ TransformedUpright,
+ Upright,
+};
+VerticalOrientation vertical_orientation(u32 code_point);
+
struct CodePointRange {
u32 from { 0 };
u32 to { 0 };
diff --git a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
index 67e3aee57ff..add86b3a428 100644
--- a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
+++ b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
@@ -121,6 +121,7 @@ extern "C" fn ladybird_gfx_shape_text_uncached(
_letter_spacing: f32,
_word_spacing: f32,
_joining_context: JoiningContext,
+ _vertical_forms: bool,
_sink: *mut c_void,
_emit: unsafe extern "C" fn(*mut c_void, *const ShapedGlyph, usize, f32, usize, f32, f32, bool),
) {
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
index 992f0644e86..a9bd7bef11c 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
@@ -121,6 +121,7 @@ fn reshaped_glyph_run(
text_type: u8,
letter_spacing: f32,
word_spacing: f32,
+ is_upright: bool,
) -> OwnedGlyphRun {
let shape = libgfx_rust::text_layout::shape_text_shared(
font,
@@ -129,11 +130,12 @@ fn reshaped_glyph_run(
letter_spacing,
word_spacing,
text_chunker::joining_context(text, range),
+ is_upright,
);
OwnedGlyphRun {
glyphs: shape.glyphs().clone(),
width: shape.width(),
- is_upright: false,
+ is_upright,
}
}
@@ -147,7 +149,7 @@ pub(crate) fn hyphen_glyph_run(
word_spacing: f32,
) -> OwnedGlyphRun {
let hyphen = [if font.contains_glyph(0x2010) { 0x2010 } else { 0x2d }];
- reshaped_glyph_run(&hyphen, 0..1, font, text_type, letter_spacing, word_spacing)
+ reshaped_glyph_run(&hyphen, 0..1, font, text_type, letter_spacing, word_spacing, false)
}
/// Whether a line that breaks after a soft hyphen in text of this style ends in a hyphen.
@@ -519,6 +521,7 @@ impl Item {
letter_spacing,
word_spacing,
text_chunker::joining_context(text, start..end),
+ item.has(PreparedItem::UPRIGHT),
);
// NB: A segment that ends in a soft hyphen ends its line in a hyphen, unless it ends the item and no break
// follows the item.
@@ -553,6 +556,7 @@ impl Item {
item.text_type(),
letter_spacing,
word_spacing,
+ item.has(PreparedItem::UPRIGHT),
)
}
@@ -660,6 +664,7 @@ impl Item {
prepared_item.text_type(),
letter_spacing,
word_spacing,
+ prepared_item.has(PreparedItem::UPRIGHT),
)
});
self.drop_prefix(split_offset_in_node, remainder_glyphs);
@@ -875,6 +880,7 @@ impl Item {
// NB: A right-to-left run splits at a grapheme boundary from its logical start too, so the part that fits is the
// run's logical beginning, which the line then draws at its right end.
let font = prepared.font_of(prepared_item);
+ let is_upright = prepared_item.has(PreparedItem::UPRIGHT);
let start = self.offset_in_node;
let end = start + self.length_in_node;
@@ -892,7 +898,7 @@ impl Item {
}
let shape = |range: std::ops::Range<usize>| {
- reshaped_glyph_run(text, range, font, text_type, letter_spacing, word_spacing)
+ reshaped_glyph_run(text, range, font, text_type, letter_spacing, word_spacing, is_upright)
};
let leading_edge_inline_size = self.margin_start + self.border_start + self.padding_start;
@@ -904,6 +910,7 @@ impl Item {
letter_spacing,
word_spacing,
text_chunker::joining_context(text, start..boundary),
+ is_upright,
);
leading_edge_inline_size + CssPixels::nearest_value_for_f32(width) <= max_border_box_inline_size
};
@@ -959,6 +966,7 @@ impl Item {
letter_spacing,
word_spacing,
text_chunker::joining_context(text, start..boundary),
+ run.is_upright,
);
Some(CssPixels::nearest_value_for_f32(width))
}
@@ -1717,6 +1725,14 @@ impl<'pass> InlineContentPreparer<'pass> {
}
let shaped_range = shaped_start..shaped_start + shaped_length;
let mut shaped_text = &full_text[shaped_range.clone()];
+ let is_set_upright = |text: &[u16]| {
+ !text.is_empty()
+ && text_is_set_upright(
+ text_context.writing_mode,
+ text_context.text_orientation,
+ text_chunker::code_point_at(text, 0),
+ )
+ };
let mut shape = libgfx_rust::text_layout::shape_text_shared(
font,
shaped_text,
@@ -1724,6 +1740,7 @@ impl<'pass> InlineContentPreparer<'pass> {
text_context.letter_spacing,
text_context.word_spacing,
text_chunker::joining_context(full_text, shaped_range),
+ is_set_upright(shaped_text),
);
// Remember the decision only if every combined run is restored to its original chunks. Text, font, and break-rule
// changes replace the chunk memo, while spacing is checked separately.
@@ -1748,16 +1765,11 @@ impl<'pass> InlineContentPreparer<'pass> {
text_context.letter_spacing,
text_context.word_spacing,
text_chunker::joining_context(full_text, chunk.start..chunk.start + chunk.length),
+ is_set_upright(shaped_text),
);
}
let mut flags = if has_soft_wraps { PreparedItem::SOFT_WRAPS } else { 0 };
- if !shaped_text.is_empty()
- && text_is_set_upright(
- text_context.writing_mode,
- text_context.text_orientation,
- text_chunker::code_point_at(shaped_text, 0),
- )
- {
+ if is_set_upright(shaped_text) {
// NB: The font's own size takes any font-size-adjust into account.
let advance = font.facts().pixel_size + text_context.letter_spacing;
match &mut tab_stop {
diff --git a/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs b/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs
index 98843ce23ce..a218f704ac6 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_box_fragment.rs
@@ -240,6 +240,7 @@ impl LineBoxFragmentData {
letter_spacing,
word_spacing,
text_chunker::joining_context(full_text, start..run_end),
+ glyphs.is_upright,
);
let inline_size = CssPixels::nearest_value_for_f32(shape.width());
let run = ItemGlyphRun {
diff --git a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
index d38432ec1de..c5508d0b76c 100644
--- a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
+++ b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
@@ -165,6 +165,7 @@ unsafe extern "C" {
safe fn unicode_layout_line_break_class(code_point: u32) -> u8;
safe fn unicode_layout_joining_type(code_point: u32) -> u8;
safe fn unicode_layout_code_point_has_emoji_property(code_point: u32) -> bool;
+ safe fn unicode_layout_vertical_orientation(code_point: u32) -> u8;
}
// LibUnicode's LineBreakClass, in declaration order.
@@ -388,6 +389,11 @@ mod unicode_test_stubs {
extern "C" fn unicode_layout_code_point_has_emoji_property(_code_point: u32) -> bool {
unreachable!("no unit test segments text");
}
+
+ #[unsafe(no_mangle)]
+ extern "C" fn unicode_layout_vertical_orientation(_code_point: u32) -> u8 {
+ unreachable!("no unit test sets text vertically");
+ }
}
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -691,27 +697,14 @@ fn is_utf16_low_surrogate(code_unit: u16) -> bool {
}
/// Whether a code point is typeset upright in vertical text whose text orientation is 'mixed'.
-// FIXME: Use the Vertical_Orientation property of Unicode (UAX #50) instead of these blocks of characters, which are
-// mostly upright.
+// https://drafts.csswg.org/css-writing-modes-4/#vertical-orientations
+// "When text-orientation is mixed, the UA must determine the orientation of each typographic character unit by its
+// Vertical_Orientation property: typesetting it upright if its orientation property is U, Tu, or Tr; or typesetting
+// it sideways (90° clockwise from horizontal) if its orientation property is R."
pub(crate) fn code_point_is_upright_in_mixed_orientation(code_point: u32) -> bool {
- matches!(
- code_point,
- 0x1100..=0x11FF
- | 0x2E80..=0x303F
- | 0x3040..=0x31FF
- | 0x3200..=0x4DBF
- | 0x4E00..=0x9FFF
- | 0xA960..=0xA97F
- | 0xAC00..=0xD7FF
- | 0xF900..=0xFAFF
- | 0xFE10..=0xFE1F
- | 0xFE30..=0xFE4F
- | 0xFF01..=0xFF0C
- | 0xFF0E..=0xFF1B
- | 0xFF1F..=0xFF60
- | 0xFFE0..=0xFFE6
- | 0x20000..=0x3FFFF
- )
+ // LibUnicode's VerticalOrientation, in declaration order: Rotated comes first.
+ const ROTATED: u8 = 0;
+ unicode_layout_vertical_orientation(code_point) != ROTATED
}
/// Mirrors AK::Utf16View::code_point_at, including its lone-surrogate
diff --git a/Tests/LibWeb/Ref/expected/css/vertical-text-uses-vertical-forms-ref.html b/Tests/LibWeb/Ref/expected/css/vertical-text-uses-vertical-forms-ref.html
new file mode 100644
index 00000000000..845234bca4c
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/css/vertical-text-uses-vertical-forms-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<style>
+ @font-face { font-family: CJK; src: url(../../input/wpt-import/fonts/noto/cjk/NotoSansCJKjp-Regular-subset-chws.otf); }
+ div { writing-mode: vertical-rl; font: 40px/1 CJK; font-feature-settings: "vert" 1; }
+</style>
+<!-- The font's vertical forms, asked for by name. -->
+<div>&#x300C;&#xFF08;&#x3001;&#xFF09;&#x300D;</div>
+<div style="text-orientation: upright">&#x300C;&#xFF08;&#x3001;&#xFF09;&#x300D;</div>
diff --git a/Tests/LibWeb/Ref/input/css/vertical-text-uses-vertical-forms.html b/Tests/LibWeb/Ref/input/css/vertical-text-uses-vertical-forms.html
new file mode 100644
index 00000000000..884bdd5d076
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/css/vertical-text-uses-vertical-forms.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="match" href="../../expected/css/vertical-text-uses-vertical-forms-ref.html">
+<style>
+ @font-face { font-family: CJK; src: url(../wpt-import/fonts/noto/cjk/NotoSansCJKjp-Regular-subset-chws.otf); }
+ div { writing-mode: vertical-rl; font: 40px/1 CJK; }
+</style>
+<!-- Brackets and the ideographic comma are set upright in mixed orientation, in the vertical forms the font has for them. -->
+<div>&#x300C;&#xFF08;&#x3001;&#xFF09;&#x300D;</div>
+<div style="text-orientation: upright">&#x300C;&#xFF08;&#x3001;&#xFF09;&#x300D;</div>
diff --git a/Tests/LibWeb/Text/expected/css/vertical-text-mixed-orientation-follows-uax50.txt b/Tests/LibWeb/Text/expected/css/vertical-text-mixed-orientation-follows-uax50.txt
new file mode 100644
index 00000000000..c4b0b315b62
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/vertical-text-mixed-orientation-follows-uax50.txt
@@ -0,0 +1,6 @@
+EXCLAMATION MARK: sideways
+LATIN SMALL LETTER A: sideways
+SECTION SIGN: upright
+COPYRIGHT SIGN: upright
+PLUS-MINUS SIGN: upright
+MULTIPLICATION SIGN: upright
diff --git a/Tests/LibWeb/Text/input/css/vertical-text-mixed-orientation-follows-uax50.html b/Tests/LibWeb/Text/input/css/vertical-text-mixed-orientation-follows-uax50.html
new file mode 100644
index 00000000000..103c1c57768
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/vertical-text-mixed-orientation-follows-uax50.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<style>
+ div { writing-mode: vertical-rl; font: 20px/1 serif; }
+</style>
+<div id="mixed"></div>
+<div id="sideways" style="text-orientation: sideways"></div>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ // In mixed orientation, a character is set upright when its Vertical_Orientation is U, Tu or Tr, and sideways,
+ // as in text-orientation: sideways, when it's R.
+ const inline_size = (parent, code_point) => {
+ const span = document.createElement("span");
+ span.textContent = String.fromCodePoint(code_point);
+ parent.appendChild(span);
+ const size = span.getBoundingClientRect().height;
+ span.remove();
+ return size;
+ };
+ const names = {
+ 0x00A7: "SECTION SIGN",
+ 0x00A9: "COPYRIGHT SIGN",
+ 0x00B1: "PLUS-MINUS SIGN",
+ 0x00D7: "MULTIPLICATION SIGN",
+ 0x0061: "LATIN SMALL LETTER A",
+ 0x0021: "EXCLAMATION MARK",
+ };
+ for (const [code_point, name] of Object.entries(names)) {
+ const upright = inline_size(mixed, Number(code_point)) !== inline_size(sideways, Number(code_point));
+ println(`${name}: ${upright ? "upright" : "sideways"}`);
+ }
+ });
+</script>