Example #1
0
    def __WriteContent(self, dstBuffer: List[int], bitmapFont: BitmapFont) -> None:
        FormatPluginFontBasicKerningUtil.AddString(dstBuffer, bitmapFont.Name)
        FormatPluginFontBasicKerningUtil.AddEncodedUInt16(dstBuffer, bitmapFont.Size)
        FormatPluginFontBasicKerningUtil.AddEncodedUInt16(dstBuffer, bitmapFont.LineSpacingPx)
        FormatPluginFontBasicKerningUtil.AddEncodedUInt16(dstBuffer, bitmapFont.BaseLinePx)
        FormatPluginFontBasicKerningUtil.AddString(dstBuffer, bitmapFont.TextureName)
        FormatPluginFontBasicKerningUtil.AddEncodedBitmapFontType(dstBuffer, bitmapFont.FontType)

        self.__AddChars(dstBuffer, bitmapFont.Chars)
        self.__AddKernings(dstBuffer, bitmapFont.Kernings)
Example #2
0
    def Process(self, basicFont: BasicFont, outputFilename: str) -> None:

        dst = [] # type: List[int]
        offsetSize = self.__WriteHeader(dst)
        sizeOfHeader = len(dst)

        self.__WriteRanges(dst, basicFont.Ranges)
        self.__WriteRangeGlyphKernings(dst, basicFont.BasicGlyphKerning)
        self.__WriteDescription(dst, basicFont)
        FormatPluginFontBasicKerningUtil.AddString(dst, basicFont.Name)
        FormatPluginFontBasicKerningUtil.AddString(dst, basicFont.Header.PathName)

        # Write the number of bytes that were written to the extended header
        bytesWritten = len(dst) - sizeOfHeader
        FormatPluginFontBasicKerningUtil.SetUInt32(dst, offsetSize, bytesWritten)

        content = bytearray(dst)
        finalOutputFilename = '{}.{}'.format(outputFilename, 'fbk')
        IOUtil.WriteBinaryFileIfChanged(finalOutputFilename, content)