Skip to content

Gather handwriting from a photo/scan into a character library; Export text as 'handwritten' images!

License

Notifications You must be signed in to change notification settings

ProcStack/pxlTextGenerator

Repository files navigation

pxlTextGenerator v0.2.5 - Beta

Text to Handwriting Generator

Turn your written characters into an image based font

Export with custom page backgrounds to PNG


Index



Welcome Message & Tool Information

This tool is designed to allow users to gather hand written characters,
(Or I guess, any connected mass)
In photos/scans/images and export them to an image library and database.
- Written with Python 2.7 and PyQt 4

A Character Database is built and can be used to convert typed text into seemingly hand written images.
You can save those pages to a Page Database or export them as PNG files!
(The Character and Page Database Files let you jump back in where you left off, allowing you to edit all the settings.)

Since I have an intended purpose for this tool, it currently looks for darker objects.
Like having ink that is darker than the paper it's on.
This is done by looking out pixel by pixel to see if it's under a user-settable brightness threshold.

In the future, I'd like to add OCR (Optical Character Recognition) functionality.
Since it supports having as many character variations as you'd like, they could be used as training material for the OCR.
But that will be some time from now... We all have lives to manage and things that distract us.

It's slow right now, optimizations are being worked on,
But I'm hoping to expand out toward OpenGL / C++ in the future.
(Especially for the OCR support)
Python and PyQt was just the easy route to start with.

** Since this is still in Beta, some aspects are in flux **
The only major changes I forsee is GUI layout and adding new features.
If you find any bugs or have any suggestions, feel free to contact me at--
Kevin@Metal-Asylum.Net

- Kevin Edzenga


Graphical Overview

Letter to Character Interface

pxlTextGenerator Overview

Characer to Page Interface

pxlTextGenerator Page Output


Gifs of Features

Turn Letters into Characters

Letter Picking

Size and Fit Characters

Testbed Letter Sizing

Build Pages

Build a Page


Starting Out

The tool is expecting a folder in its root with images ( jpg, jpeg, png, bmp )
These photos should be scans/photos you took of your handwriting/letters/characters

With the tool open, click Set Project Folder, and select your folder.
The tool will then create three folders,

  • pxl_textBases_origImages - Your scans/photos will be moved to this directory
  • pxl_textCharacterOutput - Your exported Characters will be stored here as PNG files
  • pxl_pageBuilderOutput - Your exported Pages will be stored here as PNG files

If all went well, the tool should load up the first image it finds from pxl_textBases_origImages,
With a list of all your files on the top of the window

Things to note-

  • For sliders, you can click on the text next to the slider to manually enter in a value.
    • Only vertical sliders and the Left/Right Align sliders on the Character Entry Editor (Right side) don't have this feature yet.
  • After you select your character and run Read Found Character Data the Final Output thumbnail will have 3 red lines on it. You can click near those red lines and drag to adjust the values without fudging around with the sliders.
  • If you are working on editing a Character Entry, type the character out in the TextBed on the bottom to see your changes in real time. (Vertical/Left/Right Alignment and Scaling mostly)
  • Hotkeys --
    • P - Load a Project Folder
    • T - Sample Threshold Color; toggle
    • S - Select Mode
    • A - Set to Add Brush
    • R - Set to Remove Brush
    • W - Set Working Area; toggle
    • C - Crop to Work Area; toggle
    • O - Show Outline Only; toggle

Character Builder Tab

