How to Use FontTools Module in Python

Python
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 Setup.py 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
[/sourcecode]

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")
[/sourcecode]

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”]
font.saveXML("d:/YourDesireName.xml")
[/sourcecode]

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.

Web Developer Recruitment in Faraconesh Corporation

Faraconesh Logo

I hardly ever use my blog to publish unrelated subjects to programming. This is one of them.

Our company Faraconesh Corporation is bound to hire new talented and professional .NET developers. If you like working with me in person in a small-growing company which offer good salary, insurance, flexitime working beside experts which are pioneers in Iran in their skills and you meet the following needs

At least 3 years of relevant experiences.

Deep knowledge of .NET, C#, SQL Server and NHibernate

Also ability to work in team and using issue trackers, source controls and the rest of teamwork tools

Ability to work with WPF, WCF, WF and REST count as advantages

You can send your resume to jobs@faraconesh.com or to me at n.hajloo@gmail.com.

Faraconesh Corporation appreciates in advance your kind request to join and will arrange a meeting with you in next few days.

This is the Persian text for this advertisement.

کروکی آدرس شرکت فراکنش در نقشه تهران کتاب اول
من به ندرت در این وبلاگ مطالب غیرمرتبط با برنامه نویسی می‌نویسم. این مطلب یکی از آنهاست.شرکت ما، فراکنش قصد استخدام چند برنامه‌نویس بااستعداد و حرفه‌ای دات نت را دارد. اگر شما دوست دارید که با من از نزدیک در یک شرکت کوچک رو به رشد که حقوق کافی، بیمه، زمان کار آزاد و کار شانه به شانه با متخصصینی که در زمینه کاری خودشان از پیشروان هستند همکاری کنید و نیز درصورتی که شرایط زیر را دارید

حداقل سه سال سابقه کار مرتبط

درک و تسلط کافی و عمیق از ‫.NET, C#, SQL Server و  NHibernate

همچنین توانایی کار گروهی و استفاده از ابزارهای کار تیمی مانند ایشوترکر ها و سورس کنترها

توانایی کار با WPF, WCF, WF و REST مزیت به شمار می‌آید

را دارید

می‌توانید رزومه کاری خودتان را به آدرس jobs@faraconesh.com و یا برای من به آدرس n.hajloo@gmail.com ارسال نمایید.

شرکت فراکنش از درخواست همکاری محبت آمیز شما از قبل قدردانی کرده و در چند روز آینده یک قرار ملاقات با شما تنظیم خواهد کرد

A Letter to Atlassian Team

Atlassian JIRA

Recently I’m upgrading JIRA from 3.x to 4.x version for my company. During this upgrade procedure, I learnt a lot from Atlassian. When I was using Jira 3.x, I just using Jira as a simple (but) powerful issue tracking system. I was always content with it. I never felt that I have to upgrade to a newer version. It was good enough to ignore ordering a newer version. I used (a cracked version of) Jira about 3 to 4 years; because my company wasn’t able to afford it.

Jira used a simple UI in 3.x version, honestly I should say that I never impressed by it. By the way, I changed my career and in the new company they are using a licensed Jira 4.x version. After two weeks of using new Jira, I wondered that, how much changes happened on Jira. I couln’t believe that they redesigned UI completely, in a way that amazed me. Almost everything relocated and new menu works great. New Plug-ins, especially Green Hopper, forced me to confess that all in all, Jira is the best web application I’ve ever used.

Jira Project Browser
Jira Project Browser

One of the things that is really special to me, is that new version has a really affordable price. 10$ for 10 users! Most of the small companies don’t have more than 10 active users (developers) so that they can easily afford it. I have to mention that Atlassian give all of these (10$) prices to RoomToRead charity organization and they are going to raise it to 1,000,000$.

Here I want to appreciate Atlassian team because of their good software and their effort for education. I also obliged to ask for an excuse from Atlassian, because of my unfair usages at past. I write this to say that this is the first time that I really have a shame of using a cracked version of a software. I wish they forgive me for this.

How to Build your Solution with Visual Studio Command Prompt

