nehan
Version:
Html layout engine for paged-media written in Typescript
56 lines • 1.54 kB
JavaScript
import { LogicalSize, } from "./public-api";
export class DualChar {
constructor(str, info) {
this.text = str;
this.size = new LogicalSize({ measure: 0, extent: 0 });
this.info = info;
this.kerning = false;
this.spacing = 0;
this.charCount = 1;
}
isParen() {
return this.isOpenParen() || this.isCloseParen();
}
isOpenParen() {
return this.info.parenType === "open";
}
isCloseParen() {
return this.info.parenType === "close";
}
isTailNg() {
return this.info.kinsokuPos === "tail";
}
isHeadNg() {
return this.info.kinsokuPos === "head";
}
isKernEnable() {
return this.info.kernEnable;
}
isHangEnable() {
return this.info.hangEnable;
}
isSmall() {
return this.info.isSmall;
}
setMetrics(opts) {
this.size.measure = opts.font.size;
this.size.extent = opts.font.size;
this.empha = opts.empha;
if (this.kerning && this.isKernEnable() || this.isSmall()) {
this.size.measure = Math.floor(opts.font.size / 2);
}
}
toString() {
return this.text;
}
acceptEvaluator(visitor) {
if (this.empha && this.info.parenType === "none") {
return visitor.visitCharEmpha(this, this.empha);
}
if (this.kerning) {
return visitor.visitDualCharKern(this);
}
return visitor.visitDualChar(this);
}
}
//# sourceMappingURL=dual-char.js.map