Giter Club home page Giter Club logo

inkscapestrokefont's Introduction

Inkscape Extensions to Create Custom Stroke Fonts and Render Text Using Them

These extensions allow the users to create and edit their own stroke fonts (including non-english ones) and render text using them. The fonts created with these extensions are compatible with the fonts used by the Hershey Text Effect (Copyright 2011, Windell H. Oskay, www.evilmadscientist.com) available in Inkscape 1.0. Three new custom fonts (including a cursive one) are prebundled with the extensions.

Compatible with Inkscape versions 1.0 and 0.92

Installation

  1. Click on the Code button above the repository list
  2. Select Download Zip option and save the zip file to a local folder
  3. Locate the User Extensions folder, this can be found from the System option in Edit->Preference dialog.
  4. Extract the contents of the folder within the downloaded zip file in the Inkscape user extension folder. For example: if your download file is inkscapestrokefont-master.zip, then opening the file will show a single folder called inkscapestrokefont-master. Double click this folder within the zip and extract all its contents in the extensions folder. So after extracting the zip, there should be 14 files and one 1 folder called 'strokefontdata' added in the user extensions folder
  5. Restart inkscape if it was running

Usage

After installation, the extensions appear under a new sub-menu 'Custom Stroke Font' under Extensions menu of inkscape.

Rendering Text
Demo To render a text string using the custom stroke fonts, use the Render Text extension. There are a number of options to taylor the rendering.
To have an aligned text, create rectangle(s) and select it (them) before invoking the render text tool. Now check the 'Flow Text in Boxes' and select horizontal and vertical alignment options. If the 'Create Extended Rectangles' option has a value oher than 'None' and if the text does not fit the given set of rectangles, then new rectangles will be created in the selected direction to fit the entire text.
It's possible to render an entire text file in stroke font with the 'Render text from file' option. For large files, however, it might take considerable time for rendering. The resulting file size may also become quite large, since path of every letter is stored separately.
The extensions come with 3 pre-designed custom fonts. The existing Hershey Text fonts are also ported to the format required for these extensions. These fonts are available in the Render Text tool with prefix 'Hershey'.

Designing New Fonts
To create your own font you need to first create a template invoking 'Create Font Design Template' extension. Then design the fonts with reference to the guides in the template. Each designed glyph should be a single SVG path (if there are multiple segments they need to be combined in a single path). The path should have the XML ID same as the character text. So A glyph representing A should have its ID set to 'A' (without quotes).
You can duplicate the guides within the template to define new reference lines if that helps designing the font (example ScriptLastNodeOffset.svg and ScriptGlyphsAlignedWithEditExt.svg). But bear in mind, only the guides created by the Create Font Design Template extension will be used to calculate the offsets.

After completing the design the 'Generate Font Data' extension needs to be invoked to store the path data of the glyphs. The glyphs of a font are stored in an SVG file in strokefontdata subfolder within the user extensions folder. The name of the file is the same as the font name, so the font names have all the restrictions that are applicable to file names. If the file for the given font exists, the glyphs are added to it (or replaced if there exist any with the same IDs), if not a new xml file is created.
Glyphs can be designed incrementally and can have different templates.

Editing Stroke Font
Invoke Edit Stroke Font extension to edit an existing font. Choose the font to be edited from the drop down, and enter the number of rows and size. All the stroke font glyphs of the selected font are displayed in the given size, arranged in rows with row count corresponding to the user entered number. You can edit the path of the glyphs. The IDs are already set. If you want to create a new glyph reusing paths of an existing one, just give it the ID corresponding to the new glyph after editing.
To save the edited font invoke the Generate Font Data extension and (re)enter the exact font name. The Right Offset option value should always be Vertical Guide / Bounding box. The data generation process is the same as that for new fonts.

The Synchronize Font List extension should be used to synchronize the font list with the list of font data files (if the folder contents are changed externally)

Sample Font Files
Please refer to the SVGs in the fontsvg folder for sample font design. The three bundled fonts use the same SVGs to generate the font data.

Interoperability with Inkscape 1.0 Hershey Text Extension
The generated font data is now in SVG format, which is compatible with the Inkscape 1.0 Hershey Text font file format. So you can use the Inkscape 1.0 SVG stroke font files with Render Text and Edit Stroke Font Extensions (also in Inskcape 0.92). Just 1) copy the new files in the strokefontdata subfolder of user extensions directory 2) execute the Synchronize Font List extension and 3) restart Inkscape
Also, if you design a stroke font with this extension then the generated font file can be used with Inkscape 1.0 Hershey Text extension by specifying the full font file path in the extension dialog.

Video Tutorials
Part1: https://youtu.be/iCsnYlVjWA0
Part2: https://youtu.be/-7BjfxpUAfU
Part3: https://youtu.be/3YBaZfPpNjc

Credits

The custom stroke fonts are derived from: Square Grotesk and Pinyon Script available under Open Font License on https://fontlibrary.org/

The Hershey Fonts are ported from hersheydata.py from Windell H. Oskay.
Here's the acknowledgement:

  • The Hershey Fonts were originally created by Dr. A. V. Hershey while working at the U. S. National Bureau of Standards.
  • The format of the Font data in this distribution was originally created by
    James Hurt
    Cognition, Inc.
    900 Technology Park Drive
    Billerica, MA 01821
    (mit-eddie!ci-dandelion!hurt)

