This project is read-only.

FontSise and FontBold

Oct 5, 2010 at 11:46 AM
Edited Oct 5, 2010 at 11:50 AM

Hi all.

Help solve the problem. I can not adjust the font size in SacntillaNet 2.22 XML ignores the setting

<value name="default-font-size">9</value>

More do not get set in bold block JavaScript (key words and symbols), as well as I would like to highlight in bold icons

<?php and ?>

Thank you

Oct 5, 2010 at 1:06 PM

Clarification.

Need a monospace font. I tried to do it with the Courier New - did not happen.

Oct 5, 2010 at 4:47 PM

Try something similar to this, you can add the size with the Size attribute (Size="12")

 

<Styles>
	<Style Name="DEFAULT" ForeColor="Black" Font="Consolas" Bold="True"/>
	<Style Name="DOCUMENT_DEFAULT" ForeColor="Black" Font="Consolas" />
	<Style Name="WORD" ForeColor="Blue" />
	<Style Name="WORD2" ForeColor="#2b91af" Bold="True" />
	<Style Name="WORD3" ForeColor="8421376" Bold="True" />
</Styles>

Oct 5, 2010 at 5:01 PM

Thank you great, I found the solution.

Almost like you have:

   <SubLanguage Name="JavaScript">
  <Style Name="START" FontName="Courier New" Size="9" Bold="Yes"/>
  <Style Name="DEFAULT" ForeColor="0x000000" FontName="Courier New" Size="9" Bold="Yes"/>
  <Style Name="COMMENT" />
  <Style Name="COMMENTLINE" ForeColor="0x999999" FontName="Courier New" Size="9" />
  <Style Name="COMMENTDOC" ForeColor="0x999999" FontName="Courier New" Size="9" />
  <Style Name="NUMBER" ForeColor="Red" FontName="Courier New" Size="9"/>
  <Style Name="WORD" ForeColor="0x000000" FontName="Courier New" Size="9"/>
  <Style Name="KEYWORD" ForeColor="0x000099" FontName="Courier New" Size="9" Bold="Yes"/>
  <Style Name="DOUBLESTRING" ForeColor="0x0000ff" FontName="Courier New" Size="9" />
  <Style Name="SINGLESTRING" ForeColor="0x0000ff" FontName="Courier New" Size="9" />
  <Style Name="SYMBOLS" ForeColor="0x000099" FontName="Courier New" Size="9" Bold="Yes"/>
  <Style Name="STRINGEOL" FontName="Courier New" Size="9" />
  <Style Name="REGEX" FontName="Courier New" Size="9" ForeColor="0x009999" />
  </SubLanguage>

 Thanks again .

Oct 5, 2010 at 5:44 PM

well done.

You might like this small utility. It does a Console.WriteLine() with all styles. Copy&paste the result into your xml and start tweaking from there.

How to use:

editor.Lexing.Lexer = Lexer.Xml;

editor.GetStyles();

 

 

public static void GetStyles(this Scintilla scintilla)
{
	foreach (KeyValuePair<string, int> pair in scintilla.Lexing.StyleNameMap)
	{
		string colorName = "";

		string s = "<Style ";

		s += String.Format("Name=\"{0}\" ", pair.Key);

		colorName = GetKnownColor(scintilla.NativeInterface.StyleGetFore(pair.Value));
		if (colorName != "")
			s += String.Format("ForeColor=\"{0}\" ", colorName);
		else
			s += String.Format("ForeColor=\"{0}\" ", scintilla.NativeInterface.StyleGetFore(pair.Value));

		colorName = GetKnownColor(scintilla.NativeInterface.StyleGetBack(pair.Value));
		if (colorName != "")
			s += String.Format("BackColor=\"{0}\" ", colorName);
		else
			s += String.Format("BackColor=\"{0}\" ", scintilla.NativeInterface.StyleGetBack(pair.Value));

		string fontName;
		scintilla.NativeInterface.StyleGetFont(pair.Value, out fontName);
		if (!String.IsNullOrEmpty(fontName))
			s += String.Format("Font=\"{0}\" ", fontName);

		s += String.Format("Size=\"{0}\" ", scintilla.NativeInterface.StyleGetSize(pair.Value));

		if (scintilla.NativeInterface.StyleGetBold(pair.Value) == true)
			s += String.Format("Bold=\"{0}\" ", scintilla.NativeInterface.StyleGetBold(pair.Value));

		if (scintilla.NativeInterface.StyleGetItalic(pair.Value) == true)
			s += String.Format("Italic=\"{0}\" ", scintilla.NativeInterface.StyleGetItalic(pair.Value));

		if (scintilla.NativeInterface.StyleGetUnderline(pair.Value) == true)
			s += String.Format("StyleGetUnderline=\"{0}\" ", scintilla.NativeInterface.StyleGetUnderline(pair.Value));

		s += "/>";

		Console.WriteLine(s);
	}
}

private static string GetKnownColor(int iARGBValue)
{
	foreach (KnownColor eKnownColor in Enum.GetValues(typeof(KnownColor)))
	{
		Color color = Color.FromKnownColor(eKnownColor);
		int value = color.R + color.G * 255 + color.B * 255 * 255;
		if (iARGBValue == value && !color.IsSystemColor)
		{
			return color.Name;
		}
	}
	return "";
}

Oct 5, 2010 at 5:57 PM
Edited Oct 5, 2010 at 5:58 PM

Thank you. Very useful tool!