graphemy-typst/README.org
2025-06-17 17:43:32 +02:00

49 lines
2.5 KiB
Org Mode
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

* ~graphemy-typst~
Use [[https://codeberg.org/zhuriel/graphemy][Graphemy]] scripts in your typst documents
** Build
Dependencies
- Cargo with the Rust =wasm32-unknown-unknown= toolchain installed
Run ~build.sh~.
** Installation
*** As a typst package
The =typst= directory contains the typst package files that you can copy to your local package repository. See the [[https://github.com/typst/packages/blob/main/README.md#local-packages][typst package documentation]] for more information.
*** As a standalone typst file
Copy =typst/graphemy_typst.wasm= and =typst/graphemy.typ= to your project directory. (this is the method that will be used in the rest of this document.)
** Usage
Import the ~load-gmy~ function from the package
#+begin_src typst
#import "graphemy.typ": load-gmy
#+end_src
Load your script, This will read the specified file. you can also add here options that should be set for all instances of your script, such as ~margin~
#+begin_src typst
#let myscript = load-gmy("myscript.gmy").with(margin: 3)
#+end_src
Use your script as a function which formats strings
#+begin_src typ
#myscript("my sample text")
#+end_src
Available options are
- ~width~ :: The width of the resulting text in absolute length, also informs the linewidth for the graphemy typesetter if it is not set separately. (default: auto)
- height :: The height of the resulting text in absolute length. If both ~width~ and ~height~ are set, informs the shape of the bounding box for the text. (default: auto)
- ~margin~ :: The margin left around the image by graphemy, useful in stroke-based scripts. (defaulut: 0)
- ~comment~ :: Doesnt do anything in practice, only added for completness of the Graphemy rendering options. (default: none)
- ~fg~ :: the foreground color of the rendered text, specified as a Typst color value (default: color.black)
- bg :: the background color of the rendered text, specified as a Typst color value (default: none)
- ~linewidth~ :: the logical linewidth in absolute length, if it isnt specified but ~width~ is, it is used instead, otherwise the default is 100pt.
- scale :: overall scale factor of the text, doesnt affect the typst bounding box, just the scaling.
** License
Copyright © Annwan 2025
This project is licensed under the terms of the GNU General Public License version 3. A copy of the license can be found in [[LICENSE]] or obtained from the Free Software Fundation at [[https://www.gnu.org/licenses/gpl-3.0.en.html]].
Graphemy is Copyright © Zhuriel 2024-2025, licensed under the terms of the GNU General Public License version 3.