Fix examples
This commit is contained in:
parent
8ec4f04deb
commit
0012f09eeb
|
@ -210,6 +210,7 @@ dependencies = [
|
||||||
name = "canvas_text"
|
name = "canvas_text"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pathfinder_canvas 0.1.0",
|
"pathfinder_canvas 0.1.0",
|
||||||
"pathfinder_geometry 0.3.0",
|
"pathfinder_geometry 0.3.0",
|
||||||
|
@ -495,13 +496,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dwrote"
|
name = "dwrote"
|
||||||
version = "0.5.1"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -605,23 +604,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "font-kit"
|
name = "font-kit"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cocoa 0.18.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-text 13.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"dwrote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -907,14 +901,6 @@ dependencies = [
|
||||||
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itertools"
|
|
||||||
version = "0.7.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
|
@ -1357,11 +1343,11 @@ dependencies = [
|
||||||
name = "pathfinder_canvas"
|
name = "pathfinder_canvas"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"font-kit 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pathfinder_geometry 0.3.0",
|
"pathfinder_geometry 0.3.0",
|
||||||
"pathfinder_renderer 0.1.0",
|
"pathfinder_renderer 0.1.0",
|
||||||
"pathfinder_text 0.1.0",
|
"pathfinder_text 0.1.0",
|
||||||
"skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a89e9ca99e0d6736ea1b7754517f4df14fd96a2b)",
|
"skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1509,11 +1495,11 @@ name = "pathfinder_text"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"font-kit 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lyon_path 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pathfinder_geometry 0.3.0",
|
"pathfinder_geometry 0.3.0",
|
||||||
"pathfinder_renderer 0.1.0",
|
"pathfinder_renderer 0.1.0",
|
||||||
"skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a89e9ca99e0d6736ea1b7754517f4df14fd96a2b)",
|
"skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1961,10 +1947,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "skribo"
|
name = "skribo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/linebender/skribo.git?rev=a89e9ca99e0d6736ea1b7754517f4df14fd96a2b#a89e9ca99e0d6736ea1b7754517f4df14fd96a2b"
|
source = "git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e#a2d683856ba1f2d0095b12dd7823d1602a87614e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"font-kit 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"harfbuzz 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"harfbuzz 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"harfbuzz-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"harfbuzz-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2439,7 +2425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
|
"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
|
||||||
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
|
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
|
||||||
"checksum downcast-rs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b92dfd5c2f75260cbf750572f95d387e7ca0ba5e3fbe9e1a33f23025be020f"
|
"checksum downcast-rs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b92dfd5c2f75260cbf750572f95d387e7ca0ba5e3fbe9e1a33f23025be020f"
|
||||||
"checksum dwrote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30a998e9ff70cd208ccdc4f864e998688bf61d7b897dccec8e17a884d17358bf"
|
"checksum dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bd1369e02db5e9b842a9b67bce8a2fcc043beafb2ae8a799dd482d46ea1ff0d"
|
||||||
"checksum egl 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a373bc9844200b1ff15bd1b245931d1c20d09d06e4ec09f361171f29a4b0752d"
|
"checksum egl 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a373bc9844200b1ff15bd1b245931d1c20d09d06e4ec09f361171f29a4b0752d"
|
||||||
"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b"
|
"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b"
|
||||||
"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a"
|
"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a"
|
||||||
|
@ -2452,7 +2438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
|
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
|
||||||
"checksum float-cmp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17ae3a6394183450225f33d9419cbd627b3cfc831e14f3f1146d5bcaf984e00c"
|
"checksum float-cmp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17ae3a6394183450225f33d9419cbd627b3cfc831e14f3f1146d5bcaf984e00c"
|
||||||
"checksum float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e"
|
"checksum float-ord 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e"
|
||||||
"checksum font-kit 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5be0133b580e2920076afd5bd4b81dc172d10e5653bd1c516476718d52347859"
|
"checksum font-kit 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c5b784f7a48d718df8d9ee28f81f8afa0a7ffdd61038957cba1ec6837a836d46"
|
||||||
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||||
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||||
"checksum freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "11926b2b410b469d0e9399eca4cbbe237a9ef02176c485803b29216307e8e028"
|
"checksum freetype 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "11926b2b410b469d0e9399eca4cbbe237a9ef02176c485803b29216307e8e028"
|
||||||
|
@ -2480,7 +2466,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebdff791af04e30089bde8ad2a632b86af433b40c04db8d70ad4b21487db7a6a"
|
"checksum image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebdff791af04e30089bde8ad2a632b86af433b40c04db8d70ad4b21487db7a6a"
|
||||||
"checksum image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "293e54ce142a936a39da748ba8178ae6aa1914b82d846a4278f11590c89bf116"
|
"checksum image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "293e54ce142a936a39da748ba8178ae6aa1914b82d846a4278f11590c89bf116"
|
||||||
"checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
|
"checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
|
||||||
"checksum itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d"
|
|
||||||
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
|
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
|
||||||
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
|
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
|
||||||
"checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3"
|
"checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3"
|
||||||
|
@ -2582,7 +2567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
|
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
|
||||||
"checksum simplecss 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "135685097a85a64067df36e28a243e94a94f76d829087ce0be34eeb014260c0e"
|
"checksum simplecss 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "135685097a85a64067df36e28a243e94a94f76d829087ce0be34eeb014260c0e"
|
||||||
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
|
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
|
||||||
"checksum skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a89e9ca99e0d6736ea1b7754517f4df14fd96a2b)" = "<none>"
|
"checksum skribo 0.0.1 (git+https://github.com/linebender/skribo.git?rev=a2d683856ba1f2d0095b12dd7823d1602a87614e)" = "<none>"
|
||||||
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||||
"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
|
"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
|
||||||
"checksum smithay-client-toolkit 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aa4899558362a65589b53313935099835acf999740915e134dff20cca7c6a28b"
|
"checksum smithay-client-toolkit 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aa4899558362a65589b53313935099835acf999740915e134dff20cca7c6a28b"
|
||||||
|
|
|
@ -129,7 +129,7 @@ typedef struct PFSceneProxy *PFSceneProxyRef;
|
||||||
|
|
||||||
PFCanvasRef PFCanvasCreate(PFCanvasFontContextRef font_context, const PFVector2F *size);
|
PFCanvasRef PFCanvasCreate(PFCanvasFontContextRef font_context, const PFVector2F *size);
|
||||||
void PFCanvasDestroy(PFCanvasRef canvas);
|
void PFCanvasDestroy(PFCanvasRef canvas);
|
||||||
PFCanvasFontContextRef PFCanvasFontContextCreate();
|
PFCanvasFontContextRef PFCanvasFontContextCreateWithSystemSource();
|
||||||
void PFCanvasFontContextDestroy(PFCanvasFontContextRef font_context);
|
void PFCanvasFontContextDestroy(PFCanvasFontContextRef font_context);
|
||||||
PFCanvasFontContextRef PFCanvasFontContextClone(PFCanvasFontContextRef font_context);
|
PFCanvasFontContextRef PFCanvasFontContextClone(PFCanvasFontContextRef font_context);
|
||||||
PFSceneRef PFCanvasCreateScene(PFCanvasRef canvas);
|
PFSceneRef PFCanvasCreateScene(PFCanvasRef canvas);
|
||||||
|
|
|
@ -148,8 +148,8 @@ pub unsafe extern "C" fn PFCanvasDestroy(canvas: PFCanvasRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn PFCanvasFontContextCreate() -> PFCanvasFontContextRef {
|
pub unsafe extern "C" fn PFCanvasFontContextCreateWithSystemSource() -> PFCanvasFontContextRef {
|
||||||
Box::into_raw(Box::new(CanvasFontContext::new()))
|
Box::into_raw(Box::new(CanvasFontContext::from_system_source()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
|
@ -8,7 +8,7 @@ edition = "2018"
|
||||||
crate-type = ["rlib", "staticlib"]
|
crate-type = ["rlib", "staticlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
font-kit = "0.1"
|
font-kit = "0.2"
|
||||||
|
|
||||||
[dependencies.pathfinder_geometry]
|
[dependencies.pathfinder_geometry]
|
||||||
path = "../geometry"
|
path = "../geometry"
|
||||||
|
@ -21,4 +21,4 @@ path = "../text"
|
||||||
|
|
||||||
[dependencies.skribo]
|
[dependencies.skribo]
|
||||||
git = "https://github.com/linebender/skribo.git"
|
git = "https://github.com/linebender/skribo.git"
|
||||||
rev = "a89e9ca99e0d6736ea1b7754517f4df14fd96a2b"
|
rev = "a2d683856ba1f2d0095b12dd7823d1602a87614e"
|
||||||
|
|
|
@ -11,9 +11,12 @@
|
||||||
//! A simple API for Pathfinder that mirrors a subset of HTML canvas.
|
//! A simple API for Pathfinder that mirrors a subset of HTML canvas.
|
||||||
|
|
||||||
use font_kit::family_name::FamilyName;
|
use font_kit::family_name::FamilyName;
|
||||||
|
use font_kit::handle::Handle;
|
||||||
use font_kit::hinting::HintingOptions;
|
use font_kit::hinting::HintingOptions;
|
||||||
|
use font_kit::loaders::default::Font;
|
||||||
use font_kit::properties::Properties;
|
use font_kit::properties::Properties;
|
||||||
use font_kit::source::SystemSource;
|
use font_kit::source::{Source, SystemSource};
|
||||||
|
use font_kit::sources::mem::MemSource;
|
||||||
use pathfinder_geometry::basic::line_segment::LineSegment2F;
|
use pathfinder_geometry::basic::line_segment::LineSegment2F;
|
||||||
use pathfinder_geometry::basic::vector::Vector2F;
|
use pathfinder_geometry::basic::vector::Vector2F;
|
||||||
use pathfinder_geometry::basic::rect::RectF;
|
use pathfinder_geometry::basic::rect::RectF;
|
||||||
|
@ -29,6 +32,7 @@ use pathfinder_text::{SceneExt, TextRenderMode};
|
||||||
use skribo::{FontCollection, FontFamily, Layout, TextStyle};
|
use skribo::{FontCollection, FontFamily, Layout, TextStyle};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
use std::iter;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -170,6 +174,40 @@ impl CanvasRenderingContext2D {
|
||||||
|
|
||||||
// Text styles
|
// Text styles
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_font_collection(&mut self, font_collection: Arc<FontCollection>) {
|
||||||
|
self.current_state.font_collection = font_collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_font_families<I>(&mut self, font_families: I) where I: Iterator<Item = FontFamily> {
|
||||||
|
let mut font_collection = FontCollection::new();
|
||||||
|
for font_family in font_families {
|
||||||
|
font_collection.add_family(font_family);
|
||||||
|
}
|
||||||
|
self.current_state.font_collection = Arc::new(font_collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A convenience method to set a single font family.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_font_family(&mut self, font_family: FontFamily) {
|
||||||
|
self.set_font_families(iter::once(font_family))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A convenience method to set a single font family consisting of a single font.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_font(&mut self, font: Font) {
|
||||||
|
self.set_font_family(FontFamily::new_from_font(font))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A convenience method to set a single font family consisting of a font
|
||||||
|
/// described by a PostScript name.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_font_by_postscript_name(&mut self, postscript_name: &str) {
|
||||||
|
let font = self.font_context.font_source.select_by_postscript_name(postscript_name);
|
||||||
|
self.set_font(font.expect("Didn't find the font!").load().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_font_size(&mut self, new_font_size: f32) {
|
pub fn set_font_size(&mut self, new_font_size: f32) {
|
||||||
self.current_state.font_size = new_font_size;
|
self.current_state.font_size = new_font_size;
|
||||||
|
@ -509,29 +547,37 @@ pub struct TextMetrics {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CanvasFontContext {
|
pub struct CanvasFontContext {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
font_source: Arc<SystemSource>,
|
font_source: Arc<dyn Source>,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
default_font_collection: Arc<FontCollection>,
|
default_font_collection: Arc<FontCollection>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CanvasFontContext {
|
impl CanvasFontContext {
|
||||||
pub fn new() -> CanvasFontContext {
|
pub fn new(font_source: Arc<dyn Source>) -> CanvasFontContext {
|
||||||
let font_source = Arc::new(SystemSource::new());
|
|
||||||
|
|
||||||
let mut default_font_collection = FontCollection::new();
|
let mut default_font_collection = FontCollection::new();
|
||||||
let default_font =
|
if let Ok(default_font) = font_source.select_best_match(&[FamilyName::SansSerif],
|
||||||
font_source.select_best_match(&[FamilyName::SansSerif], &Properties::new())
|
&Properties::new()) {
|
||||||
.expect("Failed to select the default font!")
|
if let Ok(default_font) = default_font.load() {
|
||||||
.load()
|
|
||||||
.expect("Failed to load the default font!");
|
|
||||||
default_font_collection.add_family(FontFamily::new_from_font(default_font));
|
default_font_collection.add_family(FontFamily::new_from_font(default_font));
|
||||||
let default_font_collection = Arc::new(default_font_collection);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CanvasFontContext {
|
CanvasFontContext {
|
||||||
font_source,
|
font_source,
|
||||||
default_font_collection,
|
default_font_collection: Arc::new(default_font_collection),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A convenience method to create a font context with the system source.
|
||||||
|
/// This allows usage of fonts installed on the system.
|
||||||
|
pub fn from_system_source() -> CanvasFontContext {
|
||||||
|
CanvasFontContext::new(Arc::new(SystemSource::new()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A convenience method to create a font context with a set of in-memory fonts.
|
||||||
|
pub fn from_fonts<I>(fonts: I) -> CanvasFontContext where I: Iterator<Item = Handle> {
|
||||||
|
CanvasFontContext::new(Arc::new(MemSource::from_fonts(fonts).unwrap()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text layout utilities
|
// Text layout utilities
|
||||||
|
|
|
@ -64,7 +64,7 @@ int main(int argc, const char **argv) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make a canvas. We're going to draw a house.
|
// Make a canvas. We're going to draw a house.
|
||||||
PFCanvasRef canvas = PFCanvasCreate(PFCanvasFontContextCreate(),
|
PFCanvasRef canvas = PFCanvasCreate(PFCanvasFontContextCreateWithSystemSource(),
|
||||||
&(PFVector2F){640.0f, 480.0f});
|
&(PFVector2F){640.0f, 480.0f});
|
||||||
|
|
||||||
// Set line width.
|
// Set line width.
|
||||||
|
|
|
@ -54,7 +54,8 @@ fn main() {
|
||||||
RendererOptions { background_color: Some(ColorF::white()) });
|
RendererOptions { background_color: Some(ColorF::white()) });
|
||||||
|
|
||||||
// Make a canvas. We're going to draw a house.
|
// Make a canvas. We're going to draw a house.
|
||||||
let mut canvas = CanvasRenderingContext2D::new(CanvasFontContext::new(), window_size.to_f32());
|
let mut canvas = CanvasRenderingContext2D::new(CanvasFontContext::from_system_source(),
|
||||||
|
window_size.to_f32());
|
||||||
|
|
||||||
// Set line width.
|
// Set line width.
|
||||||
canvas.set_line_width(10.0);
|
canvas.set_line_width(10.0);
|
||||||
|
|
|
@ -52,7 +52,8 @@ fn main() {
|
||||||
RendererOptions { background_color: Some(ColorF::white()) });
|
RendererOptions { background_color: Some(ColorF::white()) });
|
||||||
|
|
||||||
// Make a canvas. We're going to draw a house.
|
// Make a canvas. We're going to draw a house.
|
||||||
let mut canvas = CanvasRenderingContext2D::new(CanvasFontContext::new(), window_size.to_f32());
|
let mut canvas = CanvasRenderingContext2D::new(CanvasFontContext::from_system_source(),
|
||||||
|
window_size.to_f32());
|
||||||
|
|
||||||
// Set line width.
|
// Set line width.
|
||||||
canvas.set_line_width(10.0);
|
canvas.set_line_width(10.0);
|
||||||
|
|
|
@ -52,7 +52,8 @@ fn main() {
|
||||||
RendererOptions { background_color: Some(ColorF::white()) });
|
RendererOptions { background_color: Some(ColorF::white()) });
|
||||||
|
|
||||||
// Make a canvas. We're going to draw a house.
|
// Make a canvas. We're going to draw a house.
|
||||||
let mut canvas = CanvasRenderingContext2D::new(CanvasFontContext::new(), window_size.to_f32());
|
let mut canvas = CanvasRenderingContext2D::new(CanvasFontContext::from_system_source(),
|
||||||
|
window_size.to_f32());
|
||||||
|
|
||||||
// Set line width.
|
// Set line width.
|
||||||
canvas.set_line_width(10.0);
|
canvas.set_line_width(10.0);
|
||||||
|
|
|
@ -100,7 +100,7 @@ impl MoireRenderer {
|
||||||
-> MoireRenderer {
|
-> MoireRenderer {
|
||||||
MoireRenderer {
|
MoireRenderer {
|
||||||
renderer,
|
renderer,
|
||||||
font_context: CanvasFontContext::new(),
|
font_context: CanvasFontContext::from_system_source(),
|
||||||
scene: SceneProxy::new(RayonExecutor),
|
scene: SceneProxy::new(RayonExecutor),
|
||||||
frame: 0,
|
frame: 0,
|
||||||
window_size,
|
window_size,
|
||||||
|
|
|
@ -5,6 +5,7 @@ authors = ["Patrick Walton <pcwalton@mimiga.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
font-kit = "0.2"
|
||||||
gl = "0.6"
|
gl = "0.6"
|
||||||
sdl2 = "0.32"
|
sdl2 = "0.32"
|
||||||
sdl2-sys = "0.32"
|
sdl2-sys = "0.32"
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
use font_kit::handle::Handle;
|
||||||
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, TextAlign};
|
use pathfinder_canvas::{CanvasFontContext, CanvasRenderingContext2D, TextAlign};
|
||||||
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I};
|
use pathfinder_geometry::basic::vector::{Vector2F, Vector2I};
|
||||||
use pathfinder_geometry::color::ColorF;
|
use pathfinder_geometry::color::ColorF;
|
||||||
use pathfinder_gl::{GLDevice, GLVersion};
|
use pathfinder_gl::{GLDevice, GLVersion};
|
||||||
use pathfinder_gpu::resources::FilesystemResourceLoader;
|
use pathfinder_gpu::resources::{FilesystemResourceLoader, ResourceLoader};
|
||||||
use pathfinder_renderer::concurrent::rayon::RayonExecutor;
|
use pathfinder_renderer::concurrent::rayon::RayonExecutor;
|
||||||
use pathfinder_renderer::concurrent::scene_proxy::SceneProxy;
|
use pathfinder_renderer::concurrent::scene_proxy::SceneProxy;
|
||||||
use pathfinder_renderer::gpu::options::{DestFramebuffer, RendererOptions};
|
use pathfinder_renderer::gpu::options::{DestFramebuffer, RendererOptions};
|
||||||
|
@ -21,6 +22,8 @@ use pathfinder_renderer::options::BuildOptions;
|
||||||
use sdl2::event::Event;
|
use sdl2::event::Event;
|
||||||
use sdl2::keyboard::Keycode;
|
use sdl2::keyboard::Keycode;
|
||||||
use sdl2::video::GLProfile;
|
use sdl2::video::GLProfile;
|
||||||
|
use std::iter;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Set up SDL2.
|
// Set up SDL2.
|
||||||
|
@ -45,15 +48,22 @@ fn main() {
|
||||||
window.gl_make_current(&gl_context).unwrap();
|
window.gl_make_current(&gl_context).unwrap();
|
||||||
|
|
||||||
// Create a Pathfinder renderer.
|
// Create a Pathfinder renderer.
|
||||||
|
let resource_loader = FilesystemResourceLoader::locate();
|
||||||
let mut renderer = Renderer::new(GLDevice::new(GLVersion::GL3, 0),
|
let mut renderer = Renderer::new(GLDevice::new(GLVersion::GL3, 0),
|
||||||
&FilesystemResourceLoader::locate(),
|
&resource_loader,
|
||||||
DestFramebuffer::full_window(window_size),
|
DestFramebuffer::full_window(window_size),
|
||||||
RendererOptions { background_color: Some(ColorF::white()) });
|
RendererOptions { background_color: Some(ColorF::white()) });
|
||||||
|
|
||||||
// Make a canvas. We're going to draw some text.
|
// Load a font.
|
||||||
let mut canvas = CanvasRenderingContext2D::new(CanvasFontContext::new(), window_size.to_f32());
|
let font_data = Arc::new(resource_loader.slurp("fonts/overpass-regular.otf").unwrap());
|
||||||
|
let font = Handle::from_memory(font_data, 0);
|
||||||
|
let font_context = CanvasFontContext::from_fonts(iter::once(font));
|
||||||
|
|
||||||
|
// Make a canvas.
|
||||||
|
let mut canvas = CanvasRenderingContext2D::new(font_context, window_size.to_f32());
|
||||||
|
|
||||||
// Draw the text.
|
// Draw the text.
|
||||||
|
canvas.set_font_by_postscript_name("Overpass-Regular");
|
||||||
canvas.set_font_size(32.0);
|
canvas.set_font_size(32.0);
|
||||||
canvas.fill_text("Hello Pathfinder!", Vector2F::new(32.0, 48.0));
|
canvas.fill_text("Hello Pathfinder!", Vector2F::new(32.0, 48.0));
|
||||||
canvas.set_text_align(TextAlign::Right);
|
canvas.set_text_align(TextAlign::Right);
|
||||||
|
|
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
euclid = "0.19"
|
euclid = "0.19"
|
||||||
font-kit = "0.1"
|
font-kit = "0.2"
|
||||||
lyon_path = "0.12"
|
lyon_path = "0.12"
|
||||||
|
|
||||||
[dependencies.pathfinder_geometry]
|
[dependencies.pathfinder_geometry]
|
||||||
|
@ -17,4 +17,4 @@ path = "../renderer"
|
||||||
|
|
||||||
[dependencies.skribo]
|
[dependencies.skribo]
|
||||||
git = "https://github.com/linebender/skribo.git"
|
git = "https://github.com/linebender/skribo.git"
|
||||||
rev = "a89e9ca99e0d6736ea1b7754517f4df14fd96a2b"
|
rev = "a2d683856ba1f2d0095b12dd7823d1602a87614e"
|
||||||
|
|
Loading…
Reference in New Issue