@@ -211,29 +211,36 @@ public final function getPrintableArea()
211211 */
212212 public final function writeText (TCPDF $ pdf , $ text , $ x , $ y , $ font =null , $ style =null , $ size =null , $ align ='L ' , $ width =null , $ height =null , $ squash =false , $ border =0 , $ spacing =0 )
213213 {
214+
215+
214216 $ prevFamily = $ pdf ->getFontFamily ();
215217 $ prevStyle = $ pdf ->getFontStyle ();
216218 $ prevSizePt = $ pdf ->getFontSizePt ();
217219
220+
218221 $ text = !empty ($ text ) ? $ text : '' ;
219222
220223 $ fontFamily = !empty ($ font ) ? $ font : $ prevFamily ;
221224 $ fontStyle = !empty ($ style ) ? $ style : $ prevStyle ;
222- if ($ size ) { $ fontSizePt = Helper::convertUnit ($ size , $ this ->getUnit (), 'pt ' , true );
223- } else { $ fontSizePt = $ prevSizePt ;
225+
226+
227+ if ($ size ) {
228+ $ fontSizePt = Helper::convertUnit ($ size , $ this ->getUnit (), 'pt ' , true );
229+ } else {
230+ $ fontSizePt = $ prevSizePt ;
224231 }
225232
226233 $ pdf ->SetFontSpacing ($ spacing );
227234
228235 $ parts = collect (explode ('** ' , $ text ))
229236 ->map (
230- function ($ part , $ index ) use ($ pdf , $ fontFamily , $ fontStyle , $ fontSizePt ) {
237+ function ($ part , $ index ) use ($ pdf , $ fontFamily , $ fontStyle , $ fontSizePt, $ text ) {
231238 $ modStyle = ($ index % 2 == 1 ) ? 'B ' : $ fontStyle ;
232239 $ pdf ->setFont ($ fontFamily , $ modStyle , $ fontSizePt );
233240 return [
234241 'text ' => $ part ,
235242 'text_width ' => $ pdf ->GetStringWidth ($ part ),
236- 'font_family ' => $ fontFamily ,
243+ 'font_family ' => Helper:: isCjk ( $ text ) ? ' cid0cs ' : $ fontFamily ,
237244 'font_style ' => $ modStyle ,
238245 'font_size ' => $ fontSizePt ,
239246 ];
0 commit comments