📄 harfbuzz-dump.c
字号:
/* * Copyright (C) 2000, 2007 Red Hat, Inc. * * This is part of HarfBuzz, an OpenType Layout engine library. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this * software and its documentation for any purpose, provided that the * above copyright notice and the following two paragraphs appear in * all copies of this software. * * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * Red Hat Author(s): Owen Taylor, Behdad Esfahbod */#include "harfbuzz-impl.h"#include "harfbuzz-dump.h"#include "harfbuzz-gdef-private.h"#include "harfbuzz-gsub-private.h"#include "harfbuzz-gpos-private.h"#include "harfbuzz-open-private.h"#include <stdarg.h>#define DUMP(format) dump (stream, indent, format)#define DUMP1(format, arg1) dump (stream, indent, format, arg1)#define DUMP2(format, arg1, arg2) dump (stream, indent, format, arg1, arg2)#define DUMP3(format, arg1, arg2, arg3) dump (stream, indent, format, arg1, arg2, arg3)#define DUMP_FINT(strct,fld) dump (stream, indent, "<" #fld ">%d</" #fld ">\n", (strct)->fld)#define DUMP_FUINT(strct,fld) dump (stream, indent, "<" #fld ">%u</" #fld ">\n", (strct)->fld)#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)#define DUMP_USHORT_ARRAY(strct,fld,cnt) Dump_UShort_Array ((strct)->fld, cnt, #fld, stream, indent);#define DEF_DUMP(type) static void Dump_ ## type (HB_ ## type *type, FILE *stream, int indent, HB_Type hb_type)#define RECURSE(name, type, val) do { DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)#define RECURSE_NUM(name, i, type, val) do { DUMP1 ("<" #name "> <!-- %d -->\n", i); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)#define DUMP_VALUE_RECORD(val, frmt) do { DUMP ("<ValueRecord>\n"); Dump_ValueRecord (val, stream, indent + 1, hb_type, frmt); DUMP ("</ValueRecord>\n"); } while (0)static voiddo_indent (FILE *stream, int indent){ fprintf (stream, "%*s", indent * 3, "");}static voiddump (FILE *stream, int indent, const char *format, ...){ va_list list; do_indent (stream, indent); va_start (list, format); vfprintf (stream, format, list); va_end (list);}static voidDump_UShort_Array (HB_UShort *array, int count, const char *name, FILE *stream, int indent){ int i; do_indent (stream, indent); fprintf (stream, "<%s>", name); for (i = 0; i < count; i++) fprintf (stream, "%d%s", array[i], i == 0 ? "" : " "); fprintf (stream, "</%s>\n", name);}static voidPrint_Tag (HB_UInt tag, FILE *stream){ fprintf (stream, "%c%c%c%c", (unsigned char)(tag >> 24), (unsigned char)((tag >> 16) & 0xff), (unsigned char)((tag >> 8) & 0xff), (unsigned char)(tag & 0xff));}DEF_DUMP (LangSys){ int i; HB_UNUSED(hb_type); DUMP_FUINT (LangSys, LookupOrderOffset); DUMP_FUINT (LangSys, ReqFeatureIndex); DUMP_FUINT (LangSys, FeatureCount); for (i=0; i < LangSys->FeatureCount; i++) DUMP1("<FeatureIndex>%d</FeatureIndex>\n", LangSys->FeatureIndex[i]);}DEF_DUMP (ScriptTable){ int i; RECURSE (DefaultLangSys, LangSys, &ScriptTable->DefaultLangSys); DUMP_FUINT (ScriptTable, LangSysCount); for (i=0; i < ScriptTable->LangSysCount; i++) { do_indent (stream, indent); fprintf (stream, "<LangSysTag>"); Print_Tag (ScriptTable->LangSysRecord[i].LangSysTag, stream); fprintf (stream, "</LangSysTag>\n"); RECURSE_NUM (LangSys, i, LangSys, &ScriptTable->LangSysRecord[i].LangSys); }}DEF_DUMP (ScriptList){ int i; DUMP_FUINT (ScriptList, ScriptCount); for (i=0; i < ScriptList->ScriptCount; i++) { do_indent (stream, indent); fprintf (stream, "<ScriptTag>"); Print_Tag (ScriptList->ScriptRecord[i].ScriptTag, stream); fprintf (stream, "</ScriptTag>\n"); RECURSE_NUM (Script, i, ScriptTable, &ScriptList->ScriptRecord[i].Script); }}DEF_DUMP (Feature){ int i; HB_UNUSED(hb_type); DUMP_FUINT (Feature, FeatureParams); DUMP_FUINT (Feature, LookupListCount); for (i=0; i < Feature->LookupListCount; i++) DUMP1("<LookupIndex>%d</LookupIndex>\n", Feature->LookupListIndex[i]);}DEF_DUMP (MarkRecord){ HB_UNUSED(hb_type); DUMP_FUINT (MarkRecord, Class); DUMP1("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );}DEF_DUMP (MarkArray){ int i; DUMP_FUINT (MarkArray, MarkCount); for (i=0; i < MarkArray->MarkCount; i++) RECURSE_NUM (MarkRecord, i, MarkRecord, &MarkArray->MarkRecord[i]);}DEF_DUMP (FeatureList){ int i; DUMP_FUINT (FeatureList, FeatureCount); for (i=0; i < FeatureList->FeatureCount; i++) { do_indent (stream, indent); fprintf (stream, "<FeatureTag>"); Print_Tag (FeatureList->FeatureRecord[i].FeatureTag, stream); fprintf (stream, "</FeatureTag> <!-- %d -->\n", i); RECURSE_NUM (Feature, i, Feature, &FeatureList->FeatureRecord[i].Feature); }}DEF_DUMP (Coverage){ HB_UNUSED(hb_type); DUMP_FUINT (Coverage, CoverageFormat); if (Coverage->CoverageFormat == 1) { int i; DUMP_FUINT (&Coverage->cf.cf1, GlyphCount); for (i = 0; i < Coverage->cf.cf1.GlyphCount; i++) DUMP2("<Glyph>%#06x</Glyph> <!-- %d -->\n", Coverage->cf.cf1.GlyphArray[i], i); } else { int i; DUMP_FUINT (&Coverage->cf.cf2, RangeCount); for ( i = 0; i < Coverage->cf.cf2.RangeCount; i++ ) DUMP3("<Glyph>%#06x - %#06x</Glyph> <!-- %d -->\n", Coverage->cf.cf2.RangeRecord[i].Start, Coverage->cf.cf2.RangeRecord[i].End, i); }}DEF_DUMP (ClassRangeRecord){ HB_UNUSED(hb_type); DUMP_FGLYPH (ClassRangeRecord, Start); DUMP_FGLYPH (ClassRangeRecord, End); DUMP_FUINT (ClassRangeRecord, Class);}DEF_DUMP (ClassDefinition){ HB_UNUSED(hb_type); DUMP_FUINT( ClassDefinition, ClassFormat); DUMP_FUINT( ClassDefinition, loaded); if (ClassDefinition->ClassFormat == 1) { int i; HB_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1; DUMP("<ClassDefinition>\n"); DUMP_FUINT (ClassDefFormat1, StartGlyph ); DUMP_FUINT (ClassDefFormat1, GlyphCount ); for (i = 0; i < ClassDefFormat1->GlyphCount; i++) DUMP2(" <Class>%d</Class> <!-- %#06x -->", ClassDefFormat1->ClassValueArray[i], ClassDefFormat1->StartGlyph+i ); } else if (ClassDefinition->ClassFormat == 2) { int i; HB_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2; DUMP_FUINT (ClassDefFormat2, ClassRangeCount); for (i = 0; i < ClassDefFormat2->ClassRangeCount; i++) RECURSE_NUM (ClassRangeRecord, i, ClassRangeRecord, &ClassDefFormat2->ClassRangeRecord[i]); } else fprintf(stderr, "invalid class def table!!!\n");}DEF_DUMP (SubstLookupRecord){ HB_UNUSED(hb_type); DUMP_FUINT (SubstLookupRecord, SequenceIndex); DUMP_FUINT (SubstLookupRecord, LookupListIndex);}DEF_DUMP (ChainSubClassRule){ int i; DUMP_USHORT_ARRAY (ChainSubClassRule, Backtrack, ChainSubClassRule->BacktrackGlyphCount); DUMP_USHORT_ARRAY (ChainSubClassRule, Input, ChainSubClassRule->InputGlyphCount - 1); DUMP_USHORT_ARRAY (ChainSubClassRule, Lookahead, ChainSubClassRule->LookaheadGlyphCount); for (i = 0; i < ChainSubClassRule->SubstCount; i++) RECURSE_NUM (SubstLookupRecord, i, SubstLookupRecord, &ChainSubClassRule->SubstLookupRecord[i]); indent--;}DEF_DUMP (ChainSubClassSet){ int i; DUMP_FUINT( ChainSubClassSet, ChainSubClassRuleCount ); for (i = 0; i < ChainSubClassSet->ChainSubClassRuleCount; i++) RECURSE_NUM (ChainSubClassRule, i, ChainSubClassRule, &ChainSubClassSet->ChainSubClassRule[i]);}static voidDump_GSUB_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type){ HB_SingleSubst *SingleSubst = &subtable->st.gsub.single; DUMP_FUINT (SingleSubst, SubstFormat); RECURSE (Coverage, Coverage, &SingleSubst->Coverage); if (SingleSubst->SubstFormat == 1) { DUMP_FINT (&SingleSubst->ssf.ssf1, DeltaGlyphID); } else { int i; DUMP_FINT (&SingleSubst->ssf.ssf2, GlyphCount); for (i=0; i < SingleSubst->ssf.ssf2.GlyphCount; i++) DUMP2("<Substitute>%#06x</Substitute> <!-- %d -->\n", SingleSubst->ssf.ssf2.Substitute[i], i); }}DEF_DUMP (Ligature){ int i; HB_UNUSED(hb_type); DUMP_FGLYPH (Ligature, LigGlyph); DUMP_FUINT (Ligature, ComponentCount); for (i=0; i < Ligature->ComponentCount - 1; i++) DUMP1("<Component>%#06x</Component>\n", Ligature->Component[i]);}DEF_DUMP (LigatureSet){ int i; DUMP_FUINT (LigatureSet, LigatureCount); for (i=0; i < LigatureSet->LigatureCount; i++) RECURSE_NUM (Ligature, i, Ligature, &LigatureSet->Ligature[i]);}static voidDump_GSUB_Lookup_Ligature (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type){ int i; HB_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature; DUMP_FUINT (LigatureSubst, SubstFormat); RECURSE (Coverage, Coverage, &LigatureSubst->Coverage); DUMP_FUINT (LigatureSubst, LigatureSetCount); for (i=0; i < LigatureSubst->LigatureSetCount; i++) RECURSE_NUM (LigatureSet, i, LigatureSet, &LigatureSubst->LigatureSet[i]);}DEF_DUMP (ContextSubstFormat1){ HB_UNUSED(hb_type); HB_UNUSED(ContextSubstFormat1); DUMP("<!-- Not implemented!!! -->\n");}DEF_DUMP (ContextSubstFormat2){ DUMP_FUINT (ContextSubstFormat2, MaxContextLength); RECURSE (Coverage, Coverage, &ContextSubstFormat2->Coverage); RECURSE (ClassDefinition, ClassDefinition, &ContextSubstFormat2->ClassDef);}DEF_DUMP (ContextSubstFormat3){ HB_UNUSED(hb_type); HB_UNUSED(ContextSubstFormat3); DUMP("<!-- Not implemented!!! -->\n");}static voidDump_GSUB_Lookup_Context (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type){ HB_ContextSubst *ContextSubst = &subtable->st.gsub.context; DUMP_FUINT (ContextSubst, SubstFormat); switch( ContextSubst->SubstFormat ) { case 1: Dump_ContextSubstFormat1 (&ContextSubst->csf.csf1, stream, indent+2, hb_type); break; case 2: Dump_ContextSubstFormat2 (&ContextSubst->csf.csf2, stream, indent+2, hb_type); break; case 3:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -