Menu

xfig reduces font size when exporting

2024-04-03
2024-04-04
  • Fabiano Baroni

    Fabiano Baroni - 2024-04-03

    xfig (through fig2dev) reduces font size when exporting by a factor of 1.3229.

    I first thought this might be related to the particular point size adopted in xfig (1/80 inch in xfig/fig2dev, as opposed to 1/72 inch), but that's not the case (80/72 = 1.1111).

    Actually, the -F option is not recognized by fig2dev when exporting to png, and one gets the error

    Argument -F unknown to png driver.
    

    Opening xfig with the -correct_font_size option does not have any effect either (as expected from fig2dev not recognizing the corresponding option -F).

    As a MRE, this fig file, which just contains a single letter "A"

    #FIG 3.2  Produced by xfig version 3.2.6a
    Landscape
    Center
    Metric
    A4
    100.00
    Single
    -2
    1200 2
    4 0 0 50 -1 18 132 0.0000 4 1620 1605 10575 7335 A\001
    

    is converted to

    <?xml version="1.0" standalone="no"?>
    <!-- Creator: fig2dev Version 3.2.6a -->
    <!-- CreationDate: 2024-04-02 11:00:16 -->
    <!-- Magnification: 1.05 -->
    <svg    xmlns="http://www.w3.org/2000/svg"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        width="106pt" height="104pt"
        viewBox="10560 5700 1676 1650">
    <g fill="none">
    <!-- Text -->
    <text xml:space="preserve" x="10575" y="7335" fill="#000000" font-family="Helvetica" font-style="normal" font-weight="bold" font-size="1584" text-anchor="start">A</text>
    </g>
    </svg>
    

    by the command

    fig2dev -L svg test_A.fig test_A.svg
    

    The font size is indicated in pt in the fig file (132), but not in the svg file (1584, I don't know which units are used there).

    If I open the svg file with inkscape, the font size shows as 99.78302765 (132 / 99.78302765 = 1.3229).

    I suspect that the discrepancy might be due to a point/pixel confusion, since the ratio between the two is close to the shrinking ratio observed, but not identical (one point is the equivalent of 1.333 pixels).

    Does anyone know what could be the origin of this font size discrepancy, and how to fix it?

     
  • tkl

    tkl - 2024-04-03

    The discrepancy is due to a programming error: At one point in the code the font size is multiplied by 12, instead of either 15 ( = 1200/80, 1200 being the dpi used internally by xfig) or 16.66 ( = 1200/72). Either way, neither 15/12 nor 16.6/12 do explain the factor. In addition, fig files in metric mode are scaled by approx. 1.05 (= 1200/(450x2.54)), because in metric mode fig uses 450 dots to the centimeter. I recommend to always use imperial mode. The 1200 dpi in xfig are quite hard-wired in the code, and the scaling from metric mode to the real dimensions are often not applied.
    The output to png accepts the -F option, and shows a more correct font size. For svg, I opened ticket [#176]. For the time being, the only option is to draw bigger text, or divide the value of the font-size attribute in the svg output by 0.72 ( = 72 × 12 / 1200).

     

    Related

    Tickets: #176

  • Fabiano Baroni

    Fabiano Baroni - 2024-04-04

    Thank you @tkl, actually with a more recent version (3.2.8b) the -F option works for outputting to png (but not to svg), and the font size still shrinks a bit but not as much.

    If I set units to Imperial (fraction), and then export to png, the font size looks ok (as in xfig). The same result is obtained using fig2dev with the -F option.

    When exporting to svg, font size is still shrunk (maybe because fig2dev does not recognize the -F option for exporting to svg, or at least that might be part of the reason).

     

    Last edit: Fabiano Baroni 2024-04-04

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.