mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 11:51:27 +00:00
Use accessor for affine transform internals which should otherwise be private.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24131 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e708ccb6e6
commit
4bd0a9f1b5
9 changed files with 816 additions and 731 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2006-11-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/winlib/WIN32GState.m:
|
||||
* Source/art/path.m:
|
||||
* Source/art/ftfont.m:
|
||||
* Source/art/ftfont-old.m:
|
||||
* Source/art/shfill.m:
|
||||
* Source/art/image.m:
|
||||
* Source/xlib/XGGState.m:
|
||||
* Source/x11/XGServerWindow.m:
|
||||
Use accessor method (-transformStruct) to get at affine transform
|
||||
internals. Make art code closer to coding standars in an attempt
|
||||
to improve readability.
|
||||
|
||||
2006-11-15 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
Notice: you should now use 'make DESTDIR=/tmp/xxx install' if you
|
||||
|
|
|
@ -907,6 +907,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
FTC_CMapDescRec cmap;
|
||||
unsigned int glyph;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
int use_sbit;
|
||||
|
||||
|
@ -934,6 +935,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform stransformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@\n",
|
||||
self,
|
||||
|
@ -946,10 +948,10 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* If we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache for screen fonts. */
|
||||
|
@ -1123,17 +1125,17 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (delta_flags & 0x1)
|
||||
x += delta_data[d++];
|
||||
if (delta_flags & 0x2)
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
y += (ts.m22 < 0) ?
|
||||
delta_data[d++] : -delta_data[d++];
|
||||
if (delta_flags & 0x4)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
if ((delta_flags & 0x8) && (uch == wch))
|
||||
{
|
||||
x += delta_data[2];
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
y += (ts.m22 < 0) ?
|
||||
delta_data[3] : -delta_data[3];
|
||||
}
|
||||
}
|
||||
|
@ -1142,7 +1144,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (uch == wch)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
}
|
||||
else
|
||||
|
@ -1269,17 +1271,17 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (delta_flags & 0x1)
|
||||
x += delta_data[d++];
|
||||
if (delta_flags & 0x2)
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
y += (ts.m22 < 0) ?
|
||||
delta_data[d++] : -delta_data[d++];
|
||||
if (delta_flags & 0x4)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
if ((delta_flags & 0x8) && (uch == wch))
|
||||
{
|
||||
x += delta_data[2];
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
y += (ts.m22 < 0) ?
|
||||
delta_data[3] : -delta_data[3];
|
||||
}
|
||||
}
|
||||
|
@ -1288,7 +1290,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (uch == wch)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
}
|
||||
else
|
||||
|
@ -1471,6 +1473,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
FT_Vector ftdelta;
|
||||
|
||||
FT_Error error;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
|
||||
if (!alpha)
|
||||
|
@ -1484,6 +1487,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform stransformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@\n",
|
||||
self,
|
||||
|
@ -1496,10 +1500,10 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* If we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache for screen fonts. */
|
||||
|
@ -1845,6 +1849,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
FT_Vector ftdelta;
|
||||
|
||||
FT_Error error;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
|
||||
if (!alpha)
|
||||
|
@ -1858,6 +1863,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform stransformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@\n",
|
||||
self,
|
||||
|
@ -1870,10 +1876,10 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* If we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache for screen fonts. */
|
||||
|
@ -2903,6 +2909,7 @@ static int filters[3][7]=
|
|||
|
||||
FT_Matrix ftmatrix;
|
||||
FT_Vector ftdelta;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
BOOL subpixel = NO;
|
||||
|
||||
|
@ -2917,6 +2924,7 @@ static int filters[3][7]=
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform stransformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)]\n",
|
||||
self,
|
||||
|
@ -2928,10 +2936,10 @@ static int filters[3][7]=
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* if we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache */
|
||||
|
|
|
@ -411,7 +411,7 @@ static void add_face(NSString *family, int family_weight,
|
|||
{
|
||||
fi->sizes[i].pixel_size = [size intValue];
|
||||
fi->sizes[i].files = fix_path(path,[sizes objectForKey: size]);
|
||||
NSDebugLLog(@"ftfont",@"%@ size %i files |%@|\n",
|
||||
NSDebugLLog(@"ftfont",@"%@ size %i files |%@|",
|
||||
fontName,fi->sizes[i].pixel_size,fi->sizes[i].files);
|
||||
i++;
|
||||
}
|
||||
|
@ -671,16 +671,14 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
|
||||
@implementation FTFontInfo
|
||||
- initWithFontName: (NSString *)name
|
||||
matrix: (const float *)fmatrix
|
||||
screenFont: (BOOL)p_screenFont
|
||||
- (id) initWithFontName: (NSString *)name
|
||||
matrix: (const float *)fmatrix
|
||||
screenFont: (BOOL)p_screenFont
|
||||
{
|
||||
FT_Size size;
|
||||
NSArray *rfi;
|
||||
FTFaceInfo *font_entry;
|
||||
|
||||
FT_Error error;
|
||||
|
||||
FT_Size size;
|
||||
NSArray *rfi;
|
||||
FTFaceInfo *font_entry;
|
||||
FT_Error error;
|
||||
|
||||
if (subpixel_text)
|
||||
{
|
||||
|
@ -692,11 +690,12 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
screenFont = p_screenFont;
|
||||
|
||||
NSDebugLLog(@"ftfont", @"[%@ -initWithFontName: %@ matrix: (%g %g %g %g %g %g)] %i\n",
|
||||
self, name,
|
||||
fmatrix[0], fmatrix[1], fmatrix[2],
|
||||
fmatrix[3], fmatrix[4], fmatrix[5],
|
||||
p_screenFont);
|
||||
NSDebugLLog(@"ftfont",
|
||||
@"[%@ -initWithFontName: %@ matrix: (%g %g %g %g %g %g)] %i",
|
||||
self, name,
|
||||
fmatrix[0], fmatrix[1], fmatrix[2],
|
||||
fmatrix[3], fmatrix[4], fmatrix[5],
|
||||
p_screenFont);
|
||||
|
||||
font_entry = [fcfg_all_fonts objectForKey: name];
|
||||
if (!font_entry)
|
||||
|
@ -733,10 +732,10 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
pix_height = fabs(matrix[3]);
|
||||
|
||||
rfi = font_entry->files;
|
||||
if (screenFont && font_entry->num_sizes &&
|
||||
pix_width == pix_height)
|
||||
if (screenFont && font_entry->num_sizes && pix_width == pix_height)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < font_entry->num_sizes; i++)
|
||||
{
|
||||
if (font_entry->sizes[i].pixel_size == pix_width)
|
||||
|
@ -761,7 +760,8 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
if ((error = FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
|
||||
{
|
||||
NSLog(@"FTC_Manager_LookupSize() failed for '%@', error %08x!\n", name, error);
|
||||
NSLog(@"FTC_Manager_LookupSize() failed for '%@', error %08x!",
|
||||
name, error);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -772,9 +772,11 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
descender = fabs(((int)size->metrics.descender) / 64.0);
|
||||
lineHeight = (int)size->metrics.height / 64.0;
|
||||
xHeight = ascender * 0.5; /* TODO */
|
||||
maximumAdvancement = NSMakeSize((size->metrics.max_advance / 64.0), ascender + descender);
|
||||
maximumAdvancement
|
||||
= NSMakeSize((size->metrics.max_advance / 64.0), ascender + descender);
|
||||
|
||||
fontBBox = NSMakeRect(0, descender, maximumAdvancement.width, ascender + descender);
|
||||
fontBBox
|
||||
= NSMakeRect(0, descender, maximumAdvancement.width, ascender + descender);
|
||||
descender = -descender;
|
||||
|
||||
/* printf("(%@) h=%g a=%g d=%g max=(%g %g) (%g %g)+(%g %g)\n",name,
|
||||
|
@ -789,6 +791,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
FT_CharMap cmap;
|
||||
FT_Encoding e;
|
||||
unicodeCmap = 0;
|
||||
|
||||
for (i = 0; i < face->num_charmaps; i++)
|
||||
{
|
||||
cmap = face->charmaps[i];
|
||||
|
@ -801,11 +804,16 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
}
|
||||
}
|
||||
{
|
||||
ligature_ff = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb00);
|
||||
ligature_fi = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb01);
|
||||
ligature_fl = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb02);
|
||||
ligature_ffi = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb03);
|
||||
ligature_ffl = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb04);
|
||||
ligature_ff
|
||||
= FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb00);
|
||||
ligature_fi
|
||||
= FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb01);
|
||||
ligature_fl
|
||||
= FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb02);
|
||||
ligature_ffi
|
||||
= FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb03);
|
||||
ligature_ffl
|
||||
= FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb04);
|
||||
/* printf("ligatures %04x %04x %04x %04x %04x | %02x %02x %02x for |%@|\n",
|
||||
ligature_ff,ligature_fi,ligature_fl,ligature_ffi,ligature_ffl,
|
||||
FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 'f'),
|
||||
|
@ -817,9 +825,11 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (screenFont)
|
||||
{
|
||||
int flags;
|
||||
|
||||
if (pix_width == pix_height && pix_width < 16 && pix_height >= 8)
|
||||
{
|
||||
int rh = face_info->render_hints_hack;
|
||||
|
||||
if (rh & 0x10000)
|
||||
{
|
||||
flags = FT_LOAD_TARGET_NORMAL;
|
||||
|
@ -860,7 +870,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
- (void) set
|
||||
{
|
||||
NSLog(@"ignore -set method of font '%@'\n", fontName);
|
||||
NSLog(@"ignore -set method of font '%@'", fontName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -887,15 +897,18 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
undefined if 0x8 is combined with 0x2 or 0x1
|
||||
*/
|
||||
- (void) drawString: (const char *)s
|
||||
at: (int)x : (int)y
|
||||
to: (int)x0 : (int)y0 : (int)x1 : (int)y1
|
||||
: (unsigned char *)buf : (int)bpl
|
||||
: (unsigned char *)abuf : (int)abpl
|
||||
color:(unsigned char)r : (unsigned char)g : (unsigned char)b : (unsigned char)alpha
|
||||
transform: (NSAffineTransform *)transform
|
||||
deltas: (const float *)delta_data : (int)delta_size : (int)delta_flags
|
||||
widthChar: (int) wch
|
||||
drawinfo: (draw_info_t *)di
|
||||
at: (int)x : (int)y
|
||||
to: (int)x0 : (int)y0 : (int)x1 : (int)y1
|
||||
: (unsigned char *)buf : (int)bpl
|
||||
: (unsigned char *)abuf : (int)abpl
|
||||
color: (unsigned char)r
|
||||
: (unsigned char)g
|
||||
: (unsigned char)b
|
||||
: (unsigned char)alpha
|
||||
transform: (NSAffineTransform *)transform
|
||||
deltas: (const float *)delta_data : (int)delta_size : (int)delta_flags
|
||||
widthChar: (int) wch
|
||||
drawinfo: (draw_info_t *)di
|
||||
{
|
||||
const unsigned char *c;
|
||||
unsigned char ch;
|
||||
|
@ -912,6 +925,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
FT_Vector ftdelta;
|
||||
|
||||
FT_Error error;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
|
||||
if (!alpha)
|
||||
|
@ -925,8 +939,9 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform transformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@\n",
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@",
|
||||
self,
|
||||
matrix[0], matrix[1], matrix[2],
|
||||
matrix[3], matrix[4], matrix[5],
|
||||
|
@ -936,17 +951,17 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* If we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache for screen fonts. */
|
||||
if (screenFont &&
|
||||
fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01 &&
|
||||
fabs(xy) < 0.01 && fabs(yx) < 0.01 &&
|
||||
xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
if (screenFont
|
||||
&& fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01
|
||||
&& fabs(xy) < 0.01 && fabs(yx) < 0.01
|
||||
&& xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
{
|
||||
use_sbit = 1;
|
||||
}
|
||||
|
@ -983,7 +998,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
}
|
||||
|
||||
|
||||
/* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p\n",
|
||||
/* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p",
|
||||
s, x, y, x0, y0, x1, y1, buf);*/
|
||||
d=0;
|
||||
for (c = (const unsigned char *)s; *c; c++)
|
||||
|
@ -1034,21 +1049,26 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
else if (ch < 0xfe)
|
||||
{
|
||||
uch = (ch & 0x01) << 30;
|
||||
ADD_UTF_BYTE(24, ADD_UTF_BYTE(18, ADD_UTF_BYTE(12, ADD_UTF_BYTE(6, ADD_UTF_BYTE(0,)))))
|
||||
ADD_UTF_BYTE(24, ADD_UTF_BYTE(18, ADD_UTF_BYTE(12,
|
||||
ADD_UTF_BYTE(6, ADD_UTF_BYTE(0,)))))
|
||||
}
|
||||
else
|
||||
uch = 0xfffd;
|
||||
{
|
||||
uch = 0xfffd;
|
||||
}
|
||||
#undef ADD_UTF_BYTE
|
||||
|
||||
glyph = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, uch);
|
||||
|
||||
if (use_sbit)
|
||||
{
|
||||
if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
|
||||
if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType,
|
||||
glyph, &sbit, NULL)))
|
||||
{
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
|
||||
error, glyph, imageType.face_id, imageType.width, imageType.height,
|
||||
imageType.flags);
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x "
|
||||
@"(%08x, %08x, %ix%i, %08x)",
|
||||
error, glyph, imageType.face_id, imageType.width,
|
||||
imageType.height, imageType.flags);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1056,25 +1076,24 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
{
|
||||
if (!delta_flags)
|
||||
{
|
||||
x += sbit->xadvance;
|
||||
x += sbit->xadvance;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (delta_flags & 0x1)
|
||||
x += delta_data[d++];
|
||||
if (delta_flags & 0x2)
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
delta_data[d++] : -delta_data[d++];
|
||||
y += (ts.m22 < 0) ?
|
||||
delta_data[d++] : -delta_data[d++];
|
||||
if (delta_flags & 0x4)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
if ((delta_flags & 0x8) && (uch == wch))
|
||||
{
|
||||
x += delta_data[2];
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
delta_data[3] : -delta_data[3];
|
||||
y += (ts.m22 < 0) ? delta_data[3] : -delta_data[3];
|
||||
}
|
||||
}
|
||||
else if (delta_flags & 0x8)
|
||||
|
@ -1082,7 +1101,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (uch == wch)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
}
|
||||
else
|
||||
|
@ -1209,18 +1228,16 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (delta_flags & 0x1)
|
||||
x += delta_data[d++];
|
||||
if (delta_flags & 0x2)
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
delta_data[d++] : -delta_data[d++];
|
||||
y += (ts.m22 < 0) ? delta_data[d++] : -delta_data[d++];
|
||||
if (delta_flags & 0x4)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
if ((delta_flags & 0x8) && (uch == wch))
|
||||
{
|
||||
x += delta_data[2];
|
||||
y += (transform->matrix.m22 < 0) ?
|
||||
delta_data[3] : -delta_data[3];
|
||||
y += (ts.m22 < 0) ? delta_data[3] : -delta_data[3];
|
||||
}
|
||||
}
|
||||
else if (delta_flags & 0x8)
|
||||
|
@ -1228,7 +1245,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if (uch == wch)
|
||||
{
|
||||
x += sbit->xadvance + delta_data[0];
|
||||
y += /*sbit->yadvance +*/ (transform->matrix.m22 < 0) ?
|
||||
y += /*sbit->yadvance +*/ (ts.m22 < 0) ?
|
||||
delta_data[1] : -delta_data[1];
|
||||
}
|
||||
else
|
||||
|
@ -1248,7 +1265,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
if ((error=FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
|
||||
{
|
||||
NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);
|
||||
NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
face = size->face;
|
||||
|
@ -1256,24 +1273,24 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
/* TODO: for screen fonts we should probably still hint */
|
||||
if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))
|
||||
{
|
||||
NSLog(@"FT_Load_Glyph() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Load_Glyph() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error=FT_Get_Glyph(face->glyph, &gl)))
|
||||
{
|
||||
NSLog(@"FT_Get_Glyph() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Get_Glyph() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error=FT_Glyph_Transform(gl, &ftmatrix, &ftdelta)))
|
||||
{
|
||||
NSLog(@"FT_Glyph_Transform() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Glyph_Transform() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
if ((error=FT_Glyph_To_Bitmap(&gl, ft_render_mode_normal, 0, 1)))
|
||||
{
|
||||
NSLog(@"FT_Glyph_To_Bitmap() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Glyph_To_Bitmap() failed with error %08x", error);
|
||||
FT_Done_Glyph(gl);
|
||||
continue;
|
||||
}
|
||||
|
@ -1405,6 +1422,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
FT_Vector ftdelta;
|
||||
|
||||
FT_Error error;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
|
||||
if (!alpha)
|
||||
|
@ -1418,8 +1436,9 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform transformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@\n",
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@",
|
||||
self,
|
||||
matrix[0], matrix[1], matrix[2],
|
||||
matrix[3], matrix[4], matrix[5],
|
||||
|
@ -1429,17 +1448,17 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* If we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache for screen fonts. */
|
||||
if (screenFont &&
|
||||
fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01 &&
|
||||
fabs(xy) < 0.01 && fabs(yx) < 0.01 &&
|
||||
xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
if (screenFont
|
||||
&& fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01
|
||||
&& fabs(xy) < 0.01 && fabs(yx) < 0.01
|
||||
&& xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
{
|
||||
use_sbit = 1;
|
||||
}
|
||||
|
@ -1464,7 +1483,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
}
|
||||
}
|
||||
|
||||
/* NSLog(@"drawGlyphs: '%p' at: %i:%i to: %i:%i:%i:%i:%p\n",
|
||||
/* NSLog(@"drawGlyphs: '%p' at: %i:%i to: %i:%i:%i:%i:%p",
|
||||
glyphs, x, y, x0, y0, x1, y1, buf);*/
|
||||
|
||||
for (; length; length--, glyphs++)
|
||||
|
@ -1473,12 +1492,14 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
if (use_sbit)
|
||||
{
|
||||
if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
|
||||
if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType,
|
||||
glyph, &sbit, NULL)))
|
||||
{
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
|
||||
error, glyph, imageType.face_id, imageType.width, imageType.height,
|
||||
imageType.flags
|
||||
);
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x "
|
||||
@"(%08x, %08x, %ix%i, %08x)",
|
||||
error, glyph, imageType.face_id,
|
||||
imageType.width, imageType.height,
|
||||
imageType.flags);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1604,33 +1625,34 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
if ((error=FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
|
||||
{
|
||||
NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);
|
||||
NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x",error);
|
||||
continue;
|
||||
}
|
||||
face = size->face;
|
||||
|
||||
/* TODO: for screen fonts ...see above... rotations of 90, 180, 270, and integer
|
||||
scales hinting might still be a good idea. */
|
||||
if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))
|
||||
/* TODO: for screen fonts ...see above... rotations of 90, 180, 270,
|
||||
* and integer scales hinting might still be a good idea. */
|
||||
if ((error = FT_Load_Glyph(face, glyph,
|
||||
FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))
|
||||
{
|
||||
NSLog(@"FT_Load_Glyph() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Load_Glyph() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error=FT_Get_Glyph(face->glyph, &gl)))
|
||||
{
|
||||
NSLog(@"FT_Get_Glyph() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Get_Glyph() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error=FT_Glyph_Transform(gl, &ftmatrix, &ftdelta)))
|
||||
{
|
||||
NSLog(@"FT_Glyph_Transform() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Glyph_Transform() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
if ((error=FT_Glyph_To_Bitmap(&gl, ft_render_mode_normal, 0, 1)))
|
||||
{
|
||||
NSLog(@"FT_Glyph_To_Bitmap() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Glyph_To_Bitmap() failed with error %08x", error);
|
||||
FT_Done_Glyph(gl);
|
||||
continue;
|
||||
}
|
||||
|
@ -1721,6 +1743,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
FT_Vector ftdelta;
|
||||
|
||||
FT_Error error;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
|
||||
if (!alpha)
|
||||
|
@ -1734,8 +1757,9 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform transformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@\n",
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)] transform=%@",
|
||||
self,
|
||||
matrix[0], matrix[1], matrix[2],
|
||||
matrix[3], matrix[4], matrix[5],
|
||||
|
@ -1745,17 +1769,17 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* If we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache for screen fonts. */
|
||||
if (screenFont &&
|
||||
fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01 &&
|
||||
fabs(xy) < 0.01 && fabs(yx) < 0.01 &&
|
||||
xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
if (screenFont
|
||||
&& fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01
|
||||
&& fabs(xy) < 0.01 && fabs(yx) < 0.01
|
||||
&& xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
{
|
||||
use_sbit = 1;
|
||||
}
|
||||
|
@ -1780,7 +1804,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
}
|
||||
}
|
||||
|
||||
/* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p\n",
|
||||
/* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p",
|
||||
s, x, y, x0, y0, x1, y1, buf);*/
|
||||
|
||||
for (; length; length--, glyphs++)
|
||||
|
@ -1792,7 +1816,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
|
||||
{
|
||||
if (glyph != 0xffffffff)
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)",
|
||||
error, glyph, imageType.face_id, imageType.width, imageType.height,
|
||||
imageType.flags
|
||||
);
|
||||
|
@ -1919,7 +1943,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
if ((error=FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
|
||||
{
|
||||
NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);
|
||||
NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
face = size->face;
|
||||
|
@ -1928,24 +1952,24 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
scales hinting might still be a good idea. */
|
||||
if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))
|
||||
{
|
||||
NSLog(@"FT_Load_Glyph() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Load_Glyph() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error=FT_Get_Glyph(face->glyph, &gl)))
|
||||
{
|
||||
NSLog(@"FT_Get_Glyph() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Get_Glyph() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error=FT_Glyph_Transform(gl, &ftmatrix, &ftdelta)))
|
||||
{
|
||||
NSLog(@"FT_Glyph_Transform() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Glyph_Transform() failed with error %08x", error);
|
||||
continue;
|
||||
}
|
||||
if ((error=FT_Glyph_To_Bitmap(&gl, ft_render_mode_normal, 0, 1)))
|
||||
{
|
||||
NSLog(@"FT_Glyph_To_Bitmap() failed with error %08x\n",error);
|
||||
NSLog(@"FT_Glyph_To_Bitmap() failed with error %08x", error);
|
||||
FT_Done_Glyph(gl);
|
||||
continue;
|
||||
}
|
||||
|
@ -2060,7 +2084,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
|
||||
if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
|
||||
{
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
|
||||
NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)",
|
||||
error, glyph, imageType.face_id,
|
||||
imageType.width, imageType.height,
|
||||
imageType.flags
|
||||
|
@ -2129,13 +2153,13 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
|
|||
if ((error=FTC_ImageCache_Lookup(ftc_imagecache, &imageType, glyph, &g, NULL)))
|
||||
{
|
||||
NSLog(@"FTC_ImageCache_Lookup() failed with error %08x",error);
|
||||
// NSLog(@"boundingRectForGlyph: %04x -> %i\n", aGlyph, glyph);
|
||||
// NSLog(@"boundingRectForGlyph: %04x -> %i", aGlyph, glyph);
|
||||
return fontBBox;
|
||||
}
|
||||
|
||||
FT_Glyph_Get_CBox(g, ft_glyph_bbox_gridfit, &bbox);
|
||||
|
||||
/* printf("got cbox for %04x: %i, %i - %i, %i\n",
|
||||
/* printf("got cbox for %04x: %i, %i - %i, %i",
|
||||
aGlyph, bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax);*/
|
||||
|
||||
return NSMakeRect(bbox.xMin / 64.0, bbox.yMin / 64.0,
|
||||
|
@ -2710,6 +2734,7 @@ static int filters[3][7]=
|
|||
|
||||
FT_Matrix ftmatrix;
|
||||
FT_Vector ftdelta;
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
BOOL subpixel = NO;
|
||||
|
||||
|
@ -2724,8 +2749,9 @@ static int filters[3][7]=
|
|||
x -= x0;
|
||||
y -= y0;
|
||||
|
||||
ts = [transform transformStruct];
|
||||
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)]\n",
|
||||
/* NSLog(@"[%@ draw using matrix: (%g %g %g %g %g %g)]",
|
||||
self,
|
||||
matrix[0], matrix[1], matrix[2],
|
||||
matrix[3], matrix[4], matrix[5]
|
||||
|
@ -2735,16 +2761,16 @@ static int filters[3][7]=
|
|||
{
|
||||
float xx, xy, yx, yy;
|
||||
|
||||
xx = matrix[0] * transform->matrix.m11 + matrix[1] * transform->matrix.m21;
|
||||
yx = matrix[0] * transform->matrix.m12 + matrix[1] * transform->matrix.m22;
|
||||
xy = matrix[2] * transform->matrix.m11 + matrix[3] * transform->matrix.m21;
|
||||
yy = matrix[2] * transform->matrix.m12 + matrix[3] * transform->matrix.m22;
|
||||
xx = matrix[0] * ts.m11 + matrix[1] * ts.m21;
|
||||
yx = matrix[0] * ts.m12 + matrix[1] * ts.m22;
|
||||
xy = matrix[2] * ts.m11 + matrix[3] * ts.m21;
|
||||
yy = matrix[2] * ts.m12 + matrix[3] * ts.m22;
|
||||
|
||||
/* if we're drawing 'normal' text (unscaled, unrotated, reasonable
|
||||
size), we can and should use the sbit cache */
|
||||
if (fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01 &&
|
||||
fabs(xy) < 0.01 && fabs(yx) < 0.01 &&
|
||||
xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
if (fabs(xx - ((int)xx)) < 0.01 && fabs(yy - ((int)yy)) < 0.01
|
||||
&& fabs(xy) < 0.01 && fabs(yx) < 0.01
|
||||
&& xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
|
||||
{
|
||||
use_sbit = 1;
|
||||
cur.font.pix_width = xx;
|
||||
|
@ -2780,7 +2806,7 @@ static int filters[3][7]=
|
|||
}
|
||||
|
||||
|
||||
/* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p\n",
|
||||
/* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p",
|
||||
s, x, y, x0, y0, x1, y1, buf);*/
|
||||
|
||||
cmap.face_id = imgd.font.face_id;
|
||||
|
|
|
@ -584,15 +584,14 @@ seem to cause edges to be off by a pixel
|
|||
{
|
||||
BOOL identity_transform, is_rgb;
|
||||
image_info_t ii;
|
||||
NSAffineTransformStruct ts = [matrix transformStruct];
|
||||
|
||||
if (!wi || !wi->data) return;
|
||||
if (all_clipped) return;
|
||||
|
||||
[matrix appendTransform: ctm];
|
||||
if (fabs(matrix->matrix.m11 - 1.0) < 0.001 &&
|
||||
fabs(matrix->matrix.m12) < 0.001 &&
|
||||
fabs(matrix->matrix.m22 - 1.0) < 0.001 &&
|
||||
fabs(matrix->matrix.m21) < 0.001)
|
||||
if (fabs(ts.m11 - 1.0) < 0.001 && fabs(ts.m12) < 0.001
|
||||
&& fabs(ts.m22 - 1.0) < 0.001 && fabs(ts.m21) < 0.001)
|
||||
identity_transform = YES;
|
||||
else
|
||||
identity_transform = NO;
|
||||
|
|
|
@ -396,7 +396,7 @@ static void artcontext_render_svp(const ArtSVP *svp, int x0, int y0, int x1, int
|
|||
also fills in the axis coordinates (x0/y0 is min) and returns 1. Otherwise
|
||||
returns 0. (Actually, if pixel is NO, it's enough that the edges remain
|
||||
within one pixel.) */
|
||||
-(int) _axis_rectangle: (float)x : (float)y : (float)w : (float)h
|
||||
- (int) _axis_rectangle: (float)x : (float)y : (float)w : (float)h
|
||||
vpath: (ArtVpath *)vp
|
||||
axis: (int *)px0 : (int *)py0 : (int *)px1 : (int *)py1
|
||||
pixel: (BOOL)pixel
|
||||
|
@ -405,16 +405,17 @@ within one pixel.) */
|
|||
float det;
|
||||
int i;
|
||||
int x0, y0, x1, y1;
|
||||
NSAffineTransformStruct ts = [ctm transformStruct];
|
||||
|
||||
if (w < 0) x += w, w = -w;
|
||||
if (h < 0) y += h, h = -h;
|
||||
|
||||
matrix[0]= ctm->matrix.m11;
|
||||
matrix[1]=-ctm->matrix.m12;
|
||||
matrix[2]= ctm->matrix.m21;
|
||||
matrix[3]=-ctm->matrix.m22;
|
||||
matrix[4]= ctm->matrix.tX - offset.x;
|
||||
matrix[5]=-ctm->matrix.tY + offset.y;
|
||||
matrix[0] = ts.m11;
|
||||
matrix[1] = -ts.m12;
|
||||
matrix[2] = ts.m21;
|
||||
matrix[3] = -ts.m22;
|
||||
matrix[4] = ts.tX - offset.x;
|
||||
matrix[5] = -ts.tY + offset.y;
|
||||
|
||||
/* If the matrix is 'inverted', ie. if the determinant is negative,
|
||||
we need to flip the order of the vertices. Since it's a rectangle
|
||||
|
@ -464,16 +465,16 @@ within one pixel.) */
|
|||
else
|
||||
*py0 = y0, *py1 = y1;
|
||||
|
||||
if (fabs(vp[0].x - vp[1].x) < 0.01 && fabs(vp[1].y - vp[2].y) < 0.01 &&
|
||||
fabs(vp[0].x - x0) < 0.01 && fabs(vp[0].y - y0) < 0.01 &&
|
||||
fabs(vp[2].x - x1) < 0.01 && fabs(vp[2].y - y1) < 0.01)
|
||||
if (fabs(vp[0].x - vp[1].x) < 0.01 && fabs(vp[1].y - vp[2].y) < 0.01
|
||||
&& fabs(vp[0].x - x0) < 0.01 && fabs(vp[0].y - y0) < 0.01
|
||||
&& fabs(vp[2].x - x1) < 0.01 && fabs(vp[2].y - y1) < 0.01)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fabs(vp[0].y - vp[1].y) < 0.01 && fabs(vp[1].x - vp[2].x) < 0.01 &&
|
||||
fabs(vp[0].x - x0) < 0.01 && fabs(vp[0].y - y0) < 0.01 &&
|
||||
fabs(vp[2].x - x1) < 0.01 && fabs(vp[2].y - y1) < 0.01)
|
||||
if (fabs(vp[0].y - vp[1].y) < 0.01 && fabs(vp[1].x - vp[2].x) < 0.01
|
||||
&& fabs(vp[0].x - x0) < 0.01 && fabs(vp[0].y - y0) < 0.01
|
||||
&& fabs(vp[2].x - x1) < 0.01 && fabs(vp[2].y - y1) < 0.01)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -491,18 +492,14 @@ within one pixel.) */
|
|||
else
|
||||
*py0 = floor(vp[2].y), *py1 = ceil(vp[0].y);
|
||||
|
||||
if (floor(vp[0].x) == floor(vp[1].x) &&
|
||||
floor(vp[0].y) == floor(vp[3].y) &&
|
||||
floor(vp[1].y) == floor(vp[2].y) &&
|
||||
floor(vp[2].x) == floor(vp[3].x))
|
||||
if (floor(vp[0].x) == floor(vp[1].x) && floor(vp[0].y) == floor(vp[3].y)
|
||||
&& floor(vp[1].y) == floor(vp[2].y) && floor(vp[2].x) == floor(vp[3].x))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (floor(vp[0].y) == floor(vp[1].y) &&
|
||||
floor(vp[0].x) == floor(vp[3].x) &&
|
||||
floor(vp[1].x) == floor(vp[2].x) &&
|
||||
floor(vp[2].y) == floor(vp[3].y))
|
||||
if (floor(vp[0].y) == floor(vp[1].y) && floor(vp[0].x) == floor(vp[3].x)
|
||||
&& floor(vp[1].x) == floor(vp[2].x) && floor(vp[2].y) == floor(vp[3].y))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -512,7 +509,7 @@ within one pixel.) */
|
|||
}
|
||||
|
||||
|
||||
-(ArtVpath *) _vpath_from_current_path: (BOOL)fill
|
||||
- (ArtVpath *) _vpath_from_current_path: (BOOL)fill
|
||||
{
|
||||
ArtBpath *bpath, *bp2;
|
||||
ArtVpath *vp;
|
||||
|
@ -725,7 +722,7 @@ static void clip_svp_callback(void *data, int y, int start,
|
|||
}
|
||||
|
||||
/* will free the passed in svp */
|
||||
-(void) _clip_add_svp: (ArtSVP *)svp
|
||||
- (void) _clip_add_svp: (ArtSVP *)svp
|
||||
{
|
||||
clip_info_t ci;
|
||||
ci.span = NULL;
|
||||
|
@ -799,7 +796,7 @@ static void clip_svp_callback(void *data, int y, int start,
|
|||
art_svp_free(svp);
|
||||
}
|
||||
|
||||
-(void) _clip: (int)rule
|
||||
- (void) _clip: (int)rule
|
||||
{
|
||||
ArtVpath *vp;
|
||||
ArtSVP *svp;
|
||||
|
@ -910,7 +907,7 @@ static void clip_svp_callback(void *data, int y, int start,
|
|||
|
||||
/** Filling **/
|
||||
|
||||
-(void) _fill: (int)rule
|
||||
- (void) _fill: (int)rule
|
||||
{
|
||||
ArtVpath *vp;
|
||||
ArtSVP *svp;
|
||||
|
@ -1039,26 +1036,44 @@ static void clip_svp_callback(void *data, int y, int start,
|
|||
|
||||
if (fill_color[3] == 255)
|
||||
{
|
||||
for (; y0 < y1; y0++, ri.dst += wi->bytes_per_line, ri.dsta += wi->sx)
|
||||
RENDER_RUN_OPAQUE_A(&ri, x1);
|
||||
while (y0 < y1)
|
||||
{
|
||||
RENDER_RUN_OPAQUE_A(&ri, x1);
|
||||
y0++;
|
||||
ri.dst += wi->bytes_per_line;
|
||||
ri.dsta += wi->sx;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; y0 < y1; y0++, ri.dst += wi->bytes_per_line, ri.dsta += wi->sx)
|
||||
RENDER_RUN_ALPHA_A(&ri, x1);
|
||||
while (y0 < y1)
|
||||
{
|
||||
RENDER_RUN_ALPHA_A(&ri, x1);
|
||||
y0++;
|
||||
ri.dst += wi->bytes_per_line;
|
||||
ri.dsta += wi->sx;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fill_color[3] == 255)
|
||||
{
|
||||
for (; y0 < y1; y0++, ri.dst += wi->bytes_per_line)
|
||||
RENDER_RUN_OPAQUE(&ri, x1);
|
||||
while (y0 < y1)
|
||||
{
|
||||
RENDER_RUN_OPAQUE(&ri, x1);
|
||||
y0++;
|
||||
ri.dst += wi->bytes_per_line;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; y0 < y1; y0++, ri.dst += wi->bytes_per_line)
|
||||
RENDER_RUN_ALPHA(&ri, x1);
|
||||
while (y0 < y1)
|
||||
{
|
||||
RENDER_RUN_ALPHA(&ri, x1);
|
||||
y0++;
|
||||
ri.dst += wi->bytes_per_line;
|
||||
}
|
||||
}
|
||||
}
|
||||
UPDATE_UNBUFFERED
|
||||
|
@ -1069,19 +1084,18 @@ static void clip_svp_callback(void *data, int y, int start,
|
|||
/** Stroking **/
|
||||
|
||||
/* will free the passed in vpath */
|
||||
-(void) _stroke: (ArtVpath *)vp
|
||||
- (void) _stroke: (ArtVpath *)vp
|
||||
{
|
||||
double temp_scale;
|
||||
ArtSVP *svp;
|
||||
|
||||
NSAffineTransformStruct ts = [ctm transformStruct];
|
||||
float dash_adjust;
|
||||
|
||||
|
||||
/* TODO: this is a hack, but it's better than nothing */
|
||||
/* since we flip vertically, the signs here should really be
|
||||
inverted, but the fabs() means that it doesn't matter */
|
||||
temp_scale = sqrt(fabs(ctm->matrix.m11 * ctm->matrix.m22 -
|
||||
ctm->matrix.m12 * ctm->matrix.m21));
|
||||
temp_scale = sqrt(fabs(ts.m11 * ts.m22 - ts.m12 * ts.m21));
|
||||
if (temp_scale <= 0) temp_scale = 1;
|
||||
|
||||
|
||||
|
@ -1266,6 +1280,7 @@ static void clip_svp_callback(void *data, int y, int start,
|
|||
{
|
||||
ArtVpath *vp, *vp2;
|
||||
double matrix[6];
|
||||
NSAffineTransformStruct ts;
|
||||
|
||||
if (!wi || !wi->data) return;
|
||||
if (all_clipped) return;
|
||||
|
@ -1291,12 +1306,13 @@ static void clip_svp_callback(void *data, int y, int start,
|
|||
vp[5].code = ART_END;
|
||||
vp[5].x = vp[5].y = 0;
|
||||
|
||||
matrix[0] = ctm->matrix.m11;
|
||||
matrix[1] =-ctm->matrix.m12;
|
||||
matrix[2] = ctm->matrix.m21;
|
||||
matrix[3] =-ctm->matrix.m22;
|
||||
matrix[4] = ctm->matrix.tX - offset.x;
|
||||
matrix[5] =-ctm->matrix.tY + offset.y;
|
||||
ts = [ctm transformStruct];
|
||||
matrix[0] = ts.m11;
|
||||
matrix[1] = -ts.m12;
|
||||
matrix[2] = ts.m21;
|
||||
matrix[3] = -ts.m22;
|
||||
matrix[4] = ts.tX - offset.x;
|
||||
matrix[5] = -ts.tY + offset.y;
|
||||
|
||||
vp2 = art_vpath_affine_transform(vp, matrix);
|
||||
art_free(vp);
|
||||
|
@ -1353,11 +1369,11 @@ will give correct results as long as both axises are scaled the same.
|
|||
|
||||
|
||||
@interface ARTGState (path_testing)
|
||||
-(void) GScurrentpath: (NSBezierPath **)p;
|
||||
- (void) GScurrentpath: (NSBezierPath **)p;
|
||||
@end
|
||||
|
||||
@implementation ARTGState (path_testing)
|
||||
-(void) GScurrentpath: (NSBezierPath **)p
|
||||
- (void) GScurrentpath: (NSBezierPath **)p
|
||||
{
|
||||
*p = [path copy];
|
||||
}
|
||||
|
@ -1365,7 +1381,7 @@ will give correct results as long as both axises are scaled the same.
|
|||
|
||||
@implementation ARTContext (path_testing)
|
||||
/* TODO: this is just for testing */
|
||||
-(void) GScurrentpath: (NSBezierPath **)p
|
||||
- (void) GScurrentpath: (NSBezierPath **)p
|
||||
{
|
||||
[(ARTGState *)gstate GScurrentpath: p];
|
||||
}
|
||||
|
|
1071
Source/art/shfill.m
1071
Source/art/shfill.m
File diff suppressed because it is too large
Load diff
|
@ -198,6 +198,8 @@ RECT GSXWindowRectToMS(WIN32GState *s, NSRect r)
|
|||
op: (NSCompositingOperation) op
|
||||
fraction: (float)delta
|
||||
{
|
||||
NSAffineTransformStruct sctms;
|
||||
NSAffineTransformStruct ctms;
|
||||
HDC sourceDC;
|
||||
HDC hDC;
|
||||
RECT rectFrom;
|
||||
|
@ -222,8 +224,10 @@ RECT GSXWindowRectToMS(WIN32GState *s, NSRect r)
|
|||
x = rectTo.left;
|
||||
y = rectTo.top;
|
||||
|
||||
if (source->ctm->matrix.m22 < 0 && ctm->matrix.m22 > 0) y += h;
|
||||
if (source->ctm->matrix.m22 > 0 && ctm->matrix.m22 < 0) y -= h;
|
||||
sctms = [source->ctm transformStruct];
|
||||
ctms = [ctm transformStruct];
|
||||
if (sctms.m22 < 0 && ctms.m22 > 0) y += h;
|
||||
if (sctms.m22 > 0 && ctms.m22 < 0) y -= h;
|
||||
|
||||
sourceDC = [source getHDC];
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@
|
|||
#else
|
||||
#include "x11/wraster.h"
|
||||
#endif
|
||||
|
||||
// For X_HAVE_UTF8_STRING
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#include <X11/extensions/shape.h>
|
||||
|
|
|
@ -420,6 +420,8 @@ NSDebugLLog(@"XGGraphics", @"Clip %@ set to X rect %@",
|
|||
- (void) copyBits: (XGGState*)source fromRect: (NSRect)aRect
|
||||
toPoint: (NSPoint)aPoint
|
||||
{
|
||||
NSAffineTransformStruct sctms;
|
||||
NSAffineTransformStruct ctms;
|
||||
XRectangle dst;
|
||||
XRectangle src;
|
||||
NSRect flushRect;
|
||||
|
@ -442,12 +444,14 @@ NSDebugLLog(@"XGGraphics", @"Clip %@ set to X rect %@",
|
|||
flushRect.size = aRect.size;
|
||||
flushRect.origin = aPoint;
|
||||
dst = XGViewRectToX(self, flushRect);
|
||||
if (source->ctm->matrix.m22 < 0 && ctm->matrix.m22 > 0) dst.y += src.height;
|
||||
if (source->ctm->matrix.m22 > 0 && ctm->matrix.m22 < 0) dst.y -= src.height;
|
||||
sctms = [source->ctm transformStruct];
|
||||
ctms = [ctm transformStruct];
|
||||
if (sctms.m22 < 0 && ctms.m22 > 0) dst.y += src.height;
|
||||
if (sctms.m22 > 0 && ctms.m22 < 0) dst.y -= src.height;
|
||||
NSDebugLLog(@"XGGraphics", @"Copy area from %@ to %@",
|
||||
NSStringFromRect(aRect), NSStringFromPoint(aPoint));
|
||||
NSStringFromRect(aRect), NSStringFromPoint(aPoint));
|
||||
XCopyArea(XDPY, from, draw, xgcntxt,
|
||||
src.x, src.y, src.width, src.height, dst.x, dst.y);
|
||||
src.x, src.y, src.width, src.height, dst.x, dst.y);
|
||||
}
|
||||
|
||||
- (void) _alphaBuffer: (gswindow_device_t *)dest_win
|
||||
|
|
Loading…
Reference in a new issue