Skip to content

Can't turn off font hinting / metrics #296

@jkrumbiegel

Description

@jkrumbiegel

When animating a drawing text glyphs jitter around, I assume they align to the underlying device space integer grid. I've found cairo functions to turn off that behavior that are not exposed in Cairo.jl's API. But using them doesn't work, maybe I'm doing something wrong. I think this would be beneficial to have included in Cairo.jl.

That's the code to turn off hinting that I use

font_options_ptr = ccall((:cairo_font_options_create, C.libcairo), Ptr{Nothing}, ())

CAIRO_HINT_STYLE_NONE = 1
CAIRO_HINT_STYLE_FULL = 4
ccall(
    (:cairo_font_options_set_hint_style, C.libcairo), Nothing,
    (Ptr{Nothing}, Int32),
    font_options_ptr, CAIRO_HINT_STYLE_NONE)

CAIRO_HINT_METRICS_DEFAULT = 0
CAIRO_HINT_METRICS_OFF = 1
CAIRO_HINT_METRICS_ON = 2

ccall(
    (:cairo_font_options_set_hint_metrics, C.libcairo), Nothing,
    (Ptr{Nothing}, Int32),
    font_options_ptr, CAIRO_HINT_METRICS_OFF)

# cc is a cairo context
ccall(
    (:cairo_set_font_options, C.libcairo), Nothing,
    (Ptr{Nothing}, Ptr{Nothing}),
    cc.ptr, font_options_ptr)

ccall(
    (:cairo_font_options_destroy, C.libcairo), Nothing,
    (Ptr{Nothing},),
    font_options_ptr)

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