Sync changes from upstream repository

Co-authored-by: Andrew Le Bihan <andy@mcneel.com>
Co-authored-by: chuck <chuck@mcneel.com>
Co-authored-by: Dale Fugier <dale@mcneel.com>
Co-authored-by: Dale Lear <dalelear@mcneel.com>
Co-authored-by: David Eränen <david.eranen@mcneel.com>
Co-authored-by: Greg Arden <greg@mcneel.com>
Co-authored-by: John Croudy <john.croudy@mcneel.com>
Co-authored-by: Lowell Walmsley <lowell@mcneel.com>
Co-authored-by: Nathan Letwory <nathan@mcneel.com>
Co-authored-by: piac <giulio@mcneel.com>
Co-authored-by: Steve Baer <steve@mcneel.com>
Co-authored-by: Tim Hemmelman <tim@mcneel.com>
This commit is contained in:
Bozo The Builder
2020-03-12 09:00:26 -07:00
parent acbc998a03
commit 01cdb463e6
50 changed files with 5774 additions and 1857 deletions

View File

@@ -249,4 +249,67 @@ const ON_Font* ON_TextContent::FirstCharFont() const
return &ON_Font::Default;
}
//static
bool ON_TextContent::GetRichTextFontTable(
const ON_wString rich_text,
ON_ClassArray< ON_wString >& font_table
)
{
int table_pos = rich_text.Find(L"\\fonttbl");
if (table_pos < 0)
return false;
const wchar_t* rtf = rich_text.Array();
int open = 1;
int table_len = 0;
int len = rich_text.Length();
for (int i = table_pos + 8; i < len && open > 0; i++)
{
if (L'{' == rich_text[i])
{
open++;
}
else if (L'}' == rich_text[i])
{
open--;
table_len = i;
}
}
for (int i = table_pos + 8; i < table_len; i++)
{
int font_pos = rich_text.Find(L"\\f", i);
if (font_pos > i)
{
for (int j = font_pos + 2; j < table_len; j++)
{
if (rtf[j] == L' ')
{
for (int si = 0; si + j < table_len; si++)
{
if (rich_text[si + j] != L' ')
{
j += si;
break;
}
}
for (int ni = 1; ni + j < table_len; ni++)
{
if (rtf[ni + j] == L';' || rtf[ni + j] == L'}')
{
font_table.AppendNew() = rich_text.SubString(j, ni);
i = ni + j;
j = len;
break;
}
}
}
}
}
}
return true;
}
//--------------------------------------------------------------------