[Bug 219608] print/freetype2 produces incorrect line spacing for some fonts

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Jul 1 07:43:26 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219608

lightside <lightside at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #183237|0                           |1
        is obsolete|                            |
 Attachment #183327|0                           |1
        is obsolete|                            |

--- Comment #24 from lightside <lightside at gmx.com> ---
Created attachment 183976
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=183976&action=edit
Some files/patch-fix_size_metrics.diff patch for test (for v2.8)

Sorry for the delay. Some time was needed to create automated testing
environment for using with "git bisect run".

The new git bisect showed following commit (based on some output from DejaVu
Sans Mono Book 14 font):
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=8ab08cff63eeb23b6c9f2c4470ae9809f2acf244
-8<--
# bad: [a12a34451a99cbbcad55d466940fd445171927fd] * Version 2.8 released.
=======================
# good: [069083cccd73d1d68da68116c8d050bb62cdfe0e] * Version 2.7.1 released.
=========================
git bisect start 'VER-2-8' 'VER-2-7-1' '--'
# bad: [c1b000da00c747cb46fd4c95ca83bee802d35487] [sfnt] Remove redundant code.
git bisect bad c1b000da00c747cb46fd4c95ca83bee802d35487
# bad: [f4e569664332b30eca48643ed5194d0da91b0560] [sfnt]
s/TT_NameEntry/TT_Name/.
git bisect bad f4e569664332b30eca48643ed5194d0da91b0560
# good: [7ccca6aec167c2c30c569765ece808f0eee023a6] [pcf] Disable long family
names by default.
git bisect good 7ccca6aec167c2c30c569765ece808f0eee023a6
# bad: [8013d89f7fe7da123e3cd5708e501caf88405226] ftsnames.h, ttnameid.h,
tttables.h: Revise documentation.
git bisect bad 8013d89f7fe7da123e3cd5708e501caf88405226
# bad: [56645f8a8ba0a08ed2bd383b5a1558e5c790bf74] Fix documentation of
`FT_Get_Sfnt_Name'.
git bisect bad 56645f8a8ba0a08ed2bd383b5a1558e5c790bf74
# bad: [d718ac4ead0d711bd73d8103ba67cca10a55b3d9] [truetype] Provide metrics
variation service.
git bisect bad d718ac4ead0d711bd73d8103ba67cca10a55b3d9
# bad: [07ee1d250c5ae008e3467dea39dfc0b7f99af0b3] [truetype] Parse `MVAR'
table.
git bisect bad 07ee1d250c5ae008e3467dea39dfc0b7f99af0b3
# bad: [8ab08cff63eeb23b6c9f2c4470ae9809f2acf244] [truetype] More preparations
for MVAR support.
git bisect bad 8ab08cff63eeb23b6c9f2c4470ae9809f2acf244
# first bad commit: [8ab08cff63eeb23b6c9f2c4470ae9809f2acf244] [truetype] More
preparations for MVAR support.
-->8-

I attached new patch, which fixes this.

Also I created following application to get some related information for
specified font (similar to what in
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/src/base/ftobjs.c?h=VER-2-8#n3076
and some from ftdump, but with ability to specify dpi):
-8<-- font_info
#include <ft2build.h>
#include FT_FREETYPE_H

FT_Error font_info(FT_Library ft, const char *font, const long dpi, const long
size)
{
        FT_Error error;
        FT_Face face;

        error = FT_New_Face(ft, font, 0, &face);
        if (error) {
                fprintf(stderr, "Unable to load font: %s\n", font);
                return error;
        }
        // Set size in pixels
        //error = FT_Set_Pixel_Sizes(face, 0, size);
        error = FT_Set_Char_Size(face, size * 64, size * 64, dpi, dpi);
        if (error) {
                fprintf(stderr, "Unable to set font size for: %s\n", font);
        }
        else {
                printf("font: %s\nstyle: %s\ndpi: %ld\nsize: %ld\n", \
                        face->family_name, face->style_name, dpi, size);
                //if (FT_IS_SCALABLE(face))
                printf("Face:\n"
                        "  ascender: %f\n" \
                        "  descender: %f\n" \
                        "  height: %f\n",
                        face->ascender / 64.0,
                        face->descender / 64.0,
                        face->height / 64.0
                );

                FT_Size_Metrics *metrics = &face->size->metrics;

                printf("Size metrics:\n" \
                        "  ascender: %f\n" \
                        "  descender: %f\n" \
                        "  height: %f\n" \
                        "  max advance: %f\n" \
                        "  x scale: %ld (%f)\n" \
                        "  y scale: %ld (%f)\n" \
                        "  x ppem: %d\n" \
                        "  y ppem: %d\n",
                        metrics->ascender / 64.0,
                        metrics->descender / 64.0,
                        metrics->height / 64.0,
                        metrics->max_advance / 64.0,
                        metrics->x_scale, metrics->x_scale / 65536.0,
                        metrics->y_scale, metrics->y_scale / 65536.0,
                        metrics->x_ppem,
                        metrics->y_ppem
                );
        }

        FT_Done_Face(face);

        return error;
}

int main(int argc, char **argv)
{
        if (argc < 2) {
                fprintf(stderr, "Usage: %s [-v] [-d dpi] [-s size]
path_to_font\n", argv[0]);
                return 1;
        }

        const char *font = NULL;
        long dpi = 72, size = 10;
        int verbose = 0;

        for (int i = 1; i < argc; ++i) {
                if (argv[i][0] == '-') switch (argv[i][1]) {
                        case 'd': {
                                if (i + 1 < argc) {
                                        //dpi = atoi(argv[++i]);
                                        dpi = strtol(argv[++i], NULL, 10);
                                }
                                else {
                                        fprintf(stderr, "Specify dpi for the
font\n");
                                        return 1;
                                }
                                break;
                        }
                        case 's': {
                                if (i + 1 < argc) {
                                        //size = atoi(argv[++i]);
                                        size = strtol(argv[++i], NULL, 10);
                                }
                                else {
                                        fprintf(stderr, "Specify size (in
pixels) for the font\n");
                                        return 1;
                                }
                                break;
                        }
                        case 'v': {
                                verbose = 1;
                                break;
                        }
                }
                else {
                        font = argv[i];
                }
        }

        if (font == NULL) {
                fprintf(stderr, "Specify path to the font\n");
                return 1;
        }

        if (verbose)
                printf("path: %s\n", font);

        FT_Error error;
        FT_Library ft;

        error = FT_Init_FreeType(&ft);
        if (error) {
                fprintf(stderr, "Unable to initialize FreeType\n");
                return 1;
        }

        error = font_info(ft, font, dpi, size);
        if (error)
                return 1;

        FT_Done_FreeType(ft);

        return 0;
}
-->8-

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.


More information about the freebsd-gnome mailing list