How to Use FontTools Module in Python


Python comes with the great modules which you can use them to improve your application functionalities. Recently I felt in love with Python and trying to implement some of my daily usages with it. I was always interested in Unicode and Fonts so that I had a glance at Python abilities in these fields and I have to say that Python has a lot to say when it comes to these areas. It is really fantastic and powerful and you have access to whatever you want just a a peace of a cake. In this Article I show you how to use python abilities to save a font as an XML document. It may be wierd for you but sometimes it is necessary to check font tables and the rest of its information.

To start working with fonts it’s worth to add FontTools library to Python; it will extend your abilities to work with fonts. You can download it from here.

Each Python module has its own way for installation. Some of them only needs a simple copy to the appropriate folders and some of them should be installed. FontTools uses the second approach so that you have to follow the following instruction to install it in your Python.

  • Open Windows Command Prompt
  • Go to the folder you download FontTools
  • Write build and press enter
  • Write Setup.pyinstall and press enter
Installing FontTools with Command Prompt in Python
Installing FontTools with Command Prompt in Python
Important Note: I first Installed My FontTools and Then take the above photo from my comand prompt so that the command reply may be different for the first time and the second. You just use the mentioned commands instead of considering provided replies by Python

Some lines will appear in your command prompt and then installation will complete within a minute. Now, to use this module in your application you have to load ( or  import or use ) this module in your application, so write the following command in your Python application just like other commands

[sourcecode language=”python”]
from fontTools.ttLib import ttfont

Note that commands are case sensitive so write it in the exact mentioned way.

Till now you are able to use FontTools abilities in your application so that to test it we create a font object and then get a simple export from it.

To create a font object in Python write the below command in your application; just note that you have to use for slash instead (/) of back slash (\) for addressing

[sourcecode language=”python”]
font = TTFont("d:/fontname.ttf")

Till now you created a new object of your font in the object named font. It’s time to use it in our application so that I save the font as an XML document just like

[sourcecode language=”python”]

Save a Font As XML with Python FontTools Module
Save a Font As XML with Python FontTools Module

You can find the rest of the FontTools commands in the documentation. Share your experiences with me if you know another good library to work with fonts.

How to publish Asp web sites with command prompt

I wanted to run a Continues Integration for my company and I set up Team City at first. It is a great application which works very nice and I configured it easily. Unfortunately our portal is one of the old website so that I couldn’t use Team City to publish my website because it work just with Web Application.

Then I try to use MSBuild for compiling and publishing my website and it wasn’t a good solution in order to the type of projects. Finally I had to use AspNetCompiler. It is a compiler to publish and build website and you have to customize it to work with your project. Here are steps in which I did to publish my website via command line.

1 – Create a XML file with desire name next to your Portal Solution (portal.sln). I use this name “AutomateBuildConfiguration.xml”.

2 – Then you have to configure this XML file with this instruction. For me following configuration was enough:

[source code=”xml”]
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="">
<Target Name="PrecompileWeb">
FixedNames="True" />

3 – You have to open one of the visual studio command line from this path :

StartMenu > All Programs > Microsoft Visual Studio 2008 > Visual Studio Tools > Visual Studio 2008 x64 Cross Tools Command Prompt.exe

I used a x64 system and chose above command line, you are free to use your own.

4 – change your path up to your XML file

5 – Use below command to publish your website

MSBuild AutomateBuildConfiguration.xml /p:Configuration=Release

6 – Enjoy your coffee, and after a while, It’s finished you already publish your website.

How To Convert RDL files to RDLC files

.Net use RDLC files for reporting and SQL Server (Reporting Services) use RDL files for reports files. In this Article we will take a look at RDL and RDLC files and also a way to convert RDL files to RDLC files.


GNU Logo
GNU Logo

‪Title : How To Convert RDL files to RDLC files

‪Publish Date : 06/05/2010

‪Version : 1.0

‪Author : Nasser Hadjloo

‪Author Mail :

‪Copyright (c) 2010 Nasser Hadjloo.

‪Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation;

‪with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.



1 – Both of them use a same XML schema called RDL (Report Definition Language). SQL Server Books Online documented this schema completely.

2 – “The ReportViewer control, which processes .rdlc files, ignores the <Query> element of RDL. If a report definition contains a query, the control will not process it. So A client report definition (.rdlc) file will only contain a query if it originated as a .rdl file.” MSDN said.

