当前位置: 首页>>代码示例>>C++>>正文


C++ Glyph::SaveSpecs方法代码示例

本文整理汇总了C++中Glyph::SaveSpecs方法的典型用法代码示例。如果您正苦于以下问题:C++ Glyph::SaveSpecs方法的具体用法?C++ Glyph::SaveSpecs怎么用?C++ Glyph::SaveSpecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Glyph的用法示例。


在下文中一共展示了Glyph::SaveSpecs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProcessFace


//.........这里部分代码省略.........
		logOutput.Print("maxPixelYsize = %i\n", maxPixelYsize);
	}

	FILE* specFile = fopen(specsName.c_str(), "wt");
	if (specFile == NULL) {
		logOutput.Print("%s: %s\n", specsName.c_str(), strerror(errno));
		return false;
	}

	u32 yStep;
	if (FT_IS_SCALABLE(face)) {
		yStep = (fontHeight * face->height) / face->units_per_EM;
	} else {
		yStep = (face->height / 64);
		if (yStep == 0) {
      // some fonts do not provide a face->height, so make one up
			yStep = (5 * fontHeight) / 4;
		}
	}

	fprintf(specFile, "\n");
	fprintf(specFile, "local fontSpecs = {\n");
	fprintf(specFile, "  srcFile  = [[%s]],\n", filename.c_str());
	fprintf(specFile, "  family   = [[%s]],\n", face->family_name);
	fprintf(specFile, "  style    = [[%s]],\n", face->style_name);
	fprintf(specFile, "  yStep    = %i,\n", yStep);
	fprintf(specFile, "  height   = %i,\n", fontHeight);
	fprintf(specFile, "  xTexSize = %i,\n", xTexSize);
	fprintf(specFile, "  yTexSize = %i,\n", yTexSize);
	fprintf(specFile, "  outlineRadius = %i,\n", outlineRadius);
	fprintf(specFile, "  outlineWeight = %i,\n", outlineWeight);
	fprintf(specFile, "}\n");
	fprintf(specFile, "\n");
	fprintf(specFile, "local glyphs = {}\n");
	fprintf(specFile, "\n");

	ILuint img;
	ilGenImages(1, &img);
	if (img == 0) {
		logOutput.Print("ERROR: ilGenImages() == 0\n");
		return false;
	}
	ilBindImage(img);

	ilTexImage(xTexSize, yTexSize, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, NULL);
	ilClearColor(1.0f, 1.0f, 1.0f, 0.0f);
	ilClearImage();

	u32 xcell = 0;
	u32 ycell = 0;
	for (int g = 0; g < (int)glyphs.size(); g++) {
		Glyph* glyph = glyphs[g];
		const u32 txOffset = (xcell * xskip) + (padding + stuffing);
		const u32 tyOffset = (ycell * yskip) + (padding + stuffing);
		ilSetPixels(
								txOffset, tyOffset, 0,
				glyph->xsize, glyph->ysize, 1,
		IL_RGBA, IL_UNSIGNED_BYTE, glyph->pixels
							 );
		glyph->txn += txOffset;
		glyph->tyn += tyOffset;
		glyph->txp += txOffset;
		glyph->typ += tyOffset;
		glyph->SaveSpecs(specFile);

		if (debugLevel >= 2) {
			PrintGlyphInfo(face->glyph, g);
		}

		xcell++;
		if (xcell >= xdivs) {
			xcell = 0;
			ycell++;
		}
	}

	fprintf(specFile, "\n");
	fprintf(specFile, "fontSpecs.glyphs = glyphs\n");
	fprintf(specFile, "\n");
	fprintf(specFile, "return fontSpecs\n");
	fprintf(specFile, "\n");

	fclose(specFile);
	logOutput.Print("Saved: %s\n", specsName.c_str());

	ilEnable(IL_FILE_OVERWRITE);
	ilHint(IL_COMPRESSION_HINT, IL_USE_COMPRESSION);
	ilSetInteger(IL_PNG_INTERLACE, 0);
	ilSetString(IL_PNG_TITLE_STRING, imageName.c_str());
	ilSetString(IL_PNG_AUTHNAME_STRING, "FontTexture");
	ilSetString(IL_PNG_DESCRIPTION_STRING,
							(outlineRadius> 0) ? "outlined" : "plain");
	ilSaveImage((char*)imageName.c_str());
	ilDisable(IL_FILE_OVERWRITE);
	logOutput.Print("Saved: %s\n", imageName.c_str());

	ilDeleteImages(1, &img);

	return true;
}
开发者ID:DeadnightWarrior,项目名称:spring,代码行数:101,代码来源:FontTexture.cpp


注:本文中的Glyph::SaveSpecs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。