~ubuntu-branches/ubuntu/trusty/pango1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to pango/pangocoretext.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-11-12 13:23:16 UTC
  • mfrom: (1.6.5) (63.3.31 sid)
  • Revision ID: package-import@ubuntu.com-20121112132316-1cffyagrjxx8tvmg
Tags: 1.30.1-1
* New upstream bug fix release.
* debian/libpango1.0-0.symbols: Add new symbol from this release.
* Grab a few fixes from upstream (via Ubuntu package, thanks Robert Ancell):
  - 00git_missing_prototype.patch: Add missing method prototype.
  - 00git_memory_leak.patch: Fix memory leak (LP: #837145)
  - 00git_thai_zero_width_spaces.patch: correctly handle zero width spaces
    in Thai (LP: #986008)
* Add debian/tests: Simple compile/link/run autopkg test. Thanks to Rafał
  Cieślak! (LP: #1073637)
* debian/control.in: Set Vcs-* to experimental branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
struct _PangoCoreTextFontPrivate
31
31
{
32
32
  PangoCoreTextFace *face;
33
 
  PangoFontDescription *desc;
34
33
  gpointer context_key;
35
34
 
36
35
  CTFontRef font_ref;
 
36
  PangoCoreTextFontKey *key;
 
37
 
 
38
  PangoCoverage *coverage;
37
39
 
38
40
  PangoFontMap *fontmap;
39
41
};
44
46
  PangoCoreTextFont *ctfont = (PangoCoreTextFont *)object;
45
47
  PangoCoreTextFontPrivate *priv = ctfont->priv;
46
48
 
47
 
  pango_font_description_free (priv->desc);
48
 
 
49
49
  g_assert (priv->fontmap != NULL);
50
50
  g_object_remove_weak_pointer (G_OBJECT (priv->fontmap), (gpointer *) (gpointer) &priv->fontmap);
51
51
  priv->fontmap = NULL;
52
52
 
 
53
  if (priv->coverage)
 
54
    pango_coverage_unref (priv->coverage);
 
55
 
53
56
  G_OBJECT_CLASS (pango_core_text_font_parent_class)->finalize (object);
54
57
}
55
58
 
58
61
{
59
62
  PangoCoreTextFont *ctfont = (PangoCoreTextFont *)font;
60
63
  PangoCoreTextFontPrivate *priv = ctfont->priv;
61
 
 
62
 
  return pango_font_description_copy (priv->desc);
 
64
  CTFontDescriptorRef ctfontdesc;
 
65
 
 
66
  ctfontdesc = pango_core_text_font_key_get_ctfontdescriptor (priv->key);
 
67
 
 
68
  return _pango_core_text_font_description_from_ct_font_descriptor (ctfontdesc);
 
69
}
 
70
 
 
71
static PangoCoverage *
 
72
ct_font_descriptor_get_coverage (CTFontDescriptorRef desc)
 
73
{
 
74
  CFCharacterSetRef charset;
 
75
  CFIndex i, length;
 
76
  CFDataRef bitmap;
 
77
  const UInt8 *ptr;
 
78
  PangoCoverage *coverage;
 
79
 
 
80
  coverage = pango_coverage_new ();
 
81
 
 
82
  charset = CTFontDescriptorCopyAttribute (desc, kCTFontCharacterSetAttribute);
 
83
  if (!charset)
 
84
    /* Return an empty coverage */
 
85
    return coverage;
 
86
 
 
87
  bitmap = CFCharacterSetCreateBitmapRepresentation (kCFAllocatorDefault,
 
88
                                                     charset);
 
89
 
 
90
  /* We only handle the BMP plane */
 
91
  length = MIN (CFDataGetLength (bitmap), 8192);
 
92
  ptr = CFDataGetBytePtr (bitmap);
 
93
 
 
94
  /* FIXME: can and should this be done more efficiently? */
 
95
  for (i = 0; i < length; i++)
 
96
    {
 
97
      int j;
 
98
 
 
99
      for (j = 0; j < 8; j++)
 
100
        pango_coverage_set (coverage, i * 8 + j,
 
101
                            ((ptr[i] & (1 << j)) == (1 << j)) ?
 
102
                            PANGO_COVERAGE_EXACT : PANGO_COVERAGE_NONE);
 
103
    }
 
104
 
 
105
  CFRelease (bitmap);
 
106
  CFRelease (charset);
 
107
 
 
108
  return coverage;
63
109
}
64
110
 
65
111
static PangoCoverage *
69
115
  PangoCoreTextFont *ctfont = (PangoCoreTextFont *)font;
70
116
  PangoCoreTextFontPrivate *priv = ctfont->priv;
71
117
 
72
 
  return pango_coverage_ref (_pango_core_text_face_get_coverage (priv->face,
73
 
                                                                 language));
 
118
  if (!priv->coverage)
 
119
    {
 
120
      CTFontDescriptorRef ctfontdesc;
 
121
 
 
122
      ctfontdesc = pango_core_text_font_key_get_ctfontdescriptor (priv->key);
 
123
 
 
124
      priv->coverage = ct_font_descriptor_get_coverage (ctfontdesc);
 
125
    }
 
126
 
 
127
  return pango_coverage_ref (priv->coverage);
74
128
}
75
129
 
76
130
static PangoEngineShape *
115
169
}
116
170
 
117
171
void
118
 
_pango_core_text_font_set_font_description (PangoCoreTextFont          *font,
119
 
                                            const PangoFontDescription *desc)
120
 
{
121
 
  PangoCoreTextFontPrivate *priv = font->priv;
122
 
 
123
 
  priv->desc = pango_font_description_copy (desc);
124
 
}
125
 
 
126
 
PangoFontDescription *
127
 
_pango_core_text_font_get_font_description (PangoCoreTextFont *font)
128
 
{
129
 
  PangoCoreTextFontPrivate *priv = font->priv;
130
 
 
131
 
  return priv->desc;
132
 
}
133
 
 
134
 
void
135
172
_pango_core_text_font_set_font_map (PangoCoreTextFont    *font,
136
173
                                    PangoCoreTextFontMap *fontmap)
137
174
{
177
214
}
178
215
 
179
216
void
 
217
_pango_core_text_font_set_font_key (PangoCoreTextFont    *font,
 
218
                                    PangoCoreTextFontKey *key)
 
219
{
 
220
  PangoCoreTextFontPrivate *priv = font->priv;
 
221
 
 
222
  priv->key = key;
 
223
 
 
224
  if (priv->coverage)
 
225
    {
 
226
      pango_coverage_unref (priv->coverage);
 
227
      priv->coverage = NULL;
 
228
    }
 
229
}
 
230
 
 
231
void
180
232
_pango_core_text_font_set_ctfont (PangoCoreTextFont *font,
181
233
                                  CTFontRef          font_ref)
182
234
{