Skip to content

Commit

Permalink
move t1lib font support to a separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Feb 6, 2011
1 parent afee75f commit a556912
Show file tree
Hide file tree
Showing 24 changed files with 1,400 additions and 1,196 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,6 +1,7 @@
*.o
Makefile
Makefile.old
MANIFEST.bak
pm_to_blib
blib

Expand All @@ -23,6 +24,7 @@ scale.c
# build generated files
*.bs
*/Makefile
Imager-[0-9]*

# test generated files
_Inline/
Expand Down
20 changes: 5 additions & 15 deletions Imager.pm
Expand Up @@ -61,14 +61,6 @@ use Imager::Font;
i_img_diff
i_init_fonts
i_t1_new
i_t1_destroy
i_t1_set_aa
i_t1_cp
i_t1_text
i_t1_bbox
i_tt_set_aa
i_tt_cp
i_tt_text
Expand Down Expand Up @@ -155,7 +147,7 @@ my %defaults;
BEGIN {
require Exporter;
@ISA = qw(Exporter);
$VERSION = '0.80';
$VERSION = '0.80_01';
eval {
require XSLoader;
XSLoader::load(Imager => $VERSION);
Expand All @@ -176,6 +168,7 @@ my %format_classes =
jpeg => "Imager::File::JPEG",
w32 => "Imager::Font::W32",
ft2 => "Imager::Font::FT2",
t1 => "Imager::Font::T1",
);

tie %formats, "Imager::FORMATS", \%formats_low, \%format_classes;
Expand Down Expand Up @@ -474,13 +467,10 @@ sub init {
$warn_obsolete = $parms{'warn_obsolete'};
}

# if ($parms{T1LIB_CONFIG}) { $ENV{T1LIB_CONFIG}=$parms{T1LIB_CONFIG}; }
# if ( $ENV{T1LIB_CONFIG} and ( $fontstate eq 'missing conf' )) {
# i_init_fonts();
# $fontstate='ok';
# }
if (exists $parms{'t1log'}) {
i_init_fonts($parms{'t1log'});
if ($formats{t1}) {
Imager::Font::T1::i_init_t1($parms{'t1log'});
}
}
}

Expand Down
183 changes: 0 additions & 183 deletions Imager.xs
Expand Up @@ -2006,10 +2006,6 @@ i_img_diffd(im1,im2)
Imager::ImgRaw im1
Imager::ImgRaw im2

undef_int
i_init_fonts(t1log=0)
int t1log

bool
_is_color_object(sv)
SV* sv
Expand All @@ -2022,185 +2018,6 @@ _is_color_object(sv)
RETVAL

#ifdef HAVE_LIBT1

void
i_t1_set_aa(st)
int st

int
i_t1_new(pfb,afm)
char* pfb
char* afm

int
i_t1_destroy(font_id)
int font_id


undef_int
i_t1_cp(im,xb,yb,channel,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
Imager::ImgRaw im
int xb
int yb
int channel
int fontnum
float points
SV* str_sv
int align
int utf8
char* flags
PREINIT:
char *str;
STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
RETVAL = i_t1_cp(im, xb,yb,channel,fontnum,points,str,len,align,
utf8,flags);
OUTPUT:
RETVAL


void
i_t1_bbox(fontnum,point,str_sv,len_ignored,utf8=0,flags="")
int fontnum
float point
SV* str_sv
int utf8
char* flags
PREINIT:
char *str;
STRLEN len;
int cords[BOUNDING_BOX_COUNT];
int i;
int rc;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
rc = i_t1_bbox(fontnum,point,str,len,cords,utf8,flags);
if (rc > 0) {
EXTEND(SP, rc);
for (i = 0; i < rc; ++i)
PUSHs(sv_2mortal(newSViv(cords[i])));
}



undef_int
i_t1_text(im,xb,yb,cl,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
Imager::ImgRaw im
int xb
int yb
Imager::Color cl
int fontnum
float points
SV* str_sv
int align
int utf8
char* flags
PREINIT:
char *str;
STRLEN len;
CODE:
#ifdef SvUTF8
if (SvUTF8(str_sv))
utf8 = 1;
#endif
str = SvPV(str_sv, len);
RETVAL = i_t1_text(im, xb,yb,cl,fontnum,points,str,len,align,
utf8,flags);
OUTPUT:
RETVAL

void
i_t1_has_chars(handle, text_sv, utf8 = 0)
int handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN len;
char *work;
int count;
int i;
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, len);
work = mymalloc(len);
count = i_t1_has_chars(handle, text, len, utf8, work);
if (GIMME_V == G_ARRAY) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
PUSHs(sv_2mortal(newSViv(work[i])));
}
}
else {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(work, count)));
}
myfree(work);

void
i_t1_face_name(handle)
int handle
PREINIT:
char name[255];
int len;
PPCODE:
len = i_t1_face_name(handle, name, sizeof(name));
if (len) {
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
}

