Terminal: built-in fonts

Cascadia Code, Sauce Code Pro (Nerd Font Mono), Source Code Pro, Roboto
Mono, JetBrains Mono, Fira Code, OpenDyslexic Mono, Inconsolata and Droid
Sans Mono in assets/fonts with their licences (OFL 1.1; Droid Sans Mono
Apache 2.0), and the system's monospace:

- the variable fonts at weight 400 and a real 700 for bold (Source Code
  Pro's and Fira Code's default instances are light), the others bold by
  the paint;
- ligatures (Cascadia Code, JetBrains Mono, Fira Code) on or off;
- glyphs a font hasn't got come from a fallback font: a run whose width
  isn't its cells' is drawn a glyph per cell, centred and narrowed to fit,
  so the grid holds;
- the cells' height holds the glyphs' ink where a font declares less
  (OpenDyslexic);
- Settings: the font with a preview in the theme's colours, ligatures,
  the fonts' licences.

OpenDyslexic Mono has no compiled release: it is built from its upstream
source with fontmake (assets/fonts/README.md).  Sauce Code Pro is Nerd
Fonts' patched Source Code Pro (Regular, 2.4 MB).

Tests (34 pass): every font loads, keeps the grid with glyphs it hasn't
got (CP437's), and the variable fonts' bold is heavier.  Lint: no issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
This commit is contained in:
Claude committed 2026-10-16 16:07:58 +00:00
1 parent a691f12509
commit 0564a2dea5
25 files changed
+1285 -10

No files matched your search

+4 -1
View File
@@ -27,7 +27,10 @@ network: the phone's own cellular calls go through speech codecs
clear-home, bold as bright, iCE colours, and box drawing and block
characters drawn to fill their cells so ANSI art has no gaps. Colour
themes (VGA, xterm, Solarized, Dracula, Monokai, Gruvbox, Nord, green
and amber phosphor), 80/132/40 fixed columns or pinch to zoom, scrollback
and amber phosphor), fonts (Cascadia Code, Sauce Code Pro Nerd Font,
Source Code Pro, Roboto Mono, JetBrains Mono, Fira Code, OpenDyslexic
Mono, Inconsolata, Droid Sans Mono or the system's; real bold weights
from the variable fonts, optional ligatures; `app/src/main/assets/fonts`), 80/132/40 fixed columns or pinch to zoom, scrollback
with fling, long-press selection with copy, paste, share and open link,
an extra keys bar (Esc, sticky Ctrl/Alt, Tab, arrows with auto-repeat,
Home/End/PgUp/PgDn, F1-F12), volume keys as font size or Ctrl/Alt,
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
# The terminal's fonts
| File | Font | Licence | Source |
|---|---|---|---|
| CascadiaCode.ttf | Cascadia Code (variable, wght 200-700) | OFL 1.1 | google/fonts `ofl/cascadiacode` |
| SauceCodeProNerdFontMono.ttf | Sauce Code Pro Nerd Font Mono, Regular | OFL 1.1 | ryanoasis/nerd-fonts `patched-fonts/SourceCodePro` |
| SourceCodePro.ttf | Source Code Pro (variable, wght 200-900) | OFL 1.1 | google/fonts `ofl/sourcecodepro` |
| RobotoMono.ttf | Roboto Mono (variable, wght 100-700) | OFL 1.1 | google/fonts `ofl/robotomono` |
| JetBrainsMono.ttf | JetBrains Mono (variable, wght 100-800) | OFL 1.1 | google/fonts `ofl/jetbrainsmono` |
| FiraCode.ttf | Fira Code (variable, wght 300-700) | OFL 1.1 | google/fonts `ofl/firacode` |
| OpenDyslexicMono.ttf | OpenDyslexic Mono, Regular | OFL 1.1 | antijingoist/opendyslexic `sources/opendyslexic-mono/OpenDyslexic-Mono.glyphs`, built with fontmake 3.12 (`-o ttf --feature-writer None`: the source's anchor `_` stops fontmake's mark feature writer; the glyphs are as they are) |
| Inconsolata.ttf | Inconsolata (variable, wght 200-900, wdth 50-200) | OFL 1.1 | google/fonts `ofl/inconsolata` |
| DroidSansMono.ttf | Droid Sans Mono | Apache 2.0 | AOSP `platform/frameworks/base/data/fonts` |
The licence texts are in `licenses/`; the app shows them (Settings, Font licences).
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,94 @@
Copyright (c) 2019 - Present, Microsoft Corporation,
with Reserved Font Name Cascadia Code.
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.
@@ -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.
@@ -0,0 +1,93 @@
Copyright 2014-2020 The Fira Code Project Authors (https://github.com/tonsky/FiraCode)
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://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.
@@ -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:
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.
@@ -0,0 +1,93 @@
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
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://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.
@@ -0,0 +1,94 @@
Copyright (c) 2019-07-29, Abbie Gonzalez (https://abbiecod.es|support@abbiecod.es),
with Reserved Font Name OpenDyslexic.
Copyright (c) 12/2012 - 2019
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.
@@ -0,0 +1,93 @@
Copyright 2015 The Roboto Mono Project Authors (https://github.com/googlefonts/robotomono)
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.
@@ -0,0 +1,93 @@
Copyright 2010-2020 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
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.
@@ -0,0 +1,93 @@
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.
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.
@@ -14,6 +14,7 @@ import androidx.datastore.preferences.preferencesDataStore
import com.neodesktop.dmodem.terminal.BackspaceMode
import com.neodesktop.dmodem.terminal.EnterMode
import com.neodesktop.dmodem.terminal.TermCharset
import com.neodesktop.dmodem.terminal.TerminalFont
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
@@ -31,6 +32,9 @@ enum class VolumeKeys(val label: String) {
/** How the terminal looks and behaves. */
data class TerminalSettings(
val themeId: String = "vga",
val font: TerminalFont = TerminalFont.SYSTEM,
/** programming ligatures (-> != ==) in the fonts that have them */
val ligatures: Boolean = false,
/** the text's size (sp) when the columns aren't fixed */
val fontSize: Float = 12f,
/** the columns the screen is fitted to (the text sized for them): 0 to size by fontSize */
@@ -63,6 +67,8 @@ class TerminalSettingsStore(private val context: Context) {
private object K {
val theme = stringPreferencesKey("theme")
val font = stringPreferencesKey("font")
val ligatures = booleanPreferencesKey("ligatures")
val fontSize = floatPreferencesKey("font_size")
val fixedColumns = intPreferencesKey("fixed_columns")
val charset = stringPreferencesKey("charset")
@@ -89,6 +95,8 @@ class TerminalSettingsStore(private val context: Context) {
val d = TerminalSettings()
TerminalSettings(
themeId = p[K.theme] ?: d.themeId,
font = enumOf(p[K.font], d.font),
ligatures = p[K.ligatures] ?: d.ligatures,
fontSize = p[K.fontSize] ?: d.fontSize,
fixedColumns = p[K.fixedColumns] ?: d.fixedColumns,
charset = enumOf(p[K.charset], d.charset),
@@ -114,6 +122,8 @@ class TerminalSettingsStore(private val context: Context) {
suspend fun save(s: TerminalSettings) {
context.terminalStore.edit { p ->
p[K.theme] = s.themeId
p[K.font] = s.font.name
p[K.ligatures] = s.ligatures
p[K.fontSize] = s.fontSize
p[K.fixedColumns] = s.fixedColumns
p[K.charset] = s.charset.name
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (C) 2026 Neo-Desktop
package com.neodesktop.dmodem.terminal
import android.content.Context
import android.content.res.AssetManager
import android.graphics.Typeface
/**
* The terminal's fonts: the system's monospace, or one of those in the
* app's assets (assets/fonts, their licences in assets/fonts/licenses).
* A variable font gets its regular and bold weights from the one file;
* one without a bold face is made bold by the paint.
*/
enum class TerminalFont(
val label: String,
/** the file in assets, null for the system's monospace */
val asset: String?,
/** a variable font (a 'wght' axis): its regular and bold weights */
val variable: Boolean = false,
/** its licence in assets/fonts/licenses */
val license: String? = null,
/** has programming ligatures (-> != ==) */
val ligatures: Boolean = false,
) {
SYSTEM("System monospace", null),
CASCADIA_CODE("Cascadia Code", "fonts/CascadiaCode.ttf", variable = true, license = "cascadiacode-OFL.txt", ligatures = true),
SAUCE_CODE_PRO("Sauce Code Pro (Nerd Font)", "fonts/SauceCodeProNerdFontMono.ttf", license = "saucecodepro-nerdfont-OFL.txt"),
SOURCE_CODE_PRO("Source Code Pro", "fonts/SourceCodePro.ttf", variable = true, license = "sourcecodepro-OFL.txt"),
ROBOTO_MONO("Roboto Mono", "fonts/RobotoMono.ttf", variable = true, license = "robotomono-OFL.txt"),
JETBRAINS_MONO("JetBrains Mono", "fonts/JetBrainsMono.ttf", variable = true, license = "jetbrainsmono-OFL.txt", ligatures = true),
FIRA_CODE("Fira Code", "fonts/FiraCode.ttf", variable = true, license = "firacode-OFL.txt", ligatures = true),
OPEN_DYSLEXIC("OpenDyslexic Mono", "fonts/OpenDyslexicMono.ttf", license = "opendyslexic-OFL.txt"),
INCONSOLATA("Inconsolata", "fonts/Inconsolata.ttf", variable = true, license = "inconsolata-OFL.txt"),
DROID_SANS_MONO("Droid Sans Mono", "fonts/DroidSansMono.ttf", license = "droidsansmono-Apache-2.0.txt");
/** a bold face of its own (not the paint's) */
val hasBold: Boolean get() = variable || asset == null
companion object {
fun byName(name: String?): TerminalFont = entries.firstOrNull { it.name == name } ?: SYSTEM
}
}
/** The fonts' typefaces, made once each. */
object FontCache {
private val cache = HashMap<Pair<TerminalFont, Boolean>, Typeface>()
@Synchronized
fun typeface(context: Context, font: TerminalFont, bold: Boolean): Typeface =
cache.getOrPut(font to bold) { load(context.assets, font, bold) }
private fun load(assets: AssetManager, font: TerminalFont, bold: Boolean): Typeface {
val path = font.asset ?: return Typeface.create(Typeface.MONOSPACE, if (bold) Typeface.BOLD else Typeface.NORMAL)
return try {
val b = Typeface.Builder(assets, path)
// (some fonts' default instance is light: Source Code Pro's is 200, Fira Code's 300)
if (font.variable) b.setFontVariationSettings("'wght' ${if (bold) 700 else 400}")
b.build() ?: Typeface.MONOSPACE
} catch (_: RuntimeException) {
Typeface.MONOSPACE
}
}
/** the font's licence text, or null */
fun license(context: Context, font: TerminalFont): String? = font.license?.let {
try {
context.assets.open("fonts/licenses/$it").bufferedReader().use { r -> r.readText() }
} catch (_: java.io.IOException) {
null
}
}
}
@@ -105,9 +105,20 @@ class TerminalView @JvmOverloads constructor(
applySettings(settings)
}
private var regularFace: Typeface = Typeface.MONOSPACE
private var boldFace: Typeface? = null
fun applySettings(s: TerminalSettings) {
val sizeChanged = s.fontSize != settings.fontSize || s.fixedColumns != settings.fixedColumns
val fontChanged = s.font != settings.font || s.ligatures != settings.ligatures || boldFace == null
val sizeChanged = fontChanged || s.fontSize != settings.fontSize || s.fixedColumns != settings.fixedColumns
settings = s
if (fontChanged) {
regularFace = FontCache.typeface(context, s.font, false)
boldFace = if (s.font.hasBold) FontCache.typeface(context, s.font, true) else null
textPaint.typeface = regularFace
// (ligatures off: one glyph per cell, as a terminal has it)
textPaint.fontFeatureSettings = if (s.ligatures) null else "'liga' 0, 'calt' 0, 'clig' 0, 'dlig' 0"
}
theme = TermTheme.byId(s.themeId)
keepScreenOn = s.keepScreenOn
session?.let {
@@ -141,9 +152,15 @@ class TerminalView @JvmOverloads constructor(
fontPx = fontPx.coerceIn(4f, 200f)
textPaint.textSize = fontPx
cellW = textPaint.measureText("M")
// the font's ascent and descent, or its glyphs' ink where that goes beyond them
// (some fonts declare less than they draw: OpenDyslexic)
val fm = textPaint.fontMetrics
cellH = floor(fm.descent - fm.ascent + 0.5f).coerceAtLeast(1f)
ascent = -fm.ascent
val ink = Rect()
textPaint.getTextBounds(METRIC_SAMPLE, 0, METRIC_SAMPLE.length, ink)
val up = max(-fm.ascent, -ink.top.toFloat())
val down = max(fm.descent, ink.bottom.toFloat())
cellH = floor(up + down + 0.5f).coerceAtLeast(1f)
ascent = up
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
@@ -240,15 +257,19 @@ class TerminalView @JvmOverloads constructor(
if (a and Style.BLINK != 0 && !settings.iceColors && !blinkOn) return
textPaint.color = fg
fillPaint.color = fg
textPaint.isFakeBoldText = a and Style.BOLD != 0 && !(settings.boldBright && Style.fg(st) in 0..7)
// bold glyphs (not only bright colours): the font's bold face, or the paint's
val heavy = a and Style.BOLD != 0 && !(settings.boldBright && Style.fg(st) in 0..7)
val bf = boldFace
textPaint.typeface = if (heavy && bf != null) bf else regularFace
textPaint.isFakeBoldText = heavy && bf == null
textPaint.textSkewX = if (a and Style.ITALIC != 0) -0.2f else 0f
runText.setLength(0)
var runStart = from
var runCells = 0
fun flush(at: Int) {
if (runText.isNotEmpty()) {
c.drawText(runText, 0, runText.length, runStart * cellW, y + ascent, textPaint)
runText.setLength(0)
}
if (runText.isNotEmpty()) drawRun(c, runText, runStart, runCells, y)
runText.setLength(0)
runCells = 0
runStart = at
}
for (x in from until to) {
@@ -263,10 +284,12 @@ class TerminalView @JvmOverloads constructor(
continue
}
if (runText.isEmpty()) runStart = x
// one glyph per cell: a wider glyph is drawn on its own, at its cell
runText.appendCodePoint(cp)
runCells++
}
flush(to)
textPaint.typeface = regularFace
textPaint.isFakeBoldText = false
if (a and Style.UNDERLINE != 0) {
c.drawRect(px(from), y + cellH - max(1f, floor(cellH / 14f)), px(to), y + cellH, fillPaint)
}
@@ -275,6 +298,32 @@ class TerminalView @JvmOverloads constructor(
}
}
/**
* cells' text from a column: as one run when its glyphs are the cells'
* width (the font's own), else each glyph in its cell (a fallback
* font's, wider or narrower), narrowed to fit it if need be
*/
private fun drawRun(c: Canvas, text: CharSequence, col: Int, cells: Int, y: Float) {
val w = textPaint.measureText(text, 0, text.length)
if (abs(w - cells * cellW) < 0.5f) {
c.drawText(text, 0, text.length, col * cellW, y + ascent, textPaint)
return
}
var i = 0
var x = col
while (i < text.length) {
val n = Character.charCount(Character.codePointAt(text, i))
val gw = textPaint.measureText(text, i, i + n)
val scale = if (gw > cellW) cellW / gw else 1f
textPaint.textScaleX = scale
val left = x * cellW + (cellW - gw * scale) / 2
c.drawText(text, i, i + n, left, y + ascent, textPaint)
textPaint.textScaleX = 1f
i += n
x++
}
}
/** a column's left edge, on a whole pixel */
private fun px(col: Int): Float = kotlin.math.round(col * cellW)
@@ -762,6 +811,8 @@ class TerminalView @JvmOverloads constructor(
}
companion object {
/** glyphs whose ink the cells' height must hold */
private const val METRIC_SAMPLE = "MHWgjpqy|_[]{}()"
private const val BLINK_MS = 530L
private const val FLASH_MS = 120L
const val MIN_SP = 5f
@@ -33,6 +33,21 @@ import com.neodesktop.dmodem.terminal.BackspaceMode
import com.neodesktop.dmodem.terminal.EnterMode
import com.neodesktop.dmodem.terminal.TermCharset
import com.neodesktop.dmodem.terminal.TermTheme
import com.neodesktop.dmodem.terminal.FontCache
import com.neodesktop.dmodem.terminal.TerminalFont
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.TextButton
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontVariation
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import kotlinx.coroutines.launch
/** The terminal's settings: each change saved (and on the screen) at once. */
@@ -50,6 +65,14 @@ fun TerminalSettingsSection() {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text("Terminal", style = MaterialTheme.typography.titleMedium)
Choice("Colours", TermTheme.byId(s.themeId).name, TermTheme.ALL.map { it.name to it.id }) { set(s.copy(themeId = it)) }
Choice("Font", s.font.label, TerminalFont.entries.map { it.label to it }) { set(s.copy(font = it)) }
FontPreview(s.font, TermTheme.byId(s.themeId))
if (s.font.ligatures) {
Flag("Ligatures (-> != ==)", s.ligatures) { set(s.copy(ligatures = it)) }
}
var showLicenses by remember { mutableStateOf(false) }
TextButton(onClick = { showLicenses = true }) { Text("Font licences") }
if (showLicenses) FontLicenses { showLicenses = false }
Choice(
"Width", if (s.fixedColumns > 0) "${s.fixedColumns} columns" else "By font size",
listOf("80 columns (BBS)" to 80, "132 columns" to 132, "40 columns" to 40, "By font size" to 0),
@@ -101,3 +124,58 @@ private fun Flag(label: String, value: Boolean, onChange: (Boolean) -> Unit) {
Switch(checked = value, onCheckedChange = onChange)
}
}
/** a line of text in the font, in the theme's colours */
@Composable
private fun FontPreview(font: TerminalFont, theme: TermTheme) {
val context = LocalContext.current
val family = remember(font) {
val path = font.asset
if (path == null) {
FontFamily.Monospace
} else if (font.variable) {
FontFamily(
Font(path, context.assets, FontWeight.Normal, variationSettings = FontVariation.Settings(FontVariation.weight(400))),
Font(path, context.assets, FontWeight.Bold, variationSettings = FontVariation.Settings(FontVariation.weight(700))),
)
} else {
FontFamily(Font(path, context.assets))
}
}
Column(
Modifier.fillMaxWidth().background(Color(theme.bgArgb)).padding(8.dp),
) {
Text("AaBbCc 0O1lI| {}[] -> != ==", fontFamily = family, color = Color(theme.fgArgb), fontSize = 15.sp)
Text(
"ATDT5551234 CONNECT 56000/V92",
fontFamily = family, color = Color(theme.palette[10]), fontSize = 15.sp, fontWeight = FontWeight.Bold,
)
}
}
/** the bundled fonts' licences */
@Composable
private fun FontLicenses(onDismiss: () -> Unit) {
val context = LocalContext.current
val text = remember {
TerminalFont.entries.filter { it.license != null }.joinToString("\n\n") { f ->
"── ${f.label} ──\n\n" + (FontCache.license(context, f) ?: "")
}
}
AlertDialog(
onDismissRequest = onDismiss,
title = { Text("Font licences") },
text = {
Column(Modifier.heightIn(max = 480.dp).verticalScroll(rememberScrollState())) {
Text(
"The terminal's fonts are under the SIL Open Font License 1.1, Droid Sans Mono under " +
"the Apache License 2.0. OpenDyslexic Mono is built from its upstream source. " +
"Sauce Code Pro is Nerd Fonts' patched Source Code Pro.",
style = MaterialTheme.typography.bodyMedium,
)
Text(text, style = MaterialTheme.typography.bodySmall, modifier = Modifier.padding(top = 12.dp))
}
},
confirmButton = { TextButton(onClick = onDismiss) { Text("Close") } },
)
}
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (C) 2026 Neo-Desktop
package com.neodesktop.dmodem.terminal
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Typeface
import android.view.View
import androidx.test.core.app.ApplicationProvider
import com.neodesktop.dmodem.modem.DteHub
import com.neodesktop.dmodem.settings.TerminalSettings
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNotSame
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode
import java.io.File
/**
* Every bundled font: it loads (not the system's in its place), its cells
* stay on the grid with glyphs it hasn't got (a fallback font's), and a
* picture of them all in build/terminal-fonts.png.
*/
@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(sdk = [35])
class TerminalFontsRenderTest {
private val w = 960
private val h = 66
@Test
fun everyFontLoadsAndKeepsTheGrid() {
val ctx = ApplicationProvider.getApplicationContext<Context>()
val sheet = Bitmap.createBitmap(w, h * TerminalFont.entries.size, Bitmap.Config.ARGB_8888)
val sc = Canvas(sheet)
val label = Paint(Paint.ANTI_ALIAS_FLAG).apply { textSize = 13f; color = 0xffffff00.toInt() }
for ((i, font) in TerminalFont.entries.withIndex()) {
if (font.asset != null) {
val tf = FontCache.typeface(ctx, font, false)
assertNotSame("${font.label} loaded", Typeface.MONOSPACE, tf)
assertNotNull(ctx.assets.open(font.asset!!))
}
val session = TerminalSession(DteHub()) { null }
session.charset = TermCharset.CP437
val v = TerminalView(ctx)
v.session = session
v.applySettings(TerminalSettings(font = font, fixedColumns = 80, cursorBlink = false, ligatures = true))
v.measure(View.MeasureSpec.makeMeasureSpec(w, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(h, View.MeasureSpec.EXACTLY))
v.layout(0, 0, w, h)
val e = "\u001b"
// glyphs not every font has (⌐ ≡ ⌠ ⌡ ∙), then a red block at column 40
val text = "${font.label.take(18).padEnd(18)} 0O1lI -> != ⌐≡⌠⌡∙±÷"
val art = TermCharset.CP437.encode(text.padEnd(40).take(40) + "$e[31m█$e[0m $e[1;32mBold$e[0m ╔═╗░▒▓")
synchronized(session.emulator) { session.emulator.append(art) }
val bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
v.draw(Canvas(bmp))
sc.drawBitmap(bmp, 0f, (i * h).toFloat(), null)
sc.drawText(font.name, w - 200f, i * h + h - 6f, label)
assertEquals(80, session.emulator.cols)
val cw = w / 80f
val red = bmp.getPixel((40 * cw + cw / 2).toInt(), 4) and 0xffffff
assertEquals("${font.label}: the block at column 40 on its cell", 0xaa0000, red)
// the cell before it is the background: nothing pushed into it
val before = bmp.getPixel((39 * cw + cw / 2).toInt(), 4) and 0xffffff
assertTrue("${font.label}: column 39 empty (0x${Integer.toHexString(before)})", before == 0)
}
File("build/terminal-fonts.png").outputStream().use { sheet.compress(Bitmap.CompressFormat.PNG, 100, it) }
}
@Test
fun variableFontsHaveARealBold() {
val ctx = ApplicationProvider.getApplicationContext<Context>()
for (f in TerminalFont.entries.filter { it.variable }) {
val p = Paint().apply { textSize = 100f }
p.typeface = FontCache.typeface(ctx, f, false)
val regular = Bitmap.createBitmap(120, 120, Bitmap.Config.ARGB_8888)
Canvas(regular).drawText("W", 0f, 100f, p)
p.typeface = FontCache.typeface(ctx, f, true)
val bold = Bitmap.createBitmap(120, 120, Bitmap.Config.ARGB_8888)
Canvas(bold).drawText("W", 0f, 100f, p)
fun ink(b: Bitmap): Int {
var n = 0
for (y in 0 until 120) for (x in 0 until 120) if ((b.getPixel(x, y) ushr 24) > 128) n++
return n
}
assertTrue("${f.label}: bold has more ink (${ink(bold)} > ${ink(regular)})", ink(bold) > ink(regular) * 1.15)
}
}
}