nan-xyz / glyph-filters Goto Github PK
View Code? Open in Web Editor NEWGenerative Fonts and Tools for Display Typography
License: SIL Open Font License 1.1
Generative Fonts and Tools for Display Typography
License: SIL Open Font License 1.1
Limit the fitpath()
so that handles are trapped within a certain range.
This is essentially a point-inside-complex-polygon problem.
Currently you're looking at each path and working out whether it's a positive path or a negative path. The classic solution is the ray casting algorithm where you start from a point definitively outside the polygon, cast a ray to the point in question, and count the number of overlaps. Here's a Python implementation of that algorithm.
I'm new to Glyphs and scripting but I found out about this cool project and wanted to try it.
I installed Glyphs 2.6.6 and Python 2.7.2 (i had first installed 3.x but I read about it in another issue and changed).
I also installed noise via pip.
I tried to run a first filter (Spray Paint) and it worked as expected but when I tried others I kept getting different errors:
Dirt
Start
starting glyph: I
glyph size: L
Traceback (most recent call last):
File "Dirt.py", line 78, in <module>
Dirt()
File "NaNFilter.py", line 25, in __init__
self.processGlyph(glyph)
File "NaNFilter.py", line 45, in processGlyph
self.processLayer(thislayer, params)
File "Dirt.py", line 26, in processLayer
noisepaths = NoiseOutline(thislayer, outlinedata, noisevars=[0.2, 0, 15])
File "NaNGFNoise.py", line 78, in NoiseOutline
x_noiz = pnoise1( (n+seedx)*noisescale, 3)
File "NaNGFNoise.py", line 37, in pnoise1
total += _noise1(x * freq, repeat * freq, base) * amp
File "NaNGFNoise.py", line 19, in _noise1
i = (i & 255) + base
TypeError: unsupported operand type(s) for &: 'float' and 'int'
End
Storm
Start
starting glyph: I
glyph size: L
Traceback (most recent call last):
File "Storm.py", line 36, in <module>
Storm()
File "NaNFilter.py", line 25, in __init__
self.processGlyph(glyph)
File "NaNFilter.py", line 45, in processGlyph
self.processLayer(thislayer, params)
File "Storm.py", line 33, in processLayer
operateOnBlackAtInterval(thislayer, self.drawStorm, self.gridsize)
File "NaNGFGraphikshared.py", line 177, in operateOnBlackAtInterval
if not withinLayerBlack(layer, x, y):
File "NaNGFGraphikshared.py", line 167, in withinLayerBlack
return (len(intersections) % 2) == 1
TypeError: object of type 'NoneType' has no len()
End
Glitch
Start
starting glyph: I
glyph size: L
Traceback (most recent call last):
File "Glitch.py", line 74, in <module>
Glitch()
File "NaNFilter.py", line 25, in __init__
self.processGlyph(glyph)
File "NaNFilter.py", line 45, in processGlyph
self.processLayer(thislayer, params)
File "Glitch.py", line 35, in processLayer
slicedpaths = self.returnSlicedPaths(paths, self.sliceheight)
File "Glitch.py", line 55, in returnSlicedPaths
G.cut_layer(tmplayer, (ox-1, y), (ox+w+1, y))
File "NaNGlyphsEnvironment.py", line 108, in cut_layer
layer.cut_between_points(pt1, pt2)
AttributeError: 'GSLayer' object has no attribute 'cut_between_points'
End
What am I missing?
Thanks
Remove very small segments and handles created by convertToFitpath()
+ NaNGFFitpath
With VF versions teased on Twitter, I thought I'd start a discussion here about what the axis should be tagged, labelled, and ranged (min/def/max) as. cc @RosaWagner
I'm guessing there are 2 options.
(A) Do what is shown in the tweets, and use the wght
axis, but range them 400/400/700
, Regular to Bold.
(B) Do custom axes for each. Eg
HAIR 0 0 100
BUBL 0 0 100
SIFI 0 0 100
I think (A) probably makes sense, but I'm guessing it might vary. The Bubbles one looks perfectly normal as a weight axis. The hairy one looks pasable. The Sci Fi one is more questionable, and I could see that related to the Type Network Parametric Axes System, and split with anisomorphic filters into X Opaque and Y Opaque axes, eg XOSF
and YOSF
:)
I tried what you advised to another user but it doesn't seem to work.
I installed Python 2.7 and pip
$ pip --version pip 20.3.4 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip (python 2.7) $ python --version Python 2.7.18
And did the install for noise
$ pip install noise DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting noise Downloading https://files.pythonhosted.org/packages/18/29/bb830ee6d934311e17a7a4fa1368faf3e73fbb09c0d80fc44e41828df177/noise-1.2.2.tar.gz (125kB) |████████████████████████████████| 133kB 1.2MB/s Installing collected packages: noise Running setup.py install for noise ... done Successfully installed noise-1.2.2
But still have this error message on Glyphs (Version 2.6.6)
Start Traceback (most recent call last): File "Beastly.py", line 8, in <module> from NaNGFGraphikshared import * File "NaNGFGraphikshared.py", line 13, in <module> from NaNGFNoise import roughenLines File "NaNGFNoise.py", line 2, in <module> from noise import * ImportError: No module named noise End
Same when I try 'import noise' launching the app, I get Traceback (most recent call last): File "<macro>", line 1, in <module> ImportError: No module named noise
Is it because of the deprecation? If so what version should I use?
If so, it should just call it and return the result.
When I run this python run-filter.py trial.glyphs Zebra
I get this error message. Even though it shows the filter as available, writing the name of it doesn't prompt the script.
Couldn't find filter 'Zebra'.
Try one of: 80sFade, Beastly, BrokenFax, Bubble, Burned, Dirt, Distressed, DoodleShadow, DoodleTriangles, Gemstones, Glitch, GlitchPop, Iso, Lines, Maps, MarkerHatch, Maze, Microbe, MoonRocks, Pixels, Puddles, Scribble, SeaCamouflage, SprayPaint, Storm, Vinyl, WetPaint, Zebra
Am I missing something?
The waves b algorithm was an improvement upon waves as seen in zebra. Now it's been refactored with itertools it's unintelligible to me.
Where windows support!?!?
Traceback (most recent call last):
File "DoodleShadow.py", line 10
from NaNGFNoise import NoiseOutline
File "NaNGFNoise.py", line 1
import numpy as np
ModuleNotFoundError: No module named 'numpy'
cc @simoncozens
Add an option or alternative function that will expand the positive outline but leave the negative counter in tact. Could also be used to increase counter sizes in instances of fill-in but leave main outline as is. Not urgent but would be helpful.
I did the install for noise
% pip install noise
Collecting noise
Downloading https://files.pythonhosted.org/packages/18/29/bb830ee6d934311e17a7a4fa1368faf3e73fbb09c0d80fc44e41828df177/noise-1.2.2.tar.gz (125kB)
|████████████████████████████████| 133kB 4.7MB/s
Installing collected packages: noise
Running setup.py install for noise ... done
Successfully installed noise-1.2.2
But it doesn't get recognised by the filter code:
Start
Traceback (most recent call last):
File "MarkerHatch.py", line 8, in <module>
from NaNGFGraphikshared import *
File "NaNGFGraphikshared.py", line 13, in <module>
from NaNGFNoise import roughenLines
File "NaNGFNoise.py", line 2, in <module>
from noise import *
ImportError: No module named noise
End
Is it some Python path thing perhaps? Not sure where these modules live...
(Glyphs Version 2.6.6 (1351))
Part of a general post processing clean up.
Hello, what an amazing show!
When I run your code, I got an error: No module named 'GlyphsApp'
I don't konw how to install GlyphsApp, may I have some help, please? Thank you
Call correctPathDirection()
prior to processLayer()
Check if curves are cubic before continuing and send error if not.
Lots of filters start:
params = {
"S": { "offset": 0, ...
def processLayer(self, thislayer, params):
offsetpaths = self.saveOffsetPaths(
thislayer, params["offset"], params["offset"], removeOverlap=True
)
outlinedata2 = setGlyphCoords(doAngularizzle(offsetpaths, 4))
Perhaps if processLayer
sees that we have an offset
member in the parameters, it should do the offsetting and store the result in instance variables. I'll have to look through and see if that's worthwhile - if there's enough commonality to make it worth abstracting, or if subtle things are different each time.
Occasionally GlyphsApp's native OffsetCurve()
causes handles irrationally fly off from parent nodes. Write a little checker function post expandMonoline()
to restrain them if any.
Error message cc @simoncozens
Traceback (most recent call last):
File "/Users/rosalie/Google/forks/Glyph-Filters/run-filter.py", line 22, in <module>
i = importlib.import_module(filter_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/rosalie/Google/forks/Glyph-Filters/NaNGlyphFilters/SeaCamouflage.py", line 256, in <module>
SeaCamouflage()
File "/Users/rosalie/Google/forks/Glyph-Filters/NaNGlyphFilters/NaNFilter.py", line 25, in __init__
self.processGlyph(glyph)
File "/Users/rosalie/Google/forks/Glyph-Filters/NaNGlyphFilters/NaNFilter.py", line 45, in processGlyph
self.processLayer(thislayer, params)
File "/Users/rosalie/Google/forks/Glyph-Filters/NaNGlyphFilters/SeaCamouflage.py", line 29, in processLayer
self.SliceGlyph(thislayer, iterations)
File "/Users/rosalie/Google/forks/Glyph-Filters/NaNGlyphFilters/SeaCamouflage.py", line 72, in SliceGlyph
G.cut_layer(thislayer, (cutx1, cuty1),(cutx2, cuty2))
File "/Users/rosalie/Google/forks/Glyph-Filters/NaNGlyphFilters/NaNGlyphsEnvironment.py", line 264, in cut_layer
raise NotImplementedError
NotImplementedError
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.