Advertisement
TKGP

Untitled

Feb 13th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. TPF tpf2 = TPF.Read($@"{ptde}\font\english\talkfont24.tpf.bak");
  2.             TPF tpf = TPF.Read(@"D:\_E\Demon's Souls (PS3 EUR)\BLES00932\PS3_GAME\USRDIR\font\eu\talkfont24.tpf");
  3.             int tc = tpf.Textures.Count;
  4.             foreach (var tex in tpf.Textures)
  5.                 tex.Bytes = tex.Headerize();
  6.             tpf.Platform = TPF.TPFPlatform.PC;
  7.             tpf.Textures.AddRange(tpf2.Textures);
  8.  
  9.             for (int i = 0; i < tpf.Textures.Count; i++)
  10.             {
  11.                 var tex = tpf.Textures[i];
  12.                 tex.Name = $"{tex.Name.Substring(0, tex.Name.Length - 4)}{i:D4}";
  13.             }
  14.             tpf.Write($@"{ptde}\font\english\talkfont24.tpf");
  15.  
  16.             CCM ccm2 = CCM.Read($@"{ptde}\font\english\talkfont24.ccm.bak");
  17.             CCM ccm = CCM.Read(@"D:\_E\Demon's Souls (PS3 EUR)\BLES00932\PS3_GAME\USRDIR\font\eu\talkfont24.ccm");
  18.             ccm.Version = CCM.CCMVer.DarkSouls1;
  19.  
  20.             double ratio = ccm.FullWidth / (double)ccm2.FullWidth;
  21.             foreach (int code in ccm2.Glyphs.Keys)
  22.             {
  23.                 if (code > 255)
  24.                 {
  25.                     var glyph = ccm2.Glyphs[code];
  26.                     glyph.TexIndex += (short)tc;
  27.                     glyph.PreSpace = (short)Math.Round(glyph.PreSpace * ratio);
  28.                     glyph.Width = (short)Math.Round(glyph.Width * ratio);
  29.                     glyph.Advance = (short)Math.Round(glyph.Advance * ratio);
  30.                     ccm.Glyphs[code] = glyph;
  31.                 }
  32.             }
  33.  
  34.             //ccm.Unk0E = ccm2.Unk0E;
  35.             //ccm.Unk1C = ccm2.Unk1C;
  36.             ccm.Unk1D = ccm2.Unk1D;
  37.             ccm.TexCount = (byte)tpf.Textures.Count;
  38.             ccm.Write($@"{ptde}\font\english\talkfont24.ccm");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement