HPDF_Font HPDF_Type0Font_New (HPDF_MMgr mmgr, HPDF_FontDef fontdef, HPDF_Encoder encoder, HPDF_Xref xref) { HPDF_Dict font; HPDF_FontAttr attr; HPDF_CMapEncoderAttr encoder_attr; HPDF_STATUS ret = 0; HPDF_Array descendant_fonts; HPDF_PTRACE ((" HPDF_Type0Font_New\n")); font = HPDF_Dict_New (mmgr); if (!font) return NULL; font->header.obj_class |= HPDF_OSUBCLASS_FONT; /* check whether the fontdef object and the encoder object is valid. */ if (encoder->type != HPDF_ENCODER_TYPE_DOUBLE_BYTE) { HPDF_SetError(font->error, HPDF_INVALID_ENCODER_TYPE, 0); return NULL; } if (fontdef->type != HPDF_FONTDEF_TYPE_CID && fontdef->type != HPDF_FONTDEF_TYPE_TRUETYPE) { HPDF_SetError(font->error, HPDF_INVALID_FONTDEF_TYPE, 0); return NULL; } attr = HPDF_GetMem (mmgr, sizeof(HPDF_FontAttr_Rec)); if (!attr) { HPDF_Dict_Free (font); return NULL; } font->header.obj_class |= HPDF_OSUBCLASS_FONT; font->write_fn = NULL; font->free_fn = OnFree_Func; font->attr = attr; encoder_attr = (HPDF_CMapEncoderAttr)encoder->attr; HPDF_MemSet (attr, 0, sizeof(HPDF_FontAttr_Rec)); attr->writing_mode = encoder_attr->writing_mode; attr->text_width_fn = TextWidth; attr->measure_text_fn = MeasureText; attr->fontdef = fontdef; attr->encoder = encoder; attr->xref = xref; if (HPDF_Xref_Add (xref, font) != HPDF_OK) return NULL; ret += HPDF_Dict_AddName (font, "Type", "Font"); ret += HPDF_Dict_AddName (font, "BaseFont", fontdef->base_font); ret += HPDF_Dict_AddName (font, "Subtype", "Type0"); if (fontdef->type == HPDF_FONTDEF_TYPE_CID) { ret += HPDF_Dict_AddName (font, "Encoding", encoder->name); } else { attr->cmap_stream = CreateCMap (encoder, xref); if (attr->cmap_stream) { ret += HPDF_Dict_Add (font, "Encoding", attr->cmap_stream); } else return NULL; } if (ret != HPDF_OK) return NULL; descendant_fonts = HPDF_Array_New (mmgr); if (!descendant_fonts) return NULL; if (HPDF_Dict_Add (font, "DescendantFonts", descendant_fonts) != HPDF_OK) return NULL; if (fontdef->type == HPDF_FONTDEF_TYPE_CID) { attr->descendant_font = CIDFontType0_New (font, xref); attr->type = HPDF_FONT_TYPE0_CID; } else { attr->descendant_font = CIDFontType2_New (font, xref); attr->type = HPDF_FONT_TYPE0_TT; } if (!attr->descendant_font) return NULL; else if (HPDF_Array_Add (descendant_fonts, attr->descendant_font) != HPDF_OK) return NULL; return font; }
HPDF_Font HPDF_Type0Font_New (HPDF_MMgr mmgr, HPDF_FontDef fontdef, HPDF_Encoder encoder, HPDF_Xref xref) { HPDF_Dict font; HPDF_FontAttr attr; HPDF_CMapEncoderAttr encoder_attr; HPDF_STATUS ret = 0; HPDF_Array descendant_fonts; HPDF_PTRACE ((" HPDF_Type0Font_New\n")); font = HPDF_Dict_New (mmgr); if (!font) return NULL; font->header.obj_class |= HPDF_OSUBCLASS_FONT; /* check whether the fontdef object and the encoder object is valid. */ if (encoder->type != HPDF_ENCODER_TYPE_DOUBLE_BYTE) { HPDF_SetError(font->error, HPDF_INVALID_ENCODER_TYPE, 0); return NULL; } if (fontdef->type != HPDF_FONTDEF_TYPE_CID && fontdef->type != HPDF_FONTDEF_TYPE_TRUETYPE) { HPDF_SetError(font->error, HPDF_INVALID_FONTDEF_TYPE, 0); return NULL; } attr = HPDF_GetMem (mmgr, sizeof(HPDF_FontAttr_Rec)); if (!attr) { HPDF_Dict_Free (font); return NULL; } font->header.obj_class |= HPDF_OSUBCLASS_FONT; font->write_fn = NULL; font->free_fn = OnFree_Func; font->attr = attr; encoder_attr = (HPDF_CMapEncoderAttr)encoder->attr; HPDF_MemSet (attr, 0, sizeof(HPDF_FontAttr_Rec)); attr->writing_mode = encoder_attr->writing_mode; attr->text_width_fn = TextWidth; attr->measure_text_fn = MeasureText; attr->fontdef = fontdef; attr->encoder = encoder; attr->xref = xref; if (HPDF_Xref_Add (xref, font) != HPDF_OK) return NULL; ret += HPDF_Dict_AddName (font, "Type", "Font"); ret += HPDF_Dict_AddName (font, "BaseFont", fontdef->base_font); ret += HPDF_Dict_AddName (font, "Subtype", "Type0"); if (fontdef->type == HPDF_FONTDEF_TYPE_CID) { ret += HPDF_Dict_AddName (font, "Encoding", encoder->name); } else { /* * Handle the Unicode encoding, see hpdf_encoding_utf.c For some * reason, xpdf-based readers cannot deal with our cmap but work * fine when using the predefined "Identity-H" * encoding. However, text selection does not work, unless we * add a ToUnicode cmap. This CMap should also be "Identity", * but that does not work -- specifying our cmap as a stream however * does work. Who can understand that ? */ if (HPDF_StrCmp(encoder_attr->ordering, "Identity-H") == 0) { ret += HPDF_Dict_AddName (font, "Encoding", "Identity-H"); attr->cmap_stream = CreateCMap (encoder, xref); if (attr->cmap_stream) { ret += HPDF_Dict_Add (font, "ToUnicode", attr->cmap_stream); } else return NULL; } else { attr->cmap_stream = CreateCMap (encoder, xref); if (attr->cmap_stream) { ret += HPDF_Dict_Add (font, "Encoding", attr->cmap_stream); } else return NULL; } } if (ret != HPDF_OK) return NULL; descendant_fonts = HPDF_Array_New (mmgr); if (!descendant_fonts) return NULL; if (HPDF_Dict_Add (font, "DescendantFonts", descendant_fonts) != HPDF_OK) return NULL; if (fontdef->type == HPDF_FONTDEF_TYPE_CID) { attr->descendant_font = CIDFontType0_New (font, xref); attr->type = HPDF_FONT_TYPE0_CID; } else { attr->descendant_font = CIDFontType2_New (font, xref); attr->type = HPDF_FONT_TYPE0_TT; } if (!attr->descendant_font) return NULL; else if (HPDF_Array_Add (descendant_fonts, attr->descendant_font) != HPDF_OK) return NULL; return font; }
void LoadMap(ResFile ff1) { PromptTime=0; MAXOBJECT=0; memset(&fmap[0][0],0,sizeof fmap); memset(Group,0,sizeof Group); memset(&TrMap[0][0],0,sizeof TrMap); memset(&LLock[0][0],0,sizeof LLock); memset(&WLock[0][0],0,sizeof WLock); memset(&WMap[0][0],0,sizeof WMap); memset(&map[0][0],0,sizeof map); memset(NLocks,0,sizeof NLocks); BuildMode=false; for(int i=0; i<maxmap; i++) for(int j=0; j<maxmap; j++) { //map[i][j].BuildingID=65535; Mops[j][i]=65535; Died[j][i]=65535; FlyMops[j][i]=65535; //map[i][j].FlyID=65535; }; RBlockRead(ff1,&i,4); if (i!=0x1B46504D) LOutErr("Incorrect map file format."); LOADMES(ff1); RBlockRead(ff1,&msx,4); RBlockRead(ff1,&msy,4); RBlockRead(ff1,&i,4); RBlockRead(ff1,&i,4); LOADMES(ff1); for(i=0; i<msy; i++) { LOADMES(ff1); RBlockRead(ff1,&tmap[i][0],msx); }; LOADMES(ff1); LoadPackArray(ff1,&Died[0][0],65536); for(i=0; i<msx; i++)for(int j=0; j<msy; j++) { byte k=Locking[tmap[j][i]]; if(k&1) { LLock[i+1][j+1]=1; IncLock(j+1,i+1); TrMap[i+1][j+1]=1; }; //if(k&2)map[j][i].WaterLock=true; }; for(i=0; i<=msx+1; i++) { TrMap[i][0]=2; TrMap[i][msy+1]=2; LLock[i][0]=2; IncLock(0,i); LLock[i][msy+1]=2; IncLock(msy+1,i); WMap[i][0]=2; WMap[i][msy+1]=2; WLock[i][0]=2; WLock[i][msy+1]=2; WMap[i][0]=2; WMap[i][msy+2]=2; WLock[i][0]=2; WLock[i][msy+2]=2; }; for(i=0; i<msy+1; i++) { TrMap[0][i]=2; TrMap[msx+1][i]=2; LLock[0][i]=2; IncLock(i,0); LLock[msx+1][i]=2; IncLock(i,msx+1); WMap[0][i]=2; WMap[msx+1][i]=2; WLock[0][i]=2; WLock[msx+1][i]=2; WMap[0][i]=2; WMap[msx+2][i]=2; WLock[0][i]=2; WLock[msx+2][i]=2; }; //RSCRSizeX=RealLx; //RSCRSizeY=RealLy; //COPYSizeX=RealLx; //smaplx=17; //if(RSCRSizeY==768)smaplx=22; //smaply=smaplx; //smapx=COPYSizeX-(smaplx<<5)-32; //smapy=(RSCRSizeY-(smaply<<5))>>1; //smapx=7*32; //smapy=28; //smaplx=19; //smaply=19; //mapx=1; //mapy=1; //minix=32; //miniy=32; MiniMade=false; //Nsel=0; CreateResMap(); CreateWaterMap(); CreateTZones(); CreateCMap(); InitRenderMap(); };