upgrade rusttype to 0.9.2

Signed-off-by: Sean Cross <sean@xobs.io>
master
Sean Cross 1 year ago
parent 476a565ae5
commit 324669af0c
  1. 639
      Cargo.lock
  2. 18
      Cargo.toml
  3. BIN
      resources/IBMPlexSans-Medium.ttf
  4. BIN
      resources/IBMPlexSans-Regular.ttf
  5. BIN
      resources/NotoEmoji-Regular.ttf
  6. BIN
      resources/NotoSansSC-Black.otf
  7. BIN
      resources/NotoSansSC-Bold.otf
  8. BIN
      resources/NotoSansSC-Light.otf
  9. BIN
      resources/NotoSansSC-Light.ttf
  10. BIN
      resources/NotoSansSC-Medium.otf
  11. BIN
      resources/NotoSansSC-Medium.ttf
  12. BIN
      resources/NotoSansSC-Regular.otf
  13. BIN
      resources/NotoSansSC-Regular.subset.ttf
  14. BIN
      resources/NotoSansSC-Regular.ttf
  15. BIN
      resources/NotoSansSC-Thin.otf
  16. BIN
      resources/Symbola-AjYx.ttf
  17. BIN
      resources/TwitterColorEmoji-SVGinOT.ttf
  18. 325
      src/main.rs

639
Cargo.lock generated

