A somewhat slick solution: Let the subspaces be $U$ and $V$, inside Euclidean space $E$. Let $\hat{P}:E \rightarrow V$ denote projection, and $P:U \rightarrow V$ denote the restriction of $\hat{P}$ to $U$. Then $A = P^{T}P:U \rightarrow U$ is symmetric, and so one can form an orthonormal basis $e_1,\ldots,e_k$ of $U$ consisting of eigenvectors of $A$. Order the basis so that the vectors in the null space of $A$ come last. (note that $Nul(A) = Nul(P)$)
Then define $f_i = Pe_i$, for each of the $e_i$ such that $Pe_i$ are nonzero. We have $\langle f_i, f_j \rangle = \langle Pe_i,Pe_j \rangle = \langle e_i, P^{T}Pe_j \rangle = \langle e_i, Ae_j \rangle = \lambda_j \langle e_i, e_j \rangle$, hence the $f_i$ are pairwise orthogonal, and we can complete this to an orthogonal basis of $V$.
It remains to show that $\langle e_i, f_i \rangle \geq 0$, and $\langle e_i, f_j \rangle = 0$ if $i \neq j$.
If $Pe_i = 0$, then $e_i$ is orthogonal to every vector in $V$ and so $\langle e_i, f_j \rangle = 0$ for all $j$.
Otherwise, we have $e_i = f_i + \tilde{f}_i$, where $\tilde{f}_i$ is orthogonal to $V$. Then $\langle e_i, f_j \rangle = \langle f_i + \tilde{f}_i, f_j \rangle = \langle f_i, f_j \rangle$, and the result follows since the $f$'s form an orthogonal basis.
Finally, normalize the $f$'s.