1 |
/* gdkglyphvector.c |
/* gdkglyphvector.c |
2 |
Copyright (C) 2003 Free Software Foundation, Inc. |
Copyright (C) 2003, 2004 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
273 |
|
|
274 |
pango_context_set_font_description (vec->ctx, vec->desc); |
pango_context_set_font_description (vec->ctx, vec->desc); |
275 |
|
|
|
items = pango_itemize (vec->ctx, str, 0, len, attrs, NULL); |
|
|
g_assert (items != NULL); |
|
|
|
|
|
/* |
|
|
step 2: for each item: |
|
|
- shape the item into a glyphstring |
|
|
- store the (item, glyphstring) pair in the vec->glyphitems list |
|
|
*/ |
|
|
|
|
276 |
if (vec->glyphitems != NULL) |
if (vec->glyphitems != NULL) |
277 |
|
items = pango_itemize (vec->ctx, str, 0, len, attrs, NULL); |
278 |
|
if (items != NULL) |
279 |
{ |
{ |
280 |
free_glyphitems (vec->glyphitems); |
|
281 |
vec->glyphitems = NULL; |
/* |
282 |
} |
step 2: for each item: |
283 |
|
- shape the item into a glyphstring |
284 |
for (item = g_list_first (items); item != NULL; item = g_list_next (item)) |
- store the (item, glyphstring) pair in the vec->glyphitems list |
285 |
{ |
*/ |
286 |
g_assert (item->data != NULL); |
|
287 |
|
if (vec->glyphitems != NULL) |
288 |
gi = NULL; |
{ |
289 |
gi = g_malloc0 (sizeof(PangoGlyphItem)); |
free_glyphitems (vec->glyphitems); |
290 |
g_assert (gi != NULL); |
vec->glyphitems = NULL; |
291 |
|
} |
292 |
gi->item = (PangoItem *)item->data; |
|
293 |
gi->glyphs = pango_glyph_string_new (); |
for (item = g_list_first (items); |
294 |
g_assert (gi->glyphs != NULL); |
item != NULL; |
295 |
|
item = g_list_next (item)) |
296 |
pango_shape (str + gi->item->offset, |
{ |
297 |
gi->item->length, |
g_assert (item->data != NULL); |
298 |
&(gi->item->analysis), |
|
299 |
gi->glyphs); |
gi = NULL; |
300 |
|
gi = g_malloc0 (sizeof(PangoGlyphItem)); |
301 |
vec->glyphitems = g_list_append (vec->glyphitems, gi); |
g_assert (gi != NULL); |
302 |
|
|
303 |
|
gi->item = (PangoItem *)item->data; |
304 |
|
gi->glyphs = pango_glyph_string_new (); |
305 |
|
g_assert (gi->glyphs != NULL); |
306 |
|
|
307 |
|
if (gi->glyphs->num_glyphs > 0) |
308 |
|
{ |
309 |
|
pango_shape (str + gi->item->offset, |
310 |
|
gi->item->length, |
311 |
|
&(gi->item->analysis), |
312 |
|
gi->glyphs); |
313 |
|
|
314 |
|
vec->glyphitems = g_list_append (vec->glyphitems, gi); |
315 |
|
} |
316 |
|
} |
317 |
|
|
318 |
|
/* |
319 |
|
ownership of each item has been transferred to glyphitems, |
320 |
|
but the list should be freed. |
321 |
|
*/ |
322 |
|
|
323 |
|
g_list_free (items); |
324 |
} |
} |
325 |
|
|
|
/* |
|
|
ownership of each item has been transferred to glyphitems, |
|
|
but the list should be freed. |
|
|
*/ |
|
|
|
|
|
g_list_free (items); |
|
326 |
pango_attr_list_unref (attrs); |
pango_attr_list_unref (attrs); |
327 |
|
|
328 |
(*env)->ReleaseStringUTFChars (env, chars, str); |
(*env)->ReleaseStringUTFChars (env, chars, str); |
329 |
gdk_threads_leave (); |
gdk_threads_leave (); |
330 |
} |
} |
445 |
g_assert (self != NULL); |
g_assert (self != NULL); |
446 |
vec = (struct glyphvec *)NSA_GET_GV_PTR (env, self); |
vec = (struct glyphvec *)NSA_GET_GV_PTR (env, self); |
447 |
g_assert (vec != NULL); |
g_assert (vec != NULL); |
448 |
g_assert (vec->glyphitems != NULL); |
if (vec->glyphitems != NULL) |
|
|
|
|
pointsize = pango_font_description_get_size (vec->desc); |
|
|
pointsize /= (double) PANGO_SCALE; |
|
|
|
|
|
for (i = g_list_first (vec->glyphitems); i != NULL; i = g_list_next (i)) |
|
449 |
{ |
{ |
450 |
g_assert (i->data != NULL); |
pointsize = pango_font_description_get_size (vec->desc); |
451 |
gi = (PangoGlyphItem *)i->data; |
pointsize /= (double) PANGO_SCALE; |
|
g_assert (gi->glyphs != NULL); |
|
|
|
|
|
face = pango_ft2_font_get_face (gi->item->analysis.font); |
|
|
assume_pointsize_and_identity_transform (pointsize, face); |
|
452 |
|
|
453 |
for (j = 0; j < gi->glyphs->num_glyphs; ++j) |
for (i = g_list_first (vec->glyphitems); i != NULL; i = g_list_next (i)) |
454 |
{ |
{ |
455 |
FT_Load_Glyph (face, gi->glyphs->glyphs[j].glyph, FT_LOAD_DEFAULT); |
g_assert (i->data != NULL); |
456 |
/* FIXME: this needs to change for vertical layouts */ |
gi = (PangoGlyphItem *)i->data; |
457 |
tmp.x = x + DOUBLE_FROM_26_6 (face->glyph->metrics.horiBearingX); |
g_assert (gi->glyphs != NULL); |
458 |
tmp.y = y + DOUBLE_FROM_26_6 (face->glyph->metrics.horiBearingY); |
|
459 |
tmp.width = DOUBLE_FROM_26_6 (face->glyph->metrics.width); |
face = pango_ft2_font_get_face (gi->item->analysis.font); |
460 |
tmp.height = DOUBLE_FROM_26_6 (face->glyph->metrics.height); |
assume_pointsize_and_identity_transform (pointsize, face); |
461 |
union_rects (&rect, &tmp); |
|
462 |
x += DOUBLE_FROM_26_6 (face->glyph->advance.x); |
for (j = 0; j < gi->glyphs->num_glyphs; ++j) |
463 |
y += DOUBLE_FROM_26_6 (face->glyph->advance.y); |
{ |
464 |
} |
FT_Load_Glyph (face, |
465 |
} |
gi->glyphs->glyphs[j].glyph, |
466 |
|
FT_LOAD_DEFAULT); |
467 |
|
/* FIXME: this needs to change for vertical layouts */ |
468 |
|
tmp.x = x + DOUBLE_FROM_26_6 (face->glyph->metrics.horiBearingX); |
469 |
|
tmp.y = y + DOUBLE_FROM_26_6 (face->glyph->metrics.horiBearingY); |
470 |
|
tmp.width = DOUBLE_FROM_26_6 (face->glyph->metrics.width); |
471 |
|
tmp.height = DOUBLE_FROM_26_6 (face->glyph->metrics.height); |
472 |
|
union_rects (&rect, &tmp); |
473 |
|
x += DOUBLE_FROM_26_6 (face->glyph->advance.x); |
474 |
|
y += DOUBLE_FROM_26_6 (face->glyph->advance.y); |
475 |
|
} |
476 |
|
} |
477 |
|
} |
478 |
|
|
479 |
ret = rect_to_array (env, &rect); |
ret = rect_to_array (env, &rect); |
480 |
gdk_threads_leave (); |
gdk_threads_leave (); |