Skip to content

Please make the diagrams with open source tools #1158

Closed

Activity

  1. jnavila commented on Jan 13, 2019

    @jnavila
    Member

    We know this. If you happen to know somebody who has this application and can export the pictures to SVG for instance, please proceed.

  2. bripmccann commented on Feb 28, 2019

    @bripmccann
    Contributor

    Searched and found some free alternatives (gratis, unfortunately not open source) which can open Sketch files and export SVGs:

    I can at least confirm they each imported and rendered, but I didn't do much beyond that. Only issue I saw was that it tries to use the Menlo-Regular and Menlo-Bold fonts, which seem to be Mac-only.

  3. YueLinHo commented on Mar 13, 2019

    @YueLinHo
    Contributor

    I tried Figma and Lunacy. They does not fully support Sketch file. For example:
    image
    image

    After using Lunacy, I realized the reason why using Sketch file is there are some components are common in use, I mean the Symbols feature .
    image

    That could be a huge reason.
    Think about changing the color of following symble:
    image => image
    and figure changes:
    image

    And all figures using it will be able to benefit from it.

    So, I am not sure it is good to use SVG?

    use the Menlo-Regular and Menlo-Bold fonts, which seem to be Mac-only.

    True. And I replace the font with Bitstream Vera Sans Mono. (cf. #605 (comment))

  4. YueLinHo commented on Mar 13, 2019

    @YueLinHo
    Contributor

    Note: Lunacy 3.14

  5. lazarljubenovic commented on Mar 13, 2019

    @lazarljubenovic
    Contributor
  6. jnavila commented on Mar 13, 2019

    @jnavila
    Member

    That could be a huge reason.
    Think about changing the color of following symble:

    Factorization of common attributes is perfectly doable in SVG. But, there are great chances that the extracted SVGs would be "flattened" (i.e. every element embeds all its attributes) and we would loose the ability to change the styling.

    @YueLinHo could you provide the output svg so that we can check its structure?

  7. YueLinHo commented on Mar 16, 2019

    @YueLinHo
    Contributor

    Factorization of common attributes is perfectly doable in SVG.

    Nice! ^__^

    @YueLinHo could you provide the output svg so that we can check its structure?

    OK. Will try it later. :-)

  8. max123kl commented on Aug 3, 2019

    @max123kl
    Contributor

    @YueLinHo
    As you wrote correctly, the font used is licensed from Apple and not generally available. The font you suggested, "Bitstream Vera Sans Mono," is not suitable for normal typesetting. It is not a proportional font but a monospaced font, which is better suited for texts that should represent a code text. In continuous text, the typeface appears broken because the letter spacing is not harmonious. (See https://www.fontsquirrel.com/fonts/bitstream-vera-sans-mono).

    If you're looking for a free font that is similar to the one in the Sketchbook file and whose license also allows free commercial use, you'll find some alternatives e.g.: https://www.fontspace.com/vincenzo-vuono/gravity or https://www.fontspace.com/kineticplasma-fonts/falling-sky.
    In addition, the Google Fonts are copyright free (See https://fonts.google.com/?category=Sans+Serif).

    @jnavila
    As I don't have a Mac available at the moment, I have to open the progit.sketch file with Lunacy (v4.0.3). Assuming it is displayed correctly, I, as a graphic designer, immediately notice some "don'ts", which considerably reduce the display quality of the images.
    On the browser page and in the PDF file, the images appear to me rather blurred. I don't understand how this can happen with a vector drawing program like Sketch. Apparently a serious error may have occurred in the workflow.

    The initiator of the issue has suggested to use open source software to create the images. From my point of view Inkscape (https://inkscape.org/) would be suitable for this task, it is available for OSX, Windows and Linux. It is also vector-based and you can create your own symbol library, so that a unified design of the images is possible. A small "HowTo" should be enough to explain the workflow to the various authors.
    If you like, I can create a new branch in my fork and give some examples for discussion.

  9. jnavila commented on Aug 3, 2019

    @jnavila
    Member

    @max123kl the files included in both media are png (the way they were extracted from Sketch), and they were heavily compressed.
    Keeping the format in vector shapes would provide better as long as it is suitable for web pages and PDF. SVG is such format.

    Inkscape manipulates SVG files, so this would be great. The problem is that up to now, the exports from Sketch were very lousy. Please go ahead with some sample, and if it can be integrated, you could even better provide a full conversion of the images. 👍

  10. max123kl commented on Aug 4, 2019

    @max123kl
    Contributor

    It does not make sense to reconstruct existing images by duplicating the work. In addition, the check for content errors must be carried out again afterwards.

    I suggest that we first analyze where the error hides in the workflow and then focus on eliminating it.
    As I said I don't have a Mac and the Sketch tool as well, so at the moment I can only refer to the output of the Windows Lunacy tool. Therefore I can only refer to the output of the Windows Lunacy program at the moment. In other words, I'm pretty sure – what I see here isn't what Sketch produces.

    In Sketch's online manual, the section "File Formats" (https://www.sketch.com/docs/exporting/file-formats/) explains that data export to PNG, but also to SVG and EPS is possible. It would be very helpful if you could save two images ("local" and "branch-and-history") and the symbol part in SVG and EPS formats respectively. I especially hope for a lot from the EPS format, as it is universally used in professional image processing.
    You can send the files to my e-mail address or place them in the "diagram-source" folder.

    Regardless of what I said before, I immediately noticed when looking at the progit.sketch file that the constructed diagrams on the individual pages are no longer in vector format, but in bitmap format. Images in vector format can be enlarged losslessly, the quality of the bitmap format decreases, which is particularly noticeable in typefaces.
    The images of the *.PNG files in the ./Images folder are almost all 800 px wide. The same figure (local.png) in the progit.sketch file has only 335 px, so it has to be enlarged more than twice. This leads to a significant blur. In addition, they were extremely compressed and also indexed (the color space of the images was reduced from 24 bit to 256 colors). Subsequent sharpening is no longer possible.
    Vector files can usually be edited afterwards without loss of quality, which also means that the effort to improve the images would be considerably less, if the data were available in vector format without indexing.

    Another question about the symbols and the symbol library in the Sketch file:
    Should it also be possible to edit the text within the symbol in the future? At the moment I can't do that - but it can also be a faulty Lunacy output.

  11. max123kl commented on Aug 4, 2019

    @max123kl
    Contributor

    @jnavila
    I have reconstructed some symbols with Inkscape.
    I have saved the work in four different file variants (https://github.com/max123kl/progit2-de/tree/Figures/diagram-source)
    The file test_oneA.svg and test_oneB.svg contains the graphics in original size, whereas ...A.svg was saved as normal SVG and ...B.svg as "optimized SVG" (reduced color gamut). The files test_oneAx2.svg and test_oneBx2.svg contain the graphics in approx. 2.6x magnification. The size of the ...Bx2 file is larger than that of the ...Ax2 file. I have to check this again. But if the result should be confirmed I see no reason to reduce the color gamut to get a smaller memory size.
    What can be clearly seen is that the image quality did not suffer due to the magnification.

    You see two columns, on the left side I have stayed as close as possible to the original. In the right column I made some small changes. So I lightened or darkened the text a bit to increase the contrast, which improves the readability. In the first row I placed two small color fields behind the graphics in the middle to simulate the background color on the website and the Sketch program.
    At the right graphic I made the filling color a bit darker to increase the contrast.

  12. ben commented on Aug 4, 2019

    @ben
    Member

    OK, I've finally been able to load up the source file in the Sketch editor – I had tried a while ago, and it kept crashing on me. Here's what I understand as the desired outcome:

    • Change the diagram font. I'm thinking Roboto Mono here, but I'm open to suggestions. Would something else be better for ebook download sizes?
    • Export the diagrams as SVG, and use those in the build path for ebooks.
    • Keep some kind of method for updating diagram styles en masse. Sketch provides this, but is there a way to export so that "symbols" are usable in something like Inkscape?

    Does that sound correct?

  13. ben commented on Aug 4, 2019

    @ben
    Member

    The first part of this will be accomplished in #1285.

  14. jnavila commented on Aug 4, 2019

    @jnavila
    Member

    I'm interested in the SVG export. If it's flattened, then it's not really useful for future changes, but if they export a structured file (with styles and reused groups) it could be used as our primary source for images.

  15. ben commented on Aug 4, 2019

    @ben
    Member

    #1285 now covers the first two.

  16. 13 remaining items

  17. ben commented on Aug 6, 2019

    @ben
    Member

    Can you tell me files that contain this "stroke"? I can't find any.

    Sure, here's one of the text nodes from the SVG file I linked to above:

    <text id="master" stroke="#979797" stroke-width="1" font-family="RobotoMono-Regular, Roboto Mono" font-size="12" font-weight="normal" fill="#000000">
      <tspan x="24.9970703" y="21">34ac2</tspan>
    </text>

    Note the stroke="#979797" stroke-width="1" properties. I think if those are removed you won't see the outlining you (rightly) disapprove of. Here's a snippet from your linked SVG:

    <text
        id="master"
        font-size="12"
        font-weight="normal"
        style="font-weight:normal;font-size:12px;font-family:RobotoMono-Regular, 'Roboto Mono';fill:#000000;stroke:#979797;stroke-width:0.4;stroke-miterlimit:4;stroke-dasharray:none">
      <tspan
          style="stroke-width:0.4;stroke-miterlimit:4;stroke-dasharray:none;-inkscape-font-specification:'Roboto Mono, Bold';font-family:'Roboto Mono';font-weight:bold;font-style:normal;font-stretch:normal;font-variant:normal;font-size:12px;text-anchor:start;text-align:start;writing-mode:lr;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;fill:#979797;fill-opacity:1"
          x="24.994141"
          y="21"
          id="tspan11">f30ab</tspan>
    </text>

    Here the outline is coming from the style property, where stroke-width:0.4 will force an outline.

  18. ben commented on Aug 6, 2019

    @ben
    Member

    Oh, and regarding the choice of font for the diagrams: if Roboto Mono is not acceptable, I'm completely happy with Source Code Pro.

  19. jnavila commented on Aug 6, 2019

    @jnavila
    Member

    If needed, a good sed filtering could tidy the "stroke" properties if needed.

  20. max123kl commented on Aug 6, 2019

    @max123kl
    Contributor

    OK, I see, you were talking about the inside code, and I was just looking at the visible image.
    For me it is very difficult to analyze code in that way because I actually trust the design app.

    I'm not very familiar with analyzing XML code. What I know is that different design programs can generate very different code for the same type of artwork. For example, Inkscape can create 3 different uncompressed and 2 compressed SVG files (see the "save as" dialog in the pull down menu).
    The code Sketch writes is similar to the code Inkscape calls "optimized SVG". If you choose this save format, the second step is an additional settings dialog, where you can choose more options. This leads to a different code in each file. I put some files (along with a Readme) in my Figures branch /diagram-source/test for comparison.
    I do not believe in filtering the XML-SVG code, unless an absolute specialist who knows both the XML code and the code generator of Sketch/Inkscape does. However, there might be unwanted side effects.

    As far as I can see, the 'stroke' attribute is responsible for the outline of an object. For vector based drawings everything is defined by outlines and fills. I imagine it will be extremely difficult to remove or change some strokes through a filter.

  21. jnavila commented on Aug 7, 2019

    @jnavila
    Member

    Your export is quite interesting, because we can see that the letters are in fact mostly made up of the stroke part ; if I zoom on new 5_A.svg :

    image

    The fill part is black and is only appearing at the internal limit of all strokes. If in Inkscape, I remove the stroke, here's what's left:

    image

    Whereas when the fill matches the stroke:

    image

    @max123kl , contrary to your belief, mechanizing the filtering of XML-SVG is really not a big deal ( the experiments above are easily doable by script). The relevant question is what kind of transformation we want to apply.

  22. max123kl commented on Aug 7, 2019

    @max123kl
    Contributor

    @jnavila
    Please show me the code (if not from my new 5_A.svg file) of the lowest example (it's not a good idea if "f" and "3" are in touch). I suspect that the outline width stroke-width there has the wrong value.

    My new 5_A.svg test file, where I did no editing, is (# at the end of the lines = my comment):

             id="master"
             stroke="#979797"				# is color gray
             stroke-width="1"				# value has to be analysed
             font-family="RobotoMono-Regular, Roboto Mono"
             font-size="12"
             font-weight="normal"				# should be set to "bold"
             fill="#000000">				# is color black should be set to "#979797"
            <tspan
               x="24.9941406"
               y="21"
               id="tspan900">f30ab</tspan>
          </text>
    

    It is very important that stroke="#979797" (means a certain gray) and fill="#000000" (means black) have to have the same value i.e. color here.
    That's what I was trying to explain in the picture.

    Ben has agreed to switch from "Roboto Mono" to "Source Code Pro". So I uploaded the file new 5_A_f30ab.svg. The only change I made was in field "f30ab", so I could analyze it better. Here's the corresponding code section:

             id="master"
             font-size="12"
             font-weight="normal"
             style="font-style:normal;font-variant:normal;font-weight:900;font-stretch:normal;font-size:12px;font-family:'Source Code Pro';-inkscape-font-specification:'Source Code Pro, Heavy';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:black;stroke:#979797;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none"
             transform="translate(17.811515)">
            <tspan
               x="24.994141"
               y="21"
               id="tspan900"
               style="font-style:normal;font-variant:normal;font-weight:900;font-stretch:normal;font-size:12px;font-family:'Source Code Pro';-inkscape-font-specification:'Source Code Pro, Heavy';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#979797;fill-opacity:1;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none">f30ab</tspan>
          </text>
    

    The different formatting could be due to the fact that the "Source Code Pro" font is in OTF format and its extended options.
    The basic values are:

    • font-family:'Source Code Pro'

    • font-size:12px

    • font-weight:900 (equivalent values are Heavy or Black)

    • fill-opacity:1 (= no transparency)

    • fill:#979797 (Character color)

    • stroke:#979797 (Outline color)

    • stroke-width:0 (no visible Outline)

    • text-align:center (is helpful if the text needs to be edited later - default value is left)

  23. jnavila commented on Aug 7, 2019

    @jnavila
    Member

    @max123kl Sorry, I hadn't followed your previous conversation about the fonts issue. The later example is only with fill at #979797 so the stroke-width is still 1.

    So, to be clear, I should take the exports that @ben did and apply the styling you just advised, right?

    If so, I'll do it tonight at home and will push on a dedicated branch for inspection.

  24. max123kl commented on Aug 7, 2019

    @max123kl
    Contributor

    It's worth a try.
    If it really worked that would save a lot of effort right now.
    As I already wrote here, I would like to create a symbol library for Inkscape, and develop a mini HOWTO for it, so that even for less experienced users the switch to Inkscape becomes easier.

    For this I need the previous Sketch symbols as SVG file(s) so that I don't have to rebuild everything.
    I now believe that you would be able to do this with a filter, but especially with OTF fonts there are so many adjustment screws you can use to optimize the look. It would be impossible for me to say now: use the value x or y or something in between for attribute ABC

    Edit:
    I forgot to mention:

    1. if the value of the text-align attribute is changed to center, the text block moves to the left (if it was previously set to left).

    2. then the TextBlock and the surrounding rectangle must be centered against each other again.

    3. Each font has its own specific tracking. When changing the font, it is also necessary to re-center it, as in point 2.

  25. ben commented on Aug 7, 2019

    @ben
    Member

    I exported the symbols page from Sketch in #1287. It's probable they have the same problems as the other exports.

  26. max123kl commented on Aug 8, 2019

    @max123kl
    Contributor

    I downloaded the symbols.svg file. It is fully editable.
    Currently, I'm working on the symbols with the new font to pack them into a library.

    I was looking for English tutorials that I could use for the promised Mini HowTo and spotted a small tool to optimize the SVG code. Personally, I'm not that experienced in coding, but maybe it's useful to you.
    https://github.com/jakearchibald/svgomg
    Follow the two links at the beginning of README.md

  27. jnavila commented on Aug 8, 2019

    @jnavila
    Member

    I just pushed the filtered SVGs to the branch filtered_svg.

    It's not so bad, have a look, please.
    At first glance, some files have been upset (where the texts have been caught by the rewrite rules for centering text in false positive):

    • clean
    • commit-and-tree
    • commits-and-parents
    • data-model-1
    • distributed
    • lifecycle
    • local
    • rerere2
    • rerere3
    • reset-ex1
    • reset-ex2
    • smudge
  28. ben commented on Aug 8, 2019

    @ben
    Member

    It's a good starting point. Want to spin up a PR so we can move this discussion over there?

  29. jnavila commented on Aug 8, 2019

    @jnavila
    Member

    Sure: #1288

  30. KZiemian commented on Aug 27, 2022

    @KZiemian

    Can this issue be close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions