• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Scala
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Stylish Computer Generated Handwritings

Muse-CGH

点击此处阅读中文版(Click here to read the Chinese version)

A program to synthesize stylish Computer Generated Handwriting.

you can download the compiled program (v1.4.2) directly (.jar file)

Overview

Muse can synthesize stylish English handwriting from plain texts. Its algorithm carefully connects strokes of adjacent characters to create cursive words and uses random perturbations to ensure that every character is unique in the rendering results.
The following photo shows some rendered text printed on paper:

alt tag

You can learn more about Muse's features through videos on my homepage.

Usage

Muse works in two modes: GUI mode and Command-line mode.
  • The GUI mode is the easiest way to use Muse, as it provides interactive editing experience. Just enter the text, click the 'render' button, and you will see the rendered result immediately. If you are not satisfied with the result, just adjust parameters on the control panel, the result then updates accordingly.
  • The Command-line mode can be very helpful if you plan to use Muse in non-Scala projects.

GUI mode

If you run Muse directly (by double click on the .jar file or by providing no command-line arguments), the program will start in GUI mode.

alt tag

In the image shown above, the upper right panel is Muse's Rendering Result Panel, where the rendered image or animation is presented; the upper left panel is Control Panel, a place you enter text or adjust parameters; the button left panel is the Console Output Panel, it tells you information about Muse's state.
  • At the bottom of Control Panel, there are two checkboxes. If you check the 'Interactive' box, every time you change the text content, without clicking 'Render' button, the Result Panel will update automatically. If you check the 'Animation' box, Result Panel will change into animation mode, then you can watch Muse writing in action!

  • At the top of Control Panel, there are two buttons. Click the 'Font Editor' button to bring up the font editor. You can create new Muse Characters or modify the existent ones as you wish. After saving your changes in the font editor, click the 'Reload Letters' button in the Control Panel to let Muse reload character map from disk. (Muse load its characters from a folder named 'letters' in its current directory)

  • As you can see, there're quite many parameters you can change. Help texts will show up if you hover the mouse cursor over them.

With Muse's newly updated Font Editor, you can design your own fonts with ease.

alt tag

Command-line mode

Muse use scopt to parse Command-line arguments.

If you provide at least one command-line arg, Muse will enter command-line mode.

Some examples (here '$' is the command-line prompt):
$ java -jar Muse.jar SampleText.txt --out myPngResult.png --FontSize 30
letters missing:
-----
arguments parsed
start to render text...
rendering finished.

start to paint text...
painting time use 105 ms.
painting finished.
saving results...
results saved to /Users/weijiayi/Desktop/Muse1.3/myPngResult.png
$

In the example above, you use java -jar Muse.jar to run Muse in command-line, then you provide the name or path of a text file (SampleText.txt in this case) as an argument. You can also use options to override the default rendering parameters.

If wrong command-line arguments are provided, Muse will print out the usage text, in which all settable parameters along with their descriptions, constraints and default values are given.
$ java -jar Muse.jar --WrongArg
Error: Unknown option --WrongArg
Error: Missing argument <input file>
muse 1.3
Usage: muse [options] <input file>

  <input file>
        the input file to read.
  -o <value> | --out <value>
        the out image name (if no extension specified, use .png)
  --LineWidth <value>
        Line width: maximum line width, must be greater than Break threshold (default: 90.0)
  --LineSpacing <value>
        Line spacing: distance between lines, must be positive (default: 4.0)
  --BreakThreshold <value>
        Break threshold: maximum empty space allowed before breaking the last word in a line, must be smaller than Line width (default: 4.0)
  --AspectRatio <value>
        Aspect Ratio: the ratio of image height and width, use automatic aspect ratio if specified as negative, must be float number (default: -1.0)
  --PixelDensity <value>
        Pixel density: how many pixels per unit length, a lower case 'a' is about 1 unit high, must be positive (default: 10.0)
  --Samples <value>
        Samples: how many quadrilaterals are used per unit length, must be positive (default: 50.0)
  --Lean <value>
        Lean: tan value of the sloping angle, must be float number (default: 0.3)
  --Thickness <value>
        Thickness: the thickness of strokes, must be positive (default: 2.8)
  --SpaceWidth <value>
        Space width: the size in unit for a whitespace, must be positive (default: 0.8)
  --LetterSpacing <value>
        Letter spacing: extra spacing between letters in a word, must be float number (default: 0.0)
  --MarkSpacing <value>
        Mark spacing: extra spacing for punctuation marks and numbers, must be float number (default: 0.4)
  --LetterRandom <value>
        Letter Random: how much randomness is used for letters in words, must be float number (default: 0.07)
  --LineRandom <value>
        Line Random: how much randomness is used for height perturbation of words in a line, must be float number (default: 0.1)

How to use the source code

You can run the source code as an sbt project. A build.sbt file has been added to this project recently.

License

This work is under the MIT license, so feel free to use it in your own projects :)

More Repositories

1

LambdaNet

Probabilistic Type Inference using Graph Neural Networks
Scala
47
star
2

textVary

Help you write better GRE/TOEFL essays by detecting your repeating phrases.
Scala
26
star
3

Singularity

Pattern Fuzzing for Worst-Case Algorithmic Complexity using Program Synthesis
Scala
21
star
4

Coeditor

Coeditor: Leveraging Repo-level Diffs for Code Auto-editing
Python
20
star
5

SmartAsserts.jl

A drop-in replacement of `Base.@assert` that prints out additional information upon failure.
Julia
17
star
6

SimpleTypePrint

Display Julia types in a more human-friendly way.
Julia
11
star
7

TensorSafe

Encode tensor/matrix shapes into Scala's type system.
Scala
7
star
8

Escher-Scala

Recursive Program Synthesis using input-output examples
Scala
7
star
9

TOEFL-preparation

6
star
10

vscode-coeditor

It's like Copilot but for suggesting where and how to make code changes.
TypeScript
4
star
11

STEADY

Simultaneous State Estimation and Dynamics Learning from Indirect Observations.
Julia
3
star
12

CAS-scala

A simple Computer Algebra System in Scala
Scala
3
star
13

LensTrace

A ray tracer written in Scala, featuring dispersion effects
Scala
3
star
14

Youdao-for-mac

Add "look up in Youdao" Service to your mac. 为你的Mac添加“有道查询”功能。
2
star
15

Lambda-In-Haskell

A haskell library for lamdba calculus.
Haskell
2
star
16

RecipeManager

Mr V+1's Recipe Manager for Scala Programmers
Scala
1
star
17

LazyLang

A Haskell-style lazy language in 500 lines of Scala code
Scala
1
star
18

ScalaAlgebraSystem

A Computer Algebra System (CAS) written in Scala.
Scala
1
star
19

SpaceY

Landing rockets using deep reinforcement learning!
Scala
1
star
20

GalaxySimulation

A demonstration of Barnes–Hut's algorithm for n-body simulations
Scala
1
star
21

old-page-2020

Jiayi Wei's homepage repo
HTML
1
star