Skip to content

Commit 5124cfe

Browse files
authored
Merge pull request #8 from humanlyio/tan/fix-unicode
Support Japanese unicode
2 parents 521d4d5 + af3f888 commit 5124cfe

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/mudbrick/font.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,11 @@ defmodule Mudbrick.Font do
116116
offset = normal_width - width_when_kerned
117117
{Mudbrick.to_hex(glyph_id), offset}
118118

119-
{glyph_id, {:std_width, _, _, _width, _}} ->
119+
{glyph_id, {:std_width, _, _, _, _}} ->
120120
Mudbrick.to_hex(glyph_id)
121+
122+
{glyph_id, {:pos, _, _, _, _}} ->
123+
Mudbrick.to_hex(glyph_id)
121124
end)
122125
end
123126

test/font_test.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ defmodule Mudbrick.FontTest do
103103
end
104104
end
105105

106+
test "kerned handles Japanese with :pos tuple" do
107+
doc = Mudbrick.new(fonts: %{bodoni: bodoni_regular()})
108+
font = Document.find_object(doc, &match?(%Font{}, &1)).value
109+
110+
result = Font.kerned(font, "日本語")
111+
assert is_list(result)
112+
assert Enum.all?(result, &(is_binary(&1) or is_tuple(&1)))
113+
end
114+
106115
describe "serialisation" do
107116
test "with descendant" do
108117
assert %Font{

0 commit comments

Comments
 (0)