MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / MdSpaceWidth

Function MdSpaceWidth

src/windows/TextInterface_Win32.cpp:134–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134int MdSpaceWidth(DrawingContext* context, int styleFlags)
135{
136 int fontId = MdDetermineFontID(styleFlags);
137 if (context->m_cachedSpaceWidths[fontId])
138 return context->m_cachedSpaceWidths[fontId];
139
140 HDC hdc = context->m_hdc;
141 HFONT font = MdGetFontByID(fontId);
142 HGDIOBJ old = SelectObject(hdc, font);
143 ABC abc{};
144 BOOL res = false;// GetCharABCWidths(hdc, ' ', ' ', &abc);
145 SelectObject(hdc, old);
146 int wd = abc.abcA + abc.abcB + abc.abcC;
147
148 if (!res) {
149 INT sz = 0;
150 GetCharWidth32(hdc, ' ', ' ', &sz);
151 wd = sz;
152 }
153
154 context->m_cachedSpaceWidths[fontId] = wd;
155 return wd;
156}
157
158void MdDrawString(DrawingContext* context, const Rect& rect, const String& str, int styleFlags)
159{

Callers 1

LayoutMethod · 0.85

Calls 2

MdDetermineFontIDFunction · 0.85
MdGetFontByIDFunction · 0.85

Tested by

no test coverage detected