penpot/common/test/common_tests/fonts_test.cljs
Alejandro Alonso f9f5a4cdd0
🐛 Honor text and emoji presentation in WebGL text (#13295)
Skia listed Color Emoji too early and treated broad SMP ranges as
emoji, so text-default symbols rendered in color and FE0F could stay
monochrome. Empty spans also stopped pushing styles.

Split spans by Unicode Emoji_Presentation and variation selectors,
use emoji-first stacks only for emoji runs, keep Color Emoji last on
text runs, and always push a style for empty spans. Closes #13271.
2026-11-25 15:22:48 +01:00

50 lines
2.1 KiB
Clojure
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns common-tests.fonts-test
(:require
[app.common.fonts :as cfnt]
[clojure.test :as t]))
(defn- fallback-font-ids
[text]
(->> (cfnt/collect-used-languages #{} text)
(cfnt/add-noto-fonts #{})
(into #{} (map :font-id))))
(t/deftest math-symbols-use-noto-sans-math
(t/testing "arrows"
(t/is (contains? (fallback-font-ids "↳") "gfont-noto-sans-math"))
(t/is (contains? (fallback-font-ids "⇒") "gfont-noto-sans-math")))
(t/testing "mathematical operators"
(t/is (contains? (fallback-font-ids "∀x ∈ A") "gfont-noto-sans-math"))
(t/is (contains? (fallback-font-ids "a ≠ b") "gfont-noto-sans-math")))
(t/testing "supplemental arrows and operators"
(t/is (contains? (fallback-font-ids "⟹") "gfont-noto-sans-math"))
(t/is (contains? (fallback-font-ids "⤴") "gfont-noto-sans-math"))
(t/is (contains? (fallback-font-ids "⨁") "gfont-noto-sans-math"))))
(t/deftest letterlike-symbols-use-noto-sans
(t/is (contains? (fallback-font-ids "x ∈ ℝ") "gfont-noto-sans"))
(t/is (contains? (fallback-font-ids "20 ℃") "gfont-noto-sans"))
(t/is (contains? (fallback-font-ids "Penpot™") "gfont-noto-sans")))
(t/deftest plain-text-does-not-use-noto-sans-math
(t/is (not (contains? (fallback-font-ids "Hello world") "gfont-noto-sans-math")))
(t/is (not (contains? (fallback-font-ids "★ ☀") "gfont-noto-sans-math"))))
(t/deftest text-default-symbols-do-not-count-as-emoji
(doseq [text ["♥" "☀" "✔" "★ ☀" "Hello" "❤"]]
(t/is (not (cfnt/contains-emoji? text)))))
(t/deftest emoji-presentation-counts-as-emoji
(doseq [text ["❤️" "♥️" "✅" "⚡️" "😀"]]
(t/is (cfnt/contains-emoji? text))))
(t/deftest text-default-symbols-still-use-symbol-fallbacks
(t/is (contains? (fallback-font-ids "♥") "gfont-noto-sans-symbols"))
(t/is (contains? (fallback-font-ids "☀") "gfont-noto-sans-symbols")))