2000-06-20 22:24:49 +00:00
|
|
|
#include <glib.h>
|
|
|
|
#include "gdkprivate-fb.h"
|
|
|
|
#include "gdkpango.h"
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <pango/pango.h>
|
|
|
|
#include <pango/pango-modules.h>
|
|
|
|
|
|
|
|
#include <freetype/freetype.h>
|
2000-07-24 16:19:00 +00:00
|
|
|
#include <freetype/ftglyph.h>
|
2000-12-01 17:14:29 +00:00
|
|
|
|
2000-06-20 22:24:49 +00:00
|
|
|
#if !defined(FREETYPE_MAJOR) || FREETYPE_MAJOR != 2
|
2000-12-01 17:14:29 +00:00
|
|
|
#error "We need Freetype 2.0"
|
2000-06-20 22:24:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PANGO_RENDER_TYPE_FB "PangoRenderTypeFB"
|
|
|
|
|
2000-12-04 17:59:43 +00:00
|
|
|
#define PANGO_SCALE_26_6 (PANGO_SCALE / (1<<6))
|
|
|
|
#define PANGO_PIXELS_26_6(d) \
|
|
|
|
(((d) >= 0) ? \
|
|
|
|
((d) + PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6 : \
|
|
|
|
((d) - PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6)
|
|
|
|
#define PANGO_UNITS_26_6(d) (PANGO_SCALE_26_6 * (d))
|
|
|
|
|
2000-06-20 22:24:49 +00:00
|
|
|
typedef struct {
|
|
|
|
PangoFontMap parent_instance;
|
|
|
|
|
|
|
|
GPtrArray *all_descs;
|
|
|
|
GHashTable *all_fonts;
|
|
|
|
|
|
|
|
int n_fonts;
|
|
|
|
|
|
|
|
double resolution;
|
|
|
|
} PangoFBFontMap;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PangoFontMapClass parent_class;
|
|
|
|
} PangoFBFontMapClass;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PangoFontDescription desc;
|
|
|
|
FT_Face ftf;
|
|
|
|
} PangoFBFontListing;
|
|
|
|
|
|
|
|
FT_Library gdk_fb_ft_lib = NULL;
|
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
#define MAX_ALIASES 3
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PangoFontDescription alias;
|
|
|
|
PangoFontDescription descriptions[MAX_ALIASES];
|
|
|
|
} PangoFBAlias;
|
|
|
|
|
|
|
|
static PangoFBAlias alias_table[] =
|
|
|
|
{
|
|
|
|
/* sans: */
|
|
|
|
{
|
|
|
|
{"Sans", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{
|
|
|
|
{"Arial", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{"URW Gothic L", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Sans", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Arial", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{"URW Gothic L", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{"Sans", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{
|
|
|
|
{"Arial", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{"URW Gothic L", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Sans", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Arial", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
{"URW Gothic L", PANGO_STYLE_OBLIQUE, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/* serif: */
|
|
|
|
{
|
|
|
|
{"Serif", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{
|
|
|
|
{"Times New Roman", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{"URW Bookman L", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Serif", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Times New Roman", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{"URW Bookman L", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{"Serif", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{
|
|
|
|
{"Times New Roman", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{"URW Bookman L", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Serif", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Times New Roman", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{"URW Bookman L", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/* monospace: */
|
|
|
|
{
|
|
|
|
{"Monospace", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{
|
|
|
|
{"Courier New", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{"Courier", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Monospace", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Courier New", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
|
|
|
{"Courier", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_NORMAL, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{"Monospace", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{
|
|
|
|
{"Courier New", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{"Courier", PANGO_STYLE_NORMAL, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Monospace", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
{
|
2000-12-05 09:47:13 +00:00
|
|
|
{"Courier New", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
|
|
|
{"Courier", PANGO_STYLE_ITALIC, PANGO_VARIANT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_STRETCH_NORMAL},
|
2000-12-01 17:14:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ALIAS_TABLE_LEN (sizeof(alias_table)/sizeof(PangoFBAlias))
|
2000-07-24 16:19:00 +00:00
|
|
|
|
2000-06-20 22:24:49 +00:00
|
|
|
void
|
2000-11-13 17:40:23 +00:00
|
|
|
gdk_fb_font_init (void)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
FT_Init_FreeType (&gdk_fb_ft_lib);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-11-13 17:40:23 +00:00
|
|
|
gdk_fb_font_fini (void)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
FT_Done_FreeType (gdk_fb_ft_lib);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
void pango_fb_font_set_size (PangoFont *font);
|
|
|
|
static void pango_fb_font_map_init (PangoFBFontMap *fontmap);
|
|
|
|
static PangoFont *pango_fb_font_map_load_font (PangoFontMap *fontmap,
|
|
|
|
const PangoFontDescription *desc);
|
|
|
|
static void pango_fb_font_map_list_fonts (PangoFontMap *fontmap,
|
|
|
|
const gchar *family,
|
|
|
|
PangoFontDescription ***descs,
|
|
|
|
int *n_descs);
|
|
|
|
static void pango_fb_font_map_list_families (PangoFontMap *fontmap,
|
|
|
|
gchar ***families,
|
|
|
|
int *n_families);
|
2000-07-24 16:19:00 +00:00
|
|
|
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
static void
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_map_class_init (PangoFBFontMapClass *class)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
class->parent_class.load_font = pango_fb_font_map_load_font;
|
|
|
|
class->parent_class.list_fonts = pango_fb_font_map_list_fonts;
|
|
|
|
class->parent_class.list_families = pango_fb_font_map_list_families;
|
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_map_get_type (void)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
static GType object_type = 0;
|
|
|
|
|
|
|
|
if (!object_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo object_info =
|
|
|
|
{
|
|
|
|
sizeof (PangoFBFontMapClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) pango_fb_font_map_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (PangoFBFontMap),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) pango_fb_font_map_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
object_type = g_type_register_static (PANGO_TYPE_FONT_MAP,
|
|
|
|
"PangoFBFontMap",
|
2000-11-02 15:38:04 +00:00
|
|
|
&object_info,
|
|
|
|
0);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return object_type;
|
|
|
|
}
|
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
static gboolean
|
|
|
|
pango_font_description_equal_nosize (const PangoFontDescription *d1,
|
|
|
|
const PangoFontDescription *d2)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
(g_strcasecmp (d1->family_name, d2->family_name)==0) &&
|
|
|
|
d1->style == d2->style &&
|
|
|
|
d1->variant == d2->variant &&
|
|
|
|
d1->weight == d2->weight &&
|
|
|
|
d1->stretch == d2->stretch;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-20 22:24:49 +00:00
|
|
|
static PangoFont *
|
2000-12-01 17:14:29 +00:00
|
|
|
pango_fb_lookup_descr (PangoFontMap *fontmap,
|
|
|
|
const PangoFontDescription *desc,
|
|
|
|
const PangoFontDescription *save_as)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
PangoFBFontMap *fbfm = (PangoFBFontMap *)fontmap;
|
|
|
|
PangoFBFont *retval;
|
2000-08-07 03:26:05 +00:00
|
|
|
PangoFBFontListing *fl = NULL;
|
2000-06-20 22:24:49 +00:00
|
|
|
int i;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
retval = g_hash_table_lookup (fbfm->all_fonts, desc);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (retval)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
g_object_ref (G_OBJECT(retval));
|
2000-12-01 17:14:29 +00:00
|
|
|
return (PangoFont *)retval;
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
for (i = 0; i < fbfm->all_descs->len; i++)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
fl = g_ptr_array_index (fbfm->all_descs, i);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
if (pango_font_description_equal_nosize(desc, &fl->desc))
|
2000-06-20 22:24:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-12-01 17:14:29 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (i >= fbfm->all_descs->len)
|
2000-06-20 22:24:49 +00:00
|
|
|
return NULL;
|
|
|
|
|
2000-11-07 14:18:47 +00:00
|
|
|
retval = (PangoFBFont *)g_object_new (PANGO_TYPE_FB_FONT, NULL);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
retval->desc = *save_as;
|
|
|
|
retval->desc.family_name = g_strdup (save_as->family_name);
|
2000-06-20 22:24:49 +00:00
|
|
|
retval->ftf = fl->ftf;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
g_hash_table_insert (fbfm->all_fonts, &retval->desc, retval);
|
2000-12-01 17:14:29 +00:00
|
|
|
g_object_ref (G_OBJECT (retval)); /* XXX FIXME: We have to keep the font in the cache
|
|
|
|
forever because I'm too clueless to see
|
2000-11-13 17:40:23 +00:00
|
|
|
signals in gobject */
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
return (PangoFont *)retval;
|
2000-12-01 17:14:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PangoFont *
|
|
|
|
pango_fb_font_map_load_font (PangoFontMap *fontmap,
|
|
|
|
const PangoFontDescription *desc)
|
|
|
|
{
|
|
|
|
PangoFont *font;
|
|
|
|
const PangoFontDescription *descs;
|
|
|
|
const PangoFontDescription *alias;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
font = pango_fb_lookup_descr (fontmap, desc, desc);
|
|
|
|
|
|
|
|
if (font)
|
|
|
|
return font;
|
|
|
|
|
|
|
|
for (i=0;i<ALIAS_TABLE_LEN;i++)
|
|
|
|
{
|
|
|
|
alias = &alias_table[i].alias;
|
|
|
|
|
|
|
|
if (pango_font_description_equal_nosize (desc, alias))
|
|
|
|
{
|
|
|
|
descs = &alias_table[i].descriptions[0];
|
|
|
|
j = 0;
|
|
|
|
while ((j < MAX_ALIASES) &&
|
|
|
|
(descs[j].family_name != NULL))
|
|
|
|
{
|
|
|
|
font = pango_fb_lookup_descr (fontmap, &descs[j], desc);
|
|
|
|
if (font)
|
|
|
|
return font;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-11-13 17:40:23 +00:00
|
|
|
list_fonts (PangoFBFontMap *fm,
|
|
|
|
const char *family,
|
|
|
|
GPtrArray *descs,
|
|
|
|
const char *dir)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
DIR *dirh;
|
|
|
|
struct dirent *dent;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
dirh = opendir (dir);
|
|
|
|
if (!dirh)
|
2000-06-20 22:24:49 +00:00
|
|
|
return;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
while ((dent = readdir (dirh)))
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
PangoFBFontListing *pfd;
|
|
|
|
char *ctmp;
|
|
|
|
char buf[1024];
|
|
|
|
FT_Face ftf;
|
|
|
|
FT_Error ec;
|
|
|
|
int i = 0, n = 1;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
ctmp = strrchr (dent->d_name, '.');
|
|
|
|
if (!ctmp ||
|
|
|
|
(strcasecmp (ctmp, ".ttf") &&
|
|
|
|
strcasecmp (ctmp, ".pfa") &&
|
|
|
|
strcasecmp (ctmp, ".pfb")))
|
2000-06-20 22:24:49 +00:00
|
|
|
continue;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
g_snprintf (buf, sizeof(buf), "%s/%s", dir, dent->d_name);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
while (i < n)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
ec = FT_New_Face (gdk_fb_ft_lib, buf, i, &ftf);
|
|
|
|
if (ec)
|
2000-07-24 16:19:00 +00:00
|
|
|
break; /* error opening */
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
n = ftf->num_faces;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (!ftf->family_name || !ftf->style_name)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
g_warning ("No family/style on %s", buf);
|
|
|
|
FT_Done_Face (ftf);
|
2000-07-24 16:19:00 +00:00
|
|
|
break;
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
pfd = g_new0 (PangoFBFontListing, 1);
|
2000-06-20 22:24:49 +00:00
|
|
|
/* Now add the item */
|
2000-11-13 17:40:23 +00:00
|
|
|
if (ftf->family_name[0] == '/')
|
|
|
|
pfd->desc.family_name = g_strdup (ftf->family_name+1);
|
2000-07-24 16:19:00 +00:00
|
|
|
else
|
2000-11-13 17:40:23 +00:00
|
|
|
pfd->desc.family_name = g_strdup (ftf->family_name);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
pfd->desc.style = PANGO_STYLE_NORMAL;
|
|
|
|
pfd->desc.variant = PANGO_VARIANT_NORMAL;
|
|
|
|
pfd->desc.weight = PANGO_WEIGHT_NORMAL;
|
|
|
|
pfd->desc.stretch = PANGO_STRETCH_NORMAL;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (ftf->style_name)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
char lcstr[512];
|
2000-11-13 17:40:23 +00:00
|
|
|
strcpy (lcstr, ftf->style_name);
|
|
|
|
g_strdown (lcstr);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (strstr (lcstr, "italic"))
|
2000-06-20 22:24:49 +00:00
|
|
|
pfd->desc.style = PANGO_STYLE_ITALIC;
|
2000-11-13 17:40:23 +00:00
|
|
|
else if (strstr (lcstr, "oblique"))
|
2000-06-20 22:24:49 +00:00
|
|
|
pfd->desc.style = PANGO_STYLE_OBLIQUE;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (strstr (lcstr, "bold"))
|
2000-06-20 22:24:49 +00:00
|
|
|
pfd->desc.weight = PANGO_WEIGHT_BOLD;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (strstr (lcstr, "condensed"))
|
2000-06-20 22:24:49 +00:00
|
|
|
pfd->desc.stretch = PANGO_STRETCH_CONDENSED;
|
2000-11-13 17:40:23 +00:00
|
|
|
else if (strstr (lcstr, "expanded"))
|
2000-06-20 22:24:49 +00:00
|
|
|
pfd->desc.stretch = PANGO_STRETCH_EXPANDED;
|
|
|
|
}
|
|
|
|
|
|
|
|
pfd->ftf = ftf;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
g_ptr_array_add (descs, pfd);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2000-07-24 16:19:00 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
closedir (dirh);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_font_description_hash (gconstpointer a)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
const PangoFontDescription *fa = a;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
return g_str_hash (fa->family_name) ^ (fa->style + fa->weight + fa->stretch + fa->variant + fa->size);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_map_init (PangoFBFontMap *fontmap)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
static const char *font_dirs[] = {
|
|
|
|
"/usr/share/fonts/default/TrueType",
|
|
|
|
"/usr/share/fonts/default/Type1",
|
|
|
|
"/usr/lib/X11/fonts/TrueType",
|
|
|
|
"/usr/lib/X11/fonts/Type1",
|
2000-12-08 15:00:07 +00:00
|
|
|
GDK_DATA_PREFIX "/share/fonts",
|
2000-06-20 22:24:49 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
int i;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
fontmap->all_fonts = g_hash_table_new (pango_font_description_hash, (GEqualFunc)pango_font_description_equal);
|
|
|
|
fontmap->all_descs = g_ptr_array_new ();
|
|
|
|
for (i = 0; font_dirs[i]; i++)
|
|
|
|
list_fonts (fontmap, NULL, fontmap->all_descs, font_dirs[i]);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_map_list_fonts (PangoFontMap *fontmap,
|
|
|
|
const gchar *family,
|
|
|
|
PangoFontDescription ***descs,
|
|
|
|
int *n_descs)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
PangoFBFontMap *fbfm = (PangoFBFontMap *)fontmap;
|
|
|
|
int i, n;
|
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
*descs = g_new (PangoFontDescription *, fbfm->all_descs->len + ALIAS_TABLE_LEN);
|
|
|
|
*n_descs = fbfm->all_descs->len + ALIAS_TABLE_LEN;
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
for (i = n = 0; i < fbfm->all_descs->len; i++)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
PangoFontDescription *pfd = g_ptr_array_index (fbfm->all_descs, i);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
if (strcasecmp (family, pfd->family_name))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
(*descs)[n++] = pango_font_description_copy (pfd);
|
|
|
|
}
|
|
|
|
for (i = 0; i < ALIAS_TABLE_LEN; i++)
|
|
|
|
{
|
|
|
|
PangoFontDescription *pfd = &alias_table[i].alias;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (strcasecmp (family, pfd->family_name))
|
2000-06-20 22:24:49 +00:00
|
|
|
continue;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
(*descs)[n++] = pango_font_description_copy (pfd);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
*n_descs = n;
|
2000-11-13 17:40:23 +00:00
|
|
|
*descs = g_realloc (*descs, n * sizeof(PangoFontDescription *));
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct famlist {
|
|
|
|
gchar **families;
|
|
|
|
int last_added;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2000-11-13 17:40:23 +00:00
|
|
|
add_entry (gpointer key, gpointer value, gpointer data)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
struct famlist *fl = data;
|
2000-11-13 17:40:23 +00:00
|
|
|
fl->families[fl->last_added++] = g_strdup (key);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_map_list_families (PangoFontMap *fontmap,
|
|
|
|
gchar ***families,
|
|
|
|
int *n_families)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
PangoFBFontMap *fbfm = (PangoFBFontMap *)fontmap;
|
2000-11-13 17:40:23 +00:00
|
|
|
GHashTable *thash = g_hash_table_new (g_str_hash, g_str_equal);
|
2000-06-20 22:24:49 +00:00
|
|
|
struct famlist stickittome;
|
2000-12-01 17:14:29 +00:00
|
|
|
gchar *family_name;
|
|
|
|
int i;
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
/* Use a temporary hashtable to uniqueify the family names. */
|
|
|
|
|
2000-06-20 22:24:49 +00:00
|
|
|
for(i = 0; i < fbfm->all_descs->len; i++)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
PangoFBFontListing *fl = g_ptr_array_index (fbfm->all_descs, i);
|
2000-12-01 17:14:29 +00:00
|
|
|
family_name = fl->desc.family_name;
|
|
|
|
g_hash_table_insert (thash, family_name, family_name);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
2000-12-01 17:14:29 +00:00
|
|
|
|
|
|
|
for(i = 0; i < ALIAS_TABLE_LEN; i++)
|
|
|
|
{
|
|
|
|
family_name = alias_table[i].alias.family_name;
|
|
|
|
g_hash_table_insert (thash, family_name, family_name);
|
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
*n_families = g_hash_table_size (thash);
|
|
|
|
*families = g_new (gchar *, *n_families);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
stickittome.families = *families;
|
|
|
|
stickittome.last_added = 0;
|
2000-11-13 17:40:23 +00:00
|
|
|
g_hash_table_foreach (thash, add_entry, &stickittome);
|
|
|
|
g_hash_table_destroy (thash);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PangoFontMap *
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_map (void)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
return g_object_new (pango_fb_font_map_get_type (), NULL);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PangoMap *
|
|
|
|
pango_fb_get_shaper_map (const char *lang)
|
|
|
|
{
|
|
|
|
static guint engine_type_id = 0;
|
|
|
|
static guint render_type_id = 0;
|
|
|
|
|
|
|
|
if (engine_type_id == 0)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
engine_type_id = g_quark_try_string (PANGO_ENGINE_TYPE_SHAPE);
|
|
|
|
render_type_id = g_quark_try_string (PANGO_RENDER_TYPE_FB);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (engine_type_id == 0)
|
|
|
|
{
|
|
|
|
engine_type_id = g_quark_from_static_string (PANGO_ENGINE_TYPE_SHAPE);
|
|
|
|
render_type_id = g_quark_from_static_string (PANGO_RENDER_TYPE_FB);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pango_find_map (lang, engine_type_id, render_type_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************** Font impl *****************/
|
|
|
|
#define PANGO_FB_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FB_FONT, PangoFBFontClass))
|
|
|
|
#define PANGO_FB_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FB_FONT))
|
|
|
|
#define PANGO_FB_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FB_FONT))
|
|
|
|
#define PANGO_FB_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FB_FONT, PangoFBFontClass))
|
|
|
|
|
|
|
|
typedef struct _PangoFBFontClass PangoFBFontClass;
|
|
|
|
typedef struct _PangoFBMetricsInfo PangoFBMetricsInfo;
|
|
|
|
typedef struct _PangoFBContextInfo PangoFBContextInfo;
|
|
|
|
|
|
|
|
struct _PangoFBMetricsInfo
|
|
|
|
{
|
|
|
|
const char *lang;
|
|
|
|
PangoFontMetrics metrics;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _PangoFBContextInfo
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _PangoFBFontClass
|
|
|
|
{
|
|
|
|
PangoFontClass parent_class;
|
|
|
|
};
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
static void pango_fb_font_class_init (PangoFBFontClass *class);
|
|
|
|
static void pango_fb_font_init (PangoFBFont *font);
|
|
|
|
static void pango_fb_font_finalize (GObject *object);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
static PangoFontDescription *pango_fb_font_describe (PangoFont *font);
|
|
|
|
static PangoCoverage * pango_fb_font_get_coverage (PangoFont *font,
|
2000-11-13 17:40:23 +00:00
|
|
|
const char *lang);
|
2000-06-20 22:24:49 +00:00
|
|
|
static PangoEngineShape * pango_fb_font_find_shaper (PangoFont *font,
|
2000-11-13 17:40:23 +00:00
|
|
|
const char *lang,
|
|
|
|
guint32 ch);
|
2000-06-20 22:24:49 +00:00
|
|
|
static void pango_fb_font_get_glyph_extents (PangoFont *font,
|
2000-11-13 17:40:23 +00:00
|
|
|
PangoGlyph glyph,
|
|
|
|
PangoRectangle *ink_rect,
|
|
|
|
PangoRectangle *logical_rect);
|
2000-06-20 22:24:49 +00:00
|
|
|
static void pango_fb_font_get_metrics (PangoFont *font,
|
2000-11-13 17:40:23 +00:00
|
|
|
const gchar *lang,
|
|
|
|
PangoFontMetrics *metrics);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
pango_fb_font_get_type (void)
|
|
|
|
{
|
|
|
|
static GType object_type = 0;
|
|
|
|
|
|
|
|
if (!object_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo object_info =
|
|
|
|
{
|
|
|
|
sizeof (PangoFBFontClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) pango_fb_font_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (PangoFBFont),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) pango_fb_font_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
object_type = g_type_register_static (PANGO_TYPE_FONT,
|
|
|
|
"PangoFBFont",
|
2000-11-02 15:38:04 +00:00
|
|
|
&object_info,
|
|
|
|
0);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return object_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pango_fb_font_init (PangoFBFont *font)
|
|
|
|
{
|
|
|
|
font->desc.size = -1;
|
2000-11-13 17:40:23 +00:00
|
|
|
font->glyph_info = g_hash_table_new (NULL, NULL);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
g_free_2(gpointer key, gpointer value, gpointer data)
|
|
|
|
{
|
2000-07-24 16:19:00 +00:00
|
|
|
PangoFBGlyphInfo *pgi = value;
|
2000-11-13 17:40:23 +00:00
|
|
|
g_free (pgi->fbd.drawable_data.mem);
|
|
|
|
g_free (value);
|
2000-06-20 22:24:49 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pango_fb_font_clear_extent_cache(PangoFBFont *fbf)
|
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
g_hash_table_foreach_remove (fbf->glyph_info, g_free_2, NULL);
|
2000-07-24 16:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PangoFBGlyphInfo *
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_get_glyph_info (PangoFont *font, PangoGlyph glyph)
|
2000-07-24 16:19:00 +00:00
|
|
|
{
|
|
|
|
PangoFBGlyphInfo *pgi;
|
2000-11-13 17:40:23 +00:00
|
|
|
PangoFBFont *fbf = PANGO_FB_FONT (font);
|
2000-07-24 16:19:00 +00:00
|
|
|
FT_Bitmap *renderme;
|
|
|
|
FT_GlyphSlot g;
|
|
|
|
PangoRectangle *my_logical_rect, *my_ink_rect;
|
|
|
|
FT_Face ftf;
|
2000-12-01 17:14:29 +00:00
|
|
|
FT_Error ec;
|
Huge GtkFB patch with lots of small bugfixes and initial selections implementation.
2000-11-23 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkselection-fb.c:
Initial selection implementation.
* gtk/gtkselection.c:
if GDK_WINDOWING_FB defined, include linux-fb/gdkfb.h and look up
requestor in gtk_selection_request.
* gdk/linux-fb/gdkfb.h, gdk/linux-fb/gdkglobals-fb.c:
Added gdk_selection_property atom.
* gdk/linux-fb/gdkprivate-fb.h:
Export _gdk_selection_window_destroyed.
Removed mask_off_x/y from GdkCursorPrivateFB.
Removed hbearing, added top, left to PangoFBGlyphInfo.
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_destroy):
Call _gdk_selection_window_destroyed
(_gdk_windowing_window_init): Don't call gdk_cursor_new() before
the root window has been created.
(static_dx_hack, static_dy_hack, compare_draw_rects,
gdk_fb_window_move_resize): Remove unnecessary sort of rectangles
in region. They are already sorted. Instead just traverse them in
reverse if draw_direction < 0.
* gdk/linux-fb/gdkinput-ps2.c (send_button_event):
Double-clicks must be sent after the normal button_press.
(gdk_fb_cursor_unhide): Remove usage of mask_off_x/y. Clean up.
* gdk/linux-fb/gdkgeometry-fb.c (gdk_window_scroll):
Pass _gdk_fb_screen_gc instead of NULL.
* gdk/linux-fb/gdkmain-fb.c (_gdk_windowing_init_check):
Initialize gdk_selection_property.
(gdk_event_make): Remove unused code.
* gdk/linux-fb/gdkcursor-fb.c:
Make the pixmap for the cursor the same size as the mask. Also remove
the mask_off_x/y fields in GdkCursorPrivateFB and combine
_gdk_cursor_new_from_pixmap() and gdk_cursor_new_from_pixmap()
Now the whole cursor is visible.
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_fb_draw_drawable_3):
Fix bug where xdest+height instead of ydest+height was used
to calculate if the source and dest overlapped. This fixes the
redraw bug when the main window in testgtk was scrolled when
partially covered by a tall window.
Copy rectangles in region in order depending on draw_direction.
Also moved the draw_direction flipping of start_y and end_y into
the gc functions, as this might not be what all of them want.
(gdk_fb_draw_lines): Support dashed lines.
(gdk_fb_draw_glyphs): Clean up glyph placement. Also fix positioning
so that the text is positioned correctly (was 1 pixel high).
gdk/linux-fb/gdkgc-fb.c:
Initialize cap_style to GTK_CAP_BUTT. This fixes a problem where
all lines were drawn a pixel to short. Also checked the default of
the rest of the values, and they're the same as X now.
* gdk/linux-fb/gdkpango-fb.c (pango_fb_font_get_glyph_info):
Clean up pixel positioning of the glyphs. Just use bgy->top and
bgy->left. Also used PANGO_PIXEL where appropriate and added 0.5
to all divisions to get correct rounding behaviour.
* gdk/linux-fb/gdkrender-fb.c (gdk_fb_draw_drawable_generic,
gdk_fb_draw_drawable_memmove, gdk_fb_draw_drawable_aa_24):
Moved start_y/end_y flip into draw_drawable implementations.
Flip also x rendering when draw_direction < 0.
Remove unneccesary multiply with draw_direction.
2000-11-25 15:44:35 +00:00
|
|
|
|
2000-07-24 16:19:00 +00:00
|
|
|
ftf = fbf->ftf;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_set_size (font);
|
2000-07-24 16:19:00 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
pgi = g_hash_table_lookup (fbf->glyph_info, GUINT_TO_POINTER (glyph));
|
|
|
|
if (pgi)
|
2000-07-24 16:19:00 +00:00
|
|
|
return pgi;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
pgi = g_new0 (PangoFBGlyphInfo, 1);
|
2000-07-24 16:19:00 +00:00
|
|
|
|
2000-12-01 17:14:29 +00:00
|
|
|
ec = FT_Load_Glyph (ftf, glyph, FT_LOAD_DEFAULT);
|
2000-07-24 16:19:00 +00:00
|
|
|
|
|
|
|
g = ftf->glyph;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (g->format != ft_glyph_format_bitmap)
|
2000-12-01 17:14:29 +00:00
|
|
|
if ((ec = FT_Render_Glyph(g, ft_render_mode_normal)))
|
|
|
|
g_warning ("Glyph render failed: %d", ec);
|
|
|
|
|
|
|
|
renderme = &g->bitmap;
|
|
|
|
pgi->top = g->bitmap_top;
|
|
|
|
pgi->left = g->bitmap_left;
|
2000-07-24 16:19:00 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
pgi->fbd.drawable_data.mem = g_memdup (renderme->buffer, renderme->pitch * renderme->rows);
|
2000-07-24 16:19:00 +00:00
|
|
|
pgi->fbd.drawable_data.rowstride = renderme->pitch;
|
|
|
|
pgi->fbd.drawable_data.width = pgi->fbd.drawable_data.lim_x = renderme->width;
|
|
|
|
pgi->fbd.drawable_data.height = pgi->fbd.drawable_data.lim_y = renderme->rows;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
switch (renderme->pixel_mode)
|
2000-07-24 16:19:00 +00:00
|
|
|
{
|
|
|
|
case ft_pixel_mode_mono:
|
|
|
|
pgi->fbd.drawable_data.depth = 1;
|
|
|
|
break;
|
|
|
|
case ft_pixel_mode_grays:
|
|
|
|
pgi->fbd.drawable_data.depth = 78;
|
|
|
|
break;
|
|
|
|
default:
|
2000-11-13 17:40:23 +00:00
|
|
|
g_assert_not_reached ();
|
2000-07-24 16:19:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
my_ink_rect = &pgi->extents[0];
|
|
|
|
my_logical_rect = &pgi->extents[1];
|
|
|
|
|
2000-12-04 17:59:43 +00:00
|
|
|
my_ink_rect->x = PANGO_UNITS_26_6 (g->metrics.horiBearingX);
|
|
|
|
my_ink_rect->width = PANGO_UNITS_26_6 (g->metrics.width);
|
|
|
|
my_ink_rect->y = -PANGO_UNITS_26_6 (g->metrics.horiBearingY);
|
|
|
|
my_ink_rect->height = PANGO_UNITS_26_6 (g->metrics.height);
|
|
|
|
|
|
|
|
my_logical_rect->x = 0;
|
|
|
|
my_logical_rect->width = PANGO_UNITS_26_6 (g->metrics.horiAdvance);
|
|
|
|
my_logical_rect->y = -PANGO_UNITS_26_6 (ftf->size->metrics.ascender + 64);
|
|
|
|
my_logical_rect->height = PANGO_UNITS_26_6 (ftf->size->metrics.height + 128);
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
g_hash_table_insert (fbf->glyph_info, GUINT_TO_POINTER(glyph), pgi);
|
2000-07-24 16:19:00 +00:00
|
|
|
|
|
|
|
return pgi;
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
static void pango_fb_font_finalize (GObject *object)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
PangoFBFont *fbf = PANGO_FB_FONT (object);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
/* XXX FIXME g_hash_table_remove(ourfontmap, &fbf->desc); */
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_coverage_unref (fbf->coverage);
|
|
|
|
g_free (fbf->desc.family_name);
|
|
|
|
pango_fb_font_clear_extent_cache (fbf);
|
|
|
|
g_hash_table_destroy (fbf->glyph_info);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pango_fb_font_class_init (PangoFBFontClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
PangoFontClass *font_class = PANGO_FONT_CLASS (class);
|
|
|
|
|
|
|
|
object_class->finalize = pango_fb_font_finalize;
|
|
|
|
font_class->describe = pango_fb_font_describe;
|
|
|
|
font_class->get_coverage = pango_fb_font_get_coverage;
|
|
|
|
font_class->find_shaper = pango_fb_font_find_shaper;
|
|
|
|
font_class->get_glyph_extents = pango_fb_font_get_glyph_extents;
|
|
|
|
font_class->get_metrics = pango_fb_font_get_metrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PangoFontDescription *
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_describe (PangoFont *font)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-11-13 17:40:23 +00:00
|
|
|
return pango_font_description_copy (&PANGO_FB_FONT(font)->desc);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_coverages_foreach (gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
pango_coverage_unref (value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PangoCoverage *
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_get_coverage (PangoFont *font,
|
|
|
|
const char *lang)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
int i, n;
|
|
|
|
PangoCoverage *retval;
|
|
|
|
PangoMap *shape_map;
|
|
|
|
GHashTable *coverage_hash;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (PANGO_FB_FONT (font)->coverage)
|
|
|
|
return pango_coverage_ref (PANGO_FB_FONT (font)->coverage);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
shape_map = pango_fb_get_shaper_map (lang);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
coverage_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
retval = pango_coverage_new ();
|
|
|
|
n = MIN( 65536, PANGO_FB_FONT (font)->ftf->num_glyphs);
|
2000-06-20 22:24:49 +00:00
|
|
|
for(i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
PangoCoverageLevel font_level;
|
|
|
|
PangoMapEntry *map_entry;
|
|
|
|
|
|
|
|
map_entry = pango_map_get_entry (shape_map, i);
|
|
|
|
|
|
|
|
if (map_entry->info)
|
|
|
|
{
|
|
|
|
PangoCoverage *coverage;
|
|
|
|
coverage = g_hash_table_lookup (coverage_hash, map_entry->info->id);
|
|
|
|
if (!coverage)
|
|
|
|
{
|
|
|
|
PangoEngineShape *engine = (PangoEngineShape *)pango_map_get_engine (shape_map, i);
|
|
|
|
|
|
|
|
coverage = engine->get_coverage (font, lang);
|
|
|
|
g_hash_table_insert (coverage_hash, map_entry->info->id, coverage);
|
|
|
|
}
|
|
|
|
|
|
|
|
font_level = pango_coverage_get (coverage, i);
|
|
|
|
if (font_level == PANGO_COVERAGE_EXACT && !map_entry->is_exact)
|
|
|
|
font_level = PANGO_COVERAGE_APPROXIMATE;
|
|
|
|
|
|
|
|
if (font_level != PANGO_COVERAGE_NONE)
|
|
|
|
pango_coverage_set (retval, i, font_level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_foreach (coverage_hash, free_coverages_foreach, NULL);
|
|
|
|
g_hash_table_destroy (coverage_hash);
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
PANGO_FB_FONT (font)->coverage = pango_coverage_ref (retval);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PangoEngineShape *
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_find_shaper (PangoFont *font,
|
|
|
|
const char *lang,
|
|
|
|
guint32 ch)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
PangoMap *shape_map = NULL;
|
|
|
|
|
|
|
|
shape_map = pango_fb_get_shaper_map (lang);
|
|
|
|
return (PangoEngineShape *)pango_map_get_engine (shape_map, ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_set_size (PangoFont *font)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
PangoFBFont *fbf = (PangoFBFont *)font;
|
2000-12-04 17:59:43 +00:00
|
|
|
gint height;
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (PANGO_FB_FONT (font)->desc.size != GPOINTER_TO_UINT (fbf->ftf->generic.data))
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-12-04 17:59:43 +00:00
|
|
|
height = PANGO_FB_FONT (font)->desc.size;
|
|
|
|
fbf->ftf->generic.data = GUINT_TO_POINTER (height);
|
|
|
|
FT_Set_Char_Size (fbf->ftf, 0, PANGO_PIXELS_26_6 (height), 72, 72);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pango_fb_font_get_glyph_extents (PangoFont *font,
|
|
|
|
PangoGlyph glyph,
|
|
|
|
PangoRectangle *ink_rect,
|
|
|
|
PangoRectangle *logical_rect)
|
|
|
|
{
|
|
|
|
PangoFBFont *fbf;
|
2000-07-24 16:19:00 +00:00
|
|
|
PangoRectangle *my_extents;
|
|
|
|
PangoFBGlyphInfo *gi;
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
fbf = PANGO_FB_FONT (font);
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
gi = pango_fb_font_get_glyph_info (font, glyph);
|
2000-07-24 16:19:00 +00:00
|
|
|
my_extents = gi->extents;
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (ink_rect)
|
2000-06-20 22:24:49 +00:00
|
|
|
*ink_rect = my_extents[0];
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (logical_rect)
|
2000-06-20 22:24:49 +00:00
|
|
|
*logical_rect = my_extents[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-11-13 17:40:23 +00:00
|
|
|
pango_fb_font_get_metrics (PangoFont *font,
|
|
|
|
const gchar *lang,
|
|
|
|
PangoFontMetrics *metrics)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
|
|
|
FT_Face ftf;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
ftf = PANGO_FB_FONT (font)->ftf;
|
2000-06-20 22:24:49 +00:00
|
|
|
|
2000-11-22 12:09:08 +00:00
|
|
|
pango_fb_font_set_size (font);
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (metrics)
|
2000-06-20 22:24:49 +00:00
|
|
|
{
|
2000-12-04 17:59:43 +00:00
|
|
|
metrics->ascent = PANGO_UNITS_26_6 (ftf->size->metrics.ascender);
|
|
|
|
metrics->descent = PANGO_UNITS_26_6 (-ftf->size->metrics.descender);
|
2000-06-20 22:24:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The following array is supposed to contain enough text to tickle all necessary fonts for each
|
|
|
|
* of the languages in the following. Yes, it's pretty lame. Not all of the languages
|
|
|
|
* in the following have sufficient text to excercise all the accents for the language, and
|
|
|
|
* there are obviously many more languages to include as well.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
LangInfo lang_texts[] = {
|
|
|
|
{ "ar", "Arabic السلام عليكم" },
|
|
|
|
{ "cs", "Czech (česky) Dobrý den" },
|
|
|
|
{ "da", "Danish (Dansk) Hej, Goddag" },
|
|
|
|
{ "el", "Greek (Ελληνικά) Γειά σας" },
|
|
|
|
{ "en", "English Hello" },
|
|
|
|
{ "eo", "Esperanto Saluton" },
|
|
|
|
{ "es", "Spanish (Español) ¡Hola!" },
|
|
|
|
{ "et", "Estonian Tere, Tervist" },
|
|
|
|
{ "fi", "Finnish (Suomi) Hei" },
|
|
|
|
{ "fr", "French (Français)" },
|
|
|
|
{ "de", "German Grüß Gott" },
|
|
|
|
{ "iw", "Hebrew שלום" },
|
|
|
|
{ "il", "Italiano Ciao, Buon giorno" },
|
|
|
|
{ "ja", "Japanese (日本語) こんにちは, コンニチハ" },
|
|
|
|
{ "ko", "Korean (한글) 안녕하세요, 안녕하십니까" },
|
|
|
|
{ "mt", "Maltese Ċaw, Saħħa" },
|
|
|
|
{ "nl", "Nederlands, Vlaams Hallo, Dag" },
|
|
|
|
{ "no", "Norwegian (Norsk) Hei, God dag" },
|
|
|
|
{ "pl", "Polish Dzień dobry, Hej" },
|
|
|
|
{ "ru", "Russian (Русский)" },
|
|
|
|
{ "sk", "Slovak Dobrý deň" },
|
|
|
|
{ "sv", "Swedish (Svenska) Hej, Goddag" },
|
|
|
|
{ "tr", "Turkish (Türkçe) Merhaba" },
|
|
|
|
{ "zh", "Chinese (中文,普通话,汉语)" }
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/******** misc gdk tie-ins **********/
|
|
|
|
PangoContext *
|
|
|
|
gdk_pango_context_get (void)
|
|
|
|
{
|
|
|
|
PangoContext *retval;
|
|
|
|
static PangoFontMap *font_map = NULL;
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
if (!font_map)
|
2000-06-20 22:24:49 +00:00
|
|
|
font_map = pango_fb_font_map ();
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
retval = pango_context_new ();
|
2000-06-20 22:24:49 +00:00
|
|
|
|
|
|
|
pango_context_add_font_map (retval, font_map);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|