void
i_t1_glyph_name(handle, text_sv, utf8 = 0)
int handle
SV *text_sv
int utf8
PREINIT:
char const *text;
STRLEN work_len;
size_t len;
char name[255];
PPCODE:
#ifdef SvUTF8
if (SvUTF8(text_sv))
utf8 = 1;
#endif
text = SvPV(text_sv, work_len);
len = work_len;
while (len) {
unsigned long ch;
if (utf8) {
ch = i_utf8_advance(&text, &len);
if (ch == ~0UL) {
i_push_error(0, "invalid UTF8 character");
break;
}
}
else {
ch = *text++;
--len;
}
EXTEND(SP, 1);
if (i_t1_glyph_name(handle, ch, name, sizeof(name))) {
PUSHs(sv_2mortal(newSVpv(name, 0)));
}
else {
PUSHs(&PL_sv_undef);
}
}

#endif

#ifdef HAVE_LIBTT
Expand Down
21 changes: 14 additions & 7 deletions MANIFEST
Expand Up @@ -50,16 +50,10 @@ Flines/Makefile.PL
Flines/t/t00flines.t
flip.im
font.c
fontfiles/dcr10.afm
fontfiles/dcr10.pfb
fontfiles/dodge.ttf
fontfiles/ExistenceTest.afm please edit ExistenceTest.sfd in CVS
fontfiles/ExistenceTest.pfb to change these files, edited and
fontfiles/ExistenceTest.ttf generated using pfaedit
fontfiles/ImUgly.ttf
fontfiles/NameTest.ttf test glyph_names() - see FT2/t/t10ft2.t
fontfiles/SpaceTest.afm
fontfiles/SpaceTest.pfb test bounding box with spaces in t30t1font.t
FT2/fontfiles/dodge.ttf
FT2/fontfiles/ExistenceTest.afm
FT2/fontfiles/ExistenceTest.pfb
Expand Down Expand Up @@ -181,7 +175,7 @@ lib/Imager/Font/BBox.pm
lib/Imager/Font/FreeType2.pm
lib/Imager/Font/Image.pm
lib/Imager/Font/Truetype.pm
lib/Imager/Font/Type1.pm
lib/Imager/Font/Type1.pm Compatibilty wrapper for Imager::Font::T1
lib/Imager/Font/Wrap.pm
lib/Imager/Fountain.pm
lib/Imager/Handy.pod
Expand Down Expand Up @@ -335,6 +329,19 @@ t/t94kwalitee.t Various "kwalitee" tests
t/t99thread.t Test wrt to perl threads
t/tr18561.t Regression tests
t/tr18561b.t
T1/fontfiles/dcr10.afm
T1/fontfiles/dcr10.pfb
T1/fontfiles/ExistenceTest.afm please edit ExistenceTest.sfd in CVS
T1/fontfiles/ExistenceTest.pfb to change these files, edited and
T1/fontfiles/SpaceTest.afm test bounding box with spaces in t10type1.t
T1/fontfiles/SpaceTest.pfb
T1/imt1.c
T1/imt1.h
T1/Makefile.PL
T1/t/t10type1.t
T1/t/t20oo.t
T1/T1.pm
T1/T1.xs
tags.c
testimg/alpha16.tga 16-bit/pixel TGA with alpha "channel" RT 32926
testimg/bad1oflow.bmp 1-bit/pixel, overflow integer on 32-bit machines
Expand Down
6 changes: 6 additions & 0 deletions MANIFEST.SKIP
Expand Up @@ -14,6 +14,10 @@
^\.svn\b
/\.svn\b

# git work files
^\.git/
^(?:.*/)?\.gitignore$

# editor trash
~$
(^|/)\#.*\#$
Expand Down Expand Up @@ -58,6 +62,7 @@ Makefile\.old$
^PNG/testout/
^SGI/testout/
^TIFF/testout/
^T1/testout/

# generated from .xs
^CountColor/CountColor\.c$
Expand All @@ -70,6 +75,7 @@ Makefile\.old$
^PNG/PNG\.c$
^SGI/SGI\.c$
^TIFF/TIFF\.c$
^T1/T1\.c$

^.*/Changes$
^blib/
Expand Down
26 changes: 13 additions & 13 deletions Makefile.PL
Expand Up @@ -597,19 +597,19 @@ sub init {
# should use this option instead of the 'gif' option}
# };

$formats{'T1-fonts'}={
order=>'30',
def=>'HAVE_LIBT1',
inccheck=>sub { -e catfile($_[0], 't1lib.h') },
libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
libfiles=>'-lt1',
objfiles=>'',
docs=>q{
postscript t1 fonts are scalable fonts. They can include
ligatures and kerning information and generally yield good
visual quality. We depend on libt1 to rasterize the fonts
for use in images.}
};
# $formats{'T1-fonts'}={
# order=>'30',
# def=>'HAVE_LIBT1',
# inccheck=>sub { -e catfile($_[0], 't1lib.h') },
# libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
# libfiles=>'-lt1',
# objfiles=>'',
# docs=>q{
# postscript t1 fonts are scalable fonts. They can include
# ligatures and kerning information and generally yield good
# visual quality. We depend on libt1 to rasterize the fonts
# for use in images.}
# };

$formats{'TT-fonts'}=
{
Expand Down
1 change: 1 addition & 0 deletions T1/.gitignore
@@ -0,0 +1 @@
T1.c

0 comments on commit a556912

Please sign in to comment.