Author Topic: Fonts to barcodes  (Read 3493 times)

0 Members and 1 Guest are viewing this topic.

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Fonts to barcodes
« on: January 02, 2020, 02:12:13 pm »
Hi everyone.

Again I have a problem with the program I am doing and I hope you can help me.

I am trying to print a barcode on the printer but it fails to load barcode fonts such as ConnectCode39.ttf or ean13.ttf

Is it possible to load these types of sources and print barcodes?

Thanks and best regards

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Fonts to barcodes
« Reply #1 on: January 02, 2020, 04:38:32 pm »
Hi. Try this, if it help you:

Code: QB64: [Select]
  1. paper& = _NEWIMAGE(1024, 768, 32) 'set correct paper size (set correct ratio)
  2. SCREEN paper&
  3. CLS , &HFFFFFFFF
  4. font = _LOADFONT("connectcode39.ttf", 15, "monospace")
  5. code& = _NEWIMAGE(1000, 100, 32)
  6. _FONT font, code&
  7. D = _DEST
  8. _DEST code&
  9.  
  10. PRINT "  123456" 'here set code number
  11.  
  12. _PUTIMAGE (250, 250), code&, paper& 'set X, Y positions on paper
  13.  
  14. '_PRINTIMAGE paper&
  15.  
  16.  

All barcodes and source for this font is from https://www.dafont.com/ccode39.font
« Last Edit: January 02, 2020, 04:51:50 pm by Petr »

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Re: Fonts to barcodes
« Reply #2 on: January 03, 2020, 07:13:03 am »
Hi
Thanks for your help.
I've tried the code and it doesn't work on windows 10 (handle = -1).
On another computer with windows 7 if it works.
How could I make it work on windows 10?
I downloaded and installed the font you attached in case it was a problem.
Thanks

Offline Morant

  • Newbie
  • Posts: 1
    • View Profile
Re: Fonts to barcodes
« Reply #3 on: January 03, 2020, 08:01:01 am »
Indeed it doesn't work on Windows 10. What could be causing this issue?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fonts to barcodes
« Reply #4 on: January 03, 2020, 10:49:56 am »
Steve found an issue with font loading discussed here:
https://www.qb64.org/forum/index.php?topic=1704.msg109426#msg109426

eh? was about using _Fontload without paths to file.
« Last Edit: January 03, 2020, 10:57:57 am by bplus »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Fonts to barcodes
« Reply #5 on: January 03, 2020, 12:04:41 pm »
Please let us know, if problem occur, when you use full path for _LOADFONT. When your font is in the same directory and error occur, please try font = _LOADFONT (_CWD$ + "\connectcode39.ttf", 15, "monospace") if it then works. This return 32 for me in Windows 7.

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Re: Fonts to barcodes
« Reply #6 on: January 03, 2020, 02:31:00 pm »
Please let us know, if problem occur, when you use full path for _LOADFONT. When your font is in the same directory and error occur, please try font = _LOADFONT (_CWD$ + "\connectcode39.ttf", 15, "monospace") if it then works. This return 32 for me in Windows 7.



This code...

handle = _LOADFONT("c:\windows\fonts\connectcode39.ttf", 15, "monospace")
PRINT handle: x$ = INPUT$(1)

...works on Windows 7 and print "32", and not works in Windows 10 and print "-1"

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Fonts to barcodes
« Reply #7 on: January 03, 2020, 03:33:22 pm »
Perhaps Steve will look at it. I really don't understand what windows 10 doesn't like. The only option that still occurs to me (although it is probably crap), what other fonts under windows 10. Do they work from the same path? And if not, what to try to place fonts on a disk where there is no system (and protected area system). Work it then from there?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fonts to barcodes
« Reply #8 on: January 03, 2020, 07:02:55 pm »
Connectcode font is not in windows fonts so downloaded file to Downloads folder and ran Petr's code (after saving code to that folder also) in Windows 10, works fine!
« Last Edit: January 03, 2020, 07:06:24 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Fonts to barcodes
« Reply #9 on: January 04, 2020, 02:18:27 am »
Runs fine on Linux 64 bit...
Logic is the beginning of wisdom.

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Re: Fonts to barcodes
« Reply #10 on: January 05, 2020, 06:55:53 am »
I downloaded the font and installed it in the \ windows \ font folder and I also tried to copy it to the QB64 folder
In neither case does it work on my Windows 10 64 bit computer and work on another computer that I have with Windows 7 64 bits
I do not know what to do
« Last Edit: January 07, 2020, 06:00:11 am by Juanjogomez »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Fonts to barcodes
« Reply #11 on: January 05, 2020, 07:21:01 am »
I test my source code, which is here under QB64 0.954, 1.1, 1.2, 1.3 in 32bit and also in 64bit versions, always it works. So, last solution, what maybe can help (or not), try install the 2015 C++ distribution. Maybe it is the same problem as here: https://www.qb64.org/forum/index.php?topic=2055.msg112806#msg112806.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fonts to barcodes
« Reply #12 on: January 05, 2020, 10:41:14 am »
I downloaded the font and installed it in the \ windows \ font folder and I also tried to copy it to the QB64 folder
In neither case does it work on my Windows 10 64 bit computer and it does work on another computer that I have with Windows 7 64 bits
I do not know what to do


Hi Juanjogomez,

Here is the whole barcode package with b+ compiled exe in Windows 10 64 bit just to test things on your side with a working EXE.

If you run the bas file make sure there is a bullet at "Output EXE to Source Folder" under the Run menu in the IDE in your Windows 10 - 64 bit QB64 IDE.

The font file is in same folder as the source where the EXE should end up if you have that line with bullet in Run menu. This avoids problem Steve reported about pathed fonts and checks that the EXE is going to the same place as the source BAS file which is also where the font file is.

Update: downloaded zip, extracted and everything works as expected on my end, so it's been double checked on a Windows 10 64 bit machine with QB64 v1.3 for 64 bit standard issue.
« Last Edit: January 05, 2020, 10:51:32 am by bplus »

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Re: Fonts to barcodes
« Reply #13 on: January 07, 2020, 04:51:39 am »
In the end I got it to work by installing version 1.3 of QB64. Bplus gave me the hint when I tried his compiled program and it worked on my computer.

Thanks everyone for your help.