Click here to Skip to main content
15,886,258 members
Home / Discussions / Graphics
   

Graphics

 
QuestionRotate TTF Font Glyph? Pin
radarcontact29-Nov-14 14:25
radarcontact29-Nov-14 14:25 
QuestionDx installation Pin
Otekpo Emmanuel20-Nov-14 19:20
Otekpo Emmanuel20-Nov-14 19:20 
AnswerRe: Dx installation Pin
Richard MacCutchan20-Nov-14 21:52
mveRichard MacCutchan20-Nov-14 21:52 
GeneralRe: Dx installation Pin
Otekpo Emmanuel20-Nov-14 23:29
Otekpo Emmanuel20-Nov-14 23:29 
GeneralRe: Dx installation Pin
Richard MacCutchan20-Nov-14 23:47
mveRichard MacCutchan20-Nov-14 23:47 
GeneralRe: Dx installation Pin
Jochen Arndt21-Nov-14 0:24
professionalJochen Arndt21-Nov-14 0:24 
QuestionMeasuring of Text with Multiple Fonts in One Single Line Pin
paul116730-Oct-14 21:59
paul116730-Oct-14 21:59 
AnswerRe: Measuring of Text with Multiple Fonts in One Single Line Pin
paul116731-Oct-14 2:12
paul116731-Oct-14 2:12 
Update
I have added one more test which is using standard GDI, and I have changed the GDI+ font to units of pixels. Unfortunately, this third test shows results which do not match the previous results at all.

Does anybody have an idea why I get so different results?

Since I had not only added a third test but also changed the code of the first tests I am appending the full example here; the results I found have been added as comments:

C++
void ApplWindow_TextDrawTest(HDC hDC)
{
	Gdiplus::Graphics *G = new Gdiplus::Graphics(hDC);
	G->SetTextRenderingHint(TextRenderingHint::TextRenderingHintClearTypeGridFit);

	Gdiplus::StringFormat MyFormat;
	MyFormat.SetAlignment(Gdiplus::StringAlignment::StringAlignmentNear);
	MyFormat.SetFormatFlags(Gdiplus::StringFormatFlags::StringFormatFlagsNoWrap);

	Gdiplus::Font TextFont(L"Calibri", 36, Gdiplus::FontStyle::FontStyleBold, Gdiplus::Unit::UnitPixel);

	const wchar_t *Text1M = L"M";
	Gdiplus::PointF TextOrigin1M(0, 0);
	Gdiplus::RectF TextBounds1M;

	const wchar_t *Text2M = L"MM";
	Gdiplus::PointF TextOrigin2M(0, 50);
	Gdiplus::RectF TextBounds2M;

	//--- Test #1:  using MeasureString ----------
	G->MeasureString(Text1M, (INT)wcslen(Text1M), &TextFont, TextOrigin1M, &MyFormat, &TextBounds1M);
	G->MeasureString(Text2M, (INT)wcslen(Text2M), &TextFont, TextOrigin2M, &MyFormat, &TextBounds2M);
	//--- Results:  Text 1 Width= 44.414  ("M")
	//---           Text 2 Width= 76.828  ("MM")

	//--- Test #2:  using MeasureCharacterRanges ----------
	Gdiplus::Status RCode;
	Gdiplus::RectF LayoutRect(0, 0, 1000, 100);
	Gdiplus::Region RegionsList[3];
	Gdiplus::CharacterRange CRanges[3];
	CRanges[0].First = 0; CRanges[0].Length = 1;
	CRanges[1].First = 1; CRanges[1].Length = 1;
	CRanges[2].First = 0; CRanges[2].Length = 2;
	MyFormat.SetMeasurableCharacterRanges(3, CRanges);
	G->MeasureCharacterRanges(Text2M, (INT)wcslen(Text2M), &TextFont, LayoutRect, &MyFormat, 3, RegionsList);
	RCode = RegionsList[0].GetBounds(&TextBounds1M, G);		// Result: Text 1 Width = 32.000  ("M")
	RCode = RegionsList[1].GetBounds(&TextBounds1M, G);		// Result: Text 1 Width = 32.000  ("M"; the second char)
	RCode = RegionsList[2].GetBounds(&TextBounds2M, G);		// Result: Text 2 Width = 64.000  ("MM")

	//--- Test #3:  using the good old GDI ----------
	int MapModeResult = SetMapMode(hDC, MM_TEXT);			// MM_TEXT is equivalent to Unit::UnitPixel?
	HFONT TextFont3 = CreateFont(36, 0, 0, 0, FW_BOLD, false, false, false, ANSI_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH | FF_DONTCARE, L"Calibri");
	HGDIOBJ PrevFont = SelectObject(hDC, TextFont3);
	ABCFLOAT ABCCharData;
	BOOL RFlg = GetCharABCWidthsFloat(hDC, (UINT)'M', (UINT)'M', &ABCCharData); // Results: abcfA = 2.000; abcfB = 22.000; abcfC = 2.000

	//--- End of Test ---
	delete G;
}

GeneralRe: Measuring of Text with Multiple Fonts in One Single Line Pin
PaulB482-Nov-14 2:22
PaulB482-Nov-14 2:22 
GeneralRe: Measuring of Text with Multiple Fonts in One Single Line Pin
paul116713-Nov-14 22:17
paul116713-Nov-14 22:17 
QuestionImage editor control for asp.net Pin
Member 111274939-Oct-14 19:22
Member 111274939-Oct-14 19:22 
AnswerRe: Image editor control for asp.net Pin
Garth J Lancaster9-Oct-14 19:33
professionalGarth J Lancaster9-Oct-14 19:33 
QuestionPNG vs JPG Pin
V.11-Sep-14 19:46
professionalV.11-Sep-14 19:46 
AnswerRe: PNG vs JPG Pin
Peter_in_278011-Sep-14 20:51
professionalPeter_in_278011-Sep-14 20:51 
AnswerRe: PNG vs JPG Pin
Pete O'Hanlon11-Sep-14 21:01
mvePete O'Hanlon11-Sep-14 21:01 
AnswerRe: PNG vs JPG Pin
Chris Losinger2-Dec-14 4:31
professionalChris Losinger2-Dec-14 4:31 
QuestionBezier Curve issue Pin
pvpeng4-Jul-14 4:16
pvpeng4-Jul-14 4:16 
QuestionRe: Bezier Curve issue Pin
Richard Deeming4-Jul-14 4:39
mveRichard Deeming4-Jul-14 4:39 
AnswerRe: Bezier Curve issue Pin
Richard MacCutchan4-Jul-14 5:53
mveRichard MacCutchan4-Jul-14 5:53 
AnswerRe: Bezier Curve issue Pin
Bernhard Hiller13-Jul-14 21:58
Bernhard Hiller13-Jul-14 21:58 
QuestionHelp calculating a perpendicular line end point. Pin
Austin_Cpp28-Jun-14 10:58
Austin_Cpp28-Jun-14 10:58 
AnswerRe: Help calculating a perpendicular line end point. Pin
Yang Kok Wah29-Jun-14 0:33
Yang Kok Wah29-Jun-14 0:33 
GeneralRe: Help calculating a perpendicular line end point. Pin
Austin_Cpp1-Jul-14 18:41
Austin_Cpp1-Jul-14 18:41 
QuestionHow to write glutSwapBuffers() in SharpGL format? Pin
pvpeng27-Jun-14 11:05
pvpeng27-Jun-14 11:05 
QuestionSharpGL: how to add a solid object to a scene Pin
Member 1075894613-Jun-14 10:31
Member 1075894613-Jun-14 10:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.