mirror of
https://github.com/overte-org/overte.git
synced 2025-04-05 18:19:26 +02:00
wip msdf fonts
This commit is contained in:
parent
48b1493410
commit
36fafe8432
24 changed files with 613 additions and 192 deletions
14
cmake/ports/artery-font-format/portfile.cmake
Normal file
14
cmake/ports/artery-font-format/portfile.cmake
Normal file
|
@ -0,0 +1,14 @@
|
|||
# header-only library
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO Chlumsky/artery-font-format
|
||||
REF 34134bde3cea35a93c2ae5703fa8d3d463793400
|
||||
SHA512 6b2fc0de9ca7b367c9b98f829ce6cee858f1252b12a49b6f1e89a5a2fdb109e20ef812f0b30495195ca0b177adae32d5e238fdc305724857ced098be2d29a6af
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
file(COPY "${SOURCE_PATH}/artery-font" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
|
||||
|
||||
# Handle copyright
|
||||
configure_file("${SOURCE_PATH}/LICENSE.txt" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY)
|
7
cmake/ports/artery-font-format/vcpkg.json
Normal file
7
cmake/ports/artery-font-format/vcpkg.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "artery-font-format",
|
||||
"version": "1.0.1",
|
||||
"description": "Header-only C++ library that facilitates encoding and decoding of the Artery Atlas Font format",
|
||||
"homepage": "https://github.com/Chlumsky/artery-font-format",
|
||||
"license": "MIT"
|
||||
}
|
|
@ -5,4 +5,4 @@
|
|||
Source: hifi-deps
|
||||
Version: 0.1.5-github-actions
|
||||
Description: Collected dependencies for High Fidelity applications
|
||||
Build-Depends: bullet3, cgltf, draco, etc2comp, glad, glm, node, nvtt, openexr (!android), openssl (windows), opus, polyvox, tbb (!android), vhacd, webrtc (!android|!(linux&arm)), zlib
|
||||
Build-Depends: artery-font-format, bullet3, cgltf, draco, etc2comp, glad, glm, node, nvtt, openexr (!android), openssl (windows), opus, polyvox, tbb (!android), vhacd, webrtc (!android|!(linux&arm)), zlib
|
||||
|
|
|
@ -1328,7 +1328,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
* @property {boolean} unlit=false - <code>true</code> if the entity is unaffected by lighting, <code>false</code> if it is lit
|
||||
* by the key light and local lights.
|
||||
* @property {string} font="" - The font to render the text with. It can be one of the following: <code>"Courier"</code>,
|
||||
* <code>"Inconsolata"</code>, <code>"Roboto"</code>, <code>"Timeless"</code>, or a path to a .sdff file.
|
||||
* <code>"Inconsolata"</code>, <code>"Roboto"</code>, <code>"Timeless"</code>, or a path to an MTSDF .arfont file generated
|
||||
* by the msdf-atlas-gen tool (https://github.com/Chlumsky/msdf-atlas-gen).
|
||||
* @property {Entities.TextEffect} textEffect="none" - The effect that is applied to the text.
|
||||
* @property {Color} textEffectColor=255,255,255 - The color of the effect.
|
||||
* @property {number} textEffectThickness=0.2 - The magnitude of the text effect, range <code>0.0</code> – <code>0.5</code>.
|
||||
|
|
93
libraries/render-utils/res/fonts/CourierPrime-OFL.txt
Normal file
93
libraries/render-utils/res/fonts/CourierPrime-OFL.txt
Normal file
|
@ -0,0 +1,93 @@
|
|||
Copyright 2015 The Courier Prime Project Authors (https://github.com/quoteunquoteapps/CourierPrime).
|
||||
|
||||
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
libraries/render-utils/res/fonts/CourierPrime.arfont
Normal file
BIN
libraries/render-utils/res/fonts/CourierPrime.arfont
Normal file
Binary file not shown.
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
|
||||
SIL Open Font License v1.10
|
||||
|
||||
This license can also be found at this permalink: http://www.fontsquirrel.com/license/courier-prime
|
||||
|
||||
Copyright (c) 2013, Quote-Unquote Apps (http://quoteunquoteapps.com),
|
||||
with Reserved Font Name Courier Prime.
|
||||
|
||||
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: http://scripts.sil.org/OFL
|
||||
|
||||
—————————————————————————————-
|
||||
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.
|
||||
*/
|
Binary file not shown.
93
libraries/render-utils/res/fonts/Inconsolata-OFL.txt
Normal file
93
libraries/render-utils/res/fonts/Inconsolata-OFL.txt
Normal file
|
@ -0,0 +1,93 @@
|
|||
Copyright 2006 The Inconsolata Project Authors
|
||||
|
||||
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
libraries/render-utils/res/fonts/InconsolataMedium.arfont
Normal file
BIN
libraries/render-utils/res/fonts/InconsolataMedium.arfont
Normal file
Binary file not shown.
Binary file not shown.
202
libraries/render-utils/res/fonts/Roboto-LICENSE.txt
Normal file
202
libraries/render-utils/res/fonts/Roboto-LICENSE.txt
Normal file
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
BIN
libraries/render-utils/res/fonts/Roboto.arfont
Normal file
BIN
libraries/render-utils/res/fonts/Roboto.arfont
Normal file
Binary file not shown.
Binary file not shown.
BIN
libraries/render-utils/res/fonts/Timeless.arfont
Normal file
BIN
libraries/render-utils/res/fonts/Timeless.arfont
Normal file
Binary file not shown.
Binary file not shown.
|
@ -1,9 +1,9 @@
|
|||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
<qresource>
|
||||
<file>CourierPrime.sdff</file>
|
||||
<file>InconsolataMedium.sdff</file>
|
||||
<file>Roboto.sdff</file>
|
||||
<file>Timeless.sdff</file>
|
||||
<file>CourierPrime.arfont</file>
|
||||
<file>InconsolataMedium.arfont</file>
|
||||
<file>Roboto.arfont</file>
|
||||
<file>Timeless.arfont</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -45,6 +45,7 @@ layout(location=RENDER_UTILS_ATTR_FADE1) flat in vec4 _glyphBounds; // we're reu
|
|||
void main() {
|
||||
vec4 color = evalSDFSuperSampled(_texCoord0, _glyphBounds);
|
||||
|
||||
// Clip to edges
|
||||
vec2 absPos = abs(_positionMS);
|
||||
if (max(absPos.x, absPos.y) >= 1.0 || _positionMS.x <= 0.0) {
|
||||
color.a = 0.0;
|
||||
|
|
|
@ -23,7 +23,8 @@ struct TextParams {
|
|||
float effectThickness;
|
||||
|
||||
int effect;
|
||||
vec3 spare;
|
||||
vec2 unitRange;
|
||||
float spare;
|
||||
};
|
||||
|
||||
LAYOUT(binding=0) uniform textParamsBuffer {
|
||||
|
@ -37,9 +38,27 @@ LAYOUT(binding=0) uniform textParamsBuffer {
|
|||
const float interiorCutoff = 0.5;
|
||||
const float taaBias = pow(2.0, TAA_TEXTURE_LOD_BIAS);
|
||||
|
||||
vec4 evalSDF(vec2 texCoord, vec4 glyphBounds) {
|
||||
// MSDF logic from: https://github.com/Chlumsky/msdfgen?tab=readme-ov-file#using-a-multi-channel-distance-field
|
||||
float median(float r, float g, float b) {
|
||||
return max(min(r, g), min(max(r, g), b));
|
||||
}
|
||||
|
||||
float screenPxRange(vec2 texCoord) {
|
||||
vec2 screenTexSize = vec2(1.0) / fwidth(texCoord);
|
||||
return max(0.5 * dot(params.unitRange, screenTexSize), 1.0);
|
||||
}
|
||||
|
||||
float evalSDF(vec2 texCoord) {
|
||||
vec3 msdf = textureLod(fontTexture, texCoord, TAA_TEXTURE_LOD_BIAS).rgb;
|
||||
float sdf = median(msdf.r, msdf.g, msdf.b);
|
||||
float screenPxDistance = screenPxRange(texCoord) * (sdf - 0.5);
|
||||
float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
||||
return opacity;
|
||||
}
|
||||
|
||||
vec4 evalSDFColor(vec2 texCoord, vec4 glyphBounds) {
|
||||
vec3 color = params.color.rgb;
|
||||
float sdf = textureLod(fontTexture, texCoord, TAA_TEXTURE_LOD_BIAS).g;
|
||||
float sdf = evalSDF(texCoord);
|
||||
|
||||
// Outline
|
||||
if (params.effect == 1 || params.effect == 2) {
|
||||
|
@ -62,7 +81,7 @@ vec4 evalSDF(vec2 texCoord, vec4 glyphBounds) {
|
|||
// really match the LOD that we use in the textureLod call below
|
||||
vec2 textureOffset = vec2(params.effectThickness * DOUBLE_MAX_OFFSET_PIXELS) / vec2(textureSize(fontTexture, 0/*int(TAA_TEXTURE_LOD_BIAS)*/));
|
||||
vec2 shadowTexCoords = texCoord - textureOffset;
|
||||
sdf = textureLod(fontTexture, shadowTexCoords, TAA_TEXTURE_LOD_BIAS).g;
|
||||
sdf = evalSDF(shadowTexCoords);
|
||||
|
||||
// don't sample from outside of our glyph bounds
|
||||
sdf *= mix(1.0, 0.0, float(clamp(shadowTexCoords, glyphBounds.xy, glyphBounds.xy + glyphBounds.zw) != shadowTexCoords));
|
||||
|
@ -78,10 +97,10 @@ vec4 evalSDFSuperSampled(vec2 texCoord, vec4 glyphBounds) {
|
|||
|
||||
// Perform 4x supersampling for anisotropic filtering
|
||||
vec4 color;
|
||||
color = evalSDF(texCoord, glyphBounds);
|
||||
color += evalSDF(texCoord + dxTexCoord, glyphBounds);
|
||||
color += evalSDF(texCoord + dyTexCoord, glyphBounds);
|
||||
color += evalSDF(texCoord + dxTexCoord + dyTexCoord, glyphBounds);
|
||||
color = evalSDFColor(texCoord, glyphBounds);
|
||||
color += evalSDFColor(texCoord + dxTexCoord, glyphBounds);
|
||||
color += evalSDFColor(texCoord + dyTexCoord, glyphBounds);
|
||||
color += evalSDFColor(texCoord + dxTexCoord + dyTexCoord, glyphBounds);
|
||||
color *= 0.25;
|
||||
|
||||
return vec4(color.rgb, step(interiorCutoff, color.a));
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#include <QImage>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "artery-font/artery-font.h"
|
||||
#include "artery-font/std-artery-font.h"
|
||||
|
||||
#include <ColorUtils.h>
|
||||
|
||||
#include <StreamHelpers.h>
|
||||
|
@ -77,12 +80,154 @@ struct QuadBuilder {
|
|||
}
|
||||
};
|
||||
|
||||
Font::Pointer Font::load(QIODevice& fontFile) {
|
||||
Pointer font = std::make_shared<Font>();
|
||||
Font::Pointer Font::load(const QString& family, QIODevice& fontFile) {
|
||||
Pointer font = std::make_shared<Font>(family);
|
||||
font->read(fontFile);
|
||||
return font;
|
||||
}
|
||||
|
||||
void Font::handleFontNetworkReply() {
|
||||
auto requestReply = qobject_cast<QNetworkReply*>(sender());
|
||||
Q_ASSERT(requestReply != nullptr);
|
||||
|
||||
if (requestReply->error() == QNetworkReply::NoError) {
|
||||
read(*requestReply);
|
||||
} else {
|
||||
qDebug() << "Error downloading " << requestReply->url() << " - " << requestReply->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
size_t _readOffset = 0;
|
||||
int readHelper(void* dst, int length, void* data) {
|
||||
memcpy(dst, (char *)data + _readOffset, length);
|
||||
_readOffset += length;
|
||||
return length;
|
||||
};
|
||||
|
||||
void Font::read(QIODevice& in) {
|
||||
_readOffset = 0;
|
||||
_loaded = false;
|
||||
|
||||
void* data = (void *)in.readAll().data();
|
||||
artery_font::StdArteryFont<float> arteryFont;
|
||||
bool success = artery_font::decode<&readHelper, float, artery_font::StdList, artery_font::StdByteArray, artery_font::StdString>(arteryFont, data);
|
||||
|
||||
if (!success) {
|
||||
qDebug() << "Font" << _family << "failed to decode.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (arteryFont.variants.length() == 0) {
|
||||
qDebug() << "Font" << _family << "has 0 variants.";
|
||||
return;
|
||||
}
|
||||
|
||||
_distanceRange = glm::vec2(arteryFont.variants[0].metrics.distanceRange);
|
||||
_fontSize = arteryFont.variants[0].metrics.ascender + fabs(arteryFont.variants[0].metrics.descender);
|
||||
_leading = arteryFont.variants[0].metrics.lineHeight;
|
||||
_spaceWidth = 0.5f * arteryFont.variants[0].metrics.emSize;
|
||||
|
||||
if (arteryFont.variants[0].glyphs.length() == 0) {
|
||||
qDebug() << "Font" << _family << "has 0 glyphs.";
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<Glyph> glyphs;
|
||||
glyphs.reserve(arteryFont.variants[0].glyphs.length());
|
||||
for (int i = 0; i < arteryFont.variants[0].glyphs.length(); i++) {
|
||||
auto& g = arteryFont.variants[0].glyphs[i];
|
||||
|
||||
Glyph glyph;
|
||||
glyph.c = g.codepoint;
|
||||
glyph.texOffset = glm::vec2(g.imageBounds.l, g.imageBounds.b);
|
||||
glyph.texSize = glm::vec2(g.imageBounds.r, g.imageBounds.t) - glyph.texOffset;
|
||||
glyph.offset = glm::vec2(g.planeBounds.l, g.planeBounds.b);
|
||||
glyph.size = glm::vec2(g.planeBounds.r, g.planeBounds.t) - glyph.offset;
|
||||
glyph.d = g.advance.h;
|
||||
glyphs.push_back(glyph);
|
||||
}
|
||||
|
||||
if (arteryFont.images.length() == 0) {
|
||||
qDebug() << "Font" << _family << "has 0 images.";
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: change back to MTSDF
|
||||
if (arteryFont.images[0].imageType != artery_font::ImageType::IMAGE_MSDF) {
|
||||
qDebug() << "Font" << _family << "has the wrong image type. Expected MTSDF (7), got" << arteryFont.images[0].imageType;
|
||||
return;
|
||||
}
|
||||
|
||||
if (arteryFont.images[0].encoding != artery_font::ImageEncoding::IMAGE_PNG && arteryFont.images[0].encoding != artery_font::ImageEncoding::IMAGE_BMP) {
|
||||
qDebug() << "Font" << _family << "has the wrong encoding. Expected BMP (4) or PNG (8), got" << arteryFont.images[0].encoding;
|
||||
return;
|
||||
}
|
||||
|
||||
if (arteryFont.images[0].pixelFormat != artery_font::PixelFormat::PIXEL_UNSIGNED8) {
|
||||
qDebug() << "Font" << _family << "has the wrong pixel format. Expected unsigned char (8), got" << arteryFont.images[0].pixelFormat;
|
||||
return;
|
||||
}
|
||||
|
||||
if (arteryFont.images[0].width == 0 || arteryFont.images[0].height == 0) {
|
||||
qDebug() << "Font" << _family << "has image with width or height of 0. Width:" << arteryFont.images[0].width << ", height:"<< arteryFont.images[0].height;
|
||||
return;
|
||||
}
|
||||
|
||||
// read image data
|
||||
QImage image;
|
||||
QString format;
|
||||
switch (arteryFont.images[0].encoding) {
|
||||
case artery_font::ImageEncoding::IMAGE_PNG:
|
||||
format = "PNG";
|
||||
break;
|
||||
case artery_font::ImageEncoding::IMAGE_BMP:
|
||||
format = "BMP";
|
||||
break;
|
||||
default:
|
||||
format = "PNG";
|
||||
break;
|
||||
}
|
||||
if (!image.loadFromData((const unsigned char*)arteryFont.images[0].data, arteryFont.images[0].data.length(), format.toStdString().c_str())) {
|
||||
qDebug() << "Failed to read" << format << "image for font" << _family;
|
||||
return;
|
||||
}
|
||||
|
||||
_glyphs.clear();
|
||||
glm::vec2 imageSize = toGlm(image.size());
|
||||
_distanceRange /= imageSize;
|
||||
foreach(Glyph g, glyphs) {
|
||||
// Adjust the pixel texture coordinates into UV coordinates,
|
||||
g.texSize /= imageSize;
|
||||
g.texOffset /= imageSize;
|
||||
// Y flip
|
||||
g.texOffset.y = 1.0f - (g.texOffset.y + g.texSize.y);
|
||||
if (g.offset.y > 0.0f) {
|
||||
g.offset.y = -g.offset.y;
|
||||
}
|
||||
// store in the character to glyph hash
|
||||
_glyphs[g.c] = g;
|
||||
};
|
||||
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888);
|
||||
|
||||
gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
||||
gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
||||
if (image.hasAlphaChannel()) {
|
||||
formatGPU = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
|
||||
formatMip = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::BGRA);
|
||||
}
|
||||
// FIXME: We're forcing this to use only one mip, and then manually doing anisotropic filtering in the shader,
|
||||
// and also calling textureLod. Shouldn't this just use anisotropic filtering and auto-generate mips?
|
||||
// We should also use smoothstep for anti-aliasing, as explained here: https://github.com/libgdx/libgdx/wiki/Distance-field-fonts
|
||||
_texture = gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Texture::SINGLE_MIP,
|
||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_POINT_MAG_LINEAR));
|
||||
_texture->setStoredMipFormat(formatMip);
|
||||
_texture->assignStoredMip(0, image.sizeInBytes(), image.constBits());
|
||||
_texture->setImportant(true);
|
||||
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
static QHash<QString, Font::Pointer> LOADED_FONTS;
|
||||
|
||||
Font::Pointer Font::load(const QString& family) {
|
||||
|
@ -91,16 +236,15 @@ Font::Pointer Font::load(const QString& family) {
|
|||
QString loadFilename;
|
||||
|
||||
if (family == ROBOTO_FONT_FAMILY) {
|
||||
loadFilename = ":/Roboto.sdff";
|
||||
loadFilename = ":/Roboto.arfont";
|
||||
} else if (family == INCONSOLATA_FONT_FAMILY) {
|
||||
loadFilename = ":/InconsolataMedium.sdff";
|
||||
loadFilename = ":/InconsolataMedium.arfont";
|
||||
} else if (family == COURIER_FONT_FAMILY) {
|
||||
loadFilename = ":/CourierPrime.sdff";
|
||||
loadFilename = ":/CourierPrime.arfont";
|
||||
} else if (family == TIMELESS_FONT_FAMILY) {
|
||||
loadFilename = ":/Timeless.sdff";
|
||||
loadFilename = ":/Timeless.arfont";
|
||||
} else if (family.startsWith("http")) {
|
||||
auto loadingFont = std::make_shared<Font>();
|
||||
loadingFont->setLoaded(false);
|
||||
auto loadingFont = std::make_shared<Font>(family);
|
||||
LOADED_FONTS[family] = loadingFont;
|
||||
|
||||
auto& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
|
@ -114,7 +258,7 @@ Font::Pointer Font::load(const QString& family) {
|
|||
connect(networkReply, &QNetworkReply::finished, loadingFont.get(), &Font::handleFontNetworkReply);
|
||||
} else if (!LOADED_FONTS.contains(ROBOTO_FONT_FAMILY)) {
|
||||
// Unrecognized font and we haven't loaded Roboto yet
|
||||
loadFilename = ":/Roboto.sdff";
|
||||
loadFilename = ":/Roboto.arfont";
|
||||
} else {
|
||||
// Unrecognized font but we've already loaded Roboto
|
||||
LOADED_FONTS[family] = LOADED_FONTS[ROBOTO_FONT_FAMILY];
|
||||
|
@ -126,25 +270,13 @@ Font::Pointer Font::load(const QString& family) {
|
|||
|
||||
qCDebug(renderutils) << "Loaded font" << loadFilename << "from Qt Resource System.";
|
||||
|
||||
LOADED_FONTS[family] = load(fontFile);
|
||||
LOADED_FONTS[family] = load(family, fontFile);
|
||||
}
|
||||
}
|
||||
return LOADED_FONTS[family];
|
||||
}
|
||||
|
||||
void Font::handleFontNetworkReply() {
|
||||
auto requestReply = qobject_cast<QNetworkReply*>(sender());
|
||||
Q_ASSERT(requestReply != nullptr);
|
||||
|
||||
if (requestReply->error() == QNetworkReply::NoError) {
|
||||
setLoaded(true);
|
||||
read(*requestReply);
|
||||
} else {
|
||||
qDebug() << "Error downloading " << requestReply->url() << " - " << requestReply->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
Font::Font() {
|
||||
Font::Font(const QString& family) : _family(family) {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, []{
|
||||
Q_INIT_RESOURCE(fonts);
|
||||
|
@ -197,82 +329,6 @@ glm::vec2 Font::computeExtent(const QString& str) const {
|
|||
return extent;
|
||||
}
|
||||
|
||||
void Font::read(QIODevice& in) {
|
||||
uint8_t header[4];
|
||||
readStream(in, header);
|
||||
if (memcmp(header, "SDFF", 4)) {
|
||||
qDebug() << "Bad SDFF file";
|
||||
_loaded = false;
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t version;
|
||||
readStream(in, version);
|
||||
|
||||
// read font name
|
||||
_family = "";
|
||||
if (version > 0x0001) {
|
||||
char c;
|
||||
readStream(in, c);
|
||||
while (c) {
|
||||
_family += c;
|
||||
readStream(in, c);
|
||||
}
|
||||
}
|
||||
|
||||
// read font data
|
||||
readStream(in, _leading);
|
||||
readStream(in, _ascent);
|
||||
readStream(in, _descent);
|
||||
readStream(in, _spaceWidth);
|
||||
_fontSize = _ascent + _descent;
|
||||
|
||||
// Read character count
|
||||
uint16_t count;
|
||||
readStream(in, count);
|
||||
// read metrics data for each character
|
||||
QVector<Glyph> glyphs(count);
|
||||
// std::for_each instead of Qt foreach because we need non-const references
|
||||
std::for_each(glyphs.begin(), glyphs.end(), [&](Glyph& g) {
|
||||
g.read(in);
|
||||
});
|
||||
|
||||
// read image data
|
||||
QImage image;
|
||||
if (!image.loadFromData(in.readAll(), "PNG")) {
|
||||
qDebug() << "Failed to read SDFF image";
|
||||
_loaded = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_glyphs.clear();
|
||||
glm::vec2 imageSize = toGlm(image.size());
|
||||
foreach(Glyph g, glyphs) {
|
||||
// Adjust the pixel texture coordinates into UV coordinates,
|
||||
g.texSize /= imageSize;
|
||||
g.texOffset /= imageSize;
|
||||
// store in the character to glyph hash
|
||||
_glyphs[g.c] = g;
|
||||
};
|
||||
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888);
|
||||
|
||||
gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
||||
gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
||||
if (image.hasAlphaChannel()) {
|
||||
formatGPU = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
|
||||
formatMip = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::BGRA);
|
||||
}
|
||||
// FIXME: We're forcing this to use only one mip, and then manually doing anisotropic filtering in the shader,
|
||||
// and also calling textureLod. Shouldn't this just use anisotropic filtering and auto-generate mips?
|
||||
// We should also use smoothstep for anti-aliasing, as explained here: https://github.com/libgdx/libgdx/wiki/Distance-field-fonts
|
||||
_texture = gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Texture::SINGLE_MIP,
|
||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_POINT_MAG_LINEAR));
|
||||
_texture->setStoredMipFormat(formatMip);
|
||||
_texture->assignStoredMip(0, image.sizeInBytes(), image.constBits());
|
||||
_texture->setImportant(true);
|
||||
}
|
||||
|
||||
void Font::setupGPU() {
|
||||
if (_pipelines.empty()) {
|
||||
using namespace shader::render_utils::program;
|
||||
|
@ -342,7 +398,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm
|
|||
glm::vec2 advance = origin;
|
||||
std::vector<std::pair<Glyph, vec2>> glyphsAndCorners;
|
||||
const QStringList tokens = tokenizeForWrapping(str);
|
||||
for (size_t i = 0; i < tokens.length(); i++) {
|
||||
for (int i = 0; i < tokens.length(); i++) {
|
||||
const QString& token = tokens[i];
|
||||
|
||||
if ((bounds.y != -1) && (advance.y < origin.y - bounds.y)) {
|
||||
|
@ -379,7 +435,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm
|
|||
}
|
||||
const Glyph& glyph = _glyphs[c];
|
||||
|
||||
glyphsAndCorners.emplace_back(glyph, advance - glm::vec2(0.0f, _ascent));
|
||||
glyphsAndCorners.emplace_back(glyph, advance);
|
||||
|
||||
// Advance by glyph size
|
||||
advance.x += glyph.d;
|
||||
|
@ -401,7 +457,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm
|
|||
std::vector<QuadBuilder> quadBuilders;
|
||||
quadBuilders.reserve(glyphsAndCorners.size());
|
||||
{
|
||||
int i = glyphsAndCorners.size() - 1;
|
||||
int i = (int)glyphsAndCorners.size() - 1;
|
||||
while (i >= 0) {
|
||||
auto nextGlyphAndCorner = glyphsAndCorners[i];
|
||||
float rightSpacing = rightEdge - (nextGlyphAndCorner.second.x + nextGlyphAndCorner.first.d);
|
||||
|
@ -426,7 +482,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm
|
|||
}
|
||||
|
||||
// The quadBuilders is backwards now because we looped over the glyphs backwards to adjust their alignment
|
||||
for (int i = quadBuilders.size() - 1; i >= 0; i--) {
|
||||
for (int i = (int)quadBuilders.size() - 1; i >= 0; i--) {
|
||||
quint16 verticesOffset = numVertices;
|
||||
drawInfo.verticesBuffer->append(quadBuilders[i]);
|
||||
numVertices += VERTICES_PER_QUAD;
|
||||
|
@ -494,6 +550,7 @@ void Font::drawString(gpu::Batch& batch, Font::DrawInfo& drawInfo, const QString
|
|||
gpuDrawParams.effectColor = ColorUtils::sRGBToLinearVec3(drawInfo.params.effectColor);
|
||||
gpuDrawParams.effectThickness = drawInfo.params.effectThickness;
|
||||
gpuDrawParams.effect = drawInfo.params.effect;
|
||||
gpuDrawParams.unitRange = _distanceRange;
|
||||
if (!drawInfo.paramsBuffer) {
|
||||
drawInfo.paramsBuffer = std::make_shared<gpu::Buffer>(sizeof(DrawParams), nullptr);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class Font : public QObject {
|
|||
public:
|
||||
using Pointer = std::shared_ptr<Font>;
|
||||
|
||||
Font();
|
||||
Font(const QString& family);
|
||||
|
||||
void read(QIODevice& path);
|
||||
|
||||
|
@ -36,10 +36,12 @@ public:
|
|||
|
||||
int effect { 0 };
|
||||
|
||||
vec2 unitRange { 1.0f };
|
||||
|
||||
#if defined(__clang__)
|
||||
__attribute__((unused))
|
||||
#endif
|
||||
vec3 _spare;
|
||||
float _spare;
|
||||
};
|
||||
|
||||
struct DrawInfo {
|
||||
|
@ -65,13 +67,12 @@ public:
|
|||
static Pointer load(const QString& family);
|
||||
|
||||
bool isLoaded() const { return _loaded; }
|
||||
void setLoaded(bool loaded) { _loaded = loaded; }
|
||||
|
||||
public slots:
|
||||
void handleFontNetworkReply();
|
||||
|
||||
private:
|
||||
static Pointer load(QIODevice& fontFile);
|
||||
static Pointer load(const QString& family, QIODevice& fontFile);
|
||||
QStringList tokenizeForWrapping(const QString& str) const;
|
||||
QStringList splitLines(const QString& str) const;
|
||||
glm::vec2 computeTokenExtent(const QString& str) const;
|
||||
|
@ -91,16 +92,15 @@ private:
|
|||
|
||||
// Font characteristics
|
||||
QString _family;
|
||||
glm::vec2 _distanceRange { 1.0f };
|
||||
float _fontSize { 0.0f };
|
||||
float _leading { 0.0f };
|
||||
float _ascent { 0.0f };
|
||||
float _descent { 0.0f };
|
||||
float _spaceWidth { 0.0f };
|
||||
|
||||
float _scale { 0.0f };
|
||||
TextAlignment _alignment;
|
||||
TextAlignment _alignment { TextAlignment::LEFT };
|
||||
|
||||
bool _loaded { true };
|
||||
bool _loaded { false };
|
||||
|
||||
gpu::TexturePointer _texture;
|
||||
gpu::BufferStreamPointer _stream;
|
||||
|
|
|
@ -9,15 +9,3 @@ QRectF Glyph::bounds() const {
|
|||
QRectF Glyph::textureBounds() const {
|
||||
return glmToRect(texOffset, texSize);
|
||||
}
|
||||
|
||||
void Glyph::read(QIODevice& in) {
|
||||
uint16_t charcode;
|
||||
readStream(in, charcode);
|
||||
c = charcode;
|
||||
readStream(in, texOffset);
|
||||
readStream(in, size);
|
||||
readStream(in, offset);
|
||||
readStream(in, d);
|
||||
// texSize is divided by the image size later
|
||||
texSize = size;
|
||||
}
|
||||
|
|
|
@ -26,13 +26,10 @@ struct Glyph {
|
|||
vec2 size;
|
||||
vec2 offset;
|
||||
float d; // xadvance - adjusts character positioning
|
||||
size_t indexOffset;
|
||||
|
||||
// We adjust bounds because offset is the bottom left corner of the font but the top left corner of a QRect
|
||||
QRectF bounds() const;
|
||||
QRectF textureBounds() const;
|
||||
|
||||
void read(QIODevice& in);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"tooltip": "The height of each line of text. This determines the size of the text."
|
||||
},
|
||||
"font": {
|
||||
"tooltip": "The font to render the text. Supported values: \"Courier\", \"Inconsolata\", \"Roboto\", \"Timeless\", or a URL to a .sdff file."
|
||||
"tooltip": "The font to render the text. Supported values: \"Courier\", \"Inconsolata\", \"Roboto\", \"Timeless\", or a URL to a MTSDF .arfont file."
|
||||
},
|
||||
"textEffect": {
|
||||
"tooltip": "The effect that is applied to the text."
|
||||
|
|
Loading…
Reference in a new issue