#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <libgen.h>
#include <ft2build.h>
#include FT_FREETYPE_H
FT_Face face;
-void
-dump_image (int pixel_size, int index)
+int
+dump_image (int pixel_size, int index, int code, int full)
{
int err = FT_Load_Glyph (face, index, FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
int i,j, size;
unsigned char *buf;
if (err)
- return;
+ return -1;
size = face->glyph->bitmap.rows * face->glyph->bitmap.width;
if (! size)
- return;
+ return -1;
buf = (unsigned char *) face->glyph->bitmap.buffer;
- printf ("(#x%02X \"P4 %d %d ",
- index, face->glyph->bitmap.width, face->glyph->bitmap.rows);
+ printf ("(#x%04X \"P4 %d %d ",
+ code, face->glyph->bitmap.width, face->glyph->bitmap.rows);
for (i = 0; i < face->glyph->bitmap.rows; i++)
for (j = 0; j < (face->glyph->bitmap.width + 7) / 8; j++)
{
printf("\\%o", buf[i * face->glyph->bitmap.pitch + j]);
}
printf ("\")\n");
+ return 0;
}
/* Format MSG by FMT and print the result to the stderr, and exit. */
int err;
int i;
int pixel_size = DEFAULT_PIXEL_SIZE;
+ FT_Uint *raw_table;
+ FT_UInt unicode_table[0x80];
+ int max_glyph_id;
if (argc != 2)
FATAL_ERROR ("%s\n", "Usage: otfimage [ X-OPTION ... ] OTF-FILE");
pixel_size = i;
}
+ for (i = 0, max_glyph_id = 0; i < 0x10000; i++)
+ if (FT_Load_Glyph (face, i, FT_LOAD_RENDER | FT_LOAD_MONOCHROME)
+
+
+ for (i = 0x0D00; i < 0x0D80; i++)
+ {
+ unicode_table[i - 0x0D00] = FT_Get_Char_Index (face, (FT_ULong) i);
+ if (unicode_table[i - 0x0D00])
+ printf ("%04X->%04X\n", i, unicode_table[i - 0x0D00]);
+ }
+
+ for (i = 0; i < 0x80; i++)
+ if (unicode_table[i])
+ dump_image (pixel_size, unicode_table[i], 0x0D00 + i, 1);
for (i = 0; i < 0x10000; i++)
- dump_image (pixel_size, i);
+ dump_image (pixel_size, i, 0x0E00 + i, 0);
+
exit (0);
}
}
static int
-setup_lookup_indices (OTF_LangSys *LangSys, OTF_FeatureList *FeatureList,
+setup_lookup_indices (OTF_LookupList *LookupList, OTF_FeatureList *FeatureList,
char *features, int *lookup_indices)
{
int i, j, n = 0;
if (*features == '*')
{
/* Consume all remaining features. */
+ /* We are sure that the last LookupCount elements of
+ lookup_indices are free to be used for this work. */
+ int *free_table = (lookup_indices + (LookupList->LookupCount
+ * FeatureList->FeatureCount));
+
+ for (i = 0; i < LookupList->LookupCount; i++)
+ free_table[i] = 0;
for (i = 0; i < FeatureList->FeatureCount; i++)
if (! feature_table[i])
{
feature = FeatureList->Feature + i;
for (j = 0; j < feature->LookupCount; j++)
- lookup_indices[n++] = feature->LookupListIndex[j];
+ free_table[feature->LookupListIndex[j]] = 1;
}
+ for (i = 0; i < LookupList->LookupCount; i++)
+ if (free_table[i])
+ lookup_indices[n++] = i;
break;
}
static int
match_chain_ids (OTF_GlyphString *gstring, int gidx, OTF_ChainRule *rule)
{
- int i, j;
+ int i = rule->BacktrackGlyphCount;
- for (i = rule->BacktrackGlyphCount, j = gidx - 1; j >= 0 && i > 0; j--)
- if (gstring->glyphs[j].glyph_id)
- i--;
if (i > 0)
- return -1;
+ {
+ int j;
- i = match_ids (gstring, j, rule->BacktrackGlyphCount, rule->Backtrack);
- if (i < 0)
- return -1;
+ for (j = gidx - 1; j >= 0; j--)
+ if (gstring->glyphs[j].glyph_id
+ && --i == 0)
+ break;
+ if (i > 0)
+ return -1;
+ if (match_ids (gstring, j, rule->BacktrackGlyphCount, rule->Backtrack)
+ < 0)
+ return -1;
+ }
gidx++;
i = match_ids (gstring, gidx, rule->InputGlyphCount - 1, rule->Input);
if (i < 0)
OTF_ClassDef *LookaheadClassDef,
OTF_ChainClassRule *rule)
{
- int i, j;
+ int i = rule->BacktrackGlyphCount;
- for (i = rule->BacktrackGlyphCount, j = gidx - 1; j >= 0 && i > 0; j--)
- if (gstring->glyphs[j].glyph_id)
- i--;
if (i > 0)
- return -1;
+ {
+ int j;
- i = match_classes (BacktrackClassDef, gstring, j,
- rule->BacktrackGlyphCount, rule->Backtrack);
- if (i < 0)
- return -1;
+ for (j = gidx - 1; j >= 0 && i > 0; j--)
+ if (gstring->glyphs[j].glyph_id
+ && i-- == 0)
+ break;
+ if (i > 0)
+ return -1;
+ if (match_classes (BacktrackClassDef, gstring, j,
+ rule->BacktrackGlyphCount, rule->Backtrack) < 0);
+ return -1;
+ }
gidx++;
i = match_classes (InputClassDef, gstring, gidx,
rule->InputGlyphCount - 1, rule->Input);
for (g = gbeg, i = 0; g < gend && i < count; g++)
if (g->glyph_id
- && get_coverage_index (coverages + i, g->glyph_id) < 0)
+ && get_coverage_index (coverages + i++, g->glyph_id) < 0)
return -1;
return (i < count ? -1 : g - gbeg);
}
match_chain_coverages (OTF_GlyphString *gstring, int gidx,
OTF_GSUB_ChainContext3 *context3)
{
- int i, j;
-
- if (gidx < context3->BacktrackGlyphCount
- || (gidx + context3->InputGlyphCount
- + context3->LookaheadGlyphCount) >= gstring->used)
- return -1;
+ int i = context3->BacktrackGlyphCount;
- for (i = context3->BacktrackGlyphCount, j = gidx - 1; j >= 0 && i > 0; j--)
- if (gstring->glyphs[j].glyph_id)
- i--;
if (i > 0)
- return -1;
+ {
+ int j;
- i = match_coverages (gstring, j, context3->BacktrackGlyphCount,
- context3->Backtrack);
- if (i < 0)
- return -1;
+ for (j = gidx - 1; j >= 0; j--)
+ if (gstring->glyphs[j].glyph_id
+ && --i == 0)
+ break;
+ if (i > 0)
+ return -1;
+ if (match_coverages (gstring, j, context3->BacktrackGlyphCount,
+ context3->Backtrack) < 0)
+ return -1;
+ }
gidx++;
- i = match_coverages (gstring, gidx, context3->InputGlyphCount - 1,
- context3->Input + 1);
- if (i < 0)
- return -1;
- gidx += i;
- i = match_coverages (gstring, gidx, context3->LookaheadGlyphCount,
- context3->LookAhead);
- if (i < 0)
+ if (context3->InputGlyphCount > 1)
+ {
+ i = match_coverages (gstring, gidx, context3->InputGlyphCount - 1,
+ context3->Input + 1);
+ if (i < 0)
+ return -1;
+ gidx += i;
+ }
+ if (match_coverages (gstring, gidx, context3->LookaheadGlyphCount,
+ context3->LookAhead) < 0)
return -1;
return 0;
}
if (gidx < rule->BacktrackGlyphCount
|| (gidx + rule->InputGlyphCount
- + rule->LookaheadGlyphCount) >= gstring->used)
+ + rule->LookaheadGlyphCount) > gstring->used)
continue;
if (match_chain_ids (gstring, gidx, rule) < 0)
continue;
if (gidx < rule->BacktrackGlyphCount
|| (gidx + rule->InputGlyphCount
- + rule->LookaheadGlyphCount) >= gstring->used)
+ + rule->LookaheadGlyphCount) > gstring->used)
continue;
if (match_chain_classes (gstring, gidx,
&context2->BacktrackClassDef,
int orig_used;
int j;
+ if (gidx < context3->BacktrackGlyphCount
+ || (gidx + context3->InputGlyphCount
+ + context3->LookaheadGlyphCount) > gstring->used)
+ return -1;
if (match_chain_coverages (gstring, gidx, context3) < 0)
continue;
orig_used = gstring->used;
if (gidx < rule->BacktrackGlyphCount
|| (gidx + rule->InputGlyphCount
- + rule->LookaheadGlyphCount) >= gstring->used)
+ + rule->LookaheadGlyphCount) > gstring->used)
continue;
for (k = 0; k < rule->BacktrackGlyphCount; k++)
if (get_class_def (&context2->BacktrackClassDef,
/* One lookup may be used by multiple features. */
lookup_indices = alloca (sizeof (int)
* gsub->LookupList.LookupCount
- * gsub->FeatureList.FeatureCount);
+ * (gsub->FeatureList.FeatureCount + 1));
if (! lookup_indices)
OTF_ERROR (OTF_ERROR_MEMORY, " feature list");
- n = setup_lookup_indices (LangSys, &gsub->FeatureList,
+ n = setup_lookup_indices (&gsub->LookupList, &gsub->FeatureList,
features, lookup_indices);
if (n < 0)
return errret;
/* One lookup may be used by multiple features. */
lookup_indices = alloca (sizeof (int)
* gpos->LookupList.LookupCount
- * gpos->FeatureList.FeatureCount);
+ * (gpos->FeatureList.FeatureCount + 1));
if (! lookup_indices)
OTF_ERROR (OTF_ERROR_MEMORY, " feature list");
- n = setup_lookup_indices (LangSys, &gpos->FeatureList,
+ n = setup_lookup_indices (&gpos->LookupList, &gpos->FeatureList,
features, lookup_indices);
if (n < 0)
return errret;