# GlyphArrangement

**URL:** <https://forum.juce.com/t/glypharrangement/11074>\
**Category:** General JUCE discussion\
**Created:** [May 31, 2011, 11:02am UTC](https://forum.juce.com/t/glypharrangement/11074 "2011-05-31T11:02:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![solar3d](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/solar3d/32/135_2.png) [@solar3d](https://forum.juce.com/u/solar3d)\
**Post date:** [May 31, 2011, 11:02am UTC](https://forum.juce.com/t/glypharrangement/11074/1 "2011-05-31T11:02:13Z")

</div>

Dear Jules,

I nearly draw any of my text using GlyphArrangement::addCurtailedLineOfText because the text gets displayed inside  
a LCD display (sort of) where I create a path using GlyphArrangement::createPath with setUsingNonZeroWinding(false) to get this  
inverse font style.

That works quite well as long as the text to display does not contain " & ". This set of characters (space & space) causes  
the application to hang. I noticed that with my Filelistcomponent that shows of course the content of my disc.  
The crash actually happens when executing GlyphArrangement::createPath! As soon as I remove the two space bars  
from the Folder Alias name, then it works fine.

Folder Alias named: “Handbuecher & Informationen” -\> hangs  
Folder Alias named: “Handbuecher&Informationen” -\> works

This folder alias was created by the system, not manually.

I’ve attached a screen print of the debugging window if that helps…

Hope, I could explain it.

Thanks  
Joerg

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 31, 2011, 12:40pm UTC](https://forum.juce.com/t/glypharrangement/11074/2 "2011-05-31T12:40:27Z")

</div>

…but GlyphArrangement is used in _all_ text drawing - even if you don’t call it directly, the other functions use it internally. So if it fails on a seqeunce containing “space-ampersand-space”, then it’d be impossible to use draw that text anywhere. And I can’t reproduce the problem - can you provide some code that fails?

---

<div class="post-metadata">

**Author:** ![solar3d](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/solar3d/32/135_2.png) [@solar3d](https://forum.juce.com/u/solar3d)\
**Post date:** [May 31, 2011, 12:56pm UTC](https://forum.juce.com/t/glypharrangement/11074/3 "2011-05-31T12:56:38Z")

</div>

Here is the code I use in my LookAndFeel class:

```auto
void VCLookAndFeel::drawFileListRow(Graphics& g, int width, int height,
                                                          String const &filename,
                                                          bool isDirectory,
                                                          bool isItemSelected,
                                                          int itemIndex,
							  JK_ListBox* const listBox)
{
	Path p;
	Font myfont;
	GlyphArrangement glyphToDraw;

	g.setColour(Colours::black));

	float iconLeft = 0.75f * height;
	float iconWidth = 1.5f * height;
	float iconHeight = 0.9f * height;

	if (isItemSelected)
		p.addRectangle(0, 0, (float)(width), (float)(height));

	if (isDirectory)
	{
		//create folder icon
		p.addRoundedRectangle(iconLeft, 0.25f * iconHeight, 0.75f * iconWidth, 0.75f * iconHeight, 3.0f);
		p.addRoundedRectangle(iconLeft, 0.15f * iconHeight, 0.5f * iconWidth, 0.75f * iconHeight, 2.0f);
	}
	else
	{
		//create star icon for files
		Point <float> centre(0.4f * iconWidth, 0.5f * iconHeight);
		p.addStar(centre, 5, 0.2f * iconHeight, 0.45f * iconHeight, 0.0f);
	}

	myfont.setHeight(height * 0.8f);
	myfont.setBold(true);
	
	glyphToDraw.addCurtailedLineOfText(myfont, filename, iconLeft + iconWidth, iconHeight, width * 0.9f, true);
	
	glyphToDraw.createPath(p);

	p.setUsingNonZeroWinding(false);

	g.fillPath(p);
		
}
```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 31, 2011, 1:35pm UTC](https://forum.juce.com/t/glypharrangement/11074/4 "2011-05-31T13:35:16Z")

</div>

If you can give me a snippet of code I can paste straight into e.g. the juce demo which demonstrates it, then I’ll have a look.

---

<div class="post-metadata">

**Author:** ![solar3d](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/solar3d/32/135_2.png) [@solar3d](https://forum.juce.com/u/solar3d)\
**Post date:** [May 31, 2011, 1:48pm UTC](https://forum.juce.com/t/glypharrangement/11074/5 "2011-05-31T13:48:14Z")

</div>

Yes, I can but I think the following info are more important to isolate  
the problem. It seems to hang the application if there is an umlaut before  
space-ambersand-space in a String.

Did some test with different names for folder, tested with the FileListComponent- that is the result:

File name to draw “Jörg & Paul” -\> hangs  
File name to draw “Joerg & Paul” -\> works  
File name to draw “Jörg” -\> works

Do you still need the code snippet?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 31, 2011, 2:02pm UTC](https://forum.juce.com/t/glypharrangement/11074/6 "2011-05-31T14:02:17Z")

</div>

I’m very very busy today. I only have time to debug this if you make it very quick for me to reproduce it.

---

<div class="post-metadata">

**Author:** ![solar3d](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/solar3d/32/135_2.png) [@solar3d](https://forum.juce.com/u/solar3d)\
**Post date:** [May 31, 2011, 2:40pm UTC](https://forum.juce.com/t/glypharrangement/11074/7 "2011-05-31T14:40:35Z")

</div>

Here we go:

You can put the code into the ListBox::paintListBoxItem method and comment out  
the addFittedText you don’t want to debug.  
It is not my final code! I didn’t pay attention to any float conversions and stuff here, just for testing!

```auto
        Path p;
	Font myfont;
	GlyphArrangement textToDraw;

	g.setColour(Colours::black);
	
	myfont.setHeight(height * 0.8f);
	myfont.setBold(true);

	textToDraw.addFittedText(myfont, String("Jörg & Paul"), 
							 0, 0, width, height,
							 Justification::centredLeft, 1, 0.7f);
	
	textToDraw.addFittedText(myfont, String("Joerg & Paul"), 
							 0, 0, width, height,
							 Justification::centredLeft, 1, 0.7f);
	
	textToDraw.createPath(p);
	
	p.setUsingNonZeroWinding(false);

	g.fillPath(p);
```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 31, 2011, 2:58pm UTC](https://forum.juce.com/t/glypharrangement/11074/8 "2011-05-31T14:58:07Z")

</div>

Before I even try that, you’re creating a unicode string from an 8-bit ascii literal (didn’t it throw an assertion?). What happens if you use L"Jörg & Paul" instead?

---

<div class="post-metadata">

**Author:** ![solar3d](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/solar3d/32/135_2.png) [@solar3d](https://forum.juce.com/u/solar3d)\
**Post date:** [May 31, 2011, 8:44pm UTC](https://forum.juce.com/t/glypharrangement/11074/9 "2011-05-31T20:44:57Z")

</div>

You are right but as I said, it is actually used to paint listbox items of the FileListComponent  
and it doesn’t even work with File::getFileName() because it returns a String!  
If there is a conversion in between from unicode to whatsoever, you should then rename  
addCurtailedLineOfText to something else w/o “Text” at the end because g.drawText works  
and GlyphArrangement::addCurtailedLineOfText doesn’t!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 31, 2011, 9:06pm UTC](https://forum.juce.com/t/glypharrangement/11074/10 "2011-05-31T21:06:28Z")

</div>

Well, I tried your code snippet on Windows and Mac and there were no problems…

---

<div class="post-metadata">

**Author:** ![solar3d](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/solar3d/32/135_2.png) [@solar3d](https://forum.juce.com/u/solar3d)\
**Post date:** [June 1, 2011, 6:20am UTC](https://forum.juce.com/t/glypharrangement/11074/11 "2011-06-01T06:20:23Z")

</div>

You won’t believe it, Jules, but updateing to the latest GIT curred this issue.

Jörg

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 1, 2011, 7:46am UTC](https://forum.juce.com/t/glypharrangement/11074/12 "2011-06-01T07:46:15Z")

</div>

Sigh… If only people would bother trying the latest version before reporting problems, it’d save me a lot of wasted time.

---

<div class="post-metadata">

**Author:** ![solar3d](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/solar3d/32/135_2.png) [@solar3d](https://forum.juce.com/u/solar3d)\
**Post date:** [June 1, 2011, 8:21am UTC](https://forum.juce.com/t/glypharrangement/11074/13 "2011-06-01T08:21:51Z")

</div>

Yeap, that is what I almost always do except this time but to be perfectly honest,  
I didn’t expect, that updating from 1.53.91 to 1.53.93 has such an impact especially if  
there is nothing descibed in the change log that point me to a bug fix for this  
particular issue and you probably would instantly tell me that there were some changes.

The only difference I can think of is that the last time when I updated  
to the latest GIT using Introjucer, I did “add and overwrite existing files” but today,  
I replaced the entire juce folder instead. Maybe there went something wrong during  
the last udate…

Anyway, it works now (okay, it doesn’t show the affected file name a propper way  
as it just replaces the ambersand by a space) but that is also if I use the original  
FileListComponent, so it just a minor issue for me…

Thanks,  
Joerg
