A case that is custom fitted for the contents is fairly simple to make, and not only provides greater security by preventing the contents from shifting during rough handling, but also looks much better.  In this demonstration, I'm using very inexpensive materials to make an insert to replace the egg-crate foam that came with a pistol case.  I chose corrugated cardboard reclaimed from boxes as the filler material, since it is free, easy to work with, and provides an appropriate level of crushability for the pistol.  For more delicate items, such as electronics, a softer material such as expanded polystyrene sheet insulation might be a better choice, or perhaps a ring of foam rubber or other soft, easily compressible material could be placed on the outside of the cardboard to provide vibration damping.

This image is of a custom made insert for an electronic safe.  This is a single side insert, where the top section is flat (to make room for the electronic lock) and the pistol sits entirely inside the bottom section.  The step-by-step instructions show a slightly more complex insert, for a case that opens in the middle.  For this case, I chose to use fitted inserts on top and bottom, to keep the pistol centered in the case and provide the maximum amount of padding possible within the volume of the case.

NOTE:  If you do make a case for a firearm, remember to ALWAYS make sure the firearm is UNLOADED when you are working with it, and ALWAYS treat it as if it WERE loaded when handling it.  This is especially relevant with this project, as you may need to work with a round in the extra magazine while fitting the case.  Use a dummy round if possible.  The Taurus 709 used in this example is provided with an integral slide lock, which was kept locked when the pistol was used for fitting.

A case or box large enough to fit the items
A piece of felt or similar stretchable fabric several inches larger than the case
Corrugated cardboard or foam sheet
Aerosol glue
Hot glue

Pencil for tracing outlines of items
Razor knife
Hot glue gun
Reciprocating saw (optional)

For an "English fit" or partitioned type case, see here.

Step 1: The Starting Point

This is a simple plastic case, with foam rubber lining the top and bottom of the case.  This provides only minimal security, as the only thing keeping the pistol from sliding around in the case is friction.  A sharp blow, as would be experienced from a fall, could allow the pistol to impact the edges of the case, potentially causing damage to relatively delicate but vital components, such as the sights or the magazine lips.  Any sturdy case or box can work; possibilities include old instrument cases, wooden cigar boxes, or even hollowed out books.

Once the case is chosen, you need to decide how the contents will be laid out.  In this case, I have the pistol itself, an extra magazine, and a cleaning rod and cloth patch.  The pistol and magazine will be arranged as shown; I decided to use the space inside the carrying handle for the handle of the cleaning rod and patch, and the brush will sit in an opening under the magazine.

Step 2: Assembling the Filler

Now we need to collect enough filler material to fill the case.  Since I am using corrugated cardboard, I start by seeing how many thicknesses it will take to fill the case, then I cut out rectangles of the correct size.  I start with one sheet that I cut to size, and draw the outlines of the contents on; that will be my master pattern, and I'll use it to cut all the additional sheets I need.  (Note:  the kitten is optional.)

Foam insulation sheets can be used here as well, but I would consider putting a layer of cardboard--corrugated or not--on the top face.  Most foam sheets are very soft, which means that it could easily be damaged by impact.  A layer of cardboard on top will provide a more resilient surface.  Particle board is also commonly used in making fitted cases, but as it is not readily crushable, it will not provide as much protection as foam or corrugated cardboard.

Step 3: Cutting to Fit

Once the filler is roughed out, you may need to do some additional trimming to fit the case.  In this case, the case tapers inwards slightly, so the outer layers will be slightly smaller than the ones in the middle.  I also need to cut out around the handle, since it intrudes into the case.  Cardboard is a good material to work with, since it can be easily cut with a knife or a saw.  In this case, I gently clamp the layers together (you can put a couple of nails through the cardboard to keep the layers lined up) and use a reciprocating saw to trim, taper, and cut out the handle.

Step 4: Fitting the Contents

Now we need to start cutting the openings in the filler where the objects will sit.  First figure out how deep each opening needs to be.  In this case, the pistol is as thick as six layers of cardboard, so I will cut through three layers on each side.  There are two additional layers of cardboard, and those will remain solid to provide protection on the sides.  The outer, solid layers are glued together at this point to form solid blocks, as are the inner layers that we'll be cutting openings in.  If you're doing a split case, then you'll have four blocks now, and if you're doing a single-sided case, you'll have three blocks.

