Recent

Author Topic: Is it possible to embed fonts???  (Read 9266 times)

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Is it possible to embed fonts???
« on: October 11, 2010, 01:39:30 pm »
I have an application where I'm overlaying text in a specific font onto a graphic image of a paper invoice to generate a simulated output from a dot matrix printer on preprinted forms.  I have the nuts and bolts of the overlay somewhat down but before I proceed I need to find a font similar to the font on the OKI impact printers we use.  Once I find one is there any way to embed it into the program so that the target computer wont have to have it installed on it to have access to the correct font??  I'd really hate to have to install the font on every pc when the only place it will be used is from my program.

Any suggestions??

Bill 

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Is it possible to embed fonts???
« Reply #1 on: October 11, 2010, 04:07:42 pm »
After a bit of digging I'm still at a loss on this.  How about if I convert the ttf to bit mapped images of the characters and then draw them where I want them??

Is there another form of font other than ttf than Lazarus can use directly that I can either convert to from an existing ttf or go looking for an existing one that comes close to what I want?

I won't be displaying this on any screens as it will be printing directly to a laser or possibly an inkjet printer.

As to the first part using bitmaps can anyone point me to a program that would convert a ttf to individual bitmaps??

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12202
  • Debugger - SynEdit - and more
    • wiki
Re: Is it possible to embed fonts???
« Reply #2 on: October 11, 2010, 04:20:45 pm »
As long as you are on windows:

there is an article on msdn
http://msdn.microsoft.com/en-us/library/ms753303.aspx

Not sure about other OS...

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Is it possible to embed fonts???
« Reply #3 on: October 11, 2010, 04:34:58 pm »
Actually I'm programming cross platform for both windows and linux so I'm looking for something more generic that will work in both.  I think if I can come up with something that will make separate bmp files for each letter and symbol I can embed that as a resource and then write some code to create images I can drop onto the canvas in place of the text but so far what I've come up with on the web either doesn't work or I can't make it work :-[  (Most likely I'm messing it up). 

Does anyone know of a font format that I could use other than ttf that might lend itself to embedding??   

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Is it possible to embed fonts???
« Reply #4 on: October 11, 2010, 10:41:12 pm »
After a bit of digging I'm still at a loss on this.  How about if I convert the ttf to bit mapped images of the characters and then draw them where I want them??

ouch. don't.

well it would be (more or less) easy if it only goes over white background, but troublesome otherwise. besides, you're complicating. stick to the text overlay approach (see last part of the post).

As to the first part using bitmaps can anyone point me to a program that would convert a ttf to individual bitmaps??

take gimp/photoshop/whatever; start a small new image, use a text tool to type one letter. save. edit the text layer to type the next character. save. repeat last two steps.

I'd really hate to have to install the font on every pc when the only place it will be used is from my program.

what's the big deal?  many programs do that on setup.  you'd just make an installer that extracts and registers the font in addition to other installation tasks.

but if you really don't want that, include the font inside the executable as a resource, extract into temp dir on start; do the job; delete on quit...

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Is it possible to embed fonts???
« Reply #5 on: October 12, 2010, 02:32:31 pm »
After a bit of digging I'm still at a loss on this.  How about if I convert the ttf to bit mapped images of the characters and then draw them where I want them??

ouch. don't.

well it would be (more or less) easy if it only goes over white background, but troublesome otherwise. besides, you're complicating. stick to the text overlay approach (see last part of the post).

As to the first part using bitmaps can anyone point me to a program that would convert a ttf to individual bitmaps??

take gimp/photoshop/whatever; start a small new image, use a text tool to type one letter. save. edit the text layer to type the next character. save. repeat last two steps.

I'd really hate to have to install the font on every pc when the only place it will be used is from my program.

what's the big deal?  many programs do that on setup.  you'd just make an installer that extracts and registers the font in addition to other installation tasks.

but if you really don't want that, include the font inside the executable as a resource, extract into temp dir on start; do the job; delete on quit...

I found out about the white background while fiddling with a ttf converter so I guess that is out.

You don't know my users  ::) This program would be used at the most once or twice a year when the inter store communications goes down or we have a major server problem with the main server.  They can and will somehow delete the font in between and then when they need to use the program and it wont print out correctly they'll yell for me to fix it while I'm in the middle of trying to correct the bigger issues for all the stores.  So I want to make the entire thing self contained.

Can I use the fonts in a temporary directory on both Linux and Windows????

mas steindorff

  • Hero Member
  • *****
  • Posts: 566
Re: Is it possible to embed fonts???
« Reply #6 on: October 12, 2010, 04:56:51 pm »
Quote
They can and will somehow delete the font in between and then when they need to use the program and it wont print out correctly they'll yell for me to fix it while I'm in the middle of trying to correct the bigger issues for all the stores.  So I want to make the entire thing self contained.

just a though, If your program doesn't need a lot of customisation then the user can just run the install package again.
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Is it possible to embed fonts???
« Reply #7 on: October 13, 2010, 07:16:28 pm »
Can I use the fonts in a temporary directory on both Linux and Windows????
i haven't tried /tmp but i can personally confirm that you can extract the font into /home/username/.fonts and it will work by setting  Label1.Font.Name := 'Font Name'; (or canvas in your case; use the font name not the font filename)

there is one tiny problem: you need to start your app after the font is already there. that means either restart it after extracting the font or (even better) make a loader that will extract the font or confirm it's already there and then start your main application. you do not need to restart x.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Is it possible to embed fonts???
« Reply #8 on: October 13, 2010, 07:40:14 pm »
This is possible with FCL-Image and the FreeType library:

http://wiki.lazarus.freepascal.org/fcl-image#Drawing_text

I suppose that one could connect this to Lazarus throught TLazIntfImage:

http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Working_with_TLazIntfImage

 

TinyPortal © 2005-2018