mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-11-23 12:09:51 +00:00
81388169c4
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.
35 lines
779 B
Objective-C
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
|