summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
Diffstat (limited to 'pango')
-rw-r--r--pango/pangoatsui-fontmap.c64
-rw-r--r--pango/pangoatsui-private.h19
-rw-r--r--pango/pangoatsui.c17
-rw-r--r--pango/pangocairo-atsui.h2
-rw-r--r--pango/pangocairo-atsuifont.c8
-rw-r--r--pango/pangocairo-atsuifontmap.c6
6 files changed, 77 insertions, 39 deletions
diff --git a/pango/pangoatsui-fontmap.c b/pango/pangoatsui-fontmap.c
index 0ba5caec..7eee93b7 100644
--- a/pango/pangoatsui-fontmap.c
+++ b/pango/pangoatsui-fontmap.c
@@ -2,7 +2,7 @@
* pangoatsui-fontmap.c
*
* Copyright (C) 2000-2003 Red Hat, Inc.
- * Copyright (C) 2005 Imendio AB
+ * Copyright (C) 2005-2007 Imendio AB
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -29,8 +29,6 @@
#import <Cocoa/Cocoa.h>
-typedef struct _PangoATSUIFamily PangoATSUIFamily;
-typedef struct _PangoATSUIFace PangoATSUIFace;
typedef struct _FontHashKey FontHashKey;
struct _PangoATSUIFamily
@@ -57,6 +55,8 @@ struct _PangoATSUIFace
PangoATSUIFamily *family;
+ PangoCoverage *coverage;
+
char *postscript_name;
char *style_name;
@@ -292,6 +292,9 @@ pango_atsui_face_finalize (GObject *object)
{
PangoATSUIFace *atsuiface = PANGO_ATSUI_FACE (object);
+ if (atsuiface->coverage)
+ pango_coverage_unref (atsuiface->coverage);
+
g_free (atsuiface->postscript_name);
g_free (atsuiface->style_name);
@@ -340,6 +343,34 @@ pango_atsui_face_get_type (void)
return object_type;
}
+const char *
+_pango_atsui_face_get_postscript_name (PangoATSUIFace *face)
+{
+ return face->postscript_name;
+}
+
+PangoCoverage *
+_pango_atsui_face_get_coverage (PangoATSUIFace *face,
+ PangoLanguage *language)
+{
+ int i;
+
+ /* Note: We currently fake the coverage by reporting that the 255 first
+ * glyphs exist in all fonts, which is not true. It's unclear how to get
+ * this done correctly.
+ */
+
+ if (face->coverage)
+ return face->coverage;
+
+ face->coverage = pango_coverage_new ();
+
+ for (i = 0; i < 256; i++)
+ pango_coverage_set (face->coverage, i, PANGO_COVERAGE_EXACT);
+
+ return face->coverage;
+}
+
static void pango_atsui_font_map_class_init (PangoATSUIFontMapClass *class);
static void pango_atsui_font_map_init (PangoATSUIFontMap *atsuifontmap);
@@ -507,7 +538,7 @@ pango_atsui_font_map_add (PangoATSUIFontMap *atsuifontmap,
atsuifont->fontmap = g_object_ref (atsuifontmap);
font_hash_key_for_context (atsuifontmap, context, &key);
- key.postscript_name = atsuifont->postscript_name;
+ key.postscript_name = (char *)_pango_atsui_face_get_postscript_name (atsuifont->face);
key.desc = atsuifont->desc;
key_copy = font_hash_key_copy (&key);
@@ -517,15 +548,15 @@ pango_atsui_font_map_add (PangoATSUIFontMap *atsuifontmap,
}
static PangoATSUIFont *
-pango_atsui_font_map_lookup (PangoATSUIFontMap *atsuifontmap,
- PangoContext *context,
+pango_atsui_font_map_lookup (PangoATSUIFontMap *atsuifontmap,
+ PangoContext *context,
PangoFontDescription *desc,
- const char *postscript_name)
+ PangoATSUIFace *face)
{
FontHashKey key;
font_hash_key_for_context (atsuifontmap, context, &key);
- key.postscript_name = (char *)postscript_name;
+ key.postscript_name = (char *)_pango_atsui_face_get_postscript_name (face);
key.desc = desc;
return g_hash_table_lookup (atsuifontmap->font_hash, &key);
@@ -549,9 +580,10 @@ pango_atsui_font_map_load_font (PangoFontMap *fontmap,
return NULL;
name = g_utf8_casefold (pango_font_description_get_family (description), -1);
-
font_family = g_hash_table_lookup (atsuifontmap->families, name);
+
g_free (name);
+
if (font_family)
{
PangoFontDescription *best_desc = NULL, *new_desc;
@@ -583,23 +615,31 @@ pango_atsui_font_map_load_font (PangoFontMap *fontmap,
pango_font_description_set_size (best_desc, size);
- best_font = pango_atsui_font_map_lookup (atsuifontmap, context, best_desc, best_face->postscript_name);
+ best_font = pango_atsui_font_map_lookup (atsuifontmap,
+ context,
+ best_desc,
+ best_face);
if (best_font)
g_object_ref (best_font);
else
{
- best_font = (* PANGO_ATSUI_FONT_MAP_GET_CLASS (atsuifontmap)->create_font) (atsuifontmap, context,
- best_face->postscript_name, best_desc);
+ PangoATSUIFontMapClass *klass;
+ klass = PANGO_ATSUI_FONT_MAP_GET_CLASS (atsuifontmap);
+ best_font = klass->create_font (atsuifontmap, context,
+ best_face, best_desc);
+
if (best_font)
pango_atsui_font_map_add (atsuifontmap, context, best_font);
/* TODO: Handle the else case here. */
}
pango_font_description_free (best_desc);
+
return PANGO_FONT (best_font);
}
+
return NULL;
}
diff --git a/pango/pangoatsui-private.h b/pango/pangoatsui-private.h
index f0603c24..a8be49e1 100644
--- a/pango/pangoatsui-private.h
+++ b/pango/pangoatsui-private.h
@@ -2,7 +2,7 @@
* pangoatsui-private.h:
*
* Copyright (C) 2003 Red Hat Software
- * Copyright (C) 2005 Imendio AB
+ * Copyright (C) 2005-2007 Imendio AB
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -44,6 +44,9 @@ G_BEGIN_DECLS
#define PANGO_RENDER_TYPE_ATSUI "PangoRenderATSUI"
+typedef struct _PangoATSUIFamily PangoATSUIFamily;
+typedef struct _PangoATSUIFace PangoATSUIFace;
+
typedef struct _PangoATSUIFontMap PangoATSUIFontMap;
typedef struct _PangoATSUIFontMapClass PangoATSUIFontMapClass;
typedef struct _PangoATSUIFont PangoATSUIFont;
@@ -74,17 +77,17 @@ struct _PangoATSUIFontMapClass
gconstpointer key_a,
gconstpointer key_b);
- PangoATSUIFont * (* create_font) (PangoATSUIFontMap *fontmap,
- PangoContext *context,
- const char *postscript_name,
- const PangoFontDescription *desc);
+ PangoATSUIFont * (* create_font) (PangoATSUIFontMap *fontmap,
+ PangoContext *context,
+ PangoATSUIFace *face,
+ const PangoFontDescription *desc);
};
struct _PangoATSUIFont
{
PangoFont parent_instance;
- char *postscript_name;
+ PangoATSUIFace *face;
PangoFontDescription *desc;
PangoMatrix matrix;
gpointer context_key;
@@ -100,6 +103,10 @@ struct _PangoATSUIFontClass
GType pango_atsui_font_map_get_type (void);
GType pango_atsui_font_get_type (void);
+const char * _pango_atsui_face_get_postscript_name (PangoATSUIFace *face);
+PangoCoverage *_pango_atsui_face_get_coverage (PangoATSUIFace *face,
+ PangoLanguage *language);
+
G_END_DECLS
#endif /* __PANGOATSUI_H__ */
diff --git a/pango/pangoatsui.c b/pango/pangoatsui.c
index 231c1002..dcb410df 100644
--- a/pango/pangoatsui.c
+++ b/pango/pangoatsui.c
@@ -1,7 +1,7 @@
/* Pango
* pangatsui.c
*
- * Copyright (C) 2005 Imendio AB
+ * Copyright (C) 2005-2007 Imendio AB
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -30,7 +30,6 @@ pango_atsui_font_finalize (GObject *object)
{
PangoATSUIFont *font = (PangoATSUIFont *)object;
- g_free (font->postscript_name);
pango_font_description_free (font->desc);
g_object_unref (font->fontmap);
@@ -50,18 +49,8 @@ static PangoCoverage *
pango_atsui_font_get_coverage (PangoFont *font,
PangoLanguage *language)
{
- PangoCoverage *coverage;
- int i;
-
- /* FIXME: Currently we say that all fonts have the
- * 255 first glyphs. This is not true.
- */
- coverage = pango_coverage_new ();
-
- for (i = 0; i < 256; i++)
- pango_coverage_set (coverage, i, PANGO_COVERAGE_EXACT);
-
- return coverage;
+ return pango_coverage_ref (_pango_atsui_face_get_coverage (PANGO_ATSUI_FONT (font)->face,
+ language));
}
static PangoEngineShape *
diff --git a/pango/pangocairo-atsui.h b/pango/pangocairo-atsui.h
index 4de615f6..2d655aa2 100644
--- a/pango/pangocairo-atsui.h
+++ b/pango/pangocairo-atsui.h
@@ -48,7 +48,7 @@ GType pango_cairo_atsui_font_map_get_type (void);
PangoATSUIFont *
_pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
PangoContext *context,
- const char *postscript_name,
+ PangoATSUIFace *face,
const PangoFontDescription *desc);
G_END_DECLS
diff --git a/pango/pangocairo-atsuifont.c b/pango/pangocairo-atsuifont.c
index 72130e41..ce00ca10 100644
--- a/pango/pangocairo-atsuifont.c
+++ b/pango/pangocairo-atsuifont.c
@@ -2,7 +2,7 @@
* pangocairo-atsuifont.c
*
* Copyright (C) 2000-2005 Red Hat Software
- * Copyright (C) 2005 Imendio AB
+ * Copyright (C) 2005-2007 Imendio AB
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -263,9 +263,10 @@ pango_cairo_atsui_font_init (PangoCairoATSUIFont *cafont)
PangoATSUIFont *
_pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
PangoContext *context,
- const char *postscript_name,
+ PangoATSUIFace *face,
const PangoFontDescription *desc)
{
+ const char *postscript_name;
PangoCairoATSUIFont *cafont;
PangoATSUIFont *afont;
CFStringRef cfstr;
@@ -273,6 +274,7 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
const PangoMatrix *pango_ctm;
ATSUFontID font_id;
+ postscript_name = _pango_atsui_face_get_postscript_name (face);
cfstr = CFStringCreateWithCString (NULL, postscript_name,
kCFStringEncodingUTF8);
@@ -288,7 +290,7 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
afont = PANGO_ATSUI_FONT (cafont);
afont->desc = pango_font_description_copy (desc);
- afont->postscript_name = g_strdup (postscript_name);
+ afont->face = face;
cafont->size = (double) pango_font_description_get_size (desc) / PANGO_SCALE;
cafont->font_id = font_id;
diff --git a/pango/pangocairo-atsuifontmap.c b/pango/pangocairo-atsuifontmap.c
index 14adca47..13822b65 100644
--- a/pango/pangocairo-atsuifontmap.c
+++ b/pango/pangocairo-atsuifontmap.c
@@ -76,12 +76,12 @@ G_DEFINE_TYPE_WITH_CODE (PangoCairoATSUIFontMap, pango_cairo_atsui_font_map, PAN
static PangoATSUIFont *
pango_cairo_atsui_font_map_create_font (PangoATSUIFontMap *fontmap,
PangoContext *context,
- const char *postscript_name,
+ PangoATSUIFace *face,
const PangoFontDescription *desc)
{
- return _pango_cairo_atsui_font_new (PANGO_CAIRO_ATSUI_FONT_MAP (fontmap), context,
- postscript_name, desc);
+ return _pango_cairo_atsui_font_new (PANGO_CAIRO_ATSUI_FONT_MAP (fontmap),
+ context, face, desc);
}
static void