KiBuzzard icon indicating copy to clipboard operation
KiBuzzard copied to clipboard

Misshaped character 'B' with Roboto Font

Open tmrkp opened this issue 3 years ago • 9 comments
trafficstars

The character 'B' with the Font "Roboto" seems to be problematic. This could also be a problem with the font itself, but the Roboto Font is very popular, so it might be worth looking into it.

Edit: I just noticed something. I've been using a previous version of this plugin on older projects and the problem with the B character wasn't present. This could be something in the 1.2.0 change. I'm not certain, but I think I've been using 1.1.0 before.

Edit 2: I just tested this with version 1.0.0 and I don't get this problem. The character 'B' looks fine. So this looks to me like a problem introduced in 1.2.0.

Roboto Font: https://fonts.google.com/specimen/Roboto

Bildschirmfoto 2022-08-16 um 17 22 30 Bildschirmfoto 2022-08-16 um 17 25 52

tmrkp avatar Aug 16 '22 15:08 tmrkp

I am experiencing similar problems with UbuntuMono-B font (the T is cut):

Screenshot from 2022-08-16 19-18-44

yaqwsx avatar Aug 16 '22 17:08 yaqwsx

This looks to be a regression. There were some performance improvements in svg2mod, with respect to how the polygons are sliced. These changes might be the cause of this type of rendering error.

gregdavill avatar Aug 17 '22 09:08 gregdavill

Hi, Using the font Exo Black available here https://fonts.google.com/specimen/Exo

I see the same behaviour in version 1.0.0, 1.1.0 and 1.2.0.

Expected image

Actual image

electrified avatar Sep 28 '22 21:09 electrified

This is related to svg2mod/svg2mod#51. I am aware and have a fix (svg2mod/svg2mod#53). I am just finalizing polygon support for svgs then that fix will be merged into svg2mod.

Sodium-Hydrogen avatar Nov 07 '22 16:11 Sodium-Hydrogen

Version 1.2 of svg2mod is out with the fix for this.

I did rework the way styles are handled to support svgs without explicitly defined styles which does seem to break kibuzzard but this change in buzzard.py 156 seems to fix the crashing I was experiencing:

- offset_text.style += "stroke-width:0.2;"
+ offset_text.style["stroke-width"] = 0.2

Sodium-Hydrogen avatar Nov 08 '22 06:11 Sodium-Hydrogen

@Sodium-Hydrogen I've updated the svg2mod dependency (https://github.com/gregdavill/KiBuzzard/pull/94). However when I try the example from above I get a different error, it seems the polygon ends up as self-intersecting. Or atleast ends up with overlapping parallel lines which seem to cause some issues. Screenshot from 2022-11-20 22-55-12 Screenshot from 2022-11-20 22-55-03

In the PCB editor the second cutout is missing. However in the 3d view it's all okay.

Screenshot from 2022-11-20 22-53-06

I'll poke into this a bit more myself, but thought I'd mention it in case you've seen it before and there is an easy fix.

gregdavill avatar Nov 20 '22 12:11 gregdavill

I'll think about how to fix this in a more elegant way. But a quick fix for the B is to flip the order the segments are inlined.

diff --git a/KiBuzzard/deps/svg2mod/svg2mod/svg2mod.py b/KiBuzzard/deps/svg2mod/svg2mod/svg2mod.py
index f6e63dfd9..92c96cce0 100755
--- a/KiBuzzard/deps/svg2mod/svg2mod/svg2mod.py
+++ b/KiBuzzard/deps/svg2mod/svg2mod/svg2mod.py
@@ -303,7 +303,7 @@ class PolygonSegment:
 
         logger.debug( "  Inlining {} segments...".format( len( segments ) ) )
 
-        segments.sort(reverse=True, key=lambda h: h.bbox[1].y)
+        segments.sort(reverse=False, key=lambda h: h.bbox[1].y)
 
         all_segments = segments[ : ] + [ self ]
         insertions = []

This achieves a much cleaner inlining, without the knot that's currently created. (manually separated here to highlight the insertion points) Screenshot from 2022-11-22 21-32-35

Screenshot from 2022-11-22 21-34-56

I'm not seeing any downsides to the sorting reversal, unless it tried to perform an insertion to the top, rather than the bottom, then we're back where we started.

gregdavill avatar Nov 22 '22 11:11 gregdavill

Nice patch!

I think your fix works for now, but I'm working on svg even-odd support so I will have to get this working for 100% of cases.

Looking at the English alphabet I think your fix will achieve enough functionality that it will be unlikely anyone else will run into this problem before a comprehensive solution exists.

Sodium-Hydrogen avatar Nov 22 '22 16:11 Sodium-Hydrogen

@timrosskamp Can you confirm that this fix works? It's currently included in a 1.3.0-rc release you can install https://github.com/gregdavill/KiBuzzard/releases/tag/1.3.0-rc

gregdavill avatar Nov 22 '22 21:11 gregdavill