文字の数分 DrawString()を使って、1文字ずつ表示してはどうでしょう。
これなら文字毎に位置を決められます。
@ サンプル
#include "dxlib.h"
#include <vector>
#include <stdarg.h>
#include <stdio.h>
int DrawFormatStringToHandleWidth(int x, int y, int color, int width, int fontHandle, const char *format, ...)
{
// 文字数を数える
if(!format) return 0;
va_list params;
va_start(params, format);
int size = _vscprintf(format, params);
if(size <= 0) return 0;
try
{
std::vector<char> str(size+1, 0);
vsprintf(&str.front(), format, params);
int count_draw_chara = 0, lastWidth = 0;
for(std::size_t n=0; n<str.size()-1; ++count_draw_chara)
{
int is_mb = MultiByteCharCheck(&str[n], DX_CHARSET_SHFTJIS);
int width = GetDrawStringWidthToHandle(&str[n], is_mb? 2: 1, fontHandle);
if(n == str.size() - 2 || (is_mb && n == str.size() - 3))
lastWidth = width;
if(is_mb) n+=2;
else n++;
}
float fx = (float)x,
add = count_draw_chara < 2? 0: (float)(width - lastWidth) / (count_draw_chara - 1);
for(std::size_t n=0, cs_index=0; n<str.size()-1; ++cs_index)
{
int is_mb = MultiByteCharCheck(&str[n], DX_CHARSET_SHFTJIS);
if(is_mb)
{
DrawFormatString((int)fx, y, color, "%c%c", str[n], str[n+1]);
n+=2;
}
else
{
DrawFormatString((int)fx, y, color, "%c", str[n]);
n++;
}
fx += add;
}
}
catch(const std::bad_alloc &)
{
size = -1;
}
va_end(params);
return size;
}
使うときはこんな感じで
DrawFormatStringToHandleWidth
(
50, 50, GetColor(255, 255, 255), 270, GetDefaultFontHandle(), "%s", "テスト文字 abc"
);