public static void Run()
        {
            // ExStart:ReceiveNotificationsOfFonts 
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); 

            Document doc = new Document(dataDir + "Rendering.doc");

            FontSettings FontSettings = new FontSettings();          

            // We can choose the default font to use in the case of any missing fonts.
            FontSettings.DefaultFontName = "Arial";
            // For testing we will set Aspose.Words to look for fonts only in a folder which doesn't exist. Since Aspose.Words won't
            // Find any fonts in the specified directory, then during rendering the fonts in the document will be subsuited with the default
            // Font specified under FontSettings.DefaultFontName. We can pick up on this subsuition using our callback.
            FontSettings.SetFontsFolder(string.Empty, false);

            // Create a new class implementing IWarningCallback which collect any warnings produced during document save.
            HandleDocumentWarnings callback = new HandleDocumentWarnings();

            doc.WarningCallback = callback;
            // Set font settings
            doc.FontSettings = FontSettings;
            string path = dataDir + "Rendering.MissingFontNotification_out.pdf";
            // Pass the save options along with the save path to the save method.
            doc.Save(path);
            // ExEnd:ReceiveNotificationsOfFonts 
            Console.WriteLine("\nReceive notifications of font substitutions by using IWarningCallback processed.\nFile saved at " + path);

            ReceiveWarningNotification(doc, dataDir);
        }
        public static void Run()
        {
            // ExStart:SetFontsFoldersSystemAndCustomFolder
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); 

            Document doc = new Document(dataDir + "Rendering.doc");
            FontSettings FontSettings = new FontSettings();

            // Retrieve the array of environment-dependent font sources that are searched by default. For example this will contain a "Windows\Fonts\" source on a Windows machines.
            // We add this array to a new ArrayList to make adding or removing font entries much easier.
            ArrayList fontSources = new ArrayList(FontSettings.GetFontsSources());

            // Add a new folder source which will instruct Aspose.Words to search the following folder for fonts.
            FolderFontSource folderFontSource = new FolderFontSource("C:\\MyFonts\\", true);

            // Add the custom folder which contains our fonts to the list of existing font sources.
            fontSources.Add(folderFontSource);

            // Convert the Arraylist of source back into a primitive array of FontSource objects.
            FontSourceBase[] updatedFontSources = (FontSourceBase[])fontSources.ToArray(typeof(FontSourceBase));
            
            // Apply the new set of font sources to use.
            FontSettings.SetFontsSources(updatedFontSources);
            // Set font settings
            doc.FontSettings = FontSettings;
            dataDir = dataDir + "Rendering.SetFontsFolders_out.pdf";
            doc.Save(dataDir);
            // ExEnd:SetFontsFoldersSystemAndCustomFolder 
            Console.WriteLine("\nFonts system and coustom folder is setup.\nFile saved at " + dataDir);
                     
        }
Пример #3
0
        public static void SetBackgroundGradient(
            StyleSet classStyleSet,
            Color backgroundGradientColor, 
            Color backgroundSelectedGradientColor, 
            Color backgroundSelectedInactiveGradientColor,
            Diagram diagram,
            string surfaceTitle)
        {
            #region Set background gradient style and shape attributes

            // Fill brush settings for background (Start gradient color).
            BrushSettings backgroundBrush = new BrushSettings();
            backgroundBrush.Color = backgroundGradientColor;
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackground, backgroundBrush);
            // Selected state
            backgroundBrush = new BrushSettings();
            backgroundBrush.Color = backgroundSelectedGradientColor;            
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelected, backgroundBrush);
            // SelectedInactive state
            backgroundBrush = new BrushSettings();
            backgroundBrush.Color = backgroundSelectedInactiveGradientColor;
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelectedInactive, backgroundBrush);
            
            // We should find a "Background" field created when we set the 
            // HasBackgroundGradient property to "true"
            AreaField background = diagram.FindShapeField("Background") as AreaField;
            if (background != null)
            {
                background.DefaultReflectParentSelectedState = true;
                //background.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, diagram.MaximumSize.Height / 2);
            }

            #endregion

            #region Set Diagram font and text attributes

            // Custom font styles for diagram title
            FontSettings fontSettings;
            fontSettings = new FontSettings();
            fontSettings.Style = FontStyle.Bold;
            fontSettings.Size = 9 / 72.0F;
            classStyleSet.OverrideFont(DiagramFonts.ShapeTitle, fontSettings);

            // Create a text field for the Diagram Title
            TextField textField = new TextField("DiagramTitle");
            textField.DefaultText = surfaceTitle;
            textField.DefaultVisibility = true;
            textField.DefaultAutoSize = true;
            textField.DefaultFontId = DiagramFonts.ShapeTitle;
            textField.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.33);
            textField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.07);

            diagram.ShapeFields.Add(textField);

            #endregion
        }