Working with command prompt always been a nice job, it helps you to schedule your routines and gives you more understanding of what’s going on the background. You will give more and on-time information; you can check the result as they happen. You can create a batch fileto build your solutions one after another and many other advantages.Visual Studio command prompt gives you all of the simple windows command prompt abilities plus some tools to control build and publish your source codesand many other abilities which you can find here. You can run Visual Studio command prompt from

[source code=””xml””]
Start Menu \ Visual Studio [2005|2008|2010] \ Visual Studio Tools \ Visual Studio 2008 Command Prompt
[/source]

You can use other prompts like – Visual Studio 2008 x64 Cross Tools Command Prompt – for general x64 system. None of them are different; the only difference is that they are provided for different platforms. As it is hard to run Visual Studio Command Prompt from Windows Task manager, you have to call it from a simple Command Prompt; it means that you have to run the following command in your Command Prompt. After that Visual Studio tools will include into your simple command prompt.

[source code=””xml””]
call "C:\Program Files (x86) \ Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64
[/source]

x86_amd64 will call x64 Cross Tools. To build your solutions you can use following commands

[source code=””xml””]
MSBuild YourSolution.sln /p:Configuration=Release
[/source]

Note that you can use a path like MSBuild D:\src\YourSolution.sln for your projects. As you all know .NET provide two different type of output for each project, Debug & Release. To specify the type of output you can use following code

[source code=””xml””]
MSBuild D:\src\YourSolution.sln /p:Configuration=Release
[/source]

List of Software Development related Podcasts

podcast
podcast

Podcast is one of the most interesting innovations on the web. Usually technology pioneers trying to share their knoweledge or products to gain more attention or to earn more money. Some ones creates podcast in order to teach something freely or to challenge a technology. Podcast is a good way to share something with a group of people.

I was looking for an Audio Book and I faced with a bunch of good references, so that I decided toshare these references with you. These are some weblogs or websites in which you can find programming related podcasts or audio books.

Please Share Persian Software Development Podcasts link withus,If you know one.

1 – http://www.hanselminutes.com , Scott Hanselman is one of the most famous ones in the web who spent his time on producing greate podcasts. I personally usually listen to his podcasts. I wish he keep doing goods.

2 – http://www.dotnetrocks.com , If you have to choose only one website to follow, I strongly recommand this one. Greatest .NET pioneers are the guest of podcasts.

3 – http://blog.stackoverflow.com/category/podcasts , Stackoverflow is growing everyday, Jeff Atwood and Joel Spolsky publish a weekly podcast that you will get familiar with the nowadays issues. For sure you will amazed that how they are challenging.

4 – http://channel9.msdn.com , Microsoft is one of the leaders in software industry, and try to broadcast it’s developing from the inside out. The project managers talk about their projects and show you what will release in near future. It is one of my favourites.

5 – http://www.se-radio.net , Software Engineering Radio is one of those who want to challenge the software engineering issues.

6 – http://thirstydeveloper.com , Dave Bost and Clark Sell, usually goes in deep and speak very technical, they are really serious about their job.

7 – http://elegantcode.com , You can find lots of different topics here.

8 – http://www.code-magazine.com/codecast , A good reference for .NET developer,

9 – http://www.pluralsight.com/community/blogs/pluralcast/default.aspx , I couldn’t underestand that they want to go in detail or just introduce something.

10 – http://www.pragprog.com/podcasts I really like the subjects and interviews.

11 – http://polymorphicpodcast.com , David Starr is one of those who create podcasts about his interests. His podcast are not too much and he produce podcast a few.

12 – http://altnetpodcast.com , I just can say delicious podcasts.

13 – http://www.sparklingclient.com , It could be one of the greatest websites which produce podcasts for Silverlight.

14 – http://www.webdevradio.com , A good resource for web development.

15 – http://agiletoolkit.libsyn.com , As it is obvious they works on Agile toolkit.

This Post at StackOverFlow will help you to find a categorized Podcast websites.

Please Share Persian Software Development Podcasts link withus,If you know one.

Developers Essential Needs

As far as Afshar Mohebbi has started a game in his blog, I think about it and the following text is my opinion about Developers need. The key point is that I remove the salary from the list base on the game. Moreover I have to add this note that the following items doesn’t mean that I am in such kind of situation, I just experience them in one company (for myself) or feel it in the companies that I went to do something and I gathered them here. Just note that these are my ideas and may be differ from yours so that if you are not agree with me share yours with me.

