import { IQuestion , } from 'survey-core' ; import { IPoint , IRect , DocController } from '../doc_controller' ; import { PdfBrick } from './pdf_brick' ; export class TextBrick extends PdfBrick { protected align : { align : string ; baseline : string ; } ; public constructor ( question , controller , rect , protected text ) { super ( question , controller , rect ) ; this . align = { align : 'left' , baseline : 'middle' } ; } private escapeText ( ) { while ( this . text . indexOf ( '\t' ) > - 1 ) { this . text = this . text . replace ( '\t' , Array ( 5 ) . join ( String . fromCharCode ( 160 ) ) ) ; } return this . text ; } public async renderInteractive ( ) { let alignPoint = this . alignPoint ( this ) ; let oldFontSize = this . controller . fontSize ; this . controller . fontSize = this . fontSize ; let oldTextColor = this . controller . doc . getTextColor ( ) ; this . controller . doc . setTextColor ( this . textColor ) ; this . controller . doc . text ( this . escapeText ( ) , alignPoint . xLeft , alignPoint . yTop , this . align ) ; this . controller . doc . setTextColor ( oldTextColor ) ; this . controller . fontSize = oldFontSize ; } protected alignPoint ( rect ) { return { xLeft : rect . xLeft , yTop : rect . yTop + ( rect . yBot - rect . yTop ) / 2.0 } ; } }