Пример #4
0
 /// <summary>
 /// Initializes the resources for all fields of this type.
 /// </summary>
 public static void InitializeInstanceResources(StyleSet classStyleSet, float fontSize, Color fontColor)
 {
     FontSettings fontSettings = new FontSettings();
     fontSettings.Style = FontStyle.Bold;
     fontSettings.Size = fontSize;
     classStyleSet.OverrideFont(DiagramFonts.ShapeTitle, fontSettings);
     BrushSettings brushSettings = new BrushSettings();
     brushSettings.Color = fontColor;
     classStyleSet.OverrideBrush(DiagramBrushes.ShapeText, brushSettings);
 }
        public NamedControlListViewModel()
        {
            // Setup initial conditions.
            Items = new ObservableCollection<INamedControlListItem>();
            TitleFont = new FontSettings
                            {
                                FontSize = 18,
                                TextTrimming = TextTrimming.WordEllipsis,
                            };

            // Wire up events.
            Items.CollectionChanged += delegate { UpdateItemState(); };
        }
        public static void Run()
        {
            // ExStart:SetFontsFoldersMultipleFolders
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); 

            Document doc = new Document(dataDir + "Rendering.doc");
            FontSettings FontSettings = new FontSettings();

            // Note that this setting will override any default font sources that are being searched by default. Now only these folders will be searched for
            // Fonts when rendering or embedding fonts. To add an extra font source while keeping system font sources then use both FontSettings.GetFontSources and
            // FontSettings.SetFontSources instead.
            FontSettings.SetFontsFolders(new string[] { @"C:\MyFonts\", @"D:\Misc\Fonts\" }, true);
            // Set font settings
            doc.FontSettings = FontSettings;
            dataDir = dataDir + "Rendering.SetFontsFolders_out.pdf";
            doc.Save(dataDir);
            // ExEnd:SetFontsFoldersMultipleFolders           
        }
        public static void Run()
        {
            // ExStart:SpecifyDefaultFontWhenRendering
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); 

            Document doc = new Document(dataDir + "Rendering.doc");

            FontSettings FontSettings = new FontSettings();

            // If the default font defined here cannot be found during rendering then the closest font on the machine is used instead.
            FontSettings.DefaultFontName = "Arial Unicode MS";
            // Set font settings
            doc.FontSettings = FontSettings;
            dataDir = dataDir + "Rendering.SetDefaultFont_out.pdf";
            // Now the set default font is used in place of any missing fonts during any rendering calls.
            doc.Save(dataDir);            
            // ExEnd:SpecifyDefaultFontWhenRendering 
            Console.WriteLine("\nDefault font is setup during rendering.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:SetTrueTypeFontsFolder
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); 

            Document doc = new Document(dataDir + "Rendering.doc");

            FontSettings FontSettings = new FontSettings();

            // Note that this setting will override any default font sources that are being searched by default. Now only these folders will be searched for
            // Fonts when rendering or embedding fonts. To add an extra font source while keeping system font sources then use both FontSettings.GetFontSources and
            // FontSettings.SetFontSources instead.
            FontSettings.SetFontsFolder(@"C:MyFonts\", false);
            // Set font settings
            doc.FontSettings = FontSettings;
            dataDir = dataDir + "Rendering.SetFontsFolder_out.pdf";
            doc.Save(dataDir);
            // ExEnd:SetTrueTypeFontsFolder
            Console.WriteLine("\nTrue type fonts folder setup successfully.\nFile saved at " + dataDir);
        }
        public TypographySettings()
        {
            _foreignFontFamily = SystemFonts.MessageFontFamily;
            _nativeFontFamily = SystemFonts.MessageFontFamily;
            _sansSerifFontFamily = SystemFonts.MessageFontFamily;
            _phoneticFontFamily = SystemFonts.MessageFontFamily;
            _fontSize = 11.0f;

            _defaultStyle = new FontSettings(FontSeries.Default, false, false, false, Colors.Black);
            _caseStyle = new FontSettings(FontSeries.Roman, false, false, true, Colors.Black);
            _categoryStyle = new FontSettings(FontSeries.Roman, false, false, true, Colors.Black);
            _constituentStyle = new FontSettings(FontSeries.SansSerif, false, false, false, Colors.Black);
            _etymologyLanguageStyle = new FontSettings(FontSeries.SansSerif, true, false, false, Colors.Black);
            _etymologyRootStyle = new FontSettings(FontSeries.Foreign, false, true, true, Colors.Black);
            _foreignStyle = new FontSettings(FontSeries.Foreign, false, true, false, Colors.Black);
            _functionStyle = new FontSettings(FontSeries.SansSerif, false, false, false, Colors.Black);
            _grammarStyle = new FontSettings(FontSeries.SansSerif, false, false, false, Colors.Black);
            _headwordStyle = new FontSettings(FontSeries.Foreign, true, true, false, Colors.Black);
            _nativeStyle = new FontSettings(FontSeries.Roman, false, true, false, Colors.Black);
            _phoneticStyle = new FontSettings(FontSeries.Phonetic, false, false, false, Colors.Black);
            _senseStyle = new FontSettings(FontSeries.SansSerif, true, false, false, Colors.Black);
            _semanticGroupStyle = new FontSettings(FontSeries.SansSerif, false, false, true, Colors.Black);
            _infixStyle = new FontSettings(FontSeries.Foreign, false, true, false, Colors.Black);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="AttributeElementListCompartmentDescription" /> class.
		/// </summary>
		/// <param name="name">The name of the element.</param>
		/// <param name="title">The title of the element.</param>
		/// <param name="titleFill">The <see cref="T:System.Drawing.Color"/> that fills the title.</param>
		/// <param name="allowCustomTitleFillColor">Specifies whether a title's fill color can be customized.</param>
		/// <param name="compartmentFill">The <see cref="T:System.Drawing.Color"/> that fills the compartment.</param>
		/// <param name="allowCustomCompartmentFillColor">Specifies whether a compartment's fill color can be customized.</param>
		/// <param name="titleFontSettings">The <see cref="T:Microsoft.VisualStudio.Modeling.Diagrams.FontSettings"/> used for
		/// the title.</param>
		/// <param name="itemFontSettings">The <see cref="T:Microsoft.VisualStudio.Modeling.Diagrams.FontSettings"/> used for
		/// the items in the compartment.</param>
		/// <param name="isDefaultCollapsed">Specifies whether the compartment will be collapsed by default.</param>
		public AttributeElementListCompartmentDescription(string name, string title, Color titleFill, bool allowCustomTitleFillColor, Color compartmentFill, bool allowCustomCompartmentFillColor, FontSettings titleFontSettings, FontSettings itemFontSettings, bool isDefaultCollapsed)
			: base(name, title, titleFill, allowCustomTitleFillColor, compartmentFill, allowCustomCompartmentFillColor, titleFontSettings, itemFontSettings, isDefaultCollapsed)
		{
		}
Пример #11
0
        /// <summary>
        /// Initializes style set resources for this shape type
        /// </summary>
        /// <param name="classStyleSet">The style set for this shape class</param>
        protected override void InitializeResources(StyleSet classStyleSet)
        {
            base.InitializeResources(classStyleSet);

            // Custom font styles
            FontSettings fontSettings;
            fontSettings = new FontSettings();
            fontSettings.Style = FontStyle.Bold;
            fontSettings.Size = 9 / 72.0F;
            classStyleSet.AddFont(new StyleSetResourceId(string.Empty, "ShapeTextBold9"), DiagramFonts.ShapeText, fontSettings);
        }
Пример #12
0
 private void OnUnselected()
 {
     FontSettings = new FontSettings();
     FontIsSet    = false;
     UpdateView();
 }
Пример #13
0
 void UpdateFont(FontSettings fontSettings) =>
 Application.Current.Resources["TextEditorFontFamily"] = fontSettings.FontFamily;
        public void SetSpecifyFontFolders()
        {
            FontSettings fontSettings = new FontSettings();
            fontSettings.SetFontsFolders(new string[] { MyDir + @"MyFonts\", @"C:\Windows\Fonts\" }, true);

            // Using load options
            LoadOptions loadOptions = new LoadOptions();
            loadOptions.FontSettings = fontSettings;
            Document doc = new Document(MyDir + "Rendering.doc", loadOptions);

            FolderFontSource folderSource = ((FolderFontSource)doc.FontSettings.GetFontsSources()[0]);
            Assert.AreEqual(MyDir + @"MyFonts\", folderSource.FolderPath);
            Assert.True(folderSource.ScanSubfolders);

            folderSource = ((FolderFontSource)doc.FontSettings.GetFontsSources()[1]);
            Assert.AreEqual(@"C:\Windows\Fonts\", folderSource.FolderPath);
            Assert.True(folderSource.ScanSubfolders);
        }
Пример #15
0
		/// <summary>
		/// Set the font size
		/// </summary>
		protected override void InitializeResources(StyleSet classStyleSet)
		{
			base.InitializeResources(classStyleSet);
			FontSettings textSettings = new FontSettings();
			classStyleSet.AddFont(FrequencyConstraintTextResource, DiagramFonts.CommentText, textSettings);
		}
Пример #16
0
 public IFontTexture GetFontSurface(FontSettings settings)
 {
     return(fontTextures[settings]);
 }
Пример #17
0
        public void AddFontSurface(FontSettings settings, IFontTexture fontSurface)
        {
            Require.ArgumentNotNull(fontSurface, nameof(fontSurface));

            fontTextures[settings] = fontSurface;
        }
 public ControlFlowGraphTabContent(GraphProvider graphProvider, ITheme theme, FontSettings font)
 {
     this.graphProvider = graphProvider;
     this.theme         = theme;
     this.font          = font;
 }
        public void AddFontSubstitutes()
        {
            FontSettings fontSettings = new FontSettings();
            fontSettings.SetFontSubstitutes("Slab", new string[] { "Times New Roman", "Arial" });
            fontSettings.AddFontSubstitutes("Arvo", new string[] { "Open Sans", "Arial" });
            
            Document doc = new Document(MyDir + "Rendering.doc");
            doc.FontSettings = fontSettings;
            
            MemoryStream dstStream = new MemoryStream();
            doc.Save(dstStream, SaveFormat.Docx);

            string[] alternativeFonts = doc.FontSettings.GetFontSubstitutes("Slab");
            Assert.AreEqual(new string[] { "Times New Roman", "Arial" }, alternativeFonts);

            alternativeFonts = doc.FontSettings.GetFontSubstitutes("Arvo");
            Assert.AreEqual(new string[] { "Open Sans", "Arial" }, alternativeFonts);
        }
Пример #20
0
		/// <summary>
		/// Initialize a font for formatting the mandatory column contents.
		/// </summary>
		/// <param name="classStyleSet">The <see cref="StyleSet"/> being initialized.</param>
		protected override void InitializeResources(StyleSet classStyleSet)
		{
			base.InitializeResources(classStyleSet);
			FontSettings fontSettings = new FontSettings();
			fontSettings.Bold = true;
			classStyleSet.AddFont(MandatoryFont, DiagramFonts.ShapeText, fontSettings);
			this.ListField.AlternateFontId = MandatoryFont;
		}
Пример #21
0
 public abstract void Serialize(FontSettings fontSettings);
Пример #22
0
        public void FontSubstitutionWarnings()
        {
            Document doc = new Document(MyDir + "Rendering.doc");

            // Create a new class implementing IWarningCallback and assign it to the PdfSaveOptions class.
            ExRendering.HandleDocumentWarnings callback = new ExRendering.HandleDocumentWarnings();
            doc.WarningCallback = callback;

            FontSettings fontSettings = new FontSettings();
            fontSettings.DefaultFontName = "Arial";
            fontSettings.SetFontSubstitutes("Arial", new string[] { "Arvo", "Slab" });
            fontSettings.SetFontsFolder(MyDir + @"MyFonts\", false);

            doc.FontSettings = fontSettings;

            doc.Save(MyDir + @"\Artifacts\Rendering.MissingFontNotification.pdf");
            
            Assert.True(callback.mFontWarnings[0].Description.Equals("Font substitutes: 'Arial' replaced with 'Arvo'."));
            Assert.True(callback.mFontWarnings[1].Description.Equals("Font 'Times New Roman' has not been found. Using 'Arvo' font instead. Reason: default font setting."));
        }
        public void SetFontSubstitutes()
        {
            FontSettings fontSettings = new FontSettings();
            fontSettings.SetFontSubstitutes("Times New Roman", new string[] { "Slab", "Arvo" });
            
            Document doc = new Document(MyDir + "Rendering.doc");
            doc.FontSettings = fontSettings;

            MemoryStream dstStream = new MemoryStream();
            doc.Save(dstStream, SaveFormat.Docx);

            //Check that font source are default
            FontSourceBase[] fontSource = doc.FontSettings.GetFontsSources();
            Assert.AreEqual("SystemFonts", fontSource[0].Type.ToString());

            Assert.AreEqual("Times New Roman", doc.FontSettings.DefaultFontName);

            string[] alternativeFonts = doc.FontSettings.GetFontSubstitutes("Times New Roman");
            Assert.AreEqual(new string[] { "Slab", "Arvo" }, alternativeFonts);
        }