[pango/simple-fontmap: 24/26] Add resolution
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/simple-fontmap: 24/26] Add resolution
- Date: Thu, 2 Sep 2021 10:52:29 +0000 (UTC)
commit cb47caa2c79e7f46e206c8046c7bab5ec1439213
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 2 00:11:59 2021 -0400
Add resolution
Just like the other fontmaps, make this a property
that fonts inherit.
pango/pango-hbfont-private.h | 1 +
pango/pango-hbfont.c | 8 +++++---
pango/pango-hbfont.h | 3 ++-
pango/pango-simplefontmap.c | 13 ++++++++++++-
pango/pango-simplefontmap.h | 4 ++++
pango/pangocairo-fcfont.c | 4 ++--
6 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/pango/pango-hbfont-private.h b/pango/pango-hbfont-private.h
index 82f4849a..3e1c98d1 100644
--- a/pango/pango-hbfont-private.h
+++ b/pango/pango-hbfont-private.h
@@ -11,4 +11,5 @@ struct _PangoHbFont
PangoHbFace *face;
PangoFontDescription *description;
PangoGravity gravity;
+ double dpi;
};
diff --git a/pango/pango-hbfont.c b/pango/pango-hbfont.c
index 8c92911c..413d457a 100644
--- a/pango/pango-hbfont.c
+++ b/pango/pango-hbfont.c
@@ -236,8 +236,8 @@ pango_hb_font_create_hb_font (PangoFont *font)
/* Size */
size = pango_font_description_get_size (self->description);
hb_font_set_scale (hb_font,
- size * (96. / 72.),
- size * (96. / 72.));
+ size * (self->dpi / 72.),
+ size * (self->dpi / 72.));
/* Variations */
n_axes = 32;
@@ -306,7 +306,8 @@ pango_hb_font_class_init (PangoHbFontClass *class)
PangoHbFont *
pango_hb_font_new (PangoHbFace *face,
const PangoFontDescription *description,
- PangoGravity gravity)
+ PangoGravity gravity,
+ double dpi)
{
PangoHbFont *font;
@@ -315,6 +316,7 @@ pango_hb_font_new (PangoHbFace *face,
font->face = g_object_ref (face);
font->description = pango_font_description_copy (description);
font->gravity = gravity;
+ font->dpi = dpi;
return font;
}
diff --git a/pango/pango-hbfont.h b/pango/pango-hbfont.h
index a159897b..c01da1dc 100644
--- a/pango/pango-hbfont.h
+++ b/pango/pango-hbfont.h
@@ -35,6 +35,7 @@ G_DECLARE_FINAL_TYPE (PangoHbFont, pango_hb_font, PANGO, HB_FONT, PangoFont)
PANGO_AVAILABLE_IN_1_50
PangoHbFont *pango_hb_font_new (PangoHbFace *face,
const PangoFontDescription *description,
- PangoGravity gravity);
+ PangoGravity gravity,
+ double dpi);
G_END_DECLS
diff --git a/pango/pango-simplefontmap.c b/pango/pango-simplefontmap.c
index a3297908..8dbf36cc 100644
--- a/pango/pango-simplefontmap.c
+++ b/pango/pango-simplefontmap.c
@@ -34,6 +34,8 @@ struct _PangoSimpleFontMap
GPtrArray *families;
GPtrArray *faces;
+
+ double dpi;
};
struct _PangoSimpleFontMapClass
@@ -48,6 +50,8 @@ pango_simple_font_map_init (PangoSimpleFontMap *self)
{
self->families = g_ptr_array_new_with_free_func (g_object_unref);
self->faces = g_ptr_array_new_with_free_func (g_object_unref);
+
+ self->dpi = 96.;
}
static void
@@ -214,7 +218,7 @@ pango_simple_font_map_load_font (PangoFontMap *map,
if (face == NULL)
face = g_ptr_array_index (self->faces, 0);
- return PANGO_FONT (pango_hb_font_new (face, desc, pango_context_get_gravity (context)));
+ return PANGO_FONT (pango_hb_font_new (face, desc, pango_context_get_gravity (context), self->dpi));
}
static PangoFontset *
@@ -315,4 +319,11 @@ pango_simple_font_map_add_file (PangoSimpleFontMap *self,
g_ptr_array_add (self->faces, face);
}
+void
+pango_simple_font_map_set_resolution (PangoSimpleFontMap *self,
+ double dpi)
+{
+ self->dpi = dpi;
+}
+
/* vim:set foldmethod=marker expandtab: */
diff --git a/pango/pango-simplefontmap.h b/pango/pango-simplefontmap.h
index 6887109b..9aa67fd3 100644
--- a/pango/pango-simplefontmap.h
+++ b/pango/pango-simplefontmap.h
@@ -39,4 +39,8 @@ void pango_simple_font_map_add_file (PangoSimpleFontMap *s
const char *file,
unsigned int index);
+PANGO_AVAILABLE_IN_1_50
+void pango_simple_font_map_set_resolution (PangoSimpleFontMap *self,
+ double dpi);
+
G_END_DECLS
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index 7de5e2ab..f2064dfa 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -317,8 +317,8 @@ create_scaled_font (PangoHbFont *font)
cairo_matrix_init_identity (&ctm);
cairo_matrix_init_scale (&font_matrix,
- size * (96. / 72.) / PANGO_SCALE,
- size * (96. / 72) / PANGO_SCALE);
+ size * (font->dpi / 72.) / PANGO_SCALE,
+ size * (font->dpi / 72) / PANGO_SCALE);
cairo_matrix_multiply (&font_matrix,
&font_matrix,
&gravity_matrix);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]