From bcfe1b01b8a4dcd6d7e6a8bac6f6271f164b29f9 Mon Sep 17 00:00:00 2001 From: drochner Date: Tue, 8 Jul 2008 15:44:36 +0000 Subject: apply a fix from upstream CVS: * src/cff/cffobjs.c (cff_face_init): Compute final `dict->units_per_em' value before assigning it to `cffface->units_per_EM'. Otherwise, CFFs without subfonts are be scaled incorrectly if the font matrix is non-standard. This fixes Savannah bug #23630 This fixes the problem that text set in a font embedded as type 1C subset was rendered unreadably small. bump PKGREVISION --- graphics/freetype2/Makefile | 3 +- graphics/freetype2/distinfo | 3 +- graphics/freetype2/patches/patch-aa | 240 ++++++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 graphics/freetype2/patches/patch-aa (limited to 'graphics') diff --git a/graphics/freetype2/Makefile b/graphics/freetype2/Makefile index e6b9214babe..7f0ba057616 100644 --- a/graphics/freetype2/Makefile +++ b/graphics/freetype2/Makefile @@ -1,7 +1,8 @@ -# $NetBSD: Makefile,v 1.64 2008/06/11 10:35:21 drochner Exp $ +# $NetBSD: Makefile,v 1.65 2008/07/08 15:44:36 drochner Exp $ DISTNAME= freetype-2.3.6 PKGNAME= ${DISTNAME:S/-/2-/} +PKGREVISION= 1 CATEGORIES= graphics MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=freetype/} \ ftp://ring.aist.go.jp/pub/graphics/freetype/freetype2/ diff --git a/graphics/freetype2/distinfo b/graphics/freetype2/distinfo index 31172fa8903..c3475985d1d 100644 --- a/graphics/freetype2/distinfo +++ b/graphics/freetype2/distinfo @@ -1,5 +1,6 @@ -$NetBSD: distinfo,v 1.26 2008/06/11 10:35:21 drochner Exp $ +$NetBSD: distinfo,v 1.27 2008/07/08 15:44:36 drochner Exp $ SHA1 (freetype-2.3.6.tar.bz2) = 611bae913e8a593449a4dc60e0bf3300abc4f974 RMD160 (freetype-2.3.6.tar.bz2) = 8047e734804191856a941e19f6acf82047099d66 Size (freetype-2.3.6.tar.bz2) = 1305717 bytes +SHA1 (patch-aa) = 4876eb28e5c5ffc9db98220f9046c639f1538bb7 diff --git a/graphics/freetype2/patches/patch-aa b/graphics/freetype2/patches/patch-aa new file mode 100644 index 00000000000..29864959fef --- /dev/null +++ b/graphics/freetype2/patches/patch-aa @@ -0,0 +1,240 @@ +$NetBSD: patch-aa,v 1.13 2008/07/08 15:44:36 drochner Exp $ + +--- src/cff/cffobjs.c.orig 2008-05-13 10:30:21.000000000 +0200 ++++ src/cff/cffobjs.c +@@ -534,6 +534,111 @@ + goto Bad_Format; + } + ++ if ( !dict->units_per_em ) ++ dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM; ++ ++ /* Normalize the font matrix so that `matrix->xx' is 1; the */ ++ /* scaling is done with `units_per_em' then (at this point, */ ++ /* it already contains the scaling factor, but without */ ++ /* normalization of the matrix). */ ++ /* */ ++ /* Note that the offsets must be expressed in integer font */ ++ /* units. */ ++ ++ { ++ FT_Matrix* matrix = &dict->font_matrix; ++ FT_Vector* offset = &dict->font_offset; ++ FT_ULong* upm = &dict->units_per_em; ++ FT_Fixed temp = FT_ABS( matrix->yy ); ++ ++ ++ if ( temp != 0x10000L ) ++ { ++ *upm = FT_DivFix( *upm, temp ); ++ ++ matrix->xx = FT_DivFix( matrix->xx, temp ); ++ matrix->yx = FT_DivFix( matrix->yx, temp ); ++ matrix->xy = FT_DivFix( matrix->xy, temp ); ++ matrix->yy = FT_DivFix( matrix->yy, temp ); ++ offset->x = FT_DivFix( offset->x, temp ); ++ offset->y = FT_DivFix( offset->y, temp ); ++ } ++ ++ offset->x >>= 16; ++ offset->y >>= 16; ++ } ++ ++ for ( i = cff->num_subfonts; i > 0; i-- ) ++ { ++ CFF_FontRecDict sub = &cff->subfonts[i - 1]->font_dict; ++ CFF_FontRecDict top = &cff->top_font.font_dict; ++ ++ FT_Matrix* matrix; ++ FT_Vector* offset; ++ FT_ULong* upm; ++ FT_Fixed temp; ++ ++ ++ if ( sub->units_per_em ) ++ { ++ FT_Int scaling; ++ ++ ++ if ( top->units_per_em > 1 && sub->units_per_em > 1 ) ++ scaling = FT_MIN( top->units_per_em, sub->units_per_em ); ++ else ++ scaling = 1; ++ ++ FT_Matrix_Multiply_Scaled( &top->font_matrix, ++ &sub->font_matrix, ++ scaling ); ++ FT_Vector_Transform_Scaled( &sub->font_offset, ++ &top->font_matrix, ++ scaling ); ++ ++ sub->units_per_em = FT_MulDiv( sub->units_per_em, ++ top->units_per_em, ++ scaling ); ++ } ++ else ++ { ++ sub->font_matrix = top->font_matrix; ++ sub->font_offset = top->font_offset; ++ ++ sub->units_per_em = top->units_per_em; ++ } ++ ++ matrix = &sub->font_matrix; ++ offset = &sub->font_offset; ++ upm = &sub->units_per_em; ++ temp = FT_ABS( matrix->yy ); ++ ++ if ( temp != 0x10000L ) ++ { ++ *upm = FT_DivFix( *upm, temp ); ++ ++ /* if *upm is larger than 100*1000 we divide by 1000 -- */ ++ /* this can happen if e.g. there is no top-font FontMatrix */ ++ /* and the subfont FontMatrix already contains the complete */ ++ /* scaling for the subfont (see section 5.11 of the PLRM) */ ++ ++ /* 100 is a heuristic value */ ++ ++ if ( *upm > 100L * 1000L ) ++ *upm = ( *upm + 500 ) / 1000; ++ ++ matrix->xx = FT_DivFix( matrix->xx, temp ); ++ matrix->yx = FT_DivFix( matrix->yx, temp ); ++ matrix->xy = FT_DivFix( matrix->xy, temp ); ++ matrix->yy = FT_DivFix( matrix->yy, temp ); ++ offset->x = FT_DivFix( offset->x, temp ); ++ offset->y = FT_DivFix( offset->y, temp ); ++ } ++ ++ offset->x >>= 16; ++ offset->y >>= 16; ++ } ++ + if ( pure_cff ) + { + char* style_name = NULL; +@@ -554,8 +659,6 @@ + cffface->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFFU ) >> 16; + cffface->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFFU ) >> 16; + +- if ( !dict->units_per_em ) +- dict->units_per_em = 1000; + + cffface->units_per_EM = dict->units_per_em; + +@@ -711,114 +814,8 @@ + + cffface->style_flags = flags; + } +- else +- { +- if ( !dict->units_per_em ) +- dict->units_per_em = face->root.units_per_EM; +- } +- +- /* Normalize the font matrix so that `matrix->xx' is 1; the */ +- /* scaling is done with `units_per_em' then (at this point, */ +- /* it already contains the scaling factor, but without */ +- /* normalization of the matrix). */ +- /* */ +- /* Note that the offsets must be expressed in integer font */ +- /* units. */ +- +- { +- FT_Matrix* matrix = &dict->font_matrix; +- FT_Vector* offset = &dict->font_offset; +- FT_ULong* upm = &dict->units_per_em; +- FT_Fixed temp = FT_ABS( matrix->yy ); +- +- +- if ( temp != 0x10000L ) +- { +- *upm = FT_DivFix( *upm, temp ); +- +- matrix->xx = FT_DivFix( matrix->xx, temp ); +- matrix->yx = FT_DivFix( matrix->yx, temp ); +- matrix->xy = FT_DivFix( matrix->xy, temp ); +- matrix->yy = FT_DivFix( matrix->yy, temp ); +- offset->x = FT_DivFix( offset->x, temp ); +- offset->y = FT_DivFix( offset->y, temp ); +- } +- +- offset->x >>= 16; +- offset->y >>= 16; +- } +- +- for ( i = cff->num_subfonts; i > 0; i-- ) +- { +- CFF_FontRecDict sub = &cff->subfonts[i - 1]->font_dict; +- CFF_FontRecDict top = &cff->top_font.font_dict; +- +- FT_Matrix* matrix; +- FT_Vector* offset; +- FT_ULong* upm; +- FT_Fixed temp; + + +- if ( sub->units_per_em ) +- { +- FT_Int scaling; +- +- +- if ( top->units_per_em > 1 && sub->units_per_em > 1 ) +- scaling = FT_MIN( top->units_per_em, sub->units_per_em ); +- else +- scaling = 1; +- +- FT_Matrix_Multiply_Scaled( &top->font_matrix, +- &sub->font_matrix, +- scaling ); +- FT_Vector_Transform_Scaled( &sub->font_offset, +- &top->font_matrix, +- scaling ); +- +- sub->units_per_em = FT_MulDiv( sub->units_per_em, +- top->units_per_em, +- scaling ); +- } +- else +- { +- sub->font_matrix = top->font_matrix; +- sub->font_offset = top->font_offset; +- +- sub->units_per_em = top->units_per_em; +- } +- +- matrix = &sub->font_matrix; +- offset = &sub->font_offset; +- upm = &sub->units_per_em; +- temp = FT_ABS( matrix->yy ); +- +- if ( temp != 0x10000L ) +- { +- *upm = FT_DivFix( *upm, temp ); +- +- /* if *upm is larger than 100*1000 we divide by 1000 -- */ +- /* this can happen if e.g. there is no top-font FontMatrix */ +- /* and the subfont FontMatrix already contains the complete */ +- /* scaling for the subfont (see section 5.11 of the PLRM) */ +- +- /* 100 is a heuristic value */ +- +- if ( *upm > 100L * 1000L ) +- *upm = ( *upm + 500 ) / 1000; +- +- matrix->xx = FT_DivFix( matrix->xx, temp ); +- matrix->yx = FT_DivFix( matrix->yx, temp ); +- matrix->xy = FT_DivFix( matrix->xy, temp ); +- matrix->yy = FT_DivFix( matrix->yy, temp ); +- offset->x = FT_DivFix( offset->x, temp ); +- offset->y = FT_DivFix( offset->y, temp ); +- } +- +- offset->x >>= 16; +- offset->y >>= 16; +- } +- + #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES + /* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */ + /* has unset this flag because of the 3.0 `post' table. */ -- cgit v1.2.3