Blurry and strange color when creating barcode using fonts
-
Hi
Is that not just normal font antialiasing?
What platform is this ? -
Hi Bro this is my code
i have tried anti aliasing .... nothing changed the same problemint width = 300; int height = 120; QImage image = QPixmap(width, height).toImage(); QPainter painter(&image); painter.setRenderHints(QPainter::SmoothPixmapTransform,true); image.fill(Qt::white); painter.setPen(Qt::black); if(ui->barcodelineedit->text().length()<12){ painter.setFont(QFont("IDAutomationHC39M Free Version", 12)); painter.drawText(QPoint(90,105), ui->barcodelineedit->text()); }else{ painter.setFont(QFont("IDAutomationHC39M Free Version", 12)); painter.drawText(QPoint(40,105), ui->barcodelineedit->text()); } ui->showiteminfolabel->setPixmap(QPixmap::fromImage(image));
-
@Proton-Phoenix
Ok for test, you could try disable it and see if it has any effect.
https://www.tenforums.com/tutorials/126775-enable-disable-font-smoothing-windows.html -
@mrjj said in Blurry and strange color when creating barcode using fonts:
@Proton-Phoenix
Ok for test, you could try disable it and see if it has any effect.
https://www.tenforums.com/tutorials/126775-enable-disable-font-smoothing-windows.htmlafter disabling smooth edges and screen fonts
problem solved !!
but the normal texts ... on the label became so bad ~~~
now i understand it's not a font or QT problem
it's just the way windows render texts and images ...
so it's normal to see some green or other colors on the barcodeReally Thank you You always Save my day <3
i hope great happy life for all of you guys
many thanks again and again <3 -
@Proton-Phoenix Two questions:
- are you going to print them out or are they intended just for the on-screen use? If the latter there might be a limit related to the display. One work-around you can try is to print them much larger (font size 48 i.e.) and then scale down with Qt::KeepAspectRatio and Qt::SmoothTransformation. If the former - test on the printouts only, use either native dpi for the printer set explicitly (windows sometimes can't be trusted to get that right) or 300 (from my experience more doesn't make sense and eats lots of memory)
- are you certain that this font is at all able to produce crisp, small sized barcodes?
Me myself used to create barcodes for printing, like I mentioned, and getting anything to be read by a scanner with a small font failed until I used this font: https://www.dafont.com/c39hrp48dhtt.font
EDIT: I see problem is solved after I posted :)
-
@artwaw said in Blurry and strange color when creating barcode using fonts:
@Proton-Phoenix Two questions:
- are you going to print them out or are they intended just for the on-screen use? If the latter there might be a limit related to the display. One work-around you can try is to print them much larger (font size 48 i.e.) and then scale down with Qt::KeepAspectRatio and Qt::SmoothTransformation. If the former - test on the printouts only, use either native dpi for the printer set explicitly (windows sometimes can't be trusted to get that right) or 300 (from my experience more doesn't make sense and eats lots of memory)
- are you certain that this font is at all able to produce crisp, small sized barcodes?
Me myself used to create barcodes for printing, like I mentioned, and getting anything to be read by a scanner with a small font failed until I used this font: https://www.dafont.com/c39hrp48dhtt.font
EDIT: I see problem is solved after I posted :)
really thank you bro too .. you helped me so many times before i will never forget that and you helped me so much here too
the label in the software it's just to show a preview to the user before printing the barcode label ....
i don't have barcode printer yet ... just testing
so it would be better to create bigger image with bigger fonts and then scale it down to barcode label size?
ok i will try that
i tried evenpainter.setFont(QFont("IDAutomationHC39M Free Version", 10));
it just need barcode with a two stars or (barcode) ... as starting and ending point
and i am using my android smartphone to scan the output barcode .. even the small barcode and it can scan it fast without any problem
and i send it to my software tcp server .. -
@Proton-Phoenix it all depends on the use case BUT if the target use is on paper, render for that. Then for the preview just scale down.
-
@artwaw said in Blurry and strange color when creating barcode using fonts:
@Proton-Phoenix it all depends on the use case BUT if the target use is on paper, render for that. Then for the preview just scale down.
the main purpose for me is to print it on a paper .. but i don't have it yet
that's why i am using small size QImage like QSizeF(100,40)
i am thinking that if i create bigger images it can't be printing as page on the Barcode printer .. so i must have one to test on real better than imagination ...
but
really thank you bro for all this great support <3i hope you try the font that i am using now and tell me your opinion if it works with you on small sized barcode
...
i hope great happy life for you <3 -
@Proton-Phoenix I no longer have access to the Zebra I was using in the past (I changed the company since then).
Zebra printers are a story on their own to troubleshoot anyway...General approach I used:
- make sure the printer is configured properly in the system, with the default page size set to the target page size.
- query the QPrinterInfo instance for the default page size.
- use that data with QPdfWriter to render whatever text + barcode I need.
- remember DPI settings, either set what the manual for the printer says (ideal) or 300 (this didn't end well for Dymo printers I used for a while, needed exact DPI of 204 ;) ).
- print and enjoy.
In general getting this to work might be lots of trial and error, depending on the brand and drivers. But once it's done right it is literally zero maintenance for years.
-
@artwaw said in Blurry and strange color when creating barcode using fonts:
@Proton-Phoenix I no longer have access to the Zebra I was using in the past (I changed the company since then).
Zebra printers are a story on their own to troubleshoot anyway...General approach I used:
- make sure the printer is configured properly in the system, with the default page size set to the target page size.
- query the QPrinterInfo instance for the default page size.
- use that data with QPdfWriter to render whatever text + barcode I need.
- remember DPI settings, either set what the manual for the printer says (ideal) or 300 (this didn't end well for Dymo printers I used for a while, needed exact DPI of 204 ;) ).
- print and enjoy.
In general getting this to work might be lots of trial and error, depending on the brand and drivers. But once it's done right it is literally zero maintenance for years.
<3 Thank you bro for everything <3