mirror of
https://github.com/penpot/penpot.git
synced 2026-11-27 05:10:32 +00:00
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.
50 lines
2.1 KiB
Clojure
50 lines
2.1 KiB
Clojure
;; 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")))
|