@@ -953,7 +953,7 @@ public function newPage(array $settings = [])
953
953
* feed int; x position (required)
954
954
* font string; font style, optional: bold, italic, regular
955
955
* font_file string; path to font file (optional for use your custom font)
956
- * font_size int; font size (default 7 )
956
+ * font_size int; font size (default 10 )
957
957
* align string; text align (also see feed parametr), optional left, right
958
958
* height int;line spacing (default 10)
959
959
*
@@ -1005,24 +1005,8 @@ public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSet
1005
1005
foreach ($ lines as $ line ) {
1006
1006
$ maxHeight = 0 ;
1007
1007
foreach ($ line as $ column ) {
1008
- $ fontSize = empty ($ column ['font_size ' ]) ? 10 : $ column ['font_size ' ];
1009
- if (!empty ($ column ['font_file ' ])) {
1010
- $ font = \Zend_Pdf_Font::fontWithPath ($ column ['font_file ' ]);
1011
- $ page ->setFont ($ font , $ fontSize );
1012
- } else {
1013
- $ fontStyle = empty ($ column ['font ' ]) ? 'regular ' : $ column ['font ' ];
1014
- switch ($ fontStyle ) {
1015
- case 'bold ' :
1016
- $ font = $ this ->_setFontBold ($ page , $ fontSize );
1017
- break ;
1018
- case 'italic ' :
1019
- $ font = $ this ->_setFontItalic ($ page , $ fontSize );
1020
- break ;
1021
- default :
1022
- $ font = $ this ->_setFontRegular ($ page , $ fontSize );
1023
- break ;
1024
- }
1025
- }
1008
+ $ font = $ this ->setFont ($ page , $ column );
1009
+ $ fontSize = $ column ['font_size ' ];
1026
1010
1027
1011
if (!is_array ($ column ['text ' ])) {
1028
1012
$ column ['text ' ] = [$ column ['text ' ]];
@@ -1033,6 +1017,8 @@ public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSet
1033
1017
foreach ($ column ['text ' ] as $ part ) {
1034
1018
if ($ this ->y - $ lineSpacing < 15 ) {
1035
1019
$ page = $ this ->newPage ($ pageSettings );
1020
+ $ font = $ this ->setFont ($ page , $ column );
1021
+ $ fontSize = $ column ['font_size ' ];
1036
1022
}
1037
1023
1038
1024
$ feed = $ column ['feed ' ];
@@ -1066,4 +1052,42 @@ public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSet
1066
1052
1067
1053
return $ page ;
1068
1054
}
1055
+
1056
+ /**
1057
+ * Set page font.
1058
+ *
1059
+ * column array format
1060
+ * font string; font style, optional: bold, italic, regular
1061
+ * font_file string; path to font file (optional for use your custom font)
1062
+ * font_size int; font size (default 10)
1063
+ *
1064
+ * @param \Zend_Pdf_Page $page
1065
+ * @param array $column
1066
+ * @return \Zend_Pdf_Resource_Font
1067
+ * @throws \Zend_Pdf_Exception
1068
+ */
1069
+ private function setFont ($ page , &$ column )
1070
+ {
1071
+ $ fontSize = empty ($ column ['font_size ' ]) ? 10 : $ column ['font_size ' ];
1072
+ $ column ['font_size ' ] = $ fontSize ;
1073
+ if (!empty ($ column ['font_file ' ])) {
1074
+ $ font = \Zend_Pdf_Font::fontWithPath ($ column ['font_file ' ]);
1075
+ $ page ->setFont ($ font , $ fontSize );
1076
+ } else {
1077
+ $ fontStyle = empty ($ column ['font ' ]) ? 'regular ' : $ column ['font ' ];
1078
+ switch ($ fontStyle ) {
1079
+ case 'bold ' :
1080
+ $ font = $ this ->_setFontBold ($ page , $ fontSize );
1081
+ break ;
1082
+ case 'italic ' :
1083
+ $ font = $ this ->_setFontItalic ($ page , $ fontSize );
1084
+ break ;
1085
+ default :
1086
+ $ font = $ this ->_setFontRegular ($ page , $ fontSize );
1087
+ break ;
1088
+ }
1089
+ }
1090
+
1091
+ return $ font ;
1092
+ }
1069
1093
}
0 commit comments