Archive for category Projects

C++ FreeFontStack

I’ve been doing a lot of research into free software font technologies and as a consequence I’ve been playing around a lot with Freetype2 and Fontconfig (actually the library interface libfontconfig). These are “straight up” c-libraries and so I (personally) find the interface a bit “clunky” in C++ code. Don’t get me wrong, I wouldn’t presume to criticize their design as it is clear the authors/maintainers are far more knowledgeable about this stuff than I am… but from a users perspective I desire a bit more.

So… I’ve written some C++ wrappers for freetype2 and fontconfig. The main goals in these projects are:

  • Don’t change the usage patterns of the library
  • Provide a pointer-like type which automatically performs reference counting for reference counted objects
  • Provide a pointer-like type which exposes member-functions where relevant
  • Provide a pointer-like type which still allows access to the public data members of the underlying structures
  • Allow access to the native c-pointer for use in parts of the library that I haven’t finished wrapping

So far… cppfontconfig wraps more or less all the functionality of libfontconfig. I’d still like to add some interface for assignment by touples in order to grab error codes when desired without the error being part of the function signature. Perhaps in the future.

cppfreetype isn’t nearly as complete (freetype2 is a much larger library). I still haven’t decided the appropriate way to deal with structures which are normally stack allocated. I do however have wrappers for FT_Face, FT_GlyphSlot, and an iterface for iterating over contours and points in an FT_Outline.

These libraries are released as GPLv3. I have public git repositories and publicly accessible doxygen documentation available in the links below. No bug tracker though since I’m giving up on redmine.

library source repository documentation
cppfreetype git://git.cheshirekow.com/cppfreetype.git www.cheshirekow.com/~projects/cppfreetype
cppfontconfig git://git.cheshirekow.com/cppfontconfig.git www.cheshirekow.com/~projects/cppfontconfig

No Comments

HTC Incredible 2 USB charging port repair

So I happened to come across a broken HTC Incredible 2. My sister had replaced it with an iPhone when the Incredible stopped charging. She had taken it back to the Verizon shop where they tried replacing the battery but it still wouldn’t charge. It seems like such a waste to throw away such a fine piece of hardware which clearly works but can’t recharge the battery.

Long story short, a lot of people have had a similar problem and had success by simply replacing the USB chargin port of the phone. As it turns out the repair is not even that difficult. The phones design is incredibly modular, with everything connected to the mainboard by ribbon cables. In this post I document the process of disassembling the HTC Incredible 2 and replacing the USB charging port.

The part I ordered was For HTC Incredible S II 2 Charging Charger Port USB Dock Connector Part Repair. The cost was $9 shipped and it came with a screwdrive and plastic pry tool.

The phone, the replacement part, and the tools that come with the part.

In addition to these tools, I also used a pair of tweezers, an exacto knife, and a very small phillips screw driver. Start by removing the outer cover. This can be done with the plastic pry tool or a coin, or a credit card with one corner shaved down a bit. There is a little tab at the bottom of the phone to get you started.

Start by removing the thin protective backing.

Then remove the battery and the simcard. These are pretty easy, just take them out.

Then remove the battery.

Then remove the simcard by pushing down on the little tab.

Now there are seven (7) star screws to remove in order to get the inner housing cover off. One of them is covered with a green “void” sticker (removing this screw will void the warranty, which I assume is already voided). If you dont have a star screwdriver (though one came with my replacement part) a small flathead should work. you can look at the next picture to see where the screws are located.

Use the star screwdriver (or a small flathead) to remove the seven (7) screws that are holding the interior plastic cover.

I used a piece of paper and take to diagram where all the parts came from as I took them off. This is a handy way to keep track of where stuff goes when you put it back together. Anyway, now that the screws are removed we may remove the inner back of the case.

Now use the plastic pry tool (or a credit card with one of the corners shaved down a bit) to pry off the interior case.

For me, the case took some work. Note that the volume rocker switch is a part of the piece we are removing so it is safe to pry under it, however the little piece of plastic over the headphone jack is not part of the piece we are removing, so don’t try to pry it out too. During this process, the USB protective housing and the little rubber cover to what looks like an antenna port came out. I just added them to my diagram so I knew how to put them back.

After removing the interior housing.

Now we can see the (presumable) culprit of the charging problem. The USB charging port has some corrosion on it. I’ve read that many people have had problems charging and that replacing this part will fix those problems. I’m making an $9 bet that this is my problem too.

We can see that the USB port is rather corroded, so hopefully the charging port is in fact the reason the phone will not charge. This is the part we will replace.

Now we have to disconnect two ribbon cables on the right side of the main board. They are covered with some ESD tape. I saved the tape and put it back on when I reassembled the phone. I’m not sure if they’re useful but I figured perhaps they’d relieve some stress on the attach points.

Remove the plastic tape from the ribbon cable.

And from this ribbon cable.

To remove the ribbon cables pop the tab on the back of the attach point. With the tab up, the ribbon cable should slide right out.

Pop the tab on the ribbon cable.

With the tab popped

And on this ribbon cable.

With the tab popped.

Now remove the two small philips screws. One is holding a piece of plastic over the headphone jack. The other is holding the main board onto the case.

Using the small phillips screwdriver, remove the screw that is holding in the board.

Again with the phillips, remove the screw that is holding in the little plastic piece over the headphone jack.

Next we need to pop out the vibrator motor. Once the motor is removed from it’s holder, you may leave it connected to the mainboard. It’s not held in with any tabs so just pull it on out with your pry tool.

Pop out the vibrator motor.

The vibrator motor popped out

Now it’s time to separate the mainboard from the housing. The mainboard is still connected by a ribbon cable on the left side, so lift up from the right side. The board is held down by two attach points. It fits under the headphone jack at the top, and it is clipped in place at the vibrator motor housing. I used the pry tool to separate the board from the clip at the vibrator motor housing, and then pulled slightly downward to remove it from under the headphone jack.

Pry the board from the housing. There are two main attach points: the vibrator motor housing and the headphone jack.

Flip over the board to expose the ribbon cable that is attaching it to the screen assembly.

Now we can remove the ribbon cable that is attaching the board to the screen. In hindsight this is not really necessary since our part is already exposed, but I guess it make things a bit easier later. Start by removing the plastic tape covering the ribbon cable attach point. Then pop the lever, and slide out the ribbon cable.

Remove the tape covering the ribbon cable attach point.

Flip up the lever on the ribbon cable attach point.

With the lever popped.

Now that the mainboard is separated from the housing we can remove the USB port. It’s just another ribbon cable so remove the tape, flip the tab, and slide out the part.

Remove the tape over the ribbon cable for the USB port.

Pop the lever on this ribbon cable

With the lever flipped.

The we simply swap in the new part. Insert the ribbon cable, make sure it’s snug inside the attach point, then close the tab.

Remove the old charging port. Dont get it confused with the new one.

Insert the ribbon cable for the new port, make sure that the new port is facing the right direction.

Close the lever on the ribbon cable attach point.

Now we reattach the mainboard to the housing by the big ribbon cable on the left (screen?). This was a bit tricky since the ribbon cable is kind of short. I had to pull a five finger maneuver to get the thing in a position where I could insert the cable without it sliding back out. Once the cable is in, close the tab.

Reconnect the ribbon cable from the screen assembly to the main board (a bit tricky).

The mainboard with the ribbon cable reattached.

Now simply flip the mainboard back over so that it is lying on the housing. Check the camera to make sure it didn’t slide out. Mine had slid out and was sitting at a funny angle so I had to shift it back into place. Also make sure that the two small ribbon cables on the right side are pulled out and aren’t buried under the mainboard.

Fold the main board back onto the housing. Make sure to pull out the two small ribbon cables so that are not under the main board.

Now we can snap the mainboard back into place, and return the vibrator motor back to it’s home.

Reinsert the vibrator motor.

Now screw back in the two phillips screws. One holds the plastic cover over the headphone jack, and the other holds the mainboard onto the housing.

Reattach the plastic cover for the headphone jack using the phillips screw.

Screw the main board back into the housing with the other phillips screw.

Now we reattach the small ribbon cables on the right side. Slide them into the attach point, close the lever, and then replace the tape (if you like).

Reattach the small ribbon cables.

Now we can snap the cover back on. Start by replacing the USB port cover. This fits into the housing by two tabs that are under the port. Replace the rubber cap on the left side if it fell off. Also return the volume rocker to it’s place inside the back of the housing (the part that you took off) if it fell out.

Replace the USB port housing

Replace the little rubber cap for whatever it is that it covers (antenna port?)

Insert the volume rocker back into the inner housing cover (if it fell out when you removed it)

Then simply snap the back of the housing into place, and screw all the screws back in.

Snap the inner housing cover back on and screw it back in.

Now you can replace the battery, simcard, and outer cover.

Replace the simcard, battery, and outer cover.

c’est fini

Plug in the phone, and if nothing starts sparking/smoking perhaps you have indeed fixed your problem. Not that this is proof, but the phone now at least tells me it’s charging the battery. We’ll see if it ever gets to 100%.

Ah, the sweet taste of success.

18 Comments

cppfontconfig – Simple C++ interface into fontconfig

Lately I’ve been trying to learn how to use (and I mean *really* use) the open source font stack. Since I tend to greatly prefer c++ over c, as part of the process of learning these libraries I figured I’d workout API wrappers. Since the font stack libraries are generally object oriented, I figured a C++ wrapper around these would be easy to accomplish.

As a start, I wrote cppfontconfig, a C++ wrapper around font config.

Documentation
git://git.cheshirekow.com/cppfontconfig.git (public git access).

I’m not sure if the design is good or if it’s even useful, I guess we’ll see.

No Comments