+2008-10-27 Richard Hult <richard@imendio.com>
+
+ Bug 558107 – is_monospace always returns FALSE in pangoatsui
+
+ * pango/pangoatsui-fontmap.c: (pango_atsui_family_is_monospace),
+ (pango_atsui_font_map_init): Mark families whose faces have the
+ NSFixedPitchFontMask set as monospaced, and use this in the
+ is_monospace implementation.
+
2008-10-23 Behdad Esfahbod <behdad@gnome.org>
Bug 557620 – pango_font_description_from_string not correct
char *family_name;
+ guint is_monospace : 1;
+
PangoFontFace **faces;
gint n_faces;
};
static const char *
pango_atsui_family_get_name (PangoFontFamily *family)
+
{
PangoATSUIFamily *atsuifamily = PANGO_ATSUI_FAMILY (family);
static gboolean
pango_atsui_family_is_monospace (PangoFontFamily *family)
{
- /* Fixme: Implement */
- return FALSE;
+ PangoATSUIFamily *atsuifamily = PANGO_ATSUI_FAMILY (family);
+
+ return atsuifamily->is_monospace;
}
static void
static void
pango_atsui_font_map_init (PangoATSUIFontMap *atsuifontmap)
{
- NSArray *family_array;
NSAutoreleasePool *pool;
+ NSFontManager *manager;
+ NSArray *family_array;
PangoATSUIFamily *family;
-
int size, i;
atsuifontmap->families = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL);
pool = [[NSAutoreleasePool alloc] init];
- family_array = [[NSFontManager sharedFontManager] availableFontFamilies];
+ manager = [NSFontManager sharedFontManager];
+ family_array = [manager availableFontFamilies];
size = [family_array count];
- for (i = 0; i < size; i++) {
- NSString *family_name = [family_array objectAtIndex:i];
-
- family = g_object_new (PANGO_TYPE_ATSUI_FAMILY, NULL);
- family->family_name = g_strdup ([family_name UTF8String]);
-
- g_hash_table_insert (atsuifontmap->families, g_utf8_casefold (family->family_name, -1), family);
- }
+ for (i = 0; i < size; i++)
+ {
+ NSString *family_name = [family_array objectAtIndex:i];
+ NSArray *members;
+
+ family = g_object_new (PANGO_TYPE_ATSUI_FAMILY, NULL);
+ family->family_name = g_strdup ([family_name UTF8String]);
+
+ members = [manager availableMembersOfFontFamily:family_name];
+ if ([members count] > 0)
+ {
+ NSArray *font_array = [members objectAtIndex:0];
+
+ /* We assume that all faces in the family are monospaced, or
+ * none.
+ */
+ if ([[font_array objectAtIndex:3] intValue] & NSFixedPitchFontMask)
+ family->is_monospace = TRUE;
+ }
+
+ g_hash_table_insert (atsuifontmap->families, g_utf8_casefold (family->family_name, -1), family);
+ }
/* Insert aliases */
family = g_object_new (PANGO_TYPE_ATSUI_FAMILY, NULL);
family = g_object_new (PANGO_TYPE_ATSUI_FAMILY, NULL);
family->family_name = g_strdup ("Monospace");
+ family->is_monospace = TRUE;
g_hash_table_insert (atsuifontmap->families, g_utf8_casefold (family->family_name, -1), family);
[pool release];