how to measure width of a string precisely?

后端 未结 4 1293
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 05:56

First of all, question How to measure width of character precisely? which is answered, doesn\'t really help for this case, so this isn\'t a duplicate of that.

4条回答
  •  时光说笑
    2020-12-16 06:27

    Try to use this methods:

    GDI+ (graphics.MeasureString and graphics.DrawString) >> System.Drawing.Graphics
    GDI (TextRenderer.MeasureText and TextRenderer.DrawText)
    

    It also may help you:

    Write a custom measure method:

    • Split entry string on special characters
    • Use above .net methods
    • Calculate width of special characters and sum ...

    Read Ian Boyd answer

提交回复
热议问题