De-NSInteger-ize {CG,O2}FontGetGlyphAdvances()

Turns out it didn't just break the build (269215f670),
it was actually *wrong*; the Apple's version uses a plain int (not even a CFIndex) for some reason. Do the same in O2FontGetGlyphAdvances(),
but keep the internal ivar as an NSInteger array pointer; we're making a copy in O2FontGetGlyphAdvances() anyway.
This commit is contained in:
Sergey Bugaev 2018-09-08 14:06:56 +03:00
parent 269215f670
commit 078fe9beb7
8 changed files with 9 additions and 10 deletions

View File

@ -189,7 +189,7 @@ static void renderFreeTypeBitmap(
O2PaintRelease(paint);
NSInteger glyphAdvances[count];
int glyphAdvances[count];
O2Float unitsPerEm=O2FontGetUnitsPerEm(font);
O2FontGetGlyphAdvances(font,glyphs,count,glyphAdvances);

View File

@ -65,7 +65,7 @@ size_t CGFontGetNumberOfGlyphs(CGFontRef self) {
return O2FontGetNumberOfGlyphs(self);
}
bool CGFontGetGlyphAdvances(CGFontRef self,const CGGlyph *glyphs,size_t count,NSInteger *advances) {
bool CGFontGetGlyphAdvances(CGFontRef self,const CGGlyph *glyphs,size_t count,int *advances) {
return O2FontGetGlyphAdvances(self,glyphs,count,advances);
}

View File

@ -10,7 +10,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <CoreGraphics/CGGeometry.h>
#include <CoreFoundation/CoreFoundation.h>
#import <Foundation/NSObjCRuntime.h>
typedef struct O2Font *CGFontRef;
@ -32,7 +31,7 @@ COREGRAPHICS_EXPORT CGFloat CGFontGetStemV(CGFontRef self);
COREGRAPHICS_EXPORT CGRect CGFontGetFontBBox(CGFontRef self);
COREGRAPHICS_EXPORT size_t CGFontGetNumberOfGlyphs(CGFontRef self);
COREGRAPHICS_EXPORT bool CGFontGetGlyphAdvances(CGFontRef self, const CGGlyph *glyphs, size_t count, NSInteger *advances);
COREGRAPHICS_EXPORT bool CGFontGetGlyphAdvances(CGFontRef self, const CGGlyph *glyphs, size_t count, int *advances);
COREGRAPHICS_EXPORT CGGlyph CGFontGetGlyphWithGlyphName(CGFontRef self, CFStringRef name);
COREGRAPHICS_EXPORT CFStringRef CGFontCopyGlyphNameForGlyph(CGFontRef self, CGGlyph glyph);

View File

@ -94,7 +94,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
-(CGPoint)positionOfGlyph:(CGGlyph)current precededByGlyph:(CGGlyph)previous isNominal:(BOOL *)isNominalp {
NSInteger advancement;
int advancement;
if(previous==0)
return CGPointMake(0,0);
@ -121,7 +121,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
-(void)getAdvancements:(CGSize *)advancements forGlyphs:(const CGGlyph *)glyphs count:(NSUInteger)count {
NSInteger advances[count];
int advances[count];
CGFontGetGlyphAdvances(_font,glyphs,count,advances);
for(int i=0;i<count;i++){

View File

@ -1309,7 +1309,7 @@ O2AffineTransform O2ContextGetTextRenderingMatrix(O2ContextRef self) {
void O2ContextGetDefaultAdvances(O2ContextRef self,const O2Glyph *glyphs,O2Size *advances,size_t count) {
O2GState *gState=O2ContextCurrentGState(self);
O2Font *font=O2GStateFont(gState);
NSInteger intAdvances[count];
int intAdvances[count];
O2Float unitsPerEm=O2FontGetUnitsPerEm(font);
O2Float pointSize=O2GStatePointSize(gState);
size_t i;

View File

@ -27,7 +27,7 @@ O2PDFArray *O2FontCreatePDFWidthsWithEncoding(O2FontRef self,O2Encoding *encodin
CGFloat unitsPerEm=O2FontGetUnitsPerEm(self);
O2PDFArray *result=[[O2PDFArray alloc] init];
O2Glyph glyphs[256];
NSInteger widths[256];
int widths[256];
int i;
[encoding getGlyphs:glyphs];

View File

@ -473,7 +473,7 @@ size_t O2FontGetNumberOfGlyphs(O2FontRef self) {
return self->_numberOfGlyphs;
}
BOOL O2FontGetGlyphAdvances(O2FontRef self,const O2Glyph *glyphs,size_t count, NSInteger *advances) {
BOOL O2FontGetGlyphAdvances(O2FontRef self,const O2Glyph *glyphs,size_t count, int *advances) {
size_t i;
if(self->_advances==NULL)

View File

@ -101,7 +101,7 @@ O2Rect O2FontGetFontBBox(O2FontRef self);
NSCharacterSet *O2FontGetCoveredCharacterSet(O2FontRef self);
size_t O2FontGetNumberOfGlyphs(O2FontRef self);
BOOL O2FontGetGlyphAdvances(O2FontRef self, const O2Glyph *glyphs, size_t count, NSInteger *advances);
BOOL O2FontGetGlyphAdvances(O2FontRef self, const O2Glyph *glyphs, size_t count, int *advances);
O2Glyph O2FontGetGlyphWithGlyphName(O2FontRef self, CFStringRef name);
NSString *O2FontCopyGlyphNameForGlyph(O2FontRef self, O2Glyph glyph);