From af3f88808a5a867fdc96c8206e96619e0004c6d2 Mon Sep 17 00:00:00 2001 From: Tan Duong Date: Thu, 11 Sep 2025 20:32:59 +0700 Subject: [PATCH] support Japanese unicode --- lib/mudbrick/font.ex | 5 ++++- test/font_test.exs | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/mudbrick/font.ex b/lib/mudbrick/font.ex index 404819c..0f4c994 100644 --- a/lib/mudbrick/font.ex +++ b/lib/mudbrick/font.ex @@ -116,8 +116,11 @@ defmodule Mudbrick.Font do offset = normal_width - width_when_kerned {Mudbrick.to_hex(glyph_id), offset} - {glyph_id, {:std_width, _, _, _width, _}} -> + {glyph_id, {:std_width, _, _, _, _}} -> Mudbrick.to_hex(glyph_id) + + {glyph_id, {:pos, _, _, _, _}} -> + Mudbrick.to_hex(glyph_id) end) end diff --git a/test/font_test.exs b/test/font_test.exs index bc352fe..2139aef 100644 --- a/test/font_test.exs +++ b/test/font_test.exs @@ -103,6 +103,15 @@ defmodule Mudbrick.FontTest do end end + test "kerned handles Japanese with :pos tuple" do + doc = Mudbrick.new(fonts: %{bodoni: bodoni_regular()}) + font = Document.find_object(doc, &match?(%Font{}, &1)).value + + result = Font.kerned(font, "日本語") + assert is_list(result) + assert Enum.all?(result, &(is_binary(&1) or is_tuple(&1))) + end + describe "serialisation" do test "with descendant" do assert %Font{