@ -1,20 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "approx"
version = "0.3.2"
name = "ab_glyph_rasterizer"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
checksum = "d9fe5e32de01730eb1f6b7f5b51c17e03e2325bf40a74f754f04f130043affff"
dependencies = [
"num-traits",
"libm",
]
[[package]]
name = "arrayvec"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]]
name = "autocfg"
version = "0.1.7"
@ -28,10 +24,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "byteorder"
version = "1.3.2"
name = "cast"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
dependencies = [
"rustc_version",
]
[[package]]
name = "cc"
@ -42,6 +41,59 @@ dependencies = [
"jobserver",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
dependencies = [
"bitflags",
]
[[package]]
name = "dlib"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
dependencies = [
"libloading",
]
[[package]]
name = "downcast-rs"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "getrandom"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
dependencies = [
"cfg-if 0.1.10",
"libc",
"wasi",
]
[[package]]
name = "jobserver"
version = "0.1.21"
@ -51,17 +103,104 @@ dependencies = [
"libc",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
[[package]]
name = "libloading"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0"
dependencies = [
"cfg-if 1.0.0",
"winapi",
]
[[package]]
name = "libm"
version = "0.1.4"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "minifb"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2407444bc74256b6f2c6fe3d8cfe0af591f5680b501e751078a96992808aa0"
dependencies = [
"cast",
"cc",
"orbclient",
"raw-window-handle",
"tempfile",
"wayland-client",
"wayland-cursor",
"wayland-protocols",
"winapi",
"x11-dl",
"xkb",
"xkbcommon-sys",
]
[[package]]
name = "nix"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
dependencies = [
"bitflags",
"cc",
"cfg-if 0.1.10",
"libc",
"void",
]
[[package]]
name = "num"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
dependencies = [
"num-integer",
"num-iter",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
checksum = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
@ -73,34 +212,268 @@ dependencies = [
]
[[package]]
name = "ordered-float"
version = "1.0.2"
name = "once_cell"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518"
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
[[package]]
name = "orbclient"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8b18f57ab94fbd058e30aa57f712ec423c0bb7403f8493a6c58eef0c36d9402"
dependencies = [
"num-traits",
"redox_syscall",
"sdl2",
]
[[package]]
name = "owned_ttf_parser"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f923fb806c46266c02ab4a5b239735c144bdeda724a50ed058e5226f594cde3"
dependencies = [
"ttf-parser 0.6.2",
]
[[package]]
name = "pkg-config"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "ppv-lite86"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "proc-macro2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
dependencies = [
"autocfg",
"libc",
"rand_chacha 0.1.1",
"rand_core 0.4.2",
"rand_hc 0.1.0",
"rand_isaac",
"rand_jitter",
"rand_os",
"rand_pcg",
"rand_xorshift",
"winapi",
]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom",
"libc",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
]
[[package]]
name = "rand_chacha"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
dependencies = [
"autocfg",
"rand_core 0.3.1",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core 0.5.1",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom",
]
[[package]]
name = "rand_hc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core 0.5.1",
]
[[package]]
name = "rand_isaac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rand_jitter"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
dependencies = [
"libc",
"rand_core 0.4.2",
"winapi",
]
[[package]]
name = "rand_os"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
dependencies = [
"cloudabi",
"fuchsia-cprng",
"libc",
"rand_core 0.4.2",
"rdrand",
"winapi",
]
[[package]]
name = "rand_pcg"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
dependencies = [
"autocfg",
"rand_core 0.4.2",
]
[[package]]
name = "rand_xorshift"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "raw-window-handle"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211"
dependencies = [
"libc",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "redox_syscall"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi",
]
[[package]]
name = "rust-font-test"
version = "0.1.0"
dependencies = [
"minifb",
"rusttype",
"rustybuzz",
"stats_alloc",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver",
]
[[package]]
name = "rusttype"
version = "0.8.1"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fa38506b5cbf2fb67f915e2725cb5012f1b9a785b0ab55c4733acda5f6554ef"
checksum = "dc7c727aded0be18c5b80c1640eae0ac8e396abf6fa8477d96cb37d18ee5ec59"
dependencies = [
"approx",
"arrayvec",
"ab_glyph_rasterizer",
"libm",
"ordered-float",
"stb_truetype",
"owned_ttf_parser",
]
[[package]]
@ -112,13 +485,58 @@ dependencies = [
"bitflags",
"cc",
"smallvec",
"ttf-parser",
"ttf-parser 0.8.3",
"unicode-bidi-mirroring",
"unicode-ccc",
"unicode-general-category",
"unicode-script",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "sdl2"
version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d051a07231e303f5f719da78cb6f7394f6d5b54f733aef5b0b447804a83edd7b"
dependencies = [
"bitflags",
"lazy_static",
"libc",
"num",
"rand 0.6.5",
"sdl2-sys",
]
[[package]]
name = "sdl2-sys"
version = "0.32.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34e71125077d297d57e4c1acfe8981b5bdfbf5a20e7b589abfdcb33bf1127f86"
dependencies = [
"cfg-if 0.1.10",
"libc",
]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "smallvec"
version = "1.5.0"
@ -132,15 +550,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a260c96bf26273969f360c2fc2e2c7732acc2ce49d939c7243c7230c2ad179d0"
[[package]]
name = "stb_truetype"
version = "0.3.0"
name = "tempfile"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824210d6fb52cbc3ad2545270ead6860c7311aa5450642b078da4515937b6f7a"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [
"byteorder",
"libm",
"cfg-if 0.1.10",
"libc",
"rand 0.7.3",
"redox_syscall",
"remove_dir_all",
"winapi",
]
[[package]]
name = "ttf-parser"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc"
[[package]]
name = "ttf-parser"
version = "0.8.3"
@ -170,3 +598,152 @@ name = "unicode-script"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79bf4d5fc96546fdb73f9827097810bbda93b11a6770ff3a54e1f445d4135787"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wayland-client"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a42cb608953ec8e132c7f53fde722cca9bfbf8b2071d685dbbb8df2b567fee8b"
dependencies = [
"bitflags",
"downcast-rs",
"libc",
"nix",
"scoped-tls",
"wayland-commons",
"wayland-scanner",
"wayland-sys",
]
[[package]]
name = "wayland-commons"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8caa2f106138cf71358c6a9e84468e4406069cec93cbd6dbfce92225fc175932"
dependencies = [
"nix",
"once_cell",
"smallvec",
"wayland-sys",
]
[[package]]
name = "wayland-cursor"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d774f69a6a4a9eac6d1a29cea45a4750ee7f997520421b2068f099a11b4cbba"
dependencies = [
"wayland-client",
"wayland-sys",
]
[[package]]
name = "wayland-protocols"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f784a990d5fa6d846fa93eb8d3bb744ff1e6ec60c7f785b0a0ee2f1a1f20bee9"
dependencies = [
"bitflags",
"wayland-client",
"wayland-commons",
"wayland-scanner",
]
[[package]]
name = "wayland-scanner"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f45ddc08a8078f3efa96b5f413268cc9c53b30712891de081fbc1d5846fbc736"
dependencies = [
"proc-macro2",
"quote",
"xml-rs",
]
[[package]]
name = "wayland-sys"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80f9fc64f9045ad5ff491886a9460437655353e8be73c1b3f29f569342553319"
dependencies = [
"dlib",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "x11-dl"
version = "2.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8"
dependencies = [
"lazy_static",
"libc",
"maybe-uninit",
"pkg-config",
]
[[package]]
name = "xkb"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aec02bc5de902aa579f3d2f2c522edaf40fa42963cbaffe645b058ddcc68fdb2"
dependencies = [
"bitflags",
"libc",
"xkbcommon-sys",
]
[[package]]
name = "xkbcommon-sys"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa434980dca02ebf28795d71e570dbb78316d095a228707efd6117bf8246d78b"
dependencies = [
"libc",
"pkg-config",
]
[[package]]
name = "xml-rs"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"

@ -1,13 +1,21 @@
[package]
name = "rust-font-test"
version = "0.1.0"
authors = ["Sean Cross <sean@xobs.io>"]
edition = "2018"
name = "rust-font-test"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
#fontdue = "0.2.4"
stats_alloc = "0.1.8"
rusttype = {version = "0.8.1", default-features = false, features = ["libm-math"] }
minifb = "0.17"
rusttype = {version = "0.9.2", default-features = false, features = ["libm-math"]}
rustybuzz = "0.2.0"
stats_alloc = "0.1.8"
[profile.release]
codegen-units = 1 # 1 better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
[features]
feature_one = []
feature_two = []

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,4 +1,5 @@
use rusttype::{point, Font, FontCollection, PositionedGlyph, Scale};
use rusttype::{point, Font, PositionedGlyph, Scale};
use std::convert::TryInto;
use std::io::Write;
// Add an allocator that lets us keep track of the system
@ -10,7 +11,8 @@ static GLOBAL: &StatsAlloc<System> = &INSTRUMENTED_SYSTEM;
fn main() {
// Chinese test
let font = include_bytes!("../resources/WenQuanYiMicroHei-01.ttf");
// let font = include_bytes!("../resources/WenQuanYiMicroHei-01.ttf");
let font = include_bytes!("../resources/NotoSansSC-Regular.ttf");
let message = " 發啊你好";
let rtl = false;
println!();
@ -21,17 +23,45 @@ fn main() {
// Arabic test
let font = include_bytes!("../resources/LateefRegOT.ttf");
let message = "مرحبا بالعالم"; // "Hello, world!"
// let message = "مممممم"; // Kerning test nonsense string
let message = "مرحبا بالعالم "; // "Hello, world!"
// let message = "مممممم"; // Kerning test nonsense string
let rtl = true;
// let message = "agylixm";
// let rtl = false;
println!();
println!("RUSTTYPE TEST:");
test_rusttype(font, message, rtl);
println!("RUSTTYPE + RUSTYBUZZ TEST:");
test_rusthbuzz(font, message);
// Emoji Test
// let font = include_bytes!("../resources/TwitterColorEmoji-SVGinOT.ttf");
// let font = include_bytes!("../resources/Symbola-AjYx.ttf");
let font = include_bytes!("../resources/NotoEmoji-Regular.ttf");
let message = concat!(
"🐶🐱🦁🐎🦄🐷🐘🐰\n",
"🐼🐓🐧🐢🐟🐙🦋🌷\n",
"🌳🌵🍄🌏🌙☁🔥🍌\n",
"🍎🍓🌽🍕🎂❤😀🤖\n",
"🎩👓🔧🎅👍☂⌛⏰\n",
"🎁💡📕✏📎✂🔒🔑\n",
"🔨☎🏁🚂🚲✈🚀🏆\n",
"⚽🎸🎺🔔⚓🎧📁📌\n",
"Hello, world! ää 🀄🃏\u{1F170}\u{1F170}\u{FE0F}\n",
// "🐶🐱🦁🐎🦄🐷🐘🐰🐼🐓🐧🐢🐟🐙🦋🌷🌳🌵🍄🌏🌙☁🔥🍌🍎🍓🌽🍕🎂❤😀🤖🎩👓🔧🎅👍☂⌛⏰🎁💡📕✏📎✂🔒🔑🔨☎🏁🚂🚲✈🚀🏆⚽🎸🎺🔔⚓🎧📁📌"
);
println!();
println!("RUSTTYPE + RUSTYBUZZ TEST:");
test_rusthbuzz(font, message);
let font = include_bytes!("../resources/TwitterColorEmoji-SVGinOT.ttf");
println!();
println!("RUSTTYPE + RUSTYBUZZ TEST:");
test_rusthbuzz(font, message);
let font = include_bytes!("../resources/Symbola-AjYx.ttf");
println!();
println!("RUSTTYPE + RUSTYBUZZ TEST:");
test_rusthbuzz(font, message);
}
// fn test_fontdue(font: &[u8], message: &str, _rtl: bool) {
@ -54,9 +84,32 @@ fn main() {
// }
fn test_rusthbuzz(font: &[u8], message: &str) {
const FB_WIDTH: usize = 520;
const FB_HEIGHT: usize = 200;
let mut buffer = [[0f32; FB_WIDTH]; FB_HEIGHT];
const FB_WIDTH: usize = 336;
const FB_HEIGHT: usize = 536;
let rusttype_height = 32.0;
let mut buffer = vec![];
for _ in 0..FB_HEIGHT {
buffer.push(vec![0f32; FB_WIDTH]);
}
use minifb::{Key, Window, WindowOptions};
let mut window = Window::new(
"Betrusted",
FB_WIDTH,
FB_HEIGHT,
WindowOptions {
scale_mode: minifb::ScaleMode::AspectRatioStretch,
resize: true,
..WindowOptions::default()
},
)
.unwrap_or_else(|e| {
panic!("{}", e);
});
const DARK_COLOUR: u32 = 0xB5B5AD;
const LIGHT_COLOUR: u32 = 0x1B1B19;
let mut native_buffer = vec![LIGHT_COLOUR; FB_WIDTH * FB_HEIGHT];
let lines = message.split('\n');
let reg = Region::new(&GLOBAL);
@ -64,140 +117,156 @@ fn test_rusthbuzz(font: &[u8], message: &str) {
println!("buzz_font: {:#?}", reg.change());
buzz_font.set_pixels_per_em(Some((196, 196)));
let mut buzz_buffer = rustybuzz::UnicodeBuffer::new();
println!("buzz_buffer: {:#?}", reg.change());
buzz_buffer.push_str(message);
println!("buzz_buffer_push: {:#?}", reg.change());
let buzz_features = vec![];
println!("buzz_features: {:#?}", reg.change());
let glyph_buffer = rustybuzz::shape(&buzz_font, &buzz_features, buzz_buffer);
println!("buzz_shape: {:#?}", reg.change());
let rusttype_font = Font::from_bytes(font).unwrap_or_else(|e| {
panic!("error constructing a FontCollection from bytes: {}", e);
});
println!("fonttype_collection: {:#?}", reg.change());
let mut cursor_x = 0.0;
let mut cursor_y = 0.0;
let rusttype_height = 196.0;
let rusttype_scale = rusttype::Scale {
x: rusttype_height * 1.0,
y: rusttype_height,
};
// Adapt the harfbuzz scale to rusttype's scale.
// I'm not sure where the "1.2" comes from, but the units only *just* match.
let harfbuzz_scale = rusttype_font.units_per_em() as f32 / rusttype_height * 1.2;
let v_metrics = rusttype_font.v_metrics(rusttype_scale);
let offset = point(0.0, v_metrics.ascent);
let mut buzz_buffer = rustybuzz::UnicodeBuffer::new();
println!("buzz_buffer: {:#?}", reg.change());
// println!("font is {} units-per-em", rusttype_font.units_per_em());
for (buzz_info, buzz_position) in glyph_buffer
.glyph_infos()
.iter()
.zip(glyph_buffer.glyph_positions().iter())
{
// let codepoint_rs = char::try_from(buzz_info.codepoint).expect("invalid codepoint");
let font_glyph = rusttype_font.glyph(rusttype::GlyphId(buzz_info.codepoint));
let glyph_scaled = font_glyph.scaled(rusttype_scale);
let x_offset = buzz_position.x_offset as f32 / harfbuzz_scale;
let y_offset = buzz_position.y_offset as f32 / harfbuzz_scale;
let x_advance = buzz_position.x_advance as f32 / harfbuzz_scale;
let y_advance = buzz_position.y_advance as f32 / harfbuzz_scale;
let glyph_positioned = glyph_scaled.positioned(rusttype::Point {
x: (x_offset as f32) + offset.x,
y: (y_offset as f32) + offset.y,
});
if let Some(bb) = glyph_positioned.pixel_bounding_box() {
// println!(
// "Offset: {} / {}, {} / {} {}/{} {}/{}",
// x_offset, y_offset,
// x_advance, y_advance,
// cursor_x, cursor_y,
// bb.min.x, bb.min.y,
// );
glyph_positioned.draw(|x, y, weight| {
let x = (x as f32) + ((cursor_x + x_offset) as f32) + (bb.min.x as f32);
let y = (y as f32) + ((cursor_y + y_offset) as f32) + (bb.min.y as f32);
if (x < 0.0)
|| (x >= (buffer[0].len() as f32))
|| (y < 0.0)
|| (y >= (buffer.len() as f32))
{
// println!("(x,y) out of bounds: ({}, {})", x, y);
return;
}
let x = x as usize;
let y = y as usize;
// if y < buffer.len() && x < buffer[0].len() {
buffer[y][x] += weight;
// }
for (line_number, line) in lines.enumerate() {
buzz_buffer.push_str(line);
println!("buzz_buffer_push: {:#?}", reg.change());
let glyph_buffer = rustybuzz::shape(&buzz_font, &buzz_features, buzz_buffer);
println!("buzz_shape: {:#?}", reg.change());
let rusttype_font =
Font::try_from_bytes(font).expect("error constructing a Font from bytes");
println!("fonttype_collection: {:#?}", reg.change());
let mut cursor_x = 0.0;
let mut cursor_y = (line_number as f32) * rusttype_height;
let rusttype_scale = rusttype::Scale {
x: rusttype_height * 1.0,
y: rusttype_height,
};
// Adapt the harfbuzz scale to rusttype's scale.
// I'm not sure where the "1.2" comes from, but the units only *just* match.
let harfbuzz_scale = rusttype_font.units_per_em() as f32 / rusttype_height * 1.0 /* * 1.2 */;
let v_metrics = rusttype_font.v_metrics(rusttype_scale);
let offset = point(0.0, v_metrics.ascent);
// println!("font is {} units-per-em", rusttype_font.units_per_em());
for (buzz_info, buzz_position) in glyph_buffer
.glyph_infos()
.iter()
.zip(glyph_buffer.glyph_positions().iter())
{
// let codepoint_rs = char::try_from(buzz_info.codepoint).expect("invalid codepoint");
let font_glyph = rusttype_font.glyph(rusttype::GlyphId(
buzz_info
.codepoint
.try_into()
.expect("codepoint out of range"),
));
let glyph_scaled = font_glyph.scaled(rusttype_scale);
let x_offset = buzz_position.x_offset as f32 / harfbuzz_scale;
let y_offset = buzz_position.y_offset as f32 / harfbuzz_scale;
let x_advance = buzz_position.x_advance as f32 / harfbuzz_scale;
let y_advance = buzz_position.y_advance as f32 / harfbuzz_scale;
let glyph_positioned = glyph_scaled.positioned(rusttype::Point {
x: (x_offset as f32) + offset.x,
y: (y_offset as f32) + offset.y,
});
}
cursor_x += x_advance;
cursor_y += y_advance;
}
// println!("Buffer: {:?}", buffer);
for y in (0..buffer.len() - 4).step_by(4) {
for x in (0..buffer[y].len() - 2).step_by(2) {
let mut offset = 0;
let threshold = 0.5;
if buffer[y + 0][x + 0] > threshold {
offset |= 1 << 0;
}
if buffer[y + 1][x + 0] > threshold {
offset |= 1 << 1;
}
if buffer[y + 2][x + 0] > threshold {
offset |= 1 << 2;
}
if buffer[y + 0][x + 1] > threshold {
offset |= 1 << 3;
}
if buffer[y + 1][x + 1] > threshold {
offset |= 1 << 4;
}
if buffer[y + 2][x + 1] > threshold {
offset |= 1 << 5;
if let Some(bb) = glyph_positioned.pixel_bounding_box() {
// println!(
// "Offset: {} / {}, {} / {} {}/{} {}/{}",
// x_offset, y_offset,
// x_advance, y_advance,
// cursor_x, cursor_y,
// bb.min.x, bb.min.y,
// );
glyph_positioned.draw(|x, y, weight| {
let x = (x as f32) + ((cursor_x + x_offset) as f32) + (bb.min.x as f32);
let y = (y as f32) + ((cursor_y + y_offset) as f32) + (bb.min.y as f32);
if (x < 0.0)
|| (x >= (buffer[0].len() as f32))
|| (y < 0.0)
|| (y >= (buffer.len() as f32))
{
// println!("(x,y) out of bounds: ({}, {})", x, y);
return;
}
let x = x as usize;
let y = y as usize;
// if y < buffer.len() && x < buffer[0].len() {
buffer[y][x] += weight;
// }
});
}
cursor_x += x_advance;
cursor_y += y_advance;
}
buzz_buffer = glyph_buffer.clear();
buzz_buffer.clear();
}
if buffer[y + 3][x + 0] > threshold {
offset |= 1 << 6;
}
if buffer[y + 3][x + 1] > threshold {
offset |= 1 << 7;
}
let pixel_br = std::char::from_u32(0x2800 + offset).unwrap();
print!("{}", pixel_br);
let mut offset = 0;
for line in &*buffer {
for pixel in line {
native_buffer[offset] = if pixel > &0.5 {
LIGHT_COLOUR
} else {
DARK_COLOUR
};
offset += 1;
}
println!();
}
window
.update_with_buffer(&native_buffer, FB_WIDTH, FB_HEIGHT)
.unwrap();
while window.is_open() && !window.is_key_down(Key::Escape) {
window.update();
}
// for y in (0..buffer.len() - 4).step_by(4) {
// for x in (0..buffer[y].len() - 2).step_by(2) {
// let mut offset = 0;
// let threshold = 0.5;
// if buffer[y + 0][x + 0] > threshold {
// offset |= 1 << 0;
// }
// if buffer[y + 1][x + 0] > threshold {
// offset |= 1 << 1;
// }
// if buffer[y + 2][x + 0] > threshold {
// offset |= 1 << 2;
// }
// if buffer[y + 0][x + 1] > threshold {
// offset |= 1 << 3;
// }
// if buffer[y + 1][x + 1] > threshold {
// offset |= 1 << 4;
// }
// if buffer[y + 2][x + 1] > threshold {
// offset |= 1 << 5;
// }
// if buffer[y + 3][x + 0] > threshold {
// offset |= 1 << 6;
// }
// if buffer[y + 3][x + 1] > threshold {
// offset |= 1 << 7;
// }
// let pixel_br = std::char::from_u32(0x2800 + offset).unwrap();
// print!("{}", pixel_br);
// }
// println!();
// }
}
fn test_rusttype(font: &[u8], message: &str, rtl: bool) {
let reg = Region::new(&GLOBAL);
let collection = FontCollection::from_bytes(font).unwrap_or_else(|e| {
panic!("error constructing a FontCollection from bytes: {}", e);
});
println!("collection: {:#?}", reg.change());
let font = collection
.into_font() // only succeeds if collection consists of one font
.unwrap_or_else(|e| {
panic!("error turning FontCollection into a Font: {}", e);
});
let font = Font::try_from_bytes(font).expect("couldn't read font file");
// Desired font pixel height
let height: f32 = 20.0; // to get 80 chars across (fits most terminals); adjust as desired

Loading…
Cancel
Save