Speaking from experience, for 98% of programmers and applications, do it yourself is not a practical option if you want a good results, unless your use case is extremely simple or you’re willing to put in a lot of work.
OS and browser companies have invested multiple man-decades of work to make it happen. Unfortunately each system does it differently.
I can’t tell you much on the portability side. In a previous life back in the late 90s I added Unicode support to Visual Studio, including the text editor. We supported Windows 95/98, (an ANSI OS) and Windows NT (Unicode). As a “plain text” editor, the problem space around layout was much simpler. It was all implemented over the span of a year and a half (IIRC), but I was working on lots of other things at the same time. Being Windows only, we used only Windows APIs – Uniscribe for the shaping and glyph handling. There was no API support for font linking - I had to cook my own, which including some limited parsing of TTF to calculate a font’s glyph coverage.
If you love text, language, typography, it can be enjoyable to do. It’s not bad if your use cases are simple (e.g. your layout is rendering to a box, and you don’t need (for example) tables, and you don’t need multiple font sizes, and you can constrain what languages you support.
Unfortunately, the complexity curve is a steep one with each new capability you want to have. To keep the effort in bounds, you have to strictly limit what you expect to achieve, on many dimensions.
Multiple languages? Then you need font-linking, and a way to figure out how to match them up so that the Chinese or Arabic within your other text is not only legible but looks good. Picking the same point size isn’t gonna do that. Do you need to support selecting text for Copy? Then you’re almost halfway to supporting editing, in terms of the display requirements and caret positioning logic.
Need to wrap lines? Then you need line-breaking, which can get quite complex (Bidi, Kinsoku rules, …), and many people don’t realize that it can’t be done strictly by analyzing characters if you want quality line breaks not in the middle of words. Thai doesn’t use spaces: a dictionary is required.
Harfbuzz is probably the only game in town for script analysis and portable shaping. I get the impression is that Pango has the best integration for that, but I have no direct experience.