TextBase Image Viewer

  • Set Project Folder - P hotkey - Sets and Attempts to load existing data
  • Reset Character Data - Resets all currently selected character data (The green color after sampling)
  • TextBase Image List - List of all your images, Hide/Show Toggle
  • Hide/Show TextBase List - Hide/Show visibility toggle for the TextBase Image List
  • Searching Threshold - Value of brightness that searching stops at.
    • (Searching finds darker colors than the threshold value.)
  • Sample Threshold by Color - T hotkey - Lets you select pixels to set the Searching Threshold
    • (Set the threshold lower once it's set, its the exact value it found, you want darker)

pxlTextGenerator Page Output

  • Modes- [When Active image]
    • Select Area - S hotkey -
      Select Character Mode Option
      • Search for a character
      • No Brush Indicator
    • Add Brush - A hotkey -
      Add Brush Option
      • Add pixels to found area
      • Brush Indicator is a Green color
    • Remove Brush - R hotkey -
      Remove Brush Option
      • Remove pixels to found area
      • Brush Indicator is a Purple color
  • Add/Remove Brush Size - Size of Add/Remove Brushes
  • Edge Grow/Shrink - Contract or Expand your character's edge per pixel
    • Negative (-1) to Contract
    • Positive (1) to Expand
  • Set Working Area / Remove Work Area - W hotkey - Isolate an area of your TextBase Image to help speed up performance and make tools/brushes easier to use.
    • Click it, the button's text will switch to Remove Work Area and turn blue, then click and drag in the TextBase area to draw a blue working area outline.
    • Clicking again will remove the current work area you have set.
  • Crop To Work Area / Exit Work Area Crop - C hotkey - To help speed up things further, you can view the Work Area by itself for faster feed back for Select/Add/Remove Brushes.
    • Click it to isolate your Work Area, the button's text will change to Exit Work Area Crop and turn blue.
    • Clicking it again will bring back the whole image you are working on.
  • Exit Work Area on Reset - Auto Exit Work Area Crop
    • When Off, if you Reset Character Data, it will keep the TextBase Viewer in Crop mode.
    • When On, it will exit Crop mode when you Reset Character Data.
  • Show Outline Only / Exit Outline Only - O hotkey - Sometimes the character found might have grabbed some junk, this will outline the found character
    • Clicking again will redraw the found area as it normally looks

Character Settings

  • Read Found Character Data - Load your character data.
    • Once you search for a character in the TextBase Viewer,
    • This button will gather all the data and build transparency information for you
    • You can then edit the character with the below options.
  • Crop, Found Area, Alpha Thumbnails - After running Read Found Character Data thumbnails are generated to show aspects of the found character data.
    • 'Alpha' refers to the transparency of the final image.
      Like how you can see the checkerboard pattern behind the main Character image.
    • Currently These thumbnails are for reference only.
  • Character Final Output Image - This is what your final character looks like.
    • *The checkered background is just to help with seeing the transparency in the character. Its removed when you click Finishe Character
    • There are 3 red lines; 2 vertical and 1 horizontal
      • The left vertical line is the desired spacing on the left side of the character to it's neighbor.
      • The right vertical line is the same as the left, but spacing on the right side of the character from its neighbor.
      • The horizontal line is the base of the character. Where the character will line up vertically on a line of text.
    • (If you click near a red line and drag, it will move the line for you. No need to use the sliders.)
  • Top/Bottom - These side sliders add or remove bounding box's top or bottom
  • Left/Right Align - The left/right most edge of the character, for spacing characters correctly
  • Base Line - Where the character aligns vertically on the line, for TextBed and Page
  • PreMultiply Scale - The amount the character is multiplied before added to the line, for TextBed and Page
  • Alpha Fade Reach - Pixel distance from the edge to had a fade to transparent
  • Alpha Contrast - The % visibility of the Alpha Fade edge.
  • Degree Rotation - Rotate the character counter-clockwise or clockwise by Negative or Positive degrees, respectively.
  • Finish Character - Creates a new Character Entry in the side bar with all of your settings stored on the entry.

Side Bar

  • Current TextBase - Thumbnail of the current TextBase image
    • Clicking it will Reset Character Data in the TextBase Viewer
  • Filter - Display only specific characters here.
    • Putting in 'A' will display only Capital Letter A's
    • Putting in 'AaB' will display only Capital Letters 'A' and 'B', along with Lowercase 'a'
  • Character Entry List - Clicking the Character in the Entry List will load the settings into the Character Settings
    • Existing un-Finish'ed character parameter details are lost

TextBed

  • Load Text Image - Load a background image into the TextBed
    • One is provided in the root of pxlTextGenerator
  • Reload Text - Reload any changes made to characters or Text Field
  • Input Test Text - Characters to display in the TextBed Viewer
  • Pull Capital Letters - Loads all Capital letters into the Text Field
  • Pull Lower Letters - Loads all Lower Case letters into the Text Field
  • Pull Numbers - Loads all Numbers into the Text Field
  • Pull Non-Alphanumeric - Loads all non-letters and non-numbers into the Text Field
  • Missing Characters - Any non-existent characters will show up here from your Input Text Text
  • Auto Update - Any changes in Character Settings or Text Field will automatically show up when On.
  • Vertical Sliders -
    • First, Top of character reference bar
    • Second, Mid of character reference bar
  • Character TextBed Display - Output of the Text Field as your Writing

Page Output Tab

Sidebar Options

  • Load Page Data File - Loads any previous Page Data written to disk
  • Load Page BG Image - Load a background image into the Page Output viewer
    • One is provided in the root of pxlTextGenerator
  • Input Page Text - The text you'd like to add to the page.
    • You can add special characters by adding % before and after
    • For a Concerned Smiley Face, %ocl%
    • (All created special characters must be created by you)
  • Page Indentation; Left, Top, Right, Bottom - Page margins
    • Indicated by red lines in the Page Output Viewer
  • Font Scale - Global scale multiplier of characters as they are added into the page
  • Font Kerning - Global kerning size in pixels, the distance between characters in the page
  • Space Size - Size of a 'space' in pixels
  • Line Height - How spread apart each new line is in pixels
  • Line Indent - Indentation distance of wrapped lines of text
  • Random Seed - The random value used when picking each character.
    • Lets say you have 4 'A' characters and type 'AAAA'
    • Random Seed 0.0 might give you A3,A2,A4,A1
    • Random Seed 3.1 might give you A1,A4,A1,A2
  • Flip Text Output Horizontally - Will flip the text on page horizontally, when On
  • Auto Update Page - Any changes will rebuild the page, when On
  • Update Output Text to Writing - Update the current page you are editing
  • New Empty Page Entry - Creates a new empty Page Group, resetting you values
    • Any unsaved changes to the current page you are working on will be lost
  • Set as New Page Entry - Creates a new Page Group from your current settings
  • Scale Exports to Power of 2 - Scales down the page image resolution to power of 2
    • Finds the closest smaller resolution of Height & Width; scales down upon export.
    • *(OpenGL textures require resolutions in powers of 2; 512, 1024, 2048, etc.)
  • Output Directory - Directory to export your Page Images to
  • Write Page Data File - Write out the Page Data File ONLY; projectName/pageListKey.py
  • Export All Page Data & Images - Write out the Page Data File and all Page Images

There is an implimented scipting system for modifying your Input Page Text -

pxlTextGenerator Page Output

Special Characters-

  • %charName% to output the character you desire
    • eg- %str% for a star symbol instead of just a multiply symbol
  • Custom special characters not implimented yet,
    • Thats a little outside my current needs for this tool.
  • Current supported special characters-
    • ocl,ocr,oll,olr,osl,osr,oal,oar,str
  • They can be set to what ever you'd like though
    • Just because it's called str doesn't mean it needs to be a star.

Font Modifying Tags-

  • %###% to scale text; %50% is 50 percent scale, %100% to get back to normal

  • %align:position% - the positions can be left, center, or right
    • %align:center%** to align your text center then **%align%`** to reset to left alignment.
    • Affects whole line until set again or reset with %align%
  • %a:position% - Set alignment for current line only
    • Any return or \n will reset the alignment to left

  • %offset:#,#% - Offset characters in X,Y by pixels
    • Relative offset for all following text.
    • If you put only one number, it will offset only in Y
      • %offset:10% - Will offset the following text [0,10]
    • Affects whole lines until set again or reset with %offset% or %o%
  • %o:#,#% - To set offset for the next character only
    • It will reset to 0,0 offset after the next character.

  • %absolute:#,#% / %abs:#,#% - Absolute line position in X,Y by pixels
    • Absolute placement of text on page.
    • (Currently only affects current line)
    • If you put only one number, it will offset only in Y
      • %abs:10% - Will position the text line to [0,10]
    • Affects whole lines until set again or reset with %offset% or %o%
    • Alignment works within absolute position tags too.
      • %abs:20%%a:center% Will center align your line, with Y position 20 pixels from top of page.

  • %smallCaps:1% / %sc:1% - Turn lower case letters into small capitals.
    • You can set the relative scale of the small caps with the Small Capital Scale slider.
    • %sc% to exit from small capitals.

  • %rotate:degrees% - Rotate characters in degrees for all following text.

  • %spaceSize:pixels% - Line space size ixels is relative offset.
    • %spaceSize:-10% - If space size is 50, it will be 40
    • Affects whole lines until set again or reset with %spaceSize% or %ss%
  • %ss:pixels% - Set spaceSize for current line only
    • Any return or \n will reset the spaceSize to current setting

  • %kern:pixels% - Line character kerning in relative pixels offset.
    • %kern:-10% - If kerning is 0, it will be -10
    • Affects whole lines until set again or reset with %kern% or %k%
  • %k:pixels% - Set kerning for next character only
    • It will reset to a 0 pixel kerning offset after the next character.

  • %lineHeight:pixels% - pixels is relative offset
    • %lineHeight:-20% - If line height is 70, it will be 50
    • %lineHeight% to clear offset.
    • Affects whole lines until set again or reset with %lineHeight% or %lh%
  • %lh:pixels% - Set lineHeight pixels for current line only
    • Any return or \n will reset the lineHeight to current setting

  • %seed:#% - Set the seed random for following characters.
    • %seed:12.4% to set a random value of 12.4
    • %seed% to reset to your set seed
    • This is good for changing a lot of characters in a word or line.
  • %s% or %s:#% - To set a random or specific seed for the next character only
    • If a specific character is a repeat of a near by variation-
      • will and both 'l's are the same 'l'-
      • wil%s%l changes the second 'l' to a different variation

  • %opacity:percent% - Percentage is 0-100
    • %opacity:50% - The characters following will be at 50% opacity.
    • Affects whole lines until set again or reset with %opacity% or %op%
  • %op:percent% - To set opacity for the next character only
    • It will reset to 100% opacity after the next character.

In the pageOutput image above, the following input text was used to generate that output-

Support for --
%align:right%%140%ALL KINDS%100% of stuff!%a%
%a:center%%60%Scale,%100%%opacity:50%Opacity,%op% %offset:-30,50%&%k:20%Offsets!%o%
%lh:60%Change line heights.
%lineHeight:30%Normal left align.
%align:center%Center align text.%a%
%align:right%Right align text.%align%%lh%
%a:center%%ss:70%Changing space sizes
%kern:35%%ss:30%%a:center%%lh:25%Kerning also!!%o%%k%
%lh:-25%
%a:center%- Edit current line only tags -
%lineHeight:30%%%ss:-50%a:position%%ss% to change alignment
%%ss:-50%ss:pixels%%ss% to change space size
%%ss:-50%lh:pixels%%ss% to change line height%lh%

%a:center%- Edit next character only tags -
%lineHeight:30%%%ss:-50%k:#%%ss% to change kerning
%lineHeight:30%%%ss:-50%o:#,#%%ss% to change offset
%%ss:-50%op:percent%%ss% to change opacity
%%ss:-50%s:pixels%%ss% to change character variation

Bottom Bar (After loading a Page BG Image)

  • Page Group List - List of all your current work
  • Per Group - Isolated group of pages built from one text input
    • Name of Group - This is the prefix name to your pages
      • A Name of 'Info' will export the pages as 'Info_1', 'Info_2', etc...
    • Edit Pages - Load and set all of the settings for that Page Group for Editing
    • Delete Pages - Deletes the ENTIRE Page Group
    • Thumbnail - Small little view of whats going on on the page

Thanks for checking out pxlTextGenerator!

About

Gather handwriting from a photo/scan into a character library; Export text as 'handwritten' images!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages