aboutsummaryrefslogtreecommitdiff
path: root/graphics/crystalspace
diff options
context:
space:
mode:
authorJoe Marcus Clarke <marcus@FreeBSD.org>2006-10-14 08:54:54 +0000
committerJoe Marcus Clarke <marcus@FreeBSD.org>2006-10-14 08:54:54 +0000
commit29747f458a1eb2ce23b4594b09d0256dd62760b8 (patch)
tree1b71ba5d9ffdd308b6c18130f7c116f5bab5dc12 /graphics/crystalspace
parent7aad84f808b93baa6a7077ce0b47573b9c4c79a0 (diff)
downloadports-29747f458a1eb2ce23b4594b09d0256dd62760b8.tar.gz
ports-29747f458a1eb2ce23b4594b09d0256dd62760b8.zip
Notes
Diffstat (limited to 'graphics/crystalspace')
-rw-r--r--graphics/crystalspace/files/patch-configure18
-rw-r--r--graphics/crystalspace/files/patch-plugins_font_server_freefnt2_freefnt2.cpp215
2 files changed, 233 insertions, 0 deletions
diff --git a/graphics/crystalspace/files/patch-configure b/graphics/crystalspace/files/patch-configure
new file mode 100644
index 000000000000..26e7850c443d
--- /dev/null
+++ b/graphics/crystalspace/files/patch-configure
@@ -0,0 +1,18 @@
+--- configure.orig Tue Oct 10 17:24:44 2006
++++ configure Tue Oct 10 17:29:10 2006
+@@ -39605,7 +39605,6 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <ft2build.h>
+- #include FT_INTERNAL_OBJECTS_H
+ #include FT_FREETYPE_H
+ #include FT_GLYPH_H
+ #include FT_MODULE_H
+@@ -39760,7 +39759,6 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include <ft2build.h>
+- #include FT_INTERNAL_OBJECTS_H
+ #include FT_FREETYPE_H
+ #include FT_GLYPH_H
+ #include FT_MODULE_H
diff --git a/graphics/crystalspace/files/patch-plugins_font_server_freefnt2_freefnt2.cpp b/graphics/crystalspace/files/patch-plugins_font_server_freefnt2_freefnt2.cpp
new file mode 100644
index 000000000000..ef9cf0e13fa5
--- /dev/null
+++ b/graphics/crystalspace/files/patch-plugins_font_server_freefnt2_freefnt2.cpp
@@ -0,0 +1,215 @@
+--- plugins/font/server/freefnt2/freefnt2.cpp.orig Tue Oct 10 17:29:34 2006
++++ plugins/font/server/freefnt2/freefnt2.cpp Tue Oct 10 17:36:40 2006
+@@ -29,10 +29,12 @@
+ #include "iutil/eventh.h"
+ #include "iutil/comp.h"
+ #include <ft2build.h>
+-#include FT_INTERNAL_OBJECTS_H
+ #include FT_FREETYPE_H
+ #include FT_GLYPH_H
+ #include FT_MODULE_H
++#include FT_SIZES_H
++#include FT_OUTLINE_H
++
+ #include "freefnt2.h"
+
+ CS_IMPLEMENT_PLUGIN
+@@ -370,6 +372,20 @@
+ return true;
+ }
+
++static void GridFitCbox (FT_BBox& cbox, FT_UInt& glyphW, FT_UInt& glyphH)
++{
++ /* compute the control box, and grid fit it */
++#define FT_PIX_FLOOR( x ) ( (x) & ~63 )
++#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
++ cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
++ cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
++ cbox.xMax = FT_PIX_CEIL( cbox.xMax );
++ cbox.yMax = FT_PIX_CEIL( cbox.yMax );
++
++ glyphW = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
++ glyphH = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
++}
++
+ csPtr<iDataBuffer> csFreeType2Font::GetGlyphBitmap (utf32_char c,
+ csBitmapMetrics& metrics)
+ {
+@@ -379,37 +395,65 @@
+ if ((c != CS_FONT_DEFAULT_GLYPH) && (ci == 0)) return 0;
+
+ if (server->FreetypeError (FT_Load_Glyph (face->face, ci,
+- FT_LOAD_RENDER | FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO),
++ FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO),
+ "Could not load glyph %u for %s", ci, name))
+ {
+ return 0;
+ }
+
+- int stride = (face->face->glyph->bitmap.width + 7) / 8;
++ /* Work around an FT2.2.1 issue where rendering of a glyph fails if the width
++ * or height is 0 */
++ FT_Outline* outline = &face->face->glyph->outline;
++ FT_BBox cbox;
++ FT_Outline_Get_CBox( outline, &cbox );
++ FT_UInt glyphW, glyphH;
++ GridFitCbox (cbox, glyphW, glyphH);
+ int maxrows = (size->metrics.height + 63) >> 6;
+- int bitmapsize = maxrows*stride;
+- uint8* bitmap = new uint8 [bitmapsize];
+- memset (bitmap, 0, bitmapsize);
++ int stride, bitmapsize;
++ uint8* bitmap;
++ if ((glyphW > 0) && (glyphH > 0))
++ {
++ if (server->FreetypeError (FT_Render_Glyph (face->face->glyph,
++ FT_RENDER_MODE_MONO),
++ "Could not render glyph %u for %s", ci, name))
++ {
++ return 0;
++ }
++ stride = (face->face->glyph->bitmap.width + 7) / 8;
++ bitmapsize = maxrows*stride;
++ }
++ else
++ bitmapsize = 0;
+
+ int descend = (-size->metrics.descender + 63) >> 6;;
+
+- int startrow = maxrows - (descend + face->face->glyph->bitmap_top);
+-
+- int endrow = startrow + face->face->glyph->bitmap.rows;
++ if (bitmapsize > 0)
++ {
++ int startrow = maxrows - (descend + face->face->glyph->bitmap_top);
++ int endrow = startrow + face->face->glyph->bitmap.rows;
+
+- if (startrow < 0) startrow = 0;
+- if (endrow > maxrows) endrow = maxrows;
++ if (startrow < 0) startrow = 0;
++ if (endrow > maxrows) endrow = maxrows;
+
+- int n, i;
+- for (n = 0, i = startrow; i < endrow; i++, n++)
+- memcpy (bitmap + stride*i,
+- face->face->glyph->bitmap.buffer +
+- n * face->face->glyph->bitmap.pitch,
+- MIN(stride, face->face->glyph->bitmap.pitch));
++ bitmap = new uint8 [bitmapsize];
++ memset (bitmap, 0, bitmapsize);
++ int n, i;
++ for (n = 0, i = startrow; i < endrow; i++, n++)
++ memcpy (bitmap + stride*i,
++ face->face->glyph->bitmap.buffer +
++ n * face->face->glyph->bitmap.pitch,
++ MIN(stride, face->face->glyph->bitmap.pitch));
++ metrics.width = face->face->glyph->bitmap.width;
++ metrics.left = face->face->glyph->bitmap_left;
++ }
++ else
++ {
++ bitmap = 0;
++ metrics.width = glyphW >> 6;
++ metrics.left = (FT_Int)( cbox.xMin >> 6 );
++ }
+
+- metrics.width = face->face->glyph->bitmap.width;
+ metrics.height = maxrows;
+- metrics.left = face->face->glyph->bitmap_left;
+ metrics.top = maxrows - descend;
+
+ return (csPtr<iDataBuffer> (new csDataBuffer ((char*)bitmap, bitmapsize,
+@@ -425,42 +469,70 @@
+ if ((c != CS_FONT_DEFAULT_GLYPH) && (ci == 0)) return 0;
+
+ if (server->FreetypeError (FT_Load_Glyph (face->face, ci,
+- FT_LOAD_RENDER | FT_RENDER_MODE_NORMAL),
++ FT_LOAD_TARGET_NORMAL),
+ "Could not load glyph %u for %s", ci, name))
+ {
+ return 0;
+ }
+
+- if (face->face->glyph->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
+- // That's not what we want.
+- return 0;
+-
+- int stride = face->face->glyph->bitmap.width;
++ /* Work around an FT2.2.1 issue where rendering of a glyph fails if the width
++ * or height is 0 */
++ FT_Outline* outline = &face->face->glyph->outline;
++ FT_BBox cbox;
++ FT_Outline_Get_CBox( outline, &cbox );
++ FT_UInt glyphW, glyphH;
++ GridFitCbox (cbox, glyphW, glyphH);
+ int maxrows = (size->metrics.height + 63) >> 6;
+- int bitmapsize = maxrows * stride;
+- // malloc at least 1 byte (malloc 0 bytes is undefined).
+- uint8* bitmap = (bitmapsize > 0) ? new uint8 [bitmapsize] : new uint8[1];
+- memset (bitmap, 0, bitmapsize);
++ int stride, bitmapsize;
++ uint8* bitmap;
++ if ((glyphW > 0) && (glyphH > 0))
++ {
++ if (server->FreetypeError (FT_Render_Glyph (face->face->glyph,
++ FT_RENDER_MODE_NORMAL),
++ "Could not render glyph %u for %s", ci, name))
++ {
++ return 0;
++ }
++ if (face->face->glyph->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
++ {
++ // That's not what we want.
++ return 0;
++ }
++ stride = face->face->glyph->bitmap.width;
++ bitmapsize = maxrows*stride;
++ metrics.width = face->face->glyph->bitmap.width;
++ metrics.left = face->face->glyph->bitmap_left;
++ }
++ else
++ {
++ bitmapsize = 0;
++ metrics.width = glyphW >> 6;
++ metrics.left = (FT_Int)( cbox.xMin >> 6 );
++ }
+
+ int descend = (-size->metrics.descender + 63) >> 6;
+
+- int startrow = maxrows - (descend + face->face->glyph->bitmap_top);
+-
+- int endrow = startrow + face->face->glyph->bitmap.rows;
++ if (bitmapsize > 0)
++ {
++ int startrow = maxrows - (descend + face->face->glyph->bitmap_top);
++ int endrow = startrow + face->face->glyph->bitmap.rows;
+
+- if (startrow < 0) startrow = 0;
+- if (endrow > maxrows) endrow = maxrows;
++ if (startrow < 0) startrow = 0;
++ if (endrow > maxrows) endrow = maxrows;
+
+- int n, i;
+- for (n = 0, i = startrow; i < endrow; i++, n++)
+- memcpy (bitmap + stride*i,
+- face->face->glyph->bitmap.buffer +
+- n * face->face->glyph->bitmap.pitch,
+- MIN(stride, face->face->glyph->bitmap.pitch));
++ bitmap = new uint8 [bitmapsize];
++ memset (bitmap, 0, bitmapsize);
++ int n, i;
++ for (n = 0, i = startrow; i < endrow; i++, n++)
++ memcpy (bitmap + stride*i,
++ face->face->glyph->bitmap.buffer +
++ n * face->face->glyph->bitmap.pitch,
++ MIN(stride, face->face->glyph->bitmap.pitch));
++ }
++ else
++ bitmap = 0;
+
+- metrics.width = face->face->glyph->bitmap.width;
+ metrics.height = maxrows;
+- metrics.left = face->face->glyph->bitmap_left;
+ metrics.top = maxrows - descend;
+
+ return (csPtr<iDataBuffer> (new csDataBuffer ((char*)bitmap, bitmapsize,