Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
42098402
Commit
42098402
authored
1 year ago
by
Anon
Browse files
Options
Downloads
Patches
Plain Diff
docs: document fonts
parent
e39885b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!125
Add Comic Mono and font docs
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/api/ctx.rst
+2
-0
2 additions, 0 deletions
docs/api/ctx.rst
docs/badge/fonts.rst
+92
-0
92 additions, 0 deletions
docs/badge/fonts.rst
docs/index.rst
+1
-0
1 addition, 0 deletions
docs/index.rst
with
95 additions
and
0 deletions
docs/api/ctx.rst
+
2
−
0
View file @
42098402
.. _ctx API:
``ctx`` module
==============
...
...
This diff is collapsed.
Click to expand it.
docs/badge/fonts.rst
0 → 100644
+
92
−
0
View file @
42098402
.. _Fonts:
Fonts
=====
The current selection of fonts is baked into the firmware for use with :ref:`Context<ctx API>`.
Available Fonts
---------------
Following fonts are currently available:
+-------------+----------------------+
| Font Number | Font Name |
+=============+======================+
| 0 | Arimo Regular |
+-------------+----------------------+
| 1 | Arimo Bold |
+-------------+----------------------+
| 2 | Arimo Italic |
+-------------+----------------------+
| 3 | Arimo Bold Italic |
+-------------+----------------------+
| 4 | Camp Font 1 |
+-------------+----------------------+
| 5 | Camp Font 2 |
+-------------+----------------------+
| 6 | Camp Font 3 |
+-------------+----------------------+
| 7 | Material Icons |
+-------------+----------------------+
| 8 | Comic Mono |
+-------------+----------------------+
The Camp Fonts are based on Beon Regular, Saira Stencil One and Questrial Regular.
Material Icons contains Glyphs in the range of U+E000 - U+F23B.
See header files in ``components/ctx/fonts/`` for details.
Basic Usage
-----------
To switch fonts, simply set ``ctx.font`` and refer to the font by full name:
.. code-block:: python
ctx.rgb(255, 255, 255)
ctx.move_to(0, 0)
ctx.font = "Camp Font 1"
ctx.text("flow3r")
To insert one or more icons, use Python ``\u`` escape sequences.
You can look up the code points for icons on `https://fonts.google.com/icons <https://fonts.google.com/icons>`_.
.. code-block:: python
ctx.save()
ctx.rgb(255, 255, 255)
ctx.move_to(0, 0)
ctx.font = "Material Icons"
ctx.text("\ue147 \ue1c2 \ue24e")
ctx.restore()
Adding New Fonts
----------------
To add a new font to the firmware, it must first be converted into the ctx binary format.
ctx provides the tools for this and you can set them up them with the folling commands:
.. code-block:: bash
git clone https://ctx.graphics/.git/
cd ctx.graphics
./configure.sh
make tools/ctx-fontgen
Now you can use ``ctx-fontgen`` to convert a font:
.. code-block:: bash
./tools/ctx-fontgen /path/to/ComicMono.ttf Comic_Mono latin1 > Comic-Mono.h
Note that the font name is read from the source file directly and not specified by any of the arguments.
You can find it at the end of the header file. In this case: ``#define ctx_font_Comic_Mono_name "Comic Mono"``.
The next step is to copy the header file over into ``components/ctx/fonts`` (and adding license headers, etc).
Once the file is in the fonts directory, it can be added to ``components/ctx/ctx_config.h``.
In there it needs an include and define with a new font number.
The new font is now available in the next firmware build, but the simulator needs a rebuild of the Wasm bundle.
See ``/sim/README.md`` for details.
This diff is collapsed.
Click to expand it.
docs/index.rst
+
1
−
0
View file @
42098402
...
...
@@ -19,6 +19,7 @@ Welcome to flow3r's documentation!
badge/badge_link.rst
badge/badge_net.rst
badge/bl00mbox.rst
badge/fonts.rst
.. toctree::
:maxdepth: 1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment