Untitled
unknown
c_cpp
a month ago
1.2 kB
6
Indexable
for (const HorizontalTextLayouter::Data &d : textLayouter.data) {
if (d.text.empty()) {
continue;
}
Ref fontRef;
// If it's an INVALID ref then we stick to our original font
if (d.fontRef.gen == -1 && d.fontRef.num == -1) {
font->getEmbeddedFontID(&fontRef);
} else {
fontRef = d.fontRef;
}
FontSubsetter *fontSubsetter = doc->getFontSubsetter();
char byte1 = d.text.at(0);
char byte2 = d.text.at(1);
if (byte1 == 0) {
// ASCII normal width character
fontSubsetter->addEntry(fontRef, byte2);
} else {
// Unicode double width character
uint32_t unicodeChar = 0;
// starting from left of the binary representation
// first 8 bits are copied from byte2
// next 8 bits are from byte1
for (int i = 0; i < 8; i++) {
if (byte2 & (1 << i)) {
unicodeChar |= (1 << i);
}
}
for (int i = 0; i < 8; i++) {
if (byte1 & (1 << i)) {
unicodeChar |= (1 << (i + 8));
}
}
fontSubsetter->addEntry(fontRef, unicodeChar);
}
}
Editor is loading...
Leave a Comment