mirror of
https://github.com/gnustep/libs-back.git
synced 2025-05-31 17:31:33 +00:00
First implementation of appendBezierPathWithGlyphs:count:toBezierPath:
for cairo. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@25522 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2050099a6e
commit
901c5b758c
2 changed files with 109 additions and 36 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2007-10-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/cairo/CairoFontInfo.m
|
||||||
|
(-appendBezierPathWithGlyphs:count:toBezierPath:): First implemenation.
|
||||||
|
|
||||||
2007-10-07 Fred Kiefer <FredKiefer@gmx.de>
|
2007-10-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/gsc/GSFunction.h: Declare the -getsample:: method in
|
* Headers/gsc/GSFunction.h: Declare the -getsample:: method in
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "GNUstepBase/Unicode.h"
|
#include "GNUstepBase/Unicode.h"
|
||||||
#include <AppKit/NSAffineTransform.h>
|
#include <AppKit/NSAffineTransform.h>
|
||||||
|
#include <AppKit/NSBezierPath.h>
|
||||||
#include "cairo/CairoFontInfo.h"
|
#include "cairo/CairoFontInfo.h"
|
||||||
#include "cairo/CairoFontEnumerator.h"
|
#include "cairo/CairoFontEnumerator.h"
|
||||||
|
|
||||||
|
@ -254,23 +255,90 @@ BOOL _cairo_extents_for_NSGlyph(cairo_scaled_font_t *scaled_font, NSGlyph glyph,
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* need cairo to export its cairo_path_t first */
|
|
||||||
- (void) appendBezierPathWithGlyphs: (NSGlyph *)glyphs
|
- (void) appendBezierPathWithGlyphs: (NSGlyph *)glyphs
|
||||||
count: (int)count
|
count: (int)length
|
||||||
toBezierPath: (NSBezierPath *)path
|
toBezierPath: (NSBezierPath *)path
|
||||||
{
|
{
|
||||||
/* TODO LATER
|
cairo_format_t format = CAIRO_FORMAT_ARGB32;
|
||||||
|
cairo_surface_t *isurface;
|
||||||
cairo_t *ct;
|
cairo_t *ct;
|
||||||
|
int ix = 400;
|
||||||
|
int iy = 400;
|
||||||
|
unsigned char *cdata;
|
||||||
int i;
|
int i;
|
||||||
NSPoint start = [path currentPoint];
|
unichar ustr[length+1];
|
||||||
cairo_glyph_t *cairo_glyphs;
|
char str[3*length+1];
|
||||||
|
unsigned char *b;
|
||||||
|
unsigned int size = 3*length+1;
|
||||||
|
cairo_status_t status;
|
||||||
|
cairo_matrix_t font_matrix;
|
||||||
|
|
||||||
cairo_glyphs = malloc(sizeof(cairo_glyph_t) * count);
|
for (i = 0; i < length; i++)
|
||||||
ct = cairo_create();
|
{
|
||||||
|
ustr[i] = glyphs[i];
|
||||||
|
}
|
||||||
|
ustr[length] = 0;
|
||||||
|
|
||||||
|
b = (unsigned char *)str;
|
||||||
|
if (!GSFromUnicode(&b, &size, ustr, length,
|
||||||
|
NSUTF8StringEncoding, NULL, GSUniTerminate))
|
||||||
|
{
|
||||||
|
NSLog(@"Conversion failed for %@",
|
||||||
|
[NSString stringWithCharacters: ustr length: length]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cdata = objc_malloc(sizeof(char) * 4 * ix * iy);
|
||||||
|
isurface = cairo_image_surface_create_for_data(cdata, format, ix, iy, 4*ix);
|
||||||
|
status = cairo_surface_status(isurface);
|
||||||
|
if (status != CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
cairo_surface_destroy(isurface);
|
||||||
|
objc_free(cdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ct = cairo_create(isurface);
|
||||||
|
|
||||||
|
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
|
||||||
|
matrix[3], matrix[4], matrix[5]);
|
||||||
|
cairo_set_font_matrix(ct, &font_matrix);
|
||||||
|
|
||||||
|
cairo_text_path(ct, str);
|
||||||
|
status = cairo_status(ct);
|
||||||
|
if (status == CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
cairo_path_t *cpath;
|
||||||
|
cairo_path_data_t *data;
|
||||||
|
|
||||||
|
cpath = cairo_copy_path(ct);
|
||||||
|
|
||||||
|
for (i = 0; i < cpath->num_data; i += cpath->data[i].header.length)
|
||||||
|
{
|
||||||
|
data = &cpath->data[i];
|
||||||
|
switch (data->header.type)
|
||||||
|
{
|
||||||
|
case CAIRO_PATH_MOVE_TO:
|
||||||
|
[path moveToPoint: NSMakePoint(data[1].point.x, data[1].point.y)];
|
||||||
|
break;
|
||||||
|
case CAIRO_PATH_LINE_TO:
|
||||||
|
[path lineToPoint: NSMakePoint(data[1].point.x, data[1].point.y)];
|
||||||
|
break;
|
||||||
|
case CAIRO_PATH_CURVE_TO:
|
||||||
|
[path curveToPoint: NSMakePoint(data[1].point.x, data[1].point.y)
|
||||||
|
controlPoint1: NSMakePoint(data[2].point.x, data[2].point.y)
|
||||||
|
controlPoint2: NSMakePoint(data[3].point.x, data[3].point.y)];
|
||||||
|
break;
|
||||||
|
case CAIRO_PATH_CLOSE_PATH:
|
||||||
|
[path closePath];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cairo_path_destroy(cpath);
|
||||||
|
}
|
||||||
cairo_destroy(ct);
|
cairo_destroy(ct);
|
||||||
*/
|
cairo_surface_destroy(isurface);
|
||||||
|
objc_free(cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawGlyphs: (const NSGlyph*)glyphs
|
- (void) drawGlyphs: (const NSGlyph*)glyphs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue