mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
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:
parent
6ec168f97a
commit
9781c27f45
3 changed files with 58 additions and 18 deletions
|
@ -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>
|
2008-06-14 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Version 0.14.0
|
* Version 0.14.0
|
||||||
|
|
|
@ -93,25 +93,36 @@
|
||||||
*/
|
*/
|
||||||
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
|
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
|
||||||
matrix[3], matrix[4], matrix[5]);
|
matrix[3], matrix[4], matrix[5]);
|
||||||
|
//cairo_matrix_scale(&font_matrix, 0.9, 0.9);
|
||||||
cairo_matrix_init_identity(&ctm);
|
cairo_matrix_init_identity(&ctm);
|
||||||
|
|
||||||
// FIXME: Should get default font options from somewhere
|
|
||||||
options = cairo_font_options_create();
|
|
||||||
face = [_faceInfo fontFace];
|
face = [_faceInfo fontFace];
|
||||||
if (!face)
|
if (!face)
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
_scaled = cairo_scaled_font_create(face, &font_matrix, &ctm, options);
|
// Get default font options
|
||||||
cairo_font_options_destroy(options);
|
options = cairo_font_options_create();
|
||||||
if (!_scaled)
|
if (cairo_font_options_status(options) != CAIRO_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
return NO;
|
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);
|
cairo_scaled_font_extents(_scaled, &font_extents);
|
||||||
|
if (cairo_scaled_font_status(_scaled) != CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
ascender = font_extents.ascent;
|
ascender = font_extents.ascent;
|
||||||
// The FreeType documentation claims this value is already negative, but it isn't.
|
|
||||||
descender = -font_extents.descent;
|
descender = -font_extents.descent;
|
||||||
xHeight = ascender * 0.6;
|
xHeight = ascender * 0.6;
|
||||||
lineHeight = font_extents.height;
|
lineHeight = font_extents.height;
|
||||||
|
@ -119,6 +130,16 @@
|
||||||
font_extents.max_y_advance);
|
font_extents.max_y_advance);
|
||||||
fontBBox = NSMakeRect(0, descender,
|
fontBBox = NSMakeRect(0, descender,
|
||||||
maximumAdvancement.width, ascender - 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;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,20 +205,32 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f)
|
||||||
{
|
{
|
||||||
int i;
|
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];
|
for (i = 0; i < clip_rects->num_rectangles; i++)
|
||||||
NSSize size = [_surface size];
|
{
|
||||||
|
cairo_rectangle_t rect = clip_rects->rectangles[i];
|
||||||
|
|
||||||
cairo_rectangle(copy->_ct, rect.x,
|
cairo_rectangle(copy->_ct, rect.x, rect.y,
|
||||||
#if CAIRO_VERSION > CAIRO_VERSION_ENCODE(1, 6, 0)
|
rect.width, rect.height);
|
||||||
rect.y,
|
cairo_clip(copy->_ct);
|
||||||
#else
|
}
|
||||||
// This strange computation is due to the device offset.
|
}
|
||||||
rect.y + 2*(offset.y - size.height),
|
else
|
||||||
#endif
|
{
|
||||||
rect.width, rect.height);
|
for (i = 0; i < clip_rects->num_rectangles; i++)
|
||||||
cairo_clip(copy->_ct);
|
{
|
||||||
|
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);
|
cairo_rectangle_list_destroy(clip_rects);
|
||||||
|
|
Loading…
Reference in a new issue