PHP backend for automatic font embedding in HTML

I’m working on a print product website where designers upload fonts for templates. We need to show real-time previews of editable regions using these fonts. The problem is browser compatibility.

Most modern browsers support @font-face with TTF files. But Internet Explorer needs EOT format.

Here’s what I’m trying to figure out:

  1. Can I convert TTF to EOT on a non-Windows server?
  2. How to automate this process?
  3. What’s the best way to handle both TTF and EOT in my CSS?

I can’t use Flash or JavaScript tricks because the text is in form fields. Any ideas on how to make this work across all browsers? Thanks for your help!

hey, i had similar font probs. try ttf2eot - it works on linux for converting ttf to eot. automate conversion with a script on file upload. for css, use:

@font-face {
font-family: ‘myfont’;
src: url(‘myfont.eot’);
src: url(‘myfont.ttf’) format(‘truetype’);
}

hope this helps!

For font conversion, I’d recommend using FontForge, an open-source tool that can handle TTF to EOT conversion on various platforms. You can integrate it into your backend workflow using its scripting capabilities.

Regarding automation, consider implementing a queue system. When a designer uploads a font, add it to a conversion queue. Use a cron job or background worker to process this queue periodically, converting fonts and updating your database.

For CSS, use the ‘bulletproof’ @font-face syntax:

@font-face {
font-family: ‘CustomFont’;
src: url(‘customfont.eot’);
src: url(‘customfont.eot?#iefix’) format(‘embedded-opentype’),
url(‘customfont.woff2’) format(‘woff2’),
url(‘customfont.woff’) format(‘woff’),
url(‘customfont.ttf’) format(‘truetype’);
}

This approach ensures maximum browser compatibility while future-proofing your setup.

ooh, font embedding sounds tricky! have u considered using a web font service like google fonts or typekit? they handle browser compatibility for u. but if u need custom fonts, maybe look into woff format? it works on most browsers. what kinda templates r u working with? sounds like an interesting project!