3 – DataSet and Data Source which used in RDLC and RDL files are totally different. RDLC (Client reports) use DataSet which actually is a DataTable and RDL (SQL Server Report) use DataSource which consist of a Data Source (actually connection String). Some Credential Information which used to access Database mentioned in Data Source and finally a SQL Command (StoreProcedure – Function …) or a Query which retrieve data from Database.

RDLC Report
RDLC Report

How To Convert RDL Files To RDLC Files

1 – As I mentioned before, both of these files are using RDL schema for representing items in a XML document, so in XML conversion there is no change. All the things you have to do, is to change RDL postfix to RDLC, commonly by Command Prompt.

2 – After that you need to Add this Report as an existing item to your Web project. (commonly in a report folder like “~/SystemName/Reports”)

3 – Next step is to create a dataset for this report, so create a DataSet File and put equivalent columns on it.

4 – At this time you need a method to retrieve data from Database and fill data on your DataSet.

5 – As you know, there is a Report Viewer control (actually an ActiveX) which get a Report and display itto user. So you need to create a page and use Report Viewer control on it. After including Report Viewer Control in the page, you need to assign your Report (RDLC file) to Report property of Report Viewer control. And also to assign your Dataset to DataSource property of ReportViewer.

6 – At the end you have to build project and check the results.

I wish this help you to convert RDL to RDLC files as easy as possible.

‪How to read Embedded Resource in c#

