I don't know which software you are using, but I recommend you read the FontLab Studio 5 manual. I am going to give you a quick answer on how to do both tasks you mention in FontLab Studio 5.
For this example, I drew 3 simple glyphs (f, i, n) and a fi ligature.
These are the glyphs in the preview panel:
Now, if you click the OpenType Panel button:
the next panel appears, where you can enter you OpenType Layout Features:
The left side is the list of features, the upper right is where you define the features and the bottom right is where the global definition data goes. In the globals, let's add the following two lines:
languagesystem DFLT dflt;
languagesystem latn dflt;
Citing this site (which I recommend you to visit!):
[The first line] will register all rules for a fallback system in case an
OpenType layout engine gets confused about which language or script your
features apply to. Additionally, before you register a script with a
specific language, you should register it with the default language
for the same reason.
Now, clicking the [+] button in the bottom left part of the panel, you add an unnamed feature:
Ignoring for the moment the languages, scripts, and for the sake of clarity, lets rewrite the feature like this:
feature liga {
sub f i by fi;
sub n n by n;
} liga;
Both lines are self-explanatory, and tell the OT Layout Engine to substitute a pair of glyphs for the one following the by. Of course, the removal of repeated characters is nonsense, but I suppose is for demonstration, and is thus included in the liga feature. Also, you have to know about lookups and can use classes. If you open the Preview panel and activate the liga feature, you get:
BTW, all that writing can be entered as a separate feature file.
That's it.
Disclaimer: I'm new at this, and I hope my dear professional typographer friends won't kill me if I omitted something or wrote something wrong. Instead, I invite you to contribute. :)
.ttf
. I would assume that anybody who actually wants to talk about plain TrueType would just say this and not use a file extension.