Traditionally, the quality of orthogonal planar drawings is quantified by the total number of bends or the maximum number of bends per edge. However, this neglects that, in typical applications, edges have varying importance. We consider the problem OPTIMALFLEXDRAW that is defined as follows. Given a planar graph G on n vertices with maximum degree 4 (4-planar graph) and for each edge e a cost function cost e : N 0 −→ R defining costs depending on the number of bends e has, compute a planar orthogonal drawing of G of minimum cost.In this generality OPTIMALFLEXDRAW is NP-hard. We show that it can be solved efficiently if (1) the cost function of each edge is convex and (2) the first bend on each edge does not cause any cost. Our algorithm takes time O(n · T flow (n)) and O(n 2 · T flow (n)) for biconnected and connected graphs, respectively, where T flow (n) denotes the time to compute a minimum-cost flow in a planar network with multiple sources and sinks. Our result is the first polynomial-time bend-optimization algorithm for general 4-planar graphs optimizing over all embeddings. Previous work considers restricted graph classes and unit costs.