|
|
@@ -129,6 +129,9 @@ tPrintParaDrawEx tPrintData[200];
|
|
|
int nPrintIndex = 0;
|
|
|
int nCurentPositionY=0;
|
|
|
int nCurentPositionX=40; // 硬件特性原因 即使设置X坐标为0 打印也会从左边距40像素开始打印 所以行方下传左边距的时候要考虑这个因素计算一下
|
|
|
+int ALine = 0; //总行数
|
|
|
+bool isLine = false;
|
|
|
+int wordspace = 0;
|
|
|
|
|
|
|
|
|
ThermalPrintClassImpl::ThermalPrintClassImpl():m_mode(0)
|
|
|
@@ -496,9 +499,10 @@ ErrorCodeEnum ThermalPrintClassImpl::ControlAction(PrintAction eAction, DWORD dw
|
|
|
snprintf(szErrMsg, sizeof(szErrMsg), "ThermalPrintClassImpl::ControlAction ACTION_PRINT_ONE_LINE : %d",dwValue1);
|
|
|
LOG4VTM(INFO,szErrMsg);
|
|
|
|
|
|
-
|
|
|
+ isLine = true;
|
|
|
+ ALine++;
|
|
|
//行方控制走纸的时候 重新计算X Y坐标
|
|
|
- nCurentPositionY = nCurentPositionY + iHeight + 5;
|
|
|
+ nCurentPositionY = nCurentPositionY + (iHeight*(iDoubleHeight+1)) + 5;
|
|
|
nCurentPositionX = 40;
|
|
|
|
|
|
|
|
|
@@ -523,7 +527,8 @@ ErrorCodeEnum ThermalPrintClassImpl::ControlAction(PrintAction eAction, DWORD dw
|
|
|
LOG4VTM(INFO,szErrMsg);
|
|
|
|
|
|
//行方控制走纸的时候 重新计算X Y坐标
|
|
|
- nCurentPositionY = nCurentPositionY + iHeight*dwValue1 + 5;
|
|
|
+ //nCurentPositionY = nCurentPositionY + iHeight*dwValue1 + 5;
|
|
|
+ nCurentPositionY = nCurentPositionY + dwValue1*((iHeight*(iDoubleHeight+1)) + 5);
|
|
|
nCurentPositionX = 40;
|
|
|
|
|
|
|
|
|
@@ -800,7 +805,7 @@ ErrorCodeEnum ThermalPrintClassImpl::SetParam(CommandType eType, DWORD dwValue1,
|
|
|
LOG4VTM(INFO,szErrMsg);
|
|
|
|
|
|
//行方下传的左边距 要考虑硬件特性 前面有40像素也就是5mm的距离
|
|
|
- //nCurentPositionX = dwValue1/0.125;
|
|
|
+ //nCurentPositionX = 40 + dwValue1/0.125;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -919,9 +924,9 @@ ErrorCodeEnum ThermalPrintClassImpl::SetFont(FontStyle eType, DWORD dwValue1, DW
|
|
|
//iFontHeight = (dwValue1*3)/0.125;
|
|
|
//iFontHeight = (dwValue1)/0.125;
|
|
|
|
|
|
- iFontHeight = (dwValue2)*iFontHeight;
|
|
|
- iHeight = iFontHeight;
|
|
|
-
|
|
|
+ // iFontHeight = (dwValue2)*iFontHeight;
|
|
|
+ // iHeight = iFontHeight;
|
|
|
+ iDoubleHeight = dwValue2 - 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -967,7 +972,7 @@ ErrorCodeEnum ThermalPrintClassImpl::SetFont(FontStyle eType, DWORD dwValue1, DW
|
|
|
char szErrMsg[256]={0};
|
|
|
snprintf(szErrMsg, sizeof(szErrMsg), "ThermalPrintClassImpl::SetFont FONT_LEFT_RIGHT_SPACE : %d %d",dwValue1,dwValue2);
|
|
|
LOG4VTM(INFO,szErrMsg);
|
|
|
-
|
|
|
+ wordspace = ((dwValue1/0.125) + (dwValue2/0.125))/(iDoubleWide + 1);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
@@ -990,7 +995,7 @@ ErrorCodeEnum ThermalPrintClassImpl::PrintText(BYTE* pData, DWORD dwDataLen)
|
|
|
tPrintData[nPrintIndex].iPositionY = nCurentPositionY;
|
|
|
tPrintData[nPrintIndex].iWidth = 496; //576-80 行方控制打印左右边距是80像素
|
|
|
tPrintData[nPrintIndex].iHeight = iHeight;
|
|
|
- tPrintData[nPrintIndex].psPrintPara.iWordSpace = 0;
|
|
|
+ tPrintData[nPrintIndex].psPrintPara.iWordSpace = wordspace;
|
|
|
tPrintData[nPrintIndex].psPrintPara.iFontHeight = iFontHeight;
|
|
|
tPrintData[nPrintIndex].psPrintPara.iLineSpace = iLineSpace;
|
|
|
tPrintData[nPrintIndex].psPrintPara.iTextAlign = iTextAlign;
|
|
|
@@ -1008,7 +1013,7 @@ ErrorCodeEnum ThermalPrintClassImpl::PrintText(BYTE* pData, DWORD dwDataLen)
|
|
|
|
|
|
tPrintData[nPrintIndex].pcData = czTem;
|
|
|
|
|
|
- char * czFontName = "CESI_FS_GB18030";
|
|
|
+ char * czFontName = "CESI_SS_GB13000";
|
|
|
memcpy(tPrintData[nPrintIndex].psPrintPara.pcFontName,czFontName,strlen(czFontName));
|
|
|
|
|
|
|
|
|
@@ -1029,29 +1034,52 @@ ErrorCodeEnum ThermalPrintClassImpl::PrintText(BYTE* pData, DWORD dwDataLen)
|
|
|
//计算文字X 、Y坐标
|
|
|
int nNumber = GetUtf8LetterNumber(czTem);
|
|
|
int nXpos;
|
|
|
- if(iDoubleWide>1)
|
|
|
+ if(iDoubleWide>0)
|
|
|
{
|
|
|
- nXpos = nNumber*(iHeight*(iDoubleWide-1)) + nNumber*3; //要计算字体宽度 倍宽数 字数 字间距等才能算准
|
|
|
+ //nXpos = nNumber*(iHeight*(iDoubleWide-1)) + nNumber*3; //要计算字体宽度 倍宽数 字数 字间距等才能算准
|
|
|
+ for(int ii=0;ii<nNumber;ii++)
|
|
|
+ {
|
|
|
+ nXpos = iHeight*(iDoubleWide+1) + wordspace*(iDoubleWide + 1);
|
|
|
+ nCurentPositionX = nCurentPositionX + nXpos;
|
|
|
+ if(nCurentPositionX > 536)
|
|
|
+ {
|
|
|
+ nCurentPositionX = 40 + nXpos;
|
|
|
+ nCurentPositionY = nCurentPositionY + (iHeight*(iDoubleHeight + 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- nXpos = nNumber*(iHeight);
|
|
|
+ nXpos = nNumber*(iHeight) + wordspace;
|
|
|
+ nCurentPositionX = nCurentPositionX + nXpos;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//X坐标实际位置
|
|
|
- nCurentPositionX = nCurentPositionX + nXpos;
|
|
|
|
|
|
|
|
|
//Y坐标 要计算上次打印是否已经换行了和总共换了多少行 再算实际Y坐标 这里要慢慢调一下
|
|
|
+
|
|
|
+ // if (isLine)
|
|
|
+ // {
|
|
|
+ // isLine = false;
|
|
|
+ // if(iDoubleHeight>0)
|
|
|
+ // {
|
|
|
+ // nCurentPositionY = nCurentPositionY + (iDoubleHeight+1) * iHeight;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
-
|
|
|
+ char XYmessage[256]={0};
|
|
|
+ snprintf(XYmessage, sizeof(XYmessage), "ThermalPrintClassImpl::SetFont X : %d ,Y: %d",nCurentPositionX,nCurentPositionY);
|
|
|
+ LOG4VTM(INFO,XYmessage);
|
|
|
|
|
|
|
|
|
|
|
|
- printf("nNumber: %d \n",nNumber);
|
|
|
- printf("nXpos: %d \n",nXpos);
|
|
|
- printf("nCurentPositionX: %d \n",nCurentPositionX);
|
|
|
- printf("nCurentPositionY:%d \n",nCurentPositionY);
|
|
|
+ // printf("nNumber: %d \n",nNumber);
|
|
|
+ // printf("nXpos: %d \n",nXpos);
|
|
|
+ // printf("nCurentPositionX: %d \n",nCurentPositionX);
|
|
|
+ // printf("nCurentPositionY:%d \n",nCurentPositionY);
|
|
|
|
|
|
|
|
|
nPrintIndex++;
|