Про GD и TTF, только не посылайте !!!

  • Автор темы Pups The RAPtor
  • Дата начала

Pups The RAPtor

Guest
Про GD и TTF, только не посылайте !!!

Траффик ограничен, поэтому лазить по поиску, по ФАКАМ и мануалам совершенно невозможно.
Надо выводить русский текст на картинку, не обязательно ttf шрифтом.
Есть PHP 4.2.1+GD2 под Win2k, выдержки из phpinfo():
GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
JPG Support enabled
PNG Support enabled
WBMP Support enabled
в скрипте после imagettftext ($im, 20, 0, 10, 20, $white, "полный путь к шрифту/arial.ttf", "Testing");
вылезает warning: <b>Warning</b>: Could not find/open font in <b>c:\oracle817\apache\apache\htdocs\rmr\font.php</b> on line <b>6</b>

Вопрос в том где грабли. Может шрифт не той модели ;)))? Брал стандартный виндовый.
 

snap

Guest
из под винды апач шрифты берет почему-то только из
c:\Windows\fonts\ ...
 

Pups The RAPtor

Guest
Автор оригинала: snap
из под винды апач шрифты берет почему-то только из
c:\Windows\fonts\ ...
Нет, таже самая фигня происходит.

Еще мысли будут у кого?
 

nikkolay

Guest
GD Version 1.6.2 or higher и все работает, код :
фонты из winxp
PHP:
<? 
$ttf_font = "C:\windows\fonts\arial.ttf"; 
$winstring = "Проверка TTF"; 
$isostring = convert_cyr_string($winstring, "w", "i"); 
$unistring = iso2uni($isostring); 

header("Content-type: image/jpeg"); 
$im = ImageCreate(400,30); 
$black = ImageColorAllocate($im, 0,0,0); 
$white = ImageColorAllocate($im, 255,255,255); 
ImageFill($im, 0, 0, $white); 
ImageTTFText($im, 18, 0, 10, 20, $black, $ttf_font, $unistring); 
ImageJpeg($im); 
ImageDestroy($im); 


