Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Setups the font features.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetupFontFeatures()
        {
            if (m_fontName == null || m_fontName == "")
            {
                Enabled = false;
                return;
            }
            IRenderEngine renderer;

            if (FontHasGraphiteTables(m_fontName, false, false))
            {
                renderer = FwGrEngineClass.Create();
            }
            else
            {
                renderer = UniscribeEngineClass.Create();
            }
            renderer.WritingSystemFactory = m_wsf;
            HoldDummyGraphics hdg = new HoldDummyGraphics(m_fontName, false, false, CreateGraphics());

            renderer.InitRenderer(hdg.m_vwGraphics, m_fontFeatures);
            m_featureEngine = renderer as IRenderingFeatures;
            if (m_featureEngine == null)
            {
                Enabled = false;
                hdg.Close();
                return;
            }
            int cfid;

            m_featureEngine.GetFeatureIDs(0, null, out cfid);
            if (cfid == 0)
            {
                Enabled = false;
                hdg.Close();
                return;
            }
            if (cfid == 1)
            {
                // What if it's the dummy built-in graphite feature that we ignore?
                // Get the list of features (only 1).
                using (ArrayPtr idsM = MarshalEx.ArrayToNative(cfid, typeof(int)))
                {
                    m_featureEngine.GetFeatureIDs(cfid, idsM, out cfid);
                    int [] ids = (int[])MarshalEx.NativeToArray(idsM, cfid, typeof(int));
                    if (ids[0] == kGrLangFeature)
                    {
                        Enabled = false;
                        hdg.Close();
                        return;
                    }
                }
            }
            Enabled = true;
            hdg.Close();
        }
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Setups the font features.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void SetupFontFeatures()
        {
            CheckDisposed();

            if (string.IsNullOrEmpty(m_fontName))
            {
                Enabled          = false;
                m_isGraphiteFont = false;
                return;
            }

            using (var hdg = new HoldDummyGraphics(m_fontName, false, false, this))
            {
                IRenderEngine renderer = GraphiteEngineClass.Create();
                renderer.InitRenderer(hdg.m_vwGraphics, m_fontFeatures);
                // check if the font is a valid Graphite font
                if (!renderer.FontIsValid)
                {
                    m_isGraphiteFont = false;
                    Enabled          = false;
                    return;
                }
                renderer.WritingSystemFactory = m_wsf;
                m_isGraphiteFont = true;
                m_featureEngine  = renderer as IRenderingFeatures;
                if (m_featureEngine == null)
                {
                    Enabled = false;
                    return;
                }
                int cfid;
                m_featureEngine.GetFeatureIDs(0, null, out cfid);
                if (cfid == 0)
                {
                    Enabled = false;
                    return;
                }
                if (cfid == 1)
                {
                    // What if it's the dummy built-in graphite feature that we ignore?
                    // Get the list of features (only 1).
                    using (ArrayPtr idsM = MarshalEx.ArrayToNative <int>(cfid))
                    {
                        m_featureEngine.GetFeatureIDs(cfid, idsM, out cfid);
                        int [] ids = MarshalEx.NativeToArray <int>(idsM, cfid);
                        if (ids[0] == kGrLangFeature)
                        {
                            Enabled = false;
                            return;
                        }
                    }
                }
                Enabled = true;
            }
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Raises the click event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        /// ------------------------------------------------------------------------------------
        protected override void OnClick(EventArgs e)
        {
            var menu = components.ContextMenu("ContextMenu");
            int cfid;

            m_featureEngine.GetFeatureIDs(0, null, out cfid);

            // Get the list of features.
            using (ArrayPtr idsM = MarshalEx.ArrayToNative <int>(cfid))
            {
                m_featureEngine.GetFeatureIDs(cfid, idsM, out cfid);
                m_ids = MarshalEx.NativeToArray <int>(idsM, cfid);
            }
            m_fontFeatures = GraphiteFontFeatures.ConvertFontFeatureCodesToIds(m_fontFeatures);
            m_values       = ParseFeatureString(m_ids, m_fontFeatures);
            Debug.Assert(m_ids.Length == m_values.Length);

            for (int ifeat = 0; ifeat < m_ids.Length; ++ifeat)
            {
                int id = m_ids[ifeat];
                if (id == kGrLangFeature)
                {
                    continue;                     // Don't show Graphite built-in 'lang' feature.
                }
                string label;
                m_featureEngine.GetFeatureLabel(id, kUiCodePage, out label);
                if (label.Length == 0)
                {
                    //Create backup default string, ie, "Feature #1".
                    label = string.Format(FwCoreDlgControls.kstidFeature, id);
                }
                int    cValueIds;
                int    nDefault;
                int [] valueIds;
                using (ArrayPtr valueIdsM = MarshalEx.ArrayToNative <int>(kMaxValPerFeat))
                {
                    m_featureEngine.GetFeatureValues(id, kMaxValPerFeat, valueIdsM,
                                                     out cValueIds, out nDefault);
                    valueIds = MarshalEx.NativeToArray <int>(valueIdsM, cValueIds);
                }
                // If we know a value for this feature, use it. Otherwise init to default.
                int featureValue = nDefault;
                if (m_values[ifeat] != Int32.MaxValue)
                {
                    featureValue = m_values[ifeat];
                }

                // Decide whether to just use a check mark, or have a submenu. Default is sub.
                bool fBinary = false;
                if (cValueIds == 2 &&
                    (valueIds[0] == 0 || valueIds[1] == 0) &&
                    valueIds[0] + valueIds[1] == 1)
                {
                    // Minimum requirement is that there are two states and the values have
                    // ids of 0 and 1. We further require that the actual values belong to a
                    // natural boolean set.
                    string valueLabelT;                     // Label corresponding to 'true' etc, the checked value
                    m_featureEngine.GetFeatureValueLabel(id, 1, kUiCodePage, out valueLabelT);
                    string valueLabelF;                     // Label corresponding to 'false' etc, the unchecked val.
                    m_featureEngine.GetFeatureValueLabel(id, 0, kUiCodePage, out valueLabelF);

                    // Enhance: these should be based on a resource, or something that depends
                    // on the code page, if the code page is ever not constant.
                    switch (valueLabelT.ToLowerInvariant())
                    {
                    case "true":
                    case "yes":
                    case "on":
                    case "":
                    {
                        switch (valueLabelF.ToLowerInvariant())
                        {
                        case "false":
                        case "no":
                        case "off":
                        case "":
                            fBinary = true;
                            break;
                        }
                    }
                    break;
                    }
                }
                if (fBinary)
                {
                    FontFeatureMenuItem item = new FontFeatureMenuItem(label, ifeat, this);
                    item.Checked = featureValue == 1;
                    menu.MenuItems.Add(item);
                }
                else if (cValueIds > 0)
                {
                    FontFeatureMenuItem menuSub = new FontFeatureMenuItem(label, ifeat, this);
                    for (int ival = 0; ival < valueIds.Length; ++ival)
                    {
                        string valueLabel;
                        m_featureEngine.GetFeatureValueLabel(id, valueIds[ival],
                                                             kUiCodePage, out valueLabel);
                        if (valueLabel.Length == 0)
                        {
                            // Create backup default string.
                            valueLabel = string.Format(FwCoreDlgControls.kstidFeatureValue,
                                                       valueIds[ival]);
                        }
                        FontFeatureMenuItem itemSub =
                            new FontFeatureMenuItem(valueLabel, valueIds[ival], this);
                        itemSub.Checked = valueIds[ival] == featureValue;
                        menuSub.MenuItems.Add(itemSub);
                    }
                    menu.MenuItems.Add(menuSub);
                }
                //				if (fBinary)
                //				{
                //					...
                //					Assert(vnMenuMap.Size() == cItems);
                //					vnMenuMap.Push((ifeat << 16) | 0x0000FFFF);
                //					cItems++;
                //				}
                //				else if (cn > 0)
                //				{
                //					Assert(cn < 0x0000FFFF);
                //					HMENU hmenuSub = ::CreatePopupMenu();
                //					::AppendMenu(hmenu, MF_POPUP, (UINT_PTR)hmenuSub, strFeat.Chars());
                //					for (int in = 0; in < cn; in++)
                //					{
                //
                //						Assert(vnMenuMap.Size() == cItems);
                //						vnMenuMap.Push((ifeat << 16) | in);
                //						cItems++;
                //					}
                //				}
                //				else
                //				}
            }
            menu.Show(this, new Point(0, Height));
        }
Exemplo n.º 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Setups the font features.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void SetupFontFeatures()
		{
			CheckDisposed();

			if (string.IsNullOrEmpty(m_fontName))
			{
				Enabled = false;
				m_isGraphiteFont = false;
				return;
			}

			using (var hdg = new HoldDummyGraphics(m_fontName, false, false, this))
			{
				IRenderEngine renderer = GraphiteEngineClass.Create();
				renderer.InitRenderer(hdg.m_vwGraphics, m_fontFeatures);
				// check if the font is a valid Graphite font
				if (!renderer.FontIsValid)
				{
					m_isGraphiteFont = false;
					Enabled = false;
					return;
				}
				renderer.WritingSystemFactory = m_wsf;
				m_isGraphiteFont = true;
				m_featureEngine = renderer as IRenderingFeatures;
				if (m_featureEngine == null)
				{
					Enabled = false;
					return;
				}
				int cfid;
				m_featureEngine.GetFeatureIDs(0, null, out cfid);
				if (cfid == 0)
				{
					Enabled = false;
					return;
				}
				if (cfid == 1)
				{
					// What if it's the dummy built-in graphite feature that we ignore?
					// Get the list of features (only 1).
					using (ArrayPtr idsM = MarshalEx.ArrayToNative<int>(cfid))
					{
						m_featureEngine.GetFeatureIDs(cfid, idsM, out cfid);
						int [] ids = MarshalEx.NativeToArray<int>(idsM, cfid);
						if (ids[0] == kGrLangFeature)
						{
							Enabled = false;
							return;
						}
					}
				}
				Enabled = true;
			}
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Setups the font features.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void SetupFontFeatures()
        {
            CheckDisposed();

#if __MonoCS__
            // TODO-Linux: Neither Graphite or UniscribeEngine Avaliable
            m_featureEngine = null;
            return;
#else
            if (m_fontName == null || m_fontName == "")
            {
                Enabled          = false;
                m_isGraphiteFont = false;
                return;
            }
            IRenderEngine renderer;
            if (FontHasGraphiteTables(m_fontName, false, false))
            {
                renderer         = FwGrEngineClass.Create();
                m_isGraphiteFont = true;
            }
            else
            {
                renderer         = UniscribeEngineClass.Create();
                m_isGraphiteFont = false;
            }
            renderer.WritingSystemFactory = m_wsf;
            using (HoldDummyGraphics hdg = new HoldDummyGraphics(m_fontName, false, false, this))
            {
                renderer.InitRenderer(hdg.m_vwGraphics, m_fontFeatures);
                m_featureEngine = renderer as IRenderingFeatures;
                if (m_featureEngine == null)
                {
                    Enabled = false;
                    return;
                }
                int cfid;
                m_featureEngine.GetFeatureIDs(0, null, out cfid);
                if (cfid == 0)
                {
                    Enabled = false;
                    return;
                }
                if (cfid == 1)
                {
                    // What if it's the dummy built-in graphite feature that we ignore?
                    // Get the list of features (only 1).
                    using (ArrayPtr idsM = MarshalEx.ArrayToNative <int>(cfid))
                    {
                        m_featureEngine.GetFeatureIDs(cfid, idsM, out cfid);
                        int [] ids = MarshalEx.NativeToArray <int>(idsM, cfid);
                        if (ids[0] == kGrLangFeature)
                        {
                            Enabled = false;
                            return;
                        }
                    }
                }
                Enabled = true;
            }
#endif
        }
Exemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Setups the font features.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void SetupFontFeatures()
		{
			if (m_fontName == null || m_fontName == "")
			{
				Enabled = false;
				return;
			}
			IRenderEngine renderer;
			if (FontHasGraphiteTables(m_fontName, false, false))
				renderer = FwGrEngineClass.Create();
			else
				renderer = UniscribeEngineClass.Create();
			renderer.WritingSystemFactory = m_wsf;
			HoldDummyGraphics hdg = new HoldDummyGraphics(m_fontName, false, false, CreateGraphics());
			renderer.InitRenderer(hdg.m_vwGraphics, m_fontFeatures);
			m_featureEngine = renderer as IRenderingFeatures;
			if (m_featureEngine == null)
			{
				Enabled = false;
				hdg.Close();
				return;
			}
			int cfid;
			m_featureEngine.GetFeatureIDs(0, null, out cfid);
			if (cfid == 0)
			{
				Enabled = false;
				hdg.Close();
				return;
			}
			if (cfid == 1)
			{
				// What if it's the dummy built-in graphite feature that we ignore?
				// Get the list of features (only 1).
				using (ArrayPtr idsM = MarshalEx.ArrayToNative(cfid, typeof(int)))
				{
					m_featureEngine.GetFeatureIDs(cfid, idsM, out cfid);
					int [] ids = (int[])MarshalEx.NativeToArray(idsM, cfid, typeof(int));
					if (ids[0] == kGrLangFeature)
					{
						Enabled = false;
						hdg.Close();
						return;
					}
				}
			}
			Enabled = true;
			hdg.Close();
		}
Exemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Setups the font features.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void SetupFontFeatures()
		{
			CheckDisposed();

#if __MonoCS__
			// TODO-Linux: Neither Graphite or UniscribeEngine Avaliable
			m_featureEngine = null;
			return;
#else
			if (m_fontName == null || m_fontName == "")
			{
				Enabled = false;
				m_isGraphiteFont = false;
				return;
			}
			IRenderEngine renderer;
			if (FontHasGraphiteTables(m_fontName, false, false))
			{
				renderer = FwGrEngineClass.Create();
				m_isGraphiteFont = true;
			}
			else
			{
				renderer = UniscribeEngineClass.Create();
				m_isGraphiteFont = false;
			}
			renderer.WritingSystemFactory = m_wsf;
			using (HoldDummyGraphics hdg = new HoldDummyGraphics(m_fontName, false, false, this))
			{
			renderer.InitRenderer(hdg.m_vwGraphics, m_fontFeatures);
			m_featureEngine = renderer as IRenderingFeatures;
			if (m_featureEngine == null)
			{
				Enabled = false;
				return;
			}
			int cfid;
			m_featureEngine.GetFeatureIDs(0, null, out cfid);
			if (cfid == 0)
			{
				Enabled = false;
				return;
			}
			if (cfid == 1)
			{
				// What if it's the dummy built-in graphite feature that we ignore?
				// Get the list of features (only 1).
				using (ArrayPtr idsM = MarshalEx.ArrayToNative<int>(cfid))
				{
					m_featureEngine.GetFeatureIDs(cfid, idsM, out cfid);
					int [] ids = MarshalEx.NativeToArray<int>(idsM, cfid);
					if (ids[0] == kGrLangFeature)
					{
						Enabled = false;
						return;
					}
				}
			}
			Enabled = true;
			}
#endif
		}