- fixed ParseFont such that the output of the Text Plugin in the Geometry Editor can now be painted using the Paint Plugin

This commit is contained in:
Marius Stanciu
2021-03-28 22:12:58 +03:00
committed by Marius Stanciu
parent cc8cf4ecbb
commit 61d19e0748
2 changed files with 14 additions and 3 deletions

View File

@@ -15,9 +15,8 @@ import os
import sys
import glob
from shapely.geometry import Polygon
from shapely.geometry import Polygon, MultiPolygon
from shapely.affinity import translate, scale
from shapely.geometry import MultiPolygon
import freetype as ft
from fontTools import ttLib
@@ -351,4 +350,15 @@ class ParseFont:
else:
scaled_path.append(scale(item, 0.00031570066, 0.00031570066, origin=(coordx, coordy)))
return MultiPolygon(scaled_path)
# determine if some polygons are completely inside the other
interiors = []
for idx, poly in enumerate(scaled_path):
try:
if scaled_path[idx + 1].within(poly):
interiors.append(scaled_path[idx + 1])
except IndexError:
break
ret_geo = MultiPolygon([x for x in scaled_path if x not in interiors]).difference(MultiPolygon(interiors))
return ret_geo