Formatting.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
diff --git a/ChangeLog b/ChangeLog
index e5bbe83..199ed91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,25 +2,25 @@
[smooth] Sub-banding protocol revision.
- Rasterization sub-banding is utilized at large sizes while using
- rather small fixed memory pool. Indeed it is possible to make an
+ Rasterization sub-banding is utilized at large sizes while using a
+ rather small fixed memory pool. Indeed it is possible to make an
educated guess how much memory is necessary at a given size for a
- given glyph. It turns out that, for large majority of European glyphs,
- you should store about 8 times more boundary pixels than their height.
- Or, vice versa, if your memory pool can hold 800 pixels the band
- height should be 100 and you should sub-band anything larger than
- that. Should you still run out of memory, FreeType bisects the band
- but you have wasted some time. This is what has been implemented in
- FreeType since the beginning.
-
- It was overlooked, however, that the top band could grow to twice the
- default band size leading to unnecessary memory overflows there. This
- commit fixes that. Now the bands are distributed more evenly and
- cannot exceed the default size.
+ given glyph. It turns out that, for a large majority of European
+ glyphs, you should store about 8 times more boundary pixels than
+ their height. Or, vice versa, if your memory pool can hold 800
+ pixels the band height should be 100 and you should sub-band
+ anything larger than that. Should you still run out of memory,
+ FreeType bisects the band but you have wasted some time. This is
+ what has been implemented in FreeType since the beginning.
+
+ It was overlooked, however, that the top band could grow to twice
+ the default band size leading to unnecessary memory overflows there.
+ This commit fixes that. Now the bands are distributed more evenly
+ and cannot exceed the default size.
Now the magic number 8 is really suitable for rather simple European
- scripts. For complex Chinese logograms the magic number should be 13
- but that is subject for another day.
+ scripts. For complex Chinese logograms the magic number should be
+ 13 but that is subject for another day.
* src/smooth/ftgrays.c (gray_convert_glyph): Revise sub-banding
protocol.
diff --git a/include/freetype/config/ftstdlib.h b/include/freetype/config/ftstdlib.h
index 562e255..58b95a7 100644
--- a/include/freetype/config/ftstdlib.h
+++ b/include/freetype/config/ftstdlib.h
@@ -142,7 +142,8 @@
/**********************************************************************/
-#define ft_atol atol
+#define ft_atol atol
+#define ft_getenv getenv
/**********************************************************************/
diff --git a/src/base/ftinit.c b/src/base/ftinit.c
index c2dd0a7..a0a09db 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -226,6 +226,123 @@
}
+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+
+#define MAX_LENGTH 128
+
+ /*
+ * The `FREETYPE_PROPERTIES' environment variable has the following
+ * syntax form (broken here into multiple lines for better readability)
+ *
+ * <whitespace>
+ * <module-name1> ':'
+ * <property-name1> '=' <property-value1>
+ * <whitespace>
+ * <module-name2> ':'
+ * <property-name2> '=' <property-value2>
+ * ...
+ *
+ * Example:
+ *
+ * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
+ * cff:no-stem-darkening=1 \
+ * autofitter:warping=1
+ *
+ */
+
+ static void
+ ft_get_default_properties( FT_Library library )
+ {
+ const char* env;
+ const char* p;
+ const char* q;
+
+ char module_name[MAX_LENGTH + 1];
+ char property_name[MAX_LENGTH + 1];
+ char property_value[MAX_LENGTH + 1];
+
+ int i;
+
+
+ env = getenv( "FREETYPE_PROPERTIES" );
+ if ( !env )
+ return;
+
+ for ( p = env; *p; p++ )
+ {
+ module_name[0] = '\0';
+ property_name[0] = '\0';
+ property_value[0] = '\0';
+
+ /* skip leading whitespace and separators */
+ if ( *p == ' ' || *p == '\t' )
+ continue;
+
+ /* read module name, followed by `:' */
+ q = p;
+ for ( i = 0; i < MAX_LENGTH; i++ )
+ {
+ if ( !*p || *p == ':' )
+ break;
+ module_name[i] = *p++;
+ }
+ module_name[i] = '\0';
+
+ if ( !*p )
+ break;
+ if ( *p != ':' || p == q )
+ break;
+
+ /* read property name, followed by `=' */
+ q = p;
+ for ( i = 0; i < MAX_LENGTH; i++ )
+ {
+ if ( !*p || *p == '=' )
+ break;
+ property_name[i] = *p++;
+ }
+ property_name[i] = '\0';
+
+ if ( !*p )
+ break;
+ if ( *p != '=' || p == q )
+ break;
+
+ /* read property value, followed by whitespace (if any) */
+ q = p;
+ for ( i = 0; i < MAX_LENGTH; i++ )
+ {
+ if ( !*p || *p == ' ' || *p == '\t' )
+ break;
+ property_value[i] = *p++;
+ }
+ property_value[i] = '\0';
+
+ if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q )
+ break;
+
+ /* we have all data; resolve them into a call to FT_Property_Set */
+ /* if possible */
+
+ /* we completely ignore errors */
+ FT_Property_Set( library,
+ module_name,
+ property_name,
+ property_value );
+ }
+ }
+
+#else
+
+ static void
+ ft_get_default_properties( FT_Library library )
+ {
+ FT_UNUSED( library );
+ }
+
+#endif
+
+
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
@@ -256,6 +373,8 @@
else
FT_Add_Default_Modules( *alibrary );
+ ft_get_default_properties( *alibrary );
+
return error;
}
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 12df14d..0bf3ac6 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1911,7 +1911,7 @@ typedef ptrdiff_t FT_PtrDist;
min = ras.min_ey;
max_y = ras.max_ey;
- for (; min < max_y; min = max )
+ for ( ; min < max_y; min = max )
{
max = min + band_size;
if ( max > max_y )