~ubuntu-branches/ubuntu/lucid/pango1.0/lucid

« back to all changes in this revision

Viewing changes to pango/pango-ot-info.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-08-11 17:30:40 UTC
  • mfrom: (1.5.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090811173040-zozfegyjkb39sep2
Tags: 1.25.2-0ubuntu1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "pango-ot-private.h"
25
25
#include "pango-impl-utils.h"
26
 
#include FT_MODULE_H
 
26
#include FT_TRUETYPE_TABLES_H
27
27
 
28
28
static void pango_ot_info_class_init (GObjectClass *object_class);
29
29
static void pango_ot_info_finalize   (GObject *object);
90
90
  g_object_unref (info);
91
91
}
92
92
 
 
93
static hb_blob_t *
 
94
_get_table  (hb_tag_t tag, void *user_data)
 
95
{
 
96
  PangoOTInfo *info = (PangoOTInfo *) user_data;
 
97
  FT_Byte *buffer;
 
98
  FT_ULong  length = 0;
 
99
  FT_Error error;
 
100
 
 
101
  error = FT_Load_Sfnt_Table (info->face, tag, 0, NULL, &length);
 
102
  if (error)
 
103
    return hb_blob_create_empty ();
 
104
 
 
105
  buffer = g_malloc (length);
 
106
  if (buffer == NULL)
 
107
    return hb_blob_create_empty ();
 
108
 
 
109
  error = FT_Load_Sfnt_Table (info->face, tag, 0, buffer, &length);
 
110
  if (error)
 
111
    return hb_blob_create_empty ();
 
112
 
 
113
  return hb_blob_create ((const char *) buffer, length,
 
114
                         HB_MEMORY_MODE_WRITEABLE,
 
115
                         g_free, NULL);
 
116
}
 
117
 
 
118
 
93
119
/**
94
120
 * pango_ot_info_get:
95
121
 * @face: a <type>FT_Face</type>.
110
136
    return face->generic.data;
111
137
  else
112
138
    {
113
 
      hb_blob_t *blob;
114
 
 
115
139
      if (face->generic.finalizer)
116
140
        face->generic.finalizer (face->generic.data);
117
141
 
120
144
 
121
145
      info->face = face;
122
146
 
123
 
      /* XXX handle face->stream->base == NULL better */
124
 
      blob = hb_blob_create ((const char *) face->stream->base,
125
 
                             (unsigned int) face->stream->size,
126
 
                             HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITEABLE,
127
 
                             NULL, NULL);
128
 
      info->hb_face = hb_face_create_for_data (blob, face->face_index);
129
 
      hb_blob_destroy (blob);
 
147
      if (face->stream->base != NULL) {
 
148
        hb_blob_t *blob;
 
149
 
 
150
        blob = hb_blob_create ((const char *) face->stream->base,
 
151
                               (unsigned int) face->stream->size,
 
152
                               HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITEABLE,
 
153
                               NULL, NULL);
 
154
        info->hb_face = hb_face_create_for_data (blob, face->face_index);
 
155
        hb_blob_destroy (blob);
 
156
      } else {
 
157
        info->hb_face = hb_face_create_for_tables (_get_table, NULL, info);
 
158
      }
 
159
 
 
160
 
 
161
      hb_face_set_unicode_funcs (info->hb_face, hb_glib_get_unicode_funcs ());
130
162
 
131
163
      /* XXX this is such a waste if not SFNT */
132
164
      if (!hb_ot_layout_has_font_glyph_classes (info->hb_face))
542
574
  hb_buffer_clear_positions (buffer->buffer);
543
575
 
544
576
  /* XXX reuse hb_font */
545
 
  hb_font = hb_font_create (info->hb_face);
 
577
  hb_font = hb_font_create ();
546
578
  hb_font_set_scale (hb_font,
547
579
                     info->face->size->metrics.x_scale,
548
580
                     info->face->size->metrics.y_scale);