Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • P pango
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 134
    • Issues 134
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 19
    • Merge requests 19
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • pango
  • Issues
  • #616

Closed
Open
Created Oct 21, 2021 by Jan Okruta@jan.okruta

Underline not working for some fonts in pango 1.46.2 (and higher)

Underline is not working for some fonts after upgrading pango from 1.42.4 to 1.46.2. Issue appears also in version 1.49.1

#include <cairo.h>
#include <pango/pangocairo.h>

int main(int argc, char *argv[]) {
    cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 240, 80);
    cairo_t *cr = cairo_create(surface);

    PangoFontDescription *font_description = pango_font_description_new();
    pango_font_description_set_absolute_size(font_description, 32 * PANGO_SCALE);

    const char *family = "Abhaya Libre";
    pango_font_description_set_family(font_description, family);

    PangoLayout *layout = pango_cairo_create_layout(cr);
    pango_layout_set_font_description(layout, font_description);
    pango_layout_set_text(layout, "Hello, world", -1);

    struct _PangoAttrList *attrs = pango_attr_list_new();
    pango_attr_list_insert(attrs, pango_attr_underline_new(PANGO_UNDERLINE_SINGLE));
    pango_layout_set_attributes(layout, attrs);

    pango_cairo_show_layout(cr, layout);

    g_object_unref(layout);
    pango_font_description_free(font_description);

    cairo_destroy(cr);

    cairo_surface_write_to_png(surface, "hello.png");
    cairo_surface_destroy(surface);

    return 0;
}

Sample font where underline is not working: Abhaya Libre Abhaya_Libre

Sample font where underline is working: Lato Lato

Edited Oct 22, 2021 by Jan Okruta
Assignee
Assign to
Time tracking