Open OTF fonts with php - greek characters included
Asked Answered
R

2

7

So, as the title says, my task is to convert a given phrase to an image on server side (php GD) with a selected .otf font. The phrase can include not only latin characters but also greek and cyrillic.

PHP's imagettftext (http://php.net/manual/en/function.imagettftext.php) won't work with non-latin characters on .otf fonts (works ok with .ttf as it seems).

Any clues?

EDIT: Font needs to be .otf

Radiograph answered 4/1, 2012 at 8:28 Comment(7)
Why not convert it to TTF then?Darwindarwinian
and do it for free at :freefontconverter.comDubiety
my bad for haven't added this to the question: I need the features .otf offers that aren't present in .ttfRadiograph
What features are those exactly?Sniggle
It is a good question whether you need those features for this image-conversion, or for something else. You could store them in two different formats.Darwindarwinian
for image conversio. To give you the full picture: It's for a store that sells fonts and it needs an online presentation of it's fonts in the way that I described it before. Enter text + choose font + other features like underlines or whatever + produce image.Radiograph
well in short nothing in native php will do this, you will have to look at other applications you can run on the server.Dubiety
R
-4

Posting rough answer that seems to work for future people bumping on this post:

Solution seemed to be: 1) open OTF with LATEX server side 2) produce PDF 3) convert to image with ImageMagick library.

Radiograph answered 9/1, 2012 at 10:40 Comment(0)
C
11

Use imagefttext function instead. It has the same arguments and usage as imagettftext, but uses the FreeType 2 library which supports OpenType and plenty of other font formats.

It doesn't support OpenType's layout tables however. See FreeType 2's FAQ for more info.

Countercheck answered 4/1, 2012 at 11:50 Comment(1)
have you tried imagefttext with non-latin characters? Can't seem to get it to work either. Getting that annoying rectangle.Radiograph
R
-4

Posting rough answer that seems to work for future people bumping on this post:

Solution seemed to be: 1) open OTF with LATEX server side 2) produce PDF 3) convert to image with ImageMagick library.

Radiograph answered 9/1, 2012 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.