Religion
Religion

1- Religion: After 5 – 6 years of developing and web designing I think one of the biggest issues in the (Iran) software market is to think about religion.

                Most of employers ask about it and filter developers by their religion. It is more common if the company is a famous one. You have to take care of your boss opinion no matter what. You have to wear, drink, eat, look and program in the way your boss like. I myself know a bunch of software companies which force employees to be in this state that the result is obvious. I have to add this point that even with this idea there are some companies which work well and are integrate in their idea but they are just a few.

2- Trust: most of the employers don’t have enough trust to their developers.

Trust
Trust

               They always think that their developers are robbers that want to thief their code so that they should limit the developers area by locking the USB and DVD-Rom drives they also limit the speed of internet or use a specific SLA for using the internet, for instance all of the developers node are not connected to internet and there is only one node which is connected to web, or there is a connection but the developer can use only 50MB of bandwidth in a day or blah, blah, blah.

               Moreover the employer may sit behind the developer computer and look at his monitor to check his work! It is totally obvious that with these conditions nobody can work for a long time and the result of this situation should not be good. 

Developer Position
Developer Position

3- Big picture of developer situation in employer mind: whenever a developer starts his/her work in one company, the employer (base on the interview, sample works, or …) create a big picture of him in his mind and after a while which developer work there he/she never change his idea about him/her. If in the first day he/she was a lazy one (but he/she change after some month) employer won’t change his idea about him/her and that’s why developers are fixing in their role in (Iranian) companies.

Contract
Contract

There are a few company which let you change your position and most of them will fix you for a specific role and after a while they think that you should be a specialist in that area no matter you like or dislike that position.

4- Inflexible contracts: All of the companies (in Iran) force the developer to do something that they never like or they never want to do. They mention it in the contract and the developer always thinks about that thing.

               For example there are lots of small companies which force developer to sign a cheque to get the job. This makes a stressful condition for developer and don’t let him work in good condition.

Bonus
Bonus

 5- Bonus: I never faced with an employer which gives bonus for a good or unwanted job. So after a while nobody will work to get a bonus or to satisfy his boss. I was in some situations which I expect for a bonus or an appriciation but all I get was “Who told you doing this? or Why you did something without asking for it” and for myself after a while everything finished and I didn’t try to do something else.

What is Page Method and How to use it

JQuery Logo
JQuery Logo

I don’t know have you ever needed to use a server side method in a client (JavaScript or JQuery) function or not? PageMethod is the answer for this question. Actually PageMethod is not a complicated method it is just a simple method with 2 differences.

  1. All Web Methods should be Static
  2. And you need to add a [WebMethod] attribute to the top of method

[sourcecode language=”csharp”]
[WebMethod]
public static void GetMyData()
{
// your codes …
}
[/sourcecode]

And that’s all. Your WebMethod is ready to use in client scripts. The good news is that you can use these methods in both of Web Services and Asp.NET Ajax.
How to Use WebMethods in Client Side Scripts? Or How to call a server-side method in JQuery functions?

[sourcecode language=”csharp”]
<script>
function SendForm() {
PageMethods. GetMyData ();
}
</script>
[/sourcecode]

Where this kind of methods can be useful?

Just think that you have a web application which needs keyboard short-cuts to be enabled. Or an Ajax modal which try to pass some data to other server methods and some other examples.

You can find a good article about it here

Iran Software Market

Custom Software
Custom Software

In Iran there are lots of successful and unsuccessful application which developed by software engineering companies, some are well-known and the others just use in some private or governmental companies.

1 –  Custom Software

This is the blood of Iran software companies. All of the Iranian companies were built to create this type of application. E.g.: Accounting, Asset, Inventory and etc. this type of software created exactly for a specific company which is the customer. Software companies take lot money to create one. In usual given money should be enough for all producer costs and that’s why Iranian companies like these software. Actually customer pays for everything (company rent fee, company amortizations, water, manager and staff salaries and etc) so that it is obvious that the result of production wouldn’t be like the one which customer expected. So most of the Custom software are unsuccessful and will order to another company to create a new one.