As you may know enterprise applications Embedd all of indeed resources into their assembly because of end users relief and prevention of loosing indeed files, in most cases embedding and using an embedd resource is so easy in dot net (c#) but if you embedd an xml resource and want to read it, you may be astound. in this article I’ll show you a way to read XML documents from EmbeddedResource in dot net 3.5


GNU Logo
GNU Logo

‪Title : ‪How to read Embedded Resource in c#

‪Publish Date : 14/12/2009

‪Version : 1.0

‪Author : Nasser Hajloo

‪Author Mail :

‪Copyright (c) 2009 Nasser Hajloo.

‪Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation;

‪with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.


How To Embedd Resource
How To Embedd Resource

what is Embedded Resource?

Embedded Resources are whatever developer want to usein his/her assembly without informing end user that he/she is using them. this type of resources will embedd in assembly and will increasing assembly size. the important note about the embedded resource is that this type of files never resultto application change, because their embedd to assembly and end user can’t change them, so if you have and important resource that lack of that file will result to application error you should emmded that resource as an Emmbeded Resource.

Embedded Resource and Resource are so different and Resources will appear to end user and him/her can shange it, usually application translation packs are the commonly exampleof this type of resource, and end user with changing this file willface with translated application.


How to Embedd a Resource? embedding a resource in dot net is as easy of drinking a cup of coffee!. to embedd a resource, all you need is selct the object on Solution Explorer and then press F4 to open Properties window, in properties window you should , from the Advanced section you should select Embedded Reource in Build Action Property. all of this proccess showed in side picture.

using each type of embedded resource is different from others, and how to use an embedded image is different from how to use embedded xml resource. in this article I will describe how to use a xml embedded resource.

How To Read / Write into XML Embedded Resource? because of embeding xml into assembly, you should use a little Reflection to read/write data into embedded xml resource. all you should do is calling xml from inside of the assembly. for example

[sourcecode language=”html”]

System.Reflection.Assembly asm = Assembly.GetExecutingAssembly();

System.IO.Stream xmlStream = asm.GetManifestResourceStream("Hajloo.FOSS.UnicodeConverter.EnterpriseAppUnit.ucd.all.flat.xml");

XmlReader reader = XmlReader.Create(xmlStream, settings);


in this example we create an object for our assembly (asm) and then use a Stream (you can use a xmlTextReader or vice versa) to read the xml, in this line of code we address the xml with complete path of XML. note that my XML name is ucd.all.flat.xml and dot between xml do not affect the clr to check another path, you should use complete Path + Name + Extension of the XML document.

in final line of code I create a XMLReader object (you can make a XMRWriter object to write inside of XML) to read (write) data from XML.

trick : if you can not find a correct path to your XML, in windows explorer right click on your assembly and then open it on Notepad++ or other editor. you can find all of you XML document inside of the assembly and you can see the fullpath of XML document here.

‪What is XBRL?


in recently days I was so sad and I can’t work because of Iran President Election in 2009, in recent days Tehran was a big garrison and we experience some rally and blah blah blah. I wish this situation ends with peace and we all can rest in peace. also I wish the best for NEDA and I think that We Are All Neda, and I hope that this so many immolates, didn’t killed for nothing. any way This is my first english post in this blog, and I wrote it in english becouse of following reasons : at the first, I want to show to whome that copy and paste my content in their blogs (without any link) that if you continiue this way, I will switch this blog into english and never write a persian content again. at second (the real reason) I write this post in english because we have no Persian company yet that implement XBRL, and as I will explain no company even interest to implement this, so I write this in english for whome that want to know something about XBRL.


این مطلب زیر نظر مجوز GFDL منتشر می‌شود. و کلیه حقوق آن برای همگان آزاد است، بدین شرط که به کلیه شرایط موجود در مجوز GFDL ( که یک نسخه از متن انگلیسی مجوز GFDL در این محل و یک ترجمه غیر رسمی (فارسی) از متن مجوز GFDL که در مرداد ۱۳۸۳ توسط کاوه رنجبر تهیه شده است در این محل ) قرار دارد پایبند باشد.

GNU Logo
GNU Logo

عنوان مطلب : ‪What is XBRL?

بخش ثانی : ندارد

تاریخ انتشار : 02/04/1387 مطابق با 23/06/2009

شماره نسخه : نسخه یک

نویسنده : ناصر حاجلو

ای-میل نویسنده :

Copyright (c) 2009 Nasser Hajloo.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation;

with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.


as Wikipedia noted that : ” XBRL (eXtensible Business Reporting Language) is an open standard which supports information modeling and the expression of semantic meaning commonly required in business reporting. XBRL is XML-based. It uses the XML syntax and related XML technologies such as XML Schema, XLink, XPath, and Namespaces to articulate this semantic meaning. One use of XBRL is to define and exchange financial information, such as a financial statement. The XBRL Specification is developed and published by XBRL International, Inc. (XII). 

XBRL is a standards-based way to communicate business and financial information. These communications are defined by metadata set out in taxonomies. Taxonomies capture the definition of individual reporting concepts as well as the relationships between concepts and other semantic meaning.

XBRLS is a simplified application profile of this standard intended to enable the non-XBRL expert to create both XBRL metadata and XBRL reports in a simple and convenient manner. At the same time, it seeks to improve the usability of XBRL, the interoperability among XBRL-based solutions and to reduce software development costs.”

as its abvious XBRL uses for validation of financial reports that commonly government organization take (reports) from the organization that should provide a clear reports for Taxes, billing informations and vise versa. so commonly Government is a good backup and supporter in this manner and the personal organizations are commonly looking for a way that create a imitation report and runaway from the real numbers.

at the end I should mention XBRL History, I write this from wikipedia content :

can be traced to the efforts of one person, Charlie Hoffman . The specification has gone through several versions, all of which are still available.

1.0 – This version was based on DTDs. It expressed the difference between data exchange in instance documents and metadata exchange in taxonomy documents. Taxonomies were expressed as XML Schema files, but these were not used for instance validation.

2.0 – This version introduced use of XML Schema substitution groups as a way of allowing schema validation of instances. Concept relations were broken out into separate XLink based linkbases. Context data in the instance was collected into a separate element.

2.1 – This version tightened the definition of terms significantly, allowing for the introduction of a conformance suite.

SBR – In 2003 the Dutch government started the Netherlands Taxonomy Project (NTP) to create a multi agency taxonomy and communication infrastructure. The Dutch government now collaborates with Australia, New Zealand and Singapore in Standard Business Reporting (SBR) programs. The key objectives of SBR include reduced time and effort spent preparing and filing reports for government by businesses.

  • XBRLS – In 2008 Charlie Hoffman and Rene van Egmond proposed a simplified more user friendly XBRL application profile of XBRL that makes using XBRL easier for most business users, improves the potential for interoperability, and improves the potential for comparibility needed by most business users, business communities, regulators and independent software vendors.

XBRL is a real united standard for all financial reports and all organization can send and receive their reports in One way. as it is abvious the final report can view every where as same and can validate the content.

so in IRAN any company or organization implement this standard for their reports, if you are an Iranian organization or a government organization that interested in XBRL we can implement this standard for you , please contact us . we also can provide meetings and session for introduce this standard for managers and financial organizations. we also can provide a service for government organization ( like exchange ) that give the numbers from companies and validate the content.

References Links