private void Init(string name) { // Get a GlyphTypeface either from a system typeface or from a // file path. if (name != null) { m_gtf = GetGlyphTypeface(name); } // If not found, look for other possible emoji fonts such as // the Firefox one. Fall back to Arial, a font available since // Windows 3.1 \o/ foreach (var f in m_fallback_fonts) { m_gtf = m_gtf ?? GetGlyphTypeface(f); } // Read the actual font data using Typography.OpenFont using (var s = m_gtf.GetFontStream()) { var r = new Typography.OpenFont.OpenFontReader(); m_openfont = r.Read(s, Typography.OpenFont.ReadFlags.Full); } // Create a layout for glyphs m_layout = new GlyphLayout(); m_layout.ScriptLang = ScriptLangs.Default; m_layout.Typeface = m_openfont; m_layout.PositionTechnique = PositionTechnique.OpenFont; m_layout.FontSizeInPoints = 0.75f; // 1 pixel #if FALSE // debug stuff var font = m_openfont; GlyphIndexList gl = new GlyphIndexList(); gl.Add(font.LookupIndex(0x1f431)); // U+1F431 CAT FACE gl.Add(font.LookupIndex(0x200d)); // U+200D ZERO WIDTH JOINER gl.Add(font.LookupIndex(0x1f453)); // U+1F453 EYEGLASSES //gl.Add(font.LookupIndex(0x1f46a)); // U+1F46A FAMILY //gl.Add(font.LookupIndex(0x1f3fe)); // U+1F3FE EMOJI MODIFIER FITZPATRICK TYPE-5 foreach (var lookup_table in font.GSUBTable.LookupList) { lookup_table.DoSubstitution(gl, 0, gl.Count); } #endif }
public ColorTypeface(string name) { m_gtf = GetGlyphTypeface(first_candidate: name); if (m_gtf == null) { return; } // Read the actual font data using Typography.OpenFont using (var s = m_gtf.GetFontStream()) { var r = new Typography.OpenFont.OpenFontReader(); m_openfont = r.Read(s, 0, Typography.OpenFont.ReadFlags.Full); } // Create a layout for glyphs m_layout = new GlyphLayout(); m_layout.ScriptLang = ScriptLangs.Default; m_layout.Typeface = m_openfont; m_layout.PositionTechnique = PositionTechnique.OpenFont; }
private void Init(string name) { m_gtf = GetGlyphTypeface(first_candidate: name); if (m_gtf == null) { return; } // Read the actual font data using Typography.OpenFont using (var s = m_gtf.GetFontStream()) { var r = new Typography.OpenFont.OpenFontReader(); m_openfont = r.Read(s, Typography.OpenFont.ReadFlags.Full); } // Create a layout for glyphs m_layout = new GlyphLayout(); m_layout.ScriptLang = ScriptLangs.Default; m_layout.Typeface = m_openfont; m_layout.PositionTechnique = PositionTechnique.OpenFont; #if FALSE // debug stuff var font = m_openfont; GlyphIndexList gl = new GlyphIndexList(); gl.Add(font.LookupIndex(0x1f431)); // U+1F431 CAT FACE gl.Add(font.LookupIndex(0x200d)); // U+200D ZERO WIDTH JOINER gl.Add(font.LookupIndex(0x1f453)); // U+1F453 EYEGLASSES //gl.Add(font.LookupIndex(0x1f46a)); // U+1F46A FAMILY //gl.Add(font.LookupIndex(0x1f3fe)); // U+1F3FE EMOJI MODIFIER FITZPATRICK TYPE-5 foreach (var lookup_table in font.GSUBTable.LookupList) { lookup_table.DoSubstitution(gl, 0, gl.Count); } #endif }