Project Development Phase
Project Development Phase

I know dozens of companies which produced unsuccessful MIS, ERP, Financial and Official Software. But it doesn’t mean that all of the Iranian companies are ditching the customer and producing buggy software. There are also some well-known companies which produce good software with a mental price.

What do you think about these unsuccessful applications future? Some of them will completely deprecate; some of them will garble and reproduced; but only a few has the chance to reorganize and return to market (customer). These a few applications will have one or two extra year for support which let them resolve the issues and become prosperous software.

On the other hand successful applications will sell to other customers with a little change to fit all of new customer needs.

2 –  Market Software

This type of software produced for all people and usually are low price because Iranian people didn’t spent much money for a software they prefer to buy a good hardware instead of a good software so that the Market software are too buggy and have low quality. Rarely you can find a good one with a suitable price. Most of these appropriate software are old software which made them well-known and that’s why the producer spending more money for that. But note that none of them implemented by new technologies because as I said before those are old software which developing with old platforms.

OutSource Issue
OutSource Issue

3 –  Out Source Software

There are two kind of out source software which categorized based on customer, one of them have abroad customer and the other one has Iranian Customer. The first one is a good example of robust Persian software; there are just a few Iranian software companies which make this kind of application, they usually get the order from an abroad company to produce software. They have professional developers and the result is really comparable to foreign software so that they are really successful and working happily.

But the second one is not always prosperous; it’s depending on the freelancer which gets the project. In Iran freelancers are usually professionals but there are some new guys which exaggerating in their abilities to get the project and the result is not good. Finding a good freelancer in Iran is a hard job because people don’t have trust to each other and put lots of pressure to project manager to give a good feedback. The point is that Iranian out source projects are small and freelancer has to complete it in less than three or six month.

4 –  Unknown Software

This is one of the most interesting types of software in Iran; usually you cannot find any equivalent for it in any other country, but what it means? New software companies are producing software, in the middle of the development they found a customer for it, and then they’ve change the software to fit with customer need. They want to give the software to the customer but customer didn’t need the software anymore so they just give a part of costs which mentioned in contract.

At last the software company has software which is not implemented by their predictions and even never used with customer to garble so the result is a buggy software which they cannot sell it to anyone so they decide to publish it on the market and because of limited experience with free market, they cannot sell a bunch of it in market so even in market, they won’t be prosperous and just give bad feedbacks from customers and in most cases they have to give the customer money back. So what’s happen then? Some of them will get rid of the company and going to work for other companies some of them try to sell it in a new way which is really awesome. And this scenario will continue,

How to Change Asp.net Applications Theme programmatically

I’m interested to Localization and globalization and one of the important issues in localization is designing scalable UIs. in this Article I’ll show you a simple way to create a scalable Asp.net UI.

—————————————————————-

GNU Logo
GNU Logo

‪Title : ‪How to Change Asp.net Applications Theme programmatically

‪Publish Date : 30/12/2009

‪Version : 1.0

‪Author : Nasser Hajloo

‪Author Mail : n.hajloo@gmail.com

‪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”.

—————————————————————-

in ASP.net2.0 microsoft present SKIN and Themes for Asp.net, in a short introduction, skin is a CssClass replacement and with skin you can specify some attribute that one of them are CssClass, and these other attribute goes in a *.skin file in App_Theme folder.

this will shorten back-end asp codes and makes it more readable and reliable and vice versa. in the other hand, Theme is a multi UI approach for asp.net application, with Theme you can create some different UI for you asp.net Application (Control) and the designer or back-end users select his/her desier UI from provided theme. in a theme you can create multi css classes or some skin files and in each skin file you can create many skins for a single control.

so with this short introduction, you (a a designer) can create different theme for a single application. and also can create some RTL and some LTR UI for your application (I always recommand to change HTML Directionality inside your css classes in html class like ).

[sourcecode language=”css”]
html
{
directionality: ltr; /* or rtl – base on page direction */
}
[/sourcecode]

usually creating an impressive UI is not a simple job and Ido not want to speak about that. Ithink you have created some Theme and now you want to let users select their theme by ownselves.

