Esempio n. 1
0
        public static FontFace LoadFont(InstalledFont installedFont, string lang, HBDirection direction, int defaultScriptCode = 0)
        {
            NativeFontFace fontFace = LoadFreeTypeFontFace(installedFont);

            SetShapingEngine(fontFace, lang, direction, defaultScriptCode);
            return(fontFace);
        }
Esempio n. 2
0
        public static FontFace LoadFont(InstalledFont installedFont, string lang, HBDirection direction, int defaultScriptCode = 0)
        {

            NativeFontFace fontFace = LoadFreeTypeFontFace(installedFont);
            SetShapingEngine(fontFace, lang, direction, defaultScriptCode);
            return fontFace;
        }
Esempio n. 3
0
        //static ActualFont LoadFont(InstalledFont installedFont,
        //    float sizeInPoints,
        //    string lang,
        //    HBDirection direction,
        //    int scriptCode)
        //{
        //    //load font from specific file

        //    NativeFontFace fontFace;
        //    //if not found
        //    //then load it
        //    byte[] fontFileContent = File.ReadAllBytes(installedFont.FontPath);
        //    int filelen = fontFileContent.Length;
        //    IntPtr unmanagedMem = Marshal.AllocHGlobal(filelen);
        //    Marshal.Copy(fontFileContent, 0, unmanagedMem, filelen);
        //    //---------------------------------------------------
        //    //convert font point size to pixel size
        //    //---------------------------------------------------
        //    //load font from memory
        //    IntPtr faceHandle = NativeMyFontsLib.MyFtNewMemoryFace(unmanagedMem, filelen);
        //    if (faceHandle != IntPtr.Zero)
        //    {

        //        //ok pass
        //        //-------------------
        //        //test change font size
        //        //NativeMyFontsLib.MyFtSetCharSize(faceHandle,
        //        //    0, //char_width in 1/64th of points, value 0 => same as height
        //        //    16 * 64,//16 pt //char_height in 1*64 of ppoints
        //        //    96,//horizontal device resolution (eg screen resolution 96 dpi)
        //        //    96);// vertical device resolution
        //        //-------------------
        //        //TODO: review here
        //        fontFace = new NativeFontFace(unmanagedMem, faceHandle, installedFont.FontName, FontStyle.Regular);
        //        fontFace.LoadFromFilename = installedFont.FontPath;
        //        ExportTypeFaceInfo exportTypeInfo = new ExportTypeFaceInfo();
        //        NativeMyFontsLib.MyFtGetFaceInfo(faceHandle, ref exportTypeInfo);
        //        fontFace.HasKerning = exportTypeInfo.hasKerning;
        //        //for shaping engine***
        //        //SetShapingEngine(fontFace,
        //        //    lang,
        //        //    defaultHbDirection,
        //        //    defaultScriptCode);

        //        //-------------------
        //        //uint glyphIndex1;
        //        //int char1 = NativeMyFontsLib.MyFtGetFirstChar(faceHandle, out glyphIndex1);
        //        //List<CharAndGlyphMap> charMap = new List<CharAndGlyphMap>();
        //        //while (char1 != 0)
        //        //{
        //        //    char c = (char)char1;
        //        //    charMap.Add(new CharAndGlyphMap(glyphIndex1, c));
        //        //    char1 = NativeMyFontsLib.MyFtGetNextChar(faceHandle, char1, out glyphIndex1);
        //        //}
        //        //-------------------

        //        //load glyph map
        //    }
        //    else
        //    {
        //        //load font error
        //        Marshal.FreeHGlobal(unmanagedMem);
        //    }

        //    //-------------------------------------------------
        //    //get font that specific size from found font face
        //    //-------------------------------------------------
        //    NativeFont nativeFont = fontFace.GetFontAtPointSize(sizeInPoints);
        //    //TODO: review here again, not hard code
        //    var fontKey = new FontKey(installedFont.FontName, sizeInPoints, FontStyle.Regular);
        //    registerFonts.Add(fontKey, nativeFont);
        //    return nativeFont;
        //}
        static void SetShapingEngine(NativeFontFace fontFace, string lang, HBDirection hb_direction, int hb_scriptcode)
        {
            ExportTypeFaceInfo exportTypeInfo = new ExportTypeFaceInfo();

            NativeMyFontsLib.MyFtSetupShapingEngine(fontFace.Handle,
                                                    lang,
                                                    lang.Length,
                                                    hb_direction,
                                                    hb_scriptcode,
                                                    ref exportTypeInfo);
            fontFace.HBFont = exportTypeInfo.hb_font;
        }
 public static FontFace LoadFont(string fontfile, string lang, HBDirection direction, int defaultScriptCode = 0)
 {
     //read font file
     OpenTypeReader openTypeReader = new OpenTypeReader();
     Typeface typeface = null;
     using (FileStream fs = new FileStream(fontfile, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         typeface = openTypeReader.Read(fs);
         if (typeface == null)
         {
             return null;
         }
     }
     //TODO:...
     //set shape engine *** 
     return new NOpenTypeFontFace(typeface, typeface.Name, fontfile);
 }
Esempio n. 5
0
 internal static void SetShapingEngine(SvgFontFace fontFace, string lang, HBDirection hb_direction, int hb_scriptcode)
 {
     ////string lang = "en";
     ////PixelFarm.Font2.NativeMyFontsLib.MyFtSetupShapingEngine(ftFaceHandle,
     ////    lang,
     ////    lang.Length,
     ////    HBDirection.HB_DIRECTION_LTR,
     ////    HBScriptCode.HB_SCRIPT_LATIN);
     //ExportTypeFaceInfo exportTypeInfo = new ExportTypeFaceInfo();
     //NativeMyFontsLib.MyFtSetupShapingEngine(fontFace.Handle,
     //    lang,
     //    lang.Length,
     //    hb_direction,
     //    hb_scriptcode,
     //    ref exportTypeInfo);
     //fontFace.HBFont = exportTypeInfo.hb_font;
 }
Esempio n. 6
0
 public static extern int MyFtSetupShapingEngine(IntPtr faceHandle, string langName,
     int langNameLen, HBDirection hbDirection, int hbScriptCode, ref ExportTypeFaceInfo exportTypeFaceInfo);
Esempio n. 7
0
 public static extern int MyFtSetupShapingEngine(IntPtr faceHandle, string langName,
                                                 int langNameLen, HBDirection hbDirection, int hbScriptCode, ref ExportTypeFaceInfo exportTypeFaceInfo);
Esempio n. 8
0
 public static FontFace LoadFont(string fontfile, string lang, HBDirection direction, int defaultScriptCode = 0)
 {
     return LoadFont(FontPreview.GetFontDetails(fontfile), lang, direction, defaultScriptCode);
 }
Esempio n. 9
0
        //static ActualFont LoadFont(InstalledFont installedFont,
        //    float sizeInPoints,
        //    string lang,
        //    HBDirection direction,
        //    int scriptCode)
        //{
        //    //load font from specific file  

        //    NativeFontFace fontFace;
        //    //if not found
        //    //then load it
        //    byte[] fontFileContent = File.ReadAllBytes(installedFont.FontPath);
        //    int filelen = fontFileContent.Length;
        //    IntPtr unmanagedMem = Marshal.AllocHGlobal(filelen);
        //    Marshal.Copy(fontFileContent, 0, unmanagedMem, filelen);
        //    //---------------------------------------------------
        //    //convert font point size to pixel size 
        //    //---------------------------------------------------
        //    //load font from memory
        //    IntPtr faceHandle = NativeMyFontsLib.MyFtNewMemoryFace(unmanagedMem, filelen);
        //    if (faceHandle != IntPtr.Zero)
        //    {

        //        //ok pass 
        //        //-------------------
        //        //test change font size
        //        //NativeMyFontsLib.MyFtSetCharSize(faceHandle,
        //        //    0, //char_width in 1/64th of points, value 0 => same as height
        //        //    16 * 64,//16 pt //char_height in 1*64 of ppoints
        //        //    96,//horizontal device resolution (eg screen resolution 96 dpi)
        //        //    96);// vertical device resolution  
        //        //------------------- 
        //        //TODO: review here
        //        fontFace = new NativeFontFace(unmanagedMem, faceHandle, installedFont.FontName, FontStyle.Regular);
        //        fontFace.LoadFromFilename = installedFont.FontPath;
        //        ExportTypeFaceInfo exportTypeInfo = new ExportTypeFaceInfo();
        //        NativeMyFontsLib.MyFtGetFaceInfo(faceHandle, ref exportTypeInfo);
        //        fontFace.HasKerning = exportTypeInfo.hasKerning;
        //        //for shaping engine***
        //        //SetShapingEngine(fontFace,
        //        //    lang,
        //        //    defaultHbDirection,
        //        //    defaultScriptCode);

        //        //------------------- 
        //        //uint glyphIndex1;
        //        //int char1 = NativeMyFontsLib.MyFtGetFirstChar(faceHandle, out glyphIndex1);
        //        //List<CharAndGlyphMap> charMap = new List<CharAndGlyphMap>(); 
        //        //while (char1 != 0)
        //        //{
        //        //    char c = (char)char1;
        //        //    charMap.Add(new CharAndGlyphMap(glyphIndex1, c));
        //        //    char1 = NativeMyFontsLib.MyFtGetNextChar(faceHandle, char1, out glyphIndex1);
        //        //}
        //        //------------------- 

        //        //load glyph map
        //    }
        //    else
        //    {
        //        //load font error
        //        Marshal.FreeHGlobal(unmanagedMem);
        //    }

        //    //-------------------------------------------------
        //    //get font that specific size from found font face
        //    //-------------------------------------------------
        //    NativeFont nativeFont = fontFace.GetFontAtPointSize(sizeInPoints);
        //    //TODO: review here again, not hard code
        //    var fontKey = new FontKey(installedFont.FontName, sizeInPoints, FontStyle.Regular);
        //    registerFonts.Add(fontKey, nativeFont);
        //    return nativeFont;
        //}
        static void SetShapingEngine(NativeFontFace fontFace, string lang, HBDirection hb_direction, int hb_scriptcode)
        {
            ExportTypeFaceInfo exportTypeInfo = new ExportTypeFaceInfo();
            NativeMyFontsLib.MyFtSetupShapingEngine(fontFace.Handle,
               lang,
               lang.Length,
               hb_direction,
               hb_scriptcode,
               ref exportTypeInfo);
            fontFace.HBFont = exportTypeInfo.hb_font;
        }
Esempio n. 10
0
 public static FontFace LoadFont(string fontfile, string lang, HBDirection direction, int defaultScriptCode = 0)
 {
     return(LoadFont(FontPreview.GetFontDetails(fontfile), lang, direction, defaultScriptCode));
 }
Esempio n. 11
0
 public static FontFace LoadFont(string fontfile, string lang, HBDirection direction, int defaultScriptCode = 0)
 {
     throw new NotSupportedException();
     //return LoadFont(FontPreview.GetFontDetails(fontfile), lang, direction, defaultScriptCode);
 }