From 61d19e074846fe8fa31090ce357ce33429816ac1 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 28 Mar 2021 22:12:58 +0300 Subject: [PATCH] - fixed ParseFont such that the output of the Text Plugin in the Geometry Editor can now be painted using the Paint Plugin --- CHANGELOG.md | 1 + appParsers/ParseFont.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da7a83ab..4bca36a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta - created a new category in Preferences where only the Engraving Related preferences are located - added a new set of options in the Preferences for the Milling Plugin by taking them out of the Geometry section - fixed an error in the Subtract Plugin when working on Geometry objects +- fixed ParseFont such that the output of the Text Plugin in the Geometry Editor can now be painted using the Paint Plugin 22.03.2021 diff --git a/appParsers/ParseFont.py b/appParsers/ParseFont.py index 552e6ff0..719bd96e 100644 --- a/appParsers/ParseFont.py +++ b/appParsers/ParseFont.py @@ -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