by default each theme should represent to each page to apply, this is possible inside <%@ Page %> decleration. you can represent your custom theme with Theme=”” attribute of page decleration. this apply your theme only for this page. and this let you apply different themes for different pages.

note that you can not use this approach in Master Pages.

you can change the theme for a single page programmatically, just note that theme (and skins) apply on page PreInit event. this will be a nightmare if you have more than 20 pages (just think about 300 Pages). so it is recommanded to use a Base class that it derived from System.Web.UI.Page and other pages derive from this class, so your base class should look like this

[sourcecode language=”css”]
namespace Hajloo.Web.UI
{
public class PageBase : System.Web.UI.Page
{
void Page_PreInit(object sender, System.EventArgs e)
{
if (Session["Theme"] != null && Session["Theme"].ToString().Length > 0)
this.Page.Theme = Session["Theme"].ToString(); // user selected theme
else
this.Page.Theme = "Hajloo_RTL"; // default theme
}
}
}
[/sourcecode]

the above code will apply a theme to the inherited pages, so now you should inherit your pages from this class. and all of your pages should look like this

[sourcecode language=”css”]
namespace Hajloo.Portal.Pages
{
public partial class Default : Hajloo.Web.UI.PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
[/sourcecode]

ok this will let you to provide a section for you user to select your provided theme from a list or by clicking on an image (below you can see some diffent method witchall of them change the current theme), and only in one page you need to put this code (usually in master pages or user profile)

[sourcecode language=”css”]
protected void drpThemes_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.drpThemes.SelectedIndex > 0)
{
Session["Theme"] = this.drpThemes.SelectedItem.Value; // dropdownlist Items Value should fill with theme names
Response.Redirect(Request.Url.AbsoluteUri);
}
}
protected void imbPersian_Click(object sender, ImageClickEventArgs e)
{
Session["Theme"] = "Hajloo_RTL"; // theme name
Response.Redirect(Request.Url.AbsoluteUri);
}
protected void imbEnglish_Click(object sender, ImageClickEventArgs e)
{
Session["Theme"] = "Hajloo_LTR"; // theme name
Response.Redirect(Request.Url.AbsoluteUri);
}
[/sourcecode]

now you can check it out and enjoy from your multi UI application.

Merry Christmas and Hapy New Year

as you knew ,I’m blogging in english and stop writing Farsi, it is because I’m trying to find a job from another country and it is better to show my experience in english. it doesn’t mean that I’ll never write a persian document any more, but there will a document on a month.

—————————————————————-

GNU Logo
GNU Logo

‪Title : ‪Merry Christmas and Hapy New Year

‪Publish Date : 29/12/2009

‪Version : 1.0

‪Author : Nasser Hajloo

‪Author Mail : n.hajloo@gmail.com

‪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”.

—————————————————————-

any way we’re going to have a new year and finishing a good year. 2009 passed and I took too many experiences. it was bad and sometimes so good. but I want to start a real good year. in this year, I’ll

  •   finish JIRA translation.
  •   create at least 1 (or 2) Visual Studio (2010) add-ins
  •   read more about unicode
  •   work with a new dev team. (as I told, I’m looking for a remote job)
  •   desing a site for myself.
  •   write persian indeed document in english (e.g: introducing 9147 in english and vice versa)
  •   find a way to connect with Microsoft Windows localization center and suggest to put ISIRI 9147 keyboard layout as standard persian keyboard.
  •   work more and more with Microsoft Expression Suit.
  •   do more with WPF.
  •   Buy a new Desktop with core i7 cpu. (I’m one of Nehalem crazies. it’s really impressive.)
  •   changing my friendly reaction.
  •   collaborating with at least 1 (or 2) open source project
  •   publishing my resume on my peronal blog (site)
  •   do more connection with english bloggers.
  •   do more activity on asp.net and SSRS forum (or stackoverflow)
  •   try to start writing my first short hand book in english and persian (2 languages) it may be about unicode or something else.
  •   do more personal projects.

ok, I think it is enough for next year and wish you (specially persian bloggers) provide more persian or english documents and make it easier to find an answer.

at last wish you freedom and hope stand by me in next year. Merry Christmas and Hapy New Year