OWASP O2 Platform Blog

Util – Font Viewer.h2

Here is a simple script that I wrote yesterday when I needed to quickly figure out how each Window’s font’s looked like.

It provides real-time preview of all existing fonts in both a TextBox and Label format.

The Gui looks like this:


Here is the source code (also included in O2 at: _Scripts\Utils\Windows\Util – Font Viewer.h2 )

//var topPanel = panel.add_Panel();
var bold = false;
var topPanel = O2Gui.open<Panel>("Font Viewer", 800,300); 
var leftPanel = topPanel.insert_Left<Panel>();
var listBox = leftPanel.add_ListBox();
var fontSizeValue = listBox.insert_Above<Panel>(40).add_TextBox("Font size","10");
var baseText = topPanel.add_GroupBox("Original Text").add_TextArea().wordWrap(false);

var textboxWithSelectedFont = topPanel.insert_Below<Panel>().add_GroupBox("Transformed Text (inside a TextBox and as a Label)").add_TextArea();
var labelWithSelectedFont = textboxWithSelectedFont.insert_Right<Panel>(topPanel.width()/2).add_Label("");

Action showTextWithSelectedFont = 
   var fontFamily = listBox.selectedItem<FontFamily>();
   if (bold)
fontSizeValue.parent().add_CheckBox("Bold", 20,0,
listBox.SelectedValueChanged+= (sender, e)=> showTextWithSelectedFont();
fontSizeValue.onTextChange((text)=> showTextWithSelectedFont());
//set demo data
baseText.set_Text("This is some text (with real time preview)");

return PublicDI.CurrentScript;

November 2, 2010 - Posted by | Windows Tools

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: