public StringFontPair(String str, NativeFont font) { this.str = str; this.font = font; }
public override bool Equals(object o) { NativeFont f = (NativeFont)o; return(f.height == height && f.face == face && f.size == size && f.style == style); }
public override object createFont(int face, int style, int size) { NativeFont nf = new NativeFont(face, style, size, new CanvasTextFormat()); using (AutoResetEvent are = new AutoResetEvent(false)) { dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { int a = Convert.ToInt32(nf.font.FontSize * (float)scaleFactor); if (scaleFactor == 1.2f) a = (int)nf.font.FontSize; switch (size) { case 8: //com.codename1.ui.Font._fSIZE_1SMALL: a = Convert.ToInt32(nf.font.FontSize * (float)1.8 / 3 * (float)scaleFactor); break; case 16: //com.codename1.ui.Font._fSIZE_1LARGE: a = Convert.ToInt32(nf.font.FontSize * (float)3.5 / 3 * (float)scaleFactor); break; } nf.font.FontSize = a; if ((style & 2) != 0) // com.codename1.ui.Font._fSTYLE_1ITALIC { nf.font.FontStyle = FontStyle.Italic; } if ((style & 1) != 0) // com.codename1.ui.Font._fSTYLE_1BOLD { nf.font.FontWeight = FontWeights.Bold; } nf.font.WordWrapping = CanvasWordWrapping.NoWrap; are.Set(); }).AsTask().GetAwaiter().GetResult(); are.WaitOne(); } return nf; }
public override object deriveTrueTypeFont(java.lang.Object font, float size, int weight) { NativeFont fnt = (NativeFont)font; NativeFont n = new NativeFont(0, 0, 0, new CanvasTextFormat()); using (AutoResetEvent are = new AutoResetEvent(false)) { dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { n.font.FontFamily = fnt.font.FontFamily; n.font.FontSize = size; if ((weight & 1) != 0) // bold { n.font.FontWeight = FontWeights.Bold; } if ((weight & 2) != 0) // italic { n.font.FontStyle = FontStyle.Italic; } n.font.WordWrapping = CanvasWordWrapping.NoWrap; are.Set(); }).AsTask().GetAwaiter().GetResult(); are.WaitOne(); } return n; }
public override object getDefaultFont() { if (defaultFont == null) { object defaul = createFont(com.codename1.ui.Font._fFACE_1SYSTEM, com.codename1.ui.Font._fSTYLE_1PLAIN, com.codename1.ui.Font._fSIZE_1MEDIUM); defaultFont = (NativeFont)defaul; } return defaultFont; }
public override object loadTrueTypeFont(java.lang.String fontName, java.lang.String fileName) { NativeFont nf = new NativeFont(0, 0, 0, new CanvasTextFormat()); string file = nativePath(fileName); string family = toCSharp(fontName); using (AutoResetEvent are = new AutoResetEvent(false)) { dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { nf.font.FontFamily = @"res\" + file + "#" + family; nf.font.WordWrapping = CanvasWordWrapping.NoWrap; are.Set(); }).AsTask().GetAwaiter().GetResult(); are.WaitOne(); } return nf; }
public override object loadNativeFont(java.lang.String lookupStr) { string lookup = nativePath(lookupStr); string[] fonts = lookup.Split(new Char[] { ';' }); foreach (string f in fonts) { try { string[] split = f.Split(new Char[] { '-' }); String familyName = split[0]; String style = split[1]; String size = split[2]; NativeFont nf = new NativeFont(0, 0, 0, new CanvasTextFormat()); using (AutoResetEvent are = new AutoResetEvent(false)) { dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { nf.font.FontFamily = familyName; if (style.Equals("bolditalic")) { nf.font.FontWeight = FontWeights.Bold; nf.font.FontStyle = FontStyle.Italic; nf.style = 2 & 1; } else if (style.Equals("italic")) { nf.font.FontStyle = FontStyle.Italic; nf.style = 2; } else if (style.Equals("bold")) { nf.font.FontWeight = FontWeights.Bold; nf.style = 1; } nf.font.FontSize = Convert.ToInt32(size); nf.font.WordWrapping = CanvasWordWrapping.NoWrap; are.Set(); }).AsTask().GetAwaiter().GetResult(); are.WaitOne(); } return nf; } catch (Exception) { Debug.WriteLine("loadNativeFont failed"); } } return null; }
protected DrawString(DrawString p, WipeComponent pendingWipe, int translateX, int translateY) : base(p, pendingWipe) { this.x = p.x + translateX; this.y = p.y + translateY; this.str = p.str; this.font = p.font; this.color = p.color; }
public DrawString(NativeGraphics ng, WipeComponent pendingWipe, NativeFont font, string str, int x, int y) : base(ng, pendingWipe) { this.color = ng.sColor; this.x = x; this.y = y; this.str = str; this.font = font; }
public override object createFont(int face, int style, int size) { if (fontCache.ContainsKey(face | style | size)) { return fontCache[face | style | size]; } int a = 24; switch (size) { case 8: //com.codename1.ui.Font._fSIZE_1SMALL: a = 15; break; case 16: //com.codename1.ui.Font._fSIZE_1LARGE: a = 56; break; } NativeFont nf = new NativeFont(); nf.height = a; nf.systemFace = face; nf.systemSize = size; nf.systemStyle = style; using (AutoResetEvent are = new AutoResetEvent(false)) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { TextBlock tb = new TextBlock(); tb.FontSize = nf.height; tb.Text = "Xp"; tb.Measure(new Size(1000000, 1000000)); nf.actualHeight = (int)tb.ActualHeight; are.Set(); }); are.WaitOne(); } if ((style & com.codename1.ui.Font._fSTYLE_1BOLD) == com.codename1.ui.Font._fSTYLE_1BOLD) { nf.bold = true; } if ((style & com.codename1.ui.Font._fSTYLE_1ITALIC) == com.codename1.ui.Font._fSTYLE_1ITALIC) { nf.italic = true; } fontCache[face | style | size] = nf; return nf; }