Small improvements for cairo backend.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@26711 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2008-06-25 22:20:18 +00:00
parent 6ec168f97a
commit 9781c27f45
3 changed files with 58 additions and 18 deletions

View file

@ -1,3 +1,10 @@
2008-06-26 Fred Kiefer <FredKiefer@gmx.de>
* Source/cairo/CairoGState.m (-copyWithZone:): Use a runtime
version check and adjust from > to >= 1.6.0.
* Source/cairo/CairoFontInfo.m (-setupAttributes): Slightly better
error checks.
2008-06-14 Adam Fedor <fedor@gnu.org>
* Version 0.14.0

View file

@ -93,25 +93,36 @@
*/
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
matrix[3], matrix[4], matrix[5]);
//cairo_matrix_scale(&font_matrix, 0.9, 0.9);
cairo_matrix_init_identity(&ctm);
// FIXME: Should get default font options from somewhere
options = cairo_font_options_create();
face = [_faceInfo fontFace];
if (!face)
{
return NO;
}
_scaled = cairo_scaled_font_create(face, &font_matrix, &ctm, options);
cairo_font_options_destroy(options);
if (!_scaled)
// Get default font options
options = cairo_font_options_create();
if (cairo_font_options_status(options) != CAIRO_STATUS_SUCCESS)
{
return NO;
}
_scaled = cairo_scaled_font_create(face, &font_matrix, &ctm, options);
cairo_font_options_destroy(options);
if (cairo_scaled_font_status(_scaled) != CAIRO_STATUS_SUCCESS)
{
return NO;
}
cairo_scaled_font_extents(_scaled, &font_extents);
if (cairo_scaled_font_status(_scaled) != CAIRO_STATUS_SUCCESS)
{
return NO;
}
ascender = font_extents.ascent;
// The FreeType documentation claims this value is already negative, but it isn't.
descender = -font_extents.descent;
xHeight = ascender * 0.6;
lineHeight = font_extents.height;
@ -119,6 +130,16 @@
font_extents.max_y_advance);
fontBBox = NSMakeRect(0, descender,
maximumAdvancement.width, ascender - descender);
/*
NSLog(@"Font matrix (%g, %g, %g, %g, %g, %g) type %d",
matrix[0], matrix[1], matrix[2],
matrix[3], matrix[4], matrix[5], cairo_scaled_font_get_type(_scaled));
NSLog(@"(%@) h=%g a=%g d=%g max=(%g %g) (%g %g)+(%g %g)\n", fontName,
xHeight, ascender, descender,
maximumAdvancement.width, maximumAdvancement.height,
fontBBox.origin.x, fontBBox.origin.y,
fontBBox.size.width, fontBBox.size.height);
*/
return YES;
}

View file

@ -205,20 +205,32 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
{
int i;
for (i = 0; i < clip_rects->num_rectangles; i++)
if (cairo_version() >= CAIRO_VERSION_ENCODE(1, 6, 0))
{
cairo_rectangle_t rect = clip_rects->rectangles[i];
NSSize size = [_surface size];
for (i = 0; i < clip_rects->num_rectangles; i++)
{
cairo_rectangle_t rect = clip_rects->rectangles[i];
cairo_rectangle(copy->_ct, rect.x,
#if CAIRO_VERSION > CAIRO_VERSION_ENCODE(1, 6, 0)
rect.y,
#else
// This strange computation is due to the device offset.
rect.y + 2*(offset.y - size.height),
#endif
rect.width, rect.height);
cairo_clip(copy->_ct);
cairo_rectangle(copy->_ct, rect.x, rect.y,
rect.width, rect.height);
cairo_clip(copy->_ct);
}
}
else
{
for (i = 0; i < clip_rects->num_rectangles; i++)
{
cairo_rectangle_t rect = clip_rects->rectangles[i];
NSSize size = [_surface size];
cairo_rectangle(copy->_ct, rect.x,
/* This strange computation is due
to the device offset missing for
clip rects in cairo < 1.6.0. */
rect.y + 2*(offset.y - size.height),
rect.width, rect.height);
cairo_clip(copy->_ct);
}
}
}
cairo_rectangle_list_destroy(clip_rects);