darling-cocotron/Onyx2D/O2PDFCharWidths.m
Sergey Bugaev 81388169c4 Move all Onyx2D headers into include/Onyx2D
It would be nice to have a proper public/private headers split, but
Onyx2D is just not designed for it (as are other Cocotron frameworks).

This way, it is at least possible to use Onyx2D without adding the full
Cocotron source tree into the include path.
2019-04-27 00:04:37 +03:00

35 lines
779 B
Objective-C

#import <Onyx2D/O2PDFCharWidths.h>
#import <Onyx2D/O2PDFArray.h>
@implementation O2PDFCharWidths
-initWithArray:(O2PDFArray *)array firstChar:(int)firstChar lastChar:(int)lastChar missingWidth:(CGFloat)missingWidth {
int i,arrayIndex;
for(i=0;i<firstChar;i++)
_widths[i]=missingWidth;
for(arrayIndex=0;i<=lastChar;i++,arrayIndex++){
O2PDFReal real=0;
[array getNumberAtIndex:arrayIndex value:&real];
_widths[i]=real/1000.0;
}
for(;i<256;i++)
_widths[i]=missingWidth;
return self;
}
void O2PDFCharWidthsGetAdvances(O2PDFCharWidths *self,O2Size *advances,const uint8_t *bytes,int length) {
int i;
for(i=0;i<length;i++){
advances[i].width=self->_widths[bytes[i]];
advances[i].height=0;
}
}
@end