File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -134,8 +134,8 @@ public function writeMatrix(MaskPattern $maskPattern):QRMatrix{
134134 *
135135 * @throws \chillerlan\QRCode\Data\QRCodeDataException
136136 */
137- private function estimateTotalBitLength ():int {
138- $ length = 0 ;
137+ public function estimateTotalBitLength ():int {
138+ $ length = 4 ; // 4 bits for the terminator
139139 $ margin = 0 ;
140140
141141 foreach ($ this ->dataSegments as $ segment ){
@@ -146,6 +146,12 @@ private function estimateTotalBitLength():int{
146146 // mode length bits margin to the next breakpoint
147147 $ margin += ($ segment instanceof Byte) ? 8 : 2 ;
148148 }
149+
150+ if ($ segment instanceof Hanzi){
151+ // Hanzi mode sets an additional 4 bit long subset identifier
152+ $ length += 4 ;
153+ }
154+
149155 }
150156
151157 foreach ([9 , 26 , 40 ] as $ breakpoint ){
@@ -168,7 +174,7 @@ private function estimateTotalBitLength():int{
168174 *
169175 * @throws \chillerlan\QRCode\Data\QRCodeDataException
170176 */
171- private function getMinimumVersion ():Version {
177+ public function getMinimumVersion ():Version {
172178
173179 if ($ this ->options ->version !== Version::AUTO ){
174180 return new Version ($ this ->options ->version );
You can’t perform that action at this time.
0 commit comments