glyphy: Implement synthetic bold
When the font appears to be synthetic bold (as indicated by th embolden property in FcPattern), use glyphys boldness uniform to render the font bolder.
This commit is contained in:
@@ -35,6 +35,9 @@
|
||||
#include <gsk/gskrectprivate.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_PANGOFT
|
||||
#include <pango/pangofc-font.h>
|
||||
#endif
|
||||
|
||||
#include "gskglcommandqueueprivate.h"
|
||||
#include "gskgldriverprivate.h"
|
||||
@@ -3150,6 +3153,23 @@ add_encoded_glyph (GskGLDrawVertex *vertices,
|
||||
*vertices = (GskGLDrawVertex) { .position = { eg->x, eg->y}, .uv = { eg->g16hi, eg->g16lo}, .color = { c[0], c[1], c[2], c[3] } };
|
||||
}
|
||||
|
||||
static gboolean
|
||||
font_is_synthetic_bold (PangoFont *font)
|
||||
{
|
||||
#ifdef HAVE_PANGOFT
|
||||
if (PANGO_IS_FC_FONT (font))
|
||||
{
|
||||
FcPattern *pattern = pango_fc_font_get_pattern (PANGO_FC_FONT (font));
|
||||
gboolean ret;
|
||||
|
||||
if (FcPatternGetBool (pattern, FC_EMBOLDEN, 0, &ret) == FcResultMatch)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_gl_render_job_visit_text_node_glyphy (GskGLRenderJob *job,
|
||||
const GskRenderNode *node,
|
||||
@@ -3173,6 +3193,7 @@ gsk_gl_render_job_visit_text_node_glyphy (GskGLRenderJob *job,
|
||||
guint i;
|
||||
int x_position = 0;
|
||||
float font_scale;
|
||||
gboolean synthetic_bold;
|
||||
|
||||
g_assert (!gsk_text_node_has_color_glyphs (node));
|
||||
|
||||
@@ -3183,6 +3204,8 @@ gsk_gl_render_job_visit_text_node_glyphy (GskGLRenderJob *job,
|
||||
return;
|
||||
|
||||
font = (PangoFont *)gsk_text_node_get_font (node);
|
||||
synthetic_bold = font_is_synthetic_bold (font);
|
||||
|
||||
glyphs = gsk_text_node_get_glyphs (node, NULL);
|
||||
library = job->driver->glyphy_library;
|
||||
offset = gsk_text_node_get_offset (node);
|
||||
@@ -3245,6 +3268,10 @@ gsk_gl_render_job_visit_text_node_glyphy (GskGLRenderJob *job,
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_CONTRAST, 0,
|
||||
1.0);
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_BOLDNESS, 0,
|
||||
synthetic_bold ? 0.1 : 0.0);
|
||||
|
||||
#if 0
|
||||
gsk_gl_program_set_uniform1f (job->current_program,
|
||||
UNIFORM_GLYPHY_OUTLINE_THICKNESS, 0,
|
||||
|
||||
Reference in New Issue
Block a user