This illustration also shows how to deal with items that are not consistent in thickness.  The magazine is the same thickness as the pistol at the bottom, but for most of its length it is thinner.  You can see where I attached an additional layer to the outer block to provide the additional height in the magazine cutout.  You may wonder why I didn't just not cut as deep on the top layers; there is a reason for this that you will see in a later step.  For now, just follow this process as needed, with full depth cuts used on the top layers and however much of the cut-out section added back to provide the height you need.  Stack the cardboard and items up as you do this, to make sure that everything fits well.  There can be a small amount of play, since the felt covering will add some thickness, but don't leave too much space or you won't get a snug fit.  Don't worry if it seems tight at this point, as the cardboard will crush slightly to make room if needed.

While for this project I'm cutting straight down, since the pistol and magazine have roughly rectangular cross-sections, angle cuts can be used as well.  For rounded objects, you may want to cut an an angle, to make an opening with sloped sides, such as used for the ammunition compartment on the revolver case.

Be sure to hang on to the cardboard you cut out, because that will may be used later to help press the felt into place.

Step 5: Attaching the Felt

Now you'll need to cut a section of felt larger than the case; you want enough to easily wrap around all the sides of the filler, past the bottom.  It's important for a good, clean fit for the felt to have some give to it, because it's going to have to stretch into the openings.

Center the filler under the felt, and then insert the items--or the cardboard you cut from the openings--into the openings, pushing then down firmly against the base layer.  While holding the items down, pull the edges of the felt to smooth out the wrinkles.  Once you get things adjusted, you'll need to place a sheet of cardboard or other flat, stiff material on top, and flip the whole assembly upside down, so you can get access to the back side.  Now carefully remove the filler, to expose the backside of the felt.

Spray the felt with spray adhesive, as directed on the adhesive can.  You will probably also need to spray the filler, so you get a glue-to-glue bond.   The brand I used said to allow several seconds of drying type before attaching the parts, so that they could be repositioned--that's the method you want to use, so you can work with the felt and get a tight, wrinkle-free surface.  Once the glue is applied, stack the filler back up on top of the felt, the flip everything back over.

NOTE:  Since you are spraying adhesive onto the felt, which has items that may be damaged on the other side, be aware of this and take any needed precautions.  Wrapping the items in plastic wrap is one approach, or using the cardboard cutouts in place of the actual items is another.

Step 6: Smoothing Out the Surface and Finishing Up

With the right adhesive, you'll have some time to work with the felt.  Peel it up in sections, stretch it gently outwards, and then press it down against the filler so it sticks.  Do this all the way around, paying particular attention to corners of the cutout. 

Once the felt is as smooth as you can get it, then you can trim the edges.  You want to leave sufficient felt all the way around to glue down to the sides of the filler, and wrap slightly around the bottom.  This will provide a good bond, and keep the edges from peeling away. You'll want to test the fit now, and make sure that you can fit the insert into the case with the felt wrapped around it.  If not, then you'll need to carefully trim the edges where it doesn't fit, being careful not to cut through the felt.

Now you need to attach the felt to the sides of the filler.  With the highly porous sides of the corrugated cardboard, hot glue provides the best adhesion, as it can fill the gaps and seep into the felt.  With a foam filler, a foam-safe spray adhesive is probably the best choice.  You will probably need to trim the corners of the felt, since multiple layers of felt at the corner will make the insert too large to easily fit into the case.

Once the felt is wrapped around the sides of the filler and secured, you should be able to slip the insert into the case.  The thickness of felt around the outside should give you a good friction fit, preventing the insert from falling out.  If it's too loose, then you may add an additional wrap of felt around the outside of the insert, or use glue or double-sided tape for a permanent installation, or Velcro spots on the inside of the case to hold the insert in place while still allowing easy removal.

Ideally, it will require a moderate amount of pressure to close and latch the case, keeping the items securely held in place.  The filler will deform slightly to accommodate the items, providing a perfect fit.  In the case of the pistol case, after remaining closed for a few minutes, the inserts began to show impressions of details such as the safety, slide release, and take-down latch in the felt.