function iso2uni ($isoline){ 
    for ($i=0; $i < strlen($isoline); $i++){ 
        $thischar=substr($isoline,$i,1); 
        $charcode=ord($thischar); 
        $uniline.=($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar;   
    } 
    return $uniline; 
} 
?>
 

Pups The RAPtor

Guest
Автор оригинала: nikkolay
из любой другой папки тоже берет
Нет, к сожалению не берет. Ни из какой папки. Правда GD Version 2.0 or higher, в этом может быть дело?
 

nikkolay

Guest
не действует :(
только под 1.6.x,

ошибка та же
[Sun Jun 02 09:45:48 2002] [error] PHP Warning: Could not find/open font in c:\apache\htdocs\index1.php on line 13
 

Pups The RAPtor

Guest
Автор оригинала: nikkolay
не действует :(
только под 1.6.x,

ошибка та же
[Sun Jun 02 09:45:48 2002] [error] PHP Warning: Could not find/open font in c:\apache\htdocs\index1.php on line 13
Да, такая вот ерунда. А не знаете где можно найти список отличий для GD 1.6.x от 2.х?
 

nikkolay

Guest
вот тебе полный changelog с версии 1.6 :)
What's new in version 2.0.1?

* Workaround for a bug in gcc, apparently found in gcc 2.7.2 and up.
I reproduced and fixed it while using gcc 2.9.5.2. The bug
occurred only when the -g option was in use. This problem caused
gcc to spew internal error messages unrelated to the correctness
of the code in gd_gd2.c. Howard Jones was first to report it.
* gdImageFilledEllipse documented and altered; no longer requires a
superfluous style argument. Thanks to Francis James Franklin.
* The Makefile now offers the correct syntax for optionally creating
a static library. Thanks to Jean-Lous Regez, among others.
* A nested comment, an attempt to return the value of a void
function, and a potentially significant error in
gdImageCopyResampled were fixed thanks to Joseph Shirley.
* A bug preventing proper truecolor text rendering was fixed, thanks
to Jason Gallagher.
* gdImageStringFT (FreeType) should now work better against a
transparent or semitransparent background, and should act in a
manner consistent with the most recent gdImageAlphaBlending
setting. Antialiasing is now done via the alpha channel mechanism
if the image is a truecolor image.
* Bugs in the output of gdImageArc and gdImageFilledArc were
reported by Bruce Verderaime. A simple and correct but inefficient
implementation has been substituted until fixes are contributed
for the faster code, which is in gd_arc_f_buggy.c along with the
test program that reproduces the bug(s).
* gdImageFilledArc now offers additional style options, which can be
combined to produce various effects.
* Masahito Yamaga ([email protected]) sent a patch to improve support
for Japanese output via gdImageStringFT. He also added a new
readme.jpn file.
* Zillions of documentation fixes.

What's new in version 2.0?

* _Support for truecolor images!_ Version 2.0 can load truecolor
PNGs with no loss of color information, and almost no loss of
alpha channel information. Version 2.0 can also load truecolor
JPEGs with as little loss as possible; however, bear in mind that
JPEG is a lossy format, so repeated load/save cycles always reduce
image quality. This is not a bug. To create a truecolor image from
scratch, call the new gdImageCreateTrueColor function. The
gdImageCreate function is still available to create palette
images, and may also be referred to as gdImageCreatePalette.
* _Support for alpha channels!_ In addition to 24 bits of color
information for each pixel (eight bits of red, green, and blue
respectively), version 2.0 supports 7 bits of "alpha channel"
information. This is used to determine exactly how transparent the
pixel should be. There is also support for a full 7 bits of
transparency for each individual palette index in a palette-based
image. Please note that, as of this writing, only Macintosh
Internet Explorer 5.x and Mozilla/Netscape 6.x display partial
transparency properly.
* The new gdImageAlphaBlending function allows for two different
modes of drawing. In blending mode, the alpha channel component of
the color supplied to all drawing functions, such as
gdImageSetPixel, determines how much of the underlying color
should be allowed to shine through. The resulting image is not
transparent. In non-blending mode, drawing color is copied
literally with the alpha channel information, resulting in a
transparent image. Blending mode is not available when drawing on
palette images.
* The gdImageCopyResampled function provides "smooth" copying from a
large image to a smaller one, using a weighted average of the
pixels of the source area rather than selecting one representative
pixel. This function is identical to gdImageCopyResized when the
destination image is a palette image.
* The gdImageTrueColorToPalette function converts a truecolor image
to a palette image. The code for this function was originally
drawn from the Independent JPEG Group library code, which is
excellent. The code has been modified to preserve as much alpha
channel information as possible in the resulting palette, in
addition to preserving colors as well as possible. This does not
work as well as might be hoped. It is usually best to simply
produce a truecolor output image instead, which guarantees the
highest output quality.
* A very high degree of backwards compatibility with existing gd 1.x
code has been maintained, at both the source code and binary
level. _Code which directly accesses the pixels array will fail
only if it encounters an existing truecolor image_, which may
happen if the code attempts to open and modify an existing JPEG or
truecolor PNG. Such code should be modified to check the trueColor
flag of the gdImage structure, and refer to the tpixels array
instead when it is set.
* gd is now compiled and installed as a shared library. However, gd
still does not use autoconf, because I (TBB) have very limited
patience with autoconf. These days, most Unix systems provide a
fairly POSIX-standard environment, and the provided Makefile is
likely to work well if users read it and follow the instructions
at the top.
* Support for line thickness was added by Michael Schwartz. My
apologies to him for sitting on his patches for so long. See the
new gdImageSetThickness function, which affects all standard gd
functions that draw lines and curves. In addition, Michael added a
convenient gdImageEllipse function.
* The new gdImageFilledArc function provides a straightforward way
to draw filled arcs. Also, gdImageFilledEllipse is a convenient
way to fill an ellipse without specifying starting and ending
angles. Thanks go out to F J Franklin.
* To put an end to the confusion, TrueType 1.x support has been
removed in favor of TrueType 2.x support. The old gdImageStringTTF
function simply invokes gdImageStringFT.
* The specialized .gd and .gd2 file formats have been upgraded to
support truecolor. New images written by the versions of these
functions found in 2.0 will be rejected, with varying degrees of
grace, by older versions of gd. THIS AFFECTS THE .GD and .GD2
FORMATS ONLY. IF YOU ARE CONFUSED BY THIS PARAGRAPH, IT PROBABLY
DOESN'T APPLY TO ANYTHING YOU WILL EVER ENCOUNTER. Since these
file formats are absolutely, positively *not* designed for
distributing images, just for preprocessing them, this should not
be a big problem. gd 2.0 should read old .gd and .gd2 files
correctly.

What's new in version 1.8.4?

* Add support for FreeType2 (John Ellson [email protected])
* Add support for finding in fonts in a builtin DEFAULT_FONTPATH, or
in a path from the GDFONTPATH environment variable.
* remove some unused symbols to reduce compiler warnings
* bugfix in size comparisons in gdImageCompare
* REXX now mentioned
* All memory allocation functions are now wrapped within the
library; gdFree is exported and recommended for freeing memory
returned by the gdImage(Something)Ptr family of functions.

What's new in version 1.8.3?

* WBMP output memory leak fixed
* #include <gd.h> corrected to #include "gd.h" in gd_wbmp.c
* Documented the fact that the source and output images shouldn't
match in the WBMP test except for black and white source images

What's new in version 1.8.2?

* WBMP support debugged and improved by Johann Van den Brande
* WBMP tests added to gdtest.c by Thomas Boutell
* Use of platform-dependent 'install' command removed by Thomas
Boutell
* Comments added to Makefile warning users to juggle the order of
the libraries if the linker complains; is there any portable way
to do this automatically, short of using autoconf?
* Documentation of gdImageCreateFromXpm corrected
* Updated links to fast-moving, always dodging libpng and zlib web
sites

What's new in version 1.8.1?

* Optional components no longer built by default (following the
documentation)
* JPEG code no longer requires inappropriate header files
* Win32 patches from Joe Gregorio
* 16-bit font support for bdftogd, from Honza Pazdziora

What's new in version 1.8?

* Support for JPEG output, courtesy of Doug Becker
* A link to Michael Bradbery's Pascal wrapper
* Support for WBMP output, courtesy of Maurice Szmurlo
* gdImageColorClosestHWB function based on hue, whiteness,
blackness, superior to the regular gdImageColorClosest function,
courtesy of Philip Warner
* License clarification: yes, you can modify gd

Additional JPEG Information

Support for reading and writing JPEG-format images is courtesy of Doug
Becker and the Independent JPEG Group / Thomas G. Lane. You can get
the latest version of the IJG JPEG software from
ftp://ftp.uu.net/graphics/jpeg/ (e.g., the jpegsrc.v6b.tar.gz file).
You _must_ use version 6b or later of the IJG JPEG software. You might
also consult the JPEG FAQ at http://www.faqs.org/faqs/jpeg-faq/.

What's new in version 1.7.3?

Another attempt at Makefile fixes to permit linking with all libraries
required on platforms with order- dependent linkers. Perhaps it will
work this time.

What's new in version 1.7.2?

An uninitialized-pointer bug in gdtestttf.c was corrected. This bug
caused crashes at the end of each call to gdImageStringTTF on some
platforms. Thanks to Wolfgang Haefelinger.

Documentation fixes. Thanks to Dohn Arms.

Makefile fixes to permit linking with all libraries required on
platforms with order- dependent linkers.

What's new in version 1.7.1?

A minor buglet in the Makefile was corrected, as well as an inaccurate
error message in gdtestttf.c. Thanks to Masahito Yamaga.

What's new in version 1.7?

Version 1.7 contains the following changes:
* Japanese language support for the TrueType functions. Thanks to
Masahito Yamaga.
* autoconf and configure have been removed, in favor of a carefully
designed Makefile which produces and properly installs the library
and the binaries. System-dependent variables are at the top of the
Makefile for easy modification. I'm sorry, folks, but autoconf
generated _many, many confused email messages_ from people who
didn't have things where autoconf expected to find them. I am not
an autoconf/automake wizard, and gd is a simple, very compact
library which does not need to be a shared library. I _did_ make
many improvements over the old gd 1.3 Makefile, which were
directly inspired by the autoconf version found in the 1.6 series
(thanks to John Ellson).
* Completely ANSI C compliant, according to the -pedantic-errors
flag of gcc. Several pieces of not-quite-ANSI-C code were causing
problems for those with non-gcc compilers.
* gdttf.c patched to allow the use of Windows symbol fonts, when
present (thanks to Joseph Peppin).
* extern "C" wrappers added to gd.h and the font header files for
the convenience of C++ programmers. bdftogd was also modified to
automatically insert these wrappers into future font header files.
Thanks to John Lindal.
* Compiles correctly on platforms that don't define SEEK_SET. Thanks
to Robert Bonomi.
* Loads Xpm images via the gdImageCreateFromXpm function, if the Xpm
library is available. Thanks to Caolan McNamara.

What's new in version 1.6.3?

Version 1.6.3 corrects a memory leak in gd_png.c. This leak caused a
significant amount of memory to be allocated and not freed when
writing a PNG image.

What's new in version 1.6.2?

Version 1.6.2 from John Ellson adds two new functions:
* gdImageStringTTF - scalable, rotatable, anti-aliased, TrueType
strings using the FreeType library, but only if libttf is found by
configure. _We do not provide TrueType fonts. Obtaining them is
entirely up to you._
* gdImageColorResolve - an efficient alternative for the common code
fragment:


if ((color=gdImageColorExact(im,R,G,B)) < 0)
if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
color=gdImageColorClosest(im,R,G,B);

Also in this release the build process has been converted to GNU
autoconf/automake/libtool conventions so that both (or either) static
and shared libraries can be built.

What's new in version 1.6.1?

Version 1.6.1 incorporates superior PNG reading and writing code from
Greg Roelofs, with minor modifications by Tom Boutell. Specifically, I
altered his code to read non-palette images (converting them to
palette images badly, by dithering them), and to tolerate palette
images with types of transparency that gd doesn't actually support (it
just ignores the advanced transparency features). Any bugs in this
area are therefore my fault, not Greg's.

Unlike gd 1.6, users should have no trouble linking with gd 1.6.1 if
they follow the instructions and install all of the pieces. However,
_If you get undefined symbol errors, be sure to check for older
versions of libpng in your library directories!_

What's new in version 1.6?

Version 1.6 features the following changes:

_Support for 8-bit palette PNG images has been added. Support for GIF
has been removed._ This step was taken to completely avoid the legal
controversy regarding the LZW compression algorithm used in GIF.
Unisys holds a patent which is relevant to LZW compression. PNG is a
superior image format in any case. Now that PNG is supported by both
Microsoft Internet Explorer and Netscape (in their recent releases),
we highly recommend that GD users upgrade in order to get
well-compressed images in a format which is legally unemcumbered.
 

Pups The RAPtor

Guest
Спасибо, действительно с 1.6.х все работает.

Только теперь вот такая ерунда происходит:
<b>Warning</b>: imagefilledarc(): requires GD 2.0 or later in <b>e:\oracle817\apache\apache\htdocs\rmr\pic.php</b> on line <b>40</b><br />

То есть мне надо одновременно использовать и gd1.6.x и gd2.x.

Это возможно? Или есть еще способы рисовать сектора?
 
Сверху