Known Issues & Workarounds

  • With the non-english characters, the Generate Font Data extension may produce an error. The workaround is: save the file, re-open it and generate the data once again.
  • If you are using Inkscape on windows, there could be problems rendering extended (e.g. non-english) characters (like ö or ß) with the text keyed in the input text box. A workaround is to create a text file with the text containing these characters and render the text using, 'Render from file' option.
  • If you are using Inkscape on windows, an extended (e.g. non-English) character in the First Glyph of Create Font Design Template extension may not work right. In such cases, you can enter the 4 digit hex unicode value of the first character (e.g. 00C0 for À) in the First Glyph field. You will get the unicode values of the characters from the Character Map.
  • Currently there is no user interface for deleting or renaming the fonts. This can be done manually by deleteting or renaming the xml file in the strokefontdata folder followed by synchronization of the font list

Please exercise caution while using the tools; save your work, before invoking any of these extensions.
You may report the issues and defects on the Issues page here or in the comments section on the video tutorial.
Feedback and suggestions are most welcome!

inkscapestrokefont's People

Contributors

shriinivas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inkscapestrokefont's Issues

Issues with special characters in generated font file

Windell Oskay commented on my blogpost that there should be no issue with Hershey Text to read special characters and asked me to report it as an issue and provide an example file where Hershey Text fail to read the SVG-font. It seems that the svg-font files I generate with the Custom Stroke Font have incorrect coding (not UTF-8 for real). See more in this issue and what Windell Oskay found. I guess the same is the case when FontForge fail to read the svg-font files from Custom Stroke Font. I can live with my workaround in the blogpost mentioned above, but maybe there is something that could be fixed from within the Custom Stroke Font extension?

Extension "Custom Stroke Font" errors in Inkscape 1.0beta2

First of all, thank you for your developments. Maybe this can help you improve it ! Best regards.

  • I installed the external extension "inkscapestrokefont" from here
  • open Inkscape
  • menu Extension / "Custom Stroke Font" available
  • errors are appearing for each submenu
  • dialog appears and seems to work fine
    - drop down menus OK
    - entering data OK
    - selecting options OK
  • then click on button apply
    => dialog appears with error message below

SUB MENU 1

  • Select in the submenu "Create Font Design Template"
  • Apply (default values)
  • Inkscape returns message:
    File "stroke_font_templ.py", line 97 try: self.startGlyph = eval("u'\u" + sg + "'") ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \uXXXX escape
  • Nothing happens next.

SUB MENU 2

  • Select in the submenu "Edit Stroke Font"
  • Apply (default values)
  • Inkscape returns message:
    Traceback (most recent call last): File "edit_stroke_font.py", line 31, in <module> from stroke_font_common import CommonDefs, InkscapeCharDataFactory, createTempl File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/stroke_font_common.py", line 84 print getXMLItemsStr(sectMarkerLine, sectMarker, fontNames), ^ SyntaxError: invalid syntax

SUB MENU 3

  • Select in the submenu "Generate Font Data"
  • Apply (default values)
  • Inkscape returns message:

Traceback (most recent call last): File "gen_stroke_font_data.py", line 37, in <module> from stroke_font_common import InkscapeCharData, CommonDefs, \ File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/stroke_font_common.py", line 84 print getXMLItemsStr(sectMarkerLine, sectMarker, fontNames), ^ SyntaxError: invalid syntax

I guess the other menus can generate similar issues, I did not try them.

Inkscape Version and Operating System:

Inkscape Version: 1.0beta2 (2b71d25, 2019-12-03)
Operating System: MacOS X Catalina
Operating System version: 10.15.4

using special characters in XML ID for font design

While trying to design a new font, I can't change the XML ID to ":" because Inkscape 1.2 considers this an Invalid ID. (Oddly, If I edit an existing font, it seems to have no problem.).

How is this supposed to work? This seems to be true for other special characters as well.

Sync Fonts doesn't actually sync the fonts

Hi,

I've added some additional fonts to the strokefontdata folder (added the EMS fonts) and then selected Sync Fonts. Nothing seems to happen. When I look the drop downs, nothing has updated.

I thought I read that an XML file is created, but I don't see one.

I've tried just modifying one of the names of the existing fonts to see if that works - not updated.
I've coped the font folder to here:
...AppData\Roaming\inkscape\extensions\inkscapestrokefont-master\strokefontdata

and
...\AppData\Roaming\inkscape\extensions

Thanks

Workaround for Inkscape v1.0.2 and v1.1

With Inkscape v1.1 and v1.0.2 in Windows at least the Edit stroke font and Generate font data did not work (did nothing, and no error message). It turns out that this currently have to be fixed by the workaround described in
this issue #2187
(i.e. removing two lines of Inkscape \lib\python3.8\site-packages\numpy\init.py)

Thought you would like to know. Sounds like this will be fixed in the future releases of Inkscape as it applies to other extensions too.

Edit svg font with missing horiz-adv-x

I was converting a ttf fot to svg using FontForge and when trying to edit this using the Custom Stroke Font - Edit Font it failed and I got nothing. It turned out that there was quite a few glyphs in the svg from FontForge missing the horiz-adv-x attribute. I guess this is a bug in while FontForge generate svg-font (the left/right bearings of those glyphs look fine when inspecting them in FontForge). Anyway - this problem was fixed by changing line 114 of stroke_font_manager.py

From
rOffset = float(e.getAttribute(xROff))

To
if e.getAttribute(xROff) == "":
rOffset = 0
else:
rOffset = float(e.getAttribute(xROff))

Ideally there should be a warning in the end that some (ideally which) glyphs had missing horiz-adv-x and that this is set to 0, or it could be set to the width of the bounding box to have something that might work - not as strange and obviously wrong as 0.

At least this made it possible to continue editing the font. So I'm happy with this solution.

Menu is disabled

I see the Custom Stroke Font menu and sub-menu but they are all grayed out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.