[pango/simple-fontmap: 26/26] Tweaks




commit 8e7967bcf84c501100be874caa068195858424fd
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 2 00:47:06 2021 -0400

    Tweaks

 pango/pango-hbface.c        |  6 +++---
 pango/pango-hbface.h        |  2 +-
 pango/pango-hbfont.c        | 22 +++++++++++++++++-----
 pango/pango-hbfont.h        | 14 ++++++++++----
 pango/pango-simplefontmap.c | 13 ++++++++-----
 5 files changed, 39 insertions(+), 18 deletions(-)
---
diff --git a/pango/pango-hbface.c b/pango/pango-hbface.c
index fcc17ede..5f9306b1 100644
--- a/pango/pango-hbface.c
+++ b/pango/pango-hbface.c
@@ -109,7 +109,7 @@ get_name_from_hb_face (hb_face_t       *face,
 }
 
 PangoHbFace *
-pango_hb_face_new (hb_blob_t    *blob,
+pango_hb_face_new (const char   *file,
                    unsigned int  index)
 {
   PangoHbFace *self;
@@ -117,9 +117,9 @@ pango_hb_face_new (hb_blob_t    *blob,
 
   self = g_object_new (PANGO_TYPE_HB_FACE, NULL);
 
-  self->blob = hb_blob_reference (blob);
+  self->blob = hb_blob_create_from_file (file);
   self->index = index;
-  self->face = hb_face_create (blob, index);
+  self->face = hb_face_create (self->blob, index);
 
   name = get_name_from_hb_face (self->face, HB_OT_NAME_ID_FULL_NAME);
   self->description = pango_font_description_from_string (name);
diff --git a/pango/pango-hbface.h b/pango/pango-hbface.h
index 5893ae7a..96efb6a2 100644
--- a/pango/pango-hbface.h
+++ b/pango/pango-hbface.h
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (PangoHbFace, pango_hb_face, PANGO, HB_FACE, PangoFontFace)
 
 PANGO_AVAILABLE_IN_1_50
-PangoHbFace *pango_hb_face_new (hb_blob_t    *blob,
+PangoHbFace *pango_hb_face_new (const char   *file,
                                 unsigned int  index);
 
 G_END_DECLS
diff --git a/pango/pango-hbfont.c b/pango/pango-hbfont.c
index 413d457a..1da5b7d0 100644
--- a/pango/pango-hbfont.c
+++ b/pango/pango-hbfont.c
@@ -38,6 +38,8 @@ G_DEFINE_TYPE (PangoHbFont, pango_hb_font, PANGO_TYPE_FONT)
 static void
 pango_hb_font_init (PangoHbFont *self)
 {
+  self->gravity = PANGO_GRAVITY_SOUTH;
+  self->dpi = 96.;
 }
 
 static void
@@ -305,9 +307,7 @@ pango_hb_font_class_init (PangoHbFontClass *class)
 
 PangoHbFont *
 pango_hb_font_new (PangoHbFace                *face,
-                   const PangoFontDescription *description,
-                   PangoGravity                gravity,
-                   double                      dpi)
+                   const PangoFontDescription *description)
 {
   PangoHbFont *font;
 
@@ -315,8 +315,20 @@ 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;
 }
+
+void
+pango_hb_font_set_gravity (PangoHbFont  *self,
+                           PangoGravity  gravity)
+{
+  self->gravity = gravity;
+}
+
+void
+pango_hb_font_set_resolution (PangoHbFont  *self,
+                              double        dpi)
+{
+  self->dpi = dpi;
+}
diff --git a/pango/pango-hbfont.h b/pango/pango-hbfont.h
index c01da1dc..d74ad930 100644
--- a/pango/pango-hbfont.h
+++ b/pango/pango-hbfont.h
@@ -33,9 +33,15 @@ PANGO_AVAILABLE_IN_1_50
 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,
-                                double                      dpi);
+PangoHbFont *           pango_hb_font_new               (PangoHbFace                 *face,
+                                                         const PangoFontDescription  *description);
+
+PANGO_AVAILABLE_IN_1_50
+void                    pango_hb_font_set_gravity       (PangoHbFont                 *self,
+                                                         PangoGravity                 gravity);
+
+PANGO_AVAILABLE_IN_1_50
+void                    pango_hb_font_set_resolution    (PangoHbFont                 *self,
+                                                         double                       dpi);
 
 G_END_DECLS
diff --git a/pango/pango-simplefontmap.c b/pango/pango-simplefontmap.c
index 8dbf36cc..09237303 100644
--- a/pango/pango-simplefontmap.c
+++ b/pango/pango-simplefontmap.c
@@ -204,6 +204,7 @@ pango_simple_font_map_load_font (PangoFontMap               *map,
   PangoSimpleFontMap *self = PANGO_SIMPLE_FONT_MAP (map);
   PangoFontDescription *best = NULL;
   PangoHbFace *face = NULL;
+  PangoHbFont *font;
 
   for (int i = 0; i < self->faces->len; i++)
     {
@@ -218,7 +219,12 @@ 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), self->dpi));
+  font = pango_hb_font_new (face, desc);
+
+  pango_hb_font_set_gravity (font, pango_context_get_gravity (context));
+  pango_hb_font_set_resolution (font, self->dpi);
+
+  return PANGO_FONT (font);
 }
 
 static PangoFontset *
@@ -304,12 +310,9 @@ pango_simple_font_map_add_file (PangoSimpleFontMap *self,
                                 unsigned int        index)
 {
   PangoFontMap *map = PANGO_FONT_MAP (self);
-  hb_blob_t *blob;
   PangoHbFace *face;
 
-  blob = hb_blob_create_from_file (file);
-  face = pango_hb_face_new (blob, index);
-  hb_blob_destroy (blob);
+  face = pango_hb_face_new (file, index);
 
   pango_hb_face_set_font_map (face, map);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]