font rendering test, ahash, F32 new type
This commit is contained in:
parent
44076fb5f0
commit
be9f00f63f
|
@ -32,6 +32,7 @@ tinyvec = "1.8"
|
||||||
indexmap = "2"
|
indexmap = "2"
|
||||||
petgraph = "0.7"
|
petgraph = "0.7"
|
||||||
itertools = "0.14.0"
|
itertools = "0.14.0"
|
||||||
|
ahash = "0.8"
|
||||||
|
|
||||||
parking_lot = "0.12.3"
|
parking_lot = "0.12.3"
|
||||||
|
|
||||||
|
|
Binary file not shown.
BIN
assets/fonts/Noto_Sans/NotoSans-VariableFont_wdth,wght.ttf
Normal file
BIN
assets/fonts/Noto_Sans/NotoSans-VariableFont_wdth,wght.ttf
Normal file
Binary file not shown.
93
assets/fonts/Noto_Sans/OFL.txt
Normal file
93
assets/fonts/Noto_Sans/OFL.txt
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://openfontlicense.org
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
BIN
assets/fonts/Noto_Sans_SC/NotoSansSC-VariableFont_wght.ttf
Normal file
BIN
assets/fonts/Noto_Sans_SC/NotoSansSC-VariableFont_wght.ttf
Normal file
Binary file not shown.
93
assets/fonts/Noto_Sans_SC/OFL.txt
Normal file
93
assets/fonts/Noto_Sans_SC/OFL.txt
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://openfontlicense.org
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
93
assets/fonts/Roboto/OFL.txt
Normal file
93
assets/fonts/Roboto/OFL.txt
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
Copyright 2011 The Roboto Project Authors (https://github.com/googlefonts/roboto-classic)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://openfontlicense.org
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
BIN
assets/fonts/Roboto/Roboto-Italic-VariableFont_wdth,wght.ttf
Normal file
BIN
assets/fonts/Roboto/Roboto-Italic-VariableFont_wdth,wght.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/Roboto/Roboto-VariableFont_wdth,wght.ttf
Normal file
BIN
assets/fonts/Roboto/Roboto-VariableFont_wdth,wght.ttf
Normal file
Binary file not shown.
266
assets/testing/hello.txt
Normal file
266
assets/testing/hello.txt
Normal file
|
@ -0,0 +1,266 @@
|
||||||
|
https://en.wiktionary.org/wiki/hello#Translations
|
||||||
|
Abkhaz: бзиа збаша (bzia zbaša), мыш бзи (məš bzi), (to a man) бзиара убааит (bziara ubaaiṭ), (to a woman) бзиара ббааит (bziara bbaaiṭ), (to more than one person) бзиара жәбааит pl (bziara ž°baaiṭ)
|
||||||
|
Afrikaans: hallo (af), goeiedag
|
||||||
|
Ainu: イランカラㇷ゚テ (irankarapte)
|
||||||
|
Albanian: tungjatjeta (sq), tung (informal), ç'kemi m or f
|
||||||
|
|
||||||
|
Arbëreshë Albanian: falem (sq)
|
||||||
|
|
||||||
|
Alemannic German: sälü, hoi, hello
|
||||||
|
Aleut: aang, draas
|
||||||
|
Ambonese Malay: wai
|
||||||
|
American Sign Language: B@Sfhead-PalmForward B@FromSfhead-PalmForward
|
||||||
|
Amharic: ሰላም (sälam)
|
||||||
|
Apache:
|
||||||
|
|
||||||
|
Jicarilla: dá nzhǫ́
|
||||||
|
Western Apache: dagotʼee, daʼanzho, yaʼateh
|
||||||
|
|
||||||
|
Arabic: السَّلَامُ عَلَيْكُمْ (ar) (as-salāmu ʿalaykum), سَلَام (ar) (salām), مَرْحَبًا (ar) (marḥaban), أَهْلًا (ar) (ʾahlan)
|
||||||
|
|
||||||
|
Egyptian Arabic: اهلاً (ahlan)
|
||||||
|
Iraqi Arabic: هلو (helaww)
|
||||||
|
|
||||||
|
Archi: салам алейкум (salam alejkum), варчӀами (warčʼami)
|
||||||
|
Armenian: բարև (hy) (barew), ողջույն (hy) (ołǰuyn)
|
||||||
|
Assamese: নমস্কাৰ (nomoskar) (very formal), আচ্চেলামো আলাইকোম (asselamü alaiküm) (formal, used among Muslims), হেল’ (helö)
|
||||||
|
Assyrian Neo-Aramaic: ܫܠܵܡܵܐ (šlama), (to a man) ܫܠܵܡܵܐ ܥܲܠܘܼܟ݂ (šlama ʿāloḳ), (to a woman) ܫܠܵܡܵܐ ܥܲܠܵܟ݂ܝ (šlama ʿālaḳ), (to more than one person) ܫܠܵܡܵܐ ܥܲܠܵܘܟ݂ܘܿܢ (šlama ʿāloḳon)
|
||||||
|
Asturian: hola (ast)
|
||||||
|
Azerbaijani: salam (az), səlam (South Azerbaijani), hər vaxtınız xeyir olsun, hər vaxtınız xeyir
|
||||||
|
Bashkir: сәләм (säläm)
|
||||||
|
Basque: kaixo (eu)
|
||||||
|
Bats: please add this translation if you can
|
||||||
|
Bavarian: servus, grias di, pfiati (Timau)
|
||||||
|
Belarusian: віта́ю (vitáju), здаро́ў (zdaróŭ) (colloquial), до́бры дзень (dóbry dzjenʹ) (good day)
|
||||||
|
Bengali: নমস্কার (bn) (nômôśkar), আসসালামুআলাইকুম (aśśalamualaikum), সালাম (śalam), হ্যালো (hjalo)
|
||||||
|
Bhojpuri: प्रणाम (praṇām)
|
||||||
|
Bouyei: mengz ndil
|
||||||
|
Bulgarian: здра́сти (bg) (zdrásti) (familiar), здраве́й (bg) sg (zdravéj) (familiar), здраве́йте (bg) pl (zdravéjte) (formal)
|
||||||
|
Burmese: မင်္ဂလာပါ (my) (mangga.lapa) , ဟဲလို (my) (hai:lui) (colloquial)
|
||||||
|
Catalan: hola (ca)
|
||||||
|
Cayuga: sgę́:nǫʔ
|
||||||
|
Central Atlas Tamazight: ⴰⵣⵓⵍ (azul)
|
||||||
|
Chamorro: håfa adai
|
||||||
|
Chechen: маршалла ду хьоьга (maršalla du ḥöga) (to one person), маршалла ду шуьга (maršalla du šüga) (to a group of people), ассаламу ӏалайкум (assalamu ʿalajkum)
|
||||||
|
Cherokee: ᎣᏏᏲ (chr) (osiyo)
|
||||||
|
Chichewa: moni
|
||||||
|
Chickasaw: chokma
|
||||||
|
Chinese:
|
||||||
|
|
||||||
|
Cantonese: 你好 (nei5 hou2), 哈佬 (haa1 lou2)
|
||||||
|
Dungan: ни хо (ni ho), сэляму (seli͡amu), хома (homa)
|
||||||
|
Hakka: 你好 (ngì-hó)
|
||||||
|
Mandarin: 你好 (zh) (nǐ hǎo), 您好 (zh) (nín hǎo) (polite), 你們好, 你们好 (nǐmen hǎo) (to a group of people), 好 (zh) (hǎo) (following an address form or name), 嗨 (zh) (hāi), 哈囉 (zh), 哈啰 (zh) (hāluó)
|
||||||
|
Min Dong: 汝好 (nṳ̄ hō̤)
|
||||||
|
Min Nan: 汝好 (lí hó)
|
||||||
|
Xiang: please add this translation if you can
|
||||||
|
Wu: 儂好, 侬好 (non hau)
|
||||||
|
|
||||||
|
Choctaw: halito
|
||||||
|
Chukchi: еттык (ettyk) (formal), ети (eti) (informal), етти (etti) (informal)
|
||||||
|
Coptic: ⲛⲟϥⲣⲓ (nofri)
|
||||||
|
Cornish: dydh da
|
||||||
|
Corsican: bonghjornu
|
||||||
|
Cree:
|
||||||
|
|
||||||
|
Plains Cree: tânisi
|
||||||
|
|
||||||
|
Czech: ahoj (cs), nazdar (cs) (informal), servus (cs) (informal), dobrý den (cs) (formal)
|
||||||
|
Danish: hej (da), dav (da), god dag (formal), hallo (da)
|
||||||
|
Dhivehi: އައްސަލާމު ޢަލައިކުމް (assalāmu ʿalaikum̊)
|
||||||
|
Dutch: hallo (nl), hoi (nl), hai (nl), hé (nl), dag (nl) (informal), goeiedag (nl), goededag (nl), goedendag (nl), goeiendag (nl) (formal)
|
||||||
|
Esperanto: saluton (eo)
|
||||||
|
Estonian: tere (et), hei (et)
|
||||||
|
Faroese: hey, halló
|
||||||
|
Fijian: bula (fj)
|
||||||
|
Finnish: terve (fi), moi (fi), hei (fi), moikka (fi)
|
||||||
|
French: bonjour (fr), salut (fr) (informal), coucou (fr)(informal), cocorico (fr)
|
||||||
|
Friulian: mandi
|
||||||
|
Galician: ola (gl), oula, ouga
|
||||||
|
Georgian: გამარჯობა (ka) (gamarǯoba), ჰეი (hei)
|
||||||
|
German: hallo (de), guten Tag (de), servus (de), moin (de), grüß Gott (de) (Southern German, Austria)
|
||||||
|
|
||||||
|
Alemannic German: grüezi
|
||||||
|
|
||||||
|
Gilbertese: mauri
|
||||||
|
Gothic: 𐌷𐌰𐌹𐌻𐍃 (hails), 𐌷𐌰𐌹𐌻𐌰 (haila)
|
||||||
|
Greek: γεια (el) (geia), γεια σου sg (geia sou), γεια σας pl (geia sas), χαίρετε (el) (chaírete)
|
||||||
|
|
||||||
|
Ancient: χαῖρε sg (khaîre), χαίρετε pl (khaírete), χαῖρε καί ὑγίαινε sg (khaîre kaí hugíaine)
|
||||||
|
|
||||||
|
Greenlandic: aluu (kl)
|
||||||
|
Guaraní: maitei (gn)
|
||||||
|
Gujarati: નમસ્તે (namaste), નમસ્કાર (namaskār)
|
||||||
|
Haitian Creole: bonjou
|
||||||
|
Hausa: sannu
|
||||||
|
Hawaiian: aloha
|
||||||
|
Hebrew: שָׁלוֹם (he) (shalóm), שָׁלוֹם עָלֵיכֶם (he) (shalóm 'aleikhém)
|
||||||
|
Hindi: नमस्ते (hi) (namaste), नमस्कार (hi) (namaskār), सलाम (hi) (salām) (used by Muslims), सत श्री अकाल (sat śrī akāl) (Sikh, hello/goodbye), हेलो (hi) (helo), हलो (halo), सत्य (hi) (satya), आदाब (hi) (ādāb)
|
||||||
|
Hmong:
|
||||||
|
Green Hmong: nyob zoo
|
||||||
|
White Hmong: nyob zoo
|
||||||
|
Hungarian: szia (hu), sziasztok (hu) pl (informal), szervusz (hu), szervusztok pl (somewhat formal), heló (hu), helló (hu) (informal), jó napot (hu), jó napot kívánok (hu) (formal), üdvözlöm
|
||||||
|
Icelandic: halló (is), hæ (is), góðan dag (is), góðan daginn (is)
|
||||||
|
Ido: hola (io)
|
||||||
|
Igbo: kèdu
|
||||||
|
Indonesian: hai (id), salam (id)
|
||||||
|
Interlingua: bon die, salute (ia)
|
||||||
|
Irish: Dia dhuit (formal, singular), Dia dhaoibh (formal, plural), Dia's Muire dhuit (formal, singular, response), Dia's Muire dhaoibh (formal, plural, response)
|
||||||
|
Isan: please add this translation if you can
|
||||||
|
Italian: ciao (it), salve (it), buongiorno (it), saluti (it) m pl
|
||||||
|
Iu Mien: yiem longx nyei
|
||||||
|
Jamaican Creole: ello, wah gwaan
|
||||||
|
Japanese: おはよう (ja) (ohayō) (morning), こんにちは (ja) (konnichi wa) (daytime), こんばんは (ja) (konban wa) (evening)
|
||||||
|
Javanese: halo
|
||||||
|
Jeju: 반갑수다 (ban-gapsuda), 펜안ᄒᆞ우꽈 (pen-anhawukkwa), 펜안 (pen-an)
|
||||||
|
Judeo-Tat: шолум (şolum)
|
||||||
|
Kabardian: уузыншэм (wwzənšăm)
|
||||||
|
Kabyle: azul
|
||||||
|
Kalmyk: мендвт (mendvt), менд (mend) (informal)
|
||||||
|
Kannada: ತುಳಿಲು (kn) (tuḷilu), ನಮಸ್ಕಾರ (kn) (namaskāra)
|
||||||
|
Karachay-Balkar: кюнюгюз ашхы болсун (künügüz aşxı bolsun), ассаламу алейкум (assalamu aleykum)
|
||||||
|
Karelian: terveh, hei
|
||||||
|
Kazakh: сәлем (kk) (sälem) (informal), сәлеметсіздер (sälemetsızder) (formal)
|
||||||
|
Khmer: ជំរាបសួរ (cumriəp suə), សួស្តី (suəsdəy)
|
||||||
|
Khün: please add this translation if you can
|
||||||
|
Kinyarwanda: muraho
|
||||||
|
Korean: 안녕하십니까 (annyeonghasimnikka) (formal), 안녕하세요 (ko) (annyeonghaseyo) (neutrally formal), 안녕(安寧) (ko) (annyeong) (informal)
|
||||||
|
Krio: kushɛ
|
||||||
|
Kurdish:
|
||||||
|
|
||||||
|
Northern Kurdish: merheba (ku), silav (ku), selam (ku)
|
||||||
|
|
||||||
|
Kyrgyz: саламатсыздарбы (salamatsızdarbı), салам (ky) (salam)
|
||||||
|
Ladino: shalom, bonjur, buenos diyas
|
||||||
|
Lak: салам (salam)
|
||||||
|
Lakota: háu
|
||||||
|
Lao: ສະບາຍດີ (sa bāi dī)
|
||||||
|
Latin: salvē (la) sg, salvēte (la) pl; avē (la) sg, avēte pl
|
||||||
|
Latvian: sveiki (informal to more than one person or people of indeterminate gender), sveiks (to a man), sveika (to a woman), čau (informal)
|
||||||
|
Laz: გეგაჯგინას (gegaǯginas)
|
||||||
|
Lezgi: салам (salam)
|
||||||
|
Lithuanian: labas (lt), sveikas (lt) (informal), sveiki (lt) (formal)
|
||||||
|
Livonian: tēriņtš
|
||||||
|
Luo: msawa
|
||||||
|
Lü: ᦍᦲᧃᦡᦲ (yiinḋii)
|
||||||
|
Luxembourgish: hallo
|
||||||
|
Macedonian: здраво (zdravo)
|
||||||
|
Malagasy: manao ahoana? (mg), salama (mg) (Tsimihety)
|
||||||
|
Malay: helo (ms), apa khabar (ms), salam (ms)
|
||||||
|
Malayalam: ഹലോ (halō), നമസ്തേ (ml) (namastē), നമസ്കാരം (ml) (namaskāraṃ)
|
||||||
|
Maltese: bonġu (mt) (before noon), bonswa (after noon), nsellimlek (formal one to one person), nsellmilkom (formal one to more than one person), nsellmulek (formal more than one person to one person), nsellmulkom (formal more than one person to more than one persons)
|
||||||
|
Manchu: ᠰᠠᡳᠶᡡᠨ (saiyūn)
|
||||||
|
Maori: kia ora (mi) (informal), tēnā koe (formal to one person), tēnā kōrua (formal to two people), tēnā koutou (formal to three or more people)
|
||||||
|
Mapudungun: mari mari
|
||||||
|
Maranungku: yo
|
||||||
|
Marathi: नमस्कार (mr) (namaskār)
|
||||||
|
Michif: tánishi, boñjour
|
||||||
|
Mingrelian: გომორძგუა (gomorʒgua)
|
||||||
|
Mohawk: sekoh
|
||||||
|
Mongolian:
|
||||||
|
|
||||||
|
Cyrillic: сайн уу? (mn) (sayn uu?) (informal), сайн байна уу? (mn) (sayn bayna uu?)
|
||||||
|
|
||||||
|
Mopan Maya: dʼyoos
|
||||||
|
Nahuatl: niltze (nah), panoltih
|
||||||
|
Navajo: yáʼátʼééh
|
||||||
|
Neapolitan: uè
|
||||||
|
Nepali: नमस्ते (ne) (namaste), नमस्कार (ne) (namaskār)
|
||||||
|
Norman: baon-n-jour (Guernsey), banjour (Guernsey), boujouo (continental Normandy), bouônjour (Jersey), bwõju (Sark)
|
||||||
|
Northern Thai: สบายดีก่อ
|
||||||
|
Norwegian:
|
||||||
|
|
||||||
|
Bokmål: hallo (no), hei (no), god dag (no) (formal), halla (no) (informal), heisann
|
||||||
|
|
||||||
|
Ojibwe: boozhoo
|
||||||
|
Okinawan: はいさい m (haisai), はいたい f (haitai), はい n (hai)
|
||||||
|
Old English: wes hāl
|
||||||
|
Oriya: ନମସ୍କାର (or) (nômôskarô)
|
||||||
|
Ossetian: салам (salam), байрай (bajraj), арфӕ (arfæ)
|
||||||
|
Palauan: alii
|
||||||
|
Pashto: سلام (ps) (salām), سلام الېک (slāmālék), السلام عليکم (as-salám alaykúm)
|
||||||
|
Persian: سلام (fa) (salâm), سلام علیکم (salâmo alaykom) (religious), درود (fa) (dorud) (literary)
|
||||||
|
Pitcairn-Norfolk: watawieh
|
||||||
|
Polish: cześć (pl) (informal), witaj (pl), witajcie, witam (more formal), dzień dobry (pl) (formal), siema (pl) (informal), halo (pl) (on phone), serwus (pl) (colloquial), cześka (colloquial), siemanero (colloquial)
|
||||||
|
Portuguese: oi (pt), olá (pt), (slang) e aí? (pt)
|
||||||
|
Punjabi: ਸਤਿ ਸ਼੍ਰੀ ਅਕਾਲ (sati śrī akāl)
|
||||||
|
Rapa Nui: 'iorana
|
||||||
|
Romani: te aves baxtalo (to a male), te aves baxtali (to a female), te aven baxtale (to two or more people)
|
||||||
|
Romanian: salut (ro), bună (ro), noroc (ro) (informal), bună ziua (formal), servus (ro)
|
||||||
|
Russian: приве́т (ru) (privét) (informal), здоро́во (ru) (zdoróvo) (colloquial), здра́вствуйте (ru) (zdrávstvujte) (formal, first "в" is silent), до́брый день (ru) (dóbryj denʹ), здра́вствуй (ru) (zdrávstvuj) (informal, first "в" is silent), салю́т (ru) (saljút)
|
||||||
|
Rusyn: наздар (nazdar)
|
||||||
|
Sami:
|
||||||
|
|
||||||
|
Inari Sami: tiervâ
|
||||||
|
Northern: dearvva, būres
|
||||||
|
Skolt: tiõrv
|
||||||
|
Southern: buaregh
|
||||||
|
|
||||||
|
Samoan: talofa
|
||||||
|
Sanskrit: नमस्कार (sa) (namaskāra), नमस्ते (namaste), नमो नमः (namo namaḥ) (formal)
|
||||||
|
Scots: hullo
|
||||||
|
Scottish Gaelic: halò (informal), latha math (formal), (informal) hòigh
|
||||||
|
Serbo-Croatian:
|
||||||
|
|
||||||
|
Cyrillic: здра̏во, ћа̑о, ме̏рха̄ба, селам, бог, бок
|
||||||
|
Roman: zdrȁvo (sh), ćȃo (sh), mȅrhāba, selam (sh), bog, bok (sh)
|
||||||
|
|
||||||
|
Sesotho: lumela
|
||||||
|
Shan: please add this translation if you can
|
||||||
|
Shona: mhoro
|
||||||
|
Sichuan Yi: please add this translation if you can
|
||||||
|
Sicilian: ciao, salutamu
|
||||||
|
Sindhi: هيلو
|
||||||
|
Sinhalese: හලෝ (halō), ආයුබෝවන් (si) (āyubōwan)
|
||||||
|
Situ: please add this translation if you can
|
||||||
|
Slovak: ahoj (sk), nazdar (informal), servus (sk) (informal), dobrý deň (formal)
|
||||||
|
Slovene: žívjo, zdrávo (informal), dóber dán, pozdravljeni (formal)
|
||||||
|
Somali: ma nabad baa, waa nabad
|
||||||
|
Sorbian:
|
||||||
|
|
||||||
|
Lower Sorbian: dobry źeń
|
||||||
|
|
||||||
|
Sotho: dumela (st)
|
||||||
|
Spanish: hola (es), buenos días (es), qué tal, buenas tardes (es)
|
||||||
|
Sundanese: halo
|
||||||
|
Svan: ხოჩა ლადა̈ღ (xoča ladäɣ)
|
||||||
|
Swahili: jambo (sw), salaam
|
||||||
|
Swedish: hallå (sv), hej (sv), god dag (sv) (formal), tjena (sv), hejsan (sv) (informal), tja (sv)
|
||||||
|
Tagalog: kamusta (tl)/kumusta (tl), musta (tl) (slang), hoy (tl), huy, oy/oi (informal), uy/ui (informal)
|
||||||
|
Tajik: салом (salom)
|
||||||
|
Tamil: வணக்கம் (ta) (vaṇakkam)
|
||||||
|
Tangsa: äshazhoix
|
||||||
|
Tatar: сәлам (tt) (sälam)
|
||||||
|
Telugu: నమసకారం (namasakāraṁ), బాగున్నారా (bāgunnārā)
|
||||||
|
Tetum: please add this translation if you can
|
||||||
|
Thai: สวัสดี (th) (sà-wàt-dii), สวัสดีครับ (male speaker), สวัสดีค่ะ (female speaker), หวัดดี (wàt-dii)
|
||||||
|
Tibetan: བཀྲ་ཤིས་བདེ་ལེགས (bkra shis bde legs)
|
||||||
|
Tigrinya: ሰላም (sälam)
|
||||||
|
Tongan: mālō e lelei
|
||||||
|
Tswana: dumela (tn) (singular, as in dumela, rra, "hello sir"), dumelang (tn) (plural, as in dumelang, borra, "hello gentlemen")
|
||||||
|
Turkish: merhaba (tr), selam (tr)
|
||||||
|
Turkmen: salam
|
||||||
|
Tuvan: экии (ekii)
|
||||||
|
Udmurt: ӟеч (dźeć), чырткем (ćyrtkem), умой (umoj)
|
||||||
|
Ukrainian: приві́т (uk) (pryvít) (informal), здоро́в був (uk) (zdoróv buv) (informal), добри́день (uk) (dobrýdenʹ) (neutral or formal), чоло́м (čolóm)
|
||||||
|
Urdu: سلام علیکم (salām-o-alaikum), اسلام علیکم (literally “Peace be upon you”), اسلام علیکم ورحمۃاللہ وبرکاتہ (literally “Peace be upon you & May Allah bless”), آداب (ur) (ādāb)
|
||||||
|
Uyghur: سالام (salam)
|
||||||
|
Uzbek: salom (uz)
|
||||||
|
Venetian: ciao (vec)
|
||||||
|
Vietnamese: xin chào (vi), chào (vi)
|
||||||
|
Volapük: glidis
|
||||||
|
Walloon: bondjoû (wa), a (wa), diewåde (wa) (old)
|
||||||
|
Welsh: helo (cy), bore da (good morning), dydd da (good day), hylo
|
||||||
|
West Frisian: hallo, hoi
|
||||||
|
Winnebago: haho (male speaker), hą (female speaker), hinįkaraginʼ
|
||||||
|
Xhosa: molo sg, molweni pl
|
||||||
|
Xibe: ᠪᠠᡳᡨᠠᡴᡡ
|
||||||
|
ᠨᠠ (baitakū na)
|
||||||
|
Yakut: эҕэрдэ (eğerde), дорообо (doroobo) (informal)
|
||||||
|
Yiddish: שלום־עליכם (sholem-aleykhem), אַ גוטן (yi) (a gutn), גוט־מאָרגן (yi) (gut-morgn)
|
||||||
|
Yoruba: Pẹlẹ o
|
||||||
|
Yup'ik: waqaa, cama-i
|
||||||
|
Zapotec: padiull
|
||||||
|
Zazaki: sılam, namaste
|
||||||
|
Zhuang: mwngz ndei
|
||||||
|
Zulu: sawubona (zu) (familiar), sanibonani (plural, respectful)
|
|
@ -2,7 +2,7 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
use renderer::{render_graph, rendering::Font, swapchain::WindowSurface, Renderer2};
|
use renderer::{render_graph, swapchain::WindowSurface, Renderer2};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
use winit::{
|
use winit::{
|
||||||
|
|
|
@ -8,6 +8,7 @@ tinyvec = { workspace = true }
|
||||||
indexmap = { workspace = true }
|
indexmap = { workspace = true }
|
||||||
petgraph = { workspace = true }
|
petgraph = { workspace = true }
|
||||||
itertools = { workspace = true }
|
itertools = { workspace = true }
|
||||||
|
ahash = { workspace = true }
|
||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
parking_lot = { workspace = true }
|
parking_lot = { workspace = true }
|
||||||
glam = { workspace = true }
|
glam = { workspace = true }
|
||||||
|
@ -33,7 +34,11 @@ cfg-if = "1.0.0"
|
||||||
dyn-clone = "1"
|
dyn-clone = "1"
|
||||||
crossbeam = "0.8.4"
|
crossbeam = "0.8.4"
|
||||||
bytemuck = { version = "1.21.0", features = ["derive"] }
|
bytemuck = { version = "1.21.0", features = ["derive"] }
|
||||||
|
|
||||||
cosmic-text = "0.12.1"
|
cosmic-text = "0.12.1"
|
||||||
|
sys-locale = "0.3.2"
|
||||||
|
guillotiere = "0.6.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tracing-test = "0.2.5"
|
tracing-test = "0.2.5"
|
||||||
|
image = "0.25.5"
|
||||||
|
|
37
crates/renderer/shaders/wireframe.slang
Normal file
37
crates/renderer/shaders/wireframe.slang
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
struct VertexIn {
|
||||||
|
[[vk::layout(0)]] float2 pos;
|
||||||
|
[[vk::layout(1)]] float4 color;
|
||||||
|
}
|
||||||
|
struct VertexOut {
|
||||||
|
[[vk::layout(0)]] float4 color;
|
||||||
|
float4 position : SV_Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PushConstant {
|
||||||
|
float4x4 mvp;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[vk::push_constant]]
|
||||||
|
ConstantBuffer<PushConstant> push_constant;
|
||||||
|
|
||||||
|
[shader("vertex")]
|
||||||
|
VertexOut vertex(VertexIn vertex) {
|
||||||
|
VertexOut output;
|
||||||
|
|
||||||
|
output.position = mul(push_constant.mvp, float4(vertex.pos, 1.0));
|
||||||
|
output.color = vertex.color;
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FragmentOut {
|
||||||
|
float4 color : SV_Target;
|
||||||
|
}
|
||||||
|
|
||||||
|
[shader("fragment")]
|
||||||
|
FragmentOut fragment(VertexOut input) {
|
||||||
|
FragmentOut output;
|
||||||
|
|
||||||
|
output.color = input.color;
|
||||||
|
return output;
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ pub mod render_graph;
|
||||||
pub mod rendering;
|
pub mod rendering;
|
||||||
pub mod swapchain;
|
pub mod swapchain;
|
||||||
pub mod sync;
|
pub mod sync;
|
||||||
|
mod text;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
use device::{Device, DeviceOwned, DeviceQueueFamilies};
|
use device::{Device, DeviceOwned, DeviceQueueFamilies};
|
||||||
|
|
|
@ -1 +1,384 @@
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use ash::vk;
|
||||||
|
use glam::{f32::Mat4, vec3};
|
||||||
|
|
||||||
|
pub use crate::egui_pass::{egui_pass, egui_pre_pass};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
buffers::{Buffer, BufferDesc},
|
||||||
|
commands,
|
||||||
|
device::{Device, DeviceOwned},
|
||||||
|
images::ImageViewDesc,
|
||||||
|
pipeline,
|
||||||
|
render_graph::{
|
||||||
|
buffer_barrier, Access, GraphResourceId, PassDesc, RecordFn, RenderContext, RenderGraph,
|
||||||
|
},
|
||||||
|
sync,
|
||||||
|
util::Rgba8,
|
||||||
|
Result,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Wireframe {
|
||||||
|
positions: Arc<Buffer>,
|
||||||
|
indices: Arc<Buffer>,
|
||||||
|
num_indices: u32,
|
||||||
|
colors: Arc<Buffer>,
|
||||||
|
pipeline: Arc<pipeline::Pipeline>,
|
||||||
|
layout: Arc<pipeline::PipelineLayout>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Wireframe {
|
||||||
|
pub async fn from_triangles_indexed(
|
||||||
|
dev: Device,
|
||||||
|
positions: Vec<glam::Vec3>,
|
||||||
|
indices: Vec<u32>,
|
||||||
|
colors: Vec<Rgba8>,
|
||||||
|
) -> Result<Self> {
|
||||||
|
let positions_size = positions.len() * size_of::<glam::Vec3>();
|
||||||
|
let num_indices = indices.len() as u32;
|
||||||
|
let indices_size = indices.len() * size_of::<u32>();
|
||||||
|
let indices_offset = positions_size;
|
||||||
|
let colors_size = colors.len() * size_of::<Rgba8>();
|
||||||
|
let colors_offset = indices_offset + indices_size;
|
||||||
|
|
||||||
|
let staging_size = positions_size + indices_size + colors_size;
|
||||||
|
|
||||||
|
let mut staging = Buffer::new(
|
||||||
|
dev.clone(),
|
||||||
|
BufferDesc {
|
||||||
|
name: Some("wireframe-staging".into()),
|
||||||
|
size: staging_size as u64,
|
||||||
|
usage: vk::BufferUsageFlags::TRANSFER_SRC,
|
||||||
|
mem_usage: vk_mem::MemoryUsage::AutoPreferHost,
|
||||||
|
alloc_flags: vk_mem::AllocationCreateFlags::MAPPED
|
||||||
|
| vk_mem::AllocationCreateFlags::HOST_ACCESS_SEQUENTIAL_WRITE
|
||||||
|
| vk_mem::AllocationCreateFlags::STRATEGY_FIRST_FIT,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut map = staging.map()?;
|
||||||
|
|
||||||
|
map[..positions_size].copy_from_slice(bytemuck::cast_slice(&positions));
|
||||||
|
map[indices_offset..][..indices_size].copy_from_slice(bytemuck::cast_slice(&indices));
|
||||||
|
map[colors_offset..][..colors_size].copy_from_slice(bytemuck::cast_slice(&colors));
|
||||||
|
}
|
||||||
|
|
||||||
|
let positions = Buffer::new(
|
||||||
|
dev.clone(),
|
||||||
|
BufferDesc {
|
||||||
|
name: Some("wireframe-positions".into()),
|
||||||
|
size: positions_size as u64,
|
||||||
|
usage: vk::BufferUsageFlags::TRANSFER_DST | vk::BufferUsageFlags::VERTEX_BUFFER,
|
||||||
|
mem_usage: vk_mem::MemoryUsage::AutoPreferDevice,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
let indices = Buffer::new(
|
||||||
|
dev.clone(),
|
||||||
|
BufferDesc {
|
||||||
|
name: Some("wireframe-indices".into()),
|
||||||
|
size: indices_size as u64,
|
||||||
|
usage: vk::BufferUsageFlags::TRANSFER_DST | vk::BufferUsageFlags::INDEX_BUFFER,
|
||||||
|
mem_usage: vk_mem::MemoryUsage::AutoPreferDevice,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
let colors = Buffer::new(
|
||||||
|
dev.clone(),
|
||||||
|
BufferDesc {
|
||||||
|
name: Some("wireframe-colors".into()),
|
||||||
|
size: colors_size as u64,
|
||||||
|
usage: vk::BufferUsageFlags::TRANSFER_DST | vk::BufferUsageFlags::VERTEX_BUFFER,
|
||||||
|
mem_usage: vk_mem::MemoryUsage::AutoPreferDevice,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let pool = commands::SingleUseCommandPool::new(dev.clone(), dev.graphics_queue().clone())?;
|
||||||
|
|
||||||
|
let cmd = pool.alloc()?;
|
||||||
|
|
||||||
|
cmd.copy_buffers(
|
||||||
|
staging.handle(),
|
||||||
|
positions.handle(),
|
||||||
|
&[vk::BufferCopy {
|
||||||
|
src_offset: 0,
|
||||||
|
dst_offset: 0,
|
||||||
|
size: positions_size as u64,
|
||||||
|
}],
|
||||||
|
);
|
||||||
|
cmd.copy_buffers(
|
||||||
|
staging.handle(),
|
||||||
|
indices.handle(),
|
||||||
|
&[vk::BufferCopy {
|
||||||
|
src_offset: indices_offset as u64,
|
||||||
|
dst_offset: 0,
|
||||||
|
size: indices_size as u64,
|
||||||
|
}],
|
||||||
|
);
|
||||||
|
cmd.copy_buffers(
|
||||||
|
staging.handle(),
|
||||||
|
colors.handle(),
|
||||||
|
&[vk::BufferCopy {
|
||||||
|
src_offset: colors_offset as u64,
|
||||||
|
dst_offset: 0,
|
||||||
|
size: colors_size as u64,
|
||||||
|
}],
|
||||||
|
);
|
||||||
|
|
||||||
|
let barriers = [
|
||||||
|
buffer_barrier(
|
||||||
|
positions.handle(),
|
||||||
|
0,
|
||||||
|
positions.len(),
|
||||||
|
Access::transfer_write(),
|
||||||
|
Access::vertex_read(),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
buffer_barrier(
|
||||||
|
indices.handle(),
|
||||||
|
0,
|
||||||
|
indices.len(),
|
||||||
|
Access::transfer_write(),
|
||||||
|
Access::index_read(),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
buffer_barrier(
|
||||||
|
colors.handle(),
|
||||||
|
0,
|
||||||
|
colors.len(),
|
||||||
|
Access::transfer_write(),
|
||||||
|
Access::vertex_read(),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
unsafe {
|
||||||
|
dev.dev().cmd_pipeline_barrier2(
|
||||||
|
cmd.buffer(),
|
||||||
|
&vk::DependencyInfo::default().buffer_memory_barriers(&barriers),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let future = cmd.submit_async(None, None, Arc::new(sync::Fence::create(dev.clone())?))?;
|
||||||
|
|
||||||
|
let (pipeline, layout) = Self::create_pipeline(dev.clone())?;
|
||||||
|
|
||||||
|
future.await;
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
positions: Arc::new(positions),
|
||||||
|
indices: Arc::new(indices),
|
||||||
|
colors: Arc::new(colors),
|
||||||
|
pipeline: Arc::new(pipeline),
|
||||||
|
layout: Arc::new(layout),
|
||||||
|
num_indices,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_pipeline(device: Device) -> Result<(pipeline::Pipeline, pipeline::PipelineLayout)> {
|
||||||
|
let pipeline_layout = pipeline::PipelineLayout::new(
|
||||||
|
device.clone(),
|
||||||
|
pipeline::PipelineLayoutDesc {
|
||||||
|
descriptor_set_layouts: &[],
|
||||||
|
push_constant_ranges: &[vk::PushConstantRange {
|
||||||
|
offset: 0,
|
||||||
|
size: 128,
|
||||||
|
stage_flags: vk::ShaderStageFlags::VERTEX,
|
||||||
|
}],
|
||||||
|
name: Some("wireframe-pipeline-layout".into()),
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let shader = pipeline::ShaderModule::new_from_path(
|
||||||
|
device.clone(),
|
||||||
|
"crates/renderer/shaders/wireframe.spv",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let pipeline = pipeline::Pipeline::new(
|
||||||
|
device.clone(),
|
||||||
|
pipeline::PipelineDesc::Graphics(pipeline::GraphicsPipelineDesc {
|
||||||
|
flags: Default::default(),
|
||||||
|
name: Some("wireframe-pipeline".into()),
|
||||||
|
shader_stages: &[
|
||||||
|
pipeline::ShaderStageDesc {
|
||||||
|
flags: vk::PipelineShaderStageCreateFlags::empty(),
|
||||||
|
module: &shader,
|
||||||
|
stage: vk::ShaderStageFlags::FRAGMENT,
|
||||||
|
entry: c"main".into(),
|
||||||
|
},
|
||||||
|
pipeline::ShaderStageDesc {
|
||||||
|
flags: vk::PipelineShaderStageCreateFlags::empty(),
|
||||||
|
module: &shader,
|
||||||
|
stage: vk::ShaderStageFlags::VERTEX,
|
||||||
|
entry: c"main".into(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
render_pass: None,
|
||||||
|
layout: &pipeline_layout,
|
||||||
|
subpass: None,
|
||||||
|
base_pipeline: None,
|
||||||
|
vertex_input: Some(pipeline::VertexInputState {
|
||||||
|
bindings: &[
|
||||||
|
vk::VertexInputBindingDescription {
|
||||||
|
binding: 0,
|
||||||
|
stride: size_of::<glam::Vec3>() as u32,
|
||||||
|
input_rate: vk::VertexInputRate::VERTEX,
|
||||||
|
},
|
||||||
|
vk::VertexInputBindingDescription {
|
||||||
|
binding: 1,
|
||||||
|
stride: size_of::<Rgba8>() as u32,
|
||||||
|
input_rate: vk::VertexInputRate::VERTEX,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
attributes: &[
|
||||||
|
vk::VertexInputAttributeDescription {
|
||||||
|
location: 0,
|
||||||
|
binding: 0,
|
||||||
|
format: vk::Format::R32G32B32_SFLOAT,
|
||||||
|
offset: 0,
|
||||||
|
},
|
||||||
|
vk::VertexInputAttributeDescription {
|
||||||
|
location: 1,
|
||||||
|
binding: 1,
|
||||||
|
format: vk::Format::R8G8B8A8_UNORM,
|
||||||
|
offset: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
input_assembly: Some(pipeline::InputAssemblyState {
|
||||||
|
topology: vk::PrimitiveTopology::TRIANGLE_LIST,
|
||||||
|
primitive_restart: false,
|
||||||
|
}),
|
||||||
|
tessellation: None,
|
||||||
|
viewport: Some(pipeline::ViewportState {
|
||||||
|
num_viewports: 1,
|
||||||
|
num_scissors: 1,
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
rasterization: Some(pipeline::RasterizationState {
|
||||||
|
cull_mode: vk::CullModeFlags::NONE,
|
||||||
|
polygon_mode: vk::PolygonMode::LINE,
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
multisample: Some(pipeline::MultisampleState {
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
depth_stencil: Some(pipeline::DepthStencilState {
|
||||||
|
depth: Some(pipeline::DepthState {
|
||||||
|
write_enable: false,
|
||||||
|
compare_op: Some(vk::CompareOp::LESS),
|
||||||
|
bounds: Some(pipeline::DepthBounds { min: 0.0, max: 1.0 }),
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
color_blend: Some(pipeline::ColorBlendState {
|
||||||
|
attachments: &[vk::PipelineColorBlendAttachmentState::default()
|
||||||
|
.color_write_mask(vk::ColorComponentFlags::RGBA)
|
||||||
|
.blend_enable(true)
|
||||||
|
.color_blend_op(vk::BlendOp::ADD)
|
||||||
|
.src_color_blend_factor(vk::BlendFactor::ONE)
|
||||||
|
.dst_color_blend_factor(vk::BlendFactor::ONE_MINUS_SRC_ALPHA)
|
||||||
|
.alpha_blend_op(vk::BlendOp::ADD)
|
||||||
|
.src_alpha_blend_factor(vk::BlendFactor::ONE)
|
||||||
|
.dst_alpha_blend_factor(vk::BlendFactor::ONE_MINUS_SRC_ALPHA)],
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
rendering: Some(pipeline::RenderingState {
|
||||||
|
color_formats: &[vk::Format::R8G8B8A8_UNORM],
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
dynamic: Some(pipeline::DynamicState {
|
||||||
|
dynamic_states: &[vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR],
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok((pipeline, pipeline_layout))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pass(&self, rg: &mut RenderGraph, target: GraphResourceId) -> Result<()> {
|
||||||
|
let reads = [(target, Access::color_attachment_read_write())].to_vec();
|
||||||
|
let writes = [(target, Access::color_attachment_write_only())].to_vec();
|
||||||
|
|
||||||
|
let record: Box<RecordFn> = Box::new({
|
||||||
|
let positions = self.positions.clone();
|
||||||
|
let indices = self.indices.clone();
|
||||||
|
let colors = self.colors.clone();
|
||||||
|
let num_indices = self.num_indices;
|
||||||
|
|
||||||
|
let pipeline = self.pipeline.clone();
|
||||||
|
let layout = self.layout.clone();
|
||||||
|
|
||||||
|
move |ctx: &RenderContext| -> Result<()> {
|
||||||
|
let target = ctx.get_image(target).unwrap();
|
||||||
|
let cmd = &ctx.cmd;
|
||||||
|
|
||||||
|
//let model = Mat4::from_scale(vec3(0.01, 0.01, 0.01));
|
||||||
|
let proj = Mat4::perspective_lh(
|
||||||
|
core::f32::consts::FRAC_PI_4,
|
||||||
|
target.width() as f32 / target.height() as f32,
|
||||||
|
0.1,
|
||||||
|
100.0,
|
||||||
|
);
|
||||||
|
let pos = vec3(0.0, 0.0, -5.0);
|
||||||
|
let view = Mat4::look_at_rh(pos, pos + vec3(0.0, 0.0, 1.0), vec3(0.0, 1.0, 0.0));
|
||||||
|
let to_clip = proj * view; // * model;
|
||||||
|
|
||||||
|
let color_attachment = &vk::RenderingAttachmentInfo::default()
|
||||||
|
.image_layout(vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL)
|
||||||
|
.image_view(target.get_view(ImageViewDesc {
|
||||||
|
kind: vk::ImageViewType::TYPE_2D,
|
||||||
|
format: target.format(),
|
||||||
|
aspect: vk::ImageAspectFlags::COLOR,
|
||||||
|
..Default::default()
|
||||||
|
})?)
|
||||||
|
.load_op(vk::AttachmentLoadOp::LOAD)
|
||||||
|
.store_op(vk::AttachmentStoreOp::STORE);
|
||||||
|
|
||||||
|
cmd.begin_rendering(
|
||||||
|
vk::RenderingInfo::default()
|
||||||
|
.color_attachments(core::slice::from_ref(color_attachment))
|
||||||
|
.layer_count(1)
|
||||||
|
.render_area(vk::Rect2D::default().extent(target.extent_2d())),
|
||||||
|
);
|
||||||
|
|
||||||
|
cmd.set_scissors(&[vk::Rect2D::default()
|
||||||
|
.offset(vk::Offset2D::default())
|
||||||
|
.extent(target.extent_2d())]);
|
||||||
|
|
||||||
|
cmd.set_viewport(&[vk::Viewport::default()
|
||||||
|
.x(0.0)
|
||||||
|
.y(0.0)
|
||||||
|
.min_depth(0.0)
|
||||||
|
.max_depth(1.0)
|
||||||
|
.width(target.width() as f32)
|
||||||
|
.height(target.height() as f32)]);
|
||||||
|
|
||||||
|
cmd.bind_pipeline(&pipeline);
|
||||||
|
cmd.bind_indices(indices.buffer(), 0, vk::IndexType::UINT32);
|
||||||
|
cmd.bind_vertex_buffers(&[positions.handle(), colors.handle()], &[0, 0]);
|
||||||
|
cmd.push_constants(
|
||||||
|
&layout,
|
||||||
|
vk::ShaderStageFlags::VERTEX,
|
||||||
|
0,
|
||||||
|
bytemuck::cast_slice(&[to_clip]),
|
||||||
|
);
|
||||||
|
cmd.draw_indexed(num_indices, 1, 0, 0, 0);
|
||||||
|
cmd.end_rendering();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
rg.add_pass(PassDesc {
|
||||||
|
reads,
|
||||||
|
writes,
|
||||||
|
record: Some(record),
|
||||||
|
});
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
424
crates/renderer/src/text.rs
Normal file
424
crates/renderer/src/text.rs
Normal file
|
@ -0,0 +1,424 @@
|
||||||
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
|
sync::{Arc, Weak},
|
||||||
|
};
|
||||||
|
|
||||||
|
use ash::vk::Extent2D;
|
||||||
|
use cosmic_text::{
|
||||||
|
Attrs, Buffer, CacheKey, Family, FontSystem, Metrics, PhysicalGlyph, SwashCache,
|
||||||
|
};
|
||||||
|
use glam::{IVec2, Vec2};
|
||||||
|
use guillotiere::size2;
|
||||||
|
#[cfg(test)]
|
||||||
|
use image::{GenericImage, GenericImageView};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
def_monotonic_id,
|
||||||
|
util::{self, Rect2D, F32},
|
||||||
|
};
|
||||||
|
|
||||||
|
const ROBOTO_BYTES: &[u8] =
|
||||||
|
include_bytes!("../../../assets/fonts/Roboto/Roboto-VariableFont_wdth,wght.ttf");
|
||||||
|
const NOTO_SANS_HAN_BYTES: &[u8] =
|
||||||
|
include_bytes!("../../../assets/fonts/Noto_Sans_SC/NotoSansSC-VariableFont_wght.ttf");
|
||||||
|
|
||||||
|
def_monotonic_id!(pub FontId);
|
||||||
|
|
||||||
|
type FontData = Arc<dyn AsRef<[u8]> + Send + Sync>;
|
||||||
|
struct FontStore {
|
||||||
|
fonts: HashMap<FontId, FontData>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FontStore {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
fonts: HashMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_font_bytes(&mut self, bytes: FontData) -> FontId {
|
||||||
|
let id = FontId::new();
|
||||||
|
self.fonts.insert(id, bytes);
|
||||||
|
id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_source(&self, id: FontId) -> Option<cosmic_text::fontdb::Source> {
|
||||||
|
self.fonts
|
||||||
|
.get(&id)
|
||||||
|
.map(|bytes| cosmic_text::fontdb::Source::Binary(Arc::clone(bytes)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
struct FontAtlasSets {
|
||||||
|
sets: HashMap<FontId, FontAtlasSet>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FontAtlasSets {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
sets: HashMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn get(&self, key: &FontId) -> Option<&FontAtlasSet> {
|
||||||
|
self.sets.get(key)
|
||||||
|
}
|
||||||
|
fn get_mut(&mut self, key: &FontId) -> Option<&mut FontAtlasSet> {
|
||||||
|
self.sets.get_mut(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Per-Font Font Atlas Set
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
struct FontAtlasSet {
|
||||||
|
// TODO: add proper plural of atlas to english language.
|
||||||
|
atlantes: HashMap<util::F32, Vec<FontAtlas>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FontAtlasSet {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
atlantes: HashMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn get_glyph_info(&self, key: CacheKey) -> Option<AtlasGlyphInfo> {
|
||||||
|
self.atlantes
|
||||||
|
.get(&F32::from_bits(key.font_size_bits))?
|
||||||
|
.iter()
|
||||||
|
.find_map(|atlas| {
|
||||||
|
atlas
|
||||||
|
.glyphs
|
||||||
|
.get(&key)
|
||||||
|
.map(|&(rect, offset)| (Arc::downgrade(&atlas.image), rect, offset))
|
||||||
|
})
|
||||||
|
.map(|(image, rect, offset)| AtlasGlyphInfo {
|
||||||
|
image,
|
||||||
|
rect,
|
||||||
|
offset,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fn add_glyph(
|
||||||
|
&mut self,
|
||||||
|
font_system: &mut FontSystem,
|
||||||
|
swash_cache: &mut SwashCache,
|
||||||
|
physical: PhysicalGlyph,
|
||||||
|
) -> Result<AtlasGlyphInfo, Error> {
|
||||||
|
let key = physical.cache_key;
|
||||||
|
|
||||||
|
let atlantes = self
|
||||||
|
.atlantes
|
||||||
|
.entry(F32::from_bits(physical.cache_key.font_size_bits))
|
||||||
|
.or_insert_with(|| vec![FontAtlas::new(512)]);
|
||||||
|
|
||||||
|
let (data, size, offset) = get_outlined_glyph_texture(font_system, swash_cache, physical)?;
|
||||||
|
|
||||||
|
if !atlantes
|
||||||
|
.iter_mut()
|
||||||
|
.any(|atlas| atlas.add_glyph(key, &data, size, offset).is_some())
|
||||||
|
{
|
||||||
|
let max_size = size.height.max(size.height);
|
||||||
|
let x2_or_512 = (1u32 << (32 - max_size.leading_zeros())).max(512);
|
||||||
|
atlantes.push(FontAtlas::new(x2_or_512));
|
||||||
|
atlantes
|
||||||
|
.last_mut()
|
||||||
|
.unwrap()
|
||||||
|
.add_glyph(key, &data, size, offset)
|
||||||
|
.ok_or(Error::FailedToRasterizeGlyph(key))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(self.get_glyph_info(key).unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Image(parking_lot::RwLock<ImageInner>);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
struct ImageInner {
|
||||||
|
image: Vec<u8>,
|
||||||
|
image_size: Extent2D,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ImageInner {
|
||||||
|
fn bytes(&self) -> &[u8] {
|
||||||
|
self.image.as_slice()
|
||||||
|
}
|
||||||
|
fn bytes_mut(&mut self) -> &mut [u8] {
|
||||||
|
self.image.as_mut_slice()
|
||||||
|
}
|
||||||
|
fn width(&self) -> u32 {
|
||||||
|
self.image_size.width
|
||||||
|
}
|
||||||
|
fn height(&self) -> u32 {
|
||||||
|
self.image_size.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct AtlasGlyphInfo {
|
||||||
|
image: Weak<Image>,
|
||||||
|
rect: Rect2D,
|
||||||
|
offset: IVec2,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FontAtlas {
|
||||||
|
// TODO: this image will be host-coherent and host-visible, so that it can
|
||||||
|
// be updated with new glyphs.
|
||||||
|
// that begs the question:
|
||||||
|
// - should it be staged to a device-local image when it's used?
|
||||||
|
// - does it make sense to use VK_EXT_external_memory_host here? It's
|
||||||
|
// supported on virtually all Windows and Linux drivers.
|
||||||
|
// - how to sync this? I need to make sure that when this image is written
|
||||||
|
// to, it isn't also being read from. Usually, these images will be
|
||||||
|
// write-only, except when rendering. Since currently my rendering may
|
||||||
|
// happen on any thread at any time, that's problematic.
|
||||||
|
//
|
||||||
|
// In fact, this is an awful type to use here because of the unique access
|
||||||
|
// requirement for mapping.
|
||||||
|
image: Arc<Image>,
|
||||||
|
// stores sub-rect of image and placement offset of glyph
|
||||||
|
glyphs: HashMap<CacheKey, (Rect2D, IVec2)>,
|
||||||
|
allocator: guillotiere::AtlasAllocator,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for FontAtlas {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("FontAtlas")
|
||||||
|
.field("image", &self.image)
|
||||||
|
.field("glyphs", &self.glyphs)
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FontAtlas {
|
||||||
|
fn new(size: u32) -> Self {
|
||||||
|
let num_bytes = size * size * 4;
|
||||||
|
Self {
|
||||||
|
image: Arc::new(Image(parking_lot::RwLock::new(ImageInner {
|
||||||
|
image: vec![0; num_bytes as usize],
|
||||||
|
image_size: Extent2D {
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
},
|
||||||
|
}))),
|
||||||
|
glyphs: HashMap::new(),
|
||||||
|
allocator: guillotiere::AtlasAllocator::new(size2(
|
||||||
|
size.try_into().unwrap(),
|
||||||
|
size.try_into().unwrap(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn has_glyph(&self, key: CacheKey) -> bool {
|
||||||
|
self.glyphs.contains_key(&key)
|
||||||
|
}
|
||||||
|
fn add_glyph(
|
||||||
|
&mut self,
|
||||||
|
key: CacheKey,
|
||||||
|
data: &Vec<u8>,
|
||||||
|
size: Extent2D,
|
||||||
|
offset: IVec2,
|
||||||
|
) -> Option<AtlasGlyphInfo> {
|
||||||
|
let allocation = self.allocator.allocate(guillotiere::size2(
|
||||||
|
(size.width + 1).try_into().unwrap(),
|
||||||
|
(size.height + 1).try_into().unwrap(),
|
||||||
|
));
|
||||||
|
|
||||||
|
let Some(allocation) = allocation else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
let rect = allocation.rectangle;
|
||||||
|
let x = rect.min.x;
|
||||||
|
let y = rect.min.y;
|
||||||
|
let width = rect.width() - 1;
|
||||||
|
let height = rect.height() - 1;
|
||||||
|
let rect = Rect2D::new_from_size(IVec2::new(x, y), IVec2::new(width, height));
|
||||||
|
self.glyphs.insert(key, (rect, offset));
|
||||||
|
|
||||||
|
// put data into image array
|
||||||
|
let mut image = self.image.0.write();
|
||||||
|
for line_y in 0..height {
|
||||||
|
let y = y + line_y;
|
||||||
|
let image_offset = 4 * y as u32 * image.width() + 4 * x as u32;
|
||||||
|
let glyph_offset = 4 * line_y * width;
|
||||||
|
let len = 4 * width as usize;
|
||||||
|
let dst = &mut image.bytes_mut()[image_offset as usize..][..len];
|
||||||
|
let src = &data[glyph_offset as usize..][..len];
|
||||||
|
dst.copy_from_slice(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(AtlasGlyphInfo {
|
||||||
|
image: Arc::downgrade(&self.image),
|
||||||
|
rect,
|
||||||
|
offset,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum Error {
|
||||||
|
#[error("Failed to rasterize glyph {0:?}.")]
|
||||||
|
FailedToRasterizeGlyph(CacheKey),
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_outlined_glyph_texture(
|
||||||
|
font_system: &mut FontSystem,
|
||||||
|
swash_cache: &mut SwashCache,
|
||||||
|
glyph: PhysicalGlyph,
|
||||||
|
) -> Result<(Vec<u8>, Extent2D, IVec2), Error> {
|
||||||
|
let image = swash_cache
|
||||||
|
.get_image_uncached(font_system, glyph.cache_key)
|
||||||
|
.ok_or(Error::FailedToRasterizeGlyph(glyph.cache_key))?;
|
||||||
|
|
||||||
|
let cosmic_text::Placement {
|
||||||
|
left,
|
||||||
|
top,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
} = image.placement;
|
||||||
|
|
||||||
|
let data = match image.content {
|
||||||
|
cosmic_text::SwashContent::Mask => image
|
||||||
|
.data
|
||||||
|
.iter()
|
||||||
|
.flat_map(|a| [255, 255, 255, *a])
|
||||||
|
.collect(),
|
||||||
|
cosmic_text::SwashContent::Color => image.data,
|
||||||
|
cosmic_text::SwashContent::SubpixelMask => {
|
||||||
|
// TODO: implement
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let extent = Extent2D { width, height };
|
||||||
|
|
||||||
|
Ok((data, extent, IVec2::new(left, top)))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test() {
|
||||||
|
let mut font_store = FontStore::new();
|
||||||
|
let mut db = cosmic_text::fontdb::Database::new();
|
||||||
|
let mut font_id_map = HashMap::<FontId, cosmic_text::fontdb::ID>::new();
|
||||||
|
let mut reverse_font_id_map = HashMap::<cosmic_text::fontdb::ID, FontId>::new();
|
||||||
|
|
||||||
|
let roboto = font_store.add_font_bytes(Arc::new(ROBOTO_BYTES));
|
||||||
|
let noto_han = font_store.add_font_bytes(Arc::new(NOTO_SANS_HAN_BYTES));
|
||||||
|
let id = *db
|
||||||
|
.load_font_source(font_store.as_source(roboto).unwrap())
|
||||||
|
.last()
|
||||||
|
.unwrap();
|
||||||
|
font_id_map.insert(roboto, id);
|
||||||
|
reverse_font_id_map.insert(id, roboto);
|
||||||
|
|
||||||
|
let id = *db
|
||||||
|
.load_font_source(font_store.as_source(noto_han).unwrap())
|
||||||
|
.last()
|
||||||
|
.unwrap();
|
||||||
|
font_id_map.insert(noto_han, id);
|
||||||
|
reverse_font_id_map.insert(id, noto_han);
|
||||||
|
|
||||||
|
db.set_sans_serif_family("Roboto");
|
||||||
|
// db.load_system_fonts();
|
||||||
|
|
||||||
|
let locale = sys_locale::get_locale().unwrap_or("en-DK".to_string());
|
||||||
|
let mut font_system = FontSystem::new_with_locale_and_db(locale, db);
|
||||||
|
let mut swash = SwashCache::new();
|
||||||
|
|
||||||
|
let mut buffer = Buffer::new_empty(Metrics::new(14.0, 20.0));
|
||||||
|
|
||||||
|
let mut buf = buffer.borrow_with(&mut font_system);
|
||||||
|
|
||||||
|
let path = format!("../../assets/testing/hello.txt");
|
||||||
|
let attrs = Attrs::new()
|
||||||
|
.family(Family::SansSerif)
|
||||||
|
.metrics(Metrics::new(48.0, 56.0));
|
||||||
|
let text = std::fs::read_to_string(path).expect("hello.txt");
|
||||||
|
|
||||||
|
buf.set_text(
|
||||||
|
"Hello, World! 你好! 안녕하세요",
|
||||||
|
attrs,
|
||||||
|
cosmic_text::Shaping::Advanced,
|
||||||
|
);
|
||||||
|
//buf.set_size(Some(400.0), Some(400.0));
|
||||||
|
buf.set_wrap(cosmic_text::Wrap::Word);
|
||||||
|
|
||||||
|
for line in buf.lines.iter_mut() {
|
||||||
|
line.set_align(Some(cosmic_text::Align::Left));
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.shape_until_scroll(false);
|
||||||
|
|
||||||
|
let mut font_atlantes = FontAtlasSets::new();
|
||||||
|
|
||||||
|
let mut glyphs = Vec::new();
|
||||||
|
let mut size = Vec2::new(0.0, 0.0);
|
||||||
|
|
||||||
|
let result = buffer
|
||||||
|
.layout_runs()
|
||||||
|
.flat_map(|run| {
|
||||||
|
size.x = size.x.max(run.line_w);
|
||||||
|
size.y = size.y + run.line_height;
|
||||||
|
run.glyphs.iter().map(move |glyph| (glyph, run.line_y))
|
||||||
|
})
|
||||||
|
.try_for_each(|(glyph, line_y)| -> Result<(), Error> {
|
||||||
|
let font_id = *reverse_font_id_map.get(&glyph.font_id).unwrap();
|
||||||
|
let set = font_atlantes.sets.entry(font_id).or_default();
|
||||||
|
|
||||||
|
let physical = glyph.physical((0.0, 0.0), 1.0);
|
||||||
|
|
||||||
|
let glyph_info = set
|
||||||
|
.get_glyph_info(physical.cache_key)
|
||||||
|
.map(Ok)
|
||||||
|
.unwrap_or_else(|| set.add_glyph(&mut font_system, &mut swash, physical.clone()))?;
|
||||||
|
|
||||||
|
let pos = {
|
||||||
|
let x = glyph_info.offset.x as f32 + physical.x as f32;
|
||||||
|
let y = line_y.round() + physical.y as f32 - glyph_info.offset.y as f32;
|
||||||
|
|
||||||
|
Vec2::new(x, y)
|
||||||
|
};
|
||||||
|
|
||||||
|
let size = glyph_info.rect.size();
|
||||||
|
glyphs.push((glyph_info, pos, size));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
|
||||||
|
let (width, height) = {
|
||||||
|
let tmp = size.ceil().as_uvec2();
|
||||||
|
(tmp.x, tmp.y)
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut image = image::RgbaImage::from_pixel(width, height, image::Rgba([0, 0, 0, 255]));
|
||||||
|
|
||||||
|
eprintln!("glyphs: {glyphs:#?}");
|
||||||
|
eprintln!("image: {width}x{height}");
|
||||||
|
|
||||||
|
for (info, pos, size) in glyphs {
|
||||||
|
let atlas_image = info.image.upgrade().unwrap();
|
||||||
|
let glyph = atlas_image.0.read();
|
||||||
|
|
||||||
|
let atlas_image = image::ImageBuffer::<image::Rgba<u8>, _>::from_raw(
|
||||||
|
glyph.width(),
|
||||||
|
glyph.height(),
|
||||||
|
glyph.bytes(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let glyph = atlas_image.view(
|
||||||
|
info.rect.top_left().x as u32,
|
||||||
|
info.rect.top_left().y as u32,
|
||||||
|
info.rect.width() as u32,
|
||||||
|
info.rect.height() as u32,
|
||||||
|
);
|
||||||
|
|
||||||
|
eprintln!("rect: {:?}", info.rect);
|
||||||
|
eprintln!("image_size: {:?}", image.dimensions());
|
||||||
|
|
||||||
|
image
|
||||||
|
.copy_from(&*glyph, pos.x as u32, pos.y as u32)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
image.save("rendered.png").unwrap();
|
||||||
|
}
|
|
@ -329,6 +329,17 @@ pub fn eq_f32(lhs: f32, rhs: f32) -> bool {
|
||||||
_ => lhs == rhs,
|
_ => lhs == rhs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn ord_f32(lhs: f32, rhs: f32) -> core::cmp::Ordering {
|
||||||
|
use core::cmp::Ordering;
|
||||||
|
use core::num::FpCategory::*;
|
||||||
|
match (lhs.classify(), rhs.classify()) {
|
||||||
|
(Zero, Zero) | (Nan, Nan) => Ordering::Equal,
|
||||||
|
(Infinite, Infinite) => {
|
||||||
|
core::cmp::PartialOrd::partial_cmp(&lhs.signum(), &rhs.signum()).unwrap()
|
||||||
|
}
|
||||||
|
_ => core::cmp::PartialOrd::partial_cmp(&lhs, &rhs).unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn hash_f32<H: std::hash::Hasher>(state: &mut H, f: f32) {
|
pub fn hash_f32<H: std::hash::Hasher>(state: &mut H, f: f32) {
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
@ -342,6 +353,72 @@ pub fn hash_f32<H: std::hash::Hasher>(state: &mut H, f: f32) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub struct F32(f32);
|
||||||
|
|
||||||
|
impl F32 {
|
||||||
|
#[inline]
|
||||||
|
pub fn from_bits(bits: u32) -> Self {
|
||||||
|
Self(f32::from_bits(bits))
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn into_bits(self) -> u32 {
|
||||||
|
self.0.to_bits()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<f32> for F32 {
|
||||||
|
fn from(value: f32) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<F32> for f32 {
|
||||||
|
fn from(value: F32) -> Self {
|
||||||
|
value.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Deref for F32 {
|
||||||
|
type Target = f32;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DerefMut for F32 {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for F32 {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
eq_f32(self.0, other.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for F32 {}
|
||||||
|
|
||||||
|
impl PartialOrd for F32 {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
Some(ord_f32(self.0, other.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for F32 {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
ord_f32(self.0, other.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl core::hash::Hash for F32 {
|
||||||
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
hash_f32(state, self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn timed<T, F: FnOnce() -> T>(label: &str, f: F) -> T {
|
pub fn timed<T, F: FnOnce() -> T>(label: &str, f: F) -> T {
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
let out = f();
|
let out = f();
|
||||||
|
|
Loading…
Reference in a new issue