public FontHandle sceFontOpenUserFile(FontLibraryHandle FontLibraryHandle, string FileName, int Mode, uint* ErrorCode) { var FontLibrary = FontLibraries.Get(FontLibraryHandle); var FontFileStream = HleIoManager.HleIoWrapper.Open(FileName, Vfs.HleIoFlags.Read, (Vfs.SceMode)Mode); var PGF = new PGF().Load(FontFileStream); var Font = new Font(FontLibrary, PGF); *ErrorCode = 0; return Fonts.Create(Font); }
public FontHandle sceFontOpenUserMemory(FontLibraryHandle FontLibraryHandle, byte* MemoryFontAddress, int MemoryFontLength, uint* ErrorCode) { var FontLibrary = FontLibraries.Get(FontLibraryHandle); var MemoryFont = PointerUtils.PointerToByteArray(MemoryFontAddress, MemoryFontLength); var PGF = new PGF().Load(new MemoryStream(MemoryFont)); var Font = new Font(FontLibrary, PGF); *ErrorCode = 0; return Fonts.Create(Font); }
//[HlePspNotImplemented] public FontHandle sceFontOpen(FontLibraryHandle FontLibraryHandle, int Index, int Mode, uint* ErrorCode) { var FontLibrary = FontLibraries.Get(FontLibraryHandle); var FontRegistry = FontLibrary.FontRegistryList[Index]; var FontFileStream = HleIoManager.HleIoWrapper.Open("flash0:/font/" + FontRegistry.FontStyle.FileName, Vfs.HleIoFlags.Read, Vfs.SceMode.All); var PGF = new PGF().Load(FontFileStream); var Font = new Font(FontLibrary, PGF); *ErrorCode = 0; return Fonts.Create(Font); }
//public FontInfo FontInfo; public Font(FontLibrary FontLibrary, PGF PGF) { this.FontLibrary = FontLibrary; this.PGF = PGF; }
public GlyphSymbol Read(PGF PGF, int GlyphIndex) { var BitReader = new BitReader(PGF.CharData); BitReader.Position = PGF.CharPointer[GlyphIndex] * 4 * 8; this.GlyphIndex = GlyphIndex; this.UnicodeChar = (char)PGF.ReverseCharMap[GlyphIndex]; //int NextOffset = br.Position; //br.Position = NextOffset; int ShadowOffset = (int)BitReader.Position + (int)BitReader.ReadBits(14) * 8; if (GlyphType == GlyphFlags.FONT_PGF_SHADOWGLYPH) { BitReader.Position = ShadowOffset; BitReader.SkipBits(14); } this.Width = BitReader.ReadBits(7); this.Height = BitReader.ReadBits(7); this.Left = BitReader.ReadBitsSigned(7); this.Top = BitReader.ReadBitsSigned(7); this.Flags = (GlyphFlags)BitReader.ReadBits(6); if (Flags.HasFlag(GlyphFlags.FONT_PGF_CHARGLYPH)) { BitReader.SkipBits(7); var shadowId = BitReader.ReadBits(9); BitReader.SkipBits(24); if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG1)) BitReader.SkipBits(56); if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG2)) BitReader.SkipBits(56); if (!Flags.HasFlag(GlyphFlags.FONT_PGF_METRIC_FLAG3)) BitReader.SkipBits(56); this.AdvanceIndex = BitReader.ReadBits(8); } this.DataByteOffset = (uint)(BitReader.Position / 8); uint PixelIndex = 0; uint NumberOfPixels = Width * Height; bool BitmapHorizontalRows = (Flags & GlyphFlags.FONT_PGF_BMP_OVERLAY) == GlyphFlags.FONT_PGF_BMP_H_ROWS; this.Data = new byte[NumberOfPixels]; int Count; uint Value = 0; uint x, y; //Console.WriteLine(br.BitsLeft); while (PixelIndex < NumberOfPixels) { uint Code = BitReader.ReadBits(4); if (Code < 8) { Value = BitReader.ReadBits(4); Count = (int)Code + 1; } else { Count = 16 - (int)Code; } for (int n = 0; (n < Count) && (PixelIndex < NumberOfPixels); n++) { if (Code >= 8) { Value = BitReader.ReadBits(4); } if (BitmapHorizontalRows) { x = PixelIndex % Width; y = PixelIndex / Width; } else { x = PixelIndex / Height; y = PixelIndex % Height; } this.Data[x + y * Width] = (byte)((Value << 0) | (Value << 4)); PixelIndex++; } } /* for (int y = 0, n = 0; y < Height; y++) { for (int x = 0; x < Width; x++, n++) { Console.Write("{0:X1}", this.Data[n] & 0xF); //String.Format } Console.WriteLine(""); } */ //Console.WriteLine(this); return this; }
public Glyph(PGF PGF, int GlyphIndex) { this.PGF = PGF; this.GlyphIndex = GlyphIndex; }
public void TestMethod1() { var PGF = new PGF().Load("../../../TestInput/ltn0.pgf"); var Bitmap = PGF.GetGlyph('H').Face.GetBitmap(); Bitmap.Save("../../../TestOutput/test.png"); }
public Font sceFontOpen(FontLibrary FontLibrary, int Index, int Mode, uint* ErrorCode) { var FontRegistry = FontLibrary.FontRegistryList[Index]; try { var FontFileStream = HleIoManager.HleIoWrapper.Open("flash0:/font/" + FontRegistry.FontStyle.FileName, Vfs.HleIoFlags.Read, Vfs.SceMode.All); var PGF = new PGF().Load(FontFileStream); var Font = new Font(FontLibrary, PGF); *ErrorCode = 0; return Font; } catch (FileNotFoundException) { var Font = new Font(FontLibrary, new NativeFontIPGF()); *ErrorCode = 0; return Font; } }