public void LoadSkin() { if (!ThemeLoaded) { return; } _Theme.Color.Get(_PartyModeID, out Color); _Theme.SelColor.Get(_PartyModeID, out SelColor); X = _Theme.X; Y = _Theme.Y; if (!_ButtonText) { Z = _Theme.Z; } W = _Theme.MaxWidth; H = _Theme.FontHeight; _Align = _Theme.Align; _ResizeAlign = _Theme.ResizeAlign; Font = new CFont(_Theme.FontFamily, _Theme.FontStyle, _Theme.FontHeight); if (_Theme.Reflection.HasValue) { _ReflectionSpace = _Theme.Reflection.Value.Space; _ReflectionHeight = _Theme.Reflection.Value.Height; } Text = _Theme.Text; Selected = false; }
//* -----------------------------------------------------------------------* /// <summary>文字を表示します。</summary> /// /// <param name="locate">基準カーソル位置。</param> /// <param name="hAlign">水平位置揃え情報。</param> /// <param name="color">文字色。</param> /// <param name="text">テキスト。</param> /// <returns>フォント オブジェクト。</returns> protected CFont print(Point locate, EAlign hAlign, Color color, string text) { CFont result = danmaq.ball.misc.CMisc.create98Font(locate, hAlign, color, text); taskManager.Add(result); return(result); }
public static List <Player.NPCinfo> GetNPCList(IntPtr hProcess) { List <Player.NPCinfo> list = new List <Player.NPCinfo>(); uint num = WinAPI.ReadProcessMemoryUint(hProcess, 10323344u); num = WinAPI.ReadProcessMemoryUint(hProcess, num + 2562484); num = WinAPI.ReadProcessMemoryUint(hProcess, num); for (int i = 0; i < 257; i++) { uint num2 = WinAPI.ReadProcessMemoryUint(hProcess, (uint)((int)num + i * 4)); string text = CFont.TCVN3ToUnicode(WinAPI.ReadProcessMemoryString(hProcess, num2 + 68, 44)); uint num3 = WinAPI.ReadProcessMemoryUint(hProcess, num2 + 4); uint type = WinAPI.ReadProcessMemoryUint(hProcess, num2 + 184); uint status = WinAPI.ReadProcessMemoryUint(hProcess, num2 + 196); if (num3 != 0 && text != "") { Player.NPCinfo nPCinfo = new Player.NPCinfo(); nPCinfo.Name = text; nPCinfo.id = num3; nPCinfo.type = type; nPCinfo.status = status; list.Add(nPCinfo); } } list.OrderBy((Player.NPCinfo x) => x.Name); return(list); }
private void _UpdateTextPosition() { if (!_PositionNeedsUpdate) { return; } _CalculatedFont = new CFont(Font); _Rect = MaxRect; _PositionNeedsUpdate = false; if (_Text == "") { return; } float h = _CalculatedFont.Height; float y = Y; RectangleF bounds = CBase.Fonts.GetTextBounds(this); if (W > 0f && bounds.Width > W && bounds.Width > 0f) { float factor = W / bounds.Width; float step = h * (1 - factor); h *= factor; switch (ResizeAlign) { case EHAlignment.Top: y += step * 0.25f; break; case EHAlignment.Center: y += step * 0.50f; break; case EHAlignment.Bottom: y += step * 0.75f; break; } _CalculatedFont.Height = h; bounds = CBase.Fonts.GetTextBounds(this); } float x = X; switch (Align) { case EAlignment.Center: x = X - bounds.Width / 2; break; case EAlignment.Right: x = X - bounds.Width; break; } _Rect = new SRectF(x, y, bounds.Width, bounds.Height, Z); }
/* * Select a font. * * @param font The pointer of the font to use. */ internal static void Font_Select(CFont f) { if (f == null) { return; } g_fontCurrent = f; }
internal static bool Font_Init() { g_fontIntro = Font_LoadFile("INTRO.FNT"); g_fontNew6p = (g_config.language == (byte)Language.GERMAN) && File_Exists("new6pg.fnt") ? Font_LoadFile("new6pg.fnt") : Font_LoadFile("new6p.fnt"); g_fontNew8p = Font_LoadFile("new8p.fnt"); return(g_fontNew8p != null); }
private void BtnGeneration_Click(object sender, EventArgs e) { char[] text = EInkLib.Charset.Content; //char[] text = new char[] { '电'}; var path = MakeDir(); int fontSize = (int)NudFontSize.Value; Font font = new Font("微软雅黑", fontSize, GraphicsUnit.Pixel); CFont.WriteFont(text, text.Length, fontSize, path, font, GetBpp()); }
public static void Chat(IntPtr hWnd, string text) { text = CFont.UnicodeToTCVN3(text); char[] array = text.ToCharArray(); foreach (char lParam in array) { WinAPI.SendMessage(hWnd, Msg, 1014, lParam); } Thread.Sleep(100); WinAPI.SendMessage(hWnd, Msg, 1015, 1); }
static void Font_Unload(CFont f) { byte i; for (i = 0; i < f.count; i++) { f.chars[i].data = null; //free(f->chars[i].data); } f.chars = null; //free(f->chars); //f = null; //free(f); }
//* -----------------------------------------------------------------------* /// <summary>よゆ風固定ピッチフォントを生成します。</summary> /// /// <param name="locate">基準カーソル位置。</param> /// <param name="hAlign">水平位置揃え情報。</param> /// <param name="color">文字色。</param> /// <param name="text">テキスト。</param> /// <returns>フォント オブジェクト。</returns> public static CFont create98Font(Point locate, EAlign hAlign, Color color, string text) { CFont result = new CFont(CONTENT.texFont98, text); result.alignHorizontal = hAlign; result.alignVertical = EAlign.LeftTop; result.color = color; result.pos = new Vector2(locate.X * 8, locate.Y * 16); result.sprite = CGame.sprite; result.isDrawShadow = false; return(result); }
public static Font ToFont(this CFont font) { FontStyle style = FontStyle.Regular; if (font.Bold) { style |= FontStyle.Bold; } if (font.Italic) { style |= FontStyle.Italic; } return(new Font(font.Family, (float)font.Size, style, (GraphicsUnit)font.Unit)); }
/// <summary> /// Draws a text /// </summary> /// <param name="text">The text to be drawn</param> /// <param name="font">The texts font</param> /// <param name="x">The texts x-position</param> /// <param name="y">The texts y-position</param> /// <param name="z">The texts z-position</param> /// <param name="color">The text color</param> public static void DrawText(string text, CFont font, float x, float y, float z, SColorF color, bool allMonitors = true) { if (font.Height <= 0f || text == "") { return; } CFontStyle fontStyle = _GetFontStyle(font); float dx = x; foreach (char chr in text) { fontStyle.DrawGlyph(chr, font.Height, dx, y, z, color, allMonitors); dx += fontStyle.GetWidth(chr, font.Height); } }
public static void DrawTextReflection(string text, CFont font, float x, float y, float z, SColorF color, float rspace, float rheight) { if (font.Height <= 0f || text == "") { return; } CFontStyle fontStyle = _GetFontStyle(font); float dx = x; foreach (char chr in text) { fontStyle.DrawGlyphReflection(chr, font.Height, dx, y, z, color, rspace, rheight); dx += fontStyle.GetWidth(chr, font.Height); } }
static void Main() { const byte BPP = 4; //const Int32 MAX_WIDTH = 1872/2;//电脑屏幕分辨率没那么高,折一半 //const Int32 MAX_HEIGHT = 1404/2;//电脑屏幕分辨率没那么高,折一半 const Int32 MAX_WIDTH = 1872 * 2 / 3; //电脑屏幕分辨率没那么高,折一半 const Int32 MAX_HEIGHT = 1404 * 2 / 3; //电脑屏幕分辨率没那么高,折一半 CG.Init(EInkRender.GetValidFontSize, EInkRender.DrawText, EInkRender.MeasureText); CFont.Init(MakePath()); CUIApp.Init(BPP, MAX_WIDTH, MAX_HEIGHT, 6.227f, 4.67f); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); //Application.Run(new FontForm()); }
public static void DrawText(string text, CFont font, float x, float y, float z, SColorF color, float begin, float end) { if (font.Height <= 0f || text == "") { return; } float w = GetTextWidth(text, font); if (w <= 0f) { return; } float xStart = x + w * begin; float xEnd = x + w * end; float xCur = x; CFontStyle fontStyle = _GetFontStyle(font); foreach (char chr in text) { float w2 = fontStyle.GetWidth(chr, font.Height); float b = (xStart - xCur) / w2; if (b < 1f) { if (b < 0f) { b = 0f; } float e = (xEnd - xCur) / w2; if (e > 0f) { if (e > 1f) { e = 1f; } fontStyle.DrawGlyph(chr, font.Height, xCur, y, z, color, b, e); } } xCur += w2; } }
public static void KsTui(Client client) { Player player = client.player; uint num = WinAPI.ReadProcessMemoryUint(player.HProcess, 10323344u); num = WinAPI.ReadProcessMemoryUint(player.HProcess, num + 2562484); num = WinAPI.ReadProcessMemoryUint(player.HProcess, num); for (int i = 0; i < 257; i++) { uint num2 = WinAPI.ReadProcessMemoryUint(player.HProcess, (uint)((int)num + i * 4)); string text = CFont.TCVN3ToUnicode(WinAPI.ReadProcessMemoryString(player.HProcess, num2 + 68, 44)); uint npcId = WinAPI.ReadProcessMemoryUint(player.HProcess, num2 + 4); uint num3 = WinAPI.ReadProcessMemoryUint(player.HProcess, num2 + 196); if (text.Contains("Túi trái cây") && num3 != 0 && num3 != 5) { HookCall.ClickNpc(player.hWnd, npcId, player.Address); } } }
private static CFontStyle _GetFontStyle(CFont font) { int index = _GetFontIndex(font.Name); switch (font.Style) { case EStyle.Normal: return(_FontFamilies[index].Normal); case EStyle.Italic: return(_FontFamilies[index].Italic); case EStyle.Bold: return(_FontFamilies[index].Bold); case EStyle.BoldItalic: return(_FontFamilies[index].BoldItalic); } throw new ArgumentException("Invalid Style: " + font.Style); }
public static List <Player.Item> GetItemListChest(IntPtr hProcess) { List <Player.Item> list = new List <Player.Item>(); uint num = WinAPI.ReadProcessMemoryUint(hProcess, 268655096u); num = WinAPI.ReadProcessMemoryUint(hProcess, num + 28); num = WinAPI.ReadProcessMemoryUint(hProcess, num + 40); num = WinAPI.ReadProcessMemoryUint(hProcess, num + 748); num = WinAPI.ReadProcessMemoryUint(hProcess, num + 8); uint num2 = WinAPI.ReadProcessMemoryUint(hProcess, 8837316u); num2 = WinAPI.ReadProcessMemoryUint(hProcess, num2 + 2562524); num2 = WinAPI.ReadProcessMemoryUint(hProcess, num2); int num3 = 0; for (int i = 0; i < 257; i++) { uint num4 = WinAPI.ReadProcessMemoryUint(hProcess, (uint)((int)(num + 1152) + i * 4)); uint num5 = WinAPI.ReadProcessMemoryUint(hProcess, (uint)((int)num2 + i * 4)); string text = CFont.TCVN3ToUnicode(WinAPI.ReadProcessMemoryString(hProcess, num5 + 2420, 44)); uint num6 = WinAPI.ReadProcessMemoryUint(hProcess, num2 + 4); if (num6 != 0 && text != "") { byte[] value = WinAPI.ReadProcessMemoryArrBytes(hProcess, (uint)((int)num + (1152 + num3 * 20)), 20); int num7 = BitConverter.ToInt32(value, 4); int type = BitConverter.ToInt32(value, 8); int cot = BitConverter.ToInt32(value, 12); int hang = BitConverter.ToInt32(value, 16); num3++; Player.Item item = new Player.Item(); item.Name = text; item.id = num6; item.cot = (uint)cot; item.hang = (uint)hang; item.type = (uint)type; list.Add(item); } } return(list.OrderBy((Player.Item z) => z.Name).ToList()); }
//* ────________________________________* //* methods ───────────────────────────────-* //* -----------------------------------------------------------------------* /// <summary>初期化処理を実行します。</summary> protected override void initialize() { CGame game = CGame.instance; CSpriteManager sprite = CGame.sprite; CONTENT.setContentManager(game.Content); SpriteFont font = CONTENT.texFont98; for (int i = hudStates.Length; --i >= 0;) { CFont hud = new CFont(font); hud.nextState = hudStates[i]; hud.pos = pos[i]; hud.sprite = sprite; hud.layer = 0; hud.commitNextState(true); hud.alignHorizontal = EAlign.LeftTop; hud.alignVertical = EAlign.LeftTop; new CDrawableGameComponent(game, hud, true); } new CDrawableGameComponent(game, new CEntity(CStateFPSCalculator.instance), true); CGuideWrapper.instance.NotificationPosition = NotificationPosition.Center; }
public CText(CText text) { _PartyModeID = text._PartyModeID; _TranslationID = text._TranslationID; MaxRect = text.MaxRect; _Rect = text._Rect; _PositionNeedsUpdate = false; _Align = text._Align; _ResizeAlign = text._ResizeAlign; Font = new CFont(text.Font); //Use setter to set observer Color = text.Color; SelColor = text.SelColor; _ReflectionSpace = text._ReflectionSpace; _ReflectionHeight = text._ReflectionHeight; Text = text.Text; Visible = text.Visible; Alpha = text.Alpha; _EditMode = text._EditMode; }
/// <summary> /// Draws a black text /// </summary> /// <param name="text">The text to be drawn</param> /// <param name="font">The texts font</param> /// <param name="x">The texts x-position</param> /// <param name="y">The texts y-position</param> /// <param name="z">The texts z-position</param> public static void DrawText(string text, CFont font, float x, float y, float z) { DrawText(text, font, x, y, z, new SColorF(0f, 0f, 0f, 1f)); }
public static float GetTextWidth(string text, CFont font) { CFontStyle fontStyle = _GetFontStyle(font); return(text.Sum(chr => fontStyle.GetWidth(chr, font.Height))); }
public static float GetTextHeight(string text, CFont font) { CFontStyle fontStyle = _GetFontStyle(font); return(text == "" ? 0 : text.Select(chr => fontStyle.GetHeight(chr, font.Height)).Max()); }
public static SColorF GetOutlineColor(CFont font) { return(_FontFamilies[_GetFontIndex(font.Name)].OutlineColor); }
public static List <Player.Item> GetItemList(IntPtr hProcess) { List <Player.Item> list = new List <Player.Item>(); uint num = AddressItemLocation(hProcess); uint num2 = WinAPI.ReadProcessMemoryUint(hProcess, 8837316u); num2 = WinAPI.ReadProcessMemoryUint(hProcess, num2 + 2562524); num2 = WinAPI.ReadProcessMemoryUint(hProcess, num2); int num3 = 0; for (int i = 0; i < 257; i++) { uint num4 = (uint)(i * 4); uint num5 = WinAPI.ReadProcessMemoryUint(hProcess, num2 + num4); byte[] value = WinAPI.ReadProcessMemoryArrBytes(hProcess, num5 + 130, 216); string text = CFont.TCVN3ToUnicode(WinAPI.ReadProcessMemoryString(hProcess, num5 + 2420, 44)); uint num6 = WinAPI.ReadProcessMemoryUint(hProcess, num5 + 4); uint num7 = WinAPI.ReadProcessMemoryUint(hProcess, num5 + 8); uint soluong = WinAPI.ReadProcessMemoryUint(hProcess, num5 + 48); if (num6 == 0 || !(text != "")) { continue; } int type; int cot; int hang; while (true) { byte[] value2 = WinAPI.ReadProcessMemoryArrBytes(hProcess, (uint)((int)num + (1152 + num3 * 20)), 20); int num8 = BitConverter.ToInt32(value2, 4); type = BitConverter.ToInt32(value2, 8); cot = BitConverter.ToInt32(value2, 12); hang = BitConverter.ToInt32(value2, 16); if (num8 == num7) { break; } num3++; } num3 = 0; byte[] array = WinAPI.ReadProcessMemoryArrBytes(hProcess, num5 + 1240, 8); Player.Item item = new Player.Item(); item.Name = text.TrimEnd().Replace("ThiƠt", "Thiết"); item.id = num6; item.cot = (uint)cot; item.hang = (uint)hang; item.type = (uint)type; item.soluong = soluong; item.MTdong1 = array[0].ToString(); item.MTdong2 = array[1].ToString(); item.MTdong3 = array[2].ToString(); item.MTdong4 = array[3].ToString(); item.phuluc = array[4].ToString(); item.thanh = array[5].ToString(); item.offset = num4; item.itemdong1 = BitConverter.ToInt32(value, 6); item.itemdong2 = BitConverter.ToInt32(value, 42); item.itemdong3 = BitConverter.ToInt32(value, 78); item.itemdong4 = BitConverter.ToInt32(value, 114); item.itemdong5 = BitConverter.ToInt32(value, 150); item.itemdong6 = BitConverter.ToInt32(value, 186); item.itemdong1_O = BitConverter.ToInt32(value, 0); item.itemdong2_O = BitConverter.ToInt32(value, 36); item.itemdong3_O = BitConverter.ToInt32(value, 72); item.itemdong4_O = BitConverter.ToInt32(value, 108); item.itemdong5_O = BitConverter.ToInt32(value, 144); item.itemdong6_O = BitConverter.ToInt32(value, 180); list.Add(item); } return(list.OrderBy((Player.Item z) => z.Name).ToList()); }
public static float GetOutlineSize(CFont font) { return(_FontFamilies[_GetFontIndex(font.Name)].Outline); }
public static Font GetSystemFont(CFont font) { return(_GetFontStyle(font).GetSystemFont(font.Height)); }
internal static void Font_Uninit() { Font_Unload(g_fontIntro); g_fontIntro = null; Font_Unload(g_fontNew6p); g_fontNew6p = null; Font_Unload(g_fontNew8p); g_fontNew8p = null; }
/* * Load a font file. * * @param filename The name of the font file. * @return The pointer of the allocated memory where the file has been read. */ static CFont Font_LoadFile(string filename) { byte[] buf; CFont f; byte i; ushort start; ushort dataStart; ushort widthList; ushort lineList; if (!File_Exists(filename)) { return(null); } buf = File_ReadWholeFile(filename); if (buf[2] != 0x00 || buf[3] != 0x05) { //buf = null; //free(buf); return(null); } f = new CFont(); //(Font*) calloc(1, sizeof(Font)); start = Read_LE_UInt16(buf.AsSpan(4)); dataStart = Read_LE_UInt16(buf.AsSpan(6)); widthList = Read_LE_UInt16(buf.AsSpan(8)); lineList = Read_LE_UInt16(buf.AsSpan(12)); f.height = buf[start + 4]; f.maxWidth = buf[start + 5]; f.count = (byte)(Read_LE_UInt16(buf.AsSpan(10)) - widthList); f.chars = new FontChar[f.count]; //(FontChar*) calloc(f->count, sizeof(FontChar)); for (i = 0; i < f.chars.Length; i++) { f.chars[i] = new FontChar(); } for (i = 0; i < f.count; i++) { var fc = f.chars[i]; ushort dataOffset; byte x; byte y; fc.width = buf[widthList + i]; fc.unusedLines = buf[lineList + i * 2]; fc.usedLines = buf[lineList + i * 2 + 1]; dataOffset = Read_LE_UInt16(buf.AsSpan(dataStart + i * 2)); if (dataOffset == 0) { continue; } fc.data = new byte[fc.usedLines * fc.width]; //(uint8*) malloc(fc->usedLines* fc->width); for (y = 0; y < fc.usedLines; y++) { for (x = 0; x < fc.width; x++) { var data = buf[dataOffset + y * ((fc.width + 1) / 2) + x / 2]; if (x % 2 != 0) { data >>= 4; } fc.data[y * fc.width + x] = (byte)(data & 0xF); } } } //buf = null; //free(buf); return(f); }
private unsafe void BtnRender_Click(object sender, EventArgs e) { int fontSize = (int)NudFontSize.Value; CFont.Init(MakePath()); Bitmap image = new Bitmap(Picture.Width, Picture.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Picture.Image = image; Graphics g = Graphics.FromImage(image); g.Clear(Color.White); g.Dispose(); var text = string.Intern(Txt.Text);//弄成常量 //var text = Charset.Content; CFontInfo fontInfo; CG.GetValidFontSize((int)NudFontSize.Value, out fontInfo); CBitmap bitmap; CGraphicInits.InitBitmap(out bitmap, CPixelFormat.Format8bppIndexed, image.Width, image.Height); CTextInfo textInfo = new CTextInfo() { Start = 0, End = text.Length, Length = text.Length }; textInfo.Text = Utils.ToCharPointer(text); var modifyRect = new CRect(); var rect = new CRect() { MinX = 0, MinY = 0, MaxX = 400, MaxY = 300 }; CG.DrawText(ref bitmap, textInfo, fontInfo, rect, new CPoint() { X = 0, Y = 0 }, out modifyRect); EInkRender.DrawToBitmap(ref image, bitmap, rect); ////注意:设置负数的缩进,会有文本绘制不全的问题 //FontMargin margin = new FontMargin(); //margin.PageMarginLeft = 12; //margin.PageMarginRight = margin.PageMarginLeft; //margin.PageMarginTop = margin.PageMarginLeft; //margin.PageMarginRight = margin.PageMarginLeft; //margin.LineMarginTop = 4; //margin.LineMarginBottom = 2; //margin.MarginLeft = -2; //margin.MarginRight = -1; //margin.MarginTop = 0; //margin.MarginBottom = 0; //margin.ParagraphFirstLineMarginLeft = (short)((info.Width + margin.MarginLeft + margin.MarginRight) * 2);//空2个字符 //int startX = margin.PageMarginLeft + margin.MarginLeft; //int x = startX + margin.ParagraphFirstLineMarginLeft; //int y = margin.PageMarginTop + margin.MarginTop; //FontBitmap matrix; //int maxX = bitmap.Width - margin.PageMarginRight - margin.MarginRight - 1; //int maxY = bitmap.Height - margin.PageMarginBottom - margin.LineMarginBottom - margin.MarginBottom - 1; //int lineHeight = info.Height + margin.LineMarginTop + margin.LineMarginBottom + margin.MarginTop + margin.MarginBottom; ////注意 //for (int i = 0; i < text.Length; i++) //{ // var character = text[i]; // //强制换行 // if (character == '\n' || (character == '\r' && i < text.Length - 1) && character == '\n') // { // x = startX + margin.ParagraphFirstLineMarginLeft; // y += lineHeight; // //跳过\n // if (character == '\r') // { // i++; // } // continue; // } // if (Fonts.ePageGetFontMatrix(character, fontSize, out matrix)) // { // int width = info.Width; // //新起一行 // if (x + width > maxX) // { // x = startX; // y += lineHeight; // } // if (y > maxY) // { // break; // } // Fonts.ePageDrawFontMatrix(bitmap, x, y, matrix, info); // x += width + margin.MarginLeft + margin.MarginRight; // } //} }