The above picture is not my roof but nearly identical. Except my roof also has horizontal 2x4 supports. The previous owner has a shop light running horizontally screwed directly into the 2x4. I want to install a ceiling fan but am not sure how. I know I can install a box that directly mounts to the 2x4 that is fan rated but I thought the canopy of the fan would have a greater circumference than the box and there would be an exposed gap. Any suggestions? I would want a look like this
You want the main attachment for the fan box to be attached perpendicular to the floor, not horizontally into a faming member. The twist on a horizontal attachment could lead to failure. The box should be attached with sizable screws or lag bolts.
That means, you should have a framing member directly above the box, either the 2x4 you mentioned or a short added framing piece running perpendicular (vertically) to the joist.
I would build a small wooden frame around the fan box. 2x or 1x pieces should do. They are not structural but decorative and gap filling. These will give a base larger than the canopy.
I would then run a conduit to carry the cable to the fan box, making holes in the surrounding box trim.
The picture you showed as an example has extraordinarily high ceilings, but the picture you showed of your porch looks like it does not. Also, the example fans have a gap on either side of the canopies like the one you said you want to avoid, don't they?
My recommendation would be to measure the diameter of the canopy for your fan, and choose a lumber size that will adequately cover it - maybe 2x6, probably 2x8. Then cut a piece that will fit between the joists, put it up between the joists, flat against the roof, and fasten it to the joists. Attach the fan box to it, right in the middle. Then cut another piece the same size, cut a hole out of the middle of it so it will fit over the fan box, making the fan box appear recessed. Then hang the fan on that.
I don't think you have to worry about the box being perpendicular to the floor. Fans are made with ball joints and hangers that work on vaulted ceilings, so the fan will hang straight down anyway.